List of usage examples for com.jgoodies.forms.builder DefaultFormBuilder append
public JLabel append(String textWithMnemonic, Component component)
From source file:com.zeroc.IceGridGUI.SessionKeeper.java
License:Open Source License
public static JPanel getFingerprintPanel(X509Certificate cert) throws java.security.GeneralSecurityException { FormLayout layout = new FormLayout("right:pref, 2dlu, left:pref:grow", "pref"); DefaultFormBuilder builder = new DefaultFormBuilder(layout); builder.border(Borders.DIALOG);//from www . j ava 2s. com builder.rowGroupingEnabled(true); builder.lineGapSize(LayoutStyle.getCurrent().getLinePad()); builder.addSeparator("Fingerprints"); builder.nextLine(); String sha1Fingerprint = ""; { MessageDigest md = MessageDigest.getInstance("SHA-1"); byte[] der = cert.getEncoded(); md.update(der); byte[] digest = md.digest(); StringBuilder sb = new StringBuilder(digest.length * 2); Formatter formatter = new Formatter(sb); try { for (int i = 0; i < digest.length;) { formatter.format("%02x", digest[i]); i++; if (i < digest.length) { sb.append(":"); } } } finally { formatter.close(); } sha1Fingerprint = sb.toString().toUpperCase(); } builder.append(new JLabel("<html><b>SHA-1 Fingerprint:</b></html>"), new JLabel(sha1Fingerprint)); builder.nextLine(); String md5Fingerprint = ""; { MessageDigest md = MessageDigest.getInstance("MD5"); byte[] der = cert.getEncoded(); md.update(der); byte[] digest = md.digest(); StringBuilder sb = new StringBuilder(digest.length * 2); Formatter formatter = new Formatter(sb); try { for (int i = 0; i < digest.length;) { formatter.format("%02x", digest[i]); i++; if (i < digest.length) { sb.append(":"); } } } finally { formatter.close(); } md5Fingerprint = sb.toString().toUpperCase(); } builder.append(new JLabel("<html><b>MD5 Fingerprint:</b></html>"), new JLabel(md5Fingerprint)); builder.nextLine(); return builder.getPanel(); }
From source file:com.zeroc.IceGridGUI.SessionKeeper.java
License:Open Source License
public static JPanel getSubjectAlternativeNamesPanel(X509Certificate cert) throws java.security.cert.CertificateParsingException { FormLayout layout = new FormLayout("right:pref, 2dlu, left:pref:grow", "pref"); DefaultFormBuilder builder = new DefaultFormBuilder(layout); builder.border(Borders.DIALOG);/*from ww w .ja va2 s . co m*/ builder.rowGroupingEnabled(true); builder.lineGapSize(LayoutStyle.getCurrent().getLinePad()); builder.addSeparator("Subject Alternate Names"); builder.nextLine(); Collection<List<?>> altNames = cert.getSubjectAlternativeNames(); if (altNames != null) { for (List<?> l : altNames) { Integer kind = (Integer) l.get(0); String value = l.get(1).toString(); if (kind == 2) { builder.append(new JLabel("<html><b>DNS Name:</b></html>"), new JLabel(value)); builder.nextLine(); } else if (kind == 7) { builder.append(new JLabel("<html><b>IP Address:</b></html>"), new JLabel(value)); builder.nextLine(); } } } return builder.getPanel(); }
From source file:com.zeroc.IceGridGUI.SessionKeeper.java
License:Open Source License
private void login(final JDialog parent, final ConnectionInfo info) { if (_authDialog != null) { _authDialog.dispose();/*from ww w .j a va 2s .co m*/ _authDialog = null; } if (info.getAuth() == SessionKeeper.AuthType.UsernamePasswordAuthType) { class UsernamePasswordAuthDialog extends AuthDialog { UsernamePasswordAuthDialog() { super(parent, "Login - IceGrid Admin"); Container contentPane = getContentPane(); contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS)); { // Build the basic login panel. FormLayout layout = new FormLayout("pref, 2dlu, pref:grow, 2dlu, pref", ""); DefaultFormBuilder builder = new DefaultFormBuilder(layout); builder.border(Borders.DIALOG); if (info.getPassword() == null || info.getPassword().length == 0) { _username = new JTextField(20); _username.setText(info.getUsername()); _username.setEditable(false); builder.append(new JLabel("Username"), _username); builder.nextLine(); _password = new JPasswordField(20); builder.append(new JLabel("Password"), _password); builder.nextLine(); _storePassword = new JCheckBox("Save Password."); _storePassword.setEnabled( _password.getPassword() != null && _password.getPassword().length > 0); _password.getDocument().addDocumentListener(new DocumentListener() { @Override public void changedUpdate(DocumentEvent e) { _storePassword.setEnabled( _password.getPassword() != null && _password.getPassword().length > 0); } @Override public void removeUpdate(DocumentEvent e) { _storePassword.setEnabled( _password.getPassword() != null && _password.getPassword().length > 0); } @Override public void insertUpdate(DocumentEvent e) { _storePassword.setEnabled( _password.getPassword() != null && _password.getPassword().length > 0); } }); builder.append("", _storePassword); builder.nextLine(); } if (info.getUseX509Certificate() && (info.getKeyPassword() == null || info.getKeyPassword().length == 0)) { _keyAlias = new JTextField(20); _keyAlias.setText(info.getAlias()); _keyAlias.setEditable(false); builder.append(new JLabel("Key Alias"), _keyAlias); builder.nextLine(); _keyPassword = new JPasswordField(20); builder.append(new JLabel("Key Password"), _keyPassword); builder.nextLine(); _storeKeyPassword = new JCheckBox("Save Key Password."); _storeKeyPassword.setEnabled( _keyPassword.getPassword() != null && _keyPassword.getPassword().length > 0); _keyPassword.getDocument().addDocumentListener(new DocumentListener() { @Override public void changedUpdate(DocumentEvent e) { _storeKeyPassword.setEnabled(_keyPassword.getPassword() != null && _keyPassword.getPassword().length > 0); } @Override public void removeUpdate(DocumentEvent e) { _storeKeyPassword.setEnabled(_keyPassword.getPassword() != null && _keyPassword.getPassword().length > 0); } @Override public void insertUpdate(DocumentEvent e) { _storeKeyPassword.setEnabled(_keyPassword.getPassword() != null && _keyPassword.getPassword().length > 0); } }); builder.append("", _storeKeyPassword); builder.nextLine(); } contentPane.add(builder.getPanel()); } JButton okButton = new JButton(); AbstractAction okAction = new AbstractAction("OK") { @Override public void actionPerformed(ActionEvent e) { if (_session != null) { logout(true); } assert _session == null; if (_password != null) { info.setPassword(_password.getPassword()); info.setStorePassword(_storePassword.isSelected()); } if (_keyPassword != null) { info.setKeyPassword(_keyPassword.getPassword()); info.setStoreKeyPassword(_storeKeyPassword.isSelected()); } if (checkCertificateRequirePassword(info.getAlias()) && !checkCertificatePassword(info.getAlias(), info.getKeyPassword())) { dispose(); permissionDenied(parent, info, "Invalid certificate password"); } else { Cursor oldCursor = parent.getCursor(); parent.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); dispose(); _coordinator.login(SessionKeeper.this, info, parent, oldCursor); } } }; okButton.setAction(okAction); JButton cancelButton = new JButton(); AbstractAction cancelAction = new AbstractAction("Cancel") { @Override public void actionPerformed(ActionEvent e) { dispose(); } }; cancelButton.setAction(cancelAction); JComponent buttonBar = new ButtonBarBuilder().addGlue().addButton(okButton, cancelButton) .addGlue().build(); buttonBar.setBorder(Borders.DIALOG); contentPane.add(buttonBar); getRootPane().setDefaultButton(okButton); pack(); setResizable(false); } private JTextField _username; private JPasswordField _password; private JCheckBox _storePassword; private JTextField _keyAlias; private JPasswordField _keyPassword; private JCheckBox _storeKeyPassword; } // // If there isn't a store password or the certificate requires a password // and the password isn't provided, we show the login dialog. // if ((info.getPassword() == null || info.getPassword().length == 0) || (info.getUseX509Certificate() && checkCertificateRequirePassword(info.getAlias()) && (info.getKeyPassword() == null || info.getKeyPassword().length == 0))) { _authDialog = new UsernamePasswordAuthDialog(); Utils.addEscapeListener(_authDialog); _authDialog.showDialog(); } else { if (_session != null) { logout(true); } assert _session == null; if (info.getUseX509Certificate() && checkCertificateRequirePassword(info.getAlias()) && !checkCertificatePassword(info.getAlias(), info.getKeyPassword())) { permissionDenied(parent, info, "Invalid certificate password"); } else { Cursor oldCursor = parent.getCursor(); parent.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); _coordinator.login(SessionKeeper.this, info, parent, oldCursor); } } } else // Auth dialog { class X509CertificateAuthDialog extends AuthDialog { X509CertificateAuthDialog() { super(parent, "Login - IceGrid Admin"); Container contentPane = getContentPane(); contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS)); { // Build the basic login panel. FormLayout layout = new FormLayout("pref, 2dlu, pref:grow, 2dlu, pref", ""); DefaultFormBuilder builder = new DefaultFormBuilder(layout); builder.border(Borders.DIALOG); builder.append(new JLabel("Key Password"), _keyPassword); builder.nextLine(); _storeKeyPassword = new JCheckBox("Save Key Password."); _storeKeyPassword.setEnabled(false); _keyPassword.getDocument().addDocumentListener(new DocumentListener() { @Override public void changedUpdate(DocumentEvent e) { _storeKeyPassword.setEnabled(_keyPassword.getPassword() != null && _keyPassword.getPassword().length > 0); } @Override public void removeUpdate(DocumentEvent e) { _storeKeyPassword.setEnabled(_keyPassword.getPassword() != null && _keyPassword.getPassword().length > 0); } @Override public void insertUpdate(DocumentEvent e) { _storeKeyPassword.setEnabled(_keyPassword.getPassword() != null && _keyPassword.getPassword().length > 0); } }); builder.append("", _storeKeyPassword); builder.nextLine(); contentPane.add(builder.getPanel()); } JButton okButton = new JButton(); AbstractAction okAction = new AbstractAction("OK") { @Override public void actionPerformed(ActionEvent e) { if (_session != null) { logout(true); } assert _session == null; info.setKeyPassword(_keyPassword.getPassword()); if (checkCertificateRequirePassword(info.getAlias()) && !checkCertificatePassword(info.getAlias(), info.getKeyPassword())) { dispose(); permissionDenied(parent, info, "Invalid certificate password"); } else { Cursor oldCursor = parent.getCursor(); parent.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); dispose(); _coordinator.login(SessionKeeper.this, info, parent, oldCursor); } } }; okButton.setAction(okAction); JButton cancelButton = new JButton(); AbstractAction cancelAction = new AbstractAction("Cancel") { @Override public void actionPerformed(ActionEvent e) { dispose(); } }; cancelButton.setAction(cancelAction); JComponent buttonBar = new ButtonBarBuilder().addGlue().addButton(okButton, cancelButton) .addGlue().build(); buttonBar.setBorder(Borders.DIALOG); contentPane.add(buttonBar); getRootPane().setDefaultButton(okButton); pack(); setResizable(false); } private JPasswordField _keyPassword = new JPasswordField(20); private JCheckBox _storeKeyPassword; } // // If the certificate requires a password and the password isn't provided, we // show the login dialog. // if ((info.getKeyPassword() == null || info.getKeyPassword().length == 0) && checkCertificateRequirePassword(info.getAlias())) { _authDialog = new X509CertificateAuthDialog(); Utils.addEscapeListener(_authDialog); _authDialog.showDialog(); } else { if (_session != null) { logout(true); } assert _session == null; if (checkCertificateRequirePassword(info.getAlias()) && !checkCertificatePassword(info.getAlias(), info.getKeyPassword())) { permissionDenied(parent, info, "Invalid certificate password"); } else { Cursor oldCursor = parent.getCursor(); parent.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); _coordinator.login(SessionKeeper.this, info, parent, oldCursor); } } } }
From source file:com.zeroc.IceGridGUI.SessionKeeper.java
License:Open Source License
public void permissionDenied(final JDialog parent, final ConnectionInfo info, final String msg) { class PermissionDeniedAuthDialog extends AuthDialog { PermissionDeniedAuthDialog() {/*from www . j a va2 s . c o m*/ super(parent, "Login - IceGrid Admin"); Container contentPane = getContentPane(); contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS)); { // Build the basic login panel. FormLayout layout = new FormLayout("pref, 2dlu, pref:grow, 2dlu, pref", ""); DefaultFormBuilder builder = new DefaultFormBuilder(layout); builder.border(Borders.DIALOG); if (info.getAuth() == AuthType.UsernamePasswordAuthType) { _username = new JTextField(20); _username.setText(info.getUsername()); _username.setEditable(false); builder.append(new JLabel("Username"), _username); builder.nextLine(); _password = new JPasswordField(20); if (info.getPassword() != null) { _password.setText(new String(info.getPassword())); } builder.append(new JLabel("Password"), _password); builder.nextLine(); _storePassword = new JCheckBox("Save Password."); _storePassword.setSelected(info.getStorePassword()); _storePassword .setEnabled(_password.getPassword() != null && _password.getPassword().length > 0); _password.getDocument().addDocumentListener(new DocumentListener() { @Override public void changedUpdate(DocumentEvent e) { _storePassword.setEnabled( _password.getPassword() != null && _password.getPassword().length > 0); } @Override public void removeUpdate(DocumentEvent e) { _storePassword.setEnabled( _password.getPassword() != null && _password.getPassword().length > 0); } @Override public void insertUpdate(DocumentEvent e) { _storePassword.setEnabled( _password.getPassword() != null && _password.getPassword().length > 0); } }); builder.append("", _storePassword); builder.nextLine(); } if (info.getUseX509Certificate()) { _keyAlias = new JTextField(20); _keyAlias.setText(info.getAlias()); _keyAlias.setEditable(false); builder.append(new JLabel("Key Alias"), _keyAlias); builder.nextLine(); _keyPassword = new JPasswordField(20); if (info.getKeyPassword() != null) { _keyPassword.setText(new String(info.getKeyPassword())); } builder.append(new JLabel("Key Password"), _keyPassword); builder.nextLine(); _storeKeyPassword = new JCheckBox("Save Key Password."); _storeKeyPassword.setSelected(info.getStoreKeyPassword()); _storeKeyPassword.setEnabled( _keyPassword.getPassword() != null && _keyPassword.getPassword().length > 0); _keyPassword.getDocument().addDocumentListener(new DocumentListener() { @Override public void changedUpdate(DocumentEvent e) { _storeKeyPassword.setEnabled(_keyPassword.getPassword() != null && _keyPassword.getPassword().length > 0); } @Override public void removeUpdate(DocumentEvent e) { _storeKeyPassword.setEnabled(_keyPassword.getPassword() != null && _keyPassword.getPassword().length > 0); } @Override public void insertUpdate(DocumentEvent e) { _storeKeyPassword.setEnabled(_keyPassword.getPassword() != null && _keyPassword.getPassword().length > 0); } }); builder.append("", _storeKeyPassword); builder.nextLine(); } contentPane.add(builder.getPanel()); } JButton okButton = new JButton(new AbstractAction("OK") { @Override public void actionPerformed(ActionEvent e) { if (_session != null) { logout(true); } assert _session == null; if (_password != null) { info.setPassword(_password.getPassword()); info.setStorePassword(_storePassword.isSelected()); } boolean certificatePasswordMatch = true; if (_keyPassword != null) { info.setKeyPassword(_keyPassword.getPassword()); info.setStoreKeyPassword(_storeKeyPassword.isSelected()); certificatePasswordMatch = checkCertificatePassword(info.getAlias(), info.getKeyPassword()); } if (!certificatePasswordMatch) { dispose(); permissionDenied(parent, info, "Invalid certificate password"); } else { Cursor oldCursor = parent.getCursor(); parent.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); dispose(); _coordinator.login(SessionKeeper.this, info, parent, oldCursor); } } }); JButton editConnectionButton = new JButton(new AbstractAction("Edit Connection") { @Override public void actionPerformed(ActionEvent e) { info.load(); dispose(); _authDialog = null; JDialog dialog = new ConnectionWizardDialog(info, parent); Utils.addEscapeListener(dialog); dialog.setLocationRelativeTo(parent); dialog.setVisible(true); } }); JButton cancelButton = new JButton(new AbstractAction("Cancel") { @Override public void actionPerformed(ActionEvent e) { info.load(); dispose(); _authDialog = null; } }); JComponent buttonBar = new ButtonBarBuilder().addGlue() .addButton(okButton, editConnectionButton, cancelButton).addGlue().build(); buttonBar.setBorder(Borders.DIALOG); contentPane.add(buttonBar); getRootPane().setDefaultButton(okButton); pack(); setResizable(false); } private JTextField _username; private JPasswordField _password; private JCheckBox _storePassword; private JTextField _keyAlias; private JPasswordField _keyPassword; private JCheckBox _storeKeyPassword; } JOptionPane.showMessageDialog(parent, "Permission denied: " + msg, "Login failed", JOptionPane.ERROR_MESSAGE); _authDialog = new PermissionDeniedAuthDialog(); Utils.addEscapeListener(_authDialog); _authDialog.showDialog(); }
From source file:de.atomfrede.tools.evalutation.options.ui.OptionsDialog.java
License:Open Source License
private JPanel getFirstTab() { if (firstTab == null) { firstTab = new JPanel(); firstTab.setLayout(new BorderLayout()); FormLayout layout = new FormLayout("pref, 4dlu, pref, 4dlu,fill:pref:grow"); //$NON-NLS-1$ DefaultFormBuilder builder = new DefaultFormBuilder(layout); builder.setDefaultDialogBorder(); // solenoid valves of interest builder.appendSeparator(Messages.getString("OptionsDialog.12")); //$NON-NLS-1$ builder.append(getAllSolenoidValveCheckBox(), 5); builder.append(getSolenoidValveZeroCheckBox()); builder.append(getSolenoidValveOneCheckBox()); builder.append(getSolenoidValveTwoCheckBox()); builder.append(getSolenoidValveFourCheckBox()); builder.append(getSolenoidValveEightCheckBox()); builder.append(getSolenoidValveSixteenCheckBox()); firstTab.add(builder.getPanel(), BorderLayout.CENTER); }//www .j a v a 2 s . c o m return firstTab; }
From source file:de.atomfrede.tools.evalutation.options.ui.OptionsDialog.java
License:Open Source License
private JPanel getSecondTab() { if (secondTab == null) { secondTab = new JPanel(); secondTab.setLayout(new BorderLayout()); FormLayout layout = new FormLayout("left:pref, 4dlu, fill:pref:grow"); //$NON-NLS-1$ DefaultFormBuilder builder = new DefaultFormBuilder(layout); builder.setDefaultDialogBorder(); builder.appendSeparator("Plotting"); builder.appendSeparator("CO2 Absolute"); builder.append(getCo2AbsoluteCo2AbsoluteCheckBox(), 3); builder.append("Minimum", getCo2Absolute_Co2AbsoluteMinimumSpinner()); builder.append("Maximum", getCo2Absolute_Co2AbsoluteMaximumSpinner()); builder.nextLine();/* w w w . ja v a 2 s . c o m*/ builder.appendSeparator("Delta 5 Minutes"); builder.append(getCo2AbsoluteDeltaCheckBox(), 3); builder.append("Minimum", getCo2Absolute_deltaFiveMinutesMinimumSpinner()); builder.append("Maximum", getCo2Absolute_deltaFiveMinutesMaximumSpinner()); //builder.append("Options for CO2-Absolute Only Evalution"); //$NON-NLS-1$ secondTab.add(builder.getPanel(), BorderLayout.CENTER); } return secondTab; }
From source file:de.atomfrede.tools.evalutation.options.ui.OptionsDialog.java
License:Open Source License
private JPanel getThirdTab() { if (thirdTab == null) { thirdTab = new JPanel(); thirdTab.setLayout(new BorderLayout()); FormLayout layout = new FormLayout("pref, 4dlu, pref, 4dlu,fill:pref:grow"); //$NON-NLS-1$ DefaultFormBuilder builder = new DefaultFormBuilder(layout); builder.setDefaultDialogBorder(); builder.append(getShiftByOneHourCheckBox(), 5); builder.append(getRecordReferenceChambersCheckbox(), 5); builder.append(Messages.getString("OptionsDialog.3")); //$NON-NLS-1$ builder.append(getSampleSpinner(), 3); thirdTab.add(builder.getPanel(), BorderLayout.CENTER); }/*from ww w . j a v a 2 s.co m*/ return thirdTab; }
From source file:de.atomfrede.tools.evalutation.options.ui.OptionsDialog.java
License:Open Source License
private JPanel getFourthTab() { if (fourthTab == null) { fourthTab = new JPanel(); fourthTab.setLayout(new BorderLayout()); FormLayout layout = new FormLayout("left:pref, 4dlu, fill:pref:grow"); //$NON-NLS-1$ DefaultFormBuilder builder = new DefaultFormBuilder(layout); builder.setDefaultDialogBorder(); builder.appendSeparator("Reduce Datasets"); builder.append("Density", getTypeB_DensitySpinner()); builder.appendSeparator("Plotting"); builder.appendSeparator("CO2 Absolute"); builder.append(getTypeBCo2AbsoluteCheckBox(), 3); builder.append("Minimum", getTypeB_CO2AbsoluteMinimumSpinner()); builder.append("Maximum", getTypeB_CO2AbsoluteMaximumSpinner()); builder.appendSeparator("Delta Raw"); builder.append(getTypeBDeltaRawCheckBox(), 3); builder.append("Minimum", getTypeB_deltaRawMinimumSpinner()); builder.append("Maximum", getTypeB_deltaRawMaximumSpinner()); //builder.append("Options for Ingo's Evaluation"); //$NON-NLS-1$ fourthTab.add(builder.getPanel(), BorderLayout.CENTER); }/* www . ja va 2 s.c o m*/ return fourthTab; }
From source file:de.atomfrede.tools.evalutation.tools.plot.ui.wizard.pages.FileSelectionWizardPage.java
License:Open Source License
protected void addContent() { setLayout(new JideBorderLayout()); FormLayout layout = new FormLayout("left:pref, 4dlu, fill:pref:grow, 4dlu, pref"); DefaultFormBuilder builder = new DefaultFormBuilder(layout); builder.setDefaultDialogBorder();//w ww . j av a 2 s.c o m builder.append("Input File", getInputFileTextField()); builder.append(getSelectInputFileButton()); builder.appendSeparator("Size of generated PDF"); builder.append("Width", getWidthSpinner(), 3); builder.append("Height", getHeightSpinner(), 3); add(builder.getPanel(), JideBorderLayout.CENTER); Dimension size = builder.getPanel().getSize(); Dimension prefSize = builder.getPanel().getPreferredSize(); setPreferredSize(builder.getPanel().getPreferredSize()); // setSize(builder.getPanel().getPreferredSize()); }
From source file:de.atomfrede.tools.evalutation.tools.plot.ui.wizard.time.pages.TimeFileSelectionPage.java
License:Open Source License
@Override protected void addContent() { setLayout(new JideBorderLayout()); FormLayout layout = new FormLayout("left:pref, 4dlu, fill:pref:grow, 4dlu, pref"); DefaultFormBuilder builder = new DefaultFormBuilder(layout); builder.setDefaultDialogBorder();//from www . j a v a 2 s . c om builder.append("Input File", getInputFileTextField()); builder.append(getSelectInputFileButton()); builder.appendSeparator("Size of generated PDF"); builder.append("Width", getWidthSpinner(), 3); builder.append("Height", getHeightSpinner(), 3); add(builder.getPanel(), JideBorderLayout.CENTER); }