Search in sources :

Example 16 with ItemEvent

use of java.awt.event.ItemEvent in project azure-tools-for-java by Microsoft.

the class SparkSubmissionContentPanel method addSparkClustersLineItem.

private void addSparkClustersLineItem() {
    JLabel sparkClusterLabel = new JLabel("Spark clusters(Linux only)");
    sparkClusterLabel.setToolTipText("The HDInsight Spark cluster you want to submit your application to. Only Linux cluster is supported.");
    GridBagConstraints c11 = new GridBagConstraints();
    c11.gridx = 0;
    c11.gridy = 0;
    c11.insets = new Insets(margin, margin, 0, margin);
    add(sparkClusterLabel, new GridBagConstraints(0, displayLayoutCurrentRow, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(margin, margin, 0, margin), 0, 0));
    clustersListComboBox = new ComboboxWithBrowseButton();
    clustersListComboBox.setButtonIcon(StreamUtil.getImageResourceFile(REFRESH_BUTTON_PATH));
    clustersListComboBox.getButton().setToolTipText("Refresh");
    clustersListComboBox.getButton().addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            Cursor cursor = getCursor();
            setCursor(new Cursor(Cursor.WAIT_CURSOR));
            List<IClusterDetail> clusterDetails = ClusterManagerEx.getInstance().getClusterDetails(submitModel.getProject());
            setCursor(cursor);
            submitModel.setClusterComboBoxModel(clusterDetails);
        }
    });
    clustersListComboBox.getComboBox().setToolTipText("The HDInsight Spark cluster you want to submit your application to. Only Linux cluster is supported.");
    clustersListComboBox.getComboBox().addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName() == "model" && evt.getNewValue() instanceof DefaultComboBoxModel) {
                int size = ((DefaultComboBoxModel) evt.getNewValue()).getSize();
                setVisibleForFixedErrorMessageLabel(ErrorMessageLabelTag.ClusterName.ordinal(), size <= 0);
            }
        }
    });
    add(clustersListComboBox, new GridBagConstraints(1, displayLayoutCurrentRow, 0, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(margin, margin, 0, margin), 0, 0));
    errorMessageLabels[ErrorMessageLabelTag.ClusterName.ordinal()] = new JLabel("Cluster Name Should not be null");
    errorMessageLabels[ErrorMessageLabelTag.ClusterName.ordinal()].setForeground(DarkThemeManager.getInstance().getErrorMessageColor());
    clustersListComboBox.getComboBox().addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            setVisibleForFixedErrorMessageLabel(0, clustersListComboBox.getComboBox().getItemCount() == 0);
        }
    });
    add(errorMessageLabels[ErrorMessageLabelTag.ClusterName.ordinal()], new GridBagConstraints(1, ++displayLayoutCurrentRow, 0, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, margin, 0, 0), 0, 0));
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) ItemEvent(java.awt.event.ItemEvent) PropertyChangeListener(java.beans.PropertyChangeListener) ActionEvent(java.awt.event.ActionEvent) ActionListener(java.awt.event.ActionListener) ComboboxWithBrowseButton(com.intellij.ui.ComboboxWithBrowseButton) ArrayList(java.util.ArrayList) List(java.util.List) ItemListener(java.awt.event.ItemListener)

Example 17 with ItemEvent

use of java.awt.event.ItemEvent in project azure-tools-for-java by Microsoft.

the class SparkSubmissionContentPanel method addSelectedArtifactLineItem.

