Search in sources :

Example 6 with ItemEvent

use of java.awt.event.ItemEvent in project kotlin by JetBrains.

the class MoveKotlinNestedClassesToUpperLevelDialog method init.

@Override
protected void init() {
    classNameField.setText(innerClass.getName());
    classNameField.selectAll();
    if (innerClass instanceof KtClass && ((KtClass) innerClass).isInner()) {
        passOuterClassCheckBox.setSelected(true);
        passOuterClassCheckBox.addItemListener(new ItemListener() {

            @Override
            public void itemStateChanged(ItemEvent e) {
                parameterField.setEnabled(passOuterClassCheckBox.isSelected());
            }
        });
    } else {
        passOuterClassCheckBox.setSelected(false);
        passOuterClassCheckBox.setEnabled(false);
        parameterField.setEnabled(false);
    }
    if (passOuterClassCheckBox.isEnabled()) {
        boolean thisNeeded = isThisNeeded();
        passOuterClassCheckBox.setSelected(thisNeeded);
        parameterField.setEnabled(thisNeeded);
    }
    passOuterClassCheckBox.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            boolean selected = passOuterClassCheckBox.isSelected();
            parameterField.getComponent().setEnabled(selected);
        }
    });
    if (!(targetContainer instanceof PsiDirectory)) {
        packageNameField.setVisible(false);
        packageNameLabel.setVisible(false);
    }
    if (innerClass instanceof KtClass && ((KtClass) innerClass).isInner()) {
        KtClassBody innerClassBody = innerClass.getBody();
        Function1<String, Boolean> validator = innerClassBody != null ? new NewDeclarationNameValidator(innerClassBody, (PsiElement) null, NewDeclarationNameValidator.Target.VARIABLES, Collections.<KtDeclaration>emptyList()) : new CollectingNameValidator();
        List<String> suggestions = KotlinNameSuggester.INSTANCE.suggestNamesByType(getOuterInstanceType(), validator, "outer");
        parameterField.setSuggestions(ArrayUtil.toStringArray(suggestions));
    } else {
        parameterField.getComponent().setEnabled(false);
    }
    FqName packageFqName = getTargetPackageFqName();
    if (packageFqName != null) {
        packageNameField.prependItem(packageFqName.asString());
    }
    KotlinRefactoringSettings settings = KotlinRefactoringSettings.getInstance();
    searchForTextOccurrencesCheckBox.setSelected(settings.MOVE_TO_UPPER_LEVEL_SEARCH_FOR_TEXT);
    searchInCommentsCheckBox.setSelected(settings.MOVE_TO_UPPER_LEVEL_SEARCH_IN_COMMENTS);
    super.init();
}
Also used : ItemEvent(java.awt.event.ItemEvent) FqName(org.jetbrains.kotlin.name.FqName) CollectingNameValidator(org.jetbrains.kotlin.idea.core.CollectingNameValidator) NewDeclarationNameValidator(org.jetbrains.kotlin.idea.core.NewDeclarationNameValidator) KotlinRefactoringSettings(org.jetbrains.kotlin.idea.refactoring.KotlinRefactoringSettings) ItemListener(java.awt.event.ItemListener)

Example 7 with ItemEvent

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

the class RepositoryLibraryPropertiesEditor method initVersionsPanel.

private void initVersionsPanel() {
    final int selection = getSelection(model.getVersion(), versions);
    CollectionComboBoxModel<String> versionSelectorModel = new CollectionComboBoxModel<>(versions);
    //noinspection unchecked
    versionSelector.setModel(versionSelectorModel);
    versionSelector.setSelectedIndex(selection);
    setState(State.Loaded);
    initVersionKindSelector();
    versionSelector.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            model.setVersion(getSelectedVersion());
            onChangeListener.onChange(RepositoryLibraryPropertiesEditor.this);
        }
    });
    downloadSourcesCheckBox.setSelected(model.isDownloadSources());
    downloadSourcesCheckBox.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            model.setDownloadSources(downloadSourcesCheckBox.isSelected());
            onChangeListener.onChange(RepositoryLibraryPropertiesEditor.this);
        }
    });
    downloadJavaDocsCheckBox.setSelected(model.isDownloadJavaDocs());
    downloadJavaDocsCheckBox.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            model.setDownloadJavaDocs(downloadJavaDocsCheckBox.isSelected());
            onChangeListener.onChange(RepositoryLibraryPropertiesEditor.this);
        }
    });
}
Also used : ItemEvent(java.awt.event.ItemEvent) ChangeEvent(javax.swing.event.ChangeEvent) CollectionComboBoxModel(com.intellij.ui.CollectionComboBoxModel) ItemListener(java.awt.event.ItemListener) ChangeListener(javax.swing.event.ChangeListener)

Example 8 with ItemEvent

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

the class SelectMavenProjectDialog method createCenterPanel.

protected JComponent createCenterPanel() {
    ComboBoxUtil.setModel(myMavenProjectsComboBox, new DefaultComboBoxModel(), myMavenDomProjectModels, model -> {
        String projectName = model.getName().getStringValue();
        MavenProject mavenProject = MavenDomUtil.findProject(model);
        if (mavenProject != null) {
            projectName = mavenProject.getDisplayName();
        }
        if (StringUtil.isEmptyOrSpaces(projectName)) {
            projectName = "pom.xml";
        }
        return Pair.create(projectName, model);
    });
    myReplaceAllListener = new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            updateControls();
        }
    };
    myMavenProjectsComboBox.addItemListener(myReplaceAllListener);
    myMavenProjectsComboBox.setSelectedItem(0);
    myReplaceAllCheckBox.setVisible(myHasUsagesInProjects);
    myExtractExclusions.setVisible(myHasExclusions);
    updateControls();
    return myMainPanel;
}
Also used : ItemEvent(java.awt.event.ItemEvent) MavenProject(org.jetbrains.idea.maven.project.MavenProject) ItemListener(java.awt.event.ItemListener)

Example 9 with ItemEvent

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

the class EvalExpressionDialog method init.

protected void init() {
    final ToolWindow findWindow = ToolWindowManager.getInstance(myProject).getToolWindow(ToolWindowId.FIND);
    final boolean available = findWindow != null && findWindow.isAvailable();
    myForm.getNewTabCheckbox().setEnabled(available);
    myForm.getNewTabCheckbox().setSelected(FindSettings.getInstance().isShowResultsInSeparateView());
    myForm.getHighlightCheckbox().setSelected(mySettings.HIGHLIGHT_RESULTS);
    myForm.getHighlightCheckbox().addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            updateOkAction();
        }
    });
    myForm.getUsageViewCheckbox().setSelected(mySettings.SHOW_USAGE_VIEW);
    myForm.getUsageViewCheckbox().addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            myForm.getNewTabCheckbox().setEnabled(available && myForm.getUsageViewCheckbox().isSelected());
            updateOkAction();
        }
    });
    super.init();
}
Also used : ToolWindow(com.intellij.openapi.wm.ToolWindow) ItemEvent(java.awt.event.ItemEvent) ItemListener(java.awt.event.ItemListener)

Example 10 with ItemEvent

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

the class AddNamespaceDialog method addUpdateListener.

private void addUpdateListener(ComboBox comboBox) {
    final ComboBoxEditor boxEditor = comboBox.getEditor();
    if (boxEditor != null) {
        final Component component = boxEditor.getEditorComponent();
        if (component instanceof JTextField) {
            ((JTextField) component).getDocument().addDocumentListener(new DocumentAdapter() {

                protected void textChanged(DocumentEvent e) {
                    updateOkAction();
                }
            });
        }
    }
    comboBox.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            updateOkAction();
        }
    });
}
Also used : ItemEvent(java.awt.event.ItemEvent) DocumentAdapter(com.intellij.ui.DocumentAdapter) ItemListener(java.awt.event.ItemListener) DocumentEvent(javax.swing.event.DocumentEvent)

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