Example usage for com.jgoodies.forms.builder DefaultFormBuilder appendI15dSeparator

List of usage examples for com.jgoodies.forms.builder DefaultFormBuilder appendI15dSeparator

Introduction

In this page you can find the example usage for com.jgoodies.forms.builder DefaultFormBuilder appendI15dSeparator.

Prototype

public JComponent appendI15dSeparator(String resourceKey) 

Source Link

Document

Appends an internationalized titled separator for the given resource key that spans all columns.

Usage

From source file:org.openthinclient.console.wizards.ConnectionSettingsVisualPanel.java

License:Open Source License

private void initComponents() {
    final DefaultFormBuilder dfb = new DefaultFormBuilder(new FormLayout("r:p,3dlu,f:p:g,3dlu,p,3dlu,p"), //$NON-NLS-1$
            Messages.getBundle(), this);
    final int DEFAULT_COLSPAN = 5;

    /*//w  w  w  . jav a 2s. com
          if (null != System.getProperty("ThinClientManager.server.Codebase"))
             try {
    url = new URL(System.getProperty("ThinClientManager.server.Codebase"));
             } catch (final MalformedURLException e1) {
    e1.printStackTrace();
             }
    */

    try {
        final BasicService basicService = (BasicService) ServiceManager.lookup("javax.jnlp.BasicService");
        //fragt sich, ob basicService.getCodeBase() das selbe liefert wie System.getProperty("ThinClientManager.server.Codebase")
        url = basicService.getCodeBase();
    } catch (UnavailableServiceException use) {
        use.printStackTrace();
        //vielleicht etwas zu rabiat
        //System.exit(-1);
        System.err.println("Cannot dertermine serving host address, using 'localhost': " + use.getMessage());
        try {
            url = new URL("http://localhost");
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }
    }

    // connection line
    hostField = new javax.swing.JTextField();
    if (null != url)
        hostField.setText(url.getHost());
    dfb.appendI15d("ConnectionSettings.connection.host", hostField); //$NON-NLS-1$

    portField = new javax.swing.JTextField();
    portField.setText("10389"); //$NON-NLS-1$
    portField.setColumns(5);
    dfb.appendI15d("ConnectionSettings.connection.port", portField); //$NON-NLS-1$

    dfb.nextLine();

    connectMethodField = new javax.swing.JComboBox(
            new DefaultComboBoxModel(LDAPConnectionDescriptor.ConnectionMethod.values()));
    connectMethodField.setRenderer(new DefaultListCellRenderer() {
        @Override
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
                boolean cellHasFocus) {
            return super.getListCellRendererComponent(list,
                    Messages.getString("ConnectionSettings.connection.method." //$NON-NLS-1$
                            + ((LDAPConnectionDescriptor.ConnectionMethod) value).name()),
                    index, isSelected, cellHasFocus);
        }
    });
    connectMethodField.setEnabled(false);
    connectMethodLabel = dfb.appendI15d("ConnectionSettings.connection.method", connectMethodField); //$NON-NLS-1$
    connectMethodLabel.setEnabled(false);

    dfb.nextLine();

    // base dn line
    dfb.appendUnrelatedComponentsGapRow();

    dfb.nextLine();

    dfb.appendI15dSeparator("ConnectionSettings.optional"); //$NON-NLS-1$

    dfb.nextLine();

    baseDNField = new javax.swing.JTextField();
    baseDNField.setText("ou=openthinclient,dc=openthinclient,dc=org");
    dnLabel = dfb.appendI15d("ConnectionSettings.baseDN", baseDNField, DEFAULT_COLSPAN); //$NON-NLS-1$

    dfb.nextLine();

    // disable schemaprovider until possible use by full AD integration
    schemaProviderName = new javax.swing.JTextField();
    schemaProviderName.setEnabled(false);
    // if (null != url)
    // schemaProviderName.setText(url.getHost());
    schemaProviderLabel = dfb.appendI15d("ConnectionSettings.schemaProviderName", schemaProviderName,
            DEFAULT_COLSPAN); //$NON-NLS-1$
    schemaProviderLabel.setEnabled(false);

    dfb.nextLine();

    // authentication settings
    dfb.appendUnrelatedComponentsGapRow();

    dfb.nextLine();

    dfb.appendI15dSeparator("ConnectionSettings.authentication"); //$NON-NLS-1$

    dfb.nextLine();

    authMethodField = new javax.swing.JComboBox(
            new DefaultComboBoxModel(LDAPConnectionDescriptor.AuthenticationMethod.values()));
    authMethodField.setRenderer(new DefaultListCellRenderer() {
        @Override
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
                boolean cellHasFocus) {
            return super.getListCellRendererComponent(list,
                    Messages.getString("ConnectionSettings.authentication.method." //$NON-NLS-1$
                            + ((LDAPConnectionDescriptor.AuthenticationMethod) value).name()),
                    index, isSelected, cellHasFocus);
        }
    });
    authMethodField.setEnabled(false);
    authMethodLable = dfb.appendI15d("ConnectionSettings.authentication.method", authMethodField, //$NON-NLS-1$
            DEFAULT_COLSPAN);
    authMethodLable.setEnabled(false);

    dfb.nextLine();

    userDNField = new javax.swing.JTextField();
    userLabel = dfb.appendI15d("ConnectionSettings.user", userDNField, //$NON-NLS-1$
            DEFAULT_COLSPAN);
    userDNField.setText("cn=administrator,ou=users,ou=openthinclient,dc=openthinclient,dc=org");

    dfb.nextLine();

    passwordField = new javax.swing.JPasswordField();
    passwordLabel = dfb.appendI15d("ConnectionSettings.password", //$NON-NLS-1$
            passwordField, DEFAULT_COLSPAN);

    dfb.nextLine();

    savePasswordCheckbox = new JCheckBox(Messages.getString("ConnectionSettings.savePassword")); //$NON-NLS-1$
    dfb.append(savePasswordCheckbox, DEFAULT_COLSPAN);

    dfb.nextLine();

}

