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

MURPanelBrief.java

00001 package GuiComponents.SctConf;
00002 
00003 import javax.swing.event.AncestorListener;
00004 import javax.swing.event.AncestorEvent;
00005 
00006 import javax.swing.*;
00007 import java.awt.*;
00008 import java.awt.event.*;
00009 
00010 import java.io.File;
00011 
00012 import java.util.Vector;
00013 
00014 import org.omg.CORBA.IntHolder;
00015 import org.omg.CORBA.StringHolder;
00016 
00017 import sctConf.*;
00018 import Sct.gui.SelectionDialog;
00019 
00020 public class MURPanelBrief extends JPanel {
00021     sctConf.Configuration config;
00022     Proxies.RodProxy rod;
00023 
00024     int mur;
00025     int order;
00026 
00028     public MURPanelBrief(Configuration conf, Proxies.RodProxy r, int o) {
00029         rod = r;
00030         config = conf;
00031         order = o;
00032 
00033         try {
00034             IntHolder MUR = new IntHolder();
00035 
00036             config.getMapRODMUR(rod.partition(), rod.crate(), rod.index(), order, MUR);
00037             mur = MUR.value;
00038         } catch(NullPointerException e) {
00039             mur = 1;
00040         } catch(ConfigurationException e) {
00041             mur = -1;
00042         }
00043 
00044         initComponents();
00045         buildGUI();
00046     }
00047 
00048     public static void main(String args[]) {
00049         JFrame frame = new JFrame("Test Brief MUR Panel");
00050         frame.getContentPane().add(new MURPanelBrief(null, null, 1));
00051         frame.pack();
00052         frame.setVisible(true);
00053     }
00054     
00060     private void initComponents() {//GEN-BEGIN:initComponents
00061         jLabel1 = new javax.swing.JLabel();
00062         jLabel2 = new javax.swing.JLabel();
00063         jLabel3 = new javax.swing.JLabel();
00064         jLabel4 = new javax.swing.JLabel();
00065         jLabel5 = new javax.swing.JLabel();
00066         jLabel6 = new javax.swing.JLabel();
00067         jButton1 = new javax.swing.JButton();
00068 
00069         setLayout(new javax.swing.BoxLayout(this, javax.swing.BoxLayout.Y_AXIS));
00070 
00071         setBorder(new javax.swing.border.TitledBorder(getTitle()));
00072         jLabel1.setText(getModuleName(0));
00073         add(jLabel1);
00074 
00075         jLabel2.setText(getModuleName(1));
00076         add(jLabel2);
00077 
00078         jLabel3.setText(getModuleName(2));
00079         add(jLabel3);
00080 
00081         jLabel4.setText(getModuleName(3));
00082         add(jLabel4);
00083 
00084         jLabel5.setText(getModuleName(4));
00085         add(jLabel5);
00086 
00087         jLabel6.setText(getModuleName(5));
00088         add(jLabel6);
00089 
00090         jButton1.setText("Edit");
00091         jButton1.addActionListener(new java.awt.event.ActionListener() {
00092             public void actionPerformed(java.awt.event.ActionEvent evt) {
00093                 editButtonPerformed(evt);
00094             }
00095         });
00096 
00097         add(jButton1);
00098 
00099     }//GEN-END:initComponents
00100 
00101     private void editButtonPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editButtonPerformed
00102         JFrame frame = new JFrame("MUR editor");
00103 
00104         frame.getContentPane().add(new MURPanel(config, rod, getPosition()), BorderLayout.CENTER);
00105 
00106         frame.pack();
00107         frame.setVisible(true);
00108     }//GEN-LAST:event_editButtonPerformed
00109 
00110     void buildGUI() {
00111         validate();
00112     }
00113 
00114     String getTitle() {
00115         if(mur == -1) {
00116             return " position " + getPosition();
00117         } else {
00118             return "MUR " + mur;
00119         }
00120     }
00121 
00122     String getModuleName(int id) {
00123         int channel = order*6 + id;
00124 
00125         StringHolder serial = new StringHolder();
00126 
00127         IntHolder MUR = new IntHolder(), num = new IntHolder();
00128 
00129         try {
00130             config.translateFromROD(rod.partition(), rod.crate(), rod.index(), channel, MUR, num);
00131             config.translateToSN(MUR.value, num.value, serial);
00132         } catch(ConfigurationException e) {
00133             return "No module";
00134         }
00135 
00136         return serial.value;
00137     }
00138 
00139     int getPosition() {
00140         return order;
00141     }
00142 
00143     static JFileChooser fileChooser;
00144 
00145     { fileChooser = null; }
00146 
00147     static String getFileName() {
00148         if(fileChooser == null) {
00149             fileChooser = new JFileChooser();
00150         }
00151 
00152         if(fileChooser.showDialog(null, "Pick module configuration file") == JFileChooser.APPROVE_OPTION) {
00153           File file = fileChooser.getSelectedFile();
00154           return file.toString();
00155         } else {
00156           return null;
00157         }
00158     }
00159 
00160     // Variables declaration - do not modify//GEN-BEGIN:variables
00161     private javax.swing.JButton jButton1;
00162     private javax.swing.JLabel jLabel1;
00163     private javax.swing.JLabel jLabel2;
00164     private javax.swing.JLabel jLabel3;
00165     private javax.swing.JLabel jLabel4;
00166     private javax.swing.JLabel jLabel5;
00167     private javax.swing.JLabel jLabel6;
00168     // End of variables declaration//GEN-END:variables
00169 }

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