Example usage for javax.swing ButtonGroup ButtonGroup

List of usage examples for javax.swing ButtonGroup ButtonGroup

Introduction

In this page you can find the example usage for javax.swing ButtonGroup ButtonGroup.

Prototype

public ButtonGroup() 

Source Link

Document

Creates a new ButtonGroup.

Usage

From source file:org.codinjutsu.tools.nosql.mongo.view.MongoAuthenticationPanel.java

public MongoAuthenticationPanel() {
    usernameField.setName("usernameField");
    passwordField.setName("passwordField");
    authenticationDatabaseField.setName("authenticationDatabaseField");
    mongoCRAuthRadioButton.setName("mongoCRAuthField");
    scramSHA1AuthRadioButton.setName("scramSHA1AuthField");
    defaultAuthMethodRadioButton.setName("defaultAuthMethod");
    sslConnectionField.setName("sslConnectionField");

    ButtonGroup authMethodGroup = new ButtonGroup();
    authMethodGroup.add(mongoCRAuthRadioButton);
    authMethodGroup.add(scramSHA1AuthRadioButton);
    authMethodGroup.add(defaultAuthMethodRadioButton);

    defaultAuthMethodRadioButton.setSelected(true);
    defaultAuthMethodRadioButton.setToolTipText("Let the driver resolves the auth. mecanism");
}

From source file:org.colombbus.tangara.CommandSelection.java

/**
 * Creates a new instance of CommandSelection from Tangara frame
 *
 *///from w  w  w  .  j  a  va 2  s  .  co  m
public CommandSelection(EditorFrame parent, boolean modal, int mode) {
    super(parent, modal);
    this.mode = mode;
    myParent = parent;
    initializeIcons();
    initialize();
    ButtonGroup programDestinationGrp = new ButtonGroup();
    programDestinationGrp.add(buttonSaveProgram);
    programDestinationGrp.add(buttonDisplayProgram);
    changeState(STATE_COMMANDS_SELECTION);
    this.setLocation(new Point((parent.getX() + (parent.getWidth() - getWidth()) / 2),
            (parent.getY() + (parent.getHeight() - getHeight()) / 2)));
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            commandList.setSelectionInterval(0, commandList.getModel().getSize() - 1);
        }
    });
}

From source file:org.datanucleus.ide.idea.ui.DNEConfigForm.java

/**
 * Method generated by IntelliJ IDEA GUI Designer
 * >>> IMPORTANT!! <<<
 * DO NOT edit this method OR call it in your code!
 *
 * @noinspection ALL/* w  w w.j  a  va  2s .co  m*/
 */
private void $$$setupUI$$$() {
    createUIComponents();
    parentPanel.setLayout(new GridLayoutManager(2, 1, new Insets(1, 0, 0, 0), -1, -1));
    configTabbedPane = new JTabbedPane();
    parentPanel.add(configTabbedPane,
            new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null,
                    null, 0, false));
    configPanel = new JPanel();
    configPanel.setLayout(new GridLayoutManager(5, 3, new Insets(6, 2, 2, 2), -1, -1));
    configTabbedPane.addTab("Enhancer", configPanel);
    indexNotReadyPanel = new JPanel();
    indexNotReadyPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
    configPanel.add(indexNotReadyPanel,
            new GridConstraints(3, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, 1, null, null,
                    null, 0, false));
    final JLabel label1 = new JLabel();
    label1.setText("Please wait until indexing is finished");
    indexNotReadyPanel.add(label1,
            new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE,
                    GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0,
                    false));
    contentPanel = new JPanel();
    contentPanel.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1));
    configPanel.add(contentPanel,
            new GridConstraints(4, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null,
                    null, 0, false));
    final JPanel panel1 = new JPanel();
    panel1.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
    contentPanel.add(panel1,
            new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null,
                    null, 0, false));
    panel1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(new Color(-3355444)),
            "Affected Modules"));
    final JScrollPane scrollPane1 = new JScrollPane();
    panel1.add(scrollPane1,
            new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null,
                    null, 0, false));
    affectedModulesTable = new JTable();
    affectedModulesTable.setEnabled(true);
    affectedModulesTable.setFillsViewportHeight(false);
    affectedModulesTable.setPreferredScrollableViewportSize(new Dimension(450, 30));
    scrollPane1.setViewportView(affectedModulesTable);
    final JPanel panel2 = new JPanel();
    panel2.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
    contentPanel.add(panel2,
            new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null,
                    null, 0, false));
    panel2.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(new Color(-3355444)),
            "Metadata and annotated classes for enhancement", TitledBorder.DEFAULT_JUSTIFICATION,
            TitledBorder.DEFAULT_POSITION, null, new Color(-16777216)));
    infoPanel = new JPanel();
    infoPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
    panel2.add(infoPanel,
            new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null,
                    null, 0, false));
    final JLabel label2 = new JLabel();
    label2.setText("Please click 'Make Project' to see affected files");
    infoPanel.add(label2,
            new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE,
                    GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0,
                    false));
    metaDataAndClassesScrollPane = new JScrollPane();
    panel2.add(metaDataAndClassesScrollPane,
            new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null,
                    null, 0, false));
    metadataAndClassesTable = new JTable();
    metadataAndClassesTable.setFillsViewportHeight(false);
    metadataAndClassesTable.setFont(new Font(metadataAndClassesTable.getFont().getName(),
            metadataAndClassesTable.getFont().getStyle(), metadataAndClassesTable.getFont().getSize()));
    metadataAndClassesTable.setPreferredScrollableViewportSize(new Dimension(450, 100));
    metaDataAndClassesScrollPane.setViewportView(metadataAndClassesTable);
    modifiersPanel = new JPanel();
    modifiersPanel.setLayout(new GridLayoutManager(2, 3, new Insets(0, 2, 0, 0), -1, -1));
    configPanel.add(modifiersPanel,
            new GridConstraints(1, 0, 2, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null,
                    null, 0, false));
    final JLabel label3 = new JLabel();
    label3.setText(" Metadata file extensions (use ';' to separate)");
    modifiersPanel.add(label3,
            new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE,
                    GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0,
                    false));
    includeTestClassesCheckBox = new JCheckBox();
    includeTestClassesCheckBox.setText("Include Test classes");
    modifiersPanel.add(includeTestClassesCheckBox,
            new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    metadataExtensionTextField.setAlignmentX(0.5f);
    metadataExtensionTextField.setAutoscrolls(true);
    metadataExtensionTextField.setMargin(new Insets(1, 1, 1, 1));
    modifiersPanel.add(metadataExtensionTextField,
            new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL,
                    GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null,
                    new Dimension(150, -1), null, 0, false));
    addToCompilerResourceCheckBox = new JCheckBox();
    addToCompilerResourceCheckBox.setText("Add to compiler resource patterns");
    modifiersPanel.add(addToCompilerResourceCheckBox,
            new GridConstraints(1, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    dependenciesPanel = new JPanel();
    dependenciesPanel.setLayout(new GridLayoutManager(3, 1, new Insets(6, 2, 2, 2), -1, -1));
    configTabbedPane.addTab("Dependencies", dependenciesPanel);
    final JPanel panel3 = new JPanel();
    panel3.setLayout(new GridLayoutManager(1, 4, new Insets(0, 0, 0, 0), 5, 5));
    dependenciesPanel.add(panel3,
            new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, 1, null, null,
                    null, 0, false));
    depProjectModuleRadioButton.setText("Project Module Dependencies");
    panel3.add(depProjectModuleRadioButton,
            new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    depManualRadioButton.setText("Manual Dependencies");
    panel3.add(depManualRadioButton,
            new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    final Spacer spacer1 = new Spacer();
    panel3.add(spacer1,
            new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
                    GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0,
                    false));
    depManualUnsupportedLabel = new JLabel();
    depManualUnsupportedLabel.setText("(Not supported by plugin extension)");
    panel3.add(depManualUnsupportedLabel,
            new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE,
                    GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0,
                    false));
    manualDependenciesDisabledInfoPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
    dependenciesPanel.add(manualDependenciesDisabledInfoPanel,
            new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null,
                    null, 0, false));
    final JLabel label4 = new JLabel();
    label4.setHorizontalAlignment(0);
    label4.setHorizontalTextPosition(0);
    label4.setText("Using Enhancer and it's Dependencies from Project Module");
    manualDependenciesDisabledInfoPanel.add(label4,
            new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE,
                    GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0,
                    false));
    dependenciesPanel.add(dependenciesAddDeletePanel,
            new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null,
                    null, 0, false));
    generalPanel = new JPanel();
    generalPanel.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1));
    parentPanel.add(generalPanel,
            new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_NORTH, GridConstraints.FILL_HORIZONTAL,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null,
                    null, 0, false));
    enableEnhancerCheckBox = new JCheckBox();
    enableEnhancerCheckBox.setText("Enable Enhancer");
    generalPanel.add(enableEnhancerCheckBox,
            new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    final JPanel panel4 = new JPanel();
    panel4.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1));
    generalPanel.add(panel4,
            new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, 1, null, null,
                    null, 0, false));
    jDORadioButton.setText("JDO");
    panel4.add(jDORadioButton,
            new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    jPARadioButton = new JRadioButton();
    jPARadioButton.setText("JPA");
    panel4.add(jPARadioButton,
            new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    final Spacer spacer2 = new Spacer();
    panel4.add(spacer2,
            new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
                    GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0,
                    false));
    generalPanel.add(persistenceImplComboBox,
            new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL,
                    GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0,
                    false));
    ButtonGroup buttonGroup;
    buttonGroup = new ButtonGroup();
    buttonGroup.add(jDORadioButton);
    buttonGroup.add(jPARadioButton);
    buttonGroup = new ButtonGroup();
    buttonGroup.add(depProjectModuleRadioButton);
    buttonGroup.add(depManualRadioButton);
}

