complete methods ans simple class/package completion for run configurations (IDEA-51017)

This commit is contained in:
anna
2011-07-19 08:14:34 +04:00
parent 025293c8bb
commit fa62b4341c
14 changed files with 333 additions and 174 deletions
@@ -1,27 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.execution.applet.AppletConfigurable">
<grid id="e5f4d" binding="myWholePanel" row-count="7" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="e5f4d" binding="myWholePanel" layout-manager="GridLayoutManager" row-count="7" 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="133" y="39" width="454" height="596"/>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<grid id="ccef6" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="ccef6" 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>
<xy x="0" y="0" width="454" height="22"/>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="0" anchor="0" fill="1"/>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="fa258" class="javax.swing.JRadioButton" binding="myMainClass">
<constraints>
<xy x="0" y="0" width="84" height="22"/>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0"/>
<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>
<selected value="true"/>
@@ -30,8 +27,7 @@
</component>
<component id="74d77" class="javax.swing.JRadioButton" binding="myURL">
<constraints>
<xy x="94" y="0" width="46" height="22"/>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0"/>
<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>
<properties>
<text resource-bundle="messages/ExecutionBundle" key="applet.configuration.url.label"/>
@@ -41,8 +37,7 @@
</grid>
<component id="5dbf7" class="com.intellij.openapi.ui.LabeledComponent" binding="myPolicyFile">
<constraints>
<xy x="0" y="407" width="454" height="39"/>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="1" fill="1"/>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="1" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<componentClass value="com.intellij.openapi.ui.TextFieldWithBrowseButton"/>
@@ -52,8 +47,7 @@
</component>
<component id="67632" class="com.intellij.openapi.ui.LabeledComponent" binding="myVMParameters">
<constraints>
<xy x="0" y="451" width="454" height="21"/>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="1" fill="1">
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="1" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="400" height="-1"/>
</grid>
</constraints>
@@ -65,8 +59,7 @@
</component>
<component id="eac49" class="com.intellij.openapi.ui.LabeledComponent" binding="myModule">
<constraints>
<xy x="0" y="477" width="454" height="46"/>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="1" fill="1"/>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="1" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<componentClass value="javax.swing.JComboBox"/>
@@ -74,31 +67,25 @@
<text resource-bundle="messages/ExecutionBundle" key="applet.configuration.use.classpath.and.jdk.of.module.label"/>
</properties>
</component>
<grid id="c178e" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="c178e" layout-manager="GridLayoutManager" row-count="2" 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="0" y="27" width="454" height="375"/>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3"/>
<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"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<grid id="dbe39" binding="myHTMLOptions" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="5" vgap="-1">
<grid id="dbe39" binding="myHTMLOptions" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="5" vgap="-1">
<margin top="5" left="5" bottom="5" right="5"/>
<constraints>
<xy x="0" y="0" width="454" height="56"/>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="3" anchor="1" fill="1"/>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="3" anchor="1" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="etched" title-resource-bundle="messages/ExecutionBundle" title-key="applet.configuration.url.border"/>
<clientProperties>
<BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory"/>
</clientProperties>
<children>
<component id="a2b70" class="javax.swing.JLabel" binding="myHtmlFileLabel">
<constraints>
<xy x="11" y="28" width="74" height="14"/>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0"/>
<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>
<text resource-bundle="messages/ExecutionBundle" key="applet.configuration.url.html.file.label"/>
@@ -106,8 +93,7 @@
</component>
<component id="9aa99" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="myHtmlFile">
<constraints>
<xy x="90" y="25" width="353" height="20"/>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="3"/>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value=""/>
@@ -115,33 +101,27 @@
</component>
</children>
</grid>
<grid id="71bb1" binding="myClassOptions" row-count="4" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="7">
<grid id="71bb1" binding="myClassOptions" layout-manager="GridLayoutManager" row-count="4" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="7">
<margin top="5" left="5" bottom="5" right="5"/>
<constraints>
<xy x="0" y="61" width="454" height="314"/>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="1" fill="1"/>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="1" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<enabled value="true"/>
</properties>
<border type="etched" title-resource-bundle="messages/ExecutionBundle" title-key="applet.configuration.applet.class.border"/>
<clientProperties>
<BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory"/>
</clientProperties>
<children>
<grid id="9c777" row-count="1" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="9c777" layout-manager="GridLayoutManager" row-count="1" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="11" y="52" width="432" height="20"/>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="3" anchor="0" fill="3"/>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="575e9" class="javax.swing.JTextField" binding="myWidth">
<constraints>
<xy x="62" y="0" width="50" height="20"/>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0">
<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">
<minimum-size width="50" height="-1"/>
</grid>
</constraints>
@@ -151,8 +131,7 @@
</component>
<component id="60aa" class="javax.swing.JLabel" binding="myWidthLabel">
<constraints>
<xy x="0" y="3" width="52" height="14"/>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="4" fill="0">
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="4" fill="0" indent="0" use-parent-layout="false">
<minimum-size width="52" height="-1"/>
</grid>
</constraints>
@@ -162,8 +141,7 @@
</component>
<component id="3cd8" class="javax.swing.JLabel" binding="myHeightLabel">
<constraints>
<xy x="122" y="3" width="39" height="14"/>
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="4" fill="0"/>
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages/ExecutionBundle" key="applet.configuration.height.label"/>
@@ -171,8 +149,7 @@
</component>
<component id="16d37" class="javax.swing.JTextField" binding="myHeight">
<constraints>
<xy x="171" y="0" width="50" height="20"/>
<grid row="0" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0">
<grid row="0" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false">
<minimum-size width="50" height="-1"/>
</grid>
</constraints>
@@ -182,28 +159,25 @@
</component>
</children>
</grid>
<grid id="32908" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="32908" 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>
<xy x="11" y="106" width="432" height="197"/>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="1" fill="1"/>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="1" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<grid id="f7d4e" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="f7d4e" 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>
<xy x="357" y="0" width="75" height="197"/>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="1" anchor="0" fill="3"/>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="1" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="e3f93" class="javax.swing.JButton" binding="myAddButton">
<constraints>
<xy x="0" y="0" width="75" height="25"/>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1"/>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages/ExecutionBundle" key="button.add"/>
@@ -211,8 +185,7 @@
</component>
<component id="1e21d" class="javax.swing.JButton" binding="myRemoveButton">
<constraints>
<xy x="0" y="32" width="75" height="25"/>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1"/>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages/ExecutionBundle" key="button.remove"/>
@@ -220,17 +193,15 @@
</component>
<vspacer id="b7052">
<constraints>
<xy x="32" y="57" width="11" height="140"/>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2"/>
<grid row="2" 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>
</children>
</grid>
<xy id="814cb" binding="myTablePlace" hgap="-1" vgap="-1">
<xy id="814cb" binding="myTablePlace" layout-manager="XYLayout" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="0" y="0" width="347" height="197"/>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<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">
<preferred-size width="-1" height="100"/>
</grid>
</constraints>
@@ -240,28 +211,25 @@
</xy>
</children>
</grid>
<grid id="d9c99" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="5">
<grid id="d9c99" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="5">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="11" y="25" width="432" height="20"/>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="1" fill="1"/>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="1" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="36125" class="javax.swing.JLabel" binding="myClassNameLabel">
<constraints>
<xy x="0" y="3" width="65" height="14"/>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="4" fill="0"/>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages/ExecutionBundle" key="applet.configuration.applet.class.label"/>
</properties>
</component>
<component id="70a46" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="myClassName">
<component id="70a46" class="com.intellij.ui.EditorTextFieldWithBrowseButton" binding="myClassName" custom-create="true">
<constraints>
<xy x="75" y="0" width="357" height="20"/>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="3"/>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value=""/>
@@ -269,29 +237,26 @@
</component>
</children>
</grid>
<grid id="fcccf" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="fcccf" 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>
<xy x="11" y="79" width="432" height="20"/>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3"/>
<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>
<component id="de175" class="javax.swing.JLabel">
<constraints>
<xy x="0" y="3" width="93" height="14"/>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0"/>
<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>
<text resource-bundle="messages/ExecutionBundle" key="applet.configuration.applet.parameters.label"/>
</properties>
</component>
<xy id="c0444" hgap="-1" vgap="-1">
<xy id="c0444" layout-manager="XYLayout" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="103" y="9" width="329" height="1"/>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
<maximum-size width="-1" height="1"/>
</grid>
</constraints>
@@ -307,15 +272,14 @@
</grid>
<vspacer id="8b063">
<constraints>
<xy x="221" y="548" width="11" height="48"/>
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2"/>
<grid row="6" 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="b2d36" class="com.intellij.execution.ui.AlternativeJREPanel" binding="myAlternativeJREPanel">
<constraints>
<xy x="0" y="528" width="454" height="20"/>
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="1"/>
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
</children>
</grid>
@@ -26,6 +26,7 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.LabeledComponent;
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.ui.EditorTextFieldWithBrowseButton;
import com.intellij.ui.RawCommandLineEditor;
import com.intellij.ui.ScrollPaneFactory;
import com.intellij.ui.table.TableView;
@@ -50,7 +51,7 @@ public class AppletConfigurable extends SettingsEditor<AppletConfiguration> impl
private JPanel myHTMLOptions;
private LabeledComponent<TextFieldWithBrowseButton> myPolicyFile;
private LabeledComponent<RawCommandLineEditor> myVMParameters;
private TextFieldWithBrowseButton myClassName;
private EditorTextFieldWithBrowseButton myClassName;
private TextFieldWithBrowseButton myHtmlFile;
private JTextField myWidth;
private JTextField myHeight;
@@ -63,7 +64,7 @@ public class AppletConfigurable extends SettingsEditor<AppletConfiguration> impl
private JLabel myWidthLabel;
private JLabel myHeightLabel;
private AlternativeJREPanel myAlternativeJREPanel;
private final ButtonGroup myAppletRadioButtonGroup = new ButtonGroup();
private final ButtonGroup myAppletRadioButtonGroup;
private final Project myProject;
private final ConfigurationModuleSelector myModuleSelector;
@@ -88,7 +89,7 @@ public class AppletConfigurable extends SettingsEditor<AppletConfiguration> impl
}
}
};
private final ListTableModel<AppletConfiguration.AppletParameter> myParameters = new ListTableModel<AppletConfiguration.AppletParameter>(PARAMETER_COLUMNS);
private final ListTableModel<AppletConfiguration.AppletParameter> myParameters;
private final TableView myTable;
@NonNls
protected static final String HTTP_PREFIX = "http:/";
@@ -105,17 +106,20 @@ public class AppletConfigurable extends SettingsEditor<AppletConfiguration> impl
}
public AppletConfigurable(final Project project) {
myClassNameLabel.setLabelFor(myClassName.getTextField());
myProject = project;
myClassNameLabel.setLabelFor(myClassName.getChildComponent());
myHtmlFileLabel.setLabelFor(myHtmlFile.getTextField());
myWidthLabel.setLabelFor(myWidth);
myHeightLabel.setLabelFor(myHeight);
myProject = project;
myModuleSelector = new ConfigurationModuleSelector(project, getModuleComponent());
myTablePlace.setLayout(new BorderLayout());
myParameters = new ListTableModel<AppletConfiguration.AppletParameter>(PARAMETER_COLUMNS);
myTable = new TableView(myParameters);
myTable.getEmptyText().setText(ExecutionBundle.message("no.parameters"));
myTablePlace.add(ScrollPaneFactory.createScrollPane(myTable), BorderLayout.CENTER);
myAppletRadioButtonGroup = new ButtonGroup();
myAppletRadioButtonGroup.add(myMainClass);
myAppletRadioButtonGroup.add(myURL);
getVMParametersComponent().setDialogCaption(myVMParameters.getRawText());
@@ -192,7 +196,7 @@ public class AppletConfigurable extends SettingsEditor<AppletConfiguration> impl
return myWidth;
}
private TextFieldWithBrowseButton getClassNameComponent() {
private EditorTextFieldWithBrowseButton getClassNameComponent() {
return myClassName;
}
@@ -277,6 +281,10 @@ public class AppletConfigurable extends SettingsEditor<AppletConfiguration> impl
configuration.ALTERNATIVE_JRE_PATH_ENABLED = myAlternativeJREPanel.isPathEnabled();
}
private void createUIComponents() {
myClassName = new EditorTextFieldWithBrowseButton(myProject, true);
}
private static abstract class MyColumnInfo extends ColumnInfo<AppletConfiguration.AppletParameter, String> {
public MyColumnInfo(final String name) {
super(name);
@@ -19,12 +19,11 @@
</constraints>
<properties/>
</component>
<component id="50d08" class="com.intellij.openapi.ui.LabeledComponent" binding="myMainClass">
<component id="50d08" class="com.intellij.openapi.ui.LabeledComponent" binding="myMainClass" custom-create="true">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<componentClass value="com.intellij.openapi.ui.TextFieldWithBrowseButton$NoPathCompletion"/>
<text resource-bundle="messages/ExecutionBundle" key="application.configuration.main.class.label"/>
</properties>
</component>
@@ -26,6 +26,7 @@ import com.intellij.openapi.options.SettingsEditor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.LabeledComponent;
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
import com.intellij.ui.EditorTextFieldWithBrowseButton;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
@@ -34,16 +35,18 @@ import java.awt.event.ActionListener;
public class ApplicationConfigurable extends SettingsEditor<ApplicationConfiguration> {
private CommonJavaParametersPanel myCommonProgramParameters;
private LabeledComponent<TextFieldWithBrowseButton.NoPathCompletion> myMainClass;
private LabeledComponent<EditorTextFieldWithBrowseButton> myMainClass;
private LabeledComponent<JComboBox> myModule;
private JPanel myWholePanel;
private final ConfigurationModuleSelector myModuleSelector;
private AlternativeJREPanel myAlternativeJREPanel;
private JCheckBox myShowSwingInspectorCheckbox;
private final JreVersionDetector myVersionDetector = new JreVersionDetector();
private final JreVersionDetector myVersionDetector;
private final Project myProject;
public ApplicationConfigurable(final Project project) {
myProject = project;
myModuleSelector = new ConfigurationModuleSelector(project, myModule.getComponent());
myCommonProgramParameters.setModuleContext(myModuleSelector.getModule());
myModule.getComponent().addActionListener(new ActionListener() {
@@ -52,6 +55,7 @@ public class ApplicationConfigurable extends SettingsEditor<ApplicationConfigura
}
});
ClassBrowser.createApplicationClassBrowser(project, myModuleSelector).setField(getMainClassField());
myVersionDetector = new JreVersionDetector();
}
public void applyEditorTo(final ApplicationConfiguration configuration) throws ConfigurationException {
@@ -87,7 +91,7 @@ public class ApplicationConfigurable extends SettingsEditor<ApplicationConfigura
}
}
public TextFieldWithBrowseButton getMainClassField() {
public EditorTextFieldWithBrowseButton getMainClassField() {
return myMainClass.getComponent();
}
@@ -102,4 +106,9 @@ public class ApplicationConfigurable extends SettingsEditor<ApplicationConfigura
public void disposeEditor() {
}
private void createUIComponents() {
myMainClass = new LabeledComponent<EditorTextFieldWithBrowseButton>();
myMainClass.setComponent(new EditorTextFieldWithBrowseButton(myProject, true));
}
}
@@ -0,0 +1,50 @@
/*
* Copyright 2000-2011 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.ui;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.fileTypes.StdFileTypes;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.ComponentWithBrowseButton;
import com.intellij.psi.*;
/**
* User: anna
*/
public class EditorTextFieldWithBrowseButton extends ComponentWithBrowseButton<EditorTextField> implements TextAccessor {
public EditorTextFieldWithBrowseButton(Project project, boolean isClassAccepted) {
super(new EditorTextField(createDocument("", PsiManager.getInstance(project), isClassAccepted), project, StdFileTypes.JAVA), null);
}
private static Document createDocument(final String text, PsiManager manager, boolean isClassesAccepted) {
PsiElement defaultPackage = JavaPsiFacade.getInstance(manager.getProject()).findPackage("");
final JavaCodeFragment fragment = JavaPsiFacade.getInstance(manager.getProject()).getElementFactory()
.createReferenceCodeFragment(text, defaultPackage, true, isClassesAccepted);
fragment.setVisibilityChecker(JavaCodeFragment.VisibilityChecker.EVERYTHING_VISIBLE);
return PsiDocumentManager.getInstance(manager.getProject()).getDocument(fragment);
}
@Override
public void setText(String text) {
if (text == null) text = "";
getChildComponent().setText(text);
}
@Override
public String getText() {
return getChildComponent().getText();
}
}
@@ -17,21 +17,24 @@
package com.intellij.execution.configuration;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.ComponentWithBrowseButton;
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
import com.intellij.ui.TextAccessor;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public abstract class BrowseModuleValueActionListener implements ActionListener {
private TextFieldWithBrowseButton myField;
public abstract class BrowseModuleValueActionListener<T extends JComponent> implements ActionListener {
private ComponentWithBrowseButton<T> myField;
private final Project myProject;
protected BrowseModuleValueActionListener(final Project project) {
myProject = project;
}
public void setField(final TextFieldWithBrowseButton field) {
public void setField(final ComponentWithBrowseButton<T> field) {
myField = field;
myField.addActionListener(this);
myField.setButtonEnabled(!myProject.isDefault());
@@ -39,14 +42,14 @@ public abstract class BrowseModuleValueActionListener implements ActionListener
public void actionPerformed(final ActionEvent e) {
final String text = showDialog();
if (text != null) myField.getTextField().setText(text);
if (text != null) ((TextAccessor)myField).setText(text);
}
public String getText() {
return myField.getText();
return ((TextAccessor)myField).getText();
}
public TextFieldWithBrowseButton getField() { return myField; }
public JComponent getField() { return myField; }
@Nullable
protected abstract String showDialog();
@@ -24,12 +24,13 @@ import com.intellij.openapi.fileChooser.FileChooserDescriptor;
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory;
import com.intellij.openapi.fileChooser.FileChooserFactory;
import com.intellij.openapi.project.Project;
import com.intellij.ui.TextAccessor;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.event.ActionListener;
public class TextFieldWithBrowseButton extends ComponentWithBrowseButton<JTextField> {
public class TextFieldWithBrowseButton extends ComponentWithBrowseButton<JTextField> implements TextAccessor {
public TextFieldWithBrowseButton(){
this((ActionListener)null);
}
@@ -25,4 +25,4 @@ package com.intellij.ui;
public interface TextAccessor {
void setText(String text);
String getText();
}
}
@@ -91,16 +91,13 @@
</constraints>
<properties/>
<border type="etched" title-resource-bundle="messages/ExecutionBundle" title-key="junit.configuration.test.border"/>
<clientProperties>
<BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory"/>
</clientProperties>
<children>
<component id="b109" class="com.intellij.openapi.ui.LabeledComponent" binding="myMethod">
<component id="b109" class="com.intellij.openapi.ui.LabeledComponent" binding="myMethod" custom-create="true">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<componentClass value="com.intellij.openapi.ui.TextFieldWithBrowseButton"/>
<enabled value="true"/>
<text resource-bundle="messages/ExecutionBundle" key="junit.configuration.method.label"/>
</properties>
</component>
@@ -117,12 +114,11 @@
<properties/>
<border type="none"/>
<children>
<component id="e6070" class="com.intellij.openapi.ui.LabeledComponent" binding="myPackage">
<component id="e6070" class="com.intellij.openapi.ui.LabeledComponent" binding="myPackage" custom-create="true">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<componentClass value="com.intellij.openapi.ui.TextFieldWithBrowseButton"/>
<enabled value="true"/>
<text resource-bundle="messages/ExecutionBundle" key="junit.configuration.package.label"/>
<visible value="true"/>
@@ -192,12 +188,11 @@
<text value="Directory"/>
</properties>
</component>
<component id="89ba4" class="com.intellij.openapi.ui.LabeledComponent" binding="myClass">
<component id="89ba4" class="com.intellij.openapi.ui.LabeledComponent" binding="myClass" custom-create="true">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<componentClass value="com.intellij.openapi.ui.TextFieldWithBrowseButton"/>
<text resource-bundle="messages/ExecutionBundle" key="junit.configuration.class.label"/>
</properties>
</component>
@@ -16,7 +16,10 @@
package com.intellij.execution.junit2.configuration;
import com.intellij.codeInsight.completion.CompletionResultSet;
import com.intellij.codeInsight.lookup.LookupElementBuilder;
import com.intellij.execution.ExecutionBundle;
import com.intellij.execution.JavaExecutionUtil;
import com.intellij.execution.configuration.BrowseModuleValueActionListener;
import com.intellij.execution.junit.JUnitConfiguration;
import com.intellij.execution.junit.JUnitConfigurationType;
@@ -35,11 +38,10 @@ import com.intellij.openapi.fileChooser.FileChooserDescriptor;
import com.intellij.openapi.fileChooser.FileChooserFactory;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.options.SettingsEditor;
import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.project.IndexNotReadyException;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.FixedSizeButton;
import com.intellij.openapi.ui.LabeledComponent;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
import com.intellij.openapi.ui.*;
import com.intellij.openapi.ui.ex.MessagesEx;
import com.intellij.openapi.util.IconLoader;
import com.intellij.openapi.util.io.FileUtil;
@@ -47,8 +49,9 @@ import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiMethod;
import com.intellij.psi.PsiPackage;
import com.intellij.ui.InsertPathAction;
import com.intellij.ui.*;
import com.intellij.util.PlatformIcons;
import com.intellij.util.TextFieldCompletionProvider;
import gnu.trove.TIntArrayList;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -57,10 +60,12 @@ import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.text.Document;
import javax.swing.text.PlainDocument;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.List;
public class JUnitConfigurable extends SettingsEditor<JUnitConfiguration> {
@@ -79,11 +84,11 @@ public class JUnitConfigurable extends SettingsEditor<JUnitConfiguration> {
private JRadioButton myTestPatternButton;
private JRadioButton myTestDirButton;
private JComponent myPackagePanel;
private LabeledComponent<TextFieldWithBrowseButton> myPackage;
private LabeledComponent<EditorTextFieldWithBrowseButton> myPackage;
private LabeledComponent<TextFieldWithBrowseButton> myDir;
private LabeledComponent<JPanel> myPattern;
private LabeledComponent<TextFieldWithBrowseButton> myClass;
private LabeledComponent<TextFieldWithBrowseButton> myMethod;
private LabeledComponent<EditorTextFieldWithBrowseButton> myClass;
private LabeledComponent<EditorTextFieldWithBrowseButton> myMethod;
// Fields
private JPanel myWholePanel;
@@ -107,8 +112,10 @@ public class JUnitConfigurable extends SettingsEditor<JUnitConfiguration> {
@NonNls private static final String KLASS = "class";
private static final String[] FORK_MODE_ALL = {NONE, METHOD, KLASS};
private static final String[] FORK_MODE = {NONE, METHOD};
private Project myProject;
public JUnitConfigurable(final Project project) {
myProject = project;
myModel = new JUnitConfigurationModel(project);
myModuleSelector = new ConfigurationModuleSelector(project, getModulesComponent());
myCommonJavaParameters.setModuleContext(myModuleSelector.getModule());
@@ -257,7 +264,7 @@ public class JUnitConfigurable extends SettingsEditor<JUnitConfiguration> {
myForkCb.setModel(new DefaultComboBoxModel(FORK_MODE_ALL));
myForkCb.setSelectedItem(selectedItem);
}
else if (myClassButton.isSelected()){
else if (myClassButton.isSelected()) {
myPackagePanel.setVisible(false);
myPattern.setVisible(false);
myDir.setVisible(false);
@@ -299,14 +306,24 @@ public class JUnitConfigurable extends SettingsEditor<JUnitConfiguration> {
for (int i = 0; i < myTestLocations.length; i++) {
final LabeledComponent testLocation = getTestLocation(i);
final JComponent component = testLocation.getComponent();
final TextFieldWithBrowseButton field;
final ComponentWithBrowseButton field;
final Object document;
if (component instanceof TextFieldWithBrowseButton) {
field = (TextFieldWithBrowseButton)component;
} else {
document = new PlainDocument();
((TextFieldWithBrowseButton)field).getTextField().setDocument((Document)document);
myModel.setJUnitDocument(i, document);
} else if (component instanceof EditorTextFieldWithBrowseButton) {
field = (ComponentWithBrowseButton)component;
document = ((EditorTextField)field.getChildComponent()).getDocument();
myModel.setJUnitDocument(i, document);
}
else {
field = myPatternTextField;
document = new PlainDocument();
((TextFieldWithBrowseButton)field).getTextField().setDocument((Document)document);
myModel.setJUnitDocument(i, document);
}
final Document document = myModel.getJUnitDocument(i);
field.getTextField().setDocument(document);
myBrowsers[i].setField(field);
}
}
@@ -315,6 +332,35 @@ public class JUnitConfigurable extends SettingsEditor<JUnitConfiguration> {
return myTestLocations[index];
}
private void createUIComponents() {
myPackage = new LabeledComponent<EditorTextFieldWithBrowseButton>();
myPackage.setComponent(new EditorTextFieldWithBrowseButton(myProject, false));
myClass = new LabeledComponent<EditorTextFieldWithBrowseButton>();
myClass.setComponent(new EditorTextFieldWithBrowseButton(myProject, true));
myMethod = new LabeledComponent<EditorTextFieldWithBrowseButton>();
final EditorTextFieldWithBrowseButton textFieldWithBrowseButton = new EditorTextFieldWithBrowseButton(myProject, true);
new TextFieldCompletionProvider() {
@Override
protected void addCompletionVariants(@NotNull String text, int offset, @NotNull String prefix, @NotNull CompletionResultSet result) {
final String className = getClassName();
if (className.trim().length() == 0) {
return;
}
final PsiClass testClass = getModuleSelector().findClass(className);
if (testClass == null) return;
final JUnitUtil.TestMethodFilter filter = new JUnitUtil.TestMethodFilter(testClass);
for (PsiMethod psiMethod : testClass.getAllMethods()) {
if (filter.value(psiMethod)) {
result.addElement(LookupElementBuilder.create(psiMethod.getName()));
}
}
}
}.apply(textFieldWithBrowseButton.getChildComponent());
myMethod.setComponent(textFieldWithBrowseButton);
}
private static void addRadioButtonsListeners(final JRadioButton[] radioButtons, ChangeListener listener) {
final ButtonGroup group = new ButtonGroup();
for (final JRadioButton radioButton : radioButtons) {
@@ -405,9 +451,12 @@ public class JUnitConfigurable extends SettingsEditor<JUnitConfiguration> {
}
final ClassFilter.ClassFilterWithScope classFilter;
try {
final JUnitConfiguration configurationCopy = new JUnitConfiguration(ExecutionBundle.message("default.junit.configuration.name"), getProject(), JUnitConfigurationType.getInstance().getConfigurationFactories()[0]);
final JUnitConfiguration configurationCopy =
new JUnitConfiguration(ExecutionBundle.message("default.junit.configuration.name"), getProject(),
JUnitConfigurationType.getInstance().getConfigurationFactories()[0]);
applyEditorTo(configurationCopy);
classFilter = TestClassFilter.create(configurationCopy.getTestObject().getSourceScope(), configurationCopy.getConfigurationModule().getModule());
classFilter = TestClassFilter
.create(configurationCopy.getTestObject().getSourceScope(), configurationCopy.getConfigurationModule().getModule());
}
catch (JUnitUtil.NoJUnitException e) {
throw NoFilterException.noJUnitInModule(module);
@@ -424,12 +473,14 @@ public class JUnitConfigurable extends SettingsEditor<JUnitConfiguration> {
protected String showDialog() {
final String className = getClassName();
if (className.trim().length() == 0) {
Messages.showMessageDialog(getField(), ExecutionBundle.message("set.class.name.message"), ExecutionBundle.message("cannot.browse.method.dialog.title"), Messages.getInformationIcon());
Messages.showMessageDialog(getField(), ExecutionBundle.message("set.class.name.message"),
ExecutionBundle.message("cannot.browse.method.dialog.title"), Messages.getInformationIcon());
return null;
}
final PsiClass testClass = getModuleSelector().findClass(className);
if (testClass == null) {
Messages.showMessageDialog(getField(), ExecutionBundle.message("class.does.not.exists.error.message", className), ExecutionBundle.message("cannot.browse.method.dialog.title"),
Messages.showMessageDialog(getField(), ExecutionBundle.message("class.does.not.exists.error.message", className),
ExecutionBundle.message("cannot.browse.method.dialog.title"),
Messages.getInformationIcon());
return null;
}
@@ -446,12 +497,13 @@ public class JUnitConfigurable extends SettingsEditor<JUnitConfiguration> {
}
private String getClassName() {
return ((LabeledComponent<TextFieldWithBrowseButton>)getTestLocation(JUnitConfigurationModel.CLASS)).getComponent().getText();
return ((LabeledComponent<EditorTextFieldWithBrowseButton>)getTestLocation(JUnitConfigurationModel.CLASS)).getComponent().getText();
}
private void setPackage(final PsiPackage aPackage) {
if (aPackage == null) return;
((LabeledComponent<TextFieldWithBrowseButton>)getTestLocation(JUnitConfigurationModel.ALL_IN_PACKAGE)).getComponent().setText(aPackage.getQualifiedName());
((LabeledComponent<TextFieldWithBrowseButton>)getTestLocation(JUnitConfigurationModel.ALL_IN_PACKAGE)).getComponent()
.setText(aPackage.getQualifiedName());
}
@NotNull
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2011 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.
@@ -19,6 +19,8 @@ package com.intellij.execution.junit2.configuration;
import com.intellij.execution.JavaExecutionUtil;
import com.intellij.execution.junit.JUnitConfiguration;
import com.intellij.execution.junit.JUnitUtil;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.project.IndexNotReadyException;
@@ -26,7 +28,6 @@ import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiClass;
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
import javax.swing.text.PlainDocument;
import java.util.Arrays;
import java.util.LinkedHashSet;
@@ -42,19 +43,20 @@ public class JUnitConfigurationModel {
public static final int DIR = 4;
private static final List<String> ourTestObjects;
static {
ourTestObjects = Arrays.asList(JUnitConfiguration.TEST_PACKAGE, JUnitConfiguration.TEST_CLASS, JUnitConfiguration.TEST_METHOD, JUnitConfiguration.TEST_PATTERN,
ourTestObjects = Arrays.asList(JUnitConfiguration.TEST_PACKAGE, JUnitConfiguration.TEST_CLASS, JUnitConfiguration.TEST_METHOD,
JUnitConfiguration.TEST_PATTERN,
JUnitConfiguration.TEST_DIRECTORY);
}
private JUnitConfigurable myListener;
private int myType = -1;
private final Document[] myJUnitDocuments = new Document[5];
private final Object[] myJUnitDocuments = new Object[5];
private final Project myProject;
public JUnitConfigurationModel(final Project project) {
for (int i = 0; i < myJUnitDocuments.length; i++) myJUnitDocuments[i] = new PlainDocument();
myProject = project;
}
@@ -70,12 +72,18 @@ public class JUnitConfigurationModel {
myListener.onTypeChanged(newType);
}
public void setListener(final JUnitConfigurable listener) { myListener = listener; }
public void setListener(final JUnitConfigurable listener) {
myListener = listener;
}
public Document getJUnitDocument(final int i) {
public Object getJUnitDocument(final int i) {
return myJUnitDocuments[i];
}
public void setJUnitDocument(final int i, Object doc) {
myJUnitDocuments[i] = doc;
}
public void apply(final Module module, final JUnitConfiguration configuration) {
final boolean shouldUpdateName = configuration.isGeneratedName();
applyTo(configuration.getPersistentData(), module);
@@ -88,7 +96,9 @@ public class JUnitConfigurationModel {
final String testObject = getTestObject();
final String className = getJUnitTextValue(CLASS);
data.TEST_OBJECT = testObject;
if (testObject != JUnitConfiguration.TEST_PACKAGE && testObject != JUnitConfiguration.TEST_PATTERN && testObject != JUnitConfiguration.TEST_DIRECTORY) {
if (testObject != JUnitConfiguration.TEST_PACKAGE &&
testObject != JUnitConfiguration.TEST_PATTERN &&
testObject != JUnitConfiguration.TEST_DIRECTORY) {
try {
data.METHOD_NAME = getJUnitTextValue(METHOD);
final PsiClass testClass = JUnitUtil.findPsiClass(className, module, myProject);
@@ -136,14 +146,17 @@ public class JUnitConfigurationModel {
return getDocumentText(index, myJUnitDocuments);
}
private static String getDocumentText(final int index, final Document[] documents) {
final Document document = documents[index];
try {
return document.getText(0, document.getLength());
}
catch (BadLocationException e) {
throw new RuntimeException(e);
private static String getDocumentText(final int index, final Object[] documents) {
final Object document = documents[index];
if (document instanceof PlainDocument) {
try {
return ((PlainDocument)document).getText(0, ((PlainDocument)document).getLength());
}
catch (BadLocationException e) {
throw new RuntimeException(e);
}
}
return ((Document)document).getText();
}
public void reset(final JUnitConfiguration configuration) {
@@ -160,14 +173,23 @@ public class JUnitConfigurationModel {
setDocumentText(index, text, myJUnitDocuments);
}
private static void setDocumentText(final int index, final String text, final Document[] documents) {
final Document document = documents[index];
try {
document.remove(0, document.getLength());
document.insertString(0, text, null);
private static void setDocumentText(final int index, final String text, final Object[] documents) {
final Object document = documents[index];
if (document instanceof PlainDocument) {
try {
((PlainDocument)document).remove(0, ((PlainDocument)document).getLength());
((PlainDocument)document).insertString(0, text, null);
}
catch (BadLocationException e) {
throw new RuntimeException(e);
}
}
catch (BadLocationException e) {
throw new RuntimeException(e);
else {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
public void run() {
((Document)document).replaceString(0, ((Document)document).getTextLength(), text);
}
});
}
}
@@ -38,9 +38,6 @@
<grid row="1" column="0" row-span="1" col-span="5" vsize-policy="3" hsize-policy="3" anchor="1" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<clientProperties>
<BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory"/>
</clientProperties>
<border type="etched" title="Search for tests:"/>
<children>
<component id="3d515" class="com.intellij.openapi.ui.LabeledComponent" binding="methodField">
@@ -22,9 +22,12 @@
*/
package com.theoryinpractice.testng.configuration;
import com.intellij.codeInsight.completion.CompletionResultSet;
import com.intellij.codeInsight.lookup.LookupElementBuilder;
import com.intellij.execution.ExecutionBundle;
import com.intellij.execution.JavaExecutionUtil;
import com.intellij.execution.configuration.BrowseModuleValueActionListener;
import com.intellij.execution.junit.JUnitUtil;
import com.intellij.execution.testframework.TestSearchScope;
import com.intellij.execution.ui.AlternativeJREPanel;
import com.intellij.execution.ui.CommonJavaParametersPanel;
@@ -36,15 +39,20 @@ import com.intellij.openapi.fileChooser.FileChooserDescriptor;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.options.SettingsEditor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.ComponentWithBrowseButton;
import com.intellij.openapi.ui.LabeledComponent;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiMethod;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.ui.EditorTextFieldWithBrowseButton;
import com.intellij.ui.table.TableView;
import com.intellij.util.TextFieldCompletionProvider;
import com.theoryinpractice.testng.configuration.browser.*;
import com.theoryinpractice.testng.model.*;
import com.theoryinpractice.testng.util.TestNGUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -52,6 +60,7 @@ import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.text.Document;
import javax.swing.text.PlainDocument;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
@@ -65,7 +74,7 @@ public class TestNGConfigurationEditor extends SettingsEditor<TestNGConfiguratio
private JPanel panel;
private LabeledComponent<TextFieldWithBrowseButton> classField;
private LabeledComponent<EditorTextFieldWithBrowseButton> classField;
private LabeledComponent<JComboBox> moduleClasspath;
private AlternativeJREPanel alternateJDK;
private final ConfigurationModuleSelector moduleSelector;
@@ -75,9 +84,9 @@ public class TestNGConfigurationEditor extends SettingsEditor<TestNGConfiguratio
private JRadioButton methodTest;
private JRadioButton groupTest;
private final TestNGConfigurationModel model;
private LabeledComponent<TextFieldWithBrowseButton> methodField;
private LabeledComponent<TextFieldWithBrowseButton> packageField;
private LabeledComponent<TextFieldWithBrowseButton> groupField;
private LabeledComponent<EditorTextFieldWithBrowseButton> methodField;
private LabeledComponent<EditorTextFieldWithBrowseButton> packageField;
private LabeledComponent<TextFieldWithBrowseButton.NoPathCompletion> groupField;
private LabeledComponent<TextFieldWithBrowseButton> suiteField;
private JRadioButton packagesInProject;
private JRadioButton packagesInModule;
@@ -144,9 +153,14 @@ public class TestNGConfigurationEditor extends SettingsEditor<TestNGConfiguratio
LabeledComponent[] components = new LabeledComponent[] {packageField, classField, methodField, groupField, suiteField};
for (int i = 0; i < components.length; i++) {
TextFieldWithBrowseButton field = (TextFieldWithBrowseButton) components[i].getComponent();
Document document = model.getDocument(i);
field.getTextField().setDocument(document);
ComponentWithBrowseButton field = (ComponentWithBrowseButton)components[i].getComponent();
Object document = model.getDocument(i);
if (field instanceof TextFieldWithBrowseButton) {
((TextFieldWithBrowseButton)field).getTextField().setDocument((PlainDocument)document);
} else {
final com.intellij.openapi.editor.Document componentDocument = ((EditorTextFieldWithBrowseButton)field).getChildComponent().getDocument();
model.setDocument(i, componentDocument);
}
browseListeners[i].setField(field);
}
model.setType(TestType.CLASS);
@@ -298,13 +312,32 @@ public class TestNGConfigurationEditor extends SettingsEditor<TestNGConfiguratio
classTest.setSelected(false);
classTest.setEnabled(true);
classField.setComponent(new TextFieldWithBrowseButton());
methodField.setComponent(new TextFieldWithBrowseButton());
groupField.setComponent(new TextFieldWithBrowseButton());
classField.setComponent(new EditorTextFieldWithBrowseButton(project, true));
final EditorTextFieldWithBrowseButton methodEditorTextField = new EditorTextFieldWithBrowseButton(project, true);
new TextFieldCompletionProvider() {
@Override
protected void addCompletionVariants(@NotNull String text, int offset, @NotNull String prefix, @NotNull CompletionResultSet result) {
final String className = getClassName();
if (className.trim().length() == 0) {
return;
}
final PsiClass testClass = getModuleSelector().findClass(className);
if (testClass == null) return;
for (PsiMethod psiMethod : testClass.getAllMethods()) {
if (TestNGUtil.hasTest(psiMethod)) {
result.addElement(LookupElementBuilder.create(psiMethod.getName()));
}
}
}
}.apply(methodEditorTextField.getChildComponent());
methodField.setComponent(methodEditorTextField);
groupField.setComponent(new TextFieldWithBrowseButton.NoPathCompletion());
suiteField.setComponent(new TextFieldWithBrowseButton());
packageField.setVisible(true);
packageField.setEnabled(true);
packageField.setComponent(new TextFieldWithBrowseButton());
packageField.setComponent(new EditorTextFieldWithBrowseButton(project, false));
TextFieldWithBrowseButton outputDirectoryButton = new TextFieldWithBrowseButton();
@@ -17,16 +17,26 @@ package com.theoryinpractice.testng.model;
import com.intellij.execution.JavaExecutionUtil;
import com.intellij.execution.junit.JUnitUtil;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.RangeMarker;
import com.intellij.openapi.editor.event.DocumentListener;
import com.intellij.openapi.editor.markup.MarkupModel;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiClass;
import com.theoryinpractice.testng.configuration.TestNGConfiguration;
import com.theoryinpractice.testng.configuration.TestNGConfigurationEditor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
import javax.swing.text.PlainDocument;
import java.beans.PropertyChangeListener;
/**
* @author Hani Suleiman Date: Jul 21, 2005 Time: 1:20:14 PM
@@ -37,19 +47,23 @@ public class TestNGConfigurationModel
private TestNGConfigurationEditor editor;
private TestType type;
private final Document typeDocuments[] = new Document[5];
private final Object[] typeDocuments = new Object[5];
private final Document propertiesFileDocument = new PlainDocument();
private final Document outputDirectoryDocument = new PlainDocument();
private final Project project;
public TestNGConfigurationModel(Project project) {
type = TestType.INVALID;
for (int i = 0; i < typeDocuments.length; i++)
for (int i = 3; i < typeDocuments.length; i++)
typeDocuments[i] = new PlainDocument();
this.project = project;
}
public void setDocument(int type, com.intellij.openapi.editor.Document doc) {
typeDocuments[type] = doc;
}
public void setType(TestType type) {
if (type == this.type)
return;
@@ -66,7 +80,7 @@ public class TestNGConfigurationModel
this.editor = editor;
}
public Document getDocument(int index) {
public Object getDocument(int index) {
return typeDocuments[index];
}
@@ -142,14 +156,17 @@ public class TestNGConfigurationModel
return getText(type, typeDocuments);
}
private String getText(TestType testType, Document documents[]) {
Document document = documents[testType.getValue()];
private String getText(TestType testType, Object[] documents) {
Object document = documents[testType.getValue()];
if (document instanceof PlainDocument) {
try {
return document.getText(0, document.getLength());
return ((PlainDocument)document).getText(0, ((PlainDocument)document).getLength());
}
catch (BadLocationException e) {
throw new RuntimeException(e);
}
}
return ((com.intellij.openapi.editor.Document)document).getText();
}
public void reset(TestNGConfiguration config) {
@@ -169,18 +186,27 @@ public class TestNGConfigurationModel
setTypeValue(type, value, typeDocuments);
}
private void setTypeValue(TestType type, String value, Document documents[]) {
Document document = documents[type.getValue()];
private void setTypeValue(TestType type, String value, Object[] documents) {
Object document = documents[type.getValue()];
setDocumentText(document, value);
}
private void setDocumentText(Document document, String value) {
private void setDocumentText(final Object document, final String value) {
if (document instanceof PlainDocument) {
try {
document.remove(0, document.getLength());
document.insertString(0, value, null);
((PlainDocument)document).remove(0, ((PlainDocument)document).getLength());
((PlainDocument)document).insertString(0, value, null);
} catch (BadLocationException e) {
throw new RuntimeException(e);
}
} else {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
public void run() {
((com.intellij.openapi.editor.Document)document).replaceString(0, ((com.intellij.openapi.editor.Document)document).getTextLength(), value);
}
});
}
}
private void setType(String s) {