protected void buildPanel(String strPath) { strPath = FileUtil.openPath(strPath); ArrayList aListPath = new ArrayList(); BufferedReader reader = WFileUtil.openReadFile(strPath); if (reader == null) return; String strLine; try { while ((strLine = reader.readLine()) != null) { StringTokenizer strTok = new StringTokenizer(strLine, ":"); if (strTok.countTokens() < 4) continue; boolean bChecksum = false; boolean bShow = false; String strDir = strTok.nextToken(); String strChecksum = strTok.nextToken(); if (strChecksum.equalsIgnoreCase("checksum")) bChecksum = true; if (bChecksum && (strDir.equals("file") || strDir.equals("dir"))) { String strValue = strTok.nextToken(); String strShow = strTok.nextToken(); if (strShow.equalsIgnoreCase("yes")) bShow = true; if (bShow) aListPath.add(strValue); } } m_cmbPath = new JComboBox(aListPath.toArray()); JPanel pnlDisplay = new JPanel(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints( 0, 0, 1, 1, 0.2, 0.2, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0); pnlDisplay.add(m_cmbPath, gbc); gbc.gridx = 1; pnlDisplay.add(m_cmbChecksum, gbc); add(pnlDisplay, BorderLayout.NORTH); add(m_txaChecksum, BorderLayout.CENTER); } catch (Exception e) { e.printStackTrace(); } }
private void showSpaces(GridBagLayout gbl, GridBagConstraints gbc, int gridx, int gridy) { JLabel spaces = new JLabel(" "); gbc.gridx = gridx; gbc.gridy = gridy; gbl.setConstraints(spaces, gbc); m_pnlDisplay.add(spaces); }
/** * Creates a checkbox and sets it's value. * * @param strText either 'yes' or 'no' if yes then set the checkbox selected. */ protected JCheckBox createChkBox(String strText, JPanel pnlDisplay) { JCheckBox chkField = new JCheckBox(); boolean bSelected = (strText.equalsIgnoreCase("yes")) ? true : false; chkField.setSelected(bSelected); pnlDisplay.add(chkField); return chkField; }
protected JComboBox createCombo(String strText, JPanel pnlDisplay) { JComboBox cmbMode = new JComboBox(m_aStrMode); if (!strText.equalsIgnoreCase(m_aStrMode[0]) && !strText.equalsIgnoreCase(m_aStrMode[1])) strText = m_aStrMode[0]; cmbMode.setSelectedItem(strText); pnlDisplay.add(cmbMode); return cmbMode; }
public UserDirectoryDialog(int nBuild) { super("View Directories"); initBlink(); try { // UIManager.setLookAndFeel( "javax.swing.plaf.metal.MetalLookAndFeel" ); } catch (Exception exc) { System.out.println("Error loading L&F: " + exc); } AppIF appIf = Util.getAppIF(); if (appIf instanceof VAdminIF) m_adminIF = (VAdminIF) appIf; if (nBuild == BUILD_ALL) { JPanel left = new JPanel(); left.setOpaque(true); left.setLayout(new BorderLayout()); left.add(new ConstraintsPanel(), BorderLayout.CENTER); JPanel right = new JPanel(); right.setLayout(new BorderLayout()); right.setOpaque(true); // right.setBackground( Color.white ); JTreeTableAdmin treeTable = new JTreeTableAdmin(new FileSystemModelAdmin()); right.add(new JScrollPane(treeTable), BorderLayout.CENTER); JSplitPane pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, left, right); pane.setContinuousLayout(true); pane.setOneTouchExpandable(true); getContentPane().add(pane, BorderLayout.CENTER); } m_mlTxf = new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (timer != null) timer.cancel(); if (e.getSource() instanceof JTextField) { JTextField txf2 = (JTextField) e.getSource(); String strTxt = txf2.getText(); if (strTxt != null && strTxt.equals(INFOSTR)) txf2.setText(""); } } }; }
public JPanel makeFileTable() { JPanel right = new JPanel(); right.setLayout(new BorderLayout()); right.setOpaque(true); // right.setBackground( Color.white ); JTreeTableAdmin treeTable = new JTreeTableAdmin(new FileSystemModelAdmin()); right.add(new JScrollPane(treeTable), BorderLayout.CENTER); return right; }
private void showComp( GridBagLayout gbl, GridBagConstraints gbc, int gridx, int gridy, int gridwidth, JComponent comp) { gbc.gridx = gridx; gbc.gridy = gridy; gbl.setConstraints(comp, gbc); m_pnlDisplay.add(comp); }
private void showInstruction( GridBagLayout gbl, GridBagConstraints gbc, int gridx, int gridy, int gridwidth, JLabel instruction) { gbc.gridwidth = gridwidth; gbc.gridx = gridx; gbc.gridy = gridy; gbl.setConstraints(instruction, gbc); instruction.setForeground(Color.black); m_pnlDisplay.add(instruction); }
protected void layoutUIComponents(String strPath, boolean bDefaultFile) { JLabel label = null; // i18n // label = new JLabel( "File names can be constructed from a template. The LABEL field is " ); label = new JLabel( Util.getAdmLabel( "_admin_File_names_can_be_constructed_from_a_template._The_LABEL_field_is_")); label.setForeground(Color.black); // m_gbc.weightx = 0.5; showInstruction(m_gbl, m_gbc, 0, 0, 7, label); // i18n // label = new JLabel( "presented as the choice to the user in the \"Data save\" pop-up." ); label = new JLabel( Util.getAdmLabel( "_admin_presented_as_the_choice_to_the_user_in_the_Data_save_pop-up.")); showInstruction(m_gbl, m_gbc, 0, 1, 7, label); showInstruction(m_gbl, m_gbc, 0, 2, 1, new JLabel("")); label = new JLabel(Util.getAdmLabel("_adm_LABEL")); label.setForeground(Color.black); m_gbc.gridx = 1; m_gbc.gridy = 2; m_gbc.ipadx = 10; m_gbl.setConstraints(label, m_gbc); m_pnlDisplay.add(label); label = new JLabel(" "); m_gbc.gridx = 2; m_gbc.gridy = 2; m_gbc.ipadx = 0; // reset to default m_gbc.gridwidth = 5; m_gbl.setConstraints(label, m_gbc); // add( label ); showInstruction(m_gbl, m_gbc, 2, 2, 1, new JLabel(Util.getAdmLabel("_admin_TEMPLATE"))); m_nRow = 3; m_bDefaultFile = bDefaultFile; m_objTxfValue.clearArrays(); displayNewTxf(strPath); m_pnlDisplay.setBorder( new CompoundBorder( BorderFactory.createTitledBorder(Util.getAdmLabel("_admin_User_Directories")), BorderFactory.createEmptyBorder(10, 10, 10, 10))); }
protected void layoutUIComponents(String strPath, boolean bDefaultFile) { // gbc.weightx = 0.5; showInstructions(m_gbl, m_gbc, 0, 0, 7, infoLabel1); showInstructions(m_gbl, m_gbc, 0, 1, 7, infoLabel2); showInstructions(m_gbl, m_gbc, 0, 2, 7, infoLabel3); /*showInstructions( gbl, gbc, 0, 3, 7, infoLabel4 ); showInstructions( gbl, gbc, 0, 4, 7, infoLabel5 );*/ showInstructions(m_gbl, m_gbc, 0, 5, 1, new JLabel("")); // i18n // label = new JLabel( "LABEL" ); label = new JLabel(Util.getAdmLabel("_adm_LABEL")); label.setForeground(Color.black); m_gbc.gridx = 1; m_gbc.gridy = 5; // gbc.ipadx = 10; m_gbl.setConstraints(label, m_gbc); m_pnlDisplay.add(label); label = new JLabel(" "); m_gbc.gridx = 2; m_gbc.gridy = 5; m_gbc.ipadx = 0; m_gbc.gridwidth = 5; m_gbc.weightx = 0; m_gbl.setConstraints(label, m_gbc); // add( label ); // i18n // showInstructions( m_gbl, m_gbc, 2, 5, 1, new JLabel( "DIRECTORY" )); showInstructions(m_gbl, m_gbc, 2, 5, 1, new JLabel(Util.getAdmLabel("_adm_DIRECTORY"))); m_nRow = 5; m_bDefaultFile = bDefaultFile; m_objTxfValue.clearArrays(); displayNewTxf(strPath); m_pnlDisplay.setBorder( new CompoundBorder( // i18n // BorderFactory.createTitledBorder( " Parent Directories "), BorderFactory.createTitledBorder(Util.getAdmLabel("_adm_Parent_Directories")), BorderFactory.createEmptyBorder(10, 10, 10, 10))); }
/** * 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); }
/** * Creates a textfield and sets it's value. * * @param strText the value of the textfield. */ protected JTextField createTxf(String strText, JPanel pnlDisplay) { JTextField txfField = new JTextField(strText); pnlDisplay.add(txfField); return txfField; }
/** * Creates a label and sets it's value. * * @param strText the text of the label. */ protected JLabel createLabel(String strText, JPanel pnlDisplay) { JLabel lblField = new JLabel(strText); pnlDisplay.add(lblField); return lblField; }
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. }