From source file:org.datanucleus.ide.idea.ui.v10x.DNEConfigFormV10x.java

/**
 * Method generated by IntelliJ IDEA GUI Designer
 * >>> IMPORTANT!! <<<
 * DO NOT edit this method OR call it in your code!
 *
 * @noinspection ALL/*from  w  w w.  j a  v a2  s .  co m*/
 */
private void $$$setupUI$$$() {
    createUIComponents();
    configPanel = new JPanel();
    configPanel.setLayout(new GridLayoutManager(5, 3, new Insets(0, 0, 0, 0), -1, -1));
    enableEnhancerCheckBox = new JCheckBox();
    enableEnhancerCheckBox.setText("Enable Enhancer");
    configPanel.add(enableEnhancerCheckBox,
            new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    final JPanel panel1 = new JPanel();
    panel1.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1));
    configPanel.add(panel1,
            new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, 1, null, null,
                    null, 0, false));
    jDORadioButton = new JRadioButton();
    jDORadioButton.setText("JDO");
    panel1.add(jDORadioButton,
            new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    jPARadioButton = new JRadioButton();
    jPARadioButton.setText("JPA");
    panel1.add(jPARadioButton,
            new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    final Spacer spacer1 = new Spacer();
    panel1.add(spacer1,
            new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
                    GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0,
                    false));
    configPanel.add(persistenceImplComboBox,
            new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL,
                    GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0,
                    false));
    final JLabel label1 = new JLabel();
    label1.setText(" Metadata file extensions (use ';' to separate)");
    configPanel.add(label1,
            new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE,
                    GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0,
                    false));
    includeTestClassesCheckBox = new JCheckBox();
    includeTestClassesCheckBox.setText("Include Test classes");
    configPanel.add(includeTestClassesCheckBox,
            new GridConstraints(1, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    metadataExtensionTextField.setAlignmentX(0.5f);
    metadataExtensionTextField.setAutoscrolls(true);
    metadataExtensionTextField.setMargin(new Insets(1, 1, 1, 1));
    configPanel.add(metadataExtensionTextField,
            new GridConstraints(2, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL,
                    GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null,
                    new Dimension(150, -1), null, 0, false));
    addToCompilerResourceCheckBox = new JCheckBox();
    addToCompilerResourceCheckBox.setText("Add to compiler resource patterns");
    configPanel.add(addToCompilerResourceCheckBox,
            new GridConstraints(2, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    indexNotReadyPanel = new JPanel();
    indexNotReadyPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
    configPanel.add(indexNotReadyPanel,
            new GridConstraints(3, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null,
                    null, 0, false));
    final JLabel label2 = new JLabel();
    label2.setText("Please wait until indexing is finished");
    indexNotReadyPanel.add(label2,
            new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE,
                    GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0,
                    false));
    contentPanel = new JPanel();
    contentPanel.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1));
    configPanel.add(contentPanel,
            new GridConstraints(4, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null,
                    null, 0, false));
    final JPanel panel2 = new JPanel();
    panel2.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
    contentPanel.add(panel2,
            new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null,
                    null, 0, false));
    panel2.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Affected Modules"));
    final JScrollPane scrollPane1 = new JScrollPane();
    panel2.add(scrollPane1,
            new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null,
                    null, 0, false));
    affectedModulesTable = new JTable();
    affectedModulesTable.setEnabled(true);
    affectedModulesTable.setFillsViewportHeight(false);
    affectedModulesTable.setPreferredScrollableViewportSize(new Dimension(450, 30));
    scrollPane1.setViewportView(affectedModulesTable);
    final JPanel panel3 = new JPanel();
    panel3.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
    contentPanel.add(panel3,
            new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null,
                    null, 0, false));
    panel3.setBorder(BorderFactory.createTitledBorder("Metadata and annotated classes for enhancement"));
    infoPanel = new JPanel();
    infoPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
    panel3.add(infoPanel,
            new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null,
                    null, 0, false));
    final JLabel label3 = new JLabel();
    label3.setText("Please click 'Make Project' to see affected files");
    infoPanel.add(label3,
            new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE,
                    GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0,
                    false));
    metaDataAndClassesScrollPane = new JScrollPane();
    panel3.add(metaDataAndClassesScrollPane,
            new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null,
                    null, 0, false));
    metadataAndClassesTable = new JTable();
    metadataAndClassesTable.setFillsViewportHeight(false);
    metadataAndClassesTable.setFont(new Font(metadataAndClassesTable.getFont().getName(),
            metadataAndClassesTable.getFont().getStyle(), metadataAndClassesTable.getFont().getSize()));
    metadataAndClassesTable.setPreferredScrollableViewportSize(new Dimension(450, 100));
    metaDataAndClassesScrollPane.setViewportView(metadataAndClassesTable);
    ButtonGroup buttonGroup;
    buttonGroup = new ButtonGroup();
    buttonGroup.add(jDORadioButton);
    buttonGroup.add(jPARadioButton);
}

From source file:org.drugis.addis.gui.WelcomeDialog.java

private void initComps() {

    final ButtonGroup examples = new ButtonGroup();
    examples.add(new JRadioButton(Main.Examples.DEPRESSION.name, true));
    examples.add(new JRadioButton(Main.Examples.HYPERTENSION.name));

    final AbstractAction exampleAction = new AbstractAction() {
        public void actionPerformed(ActionEvent arg0) {
            d_main.loadExampleDomain(Main.Examples.findFileName(getSelection(examples).getText()));
            closeWelcome();/*  www . j ava  2 s.  c  o  m*/
        }
    };

    final AbstractAction loadAction = new AbstractAction() {
        public void actionPerformed(ActionEvent arg0) {
            if (d_main.fileLoadActions() == JFileChooser.APPROVE_OPTION) {
                closeWelcome();
            }
        }
    };

    final AbstractAction newAction = new AbstractAction() {
        public void actionPerformed(ActionEvent arg0) {
            d_main.newFileActions();
            closeWelcome();
        }
    };

    FormLayout layout = new FormLayout("left:pref, " + SPACING + "px, left:pref",
            "p, 3dlu, p, " + SPACING + "px, p, " + SPACING + "px, p, 3dlu, p");
    PanelBuilder builder = new PanelBuilder(layout);
    final CellConstraints cc = new CellConstraints();

    builder.add(createImageLabel(FileNames.IMAGE_HEADER), cc.xyw(1, 1, 3));
    builder.add(createButton("Load example", FileNames.ICON_TIP, exampleAction), cc.xy(1, 3));

    final PanelBuilder radios = new PanelBuilder(new FormLayout("p, fill:pref:grow, right:pref", "p, 3dlu, p"));

    final ArrayList<AbstractButton> buttons = Collections.list(examples.getElements());
    forAllDo(buttons, new Closure<AbstractButton>() {
        public void execute(final AbstractButton exampleOption) {
            int row = buttons.indexOf(exampleOption) == 0 ? 1 : buttons.indexOf(exampleOption) + 2;
            exampleOption.setOpaque(false);
            radios.add(exampleOption, cc.xy(1, row));
            radios.add(createHelpButton(exampleOption), cc.xy(3, row));
        }

        private JButton createHelpButton(final AbstractButton exampleOption) {
            JButton help = GUIFactory.createIconButton(org.drugis.mtc.gui.FileNames.ICON_ABOUT,
                    "Information about this example");
            removeBackground(help);

            help.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    Examples example = Examples.findByName(exampleOption.getText());
                    String helpText = s_help.getHelpText(example.name().toLowerCase());
                    showExampleInfo(helpText);
                }
            });
            return help;
        }
    });

    JPanel radiosPanel = radios.getPanel();
    setBorder(radiosPanel);
    builder.add(radiosPanel, cc.xy(3, 3));

    builder.add(createButton("Open file", FileNames.ICON_OPENFILE, loadAction), cc.xy(1, 5));
    JTextPane load = createLabel("Load an existing ADDIS data file stored on your computer.");
    builder.add(load, cc.xy(3, 5));

    builder.add(createButton("New dataset", FileNames.ICON_FILE_NEW, newAction), cc.xy(1, 7));
    builder.add(createLabel("Start with an empty file to build up your own data and analyses."), cc.xy(3, 7));

    builder.add(createImageLabel(FileNames.IMAGE_FOOTER), cc.xyw(1, 9, 3));

    setContentPane(builder.getPanel());
}

From source file:org.eclipse.titanium.graph.gui.windows.GraphEditor.java

/**
 * This method creates the items to show on the {@link Frame} , and adds
 * actions//from w ww .  ja  va 2s. c om
 */
