mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
more convenient presets for checkboxes
This commit is contained in:
+1
-1
@@ -167,4 +167,4 @@ variable.is.accessed.for.writing=Variable ''{0}'' is accessed for writing
|
||||
introduce.closure.parameter.elements.header=Adding parameter to a closure
|
||||
extract.closure.title=Extract closure
|
||||
cannot.process.usage.in.language.{0}=Cannot process usage in {0}
|
||||
you.cannot.pass.as.parameter.0.because.you.remove.1.from.base.method=You cannot pass ''{0}'' as parameter because you remove ''{1}'' from the method. You should deselect "Remove parameter ''{0}'' no longer used" or deselect parameter ''{1}'' in the parameter table.
|
||||
you.cannot.pass.as.parameter.0.because.you.remove.1.from.base.method=You cannot pass ''{0}'' as parameter because you remove parameter ''{1}'' associated with it from the method. You should deselect "Remove parameter ''{0}'' no longer used" or deselect parameter ''{1}'' in the parameter table.
|
||||
|
||||
+29
-7
@@ -32,6 +32,7 @@ import com.intellij.util.ui.UIUtil;
|
||||
import gnu.trove.TIntArrayList;
|
||||
import gnu.trove.TObjectIntHashMap;
|
||||
import gnu.trove.TObjectIntProcedure;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.GroovyFileType;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrParametersOwner;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrStatement;
|
||||
@@ -60,11 +61,9 @@ public class ExtractClosureDialog extends DialogWrapper {
|
||||
private final JBCheckBox myGenerateDelegateCB;
|
||||
|
||||
TObjectIntHashMap<JBCheckBox> toRemoveCBs;
|
||||
private final InitialInfo myInitialInfo;
|
||||
|
||||
public ExtractClosureDialog(InitialInfo initialInfo, GrParametersOwner owner, PsiElement toSearchFor) {
|
||||
super(initialInfo.getProject());
|
||||
myInitialInfo = initialInfo;
|
||||
|
||||
myHelper = new ExtractClosureHelper(initialInfo, owner, toSearchFor, "", false);
|
||||
|
||||
@@ -99,7 +98,6 @@ public class ExtractClosureDialog extends DialogWrapper {
|
||||
for (Object p : parametersToRemove.keys()) {
|
||||
JBCheckBox cb = new JBCheckBox(GroovyRefactoringBundle.message("remove.parameter.0.no.longer.used", ((GrParameter)p).getName()));
|
||||
cb.setFocusable(false);
|
||||
cb.setSelected(false);
|
||||
toRemoveCBs.put(cb, parametersToRemove.get((GrParameter)p));
|
||||
}
|
||||
|
||||
@@ -119,12 +117,13 @@ public class ExtractClosureDialog extends DialogWrapper {
|
||||
public boolean execute(JBCheckBox checkbox, int index) {
|
||||
if (!checkbox.isSelected()) return true;
|
||||
|
||||
final ParameterInfo param = myHelper.getParameterInfos()[index];
|
||||
if (!param.passAsParameter()) return true;
|
||||
|
||||
final ParameterInfo initialParam = myInitialInfo.getParameterInfos()[index];
|
||||
final GrParameter param = myHelper.getOwner().getParameters()[index];
|
||||
final ParameterInfo pinfo = findParamByOldName(param.getName());
|
||||
if (pinfo == null || !pinfo.passAsParameter()) return true;
|
||||
|
||||
final String message = GroovyRefactoringBundle.message("you.cannot.pass.as.parameter.0.because.you.remove.1.from.base.method",
|
||||
param.getName(), initialParam.getName());
|
||||
pinfo.getName(), param.getName());
|
||||
info.set(new ValidationInfo(message));
|
||||
return false;
|
||||
}
|
||||
@@ -132,6 +131,14 @@ public class ExtractClosureDialog extends DialogWrapper {
|
||||
return info.get();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private ParameterInfo findParamByOldName(String name) {
|
||||
for (ParameterInfo info : myHelper.getParameterInfos()) {
|
||||
if (name.equals(info.getOldName())) return info;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void updateSignature() {
|
||||
StringBuilder b = new StringBuilder();
|
||||
b.append("{ ");
|
||||
@@ -164,6 +171,21 @@ public class ExtractClosureDialog extends DialogWrapper {
|
||||
CodeStyleSettingsManager.getSettings(myHelper.getProject()).GENERATE_FINAL_PARAMETERS :
|
||||
settingsFinals.booleanValue());
|
||||
myGenerateDelegateCB.setSelected(false);
|
||||
|
||||
final GrParameter[] parameters = myHelper.getOwner().getParameters();
|
||||
toRemoveCBs.forEachEntry(new TObjectIntProcedure<JBCheckBox>() {
|
||||
@Override
|
||||
public boolean execute(JBCheckBox checkbox, int index) {
|
||||
checkbox.setSelected(true);
|
||||
|
||||
final GrParameter param = parameters[index];
|
||||
final ParameterInfo pinfo = findParamByOldName(param.getName());
|
||||
if (pinfo != null) {
|
||||
pinfo.setPassAsParameter(false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
updateSignature();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user