Search in sources :

Example 11 with JavaRefactoringSettings

use of com.intellij.refactoring.JavaRefactoringSettings in project intellij-community by JetBrains.

the class GrIntroduceParameterDialog method init.

@Override
protected void init() {
    super.init();
    JavaRefactoringSettings settings = JavaRefactoringSettings.getInstance();
    initReplaceFieldsWithGetters(settings);
    myDeclareFinalCheckBox.setSelected(hasFinalModifier());
    myDelegateViaOverloadingMethodCheckBox.setVisible(myInfo.getToSearchFor() != null);
    setTitle(RefactoringBundle.message("introduce.parameter.title"));
    myTable.init(myInfo);
    final GrParameter[] parameters = myInfo.getToReplaceIn().getParameters();
    toRemoveCBs.forEachEntry(new TObjectIntProcedure<JCheckBox>() {

        @Override
        public boolean execute(JCheckBox checkbox, int index) {
            checkbox.setSelected(true);
            final GrParameter param = parameters[index];
            final ParameterInfo pinfo = findParamByOldName(param.getName());
            if (pinfo != null) {
                pinfo.passAsParameter = false;
            }
            return true;
        }
    });
    updateSignature();
    if (myCanIntroduceSimpleParameter) {
        mySignaturePanel.setVisible(false);
        //action to hide signature panel if we have variants to introduce simple parameter
        myTypeComboBox.addItemListener(new ItemListener() {

            @Override
            public void itemStateChanged(ItemEvent e) {
                mySignaturePanel.setVisible(myTypeComboBox.isClosureSelected());
                pack();
            }
        });
    }
    final PsiType closureReturnType = inferClosureReturnType();
    if (PsiType.VOID.equals(closureReturnType)) {
        myForceReturnCheckBox.setEnabled(false);
        myForceReturnCheckBox.setSelected(false);
    } else {
        myForceReturnCheckBox.setSelected(isForceReturn());
    }
    if (myInfo.getToReplaceIn() instanceof GrClosableBlock) {
        myDelegateViaOverloadingMethodCheckBox.setEnabled(false);
        myDelegateViaOverloadingMethodCheckBox.setToolTipText("Delegating is not allowed in closure context");
    }
    pack();
}
Also used : JavaRefactoringSettings(com.intellij.refactoring.JavaRefactoringSettings) ItemEvent(java.awt.event.ItemEvent) GrClosableBlock(org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock) ItemListener(java.awt.event.ItemListener) ParameterInfo(org.jetbrains.plugins.groovy.refactoring.extract.ParameterInfo) GrParameter(org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter) PsiType(com.intellij.psi.PsiType)

Example 12 with JavaRefactoringSettings

use of com.intellij.refactoring.JavaRefactoringSettings in project intellij-community by JetBrains.

the class EncapsulateFieldsDialog method doAction.

protected void doAction() {
    if (myTable.isEditing()) {
        TableCellEditor editor = myTable.getCellEditor();
        if (editor != null) {
            editor.stopCellEditing();
        }
    }
    String errorString = validateData();
    if (errorString != null) {
        // were errors
        CommonRefactoringUtil.showErrorMessage(REFACTORING_NAME, errorString, HelpID.ENCAPSULATE_FIELDS, myProject);
        return;
    }
    if (getCheckedRows().length == 0) {
        CommonRefactoringUtil.showErrorMessage(REFACTORING_NAME, "Nothing found to encapsulate", HelpID.ENCAPSULATE_FIELDS, myProject);
        return;
    }
    invokeRefactoring(new EncapsulateFieldsProcessor(myProject, this));
    JavaRefactoringSettings settings = JavaRefactoringSettings.getInstance();
    settings.ENCAPSULATE_FIELDS_USE_ACCESSORS_WHEN_ACCESSIBLE = myCbUseAccessorsWhenAccessible.isSelected();
}
Also used : JavaRefactoringSettings(com.intellij.refactoring.JavaRefactoringSettings) TableCellEditor(javax.swing.table.TableCellEditor)

Example 13 with JavaRefactoringSettings

use of com.intellij.refactoring.JavaRefactoringSettings in project intellij-community by JetBrains.

the class TypeCookDialog method doAction.

protected void doAction() {
    JavaRefactoringSettings settings = JavaRefactoringSettings.getInstance();
    settings.TYPE_COOK_DROP_CASTS = myCbDropCasts.isSelected();
    settings.TYPE_COOK_PRESERVE_RAW_ARRAYS = myCbPreserveRawArrays.isSelected();
    settings.TYPE_COOK_LEAVE_OBJECT_PARAMETERIZED_TYPES_RAW = myCbLeaveObjectParameterizedTypesRaw.isSelected();
    settings.TYPE_COOK_EXHAUSTIVE = myCbExhaustive.isSelected();
    settings.TYPE_COOK_COOK_OBJECTS = myCbCookObjects.isSelected();
    settings.TYPE_COOK_PRODUCE_WILDCARDS = myCbCookToWildcards.isSelected();
    invokeRefactoring(new TypeCookProcessor(getProject(), myElements, getSettings()));
}
Also used : JavaRefactoringSettings(com.intellij.refactoring.JavaRefactoringSettings)

Example 14 with JavaRefactoringSettings

use of com.intellij.refactoring.JavaRefactoringSettings in project kotlin by JetBrains.

the class MoveKotlinTopLevelDeclarationsDialog method saveRefactoringSettings.

private void saveRefactoringSettings() {
    JavaRefactoringSettings refactoringSettings = JavaRefactoringSettings.getInstance();
    refactoringSettings.MOVE_SEARCH_IN_COMMENTS = isSearchInComments();
    refactoringSettings.MOVE_SEARCH_FOR_TEXT = isSearchInNonJavaFiles();
    refactoringSettings.MOVE_PREVIEW_USAGES = isPreviewUsages();
}
Also used : JavaRefactoringSettings(com.intellij.refactoring.JavaRefactoringSettings)

Aggregations

JavaRefactoringSettings (com.intellij.refactoring.JavaRefactoringSettings)14 Project (com.intellij.openapi.project.Project)1 PsiType (com.intellij.psi.PsiType)1 MoveDestination (com.intellij.refactoring.MoveDestination)1 InlineMethodProcessor (com.intellij.refactoring.inline.InlineMethodProcessor)1 NonFocusableCheckBox (com.intellij.ui.NonFocusableCheckBox)1 IncorrectOperationException (com.intellij.util.IncorrectOperationException)1 ItemEvent (java.awt.event.ItemEvent)1 ItemListener (java.awt.event.ItemListener)1 TableCellEditor (javax.swing.table.TableCellEditor)1 GrClosableBlock (org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock)1 GrParameter (org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter)1 ParameterInfo (org.jetbrains.plugins.groovy.refactoring.extract.ParameterInfo)1