summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Aubry2012-10-08 12:28:44 (EDT)
committer Kevin KIN-FOO2012-10-09 10:12:34 (EDT)
commitd9d7e376a3715a391ab83302ba1bb45c92db7ab3 (patch)
tree0d5ef462bd67fc8efc36e581bbdb64fe4c00792f
parentc3c34890f70d7d3bdec020a9a0a6e1b75671aab4 (diff)
downloadorg.eclipse.koneki.ldt-d9d7e376a3715a391ab83302ba1bb45c92db7ab3.zip
org.eclipse.koneki.ldt-d9d7e376a3715a391ab83302ba1bb45c92db7ab3.tar.gz
org.eclipse.koneki.ldt-d9d7e376a3715a391ab83302ba1bb45c92db7ab3.tar.bz2
Bug 391354 - Add a Run As menu entry for Lua remote application launch
configuration
-rw-r--r--plugins/org.eclipse.koneki.ldt.debug.ui/META-INF/MANIFEST.MF12
-rw-r--r--plugins/org.eclipse.koneki.ldt.debug.ui/src/org/eclipse/koneki/ldt/debug/ui/internal/launchconfiguration/local/LuaApplicationLaunchShortcut.java2
-rw-r--r--plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/LuaRemoteDebugConstant.java4
-rw-r--r--plugins/org.eclipse.koneki.ldt.remote.debug.ui/META-INF/MANIFEST.MF5
-rw-r--r--plugins/org.eclipse.koneki.ldt.remote.debug.ui/plugin.xml52
-rw-r--r--plugins/org.eclipse.koneki.ldt.remote.debug.ui/src/org/eclipse/koneki/ldt/remote/debug/ui/internal/launch/LuaRemoteLaunchShortcut.java130
-rw-r--r--plugins/org.eclipse.koneki.ldt.remote.debug.ui/src/org/eclipse/koneki/ldt/remote/debug/ui/internal/launch/Messages.java31
-rw-r--r--plugins/org.eclipse.koneki.ldt.remote.debug.ui/src/org/eclipse/koneki/ldt/remote/debug/ui/internal/launch/messages.properties4
8 files changed, 232 insertions, 8 deletions
diff --git a/plugins/org.eclipse.koneki.ldt.debug.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.koneki.ldt.debug.ui/META-INF/MANIFEST.MF
index 556b419..69586d8 100644
--- a/plugins/org.eclipse.koneki.ldt.debug.ui/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.koneki.ldt.debug.ui/META-INF/MANIFEST.MF
@@ -22,10 +22,10 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.core.expressions;bundle-version="3.4.300"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
-Export-Package: org.eclipse.koneki.ldt.debug.ui.internal;x-internal:=true,
- org.eclipse.koneki.ldt.debug.ui.internal.actions;x-internal:=true,
- org.eclipse.koneki.ldt.debug.ui.internal.interpreters;x-internal:=true,
- org.eclipse.koneki.ldt.debug.ui.internal.launchconfiguration.attach;x-internal:=true,
- org.eclipse.koneki.ldt.debug.ui.internal.launchconfiguration.local;x-internal:=true,
- org.eclipse.koneki.ldt.debug.ui.internal.launchconfiguration.local.tab;x-internal:=true
+Export-Package: org.eclipse.koneki.ldt.debug.ui.internal;x-friends:="org.eclipse.koneki.ldt.remote.debug.ui",
+ org.eclipse.koneki.ldt.debug.ui.internal.actions;x-friends:="org.eclipse.koneki.ldt.remote.debug.ui",
+ org.eclipse.koneki.ldt.debug.ui.internal.interpreters;x-friends:="org.eclipse.koneki.ldt.remote.debug.ui",
+ org.eclipse.koneki.ldt.debug.ui.internal.launchconfiguration.attach;x-friends:="org.eclipse.koneki.ldt.remote.debug.ui",
+ org.eclipse.koneki.ldt.debug.ui.internal.launchconfiguration.local;x-friends:="org.eclipse.koneki.ldt.remote.debug.ui",
+ org.eclipse.koneki.ldt.debug.ui.internal.launchconfiguration.local.tab;x-friends:="org.eclipse.koneki.ldt.remote.debug.ui"
Bundle-Vendor: %Bundle-Vendor
diff --git a/plugins/org.eclipse.koneki.ldt.debug.ui/src/org/eclipse/koneki/ldt/debug/ui/internal/launchconfiguration/local/LuaApplicationLaunchShortcut.java b/plugins/org.eclipse.koneki.ldt.debug.ui/src/org/eclipse/koneki/ldt/debug/ui/internal/launchconfiguration/local/LuaApplicationLaunchShortcut.java
index a2e412b..48977d1 100644
--- a/plugins/org.eclipse.koneki.ldt.debug.ui/src/org/eclipse/koneki/ldt/debug/ui/internal/launchconfiguration/local/LuaApplicationLaunchShortcut.java
+++ b/plugins/org.eclipse.koneki.ldt.debug.ui/src/org/eclipse/koneki/ldt/debug/ui/internal/launchconfiguration/local/LuaApplicationLaunchShortcut.java
@@ -183,7 +183,7 @@ public class LuaApplicationLaunchShortcut extends AbstractScriptLaunchShortcut {
if (config.getAttribute(ScriptLaunchConfigurationConstants.ATTR_MAIN_SCRIPT_NAME, Util.EMPTY_STRING).equals(
script.getProjectRelativePath().toString())
&& config.getAttribute(ScriptLaunchConfigurationConstants.ATTR_PROJECT_NAME, Util.EMPTY_STRING).equals(
- script.getProject().getName())) {
+ script.getProject().getName()) && config.getType().equals(getConfigurationType())) {
candidateConfigs.add(config);
}
}
diff --git a/plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/LuaRemoteDebugConstant.java b/plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/LuaRemoteDebugConstant.java
index 9ab05a7..4ba159a 100644
--- a/plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/LuaRemoteDebugConstant.java
+++ b/plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/LuaRemoteDebugConstant.java
@@ -14,10 +14,14 @@ import org.eclipse.dltk.launching.ScriptLaunchConfigurationConstants;
public interface LuaRemoteDebugConstant {
+ String REMOTE_LAUNCH_CONFIGURATION_ID = "org.eclipse.koneki.ldt.remote.debug.core.luaremotedebug"; //$NON-NLS-1$
+
String PROJECT_NAME = ScriptLaunchConfigurationConstants.ATTR_PROJECT_NAME;
String SCRIPT_NAME = ScriptLaunchConfigurationConstants.ATTR_MAIN_SCRIPT_NAME;
String HOST_ID = Activator.PLUGIN_ID + ".debug.hostid"; //$NON-NLS-1$
String BREAK_ON_FIRST_LINE = ScriptLaunchConfigurationConstants.ENABLE_BREAK_ON_FIRST_LINE;
String DBGP_LOGGING = ScriptLaunchConfigurationConstants.ENABLE_DBGP_LOGGING;
+
+ String NATURE = ScriptLaunchConfigurationConstants.ATTR_SCRIPT_NATURE;
}
diff --git a/plugins/org.eclipse.koneki.ldt.remote.debug.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.koneki.ldt.remote.debug.ui/META-INF/MANIFEST.MF
index 12bbf74..2dfd888 100644
--- a/plugins/org.eclipse.koneki.ldt.remote.debug.ui/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.koneki.ldt.remote.debug.ui/META-INF/MANIFEST.MF
@@ -13,9 +13,12 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.rse.core,
org.eclipse.dltk.debug.ui,
org.eclipse.koneki.ldt,
- org.eclipse.koneki.ldt.remote.core
+ org.eclipse.koneki.ldt.remote.core,
+ org.eclipse.koneki.ldt.debug.ui,
+ org.eclipse.rse.subsystems.files.core
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-Vendor: %Bundle-Vendor
Export-Package: org.eclipse.koneki.ldt.remote.debug.ui.internal;x-internal:=true,
+ org.eclipse.koneki.ldt.remote.debug.ui.internal.launch;x-internal:=true,
org.eclipse.koneki.ldt.remote.debug.ui.internal.launch.tab;x-internal:=true
diff --git a/plugins/org.eclipse.koneki.ldt.remote.debug.ui/plugin.xml b/plugins/org.eclipse.koneki.ldt.remote.debug.ui/plugin.xml
index 1241e9b..fb8d3a4 100644
--- a/plugins/org.eclipse.koneki.ldt.remote.debug.ui/plugin.xml
+++ b/plugins/org.eclipse.koneki.ldt.remote.debug.ui/plugin.xml
@@ -26,4 +26,56 @@
id="org.eclipse.koneki.ldt.remote.debug.core.luaremotedebug.image">
</launchConfigurationTypeImage>
</extension>
+ <extension point="org.eclipse.debug.ui.launchShortcuts">
+ <shortcut
+ label="Lua Remote Application"
+ icon="icons/obj16/lua_remote.png"
+ helpContextId="org.eclipse.jdt.debug.ui"
+ modes="run, debug"
+ class="org.eclipse.koneki.ldt.remote.debug.ui.internal.launch.LuaRemoteLaunchShortcut"
+ description="Launch a Lua application on remote host"
+ id="org.eclipse.koneki.ldt.debug.ui.localLuaShortcut">
+ <description
+ description="Run a Lua application on a remote host"
+ mode="run">
+ </description>
+ <description
+ description="Debug a Lua application on a remote host"
+ mode="debug">
+ </description>
+ <contextualLaunch>
+ <enablement>
+ <with variable="selection">
+ <count value="1"/>
+ <iterate>
+ <and>
+ <adapt type="org.eclipse.core.resources.IResource">
+ <test property="org.eclipse.core.resources.projectNature"
+ value="org.eclipse.koneki.ldt.nature"/>
+ </adapt>
+ <or>
+ <adapt type="org.eclipse.core.resources.IResource">
+ <test property="org.eclipse.core.resources.extension" value="lua"/>
+ </adapt>
+ <adapt type="org.eclipse.core.resources.IProject">
+ <test property="org.eclipse.core.resources.open"/>
+ </adapt>
+ <adapt type="org.eclipse.dltk.core.IProjectFragment">
+ <test
+ forcePluginActivation="true"
+ property="org.eclipse.koneki.ldt.debug.ui.propertytester.isLaunchableProjectFragment">
+ </test>
+ </adapt>
+ <instanceof value="org.eclipse.dltk.core.IScriptFolder"></instanceof>
+ </or>
+ </and>
+ </iterate>
+ </with>
+ </enablement>
+ </contextualLaunch>
+ <configurationType
+ id="org.eclipse.koneki.ldt.remote.debug.core.luaremotedebug">
+ </configurationType>
+ </shortcut>
+</extension>
</plugin>
diff --git a/plugins/org.eclipse.koneki.ldt.remote.debug.ui/src/org/eclipse/koneki/ldt/remote/debug/ui/internal/launch/LuaRemoteLaunchShortcut.java b/plugins/org.eclipse.koneki.ldt.remote.debug.ui/src/org/eclipse/koneki/ldt/remote/debug/ui/internal/launch/LuaRemoteLaunchShortcut.java
new file mode 100644
index 0000000..034c5fa
--- /dev/null
+++ b/plugins/org.eclipse.koneki.ldt.remote.debug.ui/src/org/eclipse/koneki/ldt/remote/debug/ui/internal/launch/LuaRemoteLaunchShortcut.java
@@ -0,0 +1,130 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Sierra Wireless and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Sierra Wireless - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.koneki.ldt.remote.debug.ui.internal.launch;
+
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.koneki.ldt.debug.ui.internal.launchconfiguration.local.LuaApplicationLaunchShortcut;
+import org.eclipse.koneki.ldt.remote.core.internal.RSEUtil;
+import org.eclipse.koneki.ldt.remote.core.internal.lua.LuaSubSystem;
+import org.eclipse.koneki.ldt.remote.debug.core.internal.LuaRemoteDebugConstant;
+import org.eclipse.koneki.ldt.remote.debug.core.internal.launch.LuaRemoteLaunchConfigurationUtil;
+import org.eclipse.koneki.ldt.remote.debug.ui.internal.Activator;
+import org.eclipse.rse.core.RSECorePlugin;
+import org.eclipse.rse.core.model.IHost;
+import org.eclipse.rse.core.subsystems.ISubSystem;
+import org.eclipse.rse.internal.ui.view.SystemViewLabelAndContentProvider;
+import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem;
+import org.eclipse.rse.ui.actions.SystemNewConnectionAction;
+import org.eclipse.ui.dialogs.ElementListSelectionDialog;
+
+@SuppressWarnings("restriction")
+public class LuaRemoteLaunchShortcut extends LuaApplicationLaunchShortcut {
+
+ @Override
+ protected ILaunchConfigurationType getConfigurationType() {
+ return DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType(LuaRemoteDebugConstant.REMOTE_LAUNCH_CONFIGURATION_ID);
+ }
+
+ /**
+ * Copy of the super method with a custom config name generation
+ */
+ @Override
+ protected ILaunchConfiguration createConfiguration(IResource script) {
+ ILaunchConfiguration config = null;
+ ILaunchConfigurationWorkingCopy wc = null;
+
+ try {
+ ILaunchConfigurationType configType = getConfigurationType();
+
+ // wait for RSE
+ RSEUtil.waitForRSEInitialization();
+
+ // find a host for the launch conf
+ IHost host = null;
+ List<IHost> hosts = findHosts();
+ if (hosts.isEmpty()) {
+ // ask user about creating a target
+ if (MessageDialog.openQuestion(getShell(), Messages.LuaRemoteLaunchShortcut_notargetdialog_title, Messages.LuaRemoteLaunchShortcut_notargetdialog_message)) {
+ SystemNewConnectionAction newConnectionAction = new SystemNewConnectionAction(getShell(), false, null);
+ newConnectionAction.run();
+ host = (IHost) newConnectionAction.getValue();
+ }
+
+ // open new lua target wizard
+ } else if (hosts.size() == 1) {
+ host = hosts.get(0);
+ } else {
+ // select dialog
+ ElementListSelectionDialog selectHostDialog = new ElementListSelectionDialog(getShell(), new SystemViewLabelAndContentProvider());
+ selectHostDialog.setElements(hosts.toArray());
+ selectHostDialog.setTitle(Messages.LuaRemoteLaunchShortcut_selectHostDialog_title);
+ selectHostDialog.setMessage(Messages.LuaRemoteLaunchShortcut_selectHost_message);
+ selectHostDialog.open();
+ host = (IHost) selectHostDialog.getFirstResult();
+ }
+
+ if (host == null) {
+ return null;
+ }
+
+ // custom launch conf name
+ String fileNameWithoutExtension = script.getLocation().removeFileExtension().lastSegment();
+ String configNamePrefix = MessageFormat.format("{0}_{1}_{2}", script.getProject().getName(), fileNameWithoutExtension, host); //$NON-NLS-1$
+
+ wc = configType.newInstance(null, getLaunchManager().generateLaunchConfigurationName(configNamePrefix));
+ wc.setAttribute(LuaRemoteDebugConstant.NATURE, getNatureId());
+ wc.setAttribute(LuaRemoteDebugConstant.PROJECT_NAME, script.getProject().getName());
+ wc.setAttribute(LuaRemoteDebugConstant.SCRIPT_NAME, script.getProjectRelativePath().toPortableString());
+ LuaRemoteLaunchConfigurationUtil.setConnectionId(wc, host);
+
+ wc.setMappedResources(new IResource[] { script });
+ config = wc.doSave();
+ } catch (CoreException e) {
+ Activator.logError("Unable to create a launch configuration from a LaunchShortcut", e); //$NON-NLS-1$
+ }
+ return config;
+ }
+
+ private List<IHost> findHosts() {
+ IHost[] hosts = RSECorePlugin.getTheSystemRegistry().getHosts();
+ ArrayList<IHost> newHostList = new ArrayList<IHost>();
+
+ for (IHost host : hosts) {
+ boolean isFileSubSystem = false;
+ boolean isLuaSubSystem = false;
+
+ for (ISubSystem subsystem : host.getSubSystems()) {
+ if (subsystem instanceof IRemoteFileSubSystem) {
+ isFileSubSystem = true;
+ }
+ if (subsystem instanceof LuaSubSystem) {
+ isLuaSubSystem = true;
+ }
+ }
+ if (isFileSubSystem && isLuaSubSystem) {
+ newHostList.add(host);
+ }
+ }
+ return newHostList;
+
+ }
+
+}
diff --git a/plugins/org.eclipse.koneki.ldt.remote.debug.ui/src/org/eclipse/koneki/ldt/remote/debug/ui/internal/launch/Messages.java b/plugins/org.eclipse.koneki.ldt.remote.debug.ui/src/org/eclipse/koneki/ldt/remote/debug/ui/internal/launch/Messages.java
new file mode 100644
index 0000000..e06fa24
--- /dev/null
+++ b/plugins/org.eclipse.koneki.ldt.remote.debug.ui/src/org/eclipse/koneki/ldt/remote/debug/ui/internal/launch/Messages.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Sierra Wireless and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Sierra Wireless - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.koneki.ldt.remote.debug.ui.internal.launch;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * TODO Comment this class
+ */
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.koneki.ldt.remote.debug.ui.internal.launch.messages"; //$NON-NLS-1$
+ public static String LuaRemoteLaunchShortcut_notargetdialog_message;
+ public static String LuaRemoteLaunchShortcut_notargetdialog_title;
+ public static String LuaRemoteLaunchShortcut_selectHost_message;
+ public static String LuaRemoteLaunchShortcut_selectHostDialog_title;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/plugins/org.eclipse.koneki.ldt.remote.debug.ui/src/org/eclipse/koneki/ldt/remote/debug/ui/internal/launch/messages.properties b/plugins/org.eclipse.koneki.ldt.remote.debug.ui/src/org/eclipse/koneki/ldt/remote/debug/ui/internal/launch/messages.properties
new file mode 100644
index 0000000..8e45872
--- /dev/null
+++ b/plugins/org.eclipse.koneki.ldt.remote.debug.ui/src/org/eclipse/koneki/ldt/remote/debug/ui/internal/launch/messages.properties
@@ -0,0 +1,4 @@
+LuaRemoteLaunchShortcut_notargetdialog_message=No lua target have been found. Do you want to create a new one ?
+LuaRemoteLaunchShortcut_notargetdialog_title=No lua target found
+LuaRemoteLaunchShortcut_selectHost_message=Select a host from the list to launch the lua application with.
+LuaRemoteLaunchShortcut_selectHostDialog_title=Select a host