mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
skip inline dialog for local variables (IDEA-126391)
This commit is contained in:
@@ -23,15 +23,15 @@ import com.intellij.refactoring.HelpID;
|
||||
import com.intellij.refactoring.JavaRefactoringSettings;
|
||||
import com.intellij.refactoring.RefactoringBundle;
|
||||
|
||||
public class InlineLocalDialog extends InlineOptionsDialog {
|
||||
public class InlineLocalDialog extends AbstractInlineLocalDialog {
|
||||
public static final String REFACTORING_NAME = RefactoringBundle.message("inline.method.title");
|
||||
|
||||
private final PsiVariable myVariable;
|
||||
|
||||
private int myOccurrencesNumber = -1;
|
||||
|
||||
public InlineLocalDialog(Project project, PsiVariable variable, PsiJavaCodeReferenceElement ref, int occurrencesCount) {
|
||||
super(project, true, variable);
|
||||
public InlineLocalDialog(Project project, PsiVariable variable, final PsiJavaCodeReferenceElement ref, int occurrencesCount) {
|
||||
super(project, variable, ref, occurrencesCount);
|
||||
myVariable = variable;
|
||||
myInvokedOnReference = ref != null;
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.colors.EditorColors;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsManager;
|
||||
import com.intellij.openapi.editor.ex.EditorSettingsExternalizable;
|
||||
import com.intellij.openapi.editor.markup.TextAttributes;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
@@ -147,15 +148,18 @@ public class InlineLocalHandler extends JavaInlineActionHandler {
|
||||
final Ref<Boolean> inlineAll = new Ref<Boolean>(true);
|
||||
if (editor != null && !ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
int occurrencesCount = refsToInlineList.size();
|
||||
final InlineLocalDialog inlineLocalDialog = new InlineLocalDialog(project, local, refExpr, occurrencesCount);
|
||||
inlineLocalDialog.show();
|
||||
if (!inlineLocalDialog.isOK()){
|
||||
WindowManager.getInstance().getStatusBar(project).setInfo(RefactoringBundle.message("press.escape.to.remove.the.highlighting"));
|
||||
return;
|
||||
}
|
||||
if (refExpr != null && inlineLocalDialog.isInlineThis()) {
|
||||
refsToInlineList = Collections.<PsiElement>singletonList(refExpr);
|
||||
inlineAll.set(false);
|
||||
if (refExpr != null && occurrencesCount > 1 || EditorSettingsExternalizable.getInstance().isShowInlineLocalDialog()) {
|
||||
final InlineLocalDialog inlineLocalDialog = new InlineLocalDialog(project, local, refExpr, occurrencesCount);
|
||||
inlineLocalDialog.show();
|
||||
if (!inlineLocalDialog.isOK()){
|
||||
WindowManager.getInstance().getStatusBar(project).setInfo(RefactoringBundle.message("press.escape.to.remove.the.highlighting"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (refExpr != null && inlineLocalDialog.isInlineThis()) {
|
||||
refsToInlineList = Collections.<PsiElement>singletonList(refExpr);
|
||||
inlineAll.set(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+9
-1
@@ -417,7 +417,7 @@
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="70a4f" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="70a4f" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
@@ -444,6 +444,14 @@
|
||||
<text resource-bundle="messages/ApplicationBundle" key="checkbox.rename.local.variables.preselect"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="b2798" class="javax.swing.JCheckBox" binding="myShowInlineDialogForCheckBox" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Show inline dialog for local variables"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="62a96" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
|
||||
@@ -97,6 +97,7 @@ public class EditorOptionsPanel {
|
||||
private JBLabel myQuickDocDelayLabel;
|
||||
private JTextField myQuickDocDelayTextField;
|
||||
private JComboBox myRichCopyColorSchemeComboBox;
|
||||
private JCheckBox myShowInlineDialogForCheckBox;
|
||||
|
||||
private static final String ACTIVE_COLOR_SCHEME = ApplicationBundle.message("combobox.richcopy.color.scheme.active");
|
||||
|
||||
@@ -206,6 +207,7 @@ public class EditorOptionsPanel {
|
||||
|
||||
myCbRenameLocalVariablesInplace.setSelected(editorSettings.isVariableInplaceRenameEnabled());
|
||||
myPreselectCheckBox.setSelected(editorSettings.isPreselectRename());
|
||||
myShowInlineDialogForCheckBox.setSelected(editorSettings.isShowInlineLocalDialog());
|
||||
|
||||
myShowReformatCodeDialogCheckBox.setSelected(editorSettings.getOptions().SHOW_REFORMAT_DIALOG);
|
||||
myShowOptimizeImportsDialogCheckBox.setSelected(editorSettings.getOptions().SHOW_OPIMIZE_IMPORTS_DIALOG);
|
||||
@@ -301,6 +303,7 @@ public class EditorOptionsPanel {
|
||||
|
||||
editorSettings.setVariableInplaceRenameEnabled(myCbRenameLocalVariablesInplace.isSelected());
|
||||
editorSettings.setPreselectRename(myPreselectCheckBox.isSelected());
|
||||
editorSettings.setShowInlineLocalDialog(myShowInlineDialogForCheckBox.isSelected());
|
||||
|
||||
editorSettings.getOptions().SHOW_REFORMAT_DIALOG = myShowReformatCodeDialogCheckBox.isSelected();
|
||||
editorSettings.getOptions().SHOW_OPIMIZE_IMPORTS_DIALOG = myShowOptimizeImportsDialogCheckBox.isSelected();
|
||||
@@ -442,6 +445,7 @@ public class EditorOptionsPanel {
|
||||
isModified |= isModified(myCommandsHistoryLimitField, UISettings.getInstance().CONSOLE_COMMAND_HISTORY_LIMIT);
|
||||
isModified |= isModified(myCbRenameLocalVariablesInplace, editorSettings.isVariableInplaceRenameEnabled());
|
||||
isModified |= isModified(myPreselectCheckBox, editorSettings.isPreselectRename());
|
||||
isModified |= isModified(myShowInlineDialogForCheckBox, editorSettings.isShowInlineLocalDialog());
|
||||
|
||||
isModified |= isModified(myShowReformatCodeDialogCheckBox, editorSettings.getOptions().SHOW_REFORMAT_DIALOG);
|
||||
isModified |= isModified(myShowOptimizeImportsDialogCheckBox, editorSettings.getOptions().SHOW_OPIMIZE_IMPORTS_DIALOG);
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.refactoring.inline;
|
||||
|
||||
import com.intellij.CommonBundle;
|
||||
import com.intellij.openapi.editor.ex.EditorSettingsExternalizable;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiReference;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class AbstractInlineLocalDialog extends InlineOptionsDialog {
|
||||
public AbstractInlineLocalDialog(Project project, PsiElement variable, final PsiReference ref, int occurrencesCount) {
|
||||
super(project, true, variable);
|
||||
if (ref == null || occurrencesCount == 1) {
|
||||
setDoNotAskOption(new DoNotAskOption() {
|
||||
@Override
|
||||
public boolean isToBeShown() {
|
||||
return EditorSettingsExternalizable.getInstance().isShowInlineLocalDialog();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setToBeShown(boolean value, int exitCode) {
|
||||
EditorSettingsExternalizable.getInstance().setShowInlineLocalDialog(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldSaveOptionsOnCancel() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getDoNotShowMessage() {
|
||||
return CommonBundle.message("dialog.options.do.not.show");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
+12
@@ -73,6 +73,8 @@ public class EditorSettingsExternalizable implements NamedJDOMExternalizable, Ex
|
||||
|
||||
public boolean RENAME_VARIABLES_INPLACE = true;
|
||||
public boolean PRESELECT_RENAME = true;
|
||||
public boolean SHOW_INLINE_DIALOG = true;
|
||||
|
||||
public boolean REFRAIN_FROM_SCROLLING = false;
|
||||
|
||||
public boolean SHOW_REFORMAT_DIALOG = true;
|
||||
@@ -522,4 +524,14 @@ public class EditorSettingsExternalizable implements NamedJDOMExternalizable, Ex
|
||||
public void setPreselectRename(final boolean val) {
|
||||
myOptions.PRESELECT_RENAME = val;
|
||||
}
|
||||
|
||||
public boolean isShowInlineLocalDialog() {
|
||||
return myOptions.SHOW_INLINE_DIALOG;
|
||||
}
|
||||
|
||||
public void setShowInlineLocalDialog(final boolean val) {
|
||||
myOptions.SHOW_INLINE_DIALOG = val;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user