mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
run configurations: CommonProgramParameters panel extracted
This commit is contained in:
@@ -17,9 +17,9 @@ package com.intellij.execution.applet;
|
||||
|
||||
import com.intellij.execution.ExecutionBundle;
|
||||
import com.intellij.execution.impl.CheckableRunConfigurationEditor;
|
||||
import com.intellij.execution.junit2.configuration.ClassBrowser;
|
||||
import com.intellij.execution.junit2.configuration.ConfigurationModuleSelector;
|
||||
import com.intellij.execution.ui.AlternativeJREPanel;
|
||||
import com.intellij.execution.ui.ClassBrowser;
|
||||
import com.intellij.execution.ui.ConfigurationModuleSelector;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory;
|
||||
import com.intellij.openapi.options.SettingsEditor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
|
||||
+3
-4
@@ -13,13 +13,11 @@
|
||||
<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="50b09" class="com.intellij.execution.junit2.configuration.CommonJavaParameters" binding="myCommonJavaParameters">
|
||||
<component id="50b09" class="com.intellij.execution.ui.CommonJavaParameters" binding="myCommonProgramParameters">
|
||||
<constraints>
|
||||
<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>
|
||||
<programParametersText resource-bundle="messages/ExecutionBundle" key="run.configuration.program.parameters"/>
|
||||
</properties>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="50d08" class="com.intellij.openapi.ui.LabeledComponent" binding="myMainClass">
|
||||
<constraints>
|
||||
@@ -56,6 +54,7 @@
|
||||
<constraints>
|
||||
<grid row="2" 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>
|
||||
|
||||
+9
-9
@@ -17,10 +17,10 @@ package com.intellij.execution.application;
|
||||
|
||||
import com.intellij.execution.ExecutionBundle;
|
||||
import com.intellij.execution.configuration.EnvironmentVariablesComponent;
|
||||
import com.intellij.execution.junit2.configuration.ClassBrowser;
|
||||
import com.intellij.execution.junit2.configuration.CommonJavaParameters;
|
||||
import com.intellij.execution.junit2.configuration.ConfigurationModuleSelector;
|
||||
import com.intellij.execution.ui.AlternativeJREPanel;
|
||||
import com.intellij.execution.ui.ClassBrowser;
|
||||
import com.intellij.execution.ui.CommonJavaParameters;
|
||||
import com.intellij.execution.ui.ConfigurationModuleSelector;
|
||||
import com.intellij.execution.util.JreVersionDetector;
|
||||
import com.intellij.openapi.options.ConfigurationException;
|
||||
import com.intellij.openapi.options.SettingsEditor;
|
||||
@@ -34,7 +34,7 @@ import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
public class ApplicationConfigurable2 extends SettingsEditor<ApplicationConfiguration> {
|
||||
private CommonJavaParameters myCommonJavaParameters;
|
||||
private CommonJavaParameters myCommonProgramParameters;
|
||||
private LabeledComponent<TextFieldWithBrowseButton> myMainClass;
|
||||
private LabeledComponent<JComboBox> myModule;
|
||||
private JPanel myWholePanel;
|
||||
@@ -49,14 +49,14 @@ public class ApplicationConfigurable2 extends SettingsEditor<ApplicationConfigur
|
||||
myModuleSelector = new ConfigurationModuleSelector(project, myModule.getComponent());
|
||||
myModule.getComponent().addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
myCommonJavaParameters.setModuleContext(myModuleSelector.getModule());
|
||||
myCommonProgramParameters.setModuleContext(myModuleSelector.getModule());
|
||||
}
|
||||
});
|
||||
ClassBrowser.createApplicationClassBrowser(project, myModuleSelector).setField(getMainClassField());
|
||||
}
|
||||
|
||||
public void applyEditorTo(final ApplicationConfiguration configuration) throws ConfigurationException {
|
||||
myCommonJavaParameters.applyTo(configuration);
|
||||
myCommonProgramParameters.applyTo(configuration);
|
||||
myModuleSelector.applyTo(configuration);
|
||||
configuration.MAIN_CLASS_NAME = getMainClassField().getText();
|
||||
configuration.ALTERNATIVE_JRE_PATH = myAlternativeJREPanel.getPath();
|
||||
@@ -70,7 +70,7 @@ public class ApplicationConfigurable2 extends SettingsEditor<ApplicationConfigur
|
||||
}
|
||||
|
||||
public void resetEditorFrom(final ApplicationConfiguration configuration) {
|
||||
myCommonJavaParameters.reset(configuration);
|
||||
myCommonProgramParameters.reset(configuration);
|
||||
myModuleSelector.reset(configuration);
|
||||
getMainClassField().setText(configuration.MAIN_CLASS_NAME);
|
||||
myAlternativeJREPanel.init(configuration.ALTERNATIVE_JRE_PATH, configuration.ALTERNATIVE_JRE_PATH_ENABLED);
|
||||
@@ -98,8 +98,8 @@ public class ApplicationConfigurable2 extends SettingsEditor<ApplicationConfigur
|
||||
return myMainClass.getComponent();
|
||||
}
|
||||
|
||||
public CommonJavaParameters getCommonJavaParameters() {
|
||||
return myCommonJavaParameters;
|
||||
public CommonJavaParameters getCommonProgramParameters() {
|
||||
return myCommonProgramParameters;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
-45
@@ -1,45 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.execution.junit2.configuration.CommonJavaParameters">
|
||||
<grid id="d88e6" binding="myWholePanel" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="10">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="64" y="62" width="431" height="136"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="6e486" class="com.intellij.openapi.ui.LabeledComponent" binding="myVMParameters">
|
||||
<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">
|
||||
<minimum-size width="0" height="-1"/>
|
||||
<preferred-size width="400" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<componentClass value="com.intellij.ui.RawCommandLineEditor"/>
|
||||
<text resource-bundle="messages/ExecutionBundle" key="junit.configuration.vm.parameters.label"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="acecf" class="com.intellij.openapi.ui.LabeledComponent" binding="myProgramParameters">
|
||||
<constraints>
|
||||
<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">
|
||||
<minimum-size width="0" height="-1"/>
|
||||
<preferred-size width="400" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<componentClass value="com.intellij.ui.RawCommandLineEditor"/>
|
||||
<text resource-bundle="messages/ExecutionBundle" key="junit.configuration.test.runner.parameters.label"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="689d0" class="com.intellij.openapi.ui.LabeledComponent" binding="myWorkingDirectoryComponent" custom-create="true">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false">
|
||||
<minimum-size width="0" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
+1
-1
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.execution.junit2.configuration;
|
||||
package com.intellij.execution.ui;
|
||||
|
||||
import com.intellij.execution.ExecutionBundle;
|
||||
import com.intellij.execution.JavaExecutionUtil;
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright 2000-2010 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.execution.ui;
|
||||
|
||||
import com.intellij.execution.ExecutionBundle;
|
||||
import com.intellij.execution.RunJavaConfiguration;
|
||||
import com.intellij.openapi.ui.LabeledComponent;
|
||||
import com.intellij.ui.RawCommandLineEditor;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
public class CommonJavaParameters extends CommonProgramParameters {
|
||||
private LabeledComponent<RawCommandLineEditor> myVMParameters;
|
||||
|
||||
public CommonJavaParameters() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addComponents(GridBagConstraints c) {
|
||||
myVMParameters = LabeledComponent.create(new RawCommandLineEditor(),
|
||||
ExecutionBundle.message("run.configuration.java.vm.parameters.label"));
|
||||
copyDialogCaption(myVMParameters);
|
||||
|
||||
|
||||
c.gridy++;
|
||||
add(myVMParameters, c);
|
||||
|
||||
super.addComponents(c);
|
||||
}
|
||||
|
||||
public void applyTo(RunJavaConfiguration configuration) {
|
||||
configuration.setProperty(RunJavaConfiguration.VM_PARAMETERS_PROPERTY, getVMParameters());
|
||||
configuration.setProperty(RunJavaConfiguration.PROGRAM_PARAMETERS_PROPERTY, getProgramParameters());
|
||||
configuration.setProperty(RunJavaConfiguration.WORKING_DIRECTORY_PROPERTY, getWorkingDirectory());
|
||||
}
|
||||
|
||||
public void setVMParameters(String text) {
|
||||
myVMParameters.getComponent().setText(text);
|
||||
}
|
||||
|
||||
public String getVMParameters() {
|
||||
return myVMParameters.getComponent().getText();
|
||||
}
|
||||
|
||||
public void reset(final RunJavaConfiguration configuration) {
|
||||
setVMParameters(configuration.getProperty(RunJavaConfiguration.VM_PARAMETERS_PROPERTY));
|
||||
setProgramParameters(configuration.getProperty(RunJavaConfiguration.PROGRAM_PARAMETERS_PROPERTY));
|
||||
setWorkingDirectory(configuration.getProperty(RunJavaConfiguration.WORKING_DIRECTORY_PROPERTY));
|
||||
}
|
||||
}
|
||||
+66
-90
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2010 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.
|
||||
@@ -13,13 +13,11 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.execution.junit2.configuration;
|
||||
package com.intellij.execution.ui;
|
||||
|
||||
import com.intellij.execution.ExecutionBundle;
|
||||
import com.intellij.execution.RunJavaConfiguration;
|
||||
import com.intellij.openapi.actionSystem.LangDataKeys;
|
||||
import com.intellij.openapi.application.PathMacros;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.fileChooser.FileChooser;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory;
|
||||
@@ -41,106 +39,34 @@ import java.awt.event.ActionListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CommonJavaParameters extends JPanel {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.execution.junit2.configuration.CommonJavaParameters");
|
||||
|
||||
public class CommonProgramParameters extends JPanel {
|
||||
private static final Icon ICON = IconLoader.getIcon("/runConfigurations/variables.png");
|
||||
|
||||
private static final int[] ourProperties = new int[]{
|
||||
RunJavaConfiguration.PROGRAM_PARAMETERS_PROPERTY,
|
||||
RunJavaConfiguration.VM_PARAMETERS_PROPERTY,
|
||||
RunJavaConfiguration.WORKING_DIRECTORY_PROPERTY
|
||||
};
|
||||
|
||||
private JPanel myWholePanel;
|
||||
private LabeledComponent<RawCommandLineEditor> myProgramParameters;
|
||||
private LabeledComponent<RawCommandLineEditor> myVMParameters;
|
||||
private LabeledComponent<RawCommandLineEditor> myProgramParametersComponent;
|
||||
private LabeledComponent<JPanel> myWorkingDirectoryComponent;
|
||||
|
||||
private final LabeledComponent[] myFields = new LabeledComponent[3];
|
||||
private Module myModule = null;
|
||||
private JButton myVariablesButton;
|
||||
private TextFieldWithBrowseButton myWorkingDirectoryField;
|
||||
|
||||
public CommonJavaParameters() {
|
||||
super(new BorderLayout());
|
||||
add(myWholePanel, BorderLayout.CENTER);
|
||||
copyDialogCaption(myProgramParameters);
|
||||
copyDialogCaption(myVMParameters);
|
||||
private Module myModuleContext = null;
|
||||
|
||||
myFields[RunJavaConfiguration.PROGRAM_PARAMETERS_PROPERTY] = myProgramParameters;
|
||||
myFields[RunJavaConfiguration.VM_PARAMETERS_PROPERTY] = myVMParameters;
|
||||
myFields[RunJavaConfiguration.WORKING_DIRECTORY_PROPERTY] = myWorkingDirectoryComponent;
|
||||
public CommonProgramParameters() {
|
||||
super(new GridBagLayout());
|
||||
initComponents();
|
||||
copyDialogCaption(myProgramParametersComponent);
|
||||
}
|
||||
|
||||
private static void copyDialogCaption(final LabeledComponent<RawCommandLineEditor> component) {
|
||||
final RawCommandLineEditor rawCommandLineEditor = component.getComponent();
|
||||
rawCommandLineEditor.setDialogCaption(component.getRawText());
|
||||
component.getLabel().setLabelFor(rawCommandLineEditor.getTextField());
|
||||
}
|
||||
protected void initComponents() {
|
||||
myProgramParametersComponent = LabeledComponent.create(new RawCommandLineEditor(),
|
||||
ExecutionBundle.message("run.configuration.program.parameters"));
|
||||
|
||||
public String getProgramParametersText() {
|
||||
return getLabeledComponent(RunJavaConfiguration.PROGRAM_PARAMETERS_PROPERTY).getText();
|
||||
}
|
||||
|
||||
public void setProgramParametersText(String textWithMnemonic) {
|
||||
getLabeledComponent(RunJavaConfiguration.PROGRAM_PARAMETERS_PROPERTY).setText(textWithMnemonic);
|
||||
copyDialogCaption(myProgramParameters);
|
||||
}
|
||||
|
||||
public void applyTo(final RunJavaConfiguration configuration) {
|
||||
for (final int property : ourProperties) {
|
||||
configuration.setProperty(property, getText(property));
|
||||
}
|
||||
}
|
||||
|
||||
public void reset(final RunJavaConfiguration configuration) {
|
||||
for (final int property : ourProperties) {
|
||||
setText(property, configuration.getProperty(property));
|
||||
}
|
||||
}
|
||||
|
||||
public void setText(final int property, final String value) {
|
||||
final JComponent component = getLabeledComponent(property).getComponent();
|
||||
if (component instanceof TextFieldWithBrowseButton)
|
||||
((TextFieldWithBrowseButton)component).setText(value);
|
||||
else if (component instanceof RawCommandLineEditor)
|
||||
((RawCommandLineEditor)component).setText(value);
|
||||
else if (component instanceof JPanel)
|
||||
myWorkingDirectoryField.setText(value);
|
||||
else LOG.error(component.getClass().getName());
|
||||
}
|
||||
|
||||
public String getText(final int property) {
|
||||
final JComponent component = getLabeledComponent(property).getComponent();
|
||||
if (component instanceof TextFieldWithBrowseButton)
|
||||
return ((TextFieldWithBrowseButton)component).getText();
|
||||
else if (component instanceof RawCommandLineEditor)
|
||||
return ((RawCommandLineEditor)component).getText();
|
||||
else if (component instanceof JPanel)
|
||||
return myWorkingDirectoryField.getText();
|
||||
else LOG.error(component.getClass().getName());
|
||||
return "";
|
||||
}
|
||||
|
||||
private LabeledComponent getLabeledComponent(final int index) {
|
||||
return myFields[index];
|
||||
}
|
||||
|
||||
public void setModuleContext(final Module module) {
|
||||
myModule = module;
|
||||
}
|
||||
|
||||
private void createUIComponents() {
|
||||
final JPanel panel = new JPanel(new BorderLayout());
|
||||
myWorkingDirectoryField = new TextFieldWithBrowseButton(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
FileChooserDescriptor fileChooserDescriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
|
||||
fileChooserDescriptor.setTitle(ExecutionBundle.message("select.working.directory.message"));
|
||||
fileChooserDescriptor.putUserData(LangDataKeys.MODULE_CONTEXT, myModule);
|
||||
fileChooserDescriptor.putUserData(LangDataKeys.MODULE_CONTEXT, myModuleContext);
|
||||
VirtualFile[] files = FileChooser.chooseFiles(myWorkingDirectoryComponent, fileChooserDescriptor);
|
||||
if (files.length != 0) {
|
||||
setText(RunJavaConfiguration.WORKING_DIRECTORY_PROPERTY, files[0].getPresentableUrl());
|
||||
setWorkingDirectory(files[0].getPresentableUrl());
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -158,7 +84,7 @@ public class CommonJavaParameters extends JPanel {
|
||||
public void run() {
|
||||
final Object value = list.getSelectedValue();
|
||||
if (value instanceof String) {
|
||||
setText(RunJavaConfiguration.WORKING_DIRECTORY_PROPERTY, "$" + value + "$");
|
||||
setWorkingDirectory("$" + value + "$");
|
||||
}
|
||||
}
|
||||
}).setMovable(false).setResizable(false).createPopup();
|
||||
@@ -167,6 +93,56 @@ public class CommonJavaParameters extends JPanel {
|
||||
});
|
||||
panel.add(button, BorderLayout.EAST);
|
||||
|
||||
myWorkingDirectoryComponent = LabeledComponent.create(panel, "&Working directory");
|
||||
myWorkingDirectoryComponent = LabeledComponent.create(panel, ExecutionBundle.message("run.configuration.working.directory.label"));
|
||||
|
||||
GridBagConstraints c = new GridBagConstraints();
|
||||
c.weightx = 1;
|
||||
c.fill = GridBagConstraints.HORIZONTAL;
|
||||
c.anchor = GridBagConstraints.LINE_START;
|
||||
c.gridx = 0;
|
||||
|
||||
addComponents(c);
|
||||
}
|
||||
|
||||
protected void addComponents(GridBagConstraints c) {
|
||||
c.gridy++;
|
||||
add(myProgramParametersComponent, c);
|
||||
c.gridy++;
|
||||
add(myWorkingDirectoryComponent, c);
|
||||
}
|
||||
|
||||
protected void copyDialogCaption(final LabeledComponent<RawCommandLineEditor> component) {
|
||||
final RawCommandLineEditor rawCommandLineEditor = component.getComponent();
|
||||
rawCommandLineEditor.setDialogCaption(component.getRawText());
|
||||
component.getLabel().setLabelFor(rawCommandLineEditor.getTextField());
|
||||
}
|
||||
|
||||
public String getProgramParametersLabel() {
|
||||
return myProgramParametersComponent.getText();
|
||||
}
|
||||
|
||||
public void setProgramParametersLabel(String textWithMnemonic) {
|
||||
myProgramParametersComponent.setText(textWithMnemonic);
|
||||
copyDialogCaption(myProgramParametersComponent);
|
||||
}
|
||||
|
||||
public String getProgramParameters() {
|
||||
return myProgramParametersComponent.getComponent().getText();
|
||||
}
|
||||
|
||||
public void setProgramParameters(String text) {
|
||||
myProgramParametersComponent.getComponent().setText(text);
|
||||
}
|
||||
|
||||
public String getWorkingDirectory() {
|
||||
return myWorkingDirectoryField.getText();
|
||||
}
|
||||
|
||||
public void setWorkingDirectory(String text) {
|
||||
myWorkingDirectoryField.setText(text);
|
||||
}
|
||||
|
||||
public void setModuleContext(Module module) {
|
||||
myModuleContext = module;
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2010 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.
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.execution.junit2.configuration;
|
||||
package com.intellij.execution.ui;
|
||||
|
||||
import com.intellij.execution.configurations.JavaRunConfigurationModule;
|
||||
import com.intellij.execution.configurations.ModuleBasedConfiguration;
|
||||
Reference in New Issue
Block a user