/** Returns the tool bar for the panel. */ protected JComponent getToolBar() { JToolBar tbarDir = new JToolBar(); JButton btnNew = new JButton(); // m_btnSave = new JButton("Save File"); // i118n // btnNew.setText("New Label"); btnNew.setText(Util.getAdmLabel("_adm_New_Label")); btnNew.setActionCommand("new"); // m_btnSave.setActionCommand("save"); ActionListener alTool = new ActionListener() { public void actionPerformed(ActionEvent e) { doAction(e); } }; btnNew.addActionListener(alTool); // m_btnSave.addActionListener(alTool); tbarDir.setFloatable(false); tbarDir.add(btnNew); /*tbarDir.add(new JLabel(" ")); tbarDir.add(m_btnSave);*/ return tbarDir; }
/** * ************************************************ * * <pre> * Summary: Catch any key pressed. * * </pre> * * ************************************************* */ public void keyPressed(KeyEvent e) { // Have an escape do the same as clicking cancel. if (e.getKeyCode() == KeyEvent.VK_ESCAPE) abandonButton.doClick(); // Return else if (e.getKeyCode() == KeyEvent.VK_ENTER) { if (closeButton.isEnabled()) { closeButton.doClick(); } } }
/** Constructor */ public WPart11Dialog() { super(null); setVisible(false); m_pnlDisplay = new JPanel(); m_pcsTypesMgr = new PropertyChangeSupport(this); JScrollPane spDisplay = new JScrollPane(m_pnlDisplay); m_pnlDisplay.setLayout(new WGridLayout(0, 2)); addComp(spDisplay); initBlink(); buttonPane.removeAll(); // Add the buttons to the panel with space between buttons. m_btnChecksum = new JButton("Make new checksum"); buttonPane.add(m_btnChecksum); buttonPane.add(Box.createRigidArea(new Dimension(5, 0))); buttonPane.add(validateButton); buttonPane.add(Box.createRigidArea(new Dimension(5, 0))); buttonPane.add(closeButton); buttonPane.add(Box.createRigidArea(new Dimension(5, 0))); buttonPane.add(abandonButton); buttonPane.add(Box.createRigidArea(new Dimension(5, 0))); buttonPane.add(helpButton); setHelpEnabled(false); closeButton.setActionCommand("close"); closeButton.addActionListener(this); validateButton.setActionCommand("validate"); validateButton.addActionListener(this); abandonButton.setActionCommand("cancel"); abandonButton.addActionListener(this); helpButton.setActionCommand("help"); helpButton.addActionListener(this); m_btnChecksum.setActionCommand("checksum"); m_btnChecksum.addActionListener(this); setCloseEnabled(true); setAbandonEnabled(true); setTitle("Configuration"); setLocation(300, 500); setResizable(true); setSize(450, 300); }
/** * Builds the components from the file and displays it. * * @param strFile the file to be read. */ public void build(int nType, String strFile, String strhelpfile) { m_nType = nType; m_strPath = (strFile != null) ? FileUtil.openPath(strFile) : ""; m_strHelpFile = strhelpfile; boolean bValidate = false; boolean bChecksum = false; if (nType == CONFIG) { setTitle("Configuration"); buildConfig(); } else { JComponent compDisplay = null; if (nType == DEFAULT) { m_pnlAccPolicy = new AccPolicyPanel(m_strPath); compDisplay = m_pnlAccPolicy; setTitle("Password Configuration"); } else if (nType == CHECKSUM) { m_pnlChecksum = new ChecksumPanel(m_strPath); compDisplay = m_pnlChecksum; setTitle("Checksum Configuration"); bValidate = true; bChecksum = true; } else { setTitle("Perform System Validation"); compDisplay = new JTextArea(); ((JTextArea) compDisplay).setEditable(false); bValidate = true; doBlink(); } m_pnlDisplay.removeAll(); m_pnlDisplay.setLayout(new BorderLayout()); m_pnlDisplay.add(compDisplay, BorderLayout.CENTER); setVisible(true); } validateButton.setVisible(bValidate); // abandonButton.setVisible(!bValidate); setAbandonEnabled(bValidate); m_btnChecksum.setVisible(bChecksum); }
public void actionPerformed(ActionEvent e) { String cmd = e.getActionCommand(); if (cmd.equals("close")) { if (m_nType == CONFIG) saveData(); else if (m_nType == DEFAULT && m_pnlAccPolicy != null) m_pnlAccPolicy.saveData(); setVisible(false); dispose(); } else if (cmd.equals("validate")) { if (timer != null) timer.cancel(); if (m_nType == CHECKSUM && m_pnlChecksum != null) m_pnlChecksum.checksumValidation(); else doSysValidation(); validateButton.setBackground(closeButton.getBackground()); } else if (cmd.equals("checksum")) { String strValue = m_pnlChecksum.getChecksum(); m_pnlChecksum.setData(strValue); } else if (cmd.equals("checksumdir")) { m_pnlChecksum.setData(""); } else if (cmd.equals("cancel")) { // build(m_bAccPolicy); setVisible(false); dispose(); } else if (cmd.equals("help")) displayHelp(); }
public void setUndoAction(String cmd, ActionListener listener) { undoButton.setActionCommand(cmd); undoButton.addActionListener(listener); }
public void setAbandonAction(String cmd, ActionListener listener) { abandonButton.setActionCommand(cmd); abandonButton.addActionListener(listener); }
public void setHelpAction(String cmd, ActionListener listener) { helpButton.setActionCommand(cmd); helpButton.addActionListener(listener); }
public void setCloseAction(String cmd, ActionListener listener) { closeButton.setActionCommand(cmd); closeButton.addActionListener(listener); }
public void setUndoEnabled(boolean b) { undoButton.setEnabled(b); undoButton.setVisible(b); enableControlPanel(); }
public void setAbandonEnabled(boolean b) { abandonButton.setEnabled(b); abandonButton.setVisible(b); enableControlPanel(); }
public void setHelpEnabled(boolean b) { helpButton.setEnabled(b); helpButton.setVisible(b); enableControlPanel(); }
public void setCloseEnabled(boolean b) { closeButton.setEnabled(b); closeButton.setVisible(b); enableControlPanel(); }
private void initUi() { String history; String undo; String close; String abandon; String help; String string; char helpMnemonic; char historyMnemonic; char undoMnemonic; char closeMnemonic; char abandonMnemonic; DisplayOptions.addChangeListener(this); // setAlwaysOnTop(true); // Get text for buttons from properties/resource file history = Util.getLabel("blHistory", "Edit..."); undo = Util.getLabel("blUndo", "Undo"); close = Util.getLabel("blClose", "Close"); abandon = Util.getLabel("blAbandon", "Abandon"); help = Util.getLabel("blHelp", "Help"); // buttons undoButton = new JButton(undo); closeButton = new JButton(close); abandonButton = new JButton(abandon); helpButton = new JButton(help); // Create an ArrayList of menu items from properties file ArrayList<String> historyList = new ArrayList<String>(); historyList.add(Util.getLabel("mlHistReturnInitState", "Return to initial state")); historyList.add(Util.getLabel("mlHistMakeSnapshot", "Make a snapshot")); historyList.add(Util.getLabel("mlHistReturnToSnapshot", "Return to snapshot")); historyList.add(Util.getLabel("mlHistReturnToDefault", "Return to system defaults")); // Pop Button for history menu historyButton = new MPopButton(historyList); historyButton.setText(history); // Only set mnemonics if found. if (Util.labelExists("blmHelp")) { string = Util.getLabel("blmHelp"); helpMnemonic = string.charAt(0); helpButton.setMnemonic(helpMnemonic); } if (Util.labelExists("blmUndo")) { string = Util.getLabel("blmUndo"); undoMnemonic = string.charAt(0); undoButton.setMnemonic(undoMnemonic); } if (Util.labelExists("blmAbandon")) { string = Util.getLabel("blmAbandon"); abandonMnemonic = string.charAt(0); abandonButton.setMnemonic(abandonMnemonic); } if (Util.labelExists("blmClose")) { string = Util.getLabel("blmClose"); closeMnemonic = string.charAt(0); closeButton.setMnemonic(closeMnemonic); } if (Util.labelExists("blmHistory")) { string = Util.getLabel("blmHistory"); historyMnemonic = string.charAt(0); historyButton.setMnemonic(historyMnemonic); } helpButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent evt) { // Display Help if help file exists CSH_Util.displayCSHelp(dialogTitle); } }); // Make a panel to hold the buttons buttonPane = new JPanel(); // Put an empty border around the inside of the panel. buttonPane.setBorder(BorderFactory.createEmptyBorder(0, 5, 10, 5)); buttonPane.setLayout(new SimpleH2Layout(SimpleH2Layout.CENTER)); // Add the buttons to the panel with space between buttons. buttonPane.add(historyButton); // buttonPane.add(Box.createRigidArea(new Dimension(5, 0))); buttonPane.add(undoButton); // buttonPane.add(Box.createRigidArea(new Dimension(5, 0))); buttonPane.add(closeButton); // buttonPane.add(Box.createRigidArea(new Dimension(5, 0))); buttonPane.add(abandonButton); // buttonPane.add(Box.createRigidArea(new Dimension(5, 0))); buttonPane.add(helpButton); // Put everything together, using the content pane's BorderLayout. Container contentPane = getContentPane(); contentPane.add(buttonPane, BorderLayout.SOUTH); setHistoryEnabled(false); // setCloseEnabled(false); setAbandonEnabled(false); setUndoEnabled(false); if (!CSH_Util.haveTopic(dialogTitle)) setHelpEnabled(false); // buttonPane.setVisible(false); // Add key listener to the whole dialog addKeyListener(this); // Make the frame fit its contents. // pack(); // nothing to pack. }