Example usage for java.awt FlowLayout RIGHT

List of usage examples for java.awt FlowLayout RIGHT

Introduction

In this page you can find the example usage for java.awt FlowLayout RIGHT.

Prototype

int RIGHT

To view the source code for java.awt FlowLayout RIGHT.

Click Source Link

Document

This value indicates that each row of components should be right-justified.

Usage

From source file:com.accenture.assets.ui.dialogs.panels.NewProjectConfigurationDialogPanel.java

/**
 * /* w ww  .ja v a2  s.com*/
 * @return
 */
private JPanel getButtonsPanel() {
    if (buttonsPanel == null) {
        buttonsPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
        buttonsPanel.setName("buttonsPanel");
    }
    buttonsPanel.add(this.getCreateButton());
    buttonsPanel.add(this.getCancelButton());
    return buttonsPanel;
}

From source file:org.nebulaframework.ui.swing.cluster.ClusterMainUI.java

/**
 * Setup the General Tab Pane/* w  w  w .  j a v a  2s  .co  m*/
 * 
 * @return JPanel for pane
 */
private JPanel setupGeneralTab() {

    JPanel generalTab = new JPanel();
    generalTab.setLayout(new BorderLayout());

    /* -- Create Main Panels -- */

    JPanel centerPanel = new JPanel();
    JPanel northPanel = new JPanel();
    JPanel southPanel = new JPanel();

    generalTab.add(centerPanel, BorderLayout.CENTER);
    generalTab.add(northPanel, BorderLayout.NORTH);

    /* -- Create Center Contents -- */

    // Statistics Panel
    JPanel statsPanel = setupStatsPanel();

    // Log Panel
    JPanel logPanel = new JPanel();
    logPanel.setLayout(new BorderLayout());
    logPanel.setBorder(BorderFactory.createTitledBorder("Log Output"));
    JTextPane logTextPane = new JTextPane();
    logTextPane.setEditable(false);
    logTextPane.setBackground(Color.BLACK);
    logTextPane.setForeground(Color.WHITE);

    logPanel.add(new JScrollPane(logTextPane, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED), BorderLayout.CENTER);
    addUIElement("general.log", logTextPane); // Add to component map

    JPanel logOptionsPanel = new JPanel();
    logPanel.add(logOptionsPanel, BorderLayout.SOUTH);
    logOptionsPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));

    final JCheckBox logScrollCheckbox = new JCheckBox("Auto-Scroll Log");
    logScrollCheckbox.setSelected(true);
    logScrollCheckbox.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            JTextPaneAppender.setAutoScroll(logScrollCheckbox.isSelected());
        }

    });
    logOptionsPanel.add(logScrollCheckbox);

    // Enable Logging
    JTextPaneAppender.setTextPane(logTextPane);

    centerPanel.setLayout(new BorderLayout(10, 10));
    centerPanel.add(statsPanel, BorderLayout.NORTH);
    centerPanel.add(logPanel, BorderLayout.CENTER);

    /* -- Create Buttons (South) -- */

    generalTab.add(southPanel, BorderLayout.SOUTH);

    final JButton shutdownButton = new JButton("Shutdown");
    shutdownButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            doShutdownCluster();
        }
    });

    southPanel.setLayout(new FlowLayout(FlowLayout.RIGHT, 10, 10));
    southPanel.add(shutdownButton);
    addUIElement("general.shutdown", shutdownButton); // Add to components map

    return generalTab;
}

From source file:org.p_vcd.ui.VcdDialog.java

public VcdDialog() {
    setSize(700, 450);//from w  ww  .j av a 2s  .  co m
    setTitle("P-VCD - Video Copy Detection");
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    this.currentStep = 1;

    getContentPane().setLayout(new BorderLayout());
    contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
    getContentPane().add(contentPanel, BorderLayout.CENTER);
    contentPanel.setLayout(new CardLayout(0, 0));
    {
        JPanel panel_Step1 = new JPanel();
        contentPanel.add(panel_Step1, "card_step1");
        panel_Step1.setLayout(new BorderLayout(0, 0));
        JLabel lblTitle = new JLabel("STEP 1 - Video Database (the \"known\")");
        panel_Step1.add(lblTitle, BorderLayout.NORTH);
        lblTitle.setHorizontalAlignment(SwingConstants.CENTER);
        lblTitle.setFont(new Font("Tahoma", Font.PLAIN, 18));

        JPanel panel_1 = new JPanel();
        panel_Step1.add(panel_1, BorderLayout.CENTER);
        panel_1.setLayout(new MigLayout("", "[250px,grow][20px][250px,grow]", "[][][230px,grow][][][]"));

        JLabel lblNewLabel = new JLabel("Please select the video databases to search in:");
        panel_1.add(lblNewLabel, "cell 0 0");

        panel_1.add(lbl_refDbTitle, "cell 2 1");

        JScrollPane scrollPane_1 = new JScrollPane();
        panel_1.add(scrollPane_1, "cell 0 1 1 3,grow");
        panel_refDatabasesList.setBackground(Color.WHITE);

        scrollPane_1.setViewportView(panel_refDatabasesList);
        panel_refDatabasesList.setLayout(new MigLayout("gapy 10", "[200px]", "[][]"));

        JScrollPane scrollPane = new JScrollPane();
        scrollPane.setBorder(null);
        panel_1.add(scrollPane, "cell 2 2,grow");

        scrollPane.setViewportView(lbl_refDbFiles);

        panel_1.add(lbl_refDbMetadata, "cell 2 3");

        JButton btnNewDatabase = new JButton("New database...");
        panel_1.add(btnNewDatabase, "cell 0 4");
        btnNewDatabase.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                newDatabaseButton();
            }
        });
    }
    {
        JPanel panel_Step2 = new JPanel();
        contentPanel.add(panel_Step2, "card_step2");
        panel_Step2.setLayout(new BorderLayout(0, 0));
        JLabel lblTitle = new JLabel("STEP 2 - Query (the \"unknown\")");
        panel_Step2.add(lblTitle, BorderLayout.NORTH);
        lblTitle.setHorizontalAlignment(SwingConstants.CENTER);
        lblTitle.setFont(new Font("Tahoma", Font.PLAIN, 18));

        JPanel panel = new JPanel();
        panel.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Query",
                TitledBorder.LEADING, TitledBorder.TOP, null, null));
        panel_Step2.add(panel, BorderLayout.CENTER);
        panel.setLayout(
                new MigLayout("", "[160px][grow]", "[25px][grow,top][25px][grow,top][25px][grow,top][grow]"));

        ButtonGroup queryButtonGroup = new ButtonGroup();

        queryButtonGroup.add(radio_queryFile);
        radio_queryFile.setFont(new Font("Tahoma", Font.PLAIN, 13));
        panel.add(radio_queryFile, "cell 0 0");

        lbl_queryFile.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                radio_queryFile.setSelected(true);
            }
        });
        panel.add(lbl_queryFile, "flowy,cell 1 0");

        JButton btnSelectFile = new JButton("Select File...");
        btnSelectFile.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                selectFileButton();
            }
        });
        panel.add(btnSelectFile, "cell 1 0");

        JLabel lblIumageOrVideo = new JLabel("Select an image or video in the local machine.");
        panel.add(lblIumageOrVideo, "cell 1 1");

        queryButtonGroup.add(radio_queryUrl);
        radio_queryUrl.setFont(new Font("Tahoma", Font.PLAIN, 13));
        panel.add(radio_queryUrl, "cell 0 2");

        txt_queryUrl.addKeyListener(new KeyAdapter() {
            @Override
            public void keyReleased(KeyEvent e) {
                radio_queryUrl.setSelected(true);
            }
        });
        txt_queryUrl.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                radio_queryUrl.setSelected(true);
            }
        });
        txt_queryUrl.addFocusListener(new FocusAdapter() {
            @Override
            public void focusGained(FocusEvent e) {
                radio_queryUrl.setSelected(true);
            }
        });
        txt_queryUrl.setText("http://");
        panel.add(txt_queryUrl, "flowy,cell 1 2");
        txt_queryUrl.setColumns(50);

        JLabel lblUrlToA = new JLabel(
                "<html>Enter the URL to download an image or video.<br>You can use a URL like: http://www.youtube.com/watch?v=... </html>");
        panel.add(lblUrlToA, "flowy,cell 1 3");

        queryButtonGroup.add(radio_queryDb);
        radio_queryDb.setFont(new Font("Tahoma", Font.PLAIN, 13));
        panel.add(radio_queryDb, "cell 0 4");

        comboBox_queryDb.setMaximumRowCount(12);
        comboBox_queryDb.setPreferredSize(new Dimension(100, 20));
        comboBox_queryDb.setMinimumSize(new Dimension(100, 20));
        comboBox_queryDb.addPropertyChangeListener(new PropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent evt) {
                if (comboBox_queryDb.getSelectedIndex() > 0)
                    radio_queryDb.setSelected(true);
                updateQueryDbDetail();
            }
        });
        comboBox_queryDb.addKeyListener(new KeyAdapter() {
            @Override
            public void keyReleased(KeyEvent e) {
                if (comboBox_queryDb.getSelectedIndex() > 0)
                    radio_queryDb.setSelected(true);
                updateQueryDbDetail();
            }
        });

        panel.add(comboBox_queryDb, "flowx,cell 1 4");

        panel.add(lbl_queryDb, "cell 1 4");

        JLabel lblPleaseNopteThe = new JLabel("<html>A search is run for each video in the database.</html>");
        panel.add(lblPleaseNopteThe, "cell 1 5");

    }
    {
        JPanel panel_Step3 = new JPanel();
        contentPanel.add(panel_Step3, "card_step3");
        panel_Step3.setLayout(new BorderLayout(0, 0));

        JLabel lblTitle = new JLabel("STEP 3 - Search Options");
        lblTitle.setFont(new Font("Tahoma", Font.PLAIN, 18));
        lblTitle.setHorizontalAlignment(SwingConstants.CENTER);
        panel_Step3.add(lblTitle, BorderLayout.NORTH);

        JPanel panel2 = new JPanel();
        panel2.setLayout(new FlowLayout());
        panel_Step3.add(panel2, BorderLayout.CENTER);
        JPanel panel = new JPanel();
        panel2.add(panel);
        panel.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Basic Options",
                TitledBorder.LEADING, TitledBorder.TOP, null, null));
        panel.setLayout(new MigLayout("gapy 5px", "[30px][101px]", "[][][][][][][20px]"));

        ButtonGroup buttonGroup = new ButtonGroup();

        buttonGroup.add(radio_searchByGlobal);
        radio_searchByGlobal.setFont(new Font("Tahoma", Font.PLAIN, 13));
        radio_searchByGlobal.setSelected(true);
        panel.add(radio_searchByGlobal, "cell 0 0 2 1,alignx left,aligny top");

        JLabel lblNewLabel_2 = new JLabel(
                "Detects most of the copies that are visually alike to the original.");
        panel.add(lblNewLabel_2, "cell 1 1");

        JButton btnOptions = new JButton("Advanced Options...");
        btnOptions.setEnabled(false);
        panel.add(btnOptions, "cell 1 2");

        buttonGroup.add(radio_searchByLocal);
        radio_searchByLocal.setFont(new Font("Tahoma", Font.PLAIN, 13));
        panel.add(radio_searchByLocal, "cell 0 4 2 1,alignx left,aligny top");

        JLabel lblNewLabel_3 = new JLabel(
                "Requires more resources (disk space, search time, memory) but can detect more copies.");
        panel.add(lblNewLabel_3, "cell 1 5");

        JButton btnOptions_1 = new JButton("Advanced Options...");
        btnOptions_1.setEnabled(false);
        panel.add(btnOptions_1, "cell 1 6");

    }
    {
        JPanel panel_Step4 = new JPanel();
        contentPanel.add(panel_Step4, "card_step4");
        panel_Step4.setLayout(new BorderLayout(0, 0));

        JLabel lblTitle = new JLabel("STEP 4 - Search");
        lblTitle.setHorizontalAlignment(SwingConstants.CENTER);
        lblTitle.setFont(new Font("Tahoma", Font.PLAIN, 18));
        panel_Step4.add(lblTitle, BorderLayout.NORTH);

        JScrollPane scrollPane = new JScrollPane();
        panel_Step4.add(scrollPane, BorderLayout.CENTER);

        textConsole.setFont(new Font("Monospaced", Font.PLAIN, 11));
        textConsole.setForeground(Color.WHITE);
        textConsole.setBackground(Color.BLACK);
        textConsole.setEditable(false);
        textConsole.setCursor(new Cursor(Cursor.TEXT_CURSOR));
        textConsole.setText(
                "Press 'Next' button to start the search...\nNote: Depending on the selected options, the search may take up to several hours.");
        scrollPane.setViewportView(textConsole);

        JPanel panel = new JPanel();
        panel_Step4.add(panel, BorderLayout.SOUTH);
        panel.setLayout(new GridLayout(0, 1, 0, 0));

        JSeparator separator = new JSeparator();
        separator.setPreferredSize(new Dimension(0, 1));
        panel.add(separator);
        progressBar.setStringPainted(true);
        progressBar.setPreferredSize(new Dimension(350, 20));
        panel.add(progressBar);

        lblProgress.setHorizontalAlignment(SwingConstants.CENTER);
        lblProgress.setFont(new Font("Tahoma", Font.PLAIN, 14));
        panel.add(lblProgress);
    }
    {
        JPanel panel_Step5 = new JPanel();
        contentPanel.add(panel_Step5, "card_step5");
        panel_Step5.setLayout(new BorderLayout(0, 0));

        JLabel lblTitle = new JLabel("STEP 5 - Results");
        lblTitle.setHorizontalAlignment(SwingConstants.CENTER);
        lblTitle.setFont(new Font("Tahoma", Font.PLAIN, 18));
        panel_Step5.add(lblTitle, BorderLayout.NORTH);

        JScrollPane scrollPane = new JScrollPane();
        panel_Step5.add(scrollPane, BorderLayout.CENTER);

        scrollPane.setViewportView(panelResults);
        panelResults.setLayout(new MigLayout("gapy 10, gapx 20",
                "[120px,center][150px,center,grow][150px,center,grow]", "[25px][]"));

    }
    {
        JPanel buttonPane = new JPanel();
        buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
        getContentPane().add(buttonPane, BorderLayout.SOUTH);
        {
            JButton prevButton = new JButton("Previous");
            prevButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    previousButton();
                }
            });
            prevButton.setActionCommand("Previous");
            buttonPane.add(prevButton);
        }
        {
            JButton okButton = new JButton("Next");
            okButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    nextButton();
                }
            });
            okButton.setActionCommand("OK");
            buttonPane.add(okButton);
            getRootPane().setDefaultButton(okButton);
        }
        {
            JButton cancelButton = new JButton("Cancel");
            cancelButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    cancelButton();
                }
            });
            cancelButton.setActionCommand("Cancel");
            buttonPane.add(cancelButton);
        }
    }
    this.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosed(WindowEvent e) {
            closeWindow();
        }
    });
    updateDatabases(null);
}

