TablesDisplayPane.java

00001 /*
00002  * TablesDisplayPane.java
00003  *
00004  * Created on 23 June 2003, 15:43
00005  */
00006 
00007 package DisplayGUI;
00008 import javax.swing.event.*;
00009 import java.util.Vector;
00010 import GuiComponents.System.*;
00015 public class TablesDisplayPane extends javax.swing.JPanel implements TestDataInfo,displayParams {
00016     gui guiControl;
00017     public javax.swing.JScrollPane jScrollPane1;
00018     private javax.swing.JScrollPane jScrollPane2;
00019     private GuiComponents.System.ISInterface is;
00020 
00021     public ResultsTable resultsTable;
00022     public IndexTable indexTable;
00023 
00024     public static int INDEX_TABLE=0;
00025     public static int RESULTS_TABLE=1;
00026 
00027 
00028     public TablesDisplayPane(gui parent) {
00029         guiControl=parent;
00030           indexTable = new IndexTable(guiControl);
00031           resultsTable = new ResultsTable(guiControl);
00032 
00033         initComponents();
00034 
00035         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)));
00036 
00037     }
00038 
00039     private void initComponents() {
00040         java.awt.GridBagConstraints gridBagConstraints;
00041 
00042         jScrollPane1 = new javax.swing.JScrollPane(indexTable.getTable());
00043         jScrollPane2 = new javax.swing.JScrollPane(resultsTable.getTable());
00044 
00045         setLayout(new java.awt.GridBagLayout());
00046 
00047         setBackground(new java.awt.Color(255, 255, 255));
00048         jScrollPane1.setBackground(new java.awt.Color(255, 255, 255));
00049         jScrollPane1.setBorder(new javax.swing.border.BevelBorder(javax.swing.border.BevelBorder.LOWERED));
00050         jScrollPane1.setMinimumSize(new java.awt.Dimension(300, 150));
00051         jScrollPane1.setPreferredSize(new java.awt.Dimension(300, 200));
00052         gridBagConstraints = new java.awt.GridBagConstraints();
00053         gridBagConstraints.gridx = 0;
00054         gridBagConstraints.gridy = 1;
00055         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
00056         gridBagConstraints.ipadx = 2;
00057         gridBagConstraints.ipady = 4;
00058         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
00059         gridBagConstraints.weighty = 0.4;
00060         add(jScrollPane1, gridBagConstraints);
00061 
00062         indexTable.tableTitle.setFont(new java.awt.Font("Arial", 0, 12));
00063         indexTable.tableTitle.setForeground(new java.awt.Color(51, 0, 153));
00064         indexTable.tableTitle.setText("Index Table");
00065         gridBagConstraints = new java.awt.GridBagConstraints();
00066         gridBagConstraints.gridx = 0;
00067         gridBagConstraints.gridy = 0;
00068         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
00069         gridBagConstraints.weighty = 0.05;
00070         add(indexTable.tableTitle, gridBagConstraints);
00071 
00072         jScrollPane2.setBorder(new javax.swing.border.BevelBorder(javax.swing.border.BevelBorder.LOWERED));
00073         jScrollPane2.setMinimumSize(new java.awt.Dimension(300, 150));
00074         jScrollPane2.setPreferredSize(new java.awt.Dimension(300, 200));
00075         gridBagConstraints = new java.awt.GridBagConstraints();
00076         gridBagConstraints.gridx = 0;
00077         gridBagConstraints.gridy = 3;
00078         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
00079         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
00080         gridBagConstraints.weighty = 0.4;
00081         add(jScrollPane2, gridBagConstraints);
00082 
00083         resultsTable.tableTitle.setFont(new java.awt.Font("Arial", 0, 12));
00084         resultsTable.tableTitle.setForeground(new java.awt.Color(51, 0, 153));
00085         resultsTable.tableTitle.setText("Results Table");
00086         gridBagConstraints = new java.awt.GridBagConstraints();
00087         gridBagConstraints.gridx = 0;
00088         gridBagConstraints.gridy = 2;
00089         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
00090         gridBagConstraints.weighty = 0.05;
00091         add(resultsTable.tableTitle, gridBagConstraints);
00092 
00093 //        jScrollPane1.addMouseListener(new tables0MouseAdapter());  // popup menu on second table only
00094 //        jScrollPane2.addMouseListener(new tables1MouseAdapter());  // popup menu on second table only
00095 
00096     }
00097   
00098     public java.awt.Insets getInsets() {
00099         return new java.awt.Insets(10,10,10, 10);
00100     }
00101 
00102 
00103     public void refresh(Vector[] tableContents, int table0RowSelect, int table1RowSelect) {
00104 
00105           indexTable.refresh(tableContents[INDEX_TABLE],table0RowSelect);
00106           resultsTable.refresh(tableContents[RESULTS_TABLE],table1RowSelect);
00107 
00108         }
00109 
00110 
00111 
00112     public String getSelectedObject() {
00113        return resultsTable.getSelectedObject();
00114        }
00115 
00116 
00117         public TestSelection getTestSelection() {
00118                 return indexTable.getTestSelection();
00119                 }
00120         public IVTestSelection getIVTestSelection() {
00121                 return indexTable.getIVTestSelection();
00122                 }
00123         public String getTestControlObjectName() {
00124                 return indexTable.getTestControlObjectName();
00125                 }
00126         public Vector getTestControlObjectNames() {
00127                 return indexTable.getObjectNames();
00128                 }
00129         public int getSelectedTest() {
00130                 return indexTable.getSelectedTest();
00131                 }
00132 
00133     public void listISObjects(ModuleCell thisCell) {
00134        String title = "No module selected";
00135 
00136        if(thisCell!=null) {
00137             title =guiControl.selectorPane.getDisplayParameter()+" for "+thisCell.getSerialNo();
00138             resultsTable.refresh(resultsTable.getISTableList(thisCell),title);
00139             }
00140          else resultsTable.setTitle(title);
00141         }
00142 
00143 
00144      public void listTestResults() {
00145 
00146 
00147           ConfigurationInterface config = ConfigurationInterface.getInstance();
00148       int status = guiControl.displayStatus.getStatus();
00149       int displayParameter = guiControl.selectorPane.getDisplayParameterIndex();
00150           String displayParamName = guiControl.selectorPane.getDisplayParameter();
00151         String testParameter = (displayParamName!=null && displayParamName.matches(".*DCS.*")) ? guiControl.selectorPane.getOption() : displayParamName;
00152         if(status==DisplayStatus.IV_DATA) {
00153               if(getIVTestSelection()==null) return;
00154               switch(displayParameter) {
00155                 case 1:
00156                  testParameter = guiControl.selectorPane.getIVParameter();
00157                  break;
00158                 case 2:
00159                  testParameter = guiControl.selectorPane.getOption();
00160                  break;
00161                 default:
00162                  testParameter = guiControl.selectorPane.getDisplayParameter();
00163                 }
00164               }
00165         else if((status!=DisplayStatus.DCS_DATA && status!=DisplayStatus.PROBE_DATA && status!=DisplayStatus.MODULE_GROUP_SELECTION) && getTestSelection()==null) return;
00166 
00167         java.util.Set moduleList = config.getSerialNumberList(guiControl.selectorPane.getViewCategoryIndex(),guiControl.selectorPane.getViewIndex());
00168         int index = guiControl.selectorPane.getMouseClickIndex();
00169         Vector theLine = new Vector();
00170         Vector table = new Vector();
00171         Vector objectsVector = new Vector();
00172         theLine.addElement("Serial No");
00173         switch(status) {
00174            case DisplayStatus.SCTDB_DATA:
00175             theLine.addElement("Location");
00176             theLine.addElement("Date");
00177             break;
00178            case DisplayStatus.SCTDB_RODDAQ_DATA:
00179               theLine.addElement("Date");
00180              break;
00181            default:
00182            }
00183         theLine.addElement(testParameter);
00184         table.addElement(theLine);
00185 
00186         SummaryReader.Test testResult;
00187 
00188         for (java.util.Iterator i = moduleList.iterator(); i.hasNext(); ) {
00189            String thisSN=(String)i.next();
00190 
00191                  ModuleCell thisCell = config.getModuleCell(thisSN);
00192                  theLine=new Vector();
00193                  theLine.addElement(thisSN);
00194 
00195                  switch(status) {
00196                    case DisplayStatus.SCTDB_DATA:
00197                      if(getTestSelection().getSCTDBObjectHeader()==null) continue;
00198                      testResult = guiControl.isInterface.getSCTDBTest(getTestSelection().getSCTDBObjectHeader()+thisSN);
00199                      if(testResult==null) {
00200                        theLine.addElement(" - ");
00201                        theLine.addElement(" - ");
00202                        }
00203                      else {
00204                        theLine.addElement(testResult.getDAQInfo().get(SummaryReader.DAQInfo.LOCATION));
00205                        theLine.addElement(testResult.getDAQInfo().get(SummaryReader.DAQInfo.DATE));
00206                        }
00207                      break;
00208                    case DisplayStatus.SCTDB_RODDAQ_DATA:
00209                      testResult = guiControl.isInterface.getSCTDBTest(getTestSelection().getSCTDBRodDaqObjectHeader()+thisSN);
00210                      if(testResult==null) theLine.addElement(" - ");
00211                      else theLine.addElement(testResult.getDAQInfo().get(SummaryReader.DAQInfo.DATE));
00212                      break;
00213                    default:
00214                    }
00215 
00216                  ColorScale thisColorScale;
00217                  if((thisColorScale = guiControl.colorScalePane.getColorScale())!=null) theLine.addElement(thisColorScale.getLabel(thisCell.getData()));
00218                  else theLine.addElement("No Data");
00219                  table.addElement(theLine);
00220                  }
00221           String title = (status==DisplayStatus.TEST_DATA && guiControl.displayPane.getDisplayOption()==2) ? testParameter+" Comparisons" : testParameter+" Results ";
00222           resultsTable.refresh(objectsVector,table,title);
00223          }   
00224 
00225     public void updateTables(boolean keepSelections) {
00226          changeTables(keepSelections);
00227          }
00228     public void updateTables() {
00229          changeTables(!guiControl.guiMenus.autoSelectMode);
00230          }
00231 
00232     private void changeTables(boolean keepSelections) {
00233 
00234           ConfigurationInterface config = ConfigurationInterface.getInstance();
00235 
00236       indexTable.setNullTestSelection();
00237 
00238       Vector theLine = new Vector();
00239       int table0Select=-1;
00240       int table1Select=-1;
00241       String selectedObject0 = indexTable.getSelectedObject();
00242       String selectedObject1 = resultsTable.getSelectedObject();
00243       if(keepSelections) table0Select = indexTable.getSelectedIndex();
00244       table1Select = resultsTable.getSelectedIndex();
00245 
00246       String title0=null;
00247       String title1=null;
00248       Vector[] tableContents = new Vector[2];
00249       tableContents[INDEX_TABLE] = new Vector();
00250       tableContents[RESULTS_TABLE] = new Vector();
00251 
00252       int previousSelection = keepSelections ? indexTable.getSelectedTest() : -1;
00253 
00254       int view = guiControl.selectorPane.getViewIndex();
00255       int displayStatus = guiControl.displayStatus.getStatus();
00256           int parameter = guiControl.selectorPane.getDisplayParameterIndex();
00257 
00258       switch(displayStatus) {
00259           case DisplayStatus.MODULE_GROUP_SELECTION :
00260                if(parameter==0) {
00261                 title0 = "ModuleGroups";
00262                 String option = guiControl.selectorPane.getOption();
00263                 title1 = (option!=null) ? option+" modules" : null;
00264                 // results table
00265                 theLine.addElement("Serial No");
00266                 String title = (view<4) ? "Row" : "Quadrant";
00267                 theLine.addElement(title);
00268                 theLine.addElement("Posn");
00269                 theLine.addElement("MUR");
00270                 tableContents[RESULTS_TABLE].addElement(theLine);
00271                 // summary table
00272                 theLine = new Vector();
00273                         switch(parameter) {
00274                                 case -1:
00275                                         break;
00276                                 case 0:
00277                                 theLine.addElement("Group");
00278                                 theLine.addElement("# Modules");
00279                                         break;
00280                                 default:
00281                                         theLine.addElement(guiControl.selectorPane.getDisplayParameter());
00282                                         theLine.addElement("Count");
00283                                 }
00284                 tableContents[INDEX_TABLE].addElement(theLine);
00285 
00286                 java.util.Set moduleList = config.getSerialNumberList(guiControl.selectorPane.getViewCategoryIndex(),guiControl.selectorPane.getViewIndex());
00287                 java.util.Map groupCounts = new java.util.HashMap();
00288 
00289                 int selectedGroup = guiControl.selectorPane.getMouseClickIndex();
00290                 table0Select = selectedGroup;
00291                 for (java.util.Iterator i = moduleList.iterator(); i.hasNext(); ) {
00292                         String thisSN=(String)i.next();
00293                         ModuleCell thisCell = config.getModuleCell(thisSN);
00294                         int thisGroup = thisCell.getModuleGroup();
00295                         if(thisGroup<0) continue;
00296 
00297                         Integer iThisGroup = new Integer(thisGroup);
00298                         Integer c;
00299                         if((c = (Integer)groupCounts.get(iThisGroup))==null) groupCounts.put(iThisGroup,new Integer(1));
00300                         else groupCounts.put(iThisGroup,new Integer(c.intValue()+1));
00301 
00302                         if(thisGroup!=selectedGroup) continue;
00303                         theLine = new Vector();
00304                         theLine.addElement(thisSN);
00305                         if(view<4) {
00306                                 theLine.addElement(Integer.toString(thisCell.getRow()));
00307                                 theLine.addElement(Integer.toString(thisCell.getPosition()));
00308                         }
00309                  else {
00310                         theLine.addElement(thisCell.getQuadrant());
00311                         theLine.addElement(thisCell.getEndCapPosition());
00312                         }
00313 
00314                 theLine.addElement(Integer.toString(thisCell.getMUR()));
00315                 tableContents[RESULTS_TABLE].addElement(theLine);
00316                 }
00317                 for(int i=0;i<8;i++) {
00318                         theLine = new Vector();
00319                         theLine.addElement("ModuleGroup "+i);
00320                         Integer c;
00321                         if((c=(Integer)groupCounts.get(new Integer(i)))==null) theLine.addElement(new Integer(0));
00322                         else theLine.addElement(c);
00323                         tableContents[INDEX_TABLE].addElement(theLine);
00324                         }
00325                         }
00326                 else { // BOC parameter
00327                         table0Select=-1;
00328                         table1Select=-1;
00329                         title0="BOC Configuration";
00330                         String pName = guiControl.selectorPane.getDisplayParameter();
00331                         title1=(pName!=null) ? pName : null;
00332                         theLine=new Vector();
00333                         theLine.addElement("Data");
00334                         theLine.addElement("Count");
00335                         tableContents[INDEX_TABLE].addElement(theLine);
00336                         }
00337 
00338              break;
00339            case DisplayStatus.IS_MONITOR:
00340                title0 = "Tests";
00341                title1 = guiControl.selectorPane.getDisplayParameter();
00342                tableContents[RESULTS_TABLE] = resultsTable.getISTableList(guiControl.displayPane.getLastClickedCell());
00343                tableContents[INDEX_TABLE] = indexTable.getTestTableList();
00344                break;
00345            case DisplayStatus.IV_DATA:
00346                title0 = "IV scans";
00347                title1 = "IV Data";
00348                tableContents[INDEX_TABLE] = indexTable.getIVScanList();
00349                theLine = new Vector();
00350                theLine.addElement("Serial No");
00351                theLine.addElement(guiControl.selectorPane.getIVParameter());
00352                tableContents[RESULTS_TABLE].addElement(theLine);
00353                break;
00354            case DisplayStatus.TEST_DATA:
00355            case DisplayStatus.SCTDB_DATA:
00356            case DisplayStatus.SCTDB_RODDAQ_DATA:
00357                int testType = guiControl.isInterface.getListFilterIndex();
00358                title0 = (testType==-1) ? "Number of Tests " : "Number of "+testMenuNames[testType]+" Tests ";
00359                String testParameter = guiControl.selectorPane.getDisplayParameter();
00360                title1 = testParameter+ " Results";
00361                theLine = new Vector();
00362                theLine.addElement("Serial No");
00363                theLine.addElement(testParameter);
00364                tableContents[RESULTS_TABLE].addElement(theLine);
00365                tableContents[INDEX_TABLE]=indexTable.getTestTableList();
00366                if(tableContents[INDEX_TABLE].size()>1) {
00367                      if(previousSelection<=tableContents[INDEX_TABLE].size()-2 && previousSelection>=0) table0Select=previousSelection;
00368                      else table0Select=tableContents[INDEX_TABLE].size()-2; // remember titles!!
00369                      }
00370 
00371                break;
00372            case DisplayStatus.DCS_DATA:
00373                table0Select=-1;
00374                table1Select=-1;
00375                title0 = "Server Info";
00376                title1 = guiControl.selectorPane.getDisplayParameter()+ " Data";
00377                theLine = new Vector();
00378                theLine.addElement("Serial No");
00379                theLine.addElement(guiControl.selectorPane.getDisplayParameter());
00380                tableContents[RESULTS_TABLE].addElement(theLine);
00381                theLine = new Vector();
00382                theLine.addElement("Server");
00383                theLine.addElement("Last Update");
00384                tableContents[INDEX_TABLE].addElement(theLine);
00385                theLine = new Vector();
00386                theLine.addElement(Preferences.PreferencesInterface.getInstance().getPreference(Preferences.PreferencesInterface.DCS_SERVER_NAME));
00387                theLine.addElement(guiControl.isInterface.isRequestBuffer.getLastUpdateTime());
00388                tableContents[INDEX_TABLE].addElement(theLine);
00389                break;
00390            case DisplayStatus.PROBE_DATA:
00391                table0Select=-1;
00392                table1Select=-1;
00393                title0 = "Module Probe Counts";
00394                title1 = "Module Probe Data";
00395                theLine = new Vector();
00396                theLine.addElement("Serial No");
00397                theLine.addElement(guiControl.selectorPane.getOption());
00398                tableContents[RESULTS_TABLE].addElement(theLine);
00399                tableContents[INDEX_TABLE] = SctApiInfo.getInstance().getCountVector();
00400                break;
00401            default:
00402                guiControl.displayPane.refreshDisplay();
00403                return;
00404               }
00405         boolean dontSelect = (displayStatus==DisplayStatus.DCS_DATA || displayStatus==DisplayStatus.PROBE_DATA);
00406 
00407         if(table0Select==-1 && tableContents[INDEX_TABLE].size()>1 && !dontSelect) table0Select=tableContents[INDEX_TABLE].size()-2; // remember titles!!
00408         if(table1Select==-1 && tableContents[RESULTS_TABLE].size()>1 && !dontSelect) table1Select=tableContents[RESULTS_TABLE].size()-2; // remember titles!!
00409           refresh(tableContents,table0Select,table1Select);
00410           indexTable.setTitle(title0);
00411           resultsTable.setTitle(title1);
00412 
00413         if(indexTable.getSelectedTest()==-1) {  // no test now selected, so need to update display manually (otherwise selection listener would do it)
00414 //              guiControl.isInterface.setTestFilter(null);
00415               indexTable.setNullTestSelection();
00416               guiControl.displayPane.setDisplayColors();
00417               guiControl.displayPane.refreshDisplay();
00418               guiControl.selectorPane.initParamList();
00419                }
00420 // for DCS, there is no selection in the test table that will fill the bottom table, so do it here manually
00421         if(displayStatus==DisplayStatus.DCS_DATA || displayStatus==DisplayStatus.PROBE_DATA || (displayStatus==DisplayStatus.MODULE_GROUP_SELECTION && parameter>0)) {
00422 //              indexTable.setNullTestSelection();
00423 //              guiControl.displayPane.setDisplayColors();
00424 //              guiControl.displayPane.refreshDisplay();
00425               listTestResults();
00426               }
00427     }
00428 
00429     public void setTestTable(Vector ISTests) {
00430            indexTable.setTableContent(ISTests);
00431            updateTables(true);
00432            }
00433     public void addNewTest(String theObjectName) {
00434            indexTable.addTableObject(theObjectName);
00435            }
00436     public void removeTest(String theObjectName) {
00437              indexTable.removeTableObject(theObjectName);
00438            updateTables(true);
00439            }
00440 
00441 
00442     public void checkForRetrievedObjects() {
00443          checkForRetrievedObjects(-1);
00444          }
00445 
00446     public void checkForRetrievedObjects(int serverIndex) {
00447            TestSelection testSelection = getTestSelection();
00448          if(testSelection==null || !testSelection.isRetrievedData()) return;
00449          if(serverIndex==-1) serverIndex = guiControl.selectorPane.getDisplayParameterIndex();
00450          if(guiControl.isInterface.isCounter.archivedObjectsRetrievedOk(serverIndex,testSelection.getRunScanRegex())) return;
00451          System.out.println("SctGUI - Retrieving archived data files...");
00452          String oName;
00453          switch(serverIndex) {
00454                           case 1:
00455                               oName = "SctData::FitScanResult";
00456                               break;
00457                           case 2:
00458                               oName = "SctData::*TestResult";
00459                               break;
00460                           default:
00461                               oName = "SctData::RawScanResult";
00462                               }
00463                       
00464          try {
00465 //           System.out.println("retrieve("+testSelection.getRunNo()+","+testSelection.getScanNo()+","+oName+","+"*"+")");
00466            ArchivingServiceI.ArchivingServiceInterface a = SystemInterface.getInstance().getArchivingService();
00467            int scan=testSelection.getScanNo();
00468            if(serverIndex==2) a.retrieve(Integer.toString(testSelection.getRunNo()),Integer.toString(scan),oName,"*");
00469            else {
00470                for(int i = 0;i<testSelection.getNoScans();i++) a.retrieve(Integer.toString(testSelection.getRunNo()),Integer.toString(scan+i),oName,"*");
00471                }
00472          }catch(Exception e2) {System.err.println("SctGUI::TablesDisplayPane - Exception from retrieving from ArchiveService: "+e2.toString());}
00473 
00474               }
00475 
00476 
00477 
00478     
00479 }
00480 

Generated on Mon Feb 6 14:12:20 2006 for SCT DAQ/DCS Software - Java by  doxygen 1.4.6