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

RODView.java

00001 package GuiComponents.SctConf;
00002 
00003 import javax.swing.*;
00004 import java.awt.*;
00005 import java.awt.event.*;
00006 
00007 import javax.swing.event.MouseInputAdapter;
00008 
00009 import org.omg.CORBA.IntHolder;
00010 import org.omg.CORBA.StringHolder;
00011 
00012 import sctConf.*;
00013 import Sct.gui.SelectionDialog;
00014 
00015 public class RODView extends JPanel {
00016     sctConf.Configuration config;
00017     Proxies.RodProxy rod;
00018 
00019     public RODView(Configuration conf, Proxies.RodProxy r) {
00020         rod = r;
00021         config = conf;
00022 
00023         buildGUI();
00024     }
00025 
00026     void buildGUI() {
00027         removeAll();
00028 
00029         setLayout(new BorderLayout());
00030 
00031         JPanel buttons = new JPanel();
00032 
00033         JButton close = new JButton("Close");
00034         close.addActionListener(new ActionListener() {
00035                 public void actionPerformed(ActionEvent e) {
00036                     ((Window)getTopLevelAncestor()).dispose();
00037                 }
00038             });
00039         buttons.add(close);
00040 
00041         add(buttons, BorderLayout.SOUTH);
00042 
00043         JPanel centre = new JPanel();
00044         centre.setLayout(new GridLayout(2, 4));
00045         for(int i=0; i<8; i++) {
00046             MURPanelBrief murPanel = new MURPanelBrief(config, rod, i);
00047 
00048             centre.add(murPanel);
00049         }
00050 
00051         add(centre, BorderLayout.CENTER);
00052 
00053         Box top = Box.createHorizontalBox();
00054 
00055         try {
00056             RodConfig rConf = config.getRodConfig(rod.partition(), rod.crate(), rod.index());
00057 
00058             Box labels = Box.createVerticalBox();
00059             labels.add(new JLabel("BaseAddress:"));
00060             labels.add(new JLabel("IPRAM:"));
00061             labels.add(new JLabel("IDRAM:"));
00062             labels.add(new JLabel("EXT:"));
00063             top.add(labels);
00064 
00065             Box values = Box.createVerticalBox();
00066             values.add(new JLabel("0x" + Long.toHexString(rConf.baseAddress)));
00067             values.add(new JLabel(rConf.slaves[0].ipramFile));
00068             values.add(new JLabel(rConf.slaves[0].idramFile));
00069             values.add(new JLabel(rConf.slaves[0].extFile));
00070             top.add(values);
00071         } catch (ConfigurationException c) {
00072             top.add(new JLabel("No Rod configuration information"));
00073         }
00074 
00075         top.add(getEditButton());
00076         add(top, BorderLayout.NORTH);
00077         validate();
00078     }
00079 
00080     JButton getEditButton() {
00081         JButton button = new JButton("Edit ROD configuration");
00082         button.addActionListener(new ActionListener() {
00083                 public void actionPerformed(ActionEvent e) {
00084                     String [] labels = {"Base address",
00085                                         "IPRAM (filename)", "IDRAM (filename)", "xcode (filename)"};
00086                     String [] defaults = {"0x00000000",
00087                                           "slaveRun_IPRAM.bin", "slaveRun_IDRAM.bin", "slaveRun_xcode.bin"};
00088 
00089                     SelectionDialog dia = new SelectionDialog(null, "Edit ROD info", labels, defaults);
00090 
00091                     dia.pack();
00092                     dia.setVisible(true);
00093 
00094                     try {
00095                         for(int i=0; i<1; i++) {
00096                             System.out.println(labels[i] + ": " + dia.getIntFieldValue(i));
00097                         }
00098 
00099                         for(int i=1; i<4; i++) {
00100                             System.out.println(labels[i] + ": " + dia.getStringFieldValue(i));
00101                         }
00102 
00103                         try {
00104                             sctConf.RodConfig rodConf = new sctConf.RodConfig();
00105                             rodConf.baseAddress = dia.getIntFieldValue(0);
00106 
00107                             rodConf.slaves = new sctConf.SlaveConfig[4];
00108                             for(int s=0; s<4; s++) {
00109                                 rodConf.slaves[s] = new sctConf.SlaveConfig();
00110                                 rodConf.slaves[s].ipramFile = dia.getStringFieldValue(1);
00111                                 rodConf.slaves[s].idramFile = dia.getStringFieldValue(2);
00112                                 rodConf.slaves[s].extFile = dia.getStringFieldValue(3);
00113                             }
00114                             
00115                             config.configureROD(rod.partition(), rod.crate(), rod.index(), rodConf);
00116 
00117                             System.out.println("ROD configured");
00118                         } catch(ConfigurationException cex) {
00119                             JOptionPane.showMessageDialog(null, "Failed to configure ROD: " + cex.detail);
00120                             return;
00121                         }
00122 
00123                         buildGUI();
00124                         System.out.println("GUI rebuilt");
00125                     } catch(SelectionDialog.InvalidDialogException i) {
00126                         JOptionPane.showMessageDialog(null, "Failed to interpret entry(ies)");
00127                     } catch(SelectionDialog.CancelledDialogException i) {
00128                         // Cancel pressed?
00129                     }
00130                     System.out.println("Finished actionPerformed");
00131                 }
00132             });
00133 
00134         return button;
00135     }
00136 }

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