00001
00002
00003
00004
00005 package DisplayGUI;
00006
00007 import sctConf.*;
00008 import ipc.*;
00009
00010 import GuiComponents.SctConf.*;
00011 import GuiComponents.System.*;
00012
00013 import java.util.Enumeration;
00014 import java.util.Vector;
00015 import java.awt.Dimension;
00016 import java.awt.BorderLayout;
00017 import java.awt.event.WindowAdapter;
00018 import java.awt.event.WindowEvent;
00019 import java.awt.event.MouseAdapter;
00020 import java.awt.event.MouseEvent;
00021 import java.awt.event.ActionEvent;
00022 import java.awt.event.ActionListener;
00023 import javax.swing.*;
00024
00025 import org.omg.CORBA.IntHolder;
00026
00031 public class HardwareConfigurationPanel extends javax.swing.JPanel {
00032
00033 private sctConf.Configuration config;
00034
00035 ConfigFileLister configFileLister=null;
00036
00037 public HardwareConfigurationPanel() {
00038
00039 connectServer();
00040 if (config==null) {
00041 System.err.println("Error (check configuration running)");
00042 System.exit(0);
00043 }
00044 System.out.println("Found configuration ok");
00045 initComponents();
00046 }
00047
00048
00049
00050
00051 private void initComponents() {
00052
00053 setBackground(new java.awt.Color(255, 255, 255));
00054
00055 TreeView treeView = new TreeView(new Proxies(config), config);
00056
00057
00058
00059
00060 saveConfigButton = new javax.swing.JButton();
00061 reLoadConfigButton = new javax.swing.JButton();
00062 moduleListButton = new javax.swing.JButton();
00063 powerMappingsButton = new javax.swing.JButton();
00064 newModuleButton = new javax.swing.JButton();
00065
00066 title = new javax.swing.JLabel("Hardware Configuration");
00067 title.setFont(new java.awt.Font("Arial",java.awt.Font.BOLD,16));
00068 title.setForeground(new java.awt.Color(51, 0, 153));
00069
00070 java.awt.GridBagConstraints gridBagConstraints;
00071 setLayout(new java.awt.GridBagLayout());
00072
00073 gridBagConstraints = new java.awt.GridBagConstraints();
00074 gridBagConstraints.gridx = 0;
00075 gridBagConstraints.gridy = 0;
00076 gridBagConstraints.gridwidth = 5;
00077 gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
00078 gridBagConstraints.weighty = 0.1;
00079 add(title, gridBagConstraints);
00080
00081 gridBagConstraints = new java.awt.GridBagConstraints();
00082 gridBagConstraints.gridx = 0;
00083 gridBagConstraints.gridy = 1;
00084 gridBagConstraints.gridwidth = 5;
00085 gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
00086 gridBagConstraints.weighty = 0.8;
00087 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
00088 add(treeView, gridBagConstraints);
00089
00090 saveConfigButton.setFont(new java.awt.Font("Arial", 0, 12));
00091 saveConfigButton.setText("Save");
00092 gridBagConstraints = new java.awt.GridBagConstraints();
00093 gridBagConstraints.gridx = 0;
00094 gridBagConstraints.gridy = 2;
00095 gridBagConstraints.weightx = 0.2;
00096 gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
00097 add(saveConfigButton, gridBagConstraints);
00098 saveConfigButton.addActionListener(new java.awt.event.ActionListener() {
00099 public void actionPerformed(java.awt.event.ActionEvent evt) {
00100 try {
00101 config.saveConfiguration("Dump_From_ConfigGUI.xml");
00102 } catch(ConfigurationException c) {
00103 JOptionPane.showMessageDialog(null, "Save configuration failed!");
00104 }
00105 }
00106 });
00107 reLoadConfigButton.setFont(new java.awt.Font("Arial", 0, 12));
00108 reLoadConfigButton.setText("Reload");
00109 gridBagConstraints = new java.awt.GridBagConstraints();
00110 gridBagConstraints.gridx = 1;
00111 gridBagConstraints.gridy = 2;
00112 gridBagConstraints.weighty = 0.1;
00113 gridBagConstraints.weightx = 0.2;
00114 gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
00115 add(reLoadConfigButton, gridBagConstraints);
00116 reLoadConfigButton.addActionListener(new java.awt.event.ActionListener() {
00117 public void actionPerformed(java.awt.event.ActionEvent evt) {
00118 try {
00119 config.loadConfiguration("");
00120 } catch(ConfigurationException c) {
00121 JOptionPane.showMessageDialog(null, "Load configuration failed!");
00122 }
00123 }
00124 });
00125 moduleListButton.setFont(new java.awt.Font("Arial", 0, 12));
00126 moduleListButton.setText("Module List");
00127 gridBagConstraints = new java.awt.GridBagConstraints();
00128 gridBagConstraints.gridx = 2;
00129 gridBagConstraints.gridy = 2;
00130 gridBagConstraints.weightx = 0.2;
00131 gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
00132 add(moduleListButton, gridBagConstraints);
00133 moduleListButton.addActionListener(new java.awt.event.ActionListener() {
00134 public void actionPerformed(java.awt.event.ActionEvent evt) {
00135 JFrame frame = new JFrame("Module list");
00136 if(config == null) {
00137 connectServer();
00138 }
00139 frame.getContentPane().add(new ModuleListView(config));
00140
00141 frame.addWindowListener(new WindowAdapter() {
00142 public void windowClosing(WindowEvent e) {
00143 e.getWindow().dispose();
00144 }
00145 });
00146 frame.pack();
00147 frame.setVisible(true);
00148 }
00149 });
00150 powerMappingsButton.setFont(new java.awt.Font("Arial", 0, 12));
00151 powerMappingsButton.setText("Power Mappings");
00152 gridBagConstraints = new java.awt.GridBagConstraints();
00153 gridBagConstraints.gridx = 3;
00154 gridBagConstraints.gridy = 2;
00155 gridBagConstraints.weightx = 0.2;
00156 gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
00157 add(powerMappingsButton, gridBagConstraints);
00158 powerMappingsButton.addActionListener(new java.awt.event.ActionListener() {
00159 public void actionPerformed(java.awt.event.ActionEvent evt) {
00160 JFrame frame = new JFrame("Power Mappings");
00161 if(config == null) {
00162 connectServer();
00163 }
00164 frame.getContentPane().add(new PowerMappings(config));
00165
00166 frame.addWindowListener(new WindowAdapter() {
00167 public void windowClosing(WindowEvent e) {
00168 e.getWindow().dispose();
00169 }
00170 });
00171 frame.pack();
00172 frame.setVisible(true);
00173 }
00174 });
00175
00176 newModuleButton.setFont(new java.awt.Font("Arial", 0, 12));
00177 newModuleButton.setText("New Module...");
00178 gridBagConstraints = new java.awt.GridBagConstraints();
00179 gridBagConstraints.gridx = 4;
00180 gridBagConstraints.gridy = 2;
00181 gridBagConstraints.weightx = 0.2;
00182 gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
00183 add(newModuleButton, gridBagConstraints);
00184 newModuleButton.addActionListener(new java.awt.event.ActionListener() {
00185 public void actionPerformed(java.awt.event.ActionEvent evt) {
00186 if(config == null) {
00187 connectServer();
00188 }
00189 if(configFileLister==null) configFileLister = new ConfigFileLister(config);
00190 configFileLister.show();
00191 }
00192 });
00193
00194
00195 }
00196
00197 public void connectServer() {
00198 SystemInterface sys = SystemInterface.getInstance();
00199
00200 sys.refresh();
00201 config = sys.getConfigurationService();
00202 }
00203
00204
00205
00206
00207
00208
00209 private javax.swing.JButton saveConfigButton;
00210 private javax.swing.JButton reLoadConfigButton;
00211 private javax.swing.JButton moduleListButton;
00212 private javax.swing.JButton powerMappingsButton;
00213 private javax.swing.JButton newModuleButton;
00214
00215 private javax.swing.JScrollPane scrollPane;
00216
00217 private javax.swing.JLabel title;
00218 }