From source file:eu.delving.sip.Application.java

private static void memoryNotConfigured() {
    String os = System.getProperty("os.name");
    Runtime rt = Runtime.getRuntime();
    int totalMemory = (int) (rt.totalMemory() / 1024 / 1024);
    StringBuilder out = new StringBuilder();
    String JAR_NAME = "SIP-Creator-2014-XX-XX.jar";
    if (os.startsWith("Windows")) {
        out.append(":: SIP-Creator Startup Batch file for Windows (more memory than ").append(totalMemory)
                .append("Mb)\n");
        out.append("java -jar -Xms1024m -Xmx1024m ").append(JAR_NAME);
    } else if (os.startsWith("Mac")) {
        out.append("# SIP-Creator Startup Script for Mac OSX (more memory than ").append(totalMemory)
                .append("Mb)\n");
        out.append("java -jar -Xms1024m -Xmx1024m ").append(JAR_NAME);
    } else {//from w  w w .ja va  2  s .c o  m
        System.out.println("Unrecognized OS: " + os);
    }
    String script = out.toString();
    final JDialog dialog = new JDialog(null, "Memory Not Configured Yet!",
            Dialog.ModalityType.APPLICATION_MODAL);
    JTextArea scriptArea = new JTextArea(3, 40);
    scriptArea.setText(script);
    scriptArea.setSelectionStart(0);
    scriptArea.setSelectionEnd(script.length());
    JPanel scriptPanel = new JPanel(new BorderLayout());
    scriptPanel.setBorder(BorderFactory.createTitledBorder("Script File"));
    scriptPanel.add(scriptArea, BorderLayout.CENTER);
    JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    buttonPanel.setBorder(BorderFactory.createEmptyBorder(15, 15, 15, 15));
    JButton ok = new JButton("OK, Continue anyway");
    ok.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            dialog.setVisible(false);
            EventQueue.invokeLater(LAUNCH);
        }
    });
    buttonPanel.add(ok);
    JPanel centralPanel = new JPanel(new GridLayout(0, 1));
    centralPanel.setBorder(BorderFactory.createEmptyBorder(15, 25, 15, 25));
    centralPanel.add(
            new JLabel("<html><b>The SIP-Creator started directly can have too little default memory allocated."
                    + "<br>It should be started with the following script:</b>"));
    centralPanel.add(scriptPanel);
    centralPanel.add(new JLabel(
            "<html><b>Please copy the above text into a batch or script file and execute that instead.</b>"));
    dialog.getContentPane().add(centralPanel, BorderLayout.CENTER);
    dialog.getContentPane().add(buttonPanel, BorderLayout.SOUTH);
    dialog.pack();
    Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
    int x = (int) ((dimension.getWidth() - dialog.getWidth()) / 2);
    int y = (int) ((dimension.getHeight() - dialog.getHeight()) / 2);
    dialog.setLocation(x, y);
    dialog.setVisible(true);
}

From source file:net.sf.taverna.t2.activities.wsdlsir.views.WSDLActivityConfigurationView.java

