Search in sources :

Example 16 with ItemListener

use of java.awt.event.ItemListener 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 17 with ItemListener

use of java.awt.event.ItemListener 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 18 with ItemListener

use of java.awt.event.ItemListener 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 19 with ItemListener

use of java.awt.event.ItemListener 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)

Example 20 with ItemListener

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

the class IntroduceVariableDialog method createCenterPanel.

protected JComponent createCenterPanel() {
    JPanel panel = new JPanel(new GridBagLayout());
    GridBagConstraints gbConstraints = new GridBagConstraints();
    gbConstraints.fill = GridBagConstraints.HORIZONTAL;
    gbConstraints.weightx = 1;
    gbConstraints.weighty = 0;
    gbConstraints.gridwidth = 1;
    gbConstraints.gridx = 0;
    gbConstraints.gridy = 0;
    gbConstraints.insets = JBUI.emptyInsets();
    if (myOccurrencesCount > 1) {
        myCbReplaceAll = new NonFocusableCheckBox();
        myCbReplaceAll.setText(RefactoringBundle.message("replace.all.occurences", myOccurrencesCount));
        panel.add(myCbReplaceAll, gbConstraints);
        myReplaceAllListener = new ItemListener() {

            public void itemStateChanged(ItemEvent e) {
                updateControls();
            }
        };
        myCbReplaceAll.addItemListener(myReplaceAllListener);
        if (myAnyLValueOccurences) {
            myCbReplaceWrite = new StateRestoringCheckBox();
            myCbReplaceWrite.setText(RefactoringBundle.message("replace.write.access.occurrences"));
            gbConstraints.insets = JBUI.insetsLeft(8);
            gbConstraints.gridy++;
            panel.add(myCbReplaceWrite, gbConstraints);
            myCbReplaceWrite.addItemListener(myReplaceAllListener);
        }
    }
    myCbFinal = new NonFocusableCheckBox();
    myCbFinal.setText(RefactoringBundle.message("declare.final"));
    final Boolean createFinals = JavaRefactoringSettings.getInstance().INTRODUCE_LOCAL_CREATE_FINALS;
    myCbFinalState = createFinals == null ? CodeStyleSettingsManager.getSettings(myProject).GENERATE_FINAL_LOCALS : createFinals.booleanValue();
    gbConstraints.insets = JBUI.emptyInsets();
    gbConstraints.gridy++;
    panel.add(myCbFinal, gbConstraints);
    myFinalListener = new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            if (myCbFinal.isEnabled()) {
                myCbFinalState = myCbFinal.isSelected();
            }
        }
    };
    myCbFinal.addItemListener(myFinalListener);
    updateControls();
    return panel;
}
Also used : ItemEvent(java.awt.event.ItemEvent) StateRestoringCheckBox(com.intellij.ui.StateRestoringCheckBox) NonFocusableCheckBox(com.intellij.ui.NonFocusableCheckBox) ItemListener(java.awt.event.ItemListener)

Aggregations

ItemListener (java.awt.event.ItemListener)331 ItemEvent (java.awt.event.ItemEvent)314 ActionEvent (java.awt.event.ActionEvent)111 ActionListener (java.awt.event.ActionListener)108 JPanel (javax.swing.JPanel)93 JLabel (javax.swing.JLabel)81 JCheckBox (javax.swing.JCheckBox)65 JComboBox (javax.swing.JComboBox)64 JButton (javax.swing.JButton)51 Dimension (java.awt.Dimension)50 BorderLayout (java.awt.BorderLayout)47 JTextField (javax.swing.JTextField)46 ButtonGroup (javax.swing.ButtonGroup)34 JCheckBoxMenuItem (javax.swing.JCheckBoxMenuItem)33 GridBagConstraints (java.awt.GridBagConstraints)29 JMenu (javax.swing.JMenu)29 ChangeEvent (javax.swing.event.ChangeEvent)29 GridBagLayout (java.awt.GridBagLayout)28 JMenuItem (javax.swing.JMenuItem)28 ChangeListener (javax.swing.event.ChangeListener)28