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