protected void initWindow() {
    drawArea = new JPanel();
    window.add(drawArea, BorderLayout.CENTER);
    drawArea.setSize(windowSize.width, windowSize.height);
    drawArea.setPreferredSize(new Dimension(windowSize.width, windowSize.height));

    menuBar = new JMenuBar();
    window.add(menuBar, BorderLayout.NORTH);

    final JMenu mnFile = new JMenu("File");

    final ActionListener saveGraph = new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent e) {
            String path = "";
            try {
                path = project.getPersistentProperty(
                        new QualifiedName(ProjectBuildPropertyData.QUALIFIER, "Graph_Save_Path"));
            } catch (CoreException exc) {
                errorHandler.reportException("Error while reading persistent property", exc);
            }
            final String oldPath = path;
            Display.getDefault().asyncExec(new Runnable() {
                @Override
                public void run() {
                    FileDialog dialog = new FileDialog(editorComposite.getShell(), SWT.SAVE);
                    dialog.setText("Save Pajek file");
                    dialog.setFilterPath(oldPath);
                    dialog.setFilterExtensions(new String[] { "*.net", "*.dot" });
                    String graphFilePath = dialog.open();
                    if (graphFilePath == null) {
                        return;
                    }
                    String newPath = graphFilePath.substring(0, graphFilePath.lastIndexOf(File.separator) + 1);
                    try {
                        QualifiedName name = new QualifiedName(ProjectBuildPropertyData.QUALIFIER,
                                "Graph_Save_Path");
                        project.setPersistentProperty(name, newPath);

                        if ("dot".equals(graphFilePath.substring(graphFilePath.lastIndexOf('.') + 1,
                                graphFilePath.length()))) {
                            GraphHandler.saveGraphToDot(graph, graphFilePath, project.getName());
                        } else {
                            GraphHandler.saveGraphToPajek(graph, graphFilePath);
                        }

                    } catch (BadLayoutException be) {
                        ErrorReporter.logExceptionStackTrace("Error while saving image to " + newPath, be);
                        errorHandler.reportErrorMessage("Bad layout\n\n" + be.getMessage());
                    } catch (Exception ce) {
                        ErrorReporter.logExceptionStackTrace("Error while saving image to " + newPath, ce);
                        errorHandler.reportException("Error while setting persistent property", ce);
                    }
                }
            });
        }
    };

    final JMenuItem mntmSave = new JMenuItem("Save (Ctrl+S)");
    mntmSave.addActionListener(saveGraph);
    mnFile.add(mntmSave);

    final ActionListener exportImage = new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent e) {
            String path = "";
            try {
                path = project.getPersistentProperty(
                        new QualifiedName(ProjectBuildPropertyData.QUALIFIER, "Graph_Save_Path"));
            } catch (CoreException exc) {
                errorHandler.reportException("Error while reading persistent property", exc);
            }
            final String oldPath = path;
            Display.getDefault().asyncExec(new Runnable() {
                @Override
                public void run() {
                    ExportPreferencesDialog prefDialog = new ExportPreferencesDialog(
                            editorComposite.getShell());
                    ImageExportType mode = prefDialog.open();

                    FileDialog dialog = new FileDialog(editorComposite.getShell(), SWT.SAVE);
                    dialog.setText("Export image");
                    dialog.setFilterPath(oldPath);
                    dialog.setFilterExtensions(new String[] { "*.png" });
                    String graphFilePath = dialog.open();
                    if (graphFilePath == null) {
                        return;
                    }
                    String newPath = graphFilePath.substring(0, graphFilePath.lastIndexOf(File.separator) + 1);
                    try {
                        QualifiedName name = new QualifiedName(ProjectBuildPropertyData.QUALIFIER,
                                "Graph_Save_Path");
                        project.setPersistentProperty(name, newPath);
                        handler.saveToImage(graphFilePath, mode);
                    } catch (BadLayoutException be) {
                        errorHandler.reportException("Error while saving image", be);
                        errorHandler.reportErrorMessage(be.getMessage());
                    } catch (CoreException ce) {
                        errorHandler.reportException("Error while setting persistent property", ce);
                    }
                }
            });
        }
    };

    final JMenuItem mntmExportToImage = new JMenuItem("Export to image file (Ctrl+E)");
    mntmExportToImage.addActionListener(exportImage);
    mnFile.add(mntmExportToImage);

    layoutMenu = new JMenu("Layout");
    layoutGroup = new ButtonGroup();

    layoutListener = new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent e) {
            final IProgressMonitor monitor = Job.getJobManager().createProgressGroup();
            monitor.beginTask("Change layout", 100);
            if (!(e.getSource() instanceof LayoutEntry)) {
                errorHandler.reportErrorMessage(
                        "Unexpected error\n\nAn unusual error has been logged" + LOGENTRYNOTE);
                ErrorReporter.logError("The layout changing event's source is not of type \"LayoutEntry\"!");
                return;
            }
            final LayoutEntry layout = (LayoutEntry) e.getSource();
            if (handler.getVisualizator() != null) {
                drawArea.remove(handler.getVisualizator());
            }
            try {
                handler.changeLayout(layout, windowSize);
                drawArea.add(handler.getVisualizator());
                if (satView != null) {
                    satView.add(handler.getSatelliteViewer());
                }
                window.pack();
            } catch (BadLayoutException exc) {
                layout.setSelected(false);
                chosenLayout.setSelected(true);
                if (exc.getType() == ErrorType.EMPTY_GRAPH || exc.getType() == ErrorType.NO_OBJECT) {
                    return;
                }
                try {
                    handler.changeLayout(chosenLayout, windowSize);
                    drawArea.add(handler.getVisualizator());
                    if (satView != null) {
                        satView.add(handler.getSatelliteViewer());
                    }
                    window.pack();
                    monitor.done();
                } catch (BadLayoutException exc2) {
                    monitor.done();
                    if (exc2.getType() != ErrorType.CYCLIC_GRAPH && exc2.getType() != ErrorType.EMPTY_GRAPH) {
                        errorHandler.reportException("Error while creating layout", exc2);
                    } else {
                        errorHandler.reportErrorMessage(exc2.getMessage());
                    }
                } catch (IllegalStateException exc3) {
                    monitor.done();
                    errorHandler.reportException("Error while creating layout", exc3);
                }
                if (exc.getType() != ErrorType.CYCLIC_GRAPH && exc.getType() != ErrorType.EMPTY_GRAPH) {
                    errorHandler.reportException("Error while creating layout", exc);
                } else {
                    errorHandler.reportErrorMessage(exc.getMessage());
                }
            } catch (IllegalStateException exc) {
                layout.setSelected(false);
                chosenLayout.setSelected(true);
                try {
                    handler.changeLayout(chosenLayout, windowSize);
                    drawArea.add(handler.getVisualizator());
                    if (satView != null) {
                        satView.add(handler.getSatelliteViewer());
                    }
                    window.pack();
                    monitor.done();
                } catch (BadLayoutException exc2) {
                    monitor.done();
                    if (exc2.getType() != ErrorType.CYCLIC_GRAPH && exc2.getType() != ErrorType.EMPTY_GRAPH) {
                        errorHandler.reportException("Error while creating layout", exc2);
                    } else {
                        errorHandler.reportErrorMessage(exc2.getMessage());
                    }
                } catch (IllegalStateException exc3) {
                    monitor.done();
                    errorHandler.reportException("Error while creating layout", exc3);
                }
                errorHandler.reportException("Error while creating layout", exc);
            }
            chosenLayout = layout.newInstance();
            monitor.done();
        }
    };

    final JMenu findMenu = new JMenu("Find");
    final JMenuItem nodeByName = new JMenuItem("Node by name (Ctrl+F)");

    final GraphEditor thisEditor = this;
    nodeByName.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent e) {
            Display.getDefault().asyncExec(new Runnable() {
                @Override
                public void run() {
                    if (wndFind != null) {
                        wndFind.close();
                    }
                    try {
                        wndFind = new FindWindow<NodeDescriptor>(editorComposite.getShell(), thisEditor,
                                graph.getVertices());
                        wndFind.open();
                    } catch (IllegalArgumentException e) {
                        errorHandler.reportException("", e);
                    }
                }
            });
        }
    });

    findMenu.add(nodeByName);

    final JMenu tools = new JMenu("Tools");
    final JMenuItem findCircles = new JMenuItem("Show circles");
    final JMenuItem findPaths = new JMenuItem("Show parallel paths");
    final JMenuItem clearResults = new JMenuItem("Clear Results");

    findCircles.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent ev) {
            final Job circlesJob = new Job("Searching for circles") {
                @Override
                protected IStatus run(final IProgressMonitor monitor) {
                    if (graph == null) {
                        return null;
                    }
                    CircleCheck<NodeDescriptor, EdgeDescriptor> checker = new CircleCheck<NodeDescriptor, EdgeDescriptor>(
                            graph);
                    if (checker.isCyclic()) {
                        for (EdgeDescriptor e : graph.getEdges()) {
                            e.setColour(Color.lightGray);
                        }
                        for (Deque<EdgeDescriptor> st : checker.getCircles()) {
                            for (EdgeDescriptor e : st) {
                                e.setColour(NodeColours.DARK_RED);
                            }
                        }
                        refresh();
                    } else {
                        errorHandler.reportInformation("Result:\n\nThis graph is not cyclic!");
                    }

                    return Status.OK_STATUS;
                } // end run
            }; // end job
            circlesJob.schedule();
        } // end actionPerformed
    });

    findPaths.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent ev) {
            final Job pathsJob = new Job("Searching for parallel paths") {
                @Override
                protected IStatus run(final IProgressMonitor monitor) {
                    if (graph == null) {
                        return null;
                    }
                    CheckParallelPaths<NodeDescriptor, EdgeDescriptor> checker = null;
                    checker = new CheckParallelPaths<NodeDescriptor, EdgeDescriptor>(graph);
                    if (checker.hasParallelPaths()) {
                        for (EdgeDescriptor e : graph.getEdges()) {
                            e.setColour(Color.lightGray);
                        }
                        for (Deque<EdgeDescriptor> list : checker.getPaths()) {
                            for (EdgeDescriptor e : list) {
                                e.setColour(NodeColours.DARK_RED);
                            }
                        }
                        refresh();
                    } else {
                        errorHandler.reportInformation("Result:\n\nThere are no parallel paths in this graph!");
                    }

                    return Status.OK_STATUS;
                } // end run
            }; // end job
            pathsJob.schedule();
        } // end actionPerformed
    });

    clearResults.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent ev) {
            for (final EdgeDescriptor e : graph.getEdges()) {
                e.setColour(Color.black);
            }
            refresh();
        }
    });

    tools.add(findCircles);
    tools.add(findPaths);
    tools.add(clearResults);

    menuBar.add(mnFile);
    menuBar.add(findMenu);
    menuBar.add(tools);
    menuBar.add(layoutMenu);

    // TODO implement refresh action
    /*
     * JMenuItem RefreshMenu=new JMenuItem("Refresh"); ActionListener
     * RefreshAction=new ActionListener() { public void
     * actionPerformed(ActionEvent ev) { GraphGenerator.schedule(); } };
     * RefreshMenu.addActionListener(RefreshAction);
     * 
     * menuBar.add(RefreshMenu);
     */

    handlerService.activateHandler(GRAPH_SEARCHCMD_ID, new AbstractHandler() {
        @Override
        public Object execute(final ExecutionEvent event) throws ExecutionException {
            nodeByName.getActionListeners()[0].actionPerformed(null);
            handlers.add(this);
            return null;
        }
    });

    handlerService.activateHandler(GRAPH_SAVECMD_ID, new AbstractHandler() {
        @Override
        public Object execute(final ExecutionEvent event) throws ExecutionException {
            mntmSave.getActionListeners()[0].actionPerformed(null);
            handlers.add(this);
            return null;
        }
    });

    handlerService.activateHandler(GRAPH_EXPORTCMD_ID, new AbstractHandler() {
        @Override
        public Object execute(final ExecutionEvent event) throws ExecutionException {
            mntmExportToImage.getActionListeners()[0].actionPerformed(null);
            handlers.add(this);
            return null;
        }
    });

    try {
        generator.generateGraph();
        setLabeller(generator.getLabeler());
        setGraph(generator.getGraph());
    } catch (InterruptedException ex) {
        errorHandler.reportException("Error while creating the graph", ex);
    }

}