From source file:org.openthinclient.console.wizards.initrealm.InitEnvironmentPanel.java

License:Open Source License

public JComponent getComponent() {

    if (null == component) {
        final DefaultFormBuilder dfb = new DefaultFormBuilder(new FormLayout("r:p,3dlu,f:p:g,3dlu,p,3dlu,p"), //$NON-NLS-1$
                Messages.getBundle(), new MyPanel());
        final int DEFAULT_COLSPAN = 5;

        manager.addPropertyChangeListener(new PropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent evt) {
                fireChangeEvent();//from   w  w w  .  j  a  va  2s  .  com
            }
        });

        final DocumentListener documentForwarder = new DocumentListener() {
            public void changedUpdate(DocumentEvent e) {
                updateComponentStates();
                fireChangeEvent();
            }

            public void insertUpdate(DocumentEvent e) {
                updateComponentStates();
                fireChangeEvent();
            }

            public void removeUpdate(DocumentEvent e) {
                updateComponentStates();
                fireChangeEvent();
            }
        };

        dfb.appendI15dSeparator(Messages.getString("InitEnvironmentPanel.separator.baseDN")); //$NON-NLS-1$
        dfb.nextLine();

        baseDNLabel = new JLabel();
        dfb.append(baseDNLabel, dfb.getColumnCount() - 2);
        dfb.nextLine();

        dfb.appendI15dSeparator(Messages.getString("InitEnvironmentPanel.separator.settings")); //$NON-NLS-1$
        dfb.nextLine();

        URL url = null;
        try {
            url = new URL("http://localhost");
        } catch (MalformedURLException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }

        /*
                 final String urlSpec = System
                       .getProperty("ThinClientManager.server.Codebase");
                 if (null != urlSpec)
                    try {
                       url = new URL(urlSpec);
                    } catch (final MalformedURLException e) {
                       e.printStackTrace();
                    }
        */

        //         try {
        //
        //
        //            final BasicService basicService =
        //               (BasicService)ServiceManager.
        //               lookup("javax.jnlp.BasicService");
        //
        //            //fragt sich, ob basicService.getCodeBase() das selbe liefert wie System.getProperty("ThinClientManager.server.Codebase")       
        //            url = basicService.getCodeBase();
        //
        //
        //         } catch (UnavailableServiceException use) {
        //             use.printStackTrace();
        //
        //             //vielleicht etwas zu rabiat
        //             //System.exit(-1);
        //         }

        String newFolderName;
        if (null != url)
            newFolderName = url.getHost();
        else
            newFolderName = Messages.getString("NewRealmInit.new_folder.defaultName");

        nameField = new JTextField();
        nameField.setText(newFolderName);
        nameField.getDocument().addDocumentListener(documentForwarder);

        dfb.appendI15d(Messages.getString("NewRealmInit.new_folder_name"), nameField, DEFAULT_COLSPAN); //$NON-NLS-1$
        dfb.nextLine();

        descriptionField = new JTextField();

        dfb.appendI15d("NewRealmInit.description", descriptionField, DEFAULT_COLSPAN); //$NON-NLS-1$
        dfb.nextLine();

        descriptionField.getDocument().addDocumentListener(new DocumentListener() {
            public void changedUpdate(DocumentEvent e) {
                updateComponentStates();
                fireChangeEvent();
            }

            public void insertUpdate(DocumentEvent e) {
                updateComponentStates();
                fireChangeEvent();
            }

            public void removeUpdate(DocumentEvent e) {
                updateComponentStates();
                fireChangeEvent();
            }
        });

        updateComponentStates();

        component = dfb.getPanel();
        component.setName(Messages.getString("InitEnvironmentPanel.name")); //$NON-NLS-1$
    }

    return component;

}