private void addSelectedArtifactLineItem() {
    final String tipInfo = "The Artifact you want to use.";
    JLabel artifactSelectLabel = new JLabel("Select an Artifact to submit");
    artifactSelectLabel.setToolTipText(tipInfo);
    selectedArtifactComboBox = new ComboBox();
    selectedArtifactComboBox.setToolTipText(tipInfo);
    errorMessageLabels[ErrorMessageLabelTag.SystemArtifact.ordinal()] = new JLabel("Artifact should not be null!");
    errorMessageLabels[ErrorMessageLabelTag.SystemArtifact.ordinal()].setForeground(DarkThemeManager.getInstance().getErrorMessageColor());
    errorMessageLabels[ErrorMessageLabelTag.SystemArtifact.ordinal()].setVisible(false);
    errorMessageLabels[ErrorMessageLabelTag.LocalArtifact.ordinal()] = new JLabel("Could not find the local jar package for Artifact");
    errorMessageLabels[ErrorMessageLabelTag.LocalArtifact.ordinal()].setForeground(DarkThemeManager.getInstance().getErrorMessageColor());
    errorMessageLabels[ErrorMessageLabelTag.LocalArtifact.ordinal()].setVisible(false);
    selectedArtifactTextField = new TextFieldWithBrowseButton();
    selectedArtifactTextField.setToolTipText("Artifact from local jar package.");
    selectedArtifactTextField.setEditable(true);
    selectedArtifactTextField.setEnabled(false);
    selectedArtifactTextField.getTextField().getDocument().addDocumentListener(new DocumentListener() {

        @Override
        public void insertUpdate(DocumentEvent e) {
            setVisibleForFixedErrorMessageLabel(2, !SparkSubmitHelper.isLocalArtifactPath(selectedArtifactTextField.getText()));
        }

        @Override
        public void removeUpdate(DocumentEvent e) {
            setVisibleForFixedErrorMessageLabel(2, !SparkSubmitHelper.isLocalArtifactPath(selectedArtifactTextField.getText()));
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            setVisibleForFixedErrorMessageLabel(2, !SparkSubmitHelper.isLocalArtifactPath(selectedArtifactTextField.getText()));
        }
    });
    selectedArtifactTextField.getButton().addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            FileChooserDescriptor chooserDescriptor = new FileChooserDescriptor(false, false, true, false, true, false);
            chooserDescriptor.setTitle("Select Local Artifact File");
            VirtualFile chooseFile = FileChooser.chooseFile(chooserDescriptor, null, null);
            if (chooseFile != null) {
                String path = chooseFile.getPath();
                if (path.endsWith("!/")) {
                    path = path.substring(0, path.length() - 2);
                }
                selectedArtifactTextField.setText(path);
            }
        }
    });
    intelliJArtifactRadioButton = new JRadioButton("Artifact from IntelliJ project:", true);
    localArtifactRadioButton = new JRadioButton("Artifact from local disk:", false);
    intelliJArtifactRadioButton.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                selectedArtifactComboBox.setEnabled(true);
                selectedArtifactTextField.setEnabled(false);
                mainClassTextField.setButtonEnabled(true);
                setVisibleForFixedErrorMessageLabel(2, false);
                if (selectedArtifactComboBox.getItemCount() == 0) {
                    setVisibleForFixedErrorMessageLabel(2, true);
                }
            }
        }
    });
    localArtifactRadioButton.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                selectedArtifactComboBox.setEnabled(false);
                selectedArtifactTextField.setEnabled(true);
                mainClassTextField.setButtonEnabled(false);
                setVisibleForFixedErrorMessageLabel(1, false);
                if (StringHelper.isNullOrWhiteSpace(selectedArtifactTextField.getText())) {
                    setVisibleForFixedErrorMessageLabel(2, true);
                }
            }
        }
    });
    ButtonGroup group = new ButtonGroup();
    group.add(intelliJArtifactRadioButton);
    group.add(localArtifactRadioButton);
    intelliJArtifactRadioButton.setSelected(true);
    add(artifactSelectLabel, new GridBagConstraints(0, ++displayLayoutCurrentRow, 0, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(margin, margin, 0, margin), 0, 0));
    add(intelliJArtifactRadioButton, new GridBagConstraints(0, ++displayLayoutCurrentRow, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(margin / 3, margin * 3, 0, margin), 0, 0));
    add(selectedArtifactComboBox, new GridBagConstraints(1, displayLayoutCurrentRow, 0, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(margin / 3, margin, 0, margin), 0, 0));
    add(errorMessageLabels[ErrorMessageLabelTag.SystemArtifact.ordinal()], new GridBagConstraints(1, ++displayLayoutCurrentRow, 0, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, margin, 0, 0), 0, 0));
    add(localArtifactRadioButton, new GridBagConstraints(0, ++displayLayoutCurrentRow, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(margin / 3, margin * 3, 0, margin), 0, 0));
    add(selectedArtifactTextField, new GridBagConstraints(1, displayLayoutCurrentRow, 0, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(margin / 3, margin, 0, margin), 0, 0));
    add(errorMessageLabels[ErrorMessageLabelTag.LocalArtifact.ordinal()], new GridBagConstraints(1, ++displayLayoutCurrentRow, 0, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, margin, 0, 0), 0, 0));
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) DocumentListener(javax.swing.event.DocumentListener) ItemEvent(java.awt.event.ItemEvent) ComboBox(com.intellij.openapi.ui.ComboBox) ActionEvent(java.awt.event.ActionEvent) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) DocumentEvent(javax.swing.event.DocumentEvent) TextFieldWithBrowseButton(com.intellij.openapi.ui.TextFieldWithBrowseButton) ActionListener(java.awt.event.ActionListener) ItemListener(java.awt.event.ItemListener)

Example 18 with ItemEvent

use of java.awt.event.ItemEvent in project intellij-community by JetBrains.

the class AbstractCustomizeWizardStep method createBigButtonPanel.

protected static JPanel createBigButtonPanel(LayoutManager layout, final JToggleButton anchorButton, final Runnable action) {
    final JPanel panel = new JPanel(layout) {

        @Override
        public Color getBackground() {
            return anchorButton.isSelected() ? getSelectionBackground() : super.getBackground();
        }
    };
    panel.setOpaque(anchorButton.isSelected());
    new ClickListener() {

        @Override
        public boolean onClick(@NotNull MouseEvent event, int clickCount) {
            anchorButton.setSelected(true);
            return true;
        }
    }.installOn(panel);
    anchorButton.addItemListener(new ItemListener() {

        boolean curState = anchorButton.isSelected();

        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED && curState != anchorButton.isSelected()) {
                action.run();
            }
            curState = anchorButton.isSelected();
            panel.setOpaque(curState);
            panel.repaint();
        }
    });
    return panel;
}
Also used : ItemEvent(java.awt.event.ItemEvent) MouseEvent(java.awt.event.MouseEvent) ItemListener(java.awt.event.ItemListener) ClickListener(com.intellij.ui.ClickListener)

Example 19 with ItemEvent

use of java.awt.event.ItemEvent in project intellij-community by JetBrains.

the class SearchDialog method buildOptions.

protected void buildOptions(JPanel searchOptions) {
    recursiveMatching = new JCheckBox(SSRBundle.message("recursive.matching.checkbox"), true);
    if (isRecursiveSearchEnabled()) {
        searchOptions.add(UIUtil.createOptionLine(recursiveMatching));
    }
    caseSensitiveMatch = new JCheckBox(FindBundle.message("find.options.case.sensitive"), true);
    searchOptions.add(UIUtil.createOptionLine(caseSensitiveMatch));
    final List<FileType> types = new ArrayList<>();
    for (FileType fileType : StructuralSearchUtil.getSuitableFileTypes()) {
        if (StructuralSearchUtil.getProfileByFileType(fileType) != null) {
            types.add(fileType);
        }
    }
    Collections.sort(types, (o1, o2) -> o1.getName().compareToIgnoreCase(o2.getName()));
    final DefaultComboBoxModel<FileType> comboBoxModel = new DefaultComboBoxModel<>(types.toArray(new FileType[types.size()]));
    fileTypes = new ComboBox<>(comboBoxModel);
    fileTypes.setRenderer(new FileTypeRenderer());
    new ComboboxSpeedSearch(fileTypes) {

        @Override
        protected String getElementText(Object element) {
            return ((FileType) element).getName();
        }
    };
    contexts = new ComboBox<>();
    contexts.setPreferredSize(new Dimension(60, -1));
    dialects = new ComboBox<>();
    dialects.setRenderer(new ListCellRendererWrapper<Language>() {

        @Override
        public void customize(JList list, Language value, int index, boolean selected, boolean hasFocus) {
            if (value == null) {
                setText("None");
            } else {
                setText(value.getDisplayName());
            }
        }
    });
    dialects.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            updateEditor();
        }
    });
    new ComboboxSpeedSearch(dialects);
    dialects.setPreferredSize(new Dimension(120, -1));
    final JLabel jLabel = new JLabel(SSRBundle.message("search.dialog.file.type.label"));
    final JLabel jLabel2 = new JLabel(SSRBundle.message("search.dialog.context.label"));
    final JLabel jLabel3 = new JLabel(SSRBundle.message("search.dialog.file.dialect.label"));
    searchOptions.add(UIUtil.createOptionLine(new JComponent[] { jLabel, fileTypes, (JComponent) Box.createHorizontalStrut(8), jLabel2, contexts, (JComponent) Box.createHorizontalStrut(8), jLabel3, dialects }));
    jLabel.setLabelFor(fileTypes);
    jLabel2.setLabelFor(contexts);
    jLabel3.setLabelFor(dialects);
    detectFileTypeAndDialect();
    fileTypes.setSelectedItem(ourFtSearchVariant);
    fileTypes.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                updateDialectsAndContexts();
                updateEditor();
                initiateValidation();
            }
        }
    });
    dialects.setSelectedItem(ourDialect);
    contexts.setSelectedItem(ourContext);
    updateDialectsAndContexts();
}
Also used : ItemEvent(java.awt.event.ItemEvent) Language(com.intellij.lang.Language) FileType(com.intellij.openapi.fileTypes.FileType) LanguageFileType(com.intellij.openapi.fileTypes.LanguageFileType) FileTypeRenderer(com.intellij.openapi.fileTypes.impl.FileTypeRenderer) ItemListener(java.awt.event.ItemListener) ComboboxSpeedSearch(com.intellij.ui.ComboboxSpeedSearch)

Example 20 with ItemEvent

use of java.awt.event.ItemEvent in project intellij-community by JetBrains.

the class XSuspendPolicyPanel method init.

@Override
public void init(Project project, final XBreakpointManager breakpointManager, @NotNull XBreakpointBase breakpoint) {
    super.init(project, breakpointManager, breakpoint);
    mySuspendCheckBox.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            boolean selected = mySuspendCheckBox.isSelected();
            if (myBreakpoint.getType().isSuspendThreadSupported()) {
                changeEnableState(selected);
            }
            if (myDelegate != null && !selected) {
                myDelegate.showMoreOptionsIfNeeded();
            }
        }
    });
    if (!myBreakpoint.getType().isSuspendThreadSupported()) {
        return;
    }
    updateSuspendPolicyFont();
    ItemListener suspendPolicyChangeListener = new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            updateMakeDefaultEnableState();
        }
    };
    updateMakeDefaultEnableState();
    mySuspendAll.addItemListener(suspendPolicyChangeListener);
    mySuspendThread.addItemListener(suspendPolicyChangeListener);
    myMakeDefaultButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            SuspendPolicy suspendPolicy = getSelectedSuspendPolicy();
            ((XBreakpointManagerImpl) myBreakpointManager).getBreakpointDefaults(myBreakpointType).setSuspendPolicy(suspendPolicy);
            updateSuspendPolicyFont();
            if (SuspendPolicy.THREAD == suspendPolicy) {
                IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> {
                    IdeFocusManager.getGlobalInstance().requestFocus(mySuspendThread, true);
                });
            } else {
                IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> {
                    IdeFocusManager.getGlobalInstance().requestFocus(mySuspendAll, true);
                });
            }
            myMakeDefaultButton.setEnabled(false);
        }
    });
}
Also used : ItemEvent(java.awt.event.ItemEvent) SuspendPolicy(com.intellij.xdebugger.breakpoints.SuspendPolicy) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) ItemListener(java.awt.event.ItemListener) XBreakpointManagerImpl(com.intellij.xdebugger.impl.breakpoints.XBreakpointManagerImpl)

Aggregations

ItemEvent (java.awt.event.ItemEvent)346 ItemListener (java.awt.event.ItemListener)320 ActionEvent (java.awt.event.ActionEvent)124 ActionListener (java.awt.event.ActionListener)114 JPanel (javax.swing.JPanel)106 JLabel (javax.swing.JLabel)84 JCheckBox (javax.swing.JCheckBox)74 JComboBox (javax.swing.JComboBox)65 Dimension (java.awt.Dimension)59 JButton (javax.swing.JButton)53 BorderLayout (java.awt.BorderLayout)48 JTextField (javax.swing.JTextField)46 ButtonGroup (javax.swing.ButtonGroup)35 JCheckBoxMenuItem (javax.swing.JCheckBoxMenuItem)33 ChangeEvent (javax.swing.event.ChangeEvent)32 ChangeListener (javax.swing.event.ChangeListener)31 GridLayout (java.awt.GridLayout)30 GridBagConstraints (java.awt.GridBagConstraints)29 JMenu (javax.swing.JMenu)29 GridBagLayout (java.awt.GridBagLayout)28