From source file:org.esa.s1tbx.ocean.worldwind.layers.Level2ProductLayer.java

public JPanel getControlPanel(final WorldWindowGLCanvas wwd) {
    theControlLevel2Panel = new JPanel(new GridLayout(7, 1, 5, 5));
    theControlLevel2Panel.setVisible(false);
    final JRadioButton owiBtn = new JRadioButton("OWI");
    owiBtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            theSelectedComp = "owi";
            setComponentVisible("owi", wwd);
            theArrowsCB.setEnabled(true);
        }//from   w  w w  . jav a  2s  .c  o  m
    });

    final JRadioButton oswBtn = new JRadioButton("OSW");
    oswBtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            theSelectedComp = "osw";
            setComponentVisible("osw", wwd);
            theArrowsCB.setEnabled(false);

            //SystemUtils.LOG.info("theSurfaceProductHash " + theSurfaceProductHash);
            //SystemUtils.LOG.info("theSurfaceSequenceHash " + theSurfaceSequenceHash);
        }
    });

    final JRadioButton rvlBtn = new JRadioButton("RVL");
    rvlBtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            theSelectedComp = "rvl";
            //System.out.println("rvl:");
            //setComponentVisible("owi", false, getWwd());
            //setComponentVisible("osw", false, getWwd());
            setComponentVisible("rvl", wwd);
            theArrowsCB.setEnabled(false);
        }
    });

    final ButtonGroup group = new ButtonGroup();
    group.add(owiBtn);
    group.add(oswBtn);
    group.add(rvlBtn);
    owiBtn.setSelected(true);

    theSelectedComp = "owi";

    final JPanel componentTypePanel = new JPanel(new GridLayout(1, 4, 5, 5));
    componentTypePanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    componentTypePanel.add(new JLabel("Component:"));
    componentTypePanel.add(owiBtn);
    componentTypePanel.add(oswBtn);
    componentTypePanel.add(rvlBtn);
    theControlLevel2Panel.add(componentTypePanel);

    final JPanel arrowDisplayPanel = new JPanel(new GridLayout(1, 2, 5, 5));

    theArrowsCB = new JCheckBox(new AbstractAction() {
        public void actionPerformed(ActionEvent actionEvent) {
            // Simply enable or disable the layer based on its toggle button.
            if (((JCheckBox) actionEvent.getSource()).isSelected())
                theOWIArrowsDisplayed = true;
            else
                theOWIArrowsDisplayed = false;

            wwd.redrawNow();
        }
    });

    arrowDisplayPanel.add(new JLabel("Display Wind Vectors:"));
    arrowDisplayPanel.add(theArrowsCB);
    theControlLevel2Panel.add(arrowDisplayPanel);

    /*
    final JPanel subsectionPanel = new JPanel(new GridLayout(1, 2, 5, 5));
    JComboBox sectionDropDown = new JComboBox();
    sectionDropDown.addItem("001");
    sectionDropDown.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
        SystemUtils.LOG.info("drop down changed");
    }
    });
            
    subsectionPanel.add(new JLabel("Subsection:"));
    subsectionPanel.add(sectionDropDown);
            
    theControlLevel2Panel.add(subsectionPanel);
    */

    final JPanel maxPanel = new JPanel(new GridLayout(1, 2, 5, 5));
    maxPanel.add(new JLabel("Max OWI Wind Speed:"));

    final JSpinner maxSP = new JSpinner(new SpinnerNumberModel(10, 0, 10, 1));
    maxSP.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            int newValue = (Integer) ((JSpinner) e.getSource()).getValue();

            theOWILimitChanged = true;
        }
    });
    maxPanel.add(maxSP);
    theControlLevel2Panel.add(maxPanel);

    final JPanel minPanel = new JPanel(new GridLayout(1, 2, 5, 5));
    minPanel.add(new JLabel("Min OWI Wind Speed:"));

    final JSpinner minSP = new JSpinner(new SpinnerNumberModel(0, 0, 10, 1));
    minSP.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            theOWILimitChanged = true;
        }
    });
    minPanel.add(minSP);
    theControlLevel2Panel.add(minPanel);

    final JPanel maxRVLPanel = new JPanel(new GridLayout(1, 2, 5, 5));
    maxRVLPanel.add(new JLabel("Max RVL Rad Vel.:"));

    final JSpinner maxRVLSP = new JSpinner(new SpinnerNumberModel(6, 0, 10, 1));
    maxRVLSP.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            int newValue = (Integer) ((JSpinner) e.getSource()).getValue();
            theRVLLimitChanged = true;
        }
    });
    maxRVLPanel.add(maxRVLSP);
    theControlLevel2Panel.add(maxRVLPanel);

    final JButton updateButton = new JButton("Update");
    updateButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {

            if (theOWILimitChanged) {

                //double minValue = ((Integer) minSP.getValue()) * 1.0e4;
                //double maxValue = ((Integer) maxSP.getValue()) * 1.0e4;
                double minValue = ((Integer) minSP.getValue());
                double maxValue = ((Integer) maxSP.getValue());
                recreateColorBarAndGradient(minValue, maxValue, "owi", wwd,
                        theSelectedComp.equalsIgnoreCase("owi"));
            }

            if (theRVLLimitChanged) {
                //SystemUtils.LOG.info("theRVLLimitChanged");

                //double minValue = ((Integer) minSP.getValue()) * 1.0e4;
                //double maxValue = ((Integer) maxSP.getValue()) * 1.0e4;

                double maxValue = ((Integer) maxRVLSP.getValue());
                double minValue = -1 * maxValue;

                recreateColorBarAndGradient(minValue, maxValue, "rvl", wwd,
                        theSelectedComp.equalsIgnoreCase("rvl"));
            }

            theOWILimitChanged = false;
            theRVLLimitChanged = false;
        }
    });
    theControlLevel2Panel.add(updateButton);

    createColorBarLegend(0, 10, "OWI Wind Speed", "owi");
    createColorBarLegend(0, 10, "OSW Wave Height.", "osw");
    createColorBarLegend(-6, 6, "RVL Rad. Vel.", "rvl");
    //addRenderable(theColorBarLegendHash.get("owi"));

    return theControlLevel2Panel;
}

From source file:org.executequery.gui.scriptgenerators.GenerateScriptsPanelThree.java

private void createTableOptionsPanel() {

    constraintsCheck = new JCheckBox("Include constraints");
    consAsAlterCheck = new JCheckBox("As ALTER TABLE statements", true);
    consInCreateCheck = new JCheckBox("Within CREATE TABLE statements");

    constraintsCheck.addItemListener(this);

    ButtonGroup bg = new ButtonGroup();
    bg.add(consAsAlterCheck);/* w w  w  .java  2 s.co m*/
    bg.add(consInCreateCheck);

    consInCreateCheck.setEnabled(false);
    consAsAlterCheck.setEnabled(false);

    createTableOptionsPanel = new ComponentTitledPanel(constraintsCheck);
    JPanel _panel = createTableOptionsPanel.getContentPane();
    _panel.setLayout(new FlowLayout(FlowLayout.LEFT, 15, 5));
    _panel.add(consAsAlterCheck);
    _panel.add(consInCreateCheck);
}

From source file:org.f2o.absurdum.puck.gui.PuckFrame.java

/**
 * Instances and shows Puck's main frame.
 *//*  ww  w . java  2s.c o m*/
