mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
inplace introduce: reuse custom settings in dialog
This commit is contained in:
+4
@@ -209,6 +209,10 @@ public class InplaceIntroduceFieldPopup extends AbstractJavaInplaceIntroducer {
|
||||
}
|
||||
}
|
||||
|
||||
public BaseExpressionToFieldHandler.InitializationPlace getInitializerPlace() {
|
||||
return myIntroduceFieldPanel.getInitializerPlace();
|
||||
}
|
||||
|
||||
protected void performIntroduce() {
|
||||
ourLastInitializerPlace = myIntroduceFieldPanel.getInitializerPlace();
|
||||
final BaseExpressionToFieldHandler.Settings settings =
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ import java.awt.*;
|
||||
class IntroduceFieldDialog extends DialogWrapper {
|
||||
|
||||
|
||||
static BaseExpressionToFieldHandler.InitializationPlace ourLastInitializerPlace;
|
||||
public static BaseExpressionToFieldHandler.InitializationPlace ourLastInitializerPlace;
|
||||
|
||||
private final Project myProject;
|
||||
private final PsiClass myParentClass;
|
||||
|
||||
@@ -124,6 +124,7 @@ public class IntroduceFieldHandler extends BaseExpressionToFieldHandler {
|
||||
occurences = (PsiExpression[])activeIntroducer.getOccurrences();
|
||||
enteredName = activeIntroducer.getInputName();
|
||||
replaceAll = activeIntroducer.isReplaceAllOccurrences();
|
||||
IntroduceFieldDialog.ourLastInitializerPlace = ((InplaceIntroduceFieldPopup)activeIntroducer).getInitializerPlace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+5
-1
@@ -160,7 +160,7 @@ public class InplaceIntroduceParameterPopup extends AbstractJavaInplaceIntroduce
|
||||
(PsiLocalVariable)getLocalVariable(), isDeleteLocalVariable, getInputName(),
|
||||
myPanel.isReplaceAllOccurences(),
|
||||
myPanel.getReplaceFieldsWithGetters(), myMustBeFinal || myPanel.isGenerateFinal(),
|
||||
myPanel.isGenerateDelegate(),
|
||||
isGenerateDelegate(),
|
||||
getType(),
|
||||
parametersToRemove);
|
||||
final Runnable runnable = new Runnable() {
|
||||
@@ -193,6 +193,10 @@ public class InplaceIntroduceParameterPopup extends AbstractJavaInplaceIntroduce
|
||||
CommandProcessor.getInstance().executeCommand(myProject, runnable, getCommandName(), null);
|
||||
}
|
||||
|
||||
public boolean isGenerateDelegate() {
|
||||
return myPanel.isGenerateDelegate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getActionName() {
|
||||
return "IntroduceParameter";
|
||||
|
||||
+8
@@ -290,6 +290,10 @@ public class IntroduceParameterDialog extends RefactoringDialog {
|
||||
myPanel.setReplaceAllOccurrences(replaceAllOccurrences);
|
||||
}
|
||||
|
||||
public void setGenerateDelegate(boolean delegate) {
|
||||
myPanel.setGenerateDelegate(delegate);
|
||||
}
|
||||
|
||||
private class IntroduceParameterSettingsPanel extends IntroduceParameterSettingsUI {
|
||||
public IntroduceParameterSettingsPanel(Project project,
|
||||
PsiLocalVariable onLocalVariable,
|
||||
@@ -308,5 +312,9 @@ public class IntroduceParameterDialog extends RefactoringDialog {
|
||||
super.updateControls(removeParamsCb);
|
||||
updateFinalState();
|
||||
}
|
||||
|
||||
public void setGenerateDelegate(boolean delegate) {
|
||||
myCbGenerateDelegate.setSelected(delegate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
@@ -408,6 +408,7 @@ public class IntroduceParameterHandler extends IntroduceHandlerBase implements R
|
||||
|
||||
String enteredName = null;
|
||||
boolean replaceAllOccurrences = false;
|
||||
boolean delegate = false;
|
||||
if (isInplaceAvailableOnDataContext) {
|
||||
final AbstractInplaceIntroducer activeIntroducer = AbstractInplaceIntroducer.getActiveIntroducer(myEditor);
|
||||
if (activeIntroducer == null) {
|
||||
@@ -429,6 +430,7 @@ public class IntroduceParameterHandler extends IntroduceHandlerBase implements R
|
||||
occurences = (PsiExpression[])activeIntroducer.getOccurrences();
|
||||
enteredName = activeIntroducer.getInputName();
|
||||
replaceAllOccurrences = activeIntroducer.isReplaceAllOccurrences();
|
||||
delegate = ((InplaceIntroduceParameterPopup)activeIntroducer).isGenerateDelegate();
|
||||
}
|
||||
}
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
@@ -449,6 +451,7 @@ public class IntroduceParameterHandler extends IntroduceHandlerBase implements R
|
||||
createNameSuggestionGenerator(myExpr, propName, myProject, enteredName),
|
||||
typeSelectorManager, methodToSearchFor, method, getParamsToRemove(method, occurences), mustBeFinal);
|
||||
dialog.setReplaceAllOccurrences(replaceAllOccurrences);
|
||||
dialog.setGenerateDelegate(delegate);
|
||||
dialog.show();
|
||||
if (myEditor != null) {
|
||||
myEditor.getSelectionModel().removeSelection();
|
||||
|
||||
+1
-1
@@ -59,7 +59,7 @@ public abstract class IntroduceParameterSettingsUI {
|
||||
protected final boolean myIsLocalVariable;
|
||||
|
||||
protected JCheckBox myCbReplaceAllOccurences = null;
|
||||
private JCheckBox myCbGenerateDelegate = null;
|
||||
protected JCheckBox myCbGenerateDelegate = null;
|
||||
|
||||
public IntroduceParameterSettingsUI(Project project,
|
||||
PsiLocalVariable onLocalVariable,
|
||||
|
||||
Reference in New Issue
Block a user