private void abort() { System.out.println("Press Aborted"); notes.setText("Start up\nPress 'Set Temp' to begin."); start.setEnabled(false); ready.setVisible(false); setTemp.setEnabled(true); }
@Override public void setEnabled(boolean b) { setDataTebleLockState(true); if (!b) { unlock.setEnabled(false); lock.setEnabled(false); } start.setEnabled(false); abortTime.setEnabled(false); ready.setVisible(false); passwd.setEnabled(b); tons.setEnabled(b); save.setEnabled(b); cycleName.setEnabled(b); load.setEnabled(b); setTemp.setEnabled(b); notes.setText("Start up\nPress 'Set Temp' to begin."); super.setEnabled(b); }
public TableDisplay(boolean usePress0, boolean usePress1, IPressControler p) { this.usePress0 = usePress0; this.usePress1 = usePress1; setLayout(new MigLayout()); press = p; getTable().setBorder(BorderFactory.createLoweredBevelBorder()); setBorder(BorderFactory.createLoweredBevelBorder()); // Disable auto resizing getTable().setAutoResizeMode(JTable.AUTO_RESIZE_OFF); getTable().getColumnModel().getColumn(0).setPreferredWidth(70); getTable().getColumnModel().getColumn(1).setPreferredWidth(70); setEditable(true); abortTime = new AbortTimeWidget(usePress0, usePress1, p.getPressHardware()); setTemp.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { press.setTempreture(getStartingTempreture()); waitingForTemp = true; notes.setText("Waiting for press to \nreach to temperature..."); } }); start.addChangeListener( new ChangeListener() { @Override public void stateChanged(ChangeEvent arg0) { ButtonModel aModel = start.getModel(); if (aModel.isArmed() && aModel.isPressed()) { System.out.println("Starting..."); press.onCycleStart(getCurrentCycleConfig()); notes.setText( "Waiting for press to \nreach desired pressure.\nDo not release button until it is safe."); } } }); start.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { if (isPressReady()) { System.out.println("Press Running"); abortTime.setEnabled(true); notes.setText("Press running.\nHit Abort to stop cycle."); start.setEnabled(false); } else { press.abortCycle(); } } }); save.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { CycleConfig conf = getCurrentCycleConfig(); currentSave = FileSelectionFactory.GetFile(confDir, new XmlFilter()); System.out.println("Using file: " + currentSave); conf.saveToFile(currentSave); try { // validation step conf = new CycleConfig(currentSave); if (conf != null) setCycleConfig(conf); } catch (FileNotFoundException e) { // TODO Auto-generated catch block // e.printStackTrace(); } } }); load.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { File nFile = FileSelectionFactory.GetFile(confDir, new XmlFilter()); if (nFile != null) { CycleConfig conf; try { conf = new CycleConfig(nFile); setCycleConfig(conf); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); return; } currentSave = nFile; } } }); cycleName.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String selected = getSelectedFile(); if (selected.equalsIgnoreCase(defaultFileString)) { System.out.println("Using default values"); setCycleConfig(new CycleConfig()); return; } for (int i = 0; i < availibleFiles.size(); i++) { if (selected.equalsIgnoreCase(availibleFiles.get(i).getName())) { System.out.println("Using file: " + availibleFiles.get(i).getAbsolutePath()); try { setCycleConfig(new CycleConfig(availibleFiles.get(i))); } catch (FileNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } fm.save(); return; } } } }); lock.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setDataTebleLockState(true); } }); unlock.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { fireUnlockEvent(); } }); passwd.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { fireUnlockEvent(); } }); ready.setVisible(false); // ready.setEnabled(false); // ready.setColor(Color.green); start.setColor(Color.yellow); JPanel tablePanel = new JPanel(new MigLayout()); JPanel controlsPanel = new JPanel(new MigLayout()); tablePanel.add(new JLabel("Time(min) Temp(F)"), "wrap"); tablePanel.add(getTable(), "wrap"); controlsPanel.add(load); controlsPanel.add(save, "wrap"); controlsPanel.add(new JLabel("Cycle Name")); controlsPanel.add(cycleName, "wrap"); controlsPanel.add(new JLabel("Target Pressure (Tons)")); controlsPanel.add(tons, "wrap"); controlsPanel.add(new JLabel("Current Pressure (Tons)")); controlsPanel.add(currentPressure, "wrap"); controlsPanel.add(new JLabel("Current Temperature (F)")); controlsPanel.add(currentTemp, "wrap"); notes.setText("Start up\nPress 'Set Temp' to begin."); JPanel spacePanel = new JPanel(new MigLayout()); JLabel spaceText = new JLabel(" "); spaceText.setFont(new Font("Dialog", Font.PLAIN, 24)); spacePanel.add(setTemp, "wrap"); spacePanel.add(spaceText); controlsPanel.add(spacePanel); controlsPanel.add(notes, "wrap"); JPanel spacePanel1 = new JPanel(new MigLayout()); JLabel spaceText1 = new JLabel(" "); spaceText1.setFont(new Font("Dialog", Font.PLAIN, 24)); spacePanel1.add(start, "wrap"); spacePanel1.add(spaceText1); controlsPanel.add(spacePanel1); // controlsPanel.add(ready,"wrap"); controlsPanel.add(abortTime, "wrap"); controlsPanel.add(new JLabel("Administrator Mode Enter Password:"******"wrap"); controlsPanel.add(unlock); controlsPanel.add(lock, "wrap"); JPanel interfacePanel = new JPanel(new MigLayout()); interfacePanel.add(tablePanel); interfacePanel.add(controlsPanel); add(interfacePanel, "wrap"); // add(graph,"wrap"); // graph.onCycleStart(0,new CycleConfig(getTableDataMatrix(),getPressureSetpoint())); // Load in default values on startup setCycleConfig(new CycleConfig()); cycleName.addItem(defaultFileString); setEnabled(true); }