Main Page | Packages | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

TablesDisplayPane.java

00001 /*
00002  * TablesDisplayPane.java
00003  *
00004  * Created on 23 June 2003, 15:43
00005  */
00006 
00007 package DisplayGUI;
00008 import javax.swing.JTable;
00009 import javax.swing.event.*;
00010 import javax.swing.ListSelectionModel;
00011 import java.awt.event.KeyListener;
00012 import java.awt.event.KeyEvent;
00013 import javax.swing.event.ListSelectionListener;
00014 import javax.swing.event.ListSelectionEvent;
00015 import javax.swing.JOptionPane;
00016 import java.util.Vector;
00017 import java.util.Hashtable;
00018 import java.util.Collections;
00019 import Sct_CalibrationController.TestData;
00020 import GuiComponents.System.*;
00025 public class TablesDisplayPane extends javax.swing.JPanel implements TestDataInfo,TableModelListener,ListSelectionListener,displayParams {
00026     gui guiControl;
00027     public javax.swing.JScrollPane jScrollPane1;
00028     private javax.swing.JScrollPane jScrollPane2;
00029     public javax.swing.JLabel table1Title;
00030     public javax.swing.JLabel table2Title;
00031     guiTableAdapter[] resultTable = new guiTableAdapter[2];
00032     JTable[] table = new JTable[2];
00033     Vector[] objectNames = new Vector[2];
00034     ListSelectionModel[] rowSM = new ListSelectionModel[2];
00035     String table1,table2;
00036     boolean selectionListenerIsActive=true;
00037     private GuiComponents.System.ISInterface is;
00038 
00039     private TestSelection testSelection;
00040     private IVTestSelection ivTestSelection;
00041 
00042     public TablesDisplayPane(gui parent) {
00043         guiControl=parent;
00044         testSelection=null;
00045         ivTestSelection=null;
00046         is = GuiComponents.System.ISInterface.getInstance();
00047         for(int i=0;i<2;i++) {
00048           resultTable[i] = new guiTableAdapter();
00049           resultTable[i].addTableModelListener(this);
00050           table[i] = new JTable(resultTable[i]);
00051           table[i].setFont(tableFont);
00052           rowSM[i] = table[i].getSelectionModel();
00053           rowSM[i].addListSelectionListener(this);
00054         }
00055 
00056         table[0].setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
00057         table[1].setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
00058 
00059         table1 = null;
00060         table2 = null;
00061 
00062         initComponents();
00063 
00064         table[0].addMouseListener(new tables0MouseAdapter());  // popup menu on second table only
00065         table[1].addMouseListener(new tables1MouseAdapter());  // popup menu on second table only
00066         setBorder(new javax.swing.border.TitledBorder(null, "Data", 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)));
00067  
00068     }
00069     
00070     private void initComponents() {
00071         java.awt.GridBagConstraints gridBagConstraints;
00072 
00073         jScrollPane1 = new javax.swing.JScrollPane(table[0]);
00074         table1Title = new javax.swing.JLabel();
00075         jScrollPane2 = new javax.swing.JScrollPane(table[1]);
00076         table2Title = new javax.swing.JLabel();
00077 
00078         setLayout(new java.awt.GridBagLayout());
00079 
00080         setBackground(new java.awt.Color(255, 255, 255));
00081         jScrollPane1.setBackground(new java.awt.Color(255, 255, 255));
00082         jScrollPane1.setBorder(new javax.swing.border.BevelBorder(javax.swing.border.BevelBorder.LOWERED));
00083         jScrollPane1.setMinimumSize(new java.awt.Dimension(300, 150));
00084         jScrollPane1.setPreferredSize(new java.awt.Dimension(300, 200));
00085         gridBagConstraints = new java.awt.GridBagConstraints();
00086         gridBagConstraints.gridx = 0;
00087         gridBagConstraints.gridy = 1;
00088         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
00089         gridBagConstraints.ipadx = 2;
00090         gridBagConstraints.ipady = 4;
00091         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
00092         gridBagConstraints.weighty = 0.4;
00093         add(jScrollPane1, gridBagConstraints);
00094 
00095         table1Title.setFont(new java.awt.Font("Arial", 0, 12));
00096         table1Title.setForeground(new java.awt.Color(51, 0, 153));
00097         table1Title.setText("Table 1");
00098         gridBagConstraints = new java.awt.GridBagConstraints();
00099         gridBagConstraints.gridx = 0;
00100         gridBagConstraints.gridy = 0;
00101         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
00102         gridBagConstraints.weighty = 0.05;
00103         add(table1Title, gridBagConstraints);
00104 
00105         jScrollPane2.setBorder(new javax.swing.border.BevelBorder(javax.swing.border.BevelBorder.LOWERED));
00106         jScrollPane2.setMinimumSize(new java.awt.Dimension(300, 150));
00107         jScrollPane2.setPreferredSize(new java.awt.Dimension(300, 200));
00108         gridBagConstraints = new java.awt.GridBagConstraints();
00109         gridBagConstraints.gridx = 0;
00110         gridBagConstraints.gridy = 3;
00111         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
00112         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
00113         gridBagConstraints.weighty = 0.4;
00114         add(jScrollPane2, gridBagConstraints);
00115 
00116         table2Title.setFont(new java.awt.Font("Arial", 0, 12));
00117         table2Title.setForeground(new java.awt.Color(51, 0, 153));
00118         table2Title.setText("Table 2");
00119         gridBagConstraints = new java.awt.GridBagConstraints();
00120         gridBagConstraints.gridx = 0;
00121         gridBagConstraints.gridy = 2;
00122         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
00123         gridBagConstraints.weighty = 0.05;
00124         add(table2Title, gridBagConstraints);
00125 
00126         jScrollPane1.addMouseListener(new tables0MouseAdapter());  // popup menu on second table only
00127         jScrollPane2.addMouseListener(new tables1MouseAdapter());  // popup menu on second table only
00128 
00129     }//GEN-END:initComponents
00130   
00131     public java.awt.Insets getInsets() {
00132         return new java.awt.Insets(10,10,10, 10);
00133     }
00134     
00135     public void tableChanged(javax.swing.event.TableModelEvent e) {
00136         table1Title.setText((table1==null) ? "" : table1+" : "+Integer.toString(resultTable[0].getRowCount()));
00137         table2Title.setText((table2==null) ? "" : table2+" : "+Integer.toString(resultTable[1].getRowCount()));
00138     }
00139     public void setTableTitles(String title1, String title2) {
00140         table1=title1;
00141         table2=title2;
00142         table1Title.setText((title1==null) ? "" : table1+" : "+Integer.toString(resultTable[0].getRowCount()));
00143         table2Title.setText((title2==null) ? "" : table2+" : "+Integer.toString(resultTable[1].getRowCount()));        
00144     }
00145     public int getRowCount(int table) {
00146         if(resultTable[table]==null) return 0;
00147         return resultTable[table].getRowCount();
00148         }
00149     public void setTable1Title(String title) {
00150         table2 = new String(title);
00151         table2Title.setText(table2+" : "+Integer.toString(resultTable[1].getRowCount()));        
00152     }  
00153     public void refresh(int thisModuleGroup, java.util.Vector tableContents) {
00154         selectionListenerIsActive=false;
00155         resultTable[thisModuleGroup].reTable(tableContents);
00156         selectionListenerIsActive=true;
00157         javax.swing.table.TableColumn column = table[thisModuleGroup].getColumnModel().getColumn(0);
00158         column.setPreferredWidth(100);
00159         }
00160     public void refresh(Vector[] tableContents, int table0RowSelect, int table1RowSelect) {
00161         selectionListenerIsActive=false;
00162         
00163         for(int i=0;i<2;i++) {
00164                resultTable[i].reTable(tableContents[i]);
00165                 javax.swing.table.TableColumn column = table[i].getColumnModel().getColumn(0);
00166                 column.setPreferredWidth(110);
00167                 }
00168         selectionListenerIsActive=true;
00169         if(table0RowSelect!=-1) rowSM[0].setSelectionInterval(table0RowSelect,table0RowSelect);
00170         if(table1RowSelect!=-1) rowSM[1].setSelectionInterval(table1RowSelect,table1RowSelect);
00171         }
00172     public void refresh1(Vector newObjectNames, Vector tableContents, String title) {
00173         int oldSelect = rowSM[1].getMinSelectionIndex();
00174         objectNames[1] = new Vector(newObjectNames);
00175         selectionListenerIsActive=false;
00176         resultTable[1].reTable(tableContents);
00177         if(oldSelect>=0 && oldSelect<=tableContents.size()-1) rowSM[1].setSelectionInterval(oldSelect,oldSelect);
00178         selectionListenerIsActive=true;
00179         javax.swing.table.TableColumn column = table[1].getColumnModel().getColumn(0);
00180         column.setPreferredWidth(110);       
00181         setTable1Title(title); 
00182         }
00183     public void refresh1(Vector tableContents, String title) {   // no update of objectNames[1]
00184         selectionListenerIsActive=false;
00185         int oldSelect = rowSM[1].getMinSelectionIndex();
00186         resultTable[1].reTable(tableContents);
00187         if(oldSelect>=0 && oldSelect<=tableContents.size()-1) rowSM[1].setSelectionInterval(oldSelect,oldSelect);
00188         selectionListenerIsActive=true;
00189         javax.swing.table.TableColumn column = table[1].getColumnModel().getColumn(0);
00190         column.setPreferredWidth(110);       
00191         setTable1Title(title); 
00192         }
00193 
00194 
00195     public String getSelectedObject() {
00196        return getSelectedObject(1);
00197        }
00198 
00199     public String getSelectedObject(int tableIndex) {
00200         int selectedRow = rowSM[tableIndex].getMinSelectionIndex();
00201         if(objectNames[tableIndex]==null) return null;
00202         int arraySize = objectNames[tableIndex].size();
00203         if(selectedRow==-1 || arraySize==0 || selectedRow>arraySize-1) return null;
00204         return (String)objectNames[tableIndex].elementAt(selectedRow);
00205         }
00206     public String getSelectedSerialNo() {
00207         int selectedRow = rowSM[1].getMinSelectionIndex();
00208         if(selectedRow==-1) return null;
00209         return (String)resultTable[1].getValueAt(selectedRow,0);
00210         }
00211     public void setSelectedSerialNo(String sn, boolean changeSelection) {
00212         int is = rowSM[1].getMinSelectionIndex();
00213         if(is!=-1 && !changeSelection) return;
00214         for(int i=0;i<resultTable[1].getRowCount();i++) {
00215            if(sn.equals((String)resultTable[1].getValueAt(i,0))) {
00216                        rowSM[1].setSelectionInterval(i,i); 
00217                        break;
00218                        }
00219            }
00220 
00221        }
00222               
00223 
00224     public int getSelectedTest() {
00225         return rowSM[0].getMinSelectionIndex();
00226         }
00227     public Vector getTestControlObjectNames() {
00228         return objectNames[0];
00229        }
00230     public String getTestControlObjectName() {
00231         int selectedRow = rowSM[0].getMinSelectionIndex();
00232         if(selectedRow==-1) return null;
00233         if(objectNames[0]==null) return null;
00234         if(selectedRow>=objectNames[0].size()) return null;
00235         return (String)objectNames[0].elementAt(selectedRow);
00236         }
00237 
00238     
00240     public void valueChanged(ListSelectionEvent e) {
00241               if(!selectionListenerIsActive) {
00242 //                         selectionListenerIsActive=true;
00243                          return;
00244                          }
00245 
00246               if (e.getValueIsAdjusting()) return;
00247 
00248               ListSelectionModel lsm = (ListSelectionModel)e.getSource();
00249               int thisTable = (lsm==rowSM[0]) ? 0 : 1;
00250         
00251               if (lsm.isSelectionEmpty()) {
00252                  //no rows are selected
00253                   if(thisTable==0) {   
00254                        testSelection=null;
00255                        ivTestSelection=null;
00256                        guiControl.displayPane.setDisplayColors();
00257                        guiControl.displayPane.refreshDisplay();  
00258                        guiControl.selectorPane.initParamList();
00259                        }
00260                    return;
00261                    }
00262 
00263               int minRow=lsm.getMinSelectionIndex();
00264               int maxRow=lsm.getMaxSelectionIndex();   
00265               int nselected = maxRow-minRow+1;  
00266 
00267               int displayStatus=guiControl.displayStatus.getStatus();
00268               switch(displayStatus) {
00269                  case DisplayStatus.MODULE_GROUP_SELECTION:
00270                    if(nselected>0) lsm.setSelectionInterval(minRow,minRow);
00271                    if(thisTable==0) guiControl.selectorPane.setMouseClickIndex(minRow);
00272                    guiControl.displayPane.setDisplayColors();
00273                    guiControl.displayPane.refreshDisplay();
00274                    break;
00275                  case DisplayStatus.IS_MONITOR:
00276 // if more than one row is selected, assume they want to delete them
00277                    if(nselected>1) {
00278                        int response = JOptionPane.showConfirmDialog(null,"Are you sure you want to delete these "+nselected+" objects from IS?","Confirm Deletion Request",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
00279                        if(response==JOptionPane.NO_OPTION) {
00280                              lsm.setSelectionInterval(minRow,minRow);
00281                              return; 
00282                              }
00283                      // delete the objects
00284                        if(thisTable==0) guiControl.isInterface.removeTests(objectNames[0],minRow,maxRow);
00285 //                     else deleteSelectedDataObjects();
00286                        updateTables();
00287                        return;
00288                        } 
00289                     if(thisTable!=0) return;
00290                     if(objectNames[0]!=null && objectNames[0].size()>0) testSelection = new TestSelection((String)objectNames[0].elementAt(minRow),guiControl.isInterface.getLocation());
00291 
00292                     String runScanRegex = testSelection.getRunScanRegex();
00293                     if(runScanRegex!=null) guiControl.isInterface.setISCounter(runScanRegex);
00294 //                    guiControl.isInterface.setTestFilter((String)objectNames[0].elementAt(minRow)); 
00295                     guiControl.selectorPane.initParamList(); // maybe require change of parameter menu
00296 
00297                     if(testSelection.isRetrievedData()) checkForRetrievedObjects();
00298 
00299                     guiControl.colorScalePane.setColorScale(); 
00300                     guiControl.displayPane.setDisplayColors();      
00301                     ModuleCell lastClickedCell;
00302                     if((lastClickedCell=guiControl.displayPane.getLastClickedCell())!=null) listISObjects(lastClickedCell);
00303                     guiControl.displayPane.refreshDisplay();
00304                     break;
00305                  case DisplayStatus.TEST_DATA:
00306                 if(thisTable!=0) return; // only interest in changes to the first table 
00307                     if(objectNames[0]!=null && objectNames[0].size()>0) testSelection = new TestSelection((String)objectNames[0].elementAt(minRow),guiControl.isInterface.getLocation());
00308 //                   guiControl.isInterface.setTestFilter((String)objectNames[0].elementAt(minRow)); 
00309                    guiControl.selectorPane.initParamList(); // maybe require change of parameter menu
00310 
00311                    if(testSelection.isRetrievedData()) checkForRetrievedObjects(2);   // publish test data object, if not already done
00312 
00313                    guiControl.colorScalePane.setColorScale(); 
00314                    guiControl.displayPane.setDisplayColors();      
00315                    guiControl.displayPane.refreshDisplay();
00316                    listTestResults();
00317                    break;
00318                  case DisplayStatus.SCTDB_DATA:
00319                  case DisplayStatus.SCTDB_RODDAQ_DATA:
00320                    if(thisTable!=0) return; // only interest in changes to the first table 
00321                     if(objectNames[0]!=null && objectNames[0].size()>0) testSelection = new TestSelection((String)objectNames[0].elementAt(minRow),guiControl.isInterface.getLocation());
00322 //                   guiControl.isInterface.setTestFilter((String)objectNames[0].elementAt(minRow)); 
00323                    guiControl.selectorPane.initParamList(); // maybe require change of parameter menu
00324                    guiControl.colorScalePane.setColorScale(); 
00325                    guiControl.displayPane.setDisplayColors();      
00326                    guiControl.displayPane.refreshDisplay();
00327                    listTestResults();
00328                    break;
00329                  case DisplayStatus.IV_DATA:
00330                    if(thisTable!=0) return; // only interest in changes to the first table 
00331                    if(objectNames[0]!=null && objectNames[0].size()>0) ivTestSelection = new IVTestSelection((String)objectNames[0].elementAt(minRow));
00332                    guiControl.selectorPane.initParamList(); // maybe require change of parameter menu
00333                    guiControl.colorScalePane.setColorScale(); 
00334                    guiControl.displayPane.setDisplayColors();      
00335                    guiControl.displayPane.refreshDisplay();
00336                    listTestResults();
00337                    break;
00338                   default:
00339                  }
00340             }
00341 
00342     public TestSelection getTestSelection() {
00343            return testSelection;
00344            }
00345     public IVTestSelection getIVTestSelection() {
00346            return ivTestSelection;
00347            }
00348 
00349     public void listISObjects(ModuleCell thisCell) {
00350        String title = "No module selected";
00351 
00352        if(thisCell!=null) {
00353             title =guiControl.selectorPane.getDisplayParameter()+" for "+thisCell.getSerialNo();
00354             refresh1(getISTableList(thisCell),title);
00355             }
00356         }
00357 
00358     public Vector getISTableList(ModuleCell thisCell) {
00359 
00360        Vector theLine;
00361        java.util.SortedMap m = new java.util.TreeMap();
00362 
00363        if(thisCell!=null && testSelection!=null && testSelection.getRunScanRegex()!=null) {
00364        String thisSN = thisCell.getSerialNo();
00365        java.util.List isList = (java.util.List)guiControl.isInterface.isCounter.getModuleList(guiControl.selectorPane.getDisplayParameterIndex(),testSelection.getRunScanRegex(),thisSN,testSelection.isRetrievedData());
00366        if(isList==null) objectNames[1] = new Vector();
00367        else {
00368          objectNames[1] = new Vector(isList);
00369          for(int i=0;i<objectNames[1].size();i++) {
00370             String[] objectParts = ((String)objectNames[1].elementAt(i)).split("\\.");
00371             theLine = new Vector();
00372             String sn = objectParts[4];
00373             Integer runNo = Integer.valueOf(objectParts[2]);
00374             Integer scanNo = Integer.valueOf(objectParts[3]);
00375             String fname = objectParts[1];
00376             theLine.add(sn);
00377             theLine.add(runNo);
00378             theLine.add(scanNo);
00379             theLine.add(fname);
00380             m.put(new Integer(runNo.intValue()*10000 + scanNo.intValue()),theLine);
00381             }
00382           }
00383          }
00384          Vector tableContents = new Vector(m.values());
00385          theLine=new Vector();
00386          theLine.addElement("Serial No");
00387          theLine.addElement("Run No");
00388          theLine.addElement("Scan No");
00389          theLine.addElement("Data");
00390          tableContents.insertElementAt(theLine,0);
00391          return tableContents;
00392         }
00393      public void listTestResults() {
00394 
00395         int status = guiControl.displayStatus.getStatus();
00396         int displayParameter = guiControl.selectorPane.getDisplayParameterIndex();
00397         String testParameter = (displayParameter==2 && status!=DisplayStatus.DCS_DATA) ? guiControl.selectorPane.getOption() : guiControl.selectorPane.getDisplayParameter();
00398         if(status==DisplayStatus.IV_DATA) {
00399               if(ivTestSelection==null) return;
00400               switch(displayParameter) {
00401                 case 1:
00402                  testParameter = guiControl.selectorPane.getIVParameter();
00403                  break;
00404                 case 2:                 
00405                  testParameter = guiControl.selectorPane.getOption();
00406                  break;
00407                 default:
00408                  testParameter = guiControl.selectorPane.getDisplayParameter();
00409                 }
00410               }
00411         else if(status!=DisplayStatus.DCS_DATA && testSelection==null) return;
00412 
00413         java.util.Set moduleList = guiControl.config.getSortedVector(guiControl.displayPane.getSCTView());
00414         int index = guiControl.selectorPane.getMouseClickIndex();
00415         Vector theLine = new Vector();
00416         Vector table = new Vector();
00417         Vector objectsVector = new Vector();
00418         theLine.addElement("Serial No");
00419         switch(status) {
00420            case DisplayStatus.SCTDB_DATA:
00421             theLine.addElement("Location");
00422             theLine.addElement("Date");
00423             break;
00424            case DisplayStatus.SCTDB_RODDAQ_DATA:
00425               theLine.addElement("Date");
00426              break;
00427            default:
00428            }
00429         theLine.addElement(testParameter);
00430         table.addElement(theLine);
00431 
00432         SummaryReader.Test testResult;
00433 
00434         for (java.util.Iterator i = moduleList.iterator(); i.hasNext(); ) {
00435            String thisSN=(String)i.next();
00436 
00437                  ModuleCell thisCell = (ModuleCell)guiControl.config.getModuleCell(guiControl.displayPane.getSCTView(),thisSN);
00438                  theLine=new Vector();
00439                  theLine.addElement(thisSN);
00440 
00441                  switch(status) {
00442                    case DisplayStatus.SCTDB_DATA:
00443                      if(testSelection.getSCTDBObjectHeader()==null) continue;
00444                      testResult = guiControl.isInterface.getSCTDBTest(testSelection.getSCTDBObjectHeader()+thisSN);
00445                      if(testResult==null) {
00446                        theLine.addElement(" - ");
00447                        theLine.addElement(" - ");
00448                        }
00449                      else {
00450                        theLine.addElement(testResult.getDAQInfo().get(SummaryReader.DAQInfo.LOCATION));
00451                        theLine.addElement(testResult.getDAQInfo().get(SummaryReader.DAQInfo.DATE));
00452                        }
00453                      break;
00454                    case DisplayStatus.SCTDB_RODDAQ_DATA:
00455                      testResult = guiControl.isInterface.getSCTDBTest(testSelection.getSCTDBRodDaqObjectHeader()+thisSN);
00456                      if(testResult==null) theLine.addElement(" - ");
00457                      else theLine.addElement(testResult.getDAQInfo().get(SummaryReader.DAQInfo.DATE));
00458                      break;
00459                    default:
00460                    }
00461 
00462                  ColorScale thisColorScale;
00463                  if((thisColorScale = guiControl.colorScalePane.getColorScale())!=null) theLine.addElement(thisColorScale.getLabel(thisCell.getData()));
00464                  else theLine.addElement("No Data");
00465                  table.addElement(theLine);
00466                  }      
00467           String title = (status==DisplayStatus.TEST_DATA && guiControl.displayPane.getDisplayOption()==2) ? testParameter+" Comparisons" : testParameter+" Results ";
00468           refresh1(objectsVector,table,title);     
00469          }   
00470 
00471     public void updateTables(boolean keepSelections) {
00472          changeTables(keepSelections);
00473          }
00474     public void updateTables() {
00475          changeTables(!guiControl.menuBar.autoSelectMode.isSelected());
00476          }
00477 
00478     private void changeTables(boolean keepSelections) {
00479 
00480       testSelection=null;
00481       ivTestSelection=null;
00482 
00483       Vector theLine = new Vector();
00484       int table0Select=-1;
00485       int table1Select=-1;
00486       String selectedObject0 = getSelectedObject(0);
00487       String selectedObject1 = getSelectedObject(1);
00488       if(keepSelections) {
00489         table0Select = (selectedObject0!=null) ? objectNames[0].indexOf(selectedObject0) : -1;
00490         }
00491       table1Select = (selectedObject1!=null) ? objectNames[1].indexOf(selectedObject1) : -1;
00492         
00493       String title0=null;
00494       String title1=null;
00495       Vector[] tableContents = new Vector[2];
00496       tableContents[0] = new Vector();
00497       tableContents[1] = new Vector();
00498 
00499       int previousSelection = keepSelections ? getSelectedTest() : -1;
00500 
00501       int view = guiControl.displayPane.getSCTView();
00502 
00503       switch(guiControl.displayStatus.getStatus()) {
00504           case DisplayStatus.MODULE_GROUP_SELECTION :
00505              title0 = "ModuleGroups";
00506              String option = guiControl.selectorPane.getOption();
00507              title1 = (option!=null) ? option+" modules" : null;
00508              theLine.addElement("Serial No");
00509              String title = (view<4) ? "Row" : "Quadrant";
00510              theLine.addElement(title);
00511              theLine.addElement("Posn");
00512              theLine.addElement("MUR");
00513              tableContents[1].addElement(theLine);
00514              theLine = new Vector();
00515              theLine.addElement("Group");
00516              theLine.addElement("# Modules");
00517              tableContents[0].addElement(theLine);
00518 
00519              java.util.Set moduleList = guiControl.config.getSortedVector(view);
00520              java.util.Map groupCounts = new java.util.HashMap();
00521 
00522              int selectedGroup = guiControl.selectorPane.getMouseClickIndex();
00523              table0Select = selectedGroup;
00524              for (java.util.Iterator i = moduleList.iterator(); i.hasNext(); ) {
00525                String thisSN=(String)i.next();
00526                ModuleCell thisCell = (ModuleCell)guiControl.config.getModuleCell(view,thisSN);
00527                int thisGroup = thisCell.getModuleGroup();
00528                if(thisGroup<0) continue;
00529 
00530                Integer iThisGroup = new Integer(thisGroup);
00531                Integer c;
00532                if((c = (Integer)groupCounts.get(iThisGroup))==null) groupCounts.put(iThisGroup,new Integer(1));
00533                else groupCounts.put(iThisGroup,new Integer(c.intValue()+1));
00534 
00535                if(thisGroup!=selectedGroup) continue;
00536                theLine = new Vector();
00537                theLine.addElement(thisSN);
00538                if(view<4) {
00539                     theLine.addElement(Integer.toString(thisCell.getRow()));
00540                     theLine.addElement(Integer.toString(thisCell.getPosition()));
00541                     }
00542                else {
00543                     theLine.addElement(thisCell.getQuadrant());
00544                     theLine.addElement(thisCell.getEndCapPosition());
00545                     }
00546 
00547                theLine.addElement(Integer.toString(thisCell.getMUR()));
00548                tableContents[1].addElement(theLine);
00549                }
00550                for(int i=0;i<8;i++) {
00551                   theLine = new Vector();
00552                   theLine.addElement("ModuleGroup "+i);
00553                   Integer c;
00554                   if((c=(Integer)groupCounts.get(new Integer(i)))==null) theLine.addElement(new Integer(0));
00555                   else theLine.addElement(c);
00556                   tableContents[0].addElement(theLine);
00557                   }
00558              break;
00559            case DisplayStatus.IS_MONITOR:
00560                title0 = "Tests";
00561                title1 = guiControl.selectorPane.getDisplayParameter();
00562                tableContents[1] = getISTableList(guiControl.displayPane.getLastClickedCell());
00563                tableContents[0] = getTestTableList();             
00564                break;
00565            case DisplayStatus.IV_DATA:
00566                title0 = "IV scans";
00567                title1 = "IV Data";
00568                tableContents[0] = getIVScanList();
00569                theLine = new Vector();
00570                theLine.addElement("Serial No");
00571                theLine.addElement(guiControl.selectorPane.getIVParameter());
00572                tableContents[1].addElement(theLine);
00573                break;
00574            case DisplayStatus.TEST_DATA:
00575            case DisplayStatus.SCTDB_DATA:
00576            case DisplayStatus.SCTDB_RODDAQ_DATA:
00577                int testType = guiControl.isInterface.getListFilterIndex();
00578                title0 = (testType==-1) ? "Number of Tests " : "Number of "+testMenuNames[testType]+" Tests ";
00579                String testParameter = guiControl.selectorPane.getDisplayParameter();
00580                title1 = testParameter+ " Results";
00581                theLine = new Vector();
00582                theLine.addElement("Serial No");
00583                theLine.addElement(testParameter);
00584                tableContents[1].addElement(theLine);
00585                tableContents[0]=getTestTableList();
00586                if(tableContents[0].size()>1) {
00587                      if(previousSelection<=tableContents[0].size()-2 && previousSelection>=0) table0Select=previousSelection;
00588                      else table0Select=tableContents[0].size()-2; // remember titles!!   
00589                      }
00590 
00591                break;
00592            case DisplayStatus.DCS_DATA:
00593                table0Select=-1;
00594                table1Select=-1;
00595                title0 = "Server Info";
00596                title1 = guiControl.selectorPane.getDisplayParameter()+ " Data";
00597                theLine = new Vector();
00598                theLine.addElement("Serial No");
00599                theLine.addElement(guiControl.selectorPane.getDisplayParameter());
00600                tableContents[1].addElement(theLine);
00601                theLine = new Vector();
00602                theLine.addElement("Server");
00603                theLine.addElement("Last Update");
00604                tableContents[0].addElement(theLine);
00605                theLine = new Vector();
00606                theLine.addElement(Preferences.PreferencesInterface.getInstance().getPreference(Preferences.PreferencesInterface.DCS_SERVER_NAME));
00607                theLine.addElement(guiControl.isInterface.isRequestBuffer.getLastUpdateTime());
00608                tableContents[0].addElement(theLine);
00609                break;
00610            default:
00611                return;
00612               }      
00613         if(table0Select==-1 && tableContents[0].size()>1) table0Select=tableContents[0].size()-2; // remember titles!!  
00614         if(table1Select==-1 && tableContents[1].size()>1) table1Select=tableContents[1].size()-2; // remember titles!!  
00615         refresh(tableContents,table0Select,table1Select);
00616         setTableTitles(title0,title1);
00617 
00618         if(getSelectedTest()==-1) {  // no test now selected, so need to update display manually (otherwise selection listener would do it)
00619 //              guiControl.isInterface.setTestFilter(null);
00620               testSelection=null;
00621               ivTestSelection=null;
00622               guiControl.displayPane.setDisplayColors();
00623               guiControl.displayPane.refreshDisplay();
00624               guiControl.selectorPane.initParamList();
00625                }
00626 // for DCS, there is no selection in the test table that will fill the bottom table, so do it here manually
00627         if(guiControl.displayStatus.getStatus()==DisplayStatus.DCS_DATA) {
00628               testSelection=null;
00629               ivTestSelection=null;
00630               guiControl.displayPane.setDisplayColors();
00631               guiControl.displayPane.refreshDisplay();
00632               listTestResults();
00633               }
00634     }
00635 
00636     public void setTestTable(Vector ISTests) {
00637            objectNames[0] = ISTests;
00638            updateTables(true);
00639            }
00640     public void addNewTest(String theObjectName) {
00641            if(objectNames[0]==null) return;
00642            if(!objectNames[0].contains(theObjectName)) objectNames[0].addElement(theObjectName);
00643            }
00644     public void removeTest(String theObjectName) {
00645            if(objectNames[0].contains(theObjectName)) {
00646                 objectNames[0].removeElement(theObjectName);
00647                 updateTables(true);
00648                 }
00649            }
00650 
00651    public Vector getTestTableList() {
00652 // generate the test table list ordered by run numer and scan number
00653        Vector theLine = new Vector();        // each line of the table
00654        Vector tableContent = new Vector();   // vector of table lines
00655        Vector orderVector = new Vector();      // vector for re-ordering based on runno and scanno
00656        Hashtable orderHash = new Hashtable();// hashtable to map order runno/scanno to table lines
00657        Hashtable objectOrderHash = new Hashtable();
00658 
00659        theLine.addElement("Test");
00660        theLine.addElement("Status");
00661        theLine.addElement("Run");
00662        theLine.addElement("Scan");
00663        theLine.addElement("#Scans");
00664        theLine.addElement("Source");
00665        tableContent.addElement(theLine);
00666        int exceptionCount=0;
00667        for(int i=0;i<objectNames[0].size();i++) {
00668            String thisObject = (String)objectNames[0].elementAt(i);
00669            TestData testData = new TestData(); 
00670            try {
00671            is.getRepository().getValue(thisObject, testData); 
00672            theLine=new Vector();
00673            if(testData.testName.equals("NPtGainTest") && testData.nScans==3) testData.testName = "3PtGainTest";
00674            theLine.addElement(testData.testName);
00675            switch(testData.status) {
00676              case 0:
00677                  theLine.addElement("Executing");
00678                  break;
00679              case 1:
00680                  theLine.addElement("Completed");
00681                  break;
00682              case 2:
00683                  theLine.addElement("Aborted");
00684                  break;
00685              default:
00686                  theLine.addElement("Unknown");
00687              }
00688            theLine.addElement(new Integer(testData.runNumber));
00689            theLine.addElement(new Integer(testData.startScanNumber));
00690            theLine.addElement(new Integer(testData.nScans));
00691 
00692            int offsetCount = (thisObject.matches("RetrievedData.*")) ? 0 : 100000000;
00693            Integer runScanNumber = new Integer(testData.runNumber*10000 + testData.startScanNumber +offsetCount); 
00694 
00695            if(thisObject.matches("RetrievedData.*")) theLine.addElement("Archive");
00696            else if(thisObject.matches("SCTDBData.*")) theLine.addElement("SCTDB");
00697            else theLine.addElement("New");        
00698 
00699            orderVector.addElement(runScanNumber);
00700            orderHash.put(runScanNumber,theLine);
00701            objectOrderHash.put(runScanNumber,thisObject);
00702            }catch(Exception e){exceptionCount++;}
00703 
00704            }
00705 
00706        Collections.sort(orderVector);
00707        objectNames[0]=new Vector();
00708        for(int i=0;i<orderVector.size();i++) {
00709             Integer runscan= (Integer)orderVector.elementAt(i);
00710             objectNames[0].addElement((String)objectOrderHash.get(orderVector.elementAt(i)));          // re-order object names appropriately
00711             tableContent.addElement((Vector)orderHash.get(orderVector.elementAt(i))); // and the same for the table entries
00712             }
00713        if(exceptionCount>0) System.err.println("SctGUI::TablesDisplayPane - exception reading retrieving IS data.");
00714        return tableContent;
00715     }
00716 
00717    public Vector getIVScanList() {
00718 // generate the test table list ordered by run numer and scan number
00719        Vector theLine = new Vector();        // each line of the table
00720        Vector tableContent = new Vector();   // vector of table lines
00721        Vector orderVector = new Vector();      // vector for re-ordering based on runno and scanno
00722        Hashtable orderHash = new Hashtable();// hashtable to map order runno/scanno to table lines
00723        Hashtable objectOrderHash = new Hashtable();
00724 
00725        theLine.addElement("Run");
00726        theLine.addElement("Scan");
00727        theLine.addElement("Date");
00728        theLine.addElement("Time");
00729        theLine.addElement("#Modules");
00730        theLine.addElement("Source");
00731        tableContent.addElement(theLine);
00732        for(int i=0;i<objectNames[0].size();i++) {
00733            String thisObject = (String)objectNames[0].elementAt(i);
00734            IVScanControl iv = new IVScanControl();
00735            is.getRepository().getValue(thisObject, iv); 
00736            theLine=new Vector();
00737            theLine.addElement(new Integer(iv.runNo));
00738            theLine.addElement(new Integer(iv.scanNo));
00739            theLine.addElement(iv.scanDate);
00740            theLine.addElement(iv.scanTime);
00741            theLine.addElement(new Integer(iv.modules.length));
00742 
00743            int offsetCount = (thisObject.matches("RetrievedData.*")) ? 0 : 100000000;
00744            Integer runScanNumber = new Integer(iv.runNo*10000 + iv.scanNo +offsetCount); 
00745 
00746            if(thisObject.matches("SCTDBData.*")) theLine.addElement("SCTDB");
00747            else theLine.addElement("DCS");        
00748 
00749            orderVector.addElement(runScanNumber);
00750            orderHash.put(runScanNumber,theLine);
00751            objectOrderHash.put(runScanNumber,thisObject);
00752 
00753            }
00754 
00755        Collections.sort(orderVector);
00756        objectNames[0]=new Vector();
00757        for(int i=0;i<orderVector.size();i++) {
00758             Integer runscan= (Integer)orderVector.elementAt(i);
00759             objectNames[0].addElement((String)objectOrderHash.get(orderVector.elementAt(i)));          // re-order object names appropriately
00760             tableContent.addElement((Vector)orderHash.get(orderVector.elementAt(i))); // and the same for the table entries
00761             }
00762        return tableContent;
00763     }
00764 
00765     public void updateTest(String testObjectName) {
00766            if(objectNames[0]==null) return;
00767            if(!objectNames[0].contains(testObjectName)) return;
00768            int rowNumber=objectNames[0].indexOf(testObjectName);
00769            try {
00770            TestData testData = new TestData(); 
00771            Sct.IS.SctNames.getISRepository().getValue(testObjectName, testData); 
00772            switch(testData.status) {
00773                case 0:
00774                  resultTable[0].setValueAt("Executing",rowNumber,1);
00775                  break;
00776                case 1:
00777                  resultTable[0].setValueAt("Completed",rowNumber,1);
00778                  break;
00779                case 2:
00780                  resultTable[0].setValueAt("Aborted",rowNumber,1);
00781                  break;
00782                default:
00783                  resultTable[0].setValueAt("Unknown",rowNumber,1);
00784                }
00785              resultTable[0].fireTableCellUpdated(rowNumber,1);
00786              if(testData.status==1 && guiControl.menuBar.autoUploadIsEnabled() && !testData.testName.equals("NMaskTest")) {
00787                     UploadManager upload = new UploadManager(guiControl);  // upload the data!
00788                     }
00789             }catch(Exception updateE){System.err.println("***ERROR updating test status in table list : "+updateE.toString());}
00790            
00791          }
00792 
00793     public void updateTestTable(String testObjectName, int rowNumber) {
00794            if(rowNumber==-1) return;
00795            try {
00796            TestData testData = new TestData(); 
00797            Sct.IS.SctNames.getISRepository().getValue(testObjectName, testData); 
00798            switch(testData.status) {
00799                case 0:
00800                  resultTable[0].setValueAt("Executing",rowNumber,1);
00801                  break;
00802                case 1:
00803                  resultTable[0].setValueAt("Completed",rowNumber,1);
00804                  break;
00805                case 2:
00806                  resultTable[0].setValueAt("Aborted",rowNumber,1);
00807                  break;
00808                default:
00809                  resultTable[0].setValueAt("Unknown",rowNumber,1);
00810                }
00811              resultTable[0].fireTableCellUpdated(rowNumber,1);
00812             }catch(Exception updateE){System.err.println("***ERROR updating test status in table list : "+updateE.toString());}
00813          }
00814 
00815 
00816     class tables1MouseAdapter extends java.awt.event.MouseAdapter {
00817             public void mouseClicked(java.awt.event.MouseEvent e) {
00818                switch(e.getModifiers()) {
00819                  case java.awt.event.InputEvent.BUTTON2_MASK:
00820                  case java.awt.event.InputEvent.BUTTON3_MASK:
00821                        int rowSelect = table[1].rowAtPoint(new java.awt.Point(e.getX(),e.getY()));
00822                        rowSM[1].setSelectionInterval(rowSelect,rowSelect);
00823                        if(rowSelect>=0) {
00824                          guiControl.menuBar.setSelectedSerialNo((String)resultTable[1].getValueAt(rowSelect,0));                       
00825                          guiControl.menuBar.showTablesPopupMenu(1,e);
00826                          }
00827                        break;
00828                  default:
00829                  }
00830             }
00831     }
00832     class tables0MouseAdapter extends java.awt.event.MouseAdapter {
00833             public void mouseClicked(java.awt.event.MouseEvent e) {
00834                switch(e.getModifiers()) {
00835                  case java.awt.event.InputEvent.BUTTON2_MASK:
00836                  case java.awt.event.InputEvent.BUTTON3_MASK:
00837                        int rowSelect = table[0].rowAtPoint(new java.awt.Point(e.getX(),e.getY()));
00838                        rowSM[0].setSelectionInterval(rowSelect,rowSelect);  
00839                        guiControl.menuBar.showTablesPopupMenu(0,e);
00840                        break;
00841                  default:
00842                  }
00843             }
00844     }
00845     public void checkForRetrievedObjects() {
00846          checkForRetrievedObjects(-1);
00847          }
00848 
00849     public void checkForRetrievedObjects(int serverIndex) {
00850          if(testSelection==null || !testSelection.isRetrievedData()) return;
00851          if(serverIndex==-1) serverIndex = guiControl.selectorPane.getDisplayParameterIndex();
00852          if(guiControl.isInterface.isCounter.archivedObjectsRetrievedOk(serverIndex,testSelection.getRunScanRegex())) return;
00853          System.out.println("SctGUI - Retrieving archived data files...");
00854          String oName;
00855          switch(serverIndex) {
00856                           case 1:
00857                               oName = "SctData::FitScanResult";
00858                               break;
00859                           case 2:
00860                               oName = "SctData::*TestResult";
00861                               break;
00862                           default:
00863                               oName = "SctData::RawScanResult";
00864                               }
00865                       
00866          try {
00867 //           System.out.println("retrieve("+testSelection.getRunNo()+","+testSelection.getScanNo()+","+oName+","+"*"+")");
00868            ArchivingServiceI.ArchivingServiceInterface a = SystemInterface.getInstance().getArchivingService(); 
00869            int scan=testSelection.getScanNo(); 
00870            if(serverIndex==2) a.retrieve(Integer.toString(testSelection.getRunNo()),Integer.toString(scan),oName,"*");
00871            else {
00872                for(int i = 0;i<testSelection.getNoScans();i++) a.retrieve(Integer.toString(testSelection.getRunNo()),Integer.toString(scan+i),oName,"*");
00873                }
00874          }catch(Exception e2) {System.err.println("SctGUI::TablesDisplayPane - Exception from retrieving from ArchiveService: "+e2.toString());}
00875 
00876               }
00877 
00878 
00879 
00880     
00881 }

Generated on Thu Jul 15 09:55:50 2004 for SCT DAQ/DCS Software - Java by doxygen 1.3.5