mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
some improvements in change signature dialog (IDEA-81322)
This commit is contained in:
+72
-162
@@ -1,138 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.jetbrains.plugins.groovy.refactoring.changeSignature.GrChangeSignatureDialog">
|
||||
<grid id="27dc6" binding="contentPane" layout-manager="GridLayoutManager" row-count="7" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="27dc6" binding="contentPane" layout-manager="GridLayoutManager" row-count="4" 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>
|
||||
<xy x="20" y="20" width="500" height="410"/>
|
||||
<xy x="20" y="20" width="500" height="440"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<opaque value="true"/>
|
||||
</properties>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="de28c" class="javax.swing.JLabel" binding="myNameLabel" custom-create="true">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="&Name:"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="c4b75" class="javax.swing.JLabel" binding="myReturnTypeLabel" custom-create="true">
|
||||
<constraints>
|
||||
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Return &type:"/>
|
||||
</properties>
|
||||
</component>
|
||||
<grid id="f46e6" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="90417" binding="myDelegatePanel" layout-manager="GridLayoutManager" row-count="1" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="6ca6f" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<clientProperties>
|
||||
<BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$PlainSmallWithoutIndent"/>
|
||||
</clientProperties>
|
||||
<border type="none" title="Parameters">
|
||||
<font/>
|
||||
</border>
|
||||
<children>
|
||||
<scrollpane id="8fed2" class="com.intellij.ui.components.JBScrollPane">
|
||||
<constraints border-constraint="Center"/>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="3e44a" class="com.intellij.ui.table.JBTable" binding="myParameterTable" custom-create="true">
|
||||
<constraints/>
|
||||
<properties/>
|
||||
</component>
|
||||
</children>
|
||||
</scrollpane>
|
||||
<grid id="8f1a6" binding="myParameterButtonPanel" custom-create="true" layout-manager="GridLayoutManager" row-count="1" 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 border-constraint="East"/>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="b2211" layout-manager="GridLayoutManager" row-count="4" 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="0" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="0" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<clientProperties>
|
||||
<BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"/>
|
||||
</clientProperties>
|
||||
<border type="none" title="Visibility"/>
|
||||
<children>
|
||||
<component id="ea67d" class="javax.swing.JRadioButton" binding="myPublicRadioButton" 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>
|
||||
<enabled value="true"/>
|
||||
<selected value="true"/>
|
||||
<text value="Pu&blic"/>
|
||||
</properties>
|
||||
</component>
|
||||
<vspacer id="4fecc">
|
||||
<constraints>
|
||||
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
<component id="8f6d2" class="javax.swing.JRadioButton" binding="myPrivateRadioButton" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="0" 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="Pri&vate"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="2093c" class="javax.swing.JRadioButton" binding="myProtectedRadioButton" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="1" 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="Pr&otected"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
<component id="eb288" class="com.intellij.ui.EditorTextField" binding="myNameField" custom-create="true">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="7" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="f22ad" class="com.intellij.ui.EditorTextField" binding="myReturnTypeField" custom-create="true">
|
||||
<constraints>
|
||||
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="7" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<grid id="1d25b" binding="myDelegatePanel" layout-manager="GridLayoutManager" row-count="1" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="a44c3" class="javax.swing.JLabel">
|
||||
<component id="8e2c2" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
@@ -140,7 +26,7 @@
|
||||
<text value="Method calls:"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="74bc2" class="javax.swing.JRadioButton" binding="myModifyRadioButton" default-binding="true">
|
||||
<component id="66600" class="javax.swing.JRadioButton" binding="myModifyRadioButton" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
@@ -149,7 +35,7 @@
|
||||
<text value="&Modify"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="6dfb7" class="javax.swing.JRadioButton" binding="myDelegateRadioButton" default-binding="true">
|
||||
<component id="68c5d" class="javax.swing.JRadioButton" binding="myDelegateRadioButton" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
@@ -159,69 +45,89 @@
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="7947f" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="7016f" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="36882" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<component id="6b989" class="org.jetbrains.plugins.groovy.refactoring.ui.GroovyComboboxVisibilityPanel" binding="myVisibilityPanel">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<grid id="c5b83" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<clientProperties>
|
||||
<BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$PlainSmallWithoutIndent"/>
|
||||
</clientProperties>
|
||||
<border type="none" title="Signature Preview"/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="97035" class="javax.swing.JTextArea" binding="mySignatureLabel">
|
||||
<component id="19343" class="javax.swing.JLabel" binding="myReturnTypeLabel" custom-create="true">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="6" anchor="0" fill="3" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="50"/>
|
||||
</grid>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<background color="-986896"/>
|
||||
<text value="Return &type:"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="6523b" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<clientProperties>
|
||||
<BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$PlainSmallWithoutIndent"/>
|
||||
</clientProperties>
|
||||
<border type="none" title="Exceptions"/>
|
||||
<children>
|
||||
<scrollpane id="45e94" class="com.intellij.ui.components.JBScrollPane">
|
||||
<constraints border-constraint="Center"/>
|
||||
<component id="8c5d4" class="com.intellij.ui.EditorTextField" binding="myReturnTypeField" custom-create="true">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="7" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="d4206" class="com.intellij.ui.table.JBTable" binding="myExceptionsTable" custom-create="true">
|
||||
<constraints/>
|
||||
<properties/>
|
||||
</component>
|
||||
</children>
|
||||
</scrollpane>
|
||||
<grid id="79e19" binding="myExceptionsButtonPanel" custom-create="true" layout-manager="GridLayoutManager" row-count="1" 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 border-constraint="East"/>
|
||||
</component>
|
||||
<component id="776b3" class="javax.swing.JLabel" binding="myNameLabel" custom-create="true">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="&Name:"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="84b7d" class="com.intellij.ui.EditorTextField" binding="myNameField" custom-create="true">
|
||||
<constraints>
|
||||
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="7" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="3bb42" layout-manager="GridLayoutManager" row-count="1" 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="3" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<clientProperties>
|
||||
<BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$PlainSmallWithoutIndent"/>
|
||||
</clientProperties>
|
||||
<border type="none" title="Signature preview">
|
||||
<font/>
|
||||
</border>
|
||||
<children>
|
||||
<component id="bea7" class="com.intellij.refactoring.ui.MethodSignatureComponent" binding="mySignaturePreview" custom-create="true">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false">
|
||||
<minimum-size width="-1" height="130"/>
|
||||
<preferred-size width="-1" height="130"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<component id="ac58e" class="javax.swing.JComponent" binding="myTabPanel" custom-create="true">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<buttonGroups>
|
||||
@@ -234,5 +140,9 @@
|
||||
<member id="74bc2"/>
|
||||
<member id="6dfb7"/>
|
||||
</group>
|
||||
<group name="delegateGroup">
|
||||
<member id="66600"/>
|
||||
<member id="68c5d"/>
|
||||
</group>
|
||||
</buttonGroups>
|
||||
</form>
|
||||
|
||||
+104
-85
@@ -16,6 +16,8 @@
|
||||
package org.jetbrains.plugins.groovy.refactoring.changeSignature;
|
||||
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.event.DocumentEvent;
|
||||
import com.intellij.openapi.editor.event.DocumentListener;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.*;
|
||||
@@ -25,33 +27,38 @@ import com.intellij.refactoring.changeSignature.ExceptionsTableModel;
|
||||
import com.intellij.refactoring.changeSignature.ThrownExceptionInfo;
|
||||
import com.intellij.refactoring.ui.CodeFragmentTableCellRenderer;
|
||||
import com.intellij.refactoring.ui.JavaCodeFragmentTableCellEditor;
|
||||
import com.intellij.refactoring.ui.MethodSignatureComponent;
|
||||
import com.intellij.refactoring.ui.RefactoringDialog;
|
||||
import com.intellij.refactoring.util.CanonicalTypes;
|
||||
import com.intellij.refactoring.util.CommonRefactoringUtil;
|
||||
import com.intellij.ui.EditableRowTable;
|
||||
import com.intellij.ui.EditorTextField;
|
||||
import com.intellij.ui.TabbedPaneWrapper;
|
||||
import com.intellij.ui.TableUtil;
|
||||
import com.intellij.ui.ToolbarDecorator;
|
||||
import com.intellij.ui.table.JBTable;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.VisibilityUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.debugger.fragments.GroovyCodeFragment;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifier;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeElement;
|
||||
import org.jetbrains.plugins.groovy.refactoring.GroovyRefactoringBundle;
|
||||
import org.jetbrains.plugins.groovy.refactoring.ui.GrCodeFragmentTableCellEditor;
|
||||
import org.jetbrains.plugins.groovy.refactoring.ui.GrCodeFragmentTableCellRenderer;
|
||||
import org.jetbrains.plugins.groovy.refactoring.ui.GrMethodSignatureComponent;
|
||||
import org.jetbrains.plugins.groovy.refactoring.ui.GroovyComboboxVisibilityPanel;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ChangeListener;
|
||||
import javax.swing.event.TableModelEvent;
|
||||
import javax.swing.event.TableModelListener;
|
||||
import javax.swing.table.TableColumnModel;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.List;
|
||||
|
||||
import static org.jetbrains.plugins.groovy.refactoring.GroovyRefactoringBundle.message;
|
||||
@@ -62,62 +69,49 @@ import static org.jetbrains.plugins.groovy.refactoring.GroovyRefactoringBundle.m
|
||||
public class GrChangeSignatureDialog extends RefactoringDialog {
|
||||
private EditorTextField myNameField;
|
||||
private EditorTextField myReturnTypeField;
|
||||
private JRadioButton myPublicRadioButton;
|
||||
private JRadioButton myProtectedRadioButton;
|
||||
private JRadioButton myPrivateRadioButton;
|
||||
private JBTable myParameterTable;
|
||||
private JPanel contentPane;
|
||||
private JTextArea mySignatureLabel;
|
||||
private JLabel myNameLabel;
|
||||
private JLabel myReturnTypeLabel;
|
||||
@SuppressWarnings({"UnusedDeclaration"}) private JRadioButton myModifyRadioButton;
|
||||
private JRadioButton myDelegateRadioButton;
|
||||
@SuppressWarnings({"UnusedDeclaration"}) private JPanel myParameterButtonPanel;
|
||||
private JBTable myExceptionsTable;
|
||||
@SuppressWarnings({"UnusedDeclaration"}) private JPanel myExceptionsButtonPanel;
|
||||
private JPanel myDelegatePanel;
|
||||
private GroovyComboboxVisibilityPanel myVisibilityPanel;
|
||||
private MethodSignatureComponent mySignaturePreview;
|
||||
private JComponent myTabPanel;
|
||||
private GrParameterTableModel myParameterModel;
|
||||
private GrMethod myMethod;
|
||||
private PsiTypeCodeFragment myReturnTypeCodeFragment;
|
||||
private GroovyCodeFragment myNameCodeFragment;
|
||||
private ExceptionsTableModel myExceptionTableModel;
|
||||
private static final String INDENT = " ";
|
||||
|
||||
public GrChangeSignatureDialog(@NotNull Project project, GrMethod method) {
|
||||
super(project, true);
|
||||
myMethod = method;
|
||||
setTitle(ChangeSignatureHandler.REFACTORING_NAME);
|
||||
|
||||
init();
|
||||
updateSignature();
|
||||
ActionListener listener = new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
updateSignature();
|
||||
}
|
||||
};
|
||||
myPublicRadioButton.addActionListener(listener);
|
||||
myPrivateRadioButton.addActionListener(listener);
|
||||
myProtectedRadioButton.addActionListener(listener);
|
||||
}
|
||||
|
||||
protected void init() {
|
||||
super.init();
|
||||
|
||||
setTitle(ChangeSignatureHandler.REFACTORING_NAME);
|
||||
|
||||
final PsiClass psiClass = myMethod.getContainingClass();
|
||||
if (psiClass == null) return;
|
||||
if (psiClass.isInterface()) {
|
||||
myDelegatePanel.setVisible(false);
|
||||
}
|
||||
|
||||
if (myMethod.hasModifierProperty(GrModifier.PRIVATE)) {
|
||||
myPrivateRadioButton.setSelected(true);
|
||||
} else if (myMethod.hasModifierProperty(GrModifier.PROTECTED)) {
|
||||
myProtectedRadioButton.setSelected(true);
|
||||
} else if (myMethod.hasModifierProperty(GrModifier.PUBLIC)) {
|
||||
myPublicRadioButton.setSelected(true);
|
||||
}
|
||||
}
|
||||
myVisibilityPanel.setVisibility(VisibilityUtil.getVisibilityModifier(myMethod.getModifierList()));
|
||||
|
||||
private void stopEditing() {
|
||||
TableUtil.stopEditing(myParameterTable);
|
||||
myVisibilityPanel.addListener(new ChangeListener() {
|
||||
@Override
|
||||
public void stateChanged(ChangeEvent e) {
|
||||
updateSignature();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -128,20 +122,40 @@ public class GrChangeSignatureDialog extends RefactoringDialog {
|
||||
|
||||
private void createUIComponents() {
|
||||
createNameAndReturnTypeEditors();
|
||||
createParametersPanel();
|
||||
createExceptionsPanel();
|
||||
createSignaturePreview();
|
||||
|
||||
JPanel paramPanel = createParametersPanel();
|
||||
paramPanel.setBorder(new EmptyBorder(0, 0, 0, 0));
|
||||
JPanel exceptionPanel = createExceptionsPanel();
|
||||
exceptionPanel.setBorder(new EmptyBorder(0, 0, 0, 0));
|
||||
|
||||
final TabbedPaneWrapper tabbedPane = new TabbedPaneWrapper(getDisposable());
|
||||
tabbedPane.addTab("Parameters", paramPanel);
|
||||
tabbedPane.addTab("Exceptions", exceptionPanel);
|
||||
|
||||
myTabPanel = tabbedPane.getComponent();
|
||||
|
||||
for (JComponent c : UIUtil.findComponentsOfType(myTabPanel, JComponent.class)) {
|
||||
c.setFocusCycleRoot(false);
|
||||
c.setFocusTraversalPolicy(null);
|
||||
}
|
||||
}
|
||||
|
||||
private void createSignaturePreview() {
|
||||
mySignaturePreview = new GrMethodSignatureComponent("", myProject);
|
||||
}
|
||||
|
||||
private void createNameAndReturnTypeEditors() {
|
||||
myNameCodeFragment = new GroovyCodeFragment(myProject, "");
|
||||
myNameField = new EditorTextField(PsiDocumentManager.getInstance(myProject).getDocument(myNameCodeFragment), myProject,
|
||||
myNameCodeFragment.getFileType());
|
||||
GroovyCodeFragment nameCodeFragment = new GroovyCodeFragment(myProject, "");
|
||||
myNameField = new EditorTextField(PsiDocumentManager.getInstance(myProject).getDocument(nameCodeFragment), myProject,
|
||||
nameCodeFragment.getFileType());
|
||||
|
||||
final JavaCodeFragmentFactory factory = JavaCodeFragmentFactory.getInstance(myProject);
|
||||
myReturnTypeCodeFragment = factory.createTypeCodeFragment("", myMethod, true, JavaCodeFragmentFactory.ALLOW_VOID);
|
||||
final Document document = PsiDocumentManager.getInstance(myProject).getDocument(myReturnTypeCodeFragment);
|
||||
myReturnTypeField = new EditorTextField(document, myProject, myReturnTypeCodeFragment.getFileType());
|
||||
|
||||
|
||||
myNameField.setText(myMethod.getName());
|
||||
final GrTypeElement element = myMethod.getReturnTypeElementGroovy();
|
||||
if (element != null) {
|
||||
@@ -153,10 +167,23 @@ public class GrChangeSignatureDialog extends RefactoringDialog {
|
||||
|
||||
myNameLabel = new JLabel();
|
||||
myNameLabel.setLabelFor(myNameField);
|
||||
|
||||
final DocumentListener listener = new DocumentListener() {
|
||||
@Override
|
||||
public void beforeDocumentChange(DocumentEvent event) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void documentChanged(DocumentEvent event) {
|
||||
updateSignature();
|
||||
}
|
||||
};
|
||||
myReturnTypeField.addDocumentListener(listener);
|
||||
myNameField.addDocumentListener(listener);
|
||||
}
|
||||
|
||||
private void createParametersPanel() {
|
||||
myParameterModel = new GrParameterTableModel(myMethod, this, myProject);
|
||||
private JPanel createParametersPanel() {
|
||||
myParameterModel = new GrParameterTableModel(myMethod, myProject);
|
||||
myParameterModel.addTableModelListener(new TableModelListener() {
|
||||
public void tableChanged(TableModelEvent e) {
|
||||
updateSignature();
|
||||
@@ -165,8 +192,6 @@ public class GrChangeSignatureDialog extends RefactoringDialog {
|
||||
myParameterTable = new JBTable(myParameterModel);
|
||||
myParameterTable.setPreferredScrollableViewportSize(new Dimension(550, myParameterTable.getRowHeight() * 8));
|
||||
|
||||
myParameterButtonPanel = EditableRowTable.createButtonsTable(myParameterTable, myParameterModel, true);
|
||||
|
||||
myParameterTable.setCellSelectionEnabled(true);
|
||||
final TableColumnModel columnModel = myParameterTable.getColumnModel();
|
||||
columnModel.getColumn(0).setCellRenderer(new CodeFragmentTableCellRenderer(myProject));
|
||||
@@ -183,9 +208,18 @@ public class GrChangeSignatureDialog extends RefactoringDialog {
|
||||
myParameterTable.setRowSelectionInterval(0, 0);
|
||||
myParameterTable.setColumnSelectionInterval(0, 0);
|
||||
}
|
||||
|
||||
myParameterModel.addTableModelListener(new TableModelListener() {
|
||||
@Override
|
||||
public void tableChanged(TableModelEvent e) {
|
||||
updateSignature();
|
||||
}
|
||||
});
|
||||
|
||||
return ToolbarDecorator.createDecorator(myParameterTable).createPanel();
|
||||
}
|
||||
|
||||
private void createExceptionsPanel() {
|
||||
private JPanel createExceptionsPanel() {
|
||||
myExceptionTableModel = new ExceptionsTableModel(myMethod);
|
||||
myExceptionTableModel.setTypeInfos(myMethod);
|
||||
myExceptionTableModel.addTableModelListener(new TableModelListener() {
|
||||
@@ -193,24 +227,30 @@ public class GrChangeSignatureDialog extends RefactoringDialog {
|
||||
updateSignature();
|
||||
}
|
||||
});
|
||||
myExceptionsTable = new JBTable(myExceptionTableModel);
|
||||
myExceptionsTable.setPreferredScrollableViewportSize(new Dimension(200, myExceptionsTable.getRowHeight() * 8));
|
||||
JBTable exceptionTable = new JBTable(myExceptionTableModel);
|
||||
exceptionTable.setPreferredScrollableViewportSize(new Dimension(200, exceptionTable.getRowHeight() * 8));
|
||||
|
||||
myExceptionsButtonPanel = ToolbarDecorator.createDecorator(myExceptionsTable).createPanel();
|
||||
|
||||
myExceptionsTable.getColumnModel().getColumn(0).setCellRenderer(new CodeFragmentTableCellRenderer(myProject));
|
||||
myExceptionsTable.getColumnModel().getColumn(0).setCellEditor(new JavaCodeFragmentTableCellEditor(myProject));
|
||||
exceptionTable.getColumnModel().getColumn(0).setCellRenderer(new CodeFragmentTableCellRenderer(myProject));
|
||||
exceptionTable.getColumnModel().getColumn(0).setCellEditor(new JavaCodeFragmentTableCellEditor(myProject));
|
||||
|
||||
if (myExceptionTableModel.getRowCount() > 0) {
|
||||
myExceptionsTable.setRowSelectionInterval(0, 0);
|
||||
myExceptionsTable.setColumnSelectionInterval(0, 0);
|
||||
exceptionTable.setRowSelectionInterval(0, 0);
|
||||
exceptionTable.setColumnSelectionInterval(0, 0);
|
||||
}
|
||||
|
||||
myExceptionTableModel.addTableModelListener(new TableModelListener() {
|
||||
@Override
|
||||
public void tableChanged(TableModelEvent e) {
|
||||
updateSignature();
|
||||
}
|
||||
});
|
||||
|
||||
return ToolbarDecorator.createDecorator(exceptionTable).createPanel();
|
||||
}
|
||||
|
||||
|
||||
private void updateSignature() {
|
||||
mySignatureLabel.setText(generateSignatureText());
|
||||
mySignaturePreview.setSignature(generateSignatureText());
|
||||
}
|
||||
|
||||
private String generateSignatureText() {
|
||||
@@ -218,16 +258,10 @@ public class GrChangeSignatureDialog extends RefactoringDialog {
|
||||
String type = myReturnTypeField.getText().trim();
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
if (myPublicRadioButton.isSelected() && type.length() == 0) {
|
||||
builder.append(GrModifier.DEF);
|
||||
builder.append(myVisibilityPanel.getVisibility()).append(' ');
|
||||
if (!type.isEmpty()) {
|
||||
builder.append(type).append(' ');
|
||||
}
|
||||
if (myPrivateRadioButton.isSelected()) {
|
||||
builder.append(GrModifier.PRIVATE).append(' ');
|
||||
}
|
||||
else if (myProtectedRadioButton.isSelected()) {
|
||||
builder.append(GrModifier.PROTECTED).append(' ');
|
||||
}
|
||||
builder.append(type).append(' ');
|
||||
builder.append(name).append('(');
|
||||
|
||||
final List<GrTableParameterInfo> infos = myParameterModel.getParameterInfos();
|
||||
@@ -281,17 +315,8 @@ public class GrChangeSignatureDialog extends RefactoringDialog {
|
||||
return;
|
||||
}
|
||||
|
||||
stopEditing();
|
||||
String modifier = "";
|
||||
if (myPublicRadioButton.isSelected()) {
|
||||
modifier = GrModifier.PUBLIC;
|
||||
}
|
||||
else if (myPrivateRadioButton.isSelected()) {
|
||||
modifier = GrModifier.PRIVATE;
|
||||
}
|
||||
else if (myProtectedRadioButton.isSelected()) {
|
||||
modifier = GrModifier.PROTECTED;
|
||||
}
|
||||
TableUtil.stopEditing(myParameterTable);
|
||||
String modifier = myVisibilityPanel.getVisibility();
|
||||
|
||||
PsiType returnType = null;
|
||||
try {
|
||||
@@ -310,12 +335,10 @@ public class GrChangeSignatureDialog extends RefactoringDialog {
|
||||
}
|
||||
});
|
||||
final ThrownExceptionInfo[] exceptionInfos = myExceptionTableModel.getThrownExceptions();
|
||||
invokeRefactoring(new GrChangeSignatureProcessor(myProject, new GrChangeInfoImpl(myMethod, modifier, returnType == null
|
||||
? null
|
||||
: CanonicalTypes
|
||||
.createTypeWrapper(returnType),
|
||||
newName, parameterInfos, exceptionInfos,
|
||||
myDelegateRadioButton.isSelected())));
|
||||
final CanonicalTypes.Type type = returnType == null ? null : CanonicalTypes.createTypeWrapper(returnType);
|
||||
final GrChangeInfoImpl info =
|
||||
new GrChangeInfoImpl(myMethod, modifier, type, newName, parameterInfos, exceptionInfos, myDelegateRadioButton.isSelected());
|
||||
invokeRefactoring(new GrChangeSignatureProcessor(myProject, info));
|
||||
}
|
||||
|
||||
private String getNewName() {
|
||||
@@ -323,7 +346,7 @@ public class GrChangeSignatureDialog extends RefactoringDialog {
|
||||
}
|
||||
|
||||
private void showErrorHint(String hint) {
|
||||
CommonRefactoringUtil.showErrorHint(myProject, null, hint, GroovyRefactoringBundle.message("incorrect.data"), HelpID.CHANGE_SIGNATURE);
|
||||
CommonRefactoringUtil.showErrorHint(myProject, null, hint, message("incorrect.data"), HelpID.CHANGE_SIGNATURE);
|
||||
}
|
||||
|
||||
private boolean isGroovyMethodName(String name) {
|
||||
@@ -375,24 +398,24 @@ public class GrChangeSignatureDialog extends RefactoringDialog {
|
||||
try {
|
||||
PsiType type = typeCodeFragment.getType();
|
||||
if (!(type instanceof PsiClassType)) {
|
||||
showErrorHint(GroovyRefactoringBundle.message("changeSignature.wrong.type.for.exception", typeCodeFragment.getText()));
|
||||
showErrorHint(message("changeSignature.wrong.type.for.exception", typeCodeFragment.getText()));
|
||||
return false;
|
||||
}
|
||||
|
||||
PsiClassType throwable = JavaPsiFacade.getInstance(myMethod.getProject()).getElementFactory()
|
||||
.createTypeByFQClassName("java.lang.Throwable", myMethod.getResolveScope());
|
||||
if (!throwable.isAssignableFrom(type)) {
|
||||
showErrorHint(GroovyRefactoringBundle.message("changeSignature.not.throwable.type", typeCodeFragment.getText()));
|
||||
showErrorHint(message("changeSignature.not.throwable.type", typeCodeFragment.getText()));
|
||||
return false;
|
||||
}
|
||||
exceptionInfo.setType((PsiClassType)type);
|
||||
}
|
||||
catch (PsiTypeCodeFragment.TypeSyntaxException e) {
|
||||
showErrorHint(GroovyRefactoringBundle.message("changeSignature.wrong.type.for.exception", typeCodeFragment.getText()));
|
||||
showErrorHint(message("changeSignature.wrong.type.for.exception", typeCodeFragment.getText()));
|
||||
return false;
|
||||
}
|
||||
catch (PsiTypeCodeFragment.NoTypeException e) {
|
||||
showErrorHint(GroovyRefactoringBundle.message("changeSignature.no.type.for.exception"));
|
||||
showErrorHint(message("changeSignature.no.type.for.exception"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -412,8 +435,4 @@ public class GrChangeSignatureDialog extends RefactoringDialog {
|
||||
return true; //Groovy accepts methods and parameters without explicit type
|
||||
}
|
||||
}
|
||||
|
||||
public GrParameterTableModel getParameterModel() {
|
||||
return myParameterModel;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-5
@@ -17,7 +17,7 @@ package org.jetbrains.plugins.groovy.refactoring.changeSignature;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiCodeFragment;
|
||||
import com.intellij.ui.RowEditableTableModel;
|
||||
import com.intellij.util.ui.EditableModel;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.debugger.fragments.GroovyCodeFragment;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter;
|
||||
@@ -31,15 +31,13 @@ import java.util.List;
|
||||
/**
|
||||
* @author Maxim.Medvedev
|
||||
*/
|
||||
public class GrParameterTableModel extends AbstractTableModel implements RowEditableTableModel {
|
||||
public class GrParameterTableModel extends AbstractTableModel implements EditableModel {
|
||||
private final List<GrTableParameterInfo> infos;
|
||||
private final GrMethod myMethod;
|
||||
private final GrChangeSignatureDialog myDialog;
|
||||
private final Project myProject;
|
||||
|
||||
public GrParameterTableModel(GrMethod method, GrChangeSignatureDialog dialog, Project project) {
|
||||
public GrParameterTableModel(GrMethod method, Project project) {
|
||||
myMethod = method;
|
||||
myDialog = dialog;
|
||||
final GrParameter[] parameters = myMethod.getParameters();
|
||||
infos = new ArrayList<GrTableParameterInfo>(parameters.length);
|
||||
for (int i = 0; i < parameters.length; i++) {
|
||||
|
||||
+4
-2
@@ -16,6 +16,7 @@
|
||||
package org.jetbrains.plugins.groovy.refactoring.ui;
|
||||
|
||||
import com.intellij.refactoring.ui.ComboBoxVisibilityPanel;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifier;
|
||||
|
||||
import static com.intellij.psi.PsiModifier.*;
|
||||
import static com.intellij.util.VisibilityUtil.toPresentableText;
|
||||
@@ -24,12 +25,13 @@ import static com.intellij.util.VisibilityUtil.toPresentableText;
|
||||
* @author Max Medvedev
|
||||
*/
|
||||
public class GroovyComboboxVisibilityPanel extends ComboBoxVisibilityPanel {
|
||||
private static final String[] MODIFIERS = {PRIVATE, PROTECTED, PUBLIC};
|
||||
private static final String[] MODIFIERS = {PRIVATE, PROTECTED, PUBLIC, GrModifier.DEF};
|
||||
|
||||
private static final String[] PRESENTABLE_NAMES = {
|
||||
toPresentableText(PRIVATE),
|
||||
toPresentableText(PROTECTED),
|
||||
toPresentableText(PUBLIC)
|
||||
toPresentableText(PUBLIC),
|
||||
GrModifier.DEF
|
||||
};
|
||||
|
||||
public GroovyComboboxVisibilityPanel() {
|
||||
|
||||
Reference in New Issue
Block a user