00001 package DisplayGUI;
00002 import java.awt.*;
00003 import java.awt.event.*;
00004 import javax.swing.*;
00005 import javax.swing.event.*;
00006
00007 import java.util.*;
00008
00009
00010 public class SelectorPane extends JPanel implements ListSelectionListener,displayParams,SCTInfo,TestDataInfo {
00011 private JList displayParameters, sctViews, mouseOptions;
00012 private JSplitPane splitPane;
00013 private String[] defaultString = {"...None"};
00014 private String[] resultStatusString = {"Overall Status"};
00015 private String[] defectCountString = {"Total Count"};
00016 private String[][] displayParameterStrings = {
00017 {},
00018 {"Module Group"},
00019 {"Raw Data","Fitted Data","Analysed Data"},
00020 {},
00021 {},
00022 {},
00023 {},
00024 {"Result Status","IVScan Data","DCS Conditions"},
00025 {"Module Probe"}
00026 };
00027 private String[][] mouseOptionStrings = {
00028 {},
00029 {"Group 0","Group 1","Group 2","Group 3","Group 4","Group 5","Group 6","Group 7"},
00030 {"List Data objects"},
00031 {},
00032 {},
00033 {},
00034 {"Current Conditions"},
00035 {},
00036 {"Link 0","Link 1"}
00037 };
00038 private gui guiControl;
00039
00040 private boolean selectionListenerIsActive=true;
00041
00042 private Map viewMap;
00043
00044
00045 public SelectorPane(gui parent) {
00046 guiControl=parent;
00047
00048 buildViewMap();
00049
00050 sctViews = new JList(SCTViewNames);
00051 sctViews.setFont(displayScaleFont);
00052 sctViews.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
00053 int viewIndex=0;
00054 try {
00055 Preferences.PreferencesInterface prefs = Preferences.PreferencesInterface.getInstance();
00056 String preferredView = prefs.getPreference(Preferences.PreferencesInterface.SCT_VIEW);
00057 if(!preferredView.equals(Preferences.PreferencesInterface.unDefinedString)) {
00058 Integer i1 = (Integer)viewMap.get(preferredView);
00059 if(i1!=null) viewIndex = i1.intValue();
00060 }
00061 }catch(Exception e){}
00062 sctViews.setSelectedIndex(viewIndex);
00063 sctViews.addListSelectionListener(this);
00064
00065 JScrollPane viewScrollPane = new JScrollPane(sctViews);
00066 JLabel header2 = new JLabel("Views");
00067 header2.setForeground(darkBlueColor);
00068 header2.setBackground(backgroundColor);
00069 header2.setFont(displayTextFont);
00070 viewScrollPane.setColumnHeaderView(header2);
00071 viewScrollPane.getColumnHeader().setBackground(backgroundColor);
00072 viewScrollPane.setBorder(new javax.swing.border.EmptyBorder(0,0,0,0));
00073 viewScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
00074 viewScrollPane.getVerticalScrollBar().setBackground(backgroundColor);
00075
00076 displayParameters = new JList();
00077 displayParameters.setFont(displayScaleFont);
00078 displayParameters.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
00079
00080 displayParameters.addListSelectionListener(this);
00081 JScrollPane paramScrollPane = new JScrollPane(displayParameters);
00082 JLabel header1 = new JLabel("Display Data");
00083 header1.setForeground(darkBlueColor);
00084 header1.setBackground(backgroundColor);
00085 header1.setFont(displayTextFont);
00086 paramScrollPane.setColumnHeaderView(header1);
00087 paramScrollPane.getColumnHeader().setBackground(backgroundColor);
00088 paramScrollPane.setBorder(new javax.swing.border.EmptyBorder(0,0,0,0));
00089
00090 paramScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
00091 paramScrollPane.getVerticalScrollBar().setBackground(backgroundColor);
00092
00093 mouseOptions = new JList();
00094 mouseOptions.setFont(displayScaleFont);
00095 mouseOptions.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
00096 mouseOptions.addListSelectionListener(this);
00097 JScrollPane mouseScrollPane = new JScrollPane(mouseOptions);
00098 JLabel header3 = new JLabel("Options");
00099 header3.setForeground(darkBlueColor);
00100 header3.setBackground(backgroundColor);
00101 header3.setFont(displayTextFont);
00102 mouseScrollPane.setColumnHeaderView(header3);
00103 mouseScrollPane.getColumnHeader().setBackground(backgroundColor);
00104 mouseScrollPane.setBorder(new javax.swing.border.EmptyBorder(0,0,0,0));
00105 mouseScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
00106 mouseScrollPane.getVerticalScrollBar().setBackground(backgroundColor);
00107
00108
00109 JSplitPane topSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT, paramScrollPane, mouseScrollPane);
00110 topSplit.setDividerSize(8);
00111 topSplit.setDividerLocation(0.50);
00112 topSplit.setBorder(new javax.swing.border.EmptyBorder(0,0,0,0));
00113
00114 splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
00115 topSplit, viewScrollPane);
00116
00117 splitPane.setDividerLocation(0.65);
00118 splitPane.setDividerSize(8);
00119 splitPane.setBorder(new javax.swing.border.EmptyBorder(0,0,0,0));
00120
00121
00122 Dimension minimumSize = new Dimension(95, 16);
00123 paramScrollPane.setMinimumSize(minimumSize);
00124 mouseScrollPane.setMinimumSize(minimumSize);
00125 viewScrollPane.setMinimumSize(minimumSize);
00126
00127
00128 splitPane.setPreferredSize(new Dimension(95,yOffSet+56*boxHeight));
00129 add(splitPane);
00130 setBackground(backgroundColor);
00131 setBorder(new javax.swing.border.TitledBorder(null, "Display", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 0, 11), new java.awt.Color(0, 0, 153)));
00132
00133
00134
00135
00136
00137 }
00138 public void initParamList() {
00139
00140 selectionListenerIsActive=false;
00141
00142 int displayType = guiControl.displayStatus.getStatus();
00143 boolean noParameters=true, noOptions=true;
00144 int previousParameterSelection = getDisplayParameterIndex();
00145 int previousOptionSelection = getMouseClickIndex();
00146 TestSelection testSelection = guiControl.tablesDisplayPane.getTestSelection();
00147 int testIndex = (testSelection!=null) ? testSelection.getTestIndex() : -1;
00148
00149 if(displayType==DisplayStatus.UNDEFINED) return;
00150 switch(displayType) {
00151 case DisplayStatus.MODULE_GROUP_SELECTION:
00152 case DisplayStatus.IS_MONITOR:
00153 displayParameters.setListData(displayParameterStrings[displayType]);
00154 mouseOptions.setListData(mouseOptionStrings[displayType]);
00155 noParameters=false;
00156 noOptions=false;
00157 break;
00158 case DisplayStatus.TEST_DATA:
00159 case DisplayStatus.SCTDB_DATA:
00160 case DisplayStatus.SCTDB_RODDAQ_DATA:
00161 if(testIndex!=-1 && testIndex!=TEST_DEFAULT) {
00162 displayParameters.setListData(testParameters[testIndex]);
00163 noParameters=false;
00164 switch(previousParameterSelection) {
00165 case 0:
00166 case -1:
00167 mouseOptions.setListData(resultStatusString);
00168 noOptions=false;
00169 break;
00170 case 1:
00171 case 2:
00172 mouseOptions.setListData(defectCountString);
00173 noOptions=false;
00174 break;
00175 case 3:
00176 mouseOptions.setListData(dcsOptions);
00177 noOptions=false;
00178 break;
00179 default:
00180 if(testIndex==TEST_RXTHRESHOLD || testIndex==TEST_RXTHRESHOLDBASEDONCONFIGREGISTER ||testIndex==TEST_RXDELAY) mouseOptions.setListData(linkOptions);
00181 else mouseOptions.setListData(chipOptions);
00182 noOptions=false;
00183 }
00184 }
00185
00186 break;
00187 case DisplayStatus.DCS_DATA:
00188 displayParameters.setListData(dcsOptions);
00189 noParameters=false;
00190 mouseOptions.setListData(mouseOptionStrings[displayType]);
00191 noOptions=false;
00192 break;
00193 case DisplayStatus.IV_DATA:
00194 IVTestSelection iv = guiControl.tablesDisplayPane.getIVTestSelection();
00195 if(iv==null) {
00196 displayParameters.setListData(defaultString);
00197 noParameters=true;
00198 mouseOptions.setListData(defaultString);
00199 noOptions=true;
00200 }
00201 else {
00202 displayParameters.setListData(displayParameterStrings[displayType]);
00203 noParameters=false;
00204 switch(previousParameterSelection) {
00205 case 0:
00206 case -1:
00207 mouseOptions.setListData(resultStatusString);
00208 noOptions=false;
00209 break;
00210 case 1:
00211 mouseOptions.setListData(iv.getVList());
00212 noOptions=false;
00213 break;
00214 case 2:
00215 mouseOptions.setListData(dcsOptions);
00216 noOptions=false;
00217 break;
00218 }
00219 }
00220 break;
00221 case DisplayStatus.PROBE_DATA:
00222 displayParameters.setListData(displayParameterStrings[displayType]);
00223 noParameters=false;
00224 mouseOptions.setListData(mouseOptionStrings[displayType]);
00225 noOptions=false;
00226 break;
00227
00228 case DisplayStatus.UNDEFINED:
00229 default:
00230 displayParameters.setListData(defaultString);
00231 mouseOptions.setListData(defaultString);
00232 }
00233
00234 int numParameters = displayParameters.getModel().getSize();
00235 int selectionIndex=0;
00236
00237 if(numParameters>0) {
00238 if(previousParameterSelection<numParameters && previousParameterSelection>=0) selectionIndex=previousParameterSelection;
00239 else if(previousParameterSelection>=numParameters) selectionIndex =displayParameters.getLastVisibleIndex();
00240 }
00241 displayParameters.setSelectedIndex(selectionIndex);
00242
00243 numParameters = mouseOptions.getModel().getSize();
00244 selectionIndex=0;
00245 if(numParameters>0) {
00246 if(previousOptionSelection<numParameters && previousOptionSelection>=0) selectionIndex= previousOptionSelection;
00247 else if(previousOptionSelection>=numParameters) selectionIndex = mouseOptions.getLastVisibleIndex();
00248 }
00249 mouseOptions.setSelectedIndex(selectionIndex);
00250
00251 if(noParameters) displayParameters.setListData(defaultString);
00252 if(noOptions) mouseOptions.setListData(defaultString);
00253 setVisible(true);
00254 selectionListenerIsActive=true;
00255 }
00256 public String getIVParameter() {
00257 if(getDisplayParameterIndex()==0) return "Result Status";
00258 return getOption();
00259 }
00260
00261 public int getDisplayParameterIndex() {
00262 return displayParameters.getSelectedIndex();
00263 }
00264 public int getMouseClickIndex() {
00265 return mouseOptions.getSelectedIndex();
00266 }
00267 public void setMouseClickIndex(int row) {
00268 mouseOptions.setSelectedIndex(row);
00269 }
00270 public int getViewIndex() {
00271 return sctViews.getSelectedIndex();
00272 }
00273 public String getOption() {
00274 if(getMouseClickIndex()==-1) return null;
00275 return (String)mouseOptions.getSelectedValue();
00276 }
00277 public String getDisplayParameter() {
00278 if(getDisplayParameterIndex()==-1) return null;
00279 return (String)displayParameters.getSelectedValue();
00280 }
00281
00282 public JSplitPane getSplitPane() {
00283 return splitPane;
00284 }
00285
00286 public void valueChanged(ListSelectionEvent e) {
00287
00288 if (e.getValueIsAdjusting())
00289 return;
00290
00291 JList theList = (JList)e.getSource();
00292 if (theList.isSelectionEmpty()) {
00293
00294 } else {
00295 if(!selectionListenerIsActive) {
00296
00297 return;
00298 }
00299 int index = theList.getSelectedIndex();
00300 if(theList==sctViews) {
00301 guiControl.displayPane.setSCTView(index);
00302 return;
00303 }
00304 switch(guiControl.displayStatus.getStatus()) {
00305 case DisplayStatus.MODULE_GROUP_SELECTION:
00306 guiControl.tablesDisplayPane.updateTables(true);
00307 break;
00308 case DisplayStatus.IS_MONITOR:
00309
00310
00311 guiControl.tablesDisplayPane.checkForRetrievedObjects();
00312 guiControl.colorScalePane.setColorScale();
00313 guiControl.displayPane.setDisplayColors();
00314 guiControl.displayPane.refreshDisplay();
00315 ModuleCell lastClickedCell;
00316 if((lastClickedCell=guiControl.displayPane.getLastClickedCell())!=null) guiControl.tablesDisplayPane.listISObjects(lastClickedCell);
00317 break;
00318 case DisplayStatus.TEST_DATA:
00319 case DisplayStatus.SCTDB_DATA:
00320 case DisplayStatus.SCTDB_RODDAQ_DATA:
00321 if(theList==displayParameters) initParamList();
00322 guiControl.colorScalePane.setColorScale();
00323 guiControl.displayPane.setDisplayColors();
00324 guiControl.displayPane.refreshDisplay();
00325 guiControl.tablesDisplayPane.listTestResults();
00326 break;
00327 case DisplayStatus.DCS_DATA:
00328 if(theList==displayParameters) {
00329 guiControl.isInterface.unsubscribe();
00330 guiControl.isInterface.subscribe();
00331 }
00332 guiControl.colorScalePane.setColorScale();
00333 guiControl.displayPane.setDisplayColors();
00334 guiControl.displayPane.refreshDisplay();
00335 guiControl.tablesDisplayPane.listTestResults();
00336 break;
00337 case DisplayStatus.IV_DATA:
00338 case DisplayStatus.PROBE_DATA:
00339 if(theList==displayParameters) initParamList();
00340 guiControl.colorScalePane.setColorScale();
00341 guiControl.displayPane.setDisplayColors();
00342 guiControl.displayPane.refreshDisplay();
00343 guiControl.tablesDisplayPane.listTestResults();
00344 break;
00345 default:
00346 }
00347
00348 }
00349 }
00350 private void buildViewMap() {
00351 viewMap = new HashMap();
00352 for(int i=0;i<SCTViewNames.length;i++) viewMap.put(SCTViewNames[i], new Integer(i));
00353 }
00354 public void setSCTView(String value) {
00355 if(!viewMap.containsKey(value)) return;
00356 sctViews.setSelectedIndex(((Integer)viewMap.get(value)).intValue());
00357 }
00358
00359
00360 }