public void addComponentsToPane()

in stack/launcher/src/main/java/org/apache/usergrid/launcher/LauncherFrame.java [126:328]


    public void addComponentsToPane() {
        Container pane = getContentPane();
        pane.setLayout( new GridBagLayout() );

        GridBagConstraints c;

        JToolBar toolBar = new JToolBar( "Toolbar" );
        toolBar.setBackground( new Color( 128, 128, 128 ) );
        toolBar.setFloatable( false );
        toolBar.setRollover( true );
        toolBar.setMargin( new Insets( 8, 16, 8, 8 ) );
        toolBar.setBorder( new EmptyBorder( new Insets( 8, 16, 8, 8 ) ) );

        status_label = new JLabel( status_red );
        status_label.setPreferredSize( new Dimension( 24, 64 ) );
        toolBar.add( status_label );
        status_timer = new Timer( 750, new ActionListener() {
            @Override
            public void actionPerformed( ActionEvent e ) {
                if ( status == Status.YELLOW ) {
                    if ( status_label.getIcon() == status_yellow ) {
                        status_label.setIcon( status_off );
                    }
                    else {
                        status_label.setIcon( status_yellow );
                    }
                }
            }
        } );
        status_timer.start();

        toolBar.addSeparator( new Dimension( 16, 0 ) );

        start_button = new JButton( start_active_icon );
        initButton( start_button );
        toolBar.add( start_button );
        start_button.addActionListener( new ActionListener() {
            @Override
            public void actionPerformed( ActionEvent event ) {
                start_button.setIcon( start_icon );
                stop_button.setIcon( stop_active_icon );
                app.startServer();
            }
        } );

        toolBar.addSeparator( new Dimension( 8, 0 ) );

        stop_button = new JButton( stop_icon );
        initButton( stop_button );
        toolBar.add( stop_button );
        stop_button.addActionListener( new ActionListener() {
            @Override
            public void actionPerformed( ActionEvent event ) {
                start_button.setIcon( start_active_icon );
                stop_button.setIcon( stop_icon );
                app.stopServer();
            }
        } );

        toolBar.addSeparator( new Dimension( 8, 0 ) );

        log_viewer_button = new JButton( log_viewer_icon );
        initButton( log_viewer_button );
        toolBar.add( log_viewer_button );
        log_viewer_button.addActionListener( new ActionListener() {
            @Override
            public void actionPerformed( ActionEvent event ) {
                app.showLogView();
            }
        } );

        toolBar.addSeparator( new Dimension( 8, 0 ) );

        usergrid_admin_button = new JButton( usergrid_admin_icon );
        initButton( usergrid_admin_button );
        toolBar.add( usergrid_admin_button );
        usergrid_admin_button.addActionListener( new ActionListener() {
            @Override
            public void actionPerformed( ActionEvent event ) {
                if ( app.serverIsStarted() && ( status == Status.GREEN ) ) {
                    storeAdminUrls();
                    storeAdminEmail();
                    String adminUri = null;
                    try {
                        adminUri = getAdminURI().toString();
                        Desktop.getDesktop().browse( getAdminURI() );
                    }
                    catch ( IOException e ) {
                        JOptionPane.showMessageDialog( null, new JTextArea( "Error opening URL in browser."
                                + " Please open the following URL in a browser manually:\n" + adminUri ), "Warning",
                                JOptionPane.WARNING_MESSAGE );
                    }
                    catch ( Exception ex ) {
                        JOptionPane.showMessageDialog( null, new JTextArea(
                                "Error opening URL in browser." + "Please open the following URL in a browser manually:"
                                        + adminUri ), "Warning", JOptionPane.WARNING_MESSAGE );
                    }
                }
                else {
                    JOptionPane.showMessageDialog( null, "Server must be started before opening Admin Console.\n"
                            + "Please start server and wait for the status to turn green.", "Warning",
                            JOptionPane.WARNING_MESSAGE );
                }
            }
        } );

        c = new GridBagConstraints();
        c.anchor = GridBagConstraints.CENTER;
        c.weightx = 0.0;
        c.fill = GridBagConstraints.HORIZONTAL;
        c.gridwidth = 2;
        add( toolBar, c );

        start_database_checkbox = new JCheckBox( "Start Database With Server*" );
        c = new GridBagConstraints( 0, 1, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
                new Insets( 16, 16, 8, 16 ), 0, 0 );
        start_database_checkbox.setSelected( app.isStartDatabaseWithServer() );
        start_database_checkbox.setFont( new Font( "Arial", Font.BOLD, 18 ) );
        pane.add( start_database_checkbox, c );
        start_database_checkbox.addChangeListener( new ChangeListener() {
            @Override
            public void stateChanged( ChangeEvent change ) {
                app.setStartDatabaseWithServer( start_database_checkbox.isSelected() );
            }
        } );

        init_database_checkbox = new JCheckBox( "Initialize Database on Start*" );
        c = new GridBagConstraints( 0, 2, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
                new Insets( 16, 16, 8, 16 ), 0, 0 );
        init_database_checkbox.setSelected( app.isInitializeDatabaseOnStart() );
        init_database_checkbox.setFont( new Font( "Arial", Font.BOLD, 18 ) );
        pane.add( init_database_checkbox, c );
        init_database_checkbox.addChangeListener( new ChangeListener() {
            @Override
            public void stateChanged( ChangeEvent change ) {
                app.setInitializeDatabaseOnStart( init_database_checkbox.isSelected() );
            }
        } );

        JLabel label = new JLabel( "Console URL:" );
        c = new GridBagConstraints( 0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
                new Insets( 16, 24, 8, 0 ), 0, 0 );
        label.setFont( new Font( "Arial", Font.BOLD, 18 ) );
        pane.add( label, c );

        String[] urls = app.getUrlsFromPreferences();
        urlList = new JComboBox( urls );
        urlList.setEditable( true );
        c = new GridBagConstraints( 1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE,
                new Insets( 16, 0, 8, 16 ), 0, 0 );
        urlList.setFont( new Font( "Arial", Font.BOLD, 18 ) );

        urlList.setPrototypeDisplayValue( "XXXXXXXXXXXXXXXXXXXX" );

        ComboBoxEditor editor = urlList.getEditor();
        JTextField textField = ( JTextField ) editor.getEditorComponent();
        textField.setColumns( 20 );

        setPreferredWidth( textField, 350 );
        setMaxWidth( textField, 350 );

        setPreferredWidth( urlList, 350 );
        setMaxWidth( urlList, 350 );

        pane.add( urlList, c );

        auto_login_checkbox = new JCheckBox( "Auto-login as:" );
        c = new GridBagConstraints( 0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
                new Insets( 16, 16, 8, 0 ), 0, 0 );
        auto_login_checkbox.setSelected( app.isAutoLogin() );
        auto_login_checkbox.setFont( new Font( "Arial", Font.BOLD, 18 ) );
        pane.add( auto_login_checkbox, c );
        auto_login_checkbox.addChangeListener( new ChangeListener() {
            @Override
            public void stateChanged( ChangeEvent change ) {
                app.setAutoLogin( auto_login_checkbox.isSelected() );
            }
        } );

        auto_login_email = new JTextField( app.getAdminUserEmail() );
        c = new GridBagConstraints( 1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
                new Insets( 16, 0, 8, 16 ), 0, 0 );
        auto_login_email.setFont( new Font( "Arial", Font.BOLD, 18 ) );
        pane.add( auto_login_email, c );

        label = new JLabel( "* Database can only be started or initialized once per app launch" );
        c = new GridBagConstraints( 0, 5, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
                new Insets( 16, 16, 16, 0 ), 0, 0 );
        label.setForeground( Color.RED );
        label.setFont( new Font( "Arial", Font.BOLD, 12 ) );
        pane.add( label, c );

        List<Image> icons = new ArrayList<Image>( 4 );
        icons.add( new ImageIcon( getClass().getClassLoader().getResource( "org/apache/usergrid/launcher/icon_16.png" ) )
                .getImage() );
        icons.add( new ImageIcon( getClass().getClassLoader().getResource( "org/apache/usergrid/launcher/icon_32.png" ) )
                .getImage() );
        icons.add( new ImageIcon( getClass().getClassLoader().getResource( "org/apache/usergrid/launcher/icon_64.png" ) )
                .getImage() );
        icons.add( new ImageIcon( getClass().getClassLoader().getResource( "org/apache/usergrid/launcher/icon_256.png" ) )
                .getImage() );
        setIconImages( icons );
    }