Search in sources :

Example 6 with NonFocusableCheckBox

use of com.intellij.ui.NonFocusableCheckBox in project intellij-community by JetBrains.

the class ExtractMethodDialog method createOptionsPanel.

protected JPanel createOptionsPanel() {
    final JPanel optionsPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 5));
    if (myStaticFlag || myCanBeStatic) {
        myMakeStatic.setEnabled(!myStaticFlag);
        myMakeStatic.setSelected(myStaticFlag);
        if (myVariableData.hasInstanceFields()) {
            myMakeStatic.setText(RefactoringBundle.message("declare.static.pass.fields.checkbox"));
        }
        myMakeStatic.addItemListener(e -> {
            if (myVariableData.hasInstanceFields()) {
                myVariableData.setPassFields(myMakeStatic.isSelected());
                myInputVariables = myVariableData.getInputVariables().toArray(new VariableData[myVariableData.getInputVariables().size()]);
                updateVarargsEnabled();
                createParametersPanel();
            }
            updateSignature();
        });
        optionsPanel.add(myMakeStatic);
    } else {
        myMakeStatic.setSelected(false);
        myMakeStatic.setEnabled(false);
    }
    final Border emptyBorder = IdeBorderFactory.createEmptyBorder(5, 0, 5, 4);
    myMakeStatic.setBorder(emptyBorder);
    myFoldParameters.setSelected(myVariableData.isFoldingSelectedByDefault());
    myFoldParameters.setVisible(myVariableData.isFoldable());
    myVariableData.setFoldingAvailable(myFoldParameters.isSelected());
    myInputVariables = myVariableData.getInputVariables().toArray(new VariableData[myVariableData.getInputVariables().size()]);
    myFoldParameters.addActionListener(e -> {
        myVariableData.setFoldingAvailable(myFoldParameters.isSelected());
        myInputVariables = myVariableData.getInputVariables().toArray(new VariableData[myVariableData.getInputVariables().size()]);
        updateVarargsEnabled();
        createParametersPanel();
        updateSignature();
    });
    optionsPanel.add(myFoldParameters);
    myFoldParameters.setBorder(emptyBorder);
    boolean canBeVarargs = false;
    for (VariableData data : myInputVariables) {
        canBeVarargs |= data.type instanceof PsiArrayType;
    }
    if (myVariableData.isFoldable()) {
        canBeVarargs |= myVariableData.isFoldingSelectedByDefault();
    }
    if (canBeVarargs) {
        myMakeVarargs = new NonFocusableCheckBox(RefactoringBundle.message("declare.varargs.checkbox"));
        myMakeVarargs.setBorder(emptyBorder);
        updateVarargsEnabled();
        myMakeVarargs.addItemListener(e -> updateSignature());
        myMakeVarargs.setSelected(false);
        optionsPanel.add(myMakeVarargs);
    }
    if (myNullness != null && myNullness != Nullness.UNKNOWN) {
        final boolean isSelected = PropertiesComponent.getInstance(myProject).getBoolean(EXTRACT_METHOD_GENERATE_ANNOTATIONS, true);
        myGenerateAnnotations = new JCheckBox(RefactoringBundle.message("declare.generated.annotations"), isSelected);
        myGenerateAnnotations.addItemListener(e -> updateSignature());
        optionsPanel.add(myGenerateAnnotations);
    }
    if (myCbChainedConstructor != null) {
        optionsPanel.add(myCbChainedConstructor);
        myCbChainedConstructor.setBorder(emptyBorder);
        myCbChainedConstructor.addItemListener(e -> {
            if (myDefaultVisibility) {
                myChangingVisibility = true;
                try {
                    if (isChainedConstructor()) {
                        myVisibilityPanel.setVisibility(VisibilityUtil.getVisibilityModifier(myTargetClass.getModifierList()));
                    } else {
                        myVisibilityPanel.setVisibility(PsiModifier.PRIVATE);
                    }
                } finally {
                    myChangingVisibility = false;
                }
            }
            update();
        });
    }
    return optionsPanel;
}
Also used : NonFocusableCheckBox(com.intellij.ui.NonFocusableCheckBox) VariableData(com.intellij.refactoring.util.VariableData) Border(javax.swing.border.Border)

Example 7 with NonFocusableCheckBox

use of com.intellij.ui.NonFocusableCheckBox in project intellij-community by JetBrains.

the class AnonymousToInnerDialog method createNorthPanel.

protected JComponent createNorthPanel() {
    myNameField = new NameSuggestionsField(myProject);
    FormBuilder formBuilder = FormBuilder.createFormBuilder().addLabeledComponent(RefactoringBundle.message("anonymousToInner.class.name.label.text"), myNameField);
    if (!myShowCanBeStatic) {
        myCbMakeStatic = new NonFocusableCheckBox(RefactoringBundle.message("anonymousToInner.make.class.static.checkbox.text"));
        myCbMakeStatic.setSelected(true);
        formBuilder.addComponent(myCbMakeStatic);
    }
    return formBuilder.getPanel();
}
Also used : FormBuilder(com.intellij.util.ui.FormBuilder) NonFocusableCheckBox(com.intellij.ui.NonFocusableCheckBox) NameSuggestionsField(com.intellij.refactoring.ui.NameSuggestionsField)

Example 8 with NonFocusableCheckBox

use of com.intellij.ui.NonFocusableCheckBox in project intellij-community by JetBrains.

the class IntroduceParameterSettingsUI method createRemoveParamsPanel.

