Search in sources :

Example 11 with NonFocusableCheckBox

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

the class RenameDialog method createCheckboxes.

protected void createCheckboxes(JPanel panel, GridBagConstraints gbConstraints) {
    gbConstraints.insets = JBUI.insetsBottom(4);
    gbConstraints.gridwidth = 1;
    gbConstraints.gridx = 0;
    gbConstraints.weighty = 0;
    gbConstraints.weightx = 1;
    gbConstraints.fill = GridBagConstraints.BOTH;
    myCbSearchInComments = new NonFocusableCheckBox();
    myCbSearchInComments.setText(RefactoringBundle.getSearchInCommentsAndStringsText());
    myCbSearchInComments.setSelected(true);
    panel.add(myCbSearchInComments, gbConstraints);
    gbConstraints.insets = JBUI.insetsBottom(4);
    gbConstraints.gridwidth = GridBagConstraints.REMAINDER;
    gbConstraints.gridx = 1;
    gbConstraints.weightx = 1;
    gbConstraints.fill = GridBagConstraints.BOTH;
    myCbSearchTextOccurrences = new NonFocusableCheckBox();
    myCbSearchTextOccurrences.setText(RefactoringBundle.getSearchForTextOccurrencesText());
    myCbSearchTextOccurrences.setSelected(true);
    panel.add(myCbSearchTextOccurrences, gbConstraints);
    if (!TextOccurrencesUtil.isSearchTextOccurencesEnabled(myPsiElement)) {
        myCbSearchTextOccurrences.setEnabled(false);
        myCbSearchTextOccurrences.setSelected(false);
        myCbSearchTextOccurrences.setVisible(false);
    }
    for (AutomaticRenamerFactory factory : Extensions.getExtensions(AutomaticRenamerFactory.EP_NAME)) {
        if (factory.isApplicable(myPsiElement) && factory.getOptionName() != null) {
            gbConstraints.insets = JBUI.insetsBottom(4);
            gbConstraints.gridwidth = myAutoRenamerFactories.size() % 2 == 0 ? 1 : GridBagConstraints.REMAINDER;
            gbConstraints.gridx = myAutoRenamerFactories.size() % 2;
            gbConstraints.weightx = 1;
            gbConstraints.fill = GridBagConstraints.BOTH;
            JCheckBox checkBox = new NonFocusableCheckBox();
            checkBox.setText(factory.getOptionName());
            checkBox.setSelected(factory.isEnabled());
            panel.add(checkBox, gbConstraints);
            myAutoRenamerFactories.put(factory, checkBox);
        }
    }
}
Also used : AutomaticRenamerFactory(com.intellij.refactoring.rename.naming.AutomaticRenamerFactory) NonFocusableCheckBox(com.intellij.ui.NonFocusableCheckBox)

Example 12 with NonFocusableCheckBox

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

the class MoveFilesOrDirectoriesDialog method createNorthPanel.

@Override
protected JComponent createNorthPanel() {
    myNameLabel = JBLabelDecorator.createJBLabelDecorator().setBold(true);
    myTargetDirectoryField = new TextFieldWithHistoryWithBrowseButton();
    final List<String> recentEntries = RecentsManager.getInstance(myProject).getRecentEntries(RECENT_KEYS);
    if (recentEntries != null) {
        myTargetDirectoryField.getChildComponent().setHistory(recentEntries);
    }
    final FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
    myTargetDirectoryField.addBrowseFolderListener(RefactoringBundle.message("select.target.directory"), RefactoringBundle.message("the.file.will.be.moved.to.this.directory"), myProject, descriptor, TextComponentAccessor.TEXT_FIELD_WITH_HISTORY_WHOLE_TEXT);
    final JTextField textField = myTargetDirectoryField.getChildComponent().getTextEditor();
    FileChooserFactory.getInstance().installFileCompletion(textField, descriptor, true, getDisposable());
    textField.getDocument().addDocumentListener(new DocumentAdapter() {

        @Override
        protected void textChanged(DocumentEvent e) {
            validateOKButton();
        }
    });
    myTargetDirectoryField.setTextFieldPreferredWidth(CopyFilesOrDirectoriesDialog.MAX_PATH_LENGTH);
    Disposer.register(getDisposable(), myTargetDirectoryField);
    String shortcutText = KeymapUtil.getFirstKeyboardShortcutText(ActionManager.getInstance().getAction(IdeActions.ACTION_CODE_COMPLETION));
    myCbSearchForReferences = new NonFocusableCheckBox(RefactoringBundle.message("search.for.references"));
    myCbSearchForReferences.setSelected(RefactoringSettings.getInstance().MOVE_SEARCH_FOR_REFERENCES_FOR_FILE);
    myOpenInEditorCb = new NonFocusableCheckBox("Open moved files in editor");
    myOpenInEditorCb.setSelected(isOpenInEditor());
    return FormBuilder.createFormBuilder().addComponent(myNameLabel).addLabeledComponent(RefactoringBundle.message("move.files.to.directory.label"), myTargetDirectoryField, UIUtil.LARGE_VGAP).addTooltip(RefactoringBundle.message("path.completion.shortcut", shortcutText)).addComponentToRightColumn(myCbSearchForReferences, UIUtil.LARGE_VGAP).addComponentToRightColumn(myOpenInEditorCb, UIUtil.LARGE_VGAP).getPanel();
}
Also used : TextFieldWithHistoryWithBrowseButton(com.intellij.ui.TextFieldWithHistoryWithBrowseButton) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) NonFocusableCheckBox(com.intellij.ui.NonFocusableCheckBox) DocumentAdapter(com.intellij.ui.DocumentAdapter) DocumentEvent(javax.swing.event.DocumentEvent)

Example 13 with NonFocusableCheckBox

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

the class RenameWithOptionalReferencesDialog method createCheckboxes.

@Override
protected void createCheckboxes(JPanel panel, GridBagConstraints gbConstraints) {
    gbConstraints.insets = new Insets(0, 0, 4, 0);
    gbConstraints.gridwidth = 1;
    gbConstraints.gridx = 0;
    gbConstraints.weighty = 0;
    gbConstraints.weightx = 1;
    gbConstraints.fill = GridBagConstraints.BOTH;
    myCbSearchForReferences = new NonFocusableCheckBox(RefactoringBundle.message("search.for.references"));
    myCbSearchForReferences.setSelected(getSearchForReferences());
    panel.add(myCbSearchForReferences, gbConstraints);
    super.createCheckboxes(panel, gbConstraints);
}
Also used : NonFocusableCheckBox(com.intellij.ui.NonFocusableCheckBox)

Example 14 with NonFocusableCheckBox

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

the class GrInplaceVariableIntroducer method getComponent.

@Override
protected JComponent getComponent() {
    myCanBeFinalCb = new NonFocusableCheckBox("Declare final");
    myCanBeFinalCb.setSelected(false);
    myCanBeFinalCb.setMnemonic('f');
    final GrFinalListener finalListener = new GrFinalListener(myEditor);
    myCanBeFinalCb.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            new WriteCommandAction(myProject, getCommandName(), getCommandName()) {

                @Override
                protected void run(@NotNull Result result) throws Throwable {
                    PsiDocumentManager.getInstance(myProject).commitDocument(myEditor.getDocument());
                    final GrVariable variable = getVariable();
                    if (variable != null) {
                        finalListener.perform(myCanBeFinalCb.isSelected(), variable);
                    }
                }
            }.execute();
        }
    });
    final JPanel panel = new JPanel(new GridBagLayout());
    panel.setBorder(null);
    if (myCanBeFinalCb != null) {
        panel.add(myCanBeFinalCb, new GridBagConstraints(0, 1, 1, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
    }
    panel.add(Box.createVerticalBox(), new GridBagConstraints(0, 2, 1, 1, 1, 1, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
    return panel;
}
Also used : WriteCommandAction(com.intellij.openapi.command.WriteCommandAction) GrFinalListener(org.jetbrains.plugins.groovy.refactoring.introduce.GrFinalListener) ActionEvent(java.awt.event.ActionEvent) NotNull(org.jetbrains.annotations.NotNull) Result(com.intellij.openapi.application.Result) GrVariable(org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable) ActionListener(java.awt.event.ActionListener) NonFocusableCheckBox(com.intellij.ui.NonFocusableCheckBox)

Example 15 with NonFocusableCheckBox

use of com.intellij.ui.NonFocusableCheckBox in project kotlin by JetBrains.

the class KotlinInplaceVariableIntroducer method getCreateExplicitTypeCheckBox.

@Nullable
protected final Function0<JComponent> getCreateExplicitTypeCheckBox() {
    if (myExprType == null || noTypeInference)
        return null;
    return new Function0<JComponent>() {

        @Override
        public JComponent invoke() {
            final JCheckBox exprTypeCheckbox = new NonFocusableCheckBox("Specify type explicitly");
            exprTypeCheckbox.setSelected(false);
            exprTypeCheckbox.setMnemonic('t');
            exprTypeCheckbox.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(@NotNull ActionEvent e) {
                    runWriteActionAndRestartRefactoring(new Runnable() {

                        @Override
                        public void run() {
                            if (exprTypeCheckbox.isSelected()) {
                                String renderedType = IdeDescriptorRenderers.SOURCE_CODE_SHORT_NAMES_IN_TYPES.renderType(myExprType);
                                myDeclaration.setTypeReference(new KtPsiFactory(myProject).createType(renderedType));
                            } else {
                                myDeclaration.setTypeReference(null);
                            }
                        }
                    });
                }
            });
            return exprTypeCheckbox;
        }
    };
}
Also used : ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) NonFocusableCheckBox(com.intellij.ui.NonFocusableCheckBox) Function0(kotlin.jvm.functions.Function0) Nullable(org.jetbrains.annotations.Nullable)

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