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 mouseOptions.setListData(defectCountString);
00169 noOptions=false;
00170 break;
00171 case 2:
00172 mouseOptions.setListData(dcsOptions);
00173 noOptions=false;
00174 break;
00175 default:
00176 if(testIndex==TEST_RXTHRESHOLD || testIndex==TEST_RXDELAY) mouseOptions.setListData(linkOptions);
00177 else mouseOptions.setListData(chipOptions);
00178 noOptions=false;
00179 }
00180 }
00181
00182 break;
00183 case DisplayStatus.DCS_DATA:
00184 displayParameters.setListData(dcsOptions);
00185 noParameters=false;
00186 mouseOptions.setListData(mouseOptionStrings[displayType]);
00187 noOptions=false;
00188 break;
00189 case DisplayStatus.IV_DATA:
00190 IVTestSelection iv = guiControl.tablesDisplayPane.getIVTestSelection();
00191 if(iv==null) {
00192 displayParameters.setListData(defaultString);
00193 noParameters=true;
00194 mouseOptions.setListData(defaultString);
00195 noOptions=true;
00196 }
00197 else {
00198 displayParameters.setListData(displayParameterStrings[displayType]);
00199 noParameters=false;
00200 switch(previousParameterSelection) {
00201 case 0:
00202 case -1:
00203 mouseOptions.setListData(resultStatusString);
00204 noOptions=false;
00205 break;
00206 case 1:
00207 mouseOptions.setListData(iv.getVList());
00208 noOptions=false;
00209 break;
00210 case 2:
00211 mouseOptions.setListData(dcsOptions);
00212 noOptions=false;
00213 break;
00214 }
00215 }
00216 break;
00217
00218 case DisplayStatus.UNDEFINED:
00219 default:
00220 displayParameters.setListData(defaultString);
00221 mouseOptions.setListData(defaultString);
00222 }
00223
00224 int numParameters = displayParameters.getModel().getSize();
00225 int selectionIndex=0;
00226
00227 if(numParameters>0) {
00228 if(previousParameterSelection<numParameters && previousParameterSelection>=0) selectionIndex=previousParameterSelection;
00229 else if(previousParameterSelection>=numParameters) selectionIndex =displayParameters.getLastVisibleIndex();
00230 }
00231 displayParameters.setSelectedIndex(selectionIndex);
00232
00233 numParameters = mouseOptions.getModel().getSize();
00234 selectionIndex=0;
00235 if(numParameters>0) {
00236 if(previousOptionSelection<numParameters && previousOptionSelection>=0) selectionIndex= previousOptionSelection;
00237 else if(previousOptionSelection>=numParameters) selectionIndex = mouseOptions.getLastVisibleIndex();
00238 }
00239 mouseOptions.setSelectedIndex(selectionIndex);
00240
00241 if(noParameters) displayParameters.setListData(defaultString);
00242 if(noOptions) mouseOptions.setListData(defaultString);
00243 setVisible(true);
00244 selectionListenerIsActive=true;
00245 }
00246 public String getIVParameter() {
00247 if(getDisplayParameterIndex()==0) return "Result Status";
00248 return getOption();
00249 }
00250
00251 public int getDisplayParameterIndex() {
00252 return displayParameters.getSelectedIndex();
00253 }
00254 public int getMouseClickIndex() {
00255 return mouseOptions.getSelectedIndex();
00256 }
00257 public void setMouseClickIndex(int row) {
00258 mouseOptions.setSelectedIndex(row);
00259 }
00260 public int getViewIndex() {
00261 return sctViews.getSelectedIndex();
00262 }
00263 public String getOption() {
00264 if(getMouseClickIndex()==-1) return null;
00265 return (String)mouseOptions.getSelectedValue();
00266 }
00267 public String getDisplayParameter() {
00268 if(getDisplayParameterIndex()==-1) return null;
00269 return (String)displayParameters.getSelectedValue();
00270 }
00271
00272 public JSplitPane getSplitPane() {
00273 return splitPane;
00274 }
00275
00276 public void valueChanged(ListSelectionEvent e) {
00277
00278 if (e.getValueIsAdjusting())
00279 return;
00280
00281 JList theList = (JList)e.getSource();
00282 if (theList.isSelectionEmpty()) {
00283
00284 } else {
00285 if(!selectionListenerIsActive) {
00286
00287 return;
00288 }
00289 int index = theList.getSelectedIndex();
00290 if(theList==sctViews) {
00291 guiControl.displayPane.setSCTView(index);
00292 return;
00293 }
00294 switch(guiControl.displayStatus.getStatus()) {
00295 case DisplayStatus.MODULE_GROUP_SELECTION:
00296 guiControl.tablesDisplayPane.updateTables(true);
00297 break;
00298 case DisplayStatus.IS_MONITOR:
00299
00300
00301 guiControl.tablesDisplayPane.checkForRetrievedObjects();
00302 guiControl.colorScalePane.setColorScale();
00303 guiControl.displayPane.setDisplayColors();
00304 guiControl.displayPane.refreshDisplay();
00305 ModuleCell lastClickedCell;
00306 if((lastClickedCell=guiControl.displayPane.getLastClickedCell())!=null) guiControl.tablesDisplayPane.listISObjects(lastClickedCell);
00307 break;
00308 case DisplayStatus.TEST_DATA:
00309 case DisplayStatus.SCTDB_DATA:
00310 case DisplayStatus.SCTDB_RODDAQ_DATA:
00311 if(theList==displayParameters) initParamList();
00312 guiControl.colorScalePane.setColorScale();
00313 guiControl.displayPane.setDisplayColors();
00314 guiControl.displayPane.refreshDisplay();
00315 guiControl.tablesDisplayPane.listTestResults();
00316 break;
00317 case DisplayStatus.DCS_DATA:
00318
00319
00320
00321
00322 guiControl.colorScalePane.setColorScale();
00323 guiControl.displayPane.setDisplayColors();
00324 guiControl.displayPane.refreshDisplay();
00325 guiControl.tablesDisplayPane.listTestResults();
00326 break;
00327 case DisplayStatus.IV_DATA:
00328 if(theList==displayParameters) initParamList();
00329 guiControl.colorScalePane.setColorScale();
00330 guiControl.displayPane.setDisplayColors();
00331 guiControl.displayPane.refreshDisplay();
00332 guiControl.tablesDisplayPane.listTestResults();
00333 break;
00334 default:
00335 }
00336
00337 }
00338 }
00339 private void buildViewMap() {
00340 viewMap = new HashMap();
00341 for(int i=0;i<SCTViewNames.length;i++) viewMap.put(SCTViewNames[i], new Integer(i));
00342 }
00343 public void setSCTView(String value) {
00344 if(!viewMap.containsKey(value)) return;
00345 sctViews.setSelectedIndex(((Integer)viewMap.get(value)).intValue());
00346 }
00347
00348
00349 }