private void initComponents() {

    this.setModalityType(Dialog.ModalityType.DOCUMENT_MODAL);

    int gridy = 0;

    // title panel
    JPanel titlePanel = new JPanel(new BorderLayout());
    titlePanel.setBackground(Color.WHITE);
    JLabel titleLabel = new JLabel("Security configuration");
    titleLabel.setFont(titleLabel.getFont().deriveFont(Font.BOLD, 13.5f));
    titleLabel.setBorder(new EmptyBorder(10, 10, 0, 10));
    DialogTextArea titleMessage = new DialogTextArea("Select a security profile for the service");
    titleMessage.setMargin(new Insets(5, 20, 10, 10));
    titleMessage.setFont(titleMessage.getFont().deriveFont(11f));
    titleMessage.setEditable(false);//w w  w  . j a va2 s  .co  m
    titleMessage.setFocusable(false);
    titlePanel.setBorder(new EmptyBorder(10, 10, 0, 10));
    titlePanel.add(titleLabel, BorderLayout.NORTH);
    titlePanel.add(titleMessage, BorderLayout.CENTER);
    addDivider(titlePanel, SwingConstants.BOTTOM, true);

    // Main panel
    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new GridBagLayout());
    mainPanel.setBorder(new EmptyBorder(10, 10, 10, 10));

    //Create the radio buttons
    noSecurityRadioButton = new JRadioButton("None");
    noSecurityRadioButton.addItemListener(this);

    wsSecurityAuthNRadioButton = new JRadioButton("WS-Security username and password authentication");
    wsSecurityAuthNRadioButton.addItemListener(this);

    httpSecurityAuthNRadioButton = new JRadioButton("HTTP username and password authentication");
    httpSecurityAuthNRadioButton.addItemListener(this);

    SAMLSecurityAuthNRadioButton = new JRadioButton("SAML WEB SSO profile authentication");
    SAMLSecurityAuthNRadioButton.addItemListener(this);

    //Group the radio buttons
    buttonGroup = new ButtonGroup();
    buttonGroup.add(noSecurityRadioButton);
    buttonGroup.add(wsSecurityAuthNRadioButton);
    buttonGroup.add(httpSecurityAuthNRadioButton);
    buttonGroup.add(SAMLSecurityAuthNRadioButton);

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.weightx = 1.0;
    gbc.weighty = 0.0;

    gbc.gridx = 0;
    gbc.gridy = gridy++;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(5, 10, 0, 0);
    mainPanel.add(noSecurityRadioButton, gbc);

    noSecurityLabel = new JLabel("Service requires no security");
    noSecurityLabel.setFont(noSecurityLabel.getFont().deriveFont(11f));
    //      addDivider(noSecurityLabel, SwingConstants.BOTTOM, false);
    gbc.gridx = 0;
    gbc.gridy = gridy++;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(0, 40, 10, 10);
    mainPanel.add(noSecurityLabel, gbc);

    gbc.gridx = 0;
    gbc.gridy = gridy++;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(5, 10, 0, 0);
    mainPanel.add(httpSecurityAuthNRadioButton, gbc);

    ActionListener usernamePasswordListener = new ActionListener() {

        public void actionPerformed(ActionEvent e) {

            // Get Credential Manager UI to get the username and password for the service
            CredentialManagerUI credManagerUI = CredentialManagerUI.getInstance();
            if (credManagerUI != null)
                credManagerUI.newPasswordForService(oldBean.getWsdl());
        }
    };

    httpSecurityAuthNLabel = new JLabel(
            "Service requires HTTP username and password in order to authenticate the user");
    httpSecurityAuthNLabel.setFont(httpSecurityAuthNLabel.getFont().deriveFont(11f));
    gbc.gridx = 0;
    gbc.gridy = gridy++;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(0, 40, 10, 10);
    mainPanel.add(httpSecurityAuthNLabel, gbc);

    // Set username and password button;
    setHttpUsernamePasswordButton = new JButton("Set username and password");
    gbc.gridx = 0;
    gbc.gridy = gridy++;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.EAST;
    gbc.insets = new Insets(0, 40, 10, 10);
    gbc.weightx = 1.0;
    gbc.weighty = 1.0; // add any vertical space to this component
    mainPanel.add(setHttpUsernamePasswordButton, gbc);
    setHttpUsernamePasswordButton.addActionListener(usernamePasswordListener);

    /////SAML

    gbc.gridx = 0;
    gbc.gridy = gridy++;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(5, 10, 0, 0);
    mainPanel.add(SAMLSecurityAuthNRadioButton, gbc);

    ActionListener getCookieListener = new ActionListener() {

        /**
         * This listener will use the CallPreparator to obtain the cookies (included shibsession_XXX cookie) and 
         * save it in the Credential Manager (as the password for user "nomatter")
         */
        public void actionPerformed(ActionEvent e) {
            try {
                WSDLParser parser = new WSDLParser(newBean.getWsdl());
                List<String> endpoints = parser.getOperationEndpointLocations(newBean.getOperation());
                for (String endpoint : endpoints) //Actually i am only expecting one endpoint
                {
                    if (debug)
                        System.out
                                .println("Obtaining a SAML cookies to save in credential manager:" + endpoint);

                    Cookie[] cookies = CallPreparator.createCookieForCallToEndpoint(endpoint);

                    // Uncomment for just the shibsession cookie
                    //                  Cookie[] cookiessession = new Cookie[1];
                    //                  for (Cookie cook : cookies)
                    //                     if (cook.getName().contains("shibsession"))
                    //                        cookiessession[0]=cook;
                    //                  cookies=cookiessession;

                    CredentialManager credman = CredentialManager.getInstance();
                    credman.saveUsernameAndPasswordForService(
                            new UsernamePassword("nomatter", serializetoString(cookies)), new URI(endpoint));
                }
            } catch (WSDLException ex) {
                System.err.println(
                        "Problem getting or saving SAML cookie: " + newBean.getWsdl() + ". " + ex.getMessage());
                ex.printStackTrace();
            } catch (ParserConfigurationException ex) {
                System.err.println(
                        "Problem getting or saving SAML cookie: " + newBean.getWsdl() + ". " + ex.getMessage());
                ex.printStackTrace();
            } catch (Exception ex) {
                System.err.println(
                        "Problem getting or saving SAML cookie: " + newBean.getWsdl() + ". " + ex.getMessage());
                ex.printStackTrace();
            }
        }
    };

    SAMLSecurityAuthNLabel = new JLabel("<html>"
            + "Service requires SAML Web SSO profile to be perfomed in order to authenticate the user. "
            + "A cookie will be saved in your Credential Manger. "
            + "In the case that it stops working, please delete the entry in your Credential Manager or re-authenticate"
            + "</html>");
    SAMLSecurityAuthNLabel.setFont(SAMLSecurityAuthNLabel.getFont().deriveFont(11f));
    gbc.gridx = 0;
    gbc.gridy = gridy++;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(3, 40, 10, 10);
    mainPanel.add(SAMLSecurityAuthNLabel, gbc);

    // Set username and password button;
    setSAMLGETCookieButton = new JButton("Authenticate and save Authentication data in Credential Manger");
    gbc.gridx = 0;
    gbc.gridy = gridy++;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.EAST;
    gbc.insets = new Insets(0, 40, 10, 10);
    gbc.weightx = 1.0;
    gbc.weighty = 1.0; // add any vertical space to this component
    mainPanel.add(setSAMLGETCookieButton, gbc);
    setSAMLGETCookieButton.addActionListener(getCookieListener);

    //END SAML

    gbc.gridx = 0;
    gbc.gridy = gridy++;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(5, 10, 0, 0);
    mainPanel.add(wsSecurityAuthNRadioButton, gbc);

    wsSecurityAuthNLabel = new JLabel(
            "Service requires WS-Security username and password in order to authenticate the user");
    wsSecurityAuthNLabel.setFont(wsSecurityAuthNLabel.getFont().deriveFont(11f));
    gbc.gridx = 0;
    gbc.gridy = gridy++;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(0, 40, 0, 0);
    mainPanel.add(wsSecurityAuthNLabel, gbc);

    // Password type list
    passwordTypeComboBox = new JComboBox(passwordTypes);
    passwordTypeComboBox.setRenderer(new ComboBoxTooltipRenderer());
    gbc.gridx = 0;
    gbc.gridy = gridy++;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(10, 40, 0, 0);
    mainPanel.add(passwordTypeComboBox, gbc);

    // 'Add timestamp' checkbox
    addTimestampCheckBox = new JCheckBox("Add a timestamp to SOAP message");
    gbc.gridx = 0;
    gbc.gridy = gridy++;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(5, 40, 10, 10);
    mainPanel.add(addTimestampCheckBox, gbc);

    // Set username and password button;
    setWsdlUsernamePasswordButton = new JButton("Set username and password");
    gbc.gridx = 0;
    gbc.gridy = gridy++;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.EAST;
    gbc.insets = new Insets(0, 40, 10, 10);
    gbc.weightx = 1.0;
    gbc.weighty = 1.0; // add any vertical space to this component
    mainPanel.add(setWsdlUsernamePasswordButton, gbc);
    setWsdlUsernamePasswordButton.addActionListener(usernamePasswordListener);

    addDivider(mainPanel, SwingConstants.BOTTOM, true);

    // OK/Cancel button panel
    JPanel okCancelPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    JButton okButton = new JButton("OK");
    okButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            okPressed();
        }
    });
    JButton cancelButton = new JButton("Cancel");
    cancelButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            cancelPressed();
        }
    });
    okCancelPanel.add(cancelButton);
    okCancelPanel.add(okButton);

    // Enable/disable controls based on what is the current security profiles
    String securityProfile = oldBean.getSecurityProfile();
    if (securityProfile == null) {
        noSecurityRadioButton.setSelected(true);
    } else {
        if (securityProfile.equals(SecurityProfiles.WSSECURITY_USERNAMETOKEN_PLAINTEXTPASSWORD)
                || securityProfile.equals(SecurityProfiles.WSSECURITY_USERNAMETOKEN_DIGESTPASSWORD)
                || securityProfile.equals(SecurityProfiles.WSSECURITY_TIMESTAMP_USERNAMETOKEN_PLAINTEXTPASSWORD)
                || securityProfile.equals(SecurityProfiles.WSSECURITY_TIMESTAMP_USERNAMETOKEN_DIGESTPASSWORD)) {
            wsSecurityAuthNRadioButton.setSelected(true);
        }
        if (securityProfile.equals(SecurityProfiles.HTTP_BASIC_AUTHN)
                || securityProfile.equals(SecurityProfiles.HTTP_DIGEST_AUTHN)) {
            httpSecurityAuthNRadioButton.setSelected(true);
        }
        if (securityProfile.equals(SecurityProfiles.SAMLWEBSSOAUTH)) {
            SAMLSecurityAuthNRadioButton.setSelected(true);
        }
        if (securityProfile.equals(SecurityProfiles.WSSECURITY_USERNAMETOKEN_PLAINTEXTPASSWORD)
                || securityProfile
                        .equals(SecurityProfiles.WSSECURITY_TIMESTAMP_USERNAMETOKEN_PLAINTEXTPASSWORD)) {
            passwordTypeComboBox.setSelectedItem(PLAINTEXT_PASSWORD);
        } else if (securityProfile.equals(SecurityProfiles.WSSECURITY_USERNAMETOKEN_DIGESTPASSWORD)
                || securityProfile.equals(SecurityProfiles.WSSECURITY_TIMESTAMP_USERNAMETOKEN_DIGESTPASSWORD)) {
            passwordTypeComboBox.setSelectedItem(DIGEST_PASSWORD);
        }
        if (securityProfile.equals(SecurityProfiles.WSSECURITY_TIMESTAMP_USERNAMETOKEN_DIGESTPASSWORD)
                || securityProfile
                        .equals(SecurityProfiles.WSSECURITY_TIMESTAMP_USERNAMETOKEN_PLAINTEXTPASSWORD)) {
            addTimestampCheckBox.setSelected(true);
        } else {
            addTimestampCheckBox.setSelected(false);
        }
    }

    // Put everything together
    JPanel layoutPanel = new JPanel(new BorderLayout());
    layoutPanel.add(titlePanel, BorderLayout.NORTH);
    layoutPanel.add(mainPanel, BorderLayout.CENTER);
    layoutPanel.add(okCancelPanel, BorderLayout.SOUTH);
    layoutPanel.setPreferredSize(new Dimension(550, 490));

    this.getContentPane().add(layoutPanel);
    this.pack();
}

From source file:org.tellervo.desktop.io.ImportDialog.java

private void initGui() {
    setTitle("Import to Database");
    setBounds(100, 100, 804, 734);/* ww w. j a v a2s . c  o  m*/

    getContentPane().setLayout(new BorderLayout());
    contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
    getContentPane().add(contentPanel, BorderLayout.CENTER);
    contentPanel.setLayout(new BorderLayout(0, 0));
    {
        horizSplitPane = new JSplitPane();
        horizSplitPane.setOneTouchExpandable(true);
        horizSplitPane.setBorder(null);
        horizSplitPane.setDividerLocation(0.4);
        contentPanel.add(horizSplitPane);
        {
            splitPaneVert = new JSplitPane();
            splitPaneVert.setOneTouchExpandable(true);
            splitPaneVert.setBorder(null);
            splitPaneVert.setOrientation(JSplitPane.VERTICAL_SPLIT);
            horizSplitPane.setLeftComponent(splitPaneVert);
            {
                panelTreeTable = new JPanel();
                panelTreeTable.setBorder(new TitledBorder(null, "TRiDaS Representation", TitledBorder.LEADING,
                        TitledBorder.TOP, null, null));
                splitPaneVert.setLeftComponent(panelTreeTable);
                panelTreeTable.setLayout(new BorderLayout(0, 0));
                {
                    JButton btnSetFromDB = new JButton("Set current entity from database");
                    panelTreeTable.add(btnSetFromDB, BorderLayout.SOUTH);
                }
            }
            {
                panelWarnings = new JPanel();
                panelWarnings.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null),
                        "Warnings", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)));
                splitPaneVert.setRightComponent(panelWarnings);
                panelWarnings.setLayout(new BorderLayout(0, 0));
                {
                    JScrollPane scrollPane = new JScrollPane();
                    panelWarnings.add(scrollPane, BorderLayout.CENTER);
                    {
                        tblWarnings = new JTable();
                        scrollPane.setViewportView(tblWarnings);
                    }
                }
            }
        }
        {
            tabbedPane = new JTabbedPane(JTabbedPane.TOP);
            tabbedPane.setBorder(null);
            horizSplitPane.setRightComponent(tabbedPane);
            {
                JPanel panelMetadata = new JPanel();
                panelMetadata.setLayout(new BorderLayout());
                initPropertiesPanel();

                panelMetadata.add(propertiesPanel, BorderLayout.CENTER);
                tabbedPane.addTab("Metadata", null, panelMetadata, null);

            }
            {
                JPanel panelData = new JPanel();
                tabbedPane.addTab("Data", null, panelData, null);
                tabbedPane.setEnabledAt(1, false);
            }
            {
                panelOrigFile = new JPanel();
                tabbedPane.addTab("Original file", null, panelOrigFile, null);
                panelOrigFile.setLayout(new BorderLayout(0, 0));
                {
                    DefaultSyntaxKit.initKit();

                }
                {
                    JScrollPane scrollPane = new JScrollPane();
                    panelOrigFile.add(scrollPane, BorderLayout.CENTER);

                    originalFilePane = new JTextArea();
                    scrollPane.setViewportView(originalFilePane);
                    originalFilePane.setEditable(false);
                    originalFilePane.setFont(new java.awt.Font("Courier", 0, 12));
                }
            }
        }
    }
    {
        JPanel buttonPane = new JPanel();
        buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
        getContentPane().add(buttonPane, BorderLayout.SOUTH);
        {
            JButton button = new JButton("Finish");
            buttonPane.add(button);
        }
    }
}

From source file:org.gumtree.vis.plot1d.Plot1DChartEditor.java

private JPanel createMaskingPanel(JFreeChart chart) {
    JPanel wrap = new JPanel(new BorderLayout());

    JPanel maskingPanel = new JPanel(new GridLayout(1, 1));
    maskingPanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));

    //Horizontal group
    JPanel managePanel = new JPanel(new BorderLayout());
    managePanel.setBorder(/*from  w  w w  .j a v  a 2  s .  c o m*/
            BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Region of Interests"));

    JPanel inner = new JPanel(new LCBLayout(6));
    inner.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
    inner.add(new JLabel("Select Region"));
    roiCombo = new JComboBox(panel.getMasks().toArray());
    //      colourScaleCombo.setMaximumRowCount(7);
    roiCombo.setSelectedIndex(-1);
    roiCombo.setActionCommand(CHANGE_ROI_COMMAND);
    roiCombo.addActionListener(this);
    inner.add(roiCombo);
    inner.add(new JLabel());

    inner.add(new JLabel("or create"));
    newRectangleButton = new JButton("New Region of Interests");
    newRectangleButton.setActionCommand(CREATE_NEW_RECT_REGION_COMMAND);
    newRectangleButton.addActionListener(this);
    inner.add(newRectangleButton);
    inner.add(new JLabel());

    JPanel editPanel = new JPanel(new BorderLayout());
    editPanel
            .setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Edit the Region"));

    JPanel editInner = new JPanel(new LCBLayout(6));
    editInner.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
    editInner.add(new JLabel("Name"));
    roiName = new JTextField(10);
    //      colourScaleCombo.setMaximumRowCount(7);
    roiName.setActionCommand(CHANGE_ROI_NAME_COMMAND);
    roiName.addActionListener(this);
    editInner.add(roiName);
    editInner.add(new JLabel());

    editInner.add(new JLabel("Usage"));
    ButtonGroup buttonGroup = new ButtonGroup();
    JPanel radioPanel = new JPanel(new GridLayout(1, 2));
    inclusiveRadio = new JRadioButton("inclusive");
    inclusiveRadio.setActionCommand(USE_INCLUSIVE_COMMAND);
    inclusiveRadio.addActionListener(this);
    buttonGroup.add(inclusiveRadio);
    radioPanel.add(inclusiveRadio);
    exclusiveRadio = new JRadioButton("exclusive");
    exclusiveRadio.setActionCommand(USE_EXCLUSIVE_COMMAND);
    exclusiveRadio.addActionListener(this);
    buttonGroup.add(exclusiveRadio);
    radioPanel.add(exclusiveRadio);
    editInner.add(radioPanel);
    editInner.add(new JLabel());

    editInner.add(new JLabel("X Range"));
    JPanel xRangePanel = new JPanel(new GridLayout(1, 2));
    JPanel xMinPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    xMinPanel.add(new JLabel("min: "));
    xMin = new JTextField(10);
    //      xMin.setActionCommand(CHANGE_XMIN_COMMAND);
    //      xMin.addActionListener(this);
    xMin.addKeyListener(this);
    xMinPanel.add(xMin);
    xRangePanel.add(xMinPanel);
    JPanel xMaxPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    xMaxPanel.add(new JLabel("max: "));
    xMax = new JTextField(10);
    //      xMax.setActionCommand(CHANGE_XMAX_COMMAND);
    xMax.addKeyListener(this);
    xMaxPanel.add(xMax);
    xRangePanel.add(xMaxPanel);
    editInner.add(xRangePanel);
    editInner.add(new JLabel());

    editInner.add(new JLabel());
    JPanel applyPanel = new JPanel(new GridLayout(1, 2));
    deleteButton = new JButton("Remove");
    deleteButton.setEnabled(false);
    deleteButton.setActionCommand(REMOVE_CHANGE_ACTION);
    deleteButton.addActionListener(this);
    applyPanel.add(deleteButton);
    applyPanel.add(new JLabel());
    applyButton = new JButton("Apply");
    applyButton.setEnabled(false);
    applyButton.setActionCommand(APPLY_CHANGE_ACTION);
    applyButton.addActionListener(this);
    applyPanel.add(applyButton);
    editInner.add(applyPanel);
    editInner.add(new JLabel());
    //      inner.add(new JLabel("X Range"));
    //      inner.add(inclusiveRadio);
    //      exclusiveRadio = new JRadioButton("exclusive");
    //      exclusiveRadio.setActionCommand(USE_EXCLUSIVE_COMMAND);
    //      exclusiveRadio.addActionListener(this);
    //      inner.add(exclusiveRadio);
    editPanel.add(editInner, BorderLayout.NORTH);
    managePanel.add(editPanel, BorderLayout.SOUTH);
    managePanel.add(inner, BorderLayout.NORTH);
    maskingPanel.add(managePanel);
    wrap.setName("ROI");

    wrap.add(maskingPanel, BorderLayout.NORTH);
    return wrap;
}

From source file:uk.ac.ucl.cs.cmic.giftcloud.uploadapp.ConfigurationDialog.java

ConfigurationDialog(final Component owner, final UploaderGuiController controller,
        final GiftCloudPropertiesFromApplication giftCloudProperties, final ProjectListModel projectListModel,
        final ResourceBundle resourceBundle, final GiftCloudDialogs giftCloudDialogs,
        final GiftCloudReporter reporter) {
    this.controller = controller;
    this.giftCloudProperties = giftCloudProperties;
    this.projectListModel = projectListModel;
    this.resourceBundle = resourceBundle;
    this.giftCloudDialogs = giftCloudDialogs;
    this.reporter = reporter;
    temporaryDropDownListModel = new TemporaryProjectListModel(projectListModel,
            giftCloudProperties.getLastProject());
    componentToCenterDialogOver = owner;

    dialog = new JDialog();
    dialog.setModal(true);/*from  w  w  w . jav  a 2 s .  c o  m*/
    dialog.setResizable(false);

    // Call custom dialog close code when the close button is clicked
    dialog.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    dialog.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent ev) {
            closeDialog();
        }
    });

    dialog.setLocationRelativeTo(componentToCenterDialogOver); // without this, appears at TLHC rather then center of parent or screen
    dialog.setTitle(resourceBundle.getString("configurationDialogTitle"));

    final GridBagConstraints sectionTitleConstraints = new GridBagConstraints();
    sectionTitleConstraints.gridx = 0;
    sectionTitleConstraints.gridy = 1;
    sectionTitleConstraints.gridwidth = 2;
    sectionTitleConstraints.weightx = 1;
    sectionTitleConstraints.weighty = 1;
    sectionTitleConstraints.anchor = GridBagConstraints.CENTER;
    sectionTitleConstraints.fill = GridBagConstraints.HORIZONTAL;

    final GridBagConstraints labelConstraints = new GridBagConstraints();
    labelConstraints.gridx = 0;
    labelConstraints.gridy = 0;
    labelConstraints.gridwidth = 1;
    labelConstraints.weightx = 1;
    labelConstraints.weighty = 1;
    labelConstraints.anchor = GridBagConstraints.LINE_START;
    labelConstraints.fill = GridBagConstraints.NONE;

    final GridBagConstraints inputConstraints = new GridBagConstraints();
    inputConstraints.gridx = 1;
    inputConstraints.gridy = 0;
    inputConstraints.gridwidth = 1;
    inputConstraints.weightx = 1;
    inputConstraints.weighty = 1;
    inputConstraints.anchor = GridBagConstraints.LINE_END;
    inputConstraints.fill = GridBagConstraints.HORIZONTAL;

    GridBagConstraints separatorConstraint = new GridBagConstraints();
    separatorConstraint.weightx = 1.0;
    separatorConstraint.fill = GridBagConstraints.HORIZONTAL;
    separatorConstraint.gridwidth = GridBagConstraints.REMAINDER;

    // The panel containing the GIFT-Cloud server configuration
    final JPanel giftCloudServerPanel = new JPanel();
    {
        GridBagLayout projectUploadlayout = new GridBagLayout();
        giftCloudServerPanel.setLayout(projectUploadlayout);
        JLabel serverPanelLabel = new JLabel(resourceBundle.getString("configPanelServerConfig"),
                SwingConstants.CENTER);
        giftCloudServerPanel.add(serverPanelLabel, sectionTitleConstraints);

        // GIFT-Cloud server URL
        {
            labelConstraints.gridwidth = 1;
            labelConstraints.gridy = 2;
            final JLabel giftCloudServerLabel = new JLabel(resourceBundle.getString("giftCloudServerText"),
                    SwingConstants.RIGHT);
            giftCloudServerLabel.setToolTipText(resourceBundle.getString("giftCloudServerTextToolTipText"));
            giftCloudServerPanel.add(giftCloudServerLabel, labelConstraints);

            giftCloudServerText = new AutoFocusTextField(giftCloudProperties.getGiftCloudUrl().orElse(""),
                    textFieldLengthForGiftCloudServerUrl);
            inputConstraints.gridy = 2;
            giftCloudServerPanel.add(giftCloudServerText, inputConstraints);
        }

        // GIFT-Cloud username
        {
            labelConstraints.gridy = 3;
            final JLabel giftCloudUserNameLabel = new JLabel(resourceBundle.getString("giftCloudUsername"),
                    SwingConstants.RIGHT);
            giftCloudUserNameLabel.setToolTipText(resourceBundle.getString("giftCloudUsernameToolTipText"));
            giftCloudServerPanel.add(giftCloudUserNameLabel, labelConstraints);

            final Optional<String> serverUrl = giftCloudProperties.getLastUserName();
            final String initialServerText = serverUrl.isPresent() ? serverUrl.get() : "";
            giftCloudUsernameText = new AutoFocusTextField(initialServerText);
            inputConstraints.gridy = 3;
            giftCloudServerPanel.add(giftCloudUsernameText, inputConstraints);
        }

        // GIFT-Cloud password
        {
            labelConstraints.gridy = 4;
            final JLabel giftCloudPasswordLabel = new JLabel(resourceBundle.getString("giftCloudPassword"),
                    SwingConstants.RIGHT);
            giftCloudPasswordLabel.setToolTipText(resourceBundle.getString("giftCloudPasswordToolTipText"));
            giftCloudServerPanel.add(giftCloudPasswordLabel, labelConstraints);

            final Optional<char[]> password = giftCloudProperties.getLastPassword();
            final char[] initialPassword = password.isPresent() ? password.get() : "".toCharArray();
            giftCloudPasswordText = new JPasswordField(new String(initialPassword), 16); // Shouldn't create a String but there's no other way to initialize the password field
            inputConstraints.gridy = 4;
            giftCloudServerPanel.add(giftCloudPasswordText, inputConstraints);
        }

        // Project list
        {
            labelConstraints.gridy = 5;
            JLabel projectListLabel = new JLabel(resourceBundle.getString("giftCloudProjectLabelText"),
                    SwingConstants.RIGHT);
            giftCloudServerPanel.add(projectListLabel, labelConstraints);

            inputConstraints.gridy = 5;
            projectList = new BackwardsCompatibleComboBox();
            projectList.setEditable(false);
            projectList.setToolTipText(resourceBundle.getString("giftCloudProjectTooltip"));
            giftCloudServerPanel.add(projectList, inputConstraints);

            labelConstraints.gridx = 1;
            projectListWaitingLabel = new JLabel(resourceBundle.getString("giftCloudProjectWaitingLabelText"),
                    SwingConstants.RIGHT);
            giftCloudServerPanel.add(projectListWaitingLabel, labelConstraints);
            labelConstraints.gridx = 0;
        }

        // Subject prefix
        {
            labelConstraints.gridy = 6;
            JLabel subjectPrefixLabel = new JLabel(resourceBundle.getString("configPanelListenerSubjectPrefix"),
                    SwingConstants.RIGHT);
            subjectPrefixLabel
                    .setToolTipText(resourceBundle.getString("configPanelListenerSubjectPrefixTooltip"));
            giftCloudServerPanel.add(subjectPrefixLabel, labelConstraints);

            inputConstraints.gridy = 6;
            final Optional<String> subjectPrefixText = giftCloudProperties.getSubjectPrefix();
            subjectPrefixField = new AutoFocusTextField(subjectPrefixText.orElse(""));
            giftCloudServerPanel.add(subjectPrefixField, inputConstraints);
        }
    }

    // Local Dicom node configuration
    final JPanel listenerPanel = new JPanel();
    {
        GridBagLayout listenerPanellayout = new GridBagLayout();
        listenerPanel.setLayout(listenerPanellayout);
        JSeparator separator = new JSeparator();
        listenerPanel.add(separator, separatorConstraint);

        JLabel listenerPanelLabel = new JLabel(resourceBundle.getString("configPanelListenerConfig"),
                SwingConstants.CENTER);
        listenerPanel.add(listenerPanelLabel, sectionTitleConstraints);

        {
            labelConstraints.gridy = 2;
            JLabel listeningAETitleJLabel = new JLabel(resourceBundle.getString("configPanelListenerAe"),
                    SwingConstants.RIGHT);
            listeningAETitleJLabel.setToolTipText(resourceBundle.getString("configPanelListenerAeToolTip"));
            listenerPanellayout.setConstraints(listeningAETitleJLabel, labelConstraints);
            listenerPanel.add(listeningAETitleJLabel);

            inputConstraints.gridy = 2;
            final String listeningAETitleInitialText = giftCloudProperties.getListenerAETitle();
            listeningAETitleField = new AutoFocusTextField(listeningAETitleInitialText);
            listenerPanellayout.setConstraints(listeningAETitleField, inputConstraints);
            listenerPanel.add(listeningAETitleField);
        }
        {
            labelConstraints.gridy = 3;
            JLabel listeningPortJLabel = new JLabel(resourceBundle.getString("configPanelListenerPort"),
                    SwingConstants.RIGHT);
            listeningPortJLabel.setToolTipText(resourceBundle.getString("configPanelListenerPortToolTip"));
            listenerPanellayout.setConstraints(listeningPortJLabel, labelConstraints);
            listenerPanel.add(listeningPortJLabel);

            inputConstraints.gridy = 3;
            final int port = giftCloudProperties.getListeningPort();
            final String portValue = Integer.toString(port);
            listeningPortField = new AutoFocusTextField(portValue);
            listenerPanellayout.setConstraints(listeningPortField, inputConstraints);
            listenerPanel.add(listeningPortField);
        }
        {
            labelConstraints.gridy = 4;
            JLabel patientListExportFolderLabel = new JLabel(
                    resourceBundle.getString("configPanelListenerPatientListExportFolder"),
                    SwingConstants.RIGHT);
            patientListExportFolderLabel.setToolTipText(
                    resourceBundle.getString("configPanelListenerPatientListExportFolderTooltip"));
            listenerPanellayout.setConstraints(patientListExportFolderLabel, labelConstraints);
            listenerPanel.add(patientListExportFolderLabel);

            inputConstraints.gridy = 4;
            final Optional<String> patientListExportFolder = giftCloudProperties.getPatientListExportFolder();
            patientListExportFolderField = new AutoFocusTextField(patientListExportFolder.orElse(""));
            listenerPanellayout.setConstraints(patientListExportFolderField, inputConstraints);
            listenerPanel.add(patientListExportFolderField);
        }

        // Patient list spreadsheet password
        {
            labelConstraints.gridy = 5;
            final JLabel patientListSpreadsheetPasswordLabel = new JLabel(
                    resourceBundle.getString("configPanelListenerPatientListSpreadhsheetPassword"),
                    SwingConstants.RIGHT);
            patientListSpreadsheetPasswordLabel.setToolTipText(
                    resourceBundle.getString("configPanelListenerPatientListSpreadhsheetPasswordTooltip"));
            listenerPanel.add(patientListSpreadsheetPasswordLabel, labelConstraints);

            final Optional<char[]> password = giftCloudProperties.getPatientListPassword();
            final char[] initialPassword = password.isPresent() ? password.get() : "".toCharArray();
            patientListSpreadsheetPasswordField = new JPasswordField(new String(initialPassword), 16); // Shouldn't create a String but there's no other way to initialize the password field
            inputConstraints.gridy = 5;
            listenerPanel.add(patientListSpreadsheetPasswordField, inputConstraints);
        }
    }

    // Remote PACS configuration
    final JPanel remoteAEPanel = new JPanel();

    {
        GridBagLayout pacsPanellayout = new GridBagLayout();
        remoteAEPanel.setLayout(pacsPanellayout);

        JSeparator separator = new JSeparator();
        remoteAEPanel.add(separator, separatorConstraint);

        JLabel remotePanelLabel = new JLabel(resourceBundle.getString("pacsPanelListenerConfig"),
                SwingConstants.CENTER);
        remoteAEPanel.add(remotePanelLabel, sectionTitleConstraints);

        {
            labelConstraints.gridy = 2;
            JLabel remoteAeTitleLabel = new JLabel(resourceBundle.getString("configPanelPacsAeTitle"),
                    SwingConstants.RIGHT);
            remoteAeTitleLabel.setToolTipText(resourceBundle.getString("configPanelPacsAeTitleTooltip"));
            remoteAEPanel.add(remoteAeTitleLabel, labelConstraints);

            final Optional<String> pacsAeTitle = giftCloudProperties.getPacsAeTitle();
            remoteAETitleField = new AutoFocusTextField(pacsAeTitle.isPresent() ? pacsAeTitle.get() : "");
            inputConstraints.gridy = 2;
            remoteAEPanel.add(remoteAETitleField, inputConstraints);
        }

        {
            labelConstraints.gridy = 3;
            JLabel remoteAeHostLabel = new JLabel(resourceBundle.getString("configPanelPacsHostname"),
                    SwingConstants.RIGHT);
            remoteAeHostLabel.setToolTipText(resourceBundle.getString("configPanelPacsHostnameTooltip"));
            remoteAEPanel.add(remoteAeHostLabel, labelConstraints);

            remoteAEHostName = new AutoFocusTextField(giftCloudProperties.getPacsHostName().orElse(""));
            inputConstraints.gridy = 3;
            remoteAEPanel.add(remoteAEHostName, inputConstraints);
        }

        {
            labelConstraints.gridy = 4;
            JLabel remoteAeTitleLabel = new JLabel(resourceBundle.getString("configPanelPacsPort"),
                    SwingConstants.RIGHT);
            remoteAeTitleLabel.setToolTipText(resourceBundle.getString("configPanelPacsPortTooltip"));
            remoteAEPanel.add(remoteAeTitleLabel, labelConstraints);

            remoteAEPortField = new AutoFocusTextField(Integer.toString(giftCloudProperties.getPacsPort()));
            inputConstraints.gridy = 4;
            remoteAEPanel.add(remoteAEPortField, inputConstraints);
        }

    }

    // The panel containing the cancel and apply buttons
    JPanel buttonPanel = new JPanel();
    JPanel closeButtonPanel = new JPanel();
    {
        final GridBagLayout buttonPanellayout = new GridBagLayout();
        buttonPanel.setLayout(buttonPanellayout);

        JSeparator separator = new JSeparator();
        buttonPanel.add(separator, separatorConstraint);

        closeButtonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));

        JButton cancelButton = new JButton(resourceBundle.getString("cancelSettingsButtonLabelText"));
        cancelButton.setToolTipText(resourceBundle.getString("cancelSettingsButtonToolTipText"));
        closeButtonPanel.add(cancelButton);
        cancelButton.addActionListener(new CancelActionListener());

        JButton applyButton = new JButton(resourceBundle.getString("applySettingsButtonLabelText"));
        applyButton.setToolTipText(resourceBundle.getString("applySettingsButtonToolTipText"));
        closeButtonPanel.add(applyButton);
        applyButton.addActionListener(new ApplyActionListener());

        JButton closeButton = new JButton(resourceBundle.getString("closeSettingsButtonLabelText"));
        closeButton.setToolTipText(resourceBundle.getString("closeSettingsButtonToolTipText"));
        closeButtonPanel.add(closeButton);
        closeButton.addActionListener(new CloseActionListener());

        final GridBagConstraints constraints = new GridBagConstraints();
        constraints.gridx = 0;
        constraints.gridy = 1;
        constraints.weightx = 1;
        constraints.weighty = 1;
        constraints.insets = new Insets(5, 5, 5, 5);
        constraints.fill = GridBagConstraints.HORIZONTAL;
        buttonPanellayout.setConstraints(closeButtonPanel, constraints);
        buttonPanel.add(closeButtonPanel);
    }

    // The main panel of the configuration dialog
    JPanel configPanel = new JPanel();
    {
        final GridBagLayout configPanelLayout = new GridBagLayout();
        configPanel.setLayout(configPanelLayout);
        {
            final GridBagConstraints constraints = new GridBagConstraints();
            constraints.gridx = 0;
            constraints.gridy = 0;
            constraints.weightx = 1;
            constraints.weighty = 1;
            constraints.insets = new Insets(5, 5, 5, 5);
            constraints.fill = GridBagConstraints.HORIZONTAL;
            configPanelLayout.setConstraints(giftCloudServerPanel, constraints);
            configPanel.add(giftCloudServerPanel);
        }
        {
            final GridBagConstraints constraints = new GridBagConstraints();
            constraints.gridx = 0;
            constraints.gridy = 1;
            constraints.weightx = 1;
            constraints.weighty = 1;
            constraints.insets = new Insets(5, 5, 5, 5);
            constraints.fill = GridBagConstraints.HORIZONTAL;
            configPanelLayout.setConstraints(listenerPanel, constraints);
            configPanel.add(listenerPanel);
        }
        {
            final GridBagConstraints constraints = new GridBagConstraints();
            constraints.gridx = 0;
            constraints.gridy = 2;
            constraints.insets = new Insets(5, 5, 5, 5);
            constraints.fill = GridBagConstraints.HORIZONTAL;
            configPanelLayout.setConstraints(remoteAEPanel, constraints);
            configPanel.add(remoteAEPanel);
        }
        {
            final GridBagConstraints constraints = new GridBagConstraints();
            constraints.gridx = 0;
            constraints.gridy = 3;
            constraints.insets = new Insets(5, 5, 5, 5);
            constraints.fill = GridBagConstraints.HORIZONTAL;
            configPanelLayout.setConstraints(buttonPanel, constraints);
            configPanel.add(buttonPanel);
        }
    }

    projectList.setModel(temporaryDropDownListModel);
    showProjectList(projectListModel.isEnabled());

    // Create a listener to enable/disable the project list when it is set from the server.
    // The reason for this is that the project list is set after logging into the server, which can happen asynchronously after property changes have been applied.
    // If the server was configured in the dialog and apply clicked, it might take a few seconds for the project list to be updated, and we want it to become available when this happens
    projectListEnabledListener = new DropDownListModel.EnabledListener<Boolean>() {
        @Override
        public void statusChanged(final Boolean visibility) {
            showProjectList(projectListModel.isEnabled());
        }
    };

    projectListModel.addListener(projectListEnabledListener);

    GridBagLayout layout = new GridBagLayout();
    dialog.setLayout(layout);
    Container content = dialog.getContentPane();
    content.add(configPanel);
    dialog.pack();
    dialog.setVisible(true);
    dialog.pack();
}

From source file:org.openconcerto.erp.core.supplychain.order.component.CommandeSQLComponent.java

public void addViews() {
    this.setLayout(new GridBagLayout());
    final GridBagConstraints c = new DefaultGridBagConstraints();

    // Numero du commande
    c.gridx = 0;/*  w  w w  .  j a  v  a 2 s.  c o m*/
    c.weightx = 0;
    this.add(new JLabel(getLabelFor("NUMERO"), SwingConstants.RIGHT), c);

    this.numeroUniqueCommande = new JUniqueTextField(16);
    c.gridx++;
    c.weightx = 1;
    c.fill = GridBagConstraints.NONE;
    DefaultGridBagConstraints.lockMinimumSize(numeroUniqueCommande);
    this.add(this.numeroUniqueCommande, c);

    // Date
    JLabel labelDate = new JLabel(getLabelFor("DATE"));
    labelDate.setHorizontalAlignment(SwingConstants.RIGHT);
    c.gridx = 2;
    c.weightx = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    this.add(labelDate, c);

    JDate dateCommande = new JDate(true);
    c.gridx++;
    c.fill = GridBagConstraints.NONE;
    this.add(dateCommande, c);

    // Fournisseur
    c.gridx = 0;
    c.gridy++;
    c.weightx = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    this.add(new JLabel(getLabelFor("ID_FOURNISSEUR"), SwingConstants.RIGHT), c);

    c.gridx = GridBagConstraints.RELATIVE;
    c.gridwidth = 1;
    c.weightx = 1;
    c.weighty = 0;
    c.fill = GridBagConstraints.NONE;
    this.add(this.fourn, c);

    if (!getTable().getFieldsName().contains("LIVRER")) {
        // Commande en cours
        JCheckBox boxEnCours = new JCheckBox(getLabelFor("EN_COURS"));
        c.gridx = 2;
        c.weightx = 0;
        c.fill = GridBagConstraints.HORIZONTAL;
        c.gridwidth = GridBagConstraints.REMAINDER;
        this.add(boxEnCours, c);
        c.gridwidth = 1;
        this.addRequiredSQLObject(boxEnCours, "EN_COURS");
    }

    // Fournisseur
    if (getTable().contains("ID_CONTACT_FOURNISSEUR")) {
        c.gridx = 0;
        c.gridy++;
        c.weightx = 0;
        c.fill = GridBagConstraints.HORIZONTAL;
        this.add(new JLabel(getLabelFor("ID_CONTACT_FOURNISSEUR"), SwingConstants.RIGHT), c);

        c.gridx = GridBagConstraints.RELATIVE;
        c.gridwidth = 1;
        c.weightx = 1;
        c.weighty = 0;
        c.fill = GridBagConstraints.HORIZONTAL;
        final ElementComboBox boxContactFournisseur = new ElementComboBox();
        final SQLElement contactElement = Configuration.getInstance().getDirectory()
                .getElement("CONTACT_FOURNISSEUR");
        boxContactFournisseur.init(contactElement, contactElement.getComboRequest(true));
        this.add(boxContactFournisseur, c);
        this.addView(boxContactFournisseur, "ID_CONTACT_FOURNISSEUR", REQ);

        fourn.addValueListener(new PropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent arg0) {
                // TODO Raccord de mthode auto-gnr
                if (fourn.getSelectedRow() != null) {
                    boxContactFournisseur.getRequest()
                            .setWhere(new Where(contactElement.getTable().getField("ID_FOURNISSEUR"), "=",
                                    fourn.getSelectedRow().getID()));
                } else {
                    boxContactFournisseur.getRequest().setWhere(null);
                }
            }
        });
    }
    // Adresse de livraison
    if (getTable().getFieldsName().contains("ID_ADRESSE")) {
        if (getTable().getFieldsName().contains("LIVRAISON_F")) {
            c.gridx = 0;
            c.gridy++;
            c.weightx = 0;
            c.fill = GridBagConstraints.HORIZONTAL;
            this.add(new JLabel(getLabelFor("ID_ADRESSE")), c);
            c.gridx++;
            c.gridwidth = GridBagConstraints.REMAINDER;
            // c.gridy++;
            this.addView("ID_ADRESSE");
            final DefaultElementSQLObject comp = (DefaultElementSQLObject) this.getView("ID_ADRESSE").getComp();

            if (getTable().getFieldsName().contains("LIVRAISON_F")) {
                final JCheckBox boxLivr = new JCheckBox("Livr par le fournisseur");
                this.add(boxLivr, c);
                this.addSQLObject(boxLivr, "LIVRAISON_F");
                boxLivr.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent e) {
                        if (boxLivr.isSelected() && !comp.isCreated()) {
                            comp.setCreated(true);
                            if (CommandeSQLComponent.this.getTable().contains("ID_AFFAIRE")) {

                                SQLRowValues rowVals = getLivraisonAdr(
                                        ((ElementComboBox) CommandeSQLComponent.this.getView("ID_AFFAIRE")
                                                .getComp()).getSelectedRow());

                                comp.setValue(rowVals);
                            }

                        } else {
                            if (!boxLivr.isSelected()) {
                                comp.setCreated(false);
                            }
                        }
                    }
                });
            }

            c.gridy++;
            this.add(comp, c);
            this.add(this.getView("ID_ADRESSE").getComp(), c);
        } else {

            c.gridy++;
            c.gridx = 0;
            this.add(new JLabel("Livraison"), c);
            c.gridx++;
            c.gridwidth = GridBagConstraints.REMAINDER;
            this.add(boxLivrClient, c);
            c.gridwidth = 1;

            final GridBagConstraints cAdr = new DefaultGridBagConstraints();

            panelAdrSpec.add(new JLabel(getLabelFor("ID_CLIENT"), SwingConstants.RIGHT), cAdr);
            final ElementComboBox boxClient = new ElementComboBox(true);
            cAdr.weightx = 1;
            cAdr.gridx++;
            panelAdrSpec.add(boxClient, cAdr);
            this.addView(boxClient, "ID_CLIENT");

            cAdr.gridy++;
            cAdr.weightx = 0;
            cAdr.gridx = 0;
            panelAdrSpec.add(new JLabel("Adresse", SwingConstants.RIGHT), cAdr);
            final SQLRequestComboBox boxAdr = new SQLRequestComboBox(true);
            boxAdr.uiInit(Configuration.getInstance().getDirectory().getElement(getTable().getTable("ADRESSE"))
                    .getComboRequest(true));
            boxClient.addModelListener("wantedID", new PropertyChangeListener() {

                @Override
                public void propertyChange(PropertyChangeEvent evt) {
                    if (boxClient.getSelectedRow() != null && !boxClient.getSelectedRow().isUndefined()) {
                        Where w = new Where(boxAdr.getRequest().getPrimaryTable().getField("ID_CLIENT"), "=",
                                boxClient.getSelectedRow().getID());
                        w = w.or(new Where(boxAdr.getRequest().getPrimaryTable().getKey(), "=",
                                boxClient.getSelectedRow().getInt("ID_ADRESSE")));
                        w = w.or(new Where(boxAdr.getRequest().getPrimaryTable().getKey(), "=",
                                boxClient.getSelectedRow().getInt("ID_ADRESSE_F")));
                        w = w.or(new Where(boxAdr.getRequest().getPrimaryTable().getKey(), "=",
                                boxClient.getSelectedRow().getInt("ID_ADRESSE_L")));
                        boxAdr.getRequest().setWhere(w);
                    } else {
                        boxAdr.getRequest().setWhere(null);
                    }
                }
            });
            cAdr.weightx = 1;
            cAdr.gridx++;
            panelAdrSpec.add(boxAdr, cAdr);

            cAdr.gridx = 0;
            cAdr.gridy++;
            cAdr.weightx = 0;
            if (getMode() == Mode.MODIFICATION) {
                panelAdrSpec.add(new JLabel(getLabelFor("ID_ADRESSE")), cAdr);
            }
            cAdr.gridx++;
            cAdr.gridwidth = GridBagConstraints.REMAINDER;
            this.addView("ID_ADRESSE");
            compAdr = (DefaultElementSQLObject) this.getView("ID_ADRESSE").getComp();

            cAdr.gridy++;
            if (getMode() == Mode.MODIFICATION) {
                panelAdrSpec.add(compAdr, cAdr);
            }
            boxAdr.addValueListener(new PropertyChangeListener() {

                @Override
                public void propertyChange(PropertyChangeEvent evt) {
                    SQLRow row = boxAdr.getSelectedRow();
                    if (row != null && !row.isUndefined()) {
                        compAdr.setCreated(true);
                        SQLRowValues asRowValues = new SQLRowValues(row.asRowValues());
                        compAdr.setValue(asRowValues);
                    }
                }
            });

            c.gridy++;
            c.gridx = 0;
            c.gridwidth = GridBagConstraints.REMAINDER;
            c.weightx = 1;
            this.add(panelAdrSpec, c);
            c.gridwidth = 1;
            c.weightx = 0;

            boxLivrClient.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent e) {
                    panelAdrSpec.setVisible(boxLivrClient.isSelected());

                    if (!boxLivrClient.isSelected()) {
                        boxClient.setValue((Integer) null);
                        boxAdr.setValue((Integer) null);
                        compAdr.setCreated(false);
                    }
                }
            });
            panelAdrSpec.setVisible(false);
        }
    }
    c.gridwidth = 1;

    // Champ Module
    c.gridx = 0;
    c.gridy++;
    c.gridwidth = GridBagConstraints.REMAINDER;
    final JPanel addP = ComptaSQLConfElement.createAdditionalPanel();
    this.setAdditionalFieldsPanel(new FormLayouter(addP, 2));
    this.add(addP, c);

    c.gridy++;
    c.gridwidth = 1;

    final ElementComboBox boxDevise = new ElementComboBox();
    if (DefaultNXProps.getInstance().getBooleanValue(AbstractVenteArticleItemTable.ARTICLE_SHOW_DEVISE,
            false)) {
        // Devise
        c.gridx = 0;
        c.gridy++;
        c.weightx = 0;
        c.fill = GridBagConstraints.HORIZONTAL;
        this.add(new JLabel(getLabelFor("ID_DEVISE"), SwingConstants.RIGHT), c);

        c.gridx = GridBagConstraints.RELATIVE;
        c.gridwidth = 1;
        c.weightx = 1;
        c.weighty = 0;
        c.fill = GridBagConstraints.NONE;
        this.add(boxDevise, c);
        this.addView(boxDevise, "ID_DEVISE");
    }

    // Reference
    c.gridx = 0;
    c.gridy++;
    c.gridwidth = 1;
    c.weightx = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.EAST;
    this.add(new JLabel(getLabelFor("NOM"), SwingConstants.RIGHT), c);

    final JTextField textNom = new JTextField();
    c.gridx++;
    c.weightx = 1;
    this.add(textNom, c);

    String field;
    field = "ID_COMMERCIAL";
    // Commercial
    c.weightx = 0;
    c.gridx++;
    this.add(new JLabel(getLabelFor(field), SwingConstants.RIGHT), c);

    ElementComboBox commSel = new ElementComboBox(false, 25);
    c.gridx = GridBagConstraints.RELATIVE;
    c.gridwidth = 1;
    c.weightx = 1;
    c.weighty = 0;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.WEST;
    this.add(commSel, c);
    addRequiredSQLObject(commSel, field);

    // Table d'lment
    c.fill = GridBagConstraints.BOTH;
    c.gridy++;
    c.gridx = 0;
    c.weightx = 0;
    c.weighty = 1;
    c.gridwidth = 4;
    this.add(this.table, c);
    if (DefaultNXProps.getInstance().getBooleanValue(AbstractVenteArticleItemTable.ARTICLE_SHOW_DEVISE,
            false)) {

        boxDevise.addValueListener(new PropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                table.setDevise(boxDevise.getSelectedRow());

            }
        });
    }

    this.fourn.addValueListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            table.setFournisseur(fourn.getSelectedRow());
        }
    });
    // Bottom
    c.gridy++;
    c.weighty = 0;
    this.add(getBottomPanel(), c);

    c.gridx = 0;
    c.gridy++;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.WEST;

    JPanel panelOO = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    panelOO.add(this.checkImpression, c);
    panelOO.add(this.checkVisu, c);
    c.gridwidth = GridBagConstraints.REMAINDER;
    this.add(panelOO, c);

    addRequiredSQLObject(this.fourn, "ID_FOURNISSEUR");
    addSQLObject(textNom, "NOM");
    addRequiredSQLObject(dateCommande, "DATE");
    // addRequiredSQLObject(radioEtat, "ID_ETAT_DEVIS");
    addRequiredSQLObject(this.numeroUniqueCommande, "NUMERO");
    addSQLObject(this.infos, "INFOS");

    this.numeroUniqueCommande.setText(NumerotationAutoSQLElement.getNextNumero(CommandeSQLElement.class));

    // radioEtat.setValue(EtatDevisSQLElement.EN_ATTENTE);
    // this.numeroUniqueDevis.addLabelWarningMouseListener(new MouseAdapter() {
    // public void mousePressed(MouseEvent e) {
    //
    // if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1) {
    // numeroUniqueDevis.setText(NumerotationAutoSQLElement.getNextNumeroDevis());
    // }
    // }
    // });

    DefaultGridBagConstraints.lockMinimumSize(this.fourn);
    DefaultGridBagConstraints.lockMinimumSize(commSel);
}

From source file:org.nebulaframework.ui.swing.node.NodeMainUI.java

/**
 * Setup General (Control Center) Tab//  w ww.  jav a2  s .  com
 * 
 * @return JPanel for Control Center
 */
private JPanel setupGeneral() {

    JPanel generalPanel = new JPanel();
    generalPanel.setLayout(new BorderLayout());

    /* -- Stats Panel -- */
    JPanel statsPanel = new JPanel();
    generalPanel.add(statsPanel, BorderLayout.NORTH);

    statsPanel.setLayout(new GridLayout(0, 2, 10, 10));

    JPanel eastPanel = new JPanel();
    statsPanel.add(eastPanel, BorderLayout.EAST);
    eastPanel.setLayout(new BorderLayout());

    JPanel westPanel = new JPanel();
    statsPanel.add(westPanel, BorderLayout.WEST);
    westPanel.setLayout(new BorderLayout());

    // Grid Information Panel
    JPanel gridInfoPanel = new JPanel();
    eastPanel.add(gridInfoPanel, BorderLayout.NORTH);

    gridInfoPanel.setBorder(BorderFactory.createTitledBorder("Grid Information"));
    gridInfoPanel.setLayout(new GridLayout(0, 2, 10, 10));

    JLabel nodeIdLabel = new JLabel("Node ID :");
    gridInfoPanel.add(nodeIdLabel);
    JLabel nodeId = new JLabel("#nodeid#");
    gridInfoPanel.add(nodeId);
    addUIElement("general.stats.nodeid", nodeId); // Add to components map

    JLabel nodeIpLabel = new JLabel("Node IP :");
    gridInfoPanel.add(nodeIpLabel);
    JLabel nodeIp = new JLabel("#nodeip#");
    gridInfoPanel.add(nodeIp);
    addUIElement("general.stats.nodeip", nodeIp); // Add to components map

    JLabel clusterIdLabel = new JLabel("Cluster ID :");
    gridInfoPanel.add(clusterIdLabel);
    JLabel clusterId = new JLabel("#clusterid#");
    gridInfoPanel.add(clusterId);
    addUIElement("general.stats.clusterid", clusterId); // Add to components map

    JLabel clusterServiceLabel = new JLabel("Cluster Service :");
    gridInfoPanel.add(clusterServiceLabel);
    JLabel clusterService = new JLabel("#clusterservice#");
    gridInfoPanel.add(clusterService);
    addUIElement("general.stats.clusterservice", clusterService); // Add to components map

    // Node Status Panel 
    JPanel nodeStatusPanel = new JPanel();
    eastPanel.add(nodeStatusPanel, BorderLayout.SOUTH);

    nodeStatusPanel.setBorder(BorderFactory.createTitledBorder("GridNode Status"));
    nodeStatusPanel.setLayout(new GridLayout(0, 2, 10, 10));

    JLabel statusLabel = new JLabel("Status :");
    nodeStatusPanel.add(statusLabel);
    JLabel status = new JLabel("#status#");
    nodeStatusPanel.add(status);
    addUIElement("general.stats.status", status); // Add to components map

    JLabel uptimeLabel = new JLabel("Node Up Time :");
    nodeStatusPanel.add(uptimeLabel);
    JLabel uptime = new JLabel("#uptime#");
    nodeStatusPanel.add(uptime);
    addUIElement("general.stats.uptime", uptime); // Add to components map

    JLabel execTimeLabel = new JLabel("Execution Time :");
    nodeStatusPanel.add(execTimeLabel);
    JLabel execTime = new JLabel("#exectime#");
    nodeStatusPanel.add(execTime);
    addUIElement("general.stats.exectime", execTime); // Add to components map

    // Execution Statistics Panel
    JPanel execStatsPanel = new JPanel();
    westPanel.add(execStatsPanel, BorderLayout.NORTH);

    execStatsPanel.setLayout(new GridLayout(0, 2, 10, 10));
    execStatsPanel.setBorder(BorderFactory.createTitledBorder("Execution Statistics"));

    JLabel totalJobsLabel = new JLabel("Total Jobs :");
    execStatsPanel.add(totalJobsLabel);
    JLabel totalJobs = new JLabel("0");
    execStatsPanel.add(totalJobs);
    addUIElement("general.stats.totaljobs", totalJobs); // Add to components map

    JLabel totalTasksLabel = new JLabel("Total Tasks :");
    execStatsPanel.add(totalTasksLabel);
    JLabel totalTasks = new JLabel("0");
    execStatsPanel.add(totalTasks);
    addUIElement("general.stats.totaltasks", totalTasks); // Add to components map

    JLabel totalBansLabel = new JLabel("Banments :");
    execStatsPanel.add(totalBansLabel);
    JLabel totalBans = new JLabel("0");
    execStatsPanel.add(totalBans);
    addUIElement("general.stats.totalbans", totalBans); // Add to components map

    // Execution Active Job Panel
    JPanel activeJobPanel = new JPanel();
    westPanel.add(activeJobPanel, BorderLayout.SOUTH);

    activeJobPanel.setLayout(new GridLayout(0, 2, 10, 10));
    activeJobPanel.setBorder(BorderFactory.createTitledBorder("Active Job"));

    JLabel jobNameLabel = new JLabel("GridJob Name :");
    activeJobPanel.add(jobNameLabel);
    JLabel jobName = new JLabel("#jobname#");
    activeJobPanel.add(jobName);
    addUIElement("general.stats.jobname", jobName); // Add to components map

    JLabel durationLabel = new JLabel("Duration :");
    activeJobPanel.add(durationLabel);
    JLabel duration = new JLabel("#duration#");
    activeJobPanel.add(duration);
    addUIElement("general.stats.duration", duration); // Add to components map

    JLabel tasksLabel = new JLabel("Tasks Executed :");
    activeJobPanel.add(tasksLabel);
    JLabel tasks = new JLabel("#xyz#");
    activeJobPanel.add(tasks);
    addUIElement("general.stats.tasks", tasks); // Add to components map

    JLabel failuresLabel = new JLabel("Failures :");
    activeJobPanel.add(failuresLabel);
    JLabel failures = new JLabel("#failures#");
    activeJobPanel.add(failures);
    addUIElement("general.stats.failures", failures); // Add to components map

    /* -- Log Panel -- */
    JPanel logPanel = new JPanel();
    generalPanel.add(logPanel, BorderLayout.CENTER);

    logPanel.setLayout(new BorderLayout());
    logPanel.setBorder(BorderFactory.createTitledBorder("Log Output"));
    JTextPane logTextPane = new JTextPane();
    logTextPane.setEditable(false);
    logTextPane.setBackground(Color.BLACK);
    logTextPane.setForeground(Color.WHITE);

    logPanel.add(new JScrollPane(logTextPane, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED), BorderLayout.CENTER);
    addUIElement("general.log", logTextPane); // Add to component map

    JPanel logOptionsPanel = new JPanel();
    logPanel.add(logOptionsPanel, BorderLayout.SOUTH);
    logOptionsPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));

    final JCheckBox logScrollCheckbox = new JCheckBox("Auto-Scroll Log");
    logScrollCheckbox.setSelected(true);
    logScrollCheckbox.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            JTextPaneAppender.setAutoScroll(logScrollCheckbox.isSelected());
        }

    });
    logOptionsPanel.add(logScrollCheckbox);

    // Enable Logging
    JTextPaneAppender.setTextPane(logTextPane);

    /* -- Buttons Panel -- */
    JPanel buttonsPanel = new JPanel();
    generalPanel.add(buttonsPanel, BorderLayout.SOUTH);

    buttonsPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));

    // Shutdown Button
    JButton shutdownButton = new JButton("Shutdown");
    buttonsPanel.add(shutdownButton);
    shutdownButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            doShutdownNode();
        }

    });

    // Start Up time Thread
    Thread t = new Thread(new Runnable() {
        public void run() {

            long start = System.currentTimeMillis();

            while (true) {
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    log.warn("Interrupted Exception in Up Time Thread", e);
                }

                final String uptime = TimeUtils.timeDifference(start);

                SwingUtilities.invokeLater(new Runnable() {

                    public void run() {
                        JLabel upTime = getUIElement("general.stats.uptime");
                        upTime.setText(uptime);
                    }

                });
            }

        }
    });
    t.setDaemon(true);
    t.start();

    // Auto-Discovery Thread
    Thread autoDiscovery = new Thread(new Runnable() {
        public void run() {

            while (true) {
                try {

                    // Attempt every 30 seconds
                    Thread.sleep(30000);

                } catch (InterruptedException e) {
                    log.warn("Interrupted Exception in Up Time Thread", e);
                }

                if (autodiscover && (!Grid.isNode())) {
                    // 30 Second Intervals
                    doDiscover(true);
                }

            }
        }
    });
    autoDiscovery.setDaemon(true);
    autoDiscovery.start();

    return generalPanel;
}