public PuckFrame() {

    super();

    setLookAndFeel(PuckConfiguration.getInstance().getProperty("look"));

    /*
    LookAndFeelInfo[] lfs = UIManager.getInstalledLookAndFeels();
    for ( int i = 0 ; i < lfs.length ; i++ )
    {
       if ( lfs[i].getName().toLowerCase().contains("nimbus") )
       {
    try 
    {
       UIManager.setLookAndFeel(lfs[i].getClassName());
    } 
    catch (Exception e) //class not found, instantiation exception, etc. (shouldn't happen)
    {
       e.printStackTrace();
    }
            
       }
    }
    */

    setSize(PuckConfiguration.getInstance().getIntegerProperty("windowWidth"),
            PuckConfiguration.getInstance().getIntegerProperty("windowHeight"));
    setLocation(PuckConfiguration.getInstance().getIntegerProperty("windowLocationX"),
            PuckConfiguration.getInstance().getIntegerProperty("windowLocationY"));
    //setSize(600,600);
    if (PuckConfiguration.getInstance().getBooleanProperty("windowMaximized"))
        maximizeIfPossible();
    //setTitle(Messages.getInstance().getMessage("frame.title"));
    refreshTitle();
    left = new JPanel();
    right = new JPanel();
    JScrollPane rightScroll = new JScrollPane(right);
    rightScroll.getVerticalScrollBar().setUnitIncrement(16); //faster scrollbar (by default it was very slow, maybe because component inside is not text component!)
    split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, left, rightScroll) {
        //dynamic resizing of right panel
        /*
        public void setDividerLocation ( int pixels )
        {
              if ( propPanel != null )
              {
          double rightPartSize = getContentPane().getWidth() - pixels - 15;
          System.out.println("rps=" + rightPartSize);
          System.out.println("mnw=" + this.getMinimumSize().getWidth());
          Dimension propPanSize = propPanel.getSize();
          int propPanHeight = 0;
          if (propPanSize != null) propPanHeight = (int) propPanSize.getHeight();
          //propPanel.revalidate();
          System.out.println("h " + propPanHeight);
          //if ( rightPartSize >= propPanel.getMinimumSize().getWidth() )
             propPanel.setPreferredSize(new Dimension((int)rightPartSize,propPanHeight));
             //propPanel.setMinimumSize(new Dimension((int)rightPartSize,propPanHeight));
             //propPanel.setMaximumSize(new Dimension((int)rightPartSize,propPanHeight));
             //propPanel.setSize(new Dimension((int)rightPartSize,propPanHeight));
             propPanel.revalidate();
              }
              super.setDividerLocation(pixels);
        }
        */

    };
    split.setContinuousLayout(true);
    split.setResizeWeight(0.60);
    final int dividerLoc = PuckConfiguration.getInstance().getIntegerProperty("dividerLocation", 0);

    /*
    SwingUtilities.invokeLater(new Runnable(){
    public void run()
    {
    */

    /*   
    }
    });
    */
    split.setOneTouchExpandable(true);
    getContentPane().add(split);

    System.out.println(Toolkit.getDefaultToolkit().getBestCursorSize(20, 20));
    //it's 32x32. Will have to do it.

    //Image img = Toolkit.getDefaultToolkit().createImage( getClass().getResource("addCursor32.png") );

    //Image img = Toolkit.getDefaultToolkit().createImage("addCursor32.png");

    left.setLayout(new BorderLayout());

    //right.setLayout(new BoxLayout(right,BoxLayout.LINE_AXIS));
    if (PuckConfiguration.getInstance().getBooleanProperty("dynamicFormResizing"))
        right.setLayout(new BorderLayout());
    else
        right.setLayout(new FlowLayout());

    propPanel = new PropertiesPanel();
    right.add(propPanel);

    graphPanel = new GraphEditingPanel(propPanel);
    graphPanel.setGrid(Boolean.valueOf(PuckConfiguration.getInstance().getProperty("showGrid")).booleanValue());
    graphPanel.setSnapToGrid(
            Boolean.valueOf(PuckConfiguration.getInstance().getProperty("snapToGrid")).booleanValue());
    propPanel.setGraphEditingPanel(graphPanel);
    tools = new PuckToolBar(graphPanel, propPanel, this);
    left.add(tools, BorderLayout.WEST);
    left.add(graphPanel, BorderLayout.CENTER);

    /*
    Action testAction = 
    new AbstractAction()
    {
       public void actionPerformed ( ActionEvent evt )
       {
          System.out.println("Puck!");
       }
    }
    ;
    testAction.putValue(Action.NAME,"Print Puck");
            
    tools.add(testAction);
    */

    /*
    public void saveChanges ( )
    {
       if ( editingFileName == null )
       {
    //save as... code
       }
       else
       {
    File f = new File(editingFileName);
    try
    {
       Document d = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
       d.appendChild(graphPanel.getWorldNode().getAssociatedPanel().getXML(d));
       Transformer t = TransformerFactory.newInstance().newTransformer();
       Source s = new DOMSource(d);
       Result r = new StreamResult(f);
       t.transform(s,r);
       editingFileName = f.toString();
       refreshTitle();
    }
    catch ( Exception e )
    {
       JOptionPane.showMessageDialog(PuckFrame.this,e,"Whoops!",JOptionPane.ERROR_MESSAGE);
       e.printStackTrace();
    }
       }
    }
    */

    JMenuBar mainMenuBar = new JMenuBar();
    JMenu fileMenu = new JMenu(UIMessages.getInstance().getMessage("menu.file"));
    fileMenu.setMnemonic(KeyEvent.VK_F);
    saveMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.file.save"));
    saveMenuItem.setMnemonic(KeyEvent.VK_S);
    saveMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            if (editingFileName == null)
                JOptionPane.showMessageDialog(PuckFrame.this, "File has no name!", "Whoops!",
                        JOptionPane.ERROR_MESSAGE);
            /*
            File f = new File(editingFileName);
            try
            {
             Document d = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
             d.appendChild(graphPanel.getWorldNode().getAssociatedPanel().getXML(d));
             Transformer t = TransformerFactory.newInstance().newTransformer();
             Source s = new DOMSource(d);
             Result r = new StreamResult(f);
             t.transform(s,r);
             editingFileName = f.toString();
             refreshTitle();
            }
            catch ( Exception e )
            {
             JOptionPane.showMessageDialog(PuckFrame.this,e,"Whoops!",JOptionPane.ERROR_MESSAGE);
             e.printStackTrace();
            }
            */
            try {
                saveChangesInCurrentFile();
            } catch (Exception e) {
                JOptionPane.showMessageDialog(PuckFrame.this, e.getLocalizedMessage(), "Whoops!",
                        JOptionPane.ERROR_MESSAGE);
                e.printStackTrace();
            }
        }
    });
    JMenu newMenu = new JMenu(UIMessages.getInstance().getMessage("menu.file.new"));
    JMenuItem newBlankMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.file.new.blank"));
    //newBlankMenuItem.setMnemonic(KeyEvent.VK_N);
    newBlankMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            GraphElementPanel.emptyQueue(); //stop deferred loads
            graphPanel.clear();
            propPanel.clear();
            JSyntaxBSHCodeFrame.closeAllInstances();
            WorldPanel wp = new WorldPanel(graphPanel);
            WorldNode wn = new WorldNode(wp);
            graphPanel.setWorldNode(wn);
            propPanel.show(graphPanel.getWorldNode());
            resetCurrentlyEditingFile();
            refreshTitle();
            //revalidate(); //only since java 1.7
            //invalidate();
            //validate();
            split.revalidate(); //JComponents do have it before java 1.7 (not JFrame)
        }
    });
    newMenu.add(newBlankMenuItem);
    JMenu templateMenus = new WorldTemplateMenuBuilder(this).getMenu();
    if (templateMenus != null) {
        for (int i = 0; i < templateMenus.getItemCount(); i++) {
            if (i == 0)
                newMenu.add(new JSeparator());
            newMenu.add(templateMenus.getItem(i));
        }
    }
    JMenuItem saveAsMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.file.saveas"));
    saveAsMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            /*
            JFileChooser jfc = new JFileChooser(".");
            int opt = jfc.showSaveDialog(PuckFrame.this);
            if ( opt == JFileChooser.APPROVE_OPTION )
            {
             File f = jfc.getSelectedFile();
             try
             {
                Document d = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
                d.appendChild(graphPanel.getWorldNode().getAssociatedPanel().getXML(d));
                Transformer t = TransformerFactory.newInstance().newTransformer();
                Source s = new DOMSource(d);
                Result r = new StreamResult(f);
                t.transform(s,r);
                editingFileName = f.toString();
                saveMenuItem.setEnabled(true);
                refreshTitle();
             }
             catch ( Exception e )
             {
                JOptionPane.showMessageDialog(PuckFrame.this,e,"Whoops!",JOptionPane.ERROR_MESSAGE);
                e.printStackTrace();
             }
            }
            */
            try {
                saveAs();
                saveMenuItem.setEnabled(true);
            } catch (Exception e) {
                JOptionPane.showMessageDialog(PuckFrame.this, e.getLocalizedMessage(), "Whoops!",
                        JOptionPane.ERROR_MESSAGE);
                e.printStackTrace();
            }
            //saveAs(saveMenuItem);
        }
    });
    JMenuItem openMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.file.open"));
    openMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            //graphPanel.setVisible(false);
            //propPanel.setVisible(false);

            JFileChooser jfc = new JFileChooser(".");
            jfc.setFileFilter(new FiltroFicheroMundo());
            int opt = jfc.showOpenDialog(PuckFrame.this);
            if (opt == JFileChooser.APPROVE_OPTION) {
                File f = jfc.getSelectedFile();
                openFileOrShowError(f);
            }

            //graphPanel.setVisible(true);
            //propPanel.setVisible(true);
        }
    });
    openRecentMenu = new JMenu(UIMessages.getInstance().getMessage("menu.file.recent"));
    JMenuItem exitMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.file.exit"));
    exitMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {

            /*
            int opt = JOptionPane.showConfirmDialog(PuckFrame.this,Messages.getInstance().getMessage("exit.sure.text"),Messages.getInstance().getMessage("exit.sure.title"),JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
                    
            if ( opt == JOptionPane.YES_OPTION )
             System.exit(0);
            */
            userExit();

        }
    });
    JMenu exportMenu = new JMenu(UIMessages.getInstance().getMessage("menu.file.export"));
    JMenuItem exportAppletMenuItem = new JMenuItem(
            UIMessages.getInstance().getMessage("menu.file.export.applet"));
    exportAppletMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            ExportAppletDialog dial = new ExportAppletDialog(PuckFrame.this);
            dial.setVisible(true);
        }
    });
    exportMenu.add(exportAppletMenuItem);

    fileMenu.add(newMenu);
    fileMenu.add(openMenuItem);
    fileMenu.add(openRecentMenu);
    updateRecentMenu();
    fileMenu.add(new JSeparator());
    saveMenuItem.setEnabled(false);
    fileMenu.add(saveMenuItem);
    fileMenu.add(saveAsMenuItem);
    fileMenu.add(exportMenu);
    fileMenu.add(new JSeparator());
    fileMenu.add(exitMenuItem);

    mainMenuBar.add(fileMenu);

    /**
     * Create an Edit menu to support cut/copy/paste.
     */

    JMenu editMenu = new JMenu(UIMessages.getInstance().getMessage("menu.edit"));
    editMenu.setMnemonic(KeyEvent.VK_E);

    JMenuItem findMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.find.entity"));
    findMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            showFindEntityDialog();
        }
    });
    editMenu.add(findMenuItem);
    editMenu.add(new JSeparator());

    JMenuItem aMenuItem = new JMenuItem(new CutAction());
    aMenuItem.setText(UIMessages.getInstance().getMessage("menuaction.cut"));
    aMenuItem.setMnemonic(KeyEvent.VK_T);
    editMenu.add(aMenuItem);

    aMenuItem = new JMenuItem(new CopyAction());
    aMenuItem.setText(UIMessages.getInstance().getMessage("menuaction.copy"));
    aMenuItem.setMnemonic(KeyEvent.VK_C);
    editMenu.add(aMenuItem);

    aMenuItem = new JMenuItem(new PasteAction());
    aMenuItem.setText(UIMessages.getInstance().getMessage("menuaction.paste"));
    aMenuItem.setMnemonic(KeyEvent.VK_P);
    editMenu.add(aMenuItem);

    mainMenuBar.add(editMenu);

    JMenu optionsMenu = new JMenu(UIMessages.getInstance().getMessage("menu.options"));
    JMenu gridMenu = new JMenu(UIMessages.getInstance().getMessage("menu.options.grid"));
    optionsMenu.add(gridMenu);
    final JCheckBoxMenuItem showGridItem = new JCheckBoxMenuItem(
            UIMessages.getInstance().getMessage("menu.options.grid.show"));
    showGridItem.setSelected(
            Boolean.valueOf(PuckConfiguration.getInstance().getProperty("showGrid")).booleanValue());
    gridMenu.add(showGridItem);
    showGridItem.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                graphPanel.setGrid(true);
                PuckConfiguration.getInstance().setProperty("showGrid", "true");
            } else if (e.getStateChange() == ItemEvent.DESELECTED) {
                graphPanel.setGrid(false);
                PuckConfiguration.getInstance().setProperty("showGrid", "false");
            }
            graphPanel.repaint();
        }
    });
    final JCheckBoxMenuItem snapToGridItem = new JCheckBoxMenuItem(
            UIMessages.getInstance().getMessage("menu.options.grid.snap"));
    snapToGridItem.setSelected(
            Boolean.valueOf(PuckConfiguration.getInstance().getProperty("snapToGrid")).booleanValue());
    gridMenu.add(snapToGridItem);
    snapToGridItem.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                graphPanel.setSnapToGrid(true);
                PuckConfiguration.getInstance().setProperty("snapToGrid", "true");
            } else if (e.getStateChange() == ItemEvent.DESELECTED) {
                graphPanel.setSnapToGrid(false);
                PuckConfiguration.getInstance().setProperty("snapToGrid", "false");
            }
            graphPanel.repaint();
        }
    });

    JMenuItem translationModeMenu = new JMenu(UIMessages.getInstance().getMessage("menu.options.translation"));
    ButtonGroup translationGroup = new ButtonGroup();
    final JRadioButtonMenuItem holdMenuItem = new JRadioButtonMenuItem(
            UIMessages.getInstance().getMessage("menu.options.translation.hold"));
    final JRadioButtonMenuItem pushMenuItem = new JRadioButtonMenuItem(
            UIMessages.getInstance().getMessage("menu.options.translation.push"));
    pushMenuItem.setSelected("push".equals(PuckConfiguration.getInstance().getProperty("translateMode")));
    if (!pushMenuItem.isSelected())
        holdMenuItem.setSelected(true);
    translationGroup.add(holdMenuItem);
    translationGroup.add(pushMenuItem);
    holdMenuItem.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent arg0) {
            if (holdMenuItem.isSelected())
                PuckConfiguration.getInstance().setProperty("translateMode", "hold");
            else
                PuckConfiguration.getInstance().setProperty("translateMode", "push");
        }
    });
    translationModeMenu.add(holdMenuItem);
    translationModeMenu.add(pushMenuItem);
    optionsMenu.add(translationModeMenu);

    JMenuItem toolSelectionModeMenu = new JMenu(
            UIMessages.getInstance().getMessage("menu.options.toolselection"));
    ButtonGroup toolSelectionGroup = new ButtonGroup();
    final JRadioButtonMenuItem oneUseMenuItem = new JRadioButtonMenuItem(
            UIMessages.getInstance().getMessage("menu.options.toolselection.oneuse"));
    final JRadioButtonMenuItem multipleUseMenuItem = new JRadioButtonMenuItem(
            UIMessages.getInstance().getMessage("menu.options.toolselection.multipleuse"));
    multipleUseMenuItem.setSelected(
            "multipleUse".equalsIgnoreCase(PuckConfiguration.getInstance().getProperty("toolSelectionMode")));
    if (!multipleUseMenuItem.isSelected())
        oneUseMenuItem.setSelected(true);
    toolSelectionGroup.add(oneUseMenuItem);
    toolSelectionGroup.add(multipleUseMenuItem);
    oneUseMenuItem.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent arg0) {
            if (oneUseMenuItem.isSelected())
                PuckConfiguration.getInstance().setProperty("toolSelectionMode", "oneUse");
            else
                PuckConfiguration.getInstance().setProperty("toolSelectionMode", "multipleUse");
        }
    });
    toolSelectionModeMenu.add(oneUseMenuItem);
    toolSelectionModeMenu.add(multipleUseMenuItem);
    optionsMenu.add(toolSelectionModeMenu);

    JMenuItem sizesMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.options.iconsizes"));
    sizesMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            IconSizesDialog dial = new IconSizesDialog(PuckFrame.this, true);
            dial.setVisible(true);
        }
    });
    optionsMenu.add(sizesMenuItem);

    JMenuItem showHideMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.options.showhide"));
    showHideMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            ShowHideDialog dial = new ShowHideDialog(PuckFrame.this, true);
            dial.setVisible(true);
        }
    });
    optionsMenu.add(showHideMenuItem);

    JMenuItem mapColorsMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.options.mapcolors"));
    mapColorsMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            MapColorsDialog dial = new MapColorsDialog(PuckFrame.this, true);
            dial.setVisible(true);
        }
    });
    optionsMenu.add(mapColorsMenuItem);

    String skinList = PuckConfiguration.getInstance().getProperty("availableSkins");
    if (skinList != null && skinList.trim().length() > 0) {
        JMenu skinsMenu = new JMenu(UIMessages.getInstance().getMessage("menu.skins"));
        StringTokenizer st = new StringTokenizer(skinList, ", ");
        ButtonGroup skinButtons = new ButtonGroup();
        while (st.hasMoreTokens()) {
            final String nextSkin = st.nextToken();
            final JRadioButtonMenuItem skinMenuItem = new JRadioButtonMenuItem(nextSkin);
            skinMenuItem.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    setSkin(nextSkin);
                    skinMenuItem.setSelected(true);
                }
            });
            if (nextSkin.equals(PuckConfiguration.getInstance().getProperty("skin")))
                skinMenuItem.setSelected(true);
            skinsMenu.add(skinMenuItem);
            skinButtons.add(skinMenuItem);
        }
        optionsMenu.add(skinsMenu);
    }

    JMenu lookFeelMenu = new JMenu(UIMessages.getInstance().getMessage("menu.looks"));
    ButtonGroup lookButtons = new ButtonGroup();
    final JRadioButtonMenuItem defaultLookMenuItem = new JRadioButtonMenuItem(
            UIMessages.getInstance().getMessage("menu.looks.default"));
    if ("default".equals(PuckConfiguration.getInstance().getProperty("look"))) {
        defaultLookMenuItem.setSelected(true);
    }
    lookFeelMenu.add(defaultLookMenuItem);
    lookButtons.add(defaultLookMenuItem);
    defaultLookMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            setLookAndFeel("default");
            defaultLookMenuItem.setSelected(true);
        }
    });
    final JRadioButtonMenuItem systemLookMenuItem = new JRadioButtonMenuItem(
            UIMessages.getInstance().getMessage("menu.looks.system"));
    if ("system".equals(PuckConfiguration.getInstance().getProperty("look"))) {
        systemLookMenuItem.setSelected(true);
    }
    lookFeelMenu.add(systemLookMenuItem);
    lookButtons.add(systemLookMenuItem);
    systemLookMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            setLookAndFeel("system");
            systemLookMenuItem.setSelected(true);
        }
    });
    String additionalLookList = PuckConfiguration.getInstance().getProperty("additionalLooks");
    if (additionalLookList != null && additionalLookList.trim().length() > 0) {
        StringTokenizer st = new StringTokenizer(additionalLookList, ", ");
        while (st.hasMoreTokens()) {
            final String nextLook = st.nextToken();
            final JRadioButtonMenuItem lookMenuItem = new JRadioButtonMenuItem(nextLook);
            lookMenuItem.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    setLookAndFeel(nextLook);
                    lookMenuItem.setSelected(true);
                }
            });
            if (nextLook.equals(PuckConfiguration.getInstance().getProperty("look"))) {
                lookMenuItem.setSelected(true);
            }
            lookFeelMenu.add(lookMenuItem);
            lookButtons.add(lookMenuItem);
        }
    }
    optionsMenu.add(lookFeelMenu);

    optionsMenu.add(new UILanguageSelectionMenu(this));

    mainMenuBar.add(optionsMenu);

    JMenu toolsMenu = new JMenu(UIMessages.getInstance().getMessage("menu.tools"));

    final JMenuItem verbListMenuItem = new JMenuItem(
            UIMessages.getInstance().getMessage("menu.tools.verblist"));
    verbListMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            WorldPanel wp = (WorldPanel) graphPanel.getWorldNode().getAssociatedPanel();
            VerbListFrame vlf = VerbListFrame.getInstance(wp.getSelectedLanguageCode());
            vlf.setVisible(true);
        }
    });
    toolsMenu.add(verbListMenuItem);

    final JMenuItem validateMenuItem = new JMenuItem(
            UIMessages.getInstance().getMessage("menu.tools.validatebsh"));
    validateMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            BeanShellCodeValidator bscv = new BeanShellCodeValidator(graphPanel);
            if (!bscv.validate()) {
                BeanShellErrorsDialog bsed = new BeanShellErrorsDialog(PuckFrame.this, bscv.getErrorText());
                bsed.setVisible(true);
                //JOptionPane.showMessageDialog(PuckFrame.this, bscv.getErrorText());
            } else {
                JOptionPane.showMessageDialog(PuckFrame.this,
                        UIMessages.getInstance().getMessage("bsh.code.ok"), "OK!",
                        JOptionPane.INFORMATION_MESSAGE);
                //JOptionPane.showMessageDialog(PuckFrame.this, bscv.getErrorText());
            }
        }
    });
    toolsMenu.add(validateMenuItem);

    mainMenuBar.add(toolsMenu);

    JMenu helpMenu = new JMenu(UIMessages.getInstance().getMessage("menu.help"));
    //JHelpAction.startHelpWorker("help/PUCKHelp.hs");
    //JHelpAction helpTocAction = JHelpAction.getShowHelpInstance(Messages.getInstance().getMessage("menu.help.toc"));
    //JHelpAction helpContextSensitiveAction = JHelpAction.getTrackInstance(Messages.getInstance().getMessage("menu.help.context"));
    //final JMenuItem helpTocMenuItem = new JMenuItem(helpTocAction);
    //final JMenuItem helpContextSensitiveMenuItem = new JMenuItem(helpContextSensitiveAction);
    //helpMenu.add(helpTocMenuItem);
    //helpMenu.add(helpContextSensitiveMenuItem);

    final JMenuItem helpMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.help.toc"));
    helpMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            DocumentationLinkDialog dial = new DocumentationLinkDialog(PuckFrame.this, true);
            dial.setVisible(true);
        }
    });
    helpMenu.add(helpMenuItem);

    mainMenuBar.add(helpMenu);

    MenuMnemonicOnTheFly.setMnemonics(mainMenuBar);

    this.setJMenuBar(mainMenuBar);

    //setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);

    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            userExit();
        }
    });

    propPanel.show(graphPanel.getWorldNode());

    setVisible(true);

    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            if (dividerLoc > 0)
                split.setDividerLocation(dividerLoc);
            else
                split.setDividerLocation(0.60);
        }
    });

}

From source file:org.geworkbench.components.lincs.LincsInterface.java

public LincsInterface() {

    final String lincsCwbFileName = this.getClass().getPackage().getName().replace(".",
            FilePathnameUtils.FILE_SEPARATOR) + FilePathnameUtils.FILE_SEPARATOR + "Lincs.cwb.xml";
    setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));

    // temp do this, if data is there, then may be take out
    hideColumnList.add("P-value");

    add(queryTypePanel);/*from  www .j a  va2  s.co  m*/
    add(queryConditionPanel1);
    add(queryConditionPanel2);

    add(queryCommandPanel);

    experimental.setSelected(true);

    ButtonGroup group = new ButtonGroup();
    group.add(experimental);
    group.add(computational);
    queryTypePanel.add(new JLabel("Query Type"));
    queryTypePanel.add(experimental);
    queryTypePanel.add(computational);
    queryTypePanel.add(new JLabel("                                              "));
    JLabel viewLicenseLabel = new JLabel("<html><font color=blue><u><b>View License</b></u></font></html>");
    ;
    queryTypePanel.add(viewLicenseLabel);
    viewLicenseLabel.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            viewLicense_actionPerformed(lincsCwbFileName);
        }
    });
    String url = getLincsWsdlUrl();
    // String url =
    // "http://localhost:8080/axis2/services/LincsService?wsdl";
    lincs = new Lincs(url, null, null);

    queryConditionPanel1.setLayout(new GridLayout(2, 7));

    final JLabel tissueTypeLabel = new JLabel("Tissue Type");
    final JLabel cellLineLabel = new JLabel("Cell Line");
    final JLabel drug1Label = new JLabel("Drug 1");
    final JLabel drug2Label = new JLabel("Drug 2");
    final JLabel assayTypeLabel = new JLabel("Assay Type");
    final JLabel synergyMeasurementLabel = new JLabel("Synergy Measurement Type");
    final JLabel similarityAlgorithmLabel = new JLabel("Similarity Algorithm");
    final JLabel blankLabel = new JLabel("");

    queryConditionPanel1.add(new JLabel(""));
    queryConditionPanel1.add(new JLabel(""));
    queryConditionPanel1.add(drug1Label);
    queryConditionPanel1.add(new JLabel(""));
    queryConditionPanel1.add(new JLabel(""));
    queryConditionPanel1.add(new JLabel(""));
    queryConditionPanel1.add(blankLabel);

    queryConditionPanel1.add(tissueTypeLabel);
    queryConditionPanel1.add(cellLineLabel);
    queryConditionPanel1.add(drug1Search);
    queryConditionPanel1.add(drug2Label);
    queryConditionPanel1.add(assayTypeLabel);
    queryConditionPanel1.add(synergyMeasurementLabel);
    queryConditionPanel1.add(new JLabel(""));

    queryConditionPanel2.setLayout(new GridLayout(1, 7));
    List<String> tissueTypeList = null;
    List<String> drug1List = null;
    List<String> assayTypeList = null;
    List<String> synergyMeasuremetnTypeList = null;
    List<String> similarityAlgorithmList = null;

    try {
        tissueTypeList = addAll(lincs.getAllTissueNames());
        drug1List = addAll(lincs.getCompound1NamesFromExperimental(null, null));
        assayTypeList = addAll(lincs.getAllAssayTypeNames());
        synergyMeasuremetnTypeList = addAll(lincs.getAllMeasurementTypeNames());
        similarityAlgorithmList = addAll(lincs.getALLSimilarAlgorithmNames());
    } catch (Exception ex) {
        log.error(ex.getMessage());
    }

    tissueTypeBox = new JList();
    final JScrollPane tissueTypeBoxPanel = buildJListPanel(tissueTypeList, tissueTypeBox);

    cellLineBox = new JList();
    final JScrollPane cellLineBoxPanel = buildJListPanel(null, cellLineBox);
    cellLineBox.setEnabled(false);

    final JScrollPane drug1BoxPanel = buildFilterJListPanel(drug1List, drug1Box);

    drug2Box = new JList();
    final JScrollPane drug2BoxPanel = buildJListPanel(null, drug2Box);
    drug2Box.setEnabled(false);

    assayTypeBox = new JList();
    final JScrollPane assayTypeBoxPanel = buildJListPanel(assayTypeList, assayTypeBox);

    synergyMeasurementTypeBox = new JList();
    final JScrollPane synergyMeasuremetnTypeBoxPanel = buildJListPanel(synergyMeasuremetnTypeList,
            synergyMeasurementTypeBox);

    similarityAlgorithmTypeBox = new JList();

    final JScrollPane similarityAlgorithmTypeBoxPanel = buildJListPanel(similarityAlgorithmList,
            similarityAlgorithmTypeBox);

    onlyTitration = new JCheckBox("Only with titration");
    queryConditionPanel2.add(tissueTypeBoxPanel);
    queryConditionPanel2.add(cellLineBoxPanel);
    queryConditionPanel2.add(drug1BoxPanel);
    queryConditionPanel2.add(drug2BoxPanel);
    queryConditionPanel2.add(assayTypeBoxPanel);
    queryConditionPanel2.add(synergyMeasuremetnTypeBoxPanel);
    queryConditionPanel2.add(onlyTitration);

    // dynamic dependency parts
    tissueTypeBox.addListSelectionListener(new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent e) {

            if (e.getValueIsAdjusting()) {
                List<String> selectedTissueList = getSelectedValues(tissueTypeBox);
                List<String> cellLineDataList = null;
                List<String> drug1DataList = null;
                try {

                    cellLineDataList = addAll(lincs.getAllCellLineNamesForTissueTypes(selectedTissueList));

                    if (experimental.isSelected() == true)
                        drug1DataList = addAll(
                                lincs.getCompound1NamesFromExperimental(selectedTissueList, null));
                    else
                        drug1DataList = addAll(
                                lincs.getCompound1NamesFromComputational(selectedTissueList, null));

                } catch (Exception ex) {
                    log.error(ex.getMessage());
                }

                if (tissueTypeBox.getSelectedValues() != null && tissueTypeBox.getSelectedValues().length > 0)
                    cellLineBox.setModel(new LincsListModel(cellLineDataList));
                else
                    cellLineBox.setModel(new LincsListModel(null));
                cellLineBox.setEnabled(true);
                cellLineBox.clearSelection();
                drug1Box.removeAllItems();
                for (int i = 0; i < drug1DataList.size(); i++)
                    drug1Box.addItem(drug1DataList.get(i));
                drug1Box.clearSelection();
                drug2Box.clearSelection();
                drug2Box.setModel(new LincsListModel(null));
                drug2Box.setEnabled(false);
                cellLineBox.ensureIndexIsVisible(0);
                drug1Box.ensureIndexIsVisible(0);

            }
        }

    });

    // dynamic dependency parts
    cellLineBox.addListSelectionListener(new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent e) {
            if (e.getValueIsAdjusting()) {
                List<String> selectedTissueList = getSelectedValues(tissueTypeBox);
                List<String> selectedCellLineList = getSelectedValues(cellLineBox);

                List<String> drug1DataList = null;
                try {
                    if (experimental.isSelected() == true)
                        drug1DataList = addAll(lincs.getCompound1NamesFromExperimental(selectedTissueList,
                                selectedCellLineList));
                    else
                        drug1DataList = addAll(lincs.getCompound1NamesFromComputational(selectedTissueList,
                                selectedCellLineList));
                } catch (Exception ex) {
                    log.error(ex.getMessage());
                }
                drug1Box.removeAllItems();
                for (int i = 0; i < drug1DataList.size(); i++)
                    drug1Box.addItem(drug1DataList.get(i));
                drug1Box.ensureIndexIsVisible(0);
                drug1Box.clearSelection();
                drug2Box.clearSelection();
                drug2Box.setModel(new LincsListModel(null));
                drug2Box.setEnabled(false);
            }
        }

    });

    // dynamic dependency parts
    drug1Box.addListSelectionListener(new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent e) {
            if (e.getValueIsAdjusting()) {
                List<String> selectedTissueList = getSelectedValues(tissueTypeBox);
                List<String> selectedCellLineList = getSelectedValues(cellLineBox);
                List<String> selectedDrug1List = getSelectedValues(drug1Box);

                List<String> drug2DataList = null;
                try {

                    if (experimental.isSelected() == true)
                        drug2DataList = addAll(lincs.getCompound2NamesFromExperimental(selectedTissueList,
                                selectedCellLineList, selectedDrug1List));
                    else
                        drug2DataList = addAll(lincs.getCompound2NamesFromComputational(selectedTissueList,
                                selectedCellLineList, selectedDrug1List));

                } catch (Exception ex) {
                    log.error(ex.getMessage());
                }
                if (drug1Box.getSelectedValues() != null && drug1Box.getSelectedValues().length > 0)
                    drug2Box.setModel(new LincsListModel(drug2DataList));
                else
                    drug2Box.setModel(new LincsListModel(null));
                drug2Box.setEnabled(true);
                drug2Box.ensureIndexIsVisible(0);
            }
        }

    });

    maxResult = new JCheckBox("Max results");
    maxResultNumber = new JTextField("10", 10);
    searchButton = new JButton("Search");
    resetButton = new JButton("Reset");
    colorGradient = new JCheckBox("Color gradient for Score");
    queryCommandPanel.add(maxResult);
    queryCommandPanel.add(maxResultNumber);
    queryCommandPanel.add(searchButton);
    queryCommandPanel.add(resetButton);
    queryCommandPanel.add(colorGradient);
    resultTable = new TableViewer(experimentalColumnNames, null, hideColumnList);
    add(resultTable);
    add(resultProcessingPanel);
    queryResultPanel.setLayout(new BorderLayout());
    // queryResultPanel.add(new JScrollPane(resultTable),
    // BorderLayout.CENTER);

    plotOptions = new JComboBox(new String[] { HEATMAP, NETWORK });
    JButton plotButton = new JButton("Plot");
    final JCheckBox limitNetwork = new JCheckBox("Limit network to multiply-connected pairs");
    limitNetwork.setEnabled(false);
    limitNetwork.setVisible(false);
    JButton exportButton = new JButton("Export");
    exportButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent e) {
            List<String> hideColumns = new ArrayList<String>();
            hideColumns.add("Include");
            TableViewer.export(resultTable.getTable(), hideColumns, resultTable);
        }
    });

    resultProcessingPanel.add(new JLabel("Plot options:"));
    resultProcessingPanel.add(plotOptions);
    resultProcessingPanel.add(plotButton);
    resultProcessingPanel.add(limitNetwork);
    resultProcessingPanel.add(exportButton);

    plotOptions.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

            if (plotOptions.getSelectedItem().toString().equals(HEATMAP)) {
                limitNetwork.setEnabled(false);
            } else if (plotOptions.getSelectedItem().toString().equals(NETWORK)) {
                limitNetwork.setEnabled(true);
            }
        }
    });
    plotButton.addActionListener(plotListener);

    colorGradient.addActionListener(colorGradientListener);
    computational.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            queryConditionPanel1.remove(blankLabel);
            queryConditionPanel1.remove(assayTypeLabel);
            queryConditionPanel1.remove(synergyMeasurementLabel);
            queryConditionPanel2.remove(assayTypeBoxPanel);
            queryConditionPanel2.remove(synergyMeasuremetnTypeBoxPanel);
            queryConditionPanel1.add(similarityAlgorithmLabel, 10);
            queryConditionPanel2.add(similarityAlgorithmTypeBoxPanel, 4);

            queryConditionPanel1.updateUI();
            queryConditionPanel2.updateUI();
            onlyTitration.setEnabled(false);
            reset();

        }
    });

    experimental.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            queryConditionPanel1.remove(similarityAlgorithmLabel);
            queryConditionPanel2.remove(similarityAlgorithmTypeBoxPanel);
            queryConditionPanel1.add(blankLabel, 6);
            queryConditionPanel1.add(assayTypeLabel, 11);
            queryConditionPanel1.add(synergyMeasurementLabel, 12);
            queryConditionPanel2.add(assayTypeBoxPanel, 4);
            queryConditionPanel2.add(synergyMeasuremetnTypeBoxPanel, 5);
            queryConditionPanel1.updateUI();
            queryConditionPanel2.updateUI();
            onlyTitration.setEnabled(true);
            reset();
        }
    });

    searchButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {

            int rowLimit = 0;

            List<String> tissueTypes = getSelectedValues(tissueTypeBox);
            List<String> cellLineNames = getSelectedValues(cellLineBox);
            List<String> drug1Names = getSelectedValues(drug1Box);
            List<String> drug2Names = getSelectedValues(drug2Box);

            if (maxResult.isSelected()) {
                try {
                    rowLimit = new Integer(maxResultNumber.getText().trim()).intValue();
                } catch (NumberFormatException nbe) {
                    JOptionPane.showMessageDialog(null, "Please enter a number.");
                    maxResultNumber.requestFocus();
                    return;
                }
            }

            if ((drug1Names == null || drug1Names.isEmpty()) && (drug2Names == null || drug2Names.isEmpty())) {

                JOptionPane.showMessageDialog(null,
                        "Please select at least one drug constraint, multiple drugs can be selected.");
                return;

            }

            AbstractAnalysis selectedAnalysis = new LincsSearchAnalysis();
            String dataSetName = null;
            if (experimental.isSelected()) {
                selectedAnalysis.setLabel("LINCS Experimental Query");
                dataSetName = "LINCS Data";
            } else {
                selectedAnalysis.setLabel("LINCS Computational Query");
                dataSetName = "LINCS Data";
            }
            final AnalysisInvokedEvent invokeEvent = new AnalysisInvokedEvent(selectedAnalysis, dataSetName);
            publishAnalysisInvokedEvent(invokeEvent);

            try {

                if (experimental.isSelected()) {
                    List<String> assayTypes = getSelectedValues(assayTypeBox);
                    List<String> measurementTypes = getSelectedValues(synergyMeasurementTypeBox);
                    List<ExperimentalData> dataList = lincs.getExperimentalData(tissueTypes, cellLineNames,
                            drug1Names, drug2Names, measurementTypes, assayTypes, onlyTitration.isSelected(),
                            rowLimit);
                    Object[][] objects = convertExperimentalData(dataList);
                    updateResultTable(objects);
                } else {
                    List<String> similarityAlgorithmTypes = getSelectedValues(similarityAlgorithmTypeBox);

                    List<ComputationalData> dataList = lincs.getComputationalData(tissueTypes, cellLineNames,
                            drug1Names, drug2Names, similarityAlgorithmTypes, rowLimit);
                    Object[][] objects = convertComputationalData(dataList);
                    updateResultTable(objects);

                }

                publishAnalysisCompleteEvent(new AnalysisCompleteEvent(invokeEvent));

            } catch (Exception ex) {
                log.error(ex.getMessage());
                publishAnalysisAbortEvent(new AnalysisAbortEvent(invokeEvent));
            }

            if (resultTable.getData() == null || resultTable.getData().length == 0) {
                JOptionPane.showMessageDialog(null, "There is no row in the database for your query.",
                        "Empty Set", JOptionPane.INFORMATION_MESSAGE);
                return;
            }
            freeVariables = getFreeVariables();

        }

    });

    resetButton.addActionListener(new ActionListener() {

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

    });

}