protected void createRemoveParamsPanel(GridBagConstraints gbConstraints, JPanel panel) {
    final JCheckBox[] removeParamsCb = new JCheckBox[myParametersToRemove.length];
    for (int i = 0; i < myParametersToRemove.length; i++) {
        PsiParameter parameter = myParametersToRemove[i];
        if (parameter == null)
            continue;
        final NonFocusableCheckBox cb = new NonFocusableCheckBox(RefactoringBundle.message("remove.parameter.0.no.longer.used", parameter.getName()));
        removeParamsCb[i] = cb;
        cb.setSelected(true);
        gbConstraints.gridy++;
        panel.add(cb, gbConstraints);
        final int i1 = i;
        cb.addChangeListener(new ChangeListener() {

            @Override
            public void stateChanged(ChangeEvent e) {
                myParametersToRemoveChecked[i1] = cb.isSelected();
            }
        });
        myParametersToRemoveChecked[i] = true;
    }
    updateControls(removeParamsCb);
    if (myCbReplaceAllOccurences != null) {
        myCbReplaceAllOccurences.addItemListener(new ItemListener() {

            public void itemStateChanged(ItemEvent e) {
                updateControls(removeParamsCb);
            }
        });
    }
}
Also used : ItemEvent(java.awt.event.ItemEvent) PsiParameter(com.intellij.psi.PsiParameter) ChangeEvent(javax.swing.event.ChangeEvent) NonFocusableCheckBox(com.intellij.ui.NonFocusableCheckBox) ChangeListener(javax.swing.event.ChangeListener) ItemListener(java.awt.event.ItemListener)

Example 9 with NonFocusableCheckBox

use of com.intellij.ui.NonFocusableCheckBox in project intellij-community by JetBrains.

the class IntroduceParameterSettingsUI method createOccurrencesCb.

protected void createOccurrencesCb(GridBagConstraints gbConstraints, JPanel panel, final int occurenceNumber) {
    myCbReplaceAllOccurences = new NonFocusableCheckBox();
    myCbReplaceAllOccurences.setText(RefactoringBundle.message("replace.all.occurences", occurenceNumber));
    panel.add(myCbReplaceAllOccurences, gbConstraints);
    myCbReplaceAllOccurences.setSelected(false);
}
Also used : NonFocusableCheckBox(com.intellij.ui.NonFocusableCheckBox)

Example 10 with NonFocusableCheckBox

use of com.intellij.ui.NonFocusableCheckBox in project intellij-community by JetBrains.

the class InplaceChangeSignature method showBalloon.

protected void showBalloon() {
    NonFocusableCheckBox checkBox = new NonFocusableCheckBox(RefactoringBundle.message("delegation.panel.delegate.via.overloading.method"));
    checkBox.addActionListener(e -> {
        myDelegate = checkBox.isSelected();
        updateCurrentInfo();
    });
    JPanel content = new JPanel(new BorderLayout());
    content.add(new JBLabel("Performed signature modifications:"), BorderLayout.NORTH);
    content.add(myPreview.getComponent(), BorderLayout.CENTER);
    updateMethodSignature(myStableChange);
    content.add(checkBox, BorderLayout.SOUTH);
    final BalloonBuilder balloonBuilder = JBPopupFactory.getInstance().createDialogBalloonBuilder(content, null).setSmallVariant(true);
    myBalloon = balloonBuilder.createBalloon();
    myEditor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
    myBalloon.show(new PositionTracker<Balloon>(myEditor.getContentComponent()) {

        @Override
        public RelativePoint recalculateLocation(Balloon object) {
            int offset = myStableChange.getMethod().getTextOffset();
            VisualPosition visualPosition = myEditor.offsetToVisualPosition(offset);
            Point point = myEditor.visualPositionToXY(new VisualPosition(visualPosition.line, visualPosition.column));
            return new RelativePoint(myEditor.getContentComponent(), point);
        }
    }, Balloon.Position.above);
    Disposer.register(myBalloon, () -> {
        EditorFactory.getInstance().releaseEditor(myPreview);
        myPreview = null;
    });
}
Also used : JBLabel(com.intellij.ui.components.JBLabel) NonFocusableCheckBox(com.intellij.ui.NonFocusableCheckBox) Balloon(com.intellij.openapi.ui.popup.Balloon) RelativePoint(com.intellij.ui.awt.RelativePoint) RelativePoint(com.intellij.ui.awt.RelativePoint) BalloonBuilder(com.intellij.openapi.ui.popup.BalloonBuilder)

Aggregations

NonFocusableCheckBox (com.intellij.ui.NonFocusableCheckBox)16 ActionEvent (java.awt.event.ActionEvent)4 ActionListener (java.awt.event.ActionListener)4 Result (com.intellij.openapi.application.Result)3 WriteCommandAction (com.intellij.openapi.command.WriteCommandAction)3 NotNull (org.jetbrains.annotations.NotNull)3 Nullable (org.jetbrains.annotations.Nullable)3 ItemEvent (java.awt.event.ItemEvent)2 ItemListener (java.awt.event.ItemListener)2 Function0 (kotlin.jvm.functions.Function0)2 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)1 Balloon (com.intellij.openapi.ui.popup.Balloon)1 BalloonBuilder (com.intellij.openapi.ui.popup.BalloonBuilder)1 PsiParameter (com.intellij.psi.PsiParameter)1 JavaRefactoringSettings (com.intellij.refactoring.JavaRefactoringSettings)1 AutomaticRenamerFactory (com.intellij.refactoring.rename.naming.AutomaticRenamerFactory)1 NameSuggestionsField (com.intellij.refactoring.ui.NameSuggestionsField)1 VariableData (com.intellij.refactoring.util.VariableData)1 DocumentAdapter (com.intellij.ui.DocumentAdapter)1 StateRestoringCheckBox (com.intellij.ui.StateRestoringCheckBox)1