summaryrefslogtreecommitdiff
path: root/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/groovy/src/org/jetbrains/plugins/groovy/mvc')
-rw-r--r--plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcCliCommandExecutor.java46
-rw-r--r--plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcCommandExecutor.java69
-rw-r--r--plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcRunConfigurationEditor.form2
-rw-r--r--plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcRunConfigurationEditor.java18
-rw-r--r--plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcRunTarget.java8
-rw-r--r--plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcRunTargetDialog.form2
-rw-r--r--plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcRunTargetDialog.java16
-rw-r--r--plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/util/ModuleCellRenderer.java39
8 files changed, 132 insertions, 68 deletions
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcCliCommandExecutor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcCliCommandExecutor.java
new file mode 100644
index 000000000000..120c5abf189b
--- /dev/null
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcCliCommandExecutor.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2000-2014 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 org.jetbrains.plugins.groovy.mvc;
+
+import com.intellij.execution.configurations.GeneralCommandLine;
+import com.intellij.openapi.module.Module;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * @author Vladislav.Soroka
+ * @since 6/19/2014
+ */
+public class MvcCliCommandExecutor extends MvcCommandExecutor {
+ @Override
+ protected boolean isApplicable(Module module) {
+ return true;
+ }
+
+ @Nullable
+ @Override
+ protected ConsoleProcessDescriptor doRun(@NotNull Module module,
+ @NotNull MvcFramework framework,
+ @NotNull MvcCommand mvcCommand,
+ @Nullable Runnable onDone,
+ boolean showConsole,
+ boolean closeOnDone,
+ String... input) {
+ final GeneralCommandLine commandLine = framework.createCommandAndShowErrors(null, module, mvcCommand);
+ if (commandLine == null) return null;
+ return MvcConsole.executeProcess(module, commandLine, onDone, closeOnDone, input);
+ }
+}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcCommandExecutor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcCommandExecutor.java
new file mode 100644
index 000000000000..c4c791ba0042
--- /dev/null
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcCommandExecutor.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2000-2014 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 org.jetbrains.plugins.groovy.mvc;
+
+import com.intellij.openapi.extensions.ExtensionPointName;
+import com.intellij.openapi.module.Module;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * @author Vladislav.Soroka
+ * @since 6/19/2014
+ */
+public abstract class MvcCommandExecutor {
+ private static final ExtensionPointName<MvcCommandExecutor> EP_NAME =
+ ExtensionPointName.create("org.intellij.groovy.mvc.command.executor");
+
+ @Nullable
+ public static ConsoleProcessDescriptor run(@NotNull Module module,
+ @NotNull MvcFramework framework,
+ @NotNull MvcCommand mvcCommand,
+ @Nullable Runnable onDone,
+ boolean closeOnDone,
+ String... input) {
+ return run(module, framework, mvcCommand, onDone, true, closeOnDone, input);
+ }
+
+ @Nullable
+ public static ConsoleProcessDescriptor run(@NotNull Module module,
+ @NotNull MvcFramework framework,
+ @NotNull MvcCommand mvcCommand,
+ @Nullable Runnable onDone,
+ boolean showConsole,
+ boolean closeOnDone,
+ String... input) {
+ for (MvcCommandExecutor executor : EP_NAME.getExtensions()) {
+ if (executor.isApplicable(module)) {
+ return executor.doRun(module, framework, mvcCommand, onDone, showConsole, closeOnDone, input);
+ }
+ }
+
+ // fallback to default CLI implementation
+ return new MvcCliCommandExecutor().doRun(module, framework, mvcCommand, onDone, showConsole, closeOnDone, input);
+ }
+
+ protected abstract boolean isApplicable(Module module);
+
+ @Nullable
+ protected abstract ConsoleProcessDescriptor doRun(@NotNull Module module,
+ @NotNull MvcFramework framework,
+ @NotNull MvcCommand mvcCommand,
+ @Nullable Runnable onDone,
+ boolean showConsole,
+ boolean closeOnDone,
+ String... input);
+}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcRunConfigurationEditor.form b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcRunConfigurationEditor.form
index 688fe451db4c..a86aade6a66f 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcRunConfigurationEditor.form
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcRunConfigurationEditor.form
@@ -39,7 +39,7 @@
</constraints>
<properties/>
</component>
- <component id="d1e7d" class="javax.swing.JComboBox" binding="myModulesBox">
+ <component id="d1e7d" class="com.intellij.application.options.ModulesComboBox" binding="myModulesBox">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcRunConfigurationEditor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcRunConfigurationEditor.java
index 68f6d50ae80d..d81ce98ffec6 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcRunConfigurationEditor.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcRunConfigurationEditor.java
@@ -20,13 +20,13 @@ import com.intellij.execution.configuration.EnvironmentVariablesComponent;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.options.SettingsEditor;
+import com.intellij.application.options.ModulesComboBox;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.ui.DocumentAdapter;
import com.intellij.ui.PanelWithAnchor;
import com.intellij.ui.RawCommandLineEditor;
import com.intellij.ui.components.JBLabel;
import org.jetbrains.annotations.NotNull;
-import org.jetbrains.plugins.groovy.mvc.util.ModuleCellRenderer;
import javax.swing.*;
import javax.swing.event.DocumentEvent;
@@ -35,8 +35,7 @@ import java.io.File;
import java.util.HashMap;
public class MvcRunConfigurationEditor<T extends MvcRunConfiguration> extends SettingsEditor<T> implements PanelWithAnchor {
- private DefaultComboBoxModel myModulesModel;
- protected JComboBox myModulesBox;
+ protected ModulesComboBox myModulesBox;
private JPanel myMainPanel;
private RawCommandLineEditor myVMParameters;
private JTextField myCommandLine;
@@ -67,11 +66,8 @@ public class MvcRunConfigurationEditor<T extends MvcRunConfiguration> extends Se
myCommandLine.setText(configuration.cmdLine);
- myModulesModel.removeAllElements();
- for (Module module : configuration.getValidModules()) {
- myModulesModel.addElement(module);
- }
- myModulesModel.setSelectedItem(configuration.getModule());
+ myModulesBox.setModules(configuration.getValidModules());
+ myModulesBox.setSelectedModule(configuration.getModule());
commandLineChanged(getCommandLine());
@@ -142,7 +138,7 @@ public class MvcRunConfigurationEditor<T extends MvcRunConfiguration> extends Se
}
protected Module getSelectedModule() {
- return (Module)myModulesBox.getSelectedItem();
+ return myModulesBox.getSelectedModule();
}
public void addExtension(JComponent component) {
@@ -152,10 +148,6 @@ public class MvcRunConfigurationEditor<T extends MvcRunConfiguration> extends Se
@Override
@NotNull
protected JComponent createEditor() {
- myModulesModel = new DefaultComboBoxModel();
- myModulesBox.setModel(myModulesModel);
- myModulesBox.setRenderer(new ModuleCellRenderer(myModulesBox.getRenderer()));
-
return myMainPanel;
}
}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcRunTarget.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcRunTarget.java
index 6efc6665504e..ad856e862223 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcRunTarget.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcRunTarget.java
@@ -15,7 +15,6 @@
*/
package org.jetbrains.plugins.groovy.mvc;
-import com.intellij.execution.configurations.GeneralCommandLine;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.module.Module;
import org.jetbrains.annotations.NotNull;
@@ -34,13 +33,8 @@ public class MvcRunTarget extends MvcActionBase {
}
Module selectedModule = dialog.getSelectedModule();
-
MvcCommand cmd = MvcCommand.parse(dialog.getTargetArguments());
-
- final GeneralCommandLine commandLine = framework.createCommandAndShowErrors(dialog.getVmOptions(), selectedModule, cmd);
- if (commandLine == null) return;
-
- MvcConsole.executeProcess(selectedModule, commandLine, null, false);
+ MvcCommandExecutor.run(selectedModule, framework, cmd, null, false);
}
}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcRunTargetDialog.form b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcRunTargetDialog.form
index 3d086ca296b6..cafff50f6c2a 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcRunTargetDialog.form
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcRunTargetDialog.form
@@ -69,7 +69,7 @@
<text value="&amp;Module:"/>
</properties>
</component>
- <component id="cf36f" class="javax.swing.JComboBox" binding="myModuleBox">
+ <component id="cf36f" class="com.intellij.application.options.ModulesComboBox" binding="myModuleBox">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcRunTargetDialog.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcRunTargetDialog.java
index 2b629bb668a1..65c6b4be97b4 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcRunTargetDialog.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcRunTargetDialog.java
@@ -22,14 +22,17 @@ import com.intellij.openapi.editor.event.DocumentEvent;
import com.intellij.openapi.fileTypes.PlainTextFileType;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
+import com.intellij.application.options.ModulesComboBox;
import com.intellij.openapi.ui.ComboBox;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.util.text.StringUtil;
-import com.intellij.ui.*;
+import com.intellij.ui.EditorComboBoxEditor;
+import com.intellij.ui.EditorComboBoxRenderer;
+import com.intellij.ui.EditorTextField;
+import com.intellij.ui.StringComboboxEditor;
import com.intellij.util.TextFieldCompletionProvider;
import com.intellij.util.TextFieldCompletionProviderDumbAware;
import org.jetbrains.annotations.NotNull;
-import org.jetbrains.plugins.groovy.mvc.util.ModuleCellRenderer;
import org.jetbrains.plugins.groovy.mvc.util.MvcTargetDialogCompletionUtils;
import javax.swing.*;
@@ -47,7 +50,7 @@ public class MvcRunTargetDialog extends DialogWrapper {
private JLabel myTargetLabel;
private JPanel myFakePanel;
private EditorTextField myVmOptionsField;
- private JComboBox myModuleBox;
+ private ModulesComboBox myModuleBox;
private JLabel myModuleLabel;
private JLabel myVmOptionLabel;
private ComboBox myTargetField;
@@ -114,18 +117,17 @@ public class MvcRunTargetDialog extends DialogWrapper {
assert mvcModules.contains(myModule);
myModuleLabel.setLabelFor(myModuleBox);
- myModuleBox.setModel(new CollectionComboBoxModel(mvcModules, myModule));
+ myModuleBox.setModules(mvcModules);
+ myModuleBox.setSelectedModule(myModule);
myModuleBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
- myModule = (Module)myModuleBox.getSelectedItem();
+ myModule = myModuleBox.getSelectedModule();
if (myInteractiveRunAction != null) {
myInteractiveRunAction.setEnabled(myFramework.isInteractiveConsoleSupported(myModule));
}
}
});
-
- myModuleBox.setRenderer(new ModuleCellRenderer(myModuleBox.getRenderer()));
}
@NotNull
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/util/ModuleCellRenderer.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/util/ModuleCellRenderer.java
deleted file mode 100644
index 208de7bbcfbc..000000000000
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/util/ModuleCellRenderer.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2000-2012 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 org.jetbrains.plugins.groovy.mvc.util;
-
-import com.intellij.openapi.module.Module;
-import com.intellij.openapi.module.ModuleType;
-import com.intellij.ui.ListCellRendererWrapper;
-
-import javax.swing.*;
-
-/**
- * @author Sergey Evdokimov
- */
-public class ModuleCellRenderer extends ListCellRendererWrapper<Module> {
- public ModuleCellRenderer(ListCellRenderer renderer) {
- super();
- }
-
- @Override
- public void customize(JList list, Module module, int index, boolean selected, boolean hasFocus) {
- if (module != null) {
- setIcon(ModuleType.get(module).getIcon());
- setText(module.getName());
- }
- }
-}