[207518/208024] Debug 3.3 enhancements
diff --git a/plugins/org.eclipse.wst.server.ui/plugin.properties b/plugins/org.eclipse.wst.server.ui/plugin.properties
index e292c04..b2610e0 100644
--- a/plugins/org.eclipse.wst.server.ui/plugin.properties
+++ b/plugins/org.eclipse.wst.server.ui/plugin.properties
@@ -36,15 +36,16 @@
# Run on Server actions
actionRunOnServer=Run on Server
-actionRunOnServerDescription=Run the current selection on server
+actionRunOnServerDescription=Run the current selection on a server
actionDebugOnServer=Debug on Server
-actionDebugOnServerDescription=Debug the current selection on server
+actionDebugOnServerDescription=Debug the current selection on a server
actionPublish=Publish
actionPublishDescription=Publish to server
actionRun=Run
actionRunDescription=Run server
actionDebug=Debug
actionDebugDescription=Debug server
+actionProfileOnServer=Profile on Server
# --------------- Preferences and Property pages ---------------
@@ -57,6 +58,11 @@
propertiesServerInfo=General
propertiesMonitor=Monitoring
+runOnServerLaunchConfiguration=Run on Server
+launchConfigurationTabGroupDescription=Server launch selection
+launchConfigurationDelegateName=Run on Server
+launchConfigurationDelegateDescription=Runs applications on the server
+
# --------------- Editor ---------------
serverEditor=Server Editor
@@ -87,8 +93,6 @@
moduleProjectDecoratorLabel=Module Project
moduleProjectDecoratorDescription=Decorates server modules with information on the project that they come from
-runOnServerLaunchConfiguration=Run on Server
-
# --------------- Action Sets (toolbar icon groups) ---------------
# Web Browser action set
diff --git a/plugins/org.eclipse.wst.server.ui/plugin.xml b/plugins/org.eclipse.wst.server.ui/plugin.xml
index 3e5c984..5510c19 100644
--- a/plugins/org.eclipse.wst.server.ui/plugin.xml
+++ b/plugins/org.eclipse.wst.server.ui/plugin.xml
@@ -157,12 +157,14 @@
</extension>
<extension point="org.eclipse.debug.ui.launchShortcuts">
- <shortcut id="org.eclipse.wst.server.launchShortcut"
- label="%actionRunOnServer"
- class="org.eclipse.wst.server.ui.internal.ServerLaunchShortcut"
- modes="run, debug, profile"
- path="aa"
- icon="icons/etool16/run_on_server.gif">
+ <shortcut
+ id="org.eclipse.wst.server.launchShortcut"
+ label="%actionRunOnServer"
+ description="actionRunOnServerDescription"
+ modes="run, debug, profile"
+ path="aa"
+ icon="icons/etool16/run_on_server.gif"
+ class="org.eclipse.wst.server.ui.internal.ServerLaunchShortcut">
<contextualLaunch>
<enablement>
<with variable="selection">
@@ -172,7 +174,6 @@
</iterate>
</with>
</enablement>
-
<contextLabel
mode="run"
label="%actionRunOnServer"/>
@@ -183,6 +184,9 @@
mode="profile"
label="%actionProfileOnServer"/>
</contextualLaunch>
+ <configurationType
+ id="org.eclipse.wst.server.ui.launchConfigurationType">
+ </configurationType>
</shortcut>
</extension>
@@ -476,9 +480,11 @@
<extension point="org.eclipse.debug.core.launchConfigurationTypes">
<launchConfigurationType
id="org.eclipse.wst.server.ui.launchConfigurationType"
- name="%runOnServerLaunchConfiguration"
delegate="org.eclipse.wst.server.ui.internal.actions.RunOnServerLaunchConfigurationDelegate"
- modes="run,debug,profile"/>
+ delegateName="%launchConfigurationDelegateName"
+ delegateDescription="%launchConfigurationDelegateDescription"
+ modes="run,debug,profile"
+ name="%runOnServerLaunchConfiguration"/>
</extension>
<extension point="org.eclipse.debug.ui.launchConfigurationTypeImages">
@@ -491,9 +497,10 @@
<extension point="org.eclipse.debug.ui.launchConfigurationTabGroups">
<launchConfigurationTabGroup
- id="org.eclipse.wst.server.ui.launchConfigurationTabGroup"
- type="org.eclipse.wst.server.ui.launchConfigurationType"
- class="org.eclipse.wst.server.ui.internal.RunOnServerLaunchConfigurationTabGroup">
+ class="org.eclipse.wst.server.ui.internal.RunOnServerLaunchConfigurationTabGroup"
+ description="%launchConfigurationTabGroupDescription"
+ id="org.eclipse.wst.server.ui.launchConfigurationTabGroup"
+ type="org.eclipse.wst.server.ui.launchConfigurationType">
</launchConfigurationTabGroup>
</extension>
@@ -504,4 +511,4 @@
serverTypes="*"/>
</extension>
-</plugin>
\ No newline at end of file
+</plugin>
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerLaunchShortcut.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerLaunchShortcut.java
index e22812e..bd0504d 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerLaunchShortcut.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerLaunchShortcut.java
@@ -11,7 +11,9 @@
package org.eclipse.wst.server.ui.internal;
import org.eclipse.core.resources.IFile;
-import org.eclipse.debug.ui.ILaunchShortcut;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.ui.ILaunchShortcut2;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
@@ -25,9 +27,9 @@
/**
*
*/
-public class ServerLaunchShortcut implements ILaunchShortcut {
+public class ServerLaunchShortcut implements ILaunchShortcut2 {
/* (non-Javadoc)
- * @see org.eclipse.debug.ui.ILaunchShortcut#launch(org.eclipse.jface.viewers.ISelection, java.lang.String)
+ * @see ILaunchShortcut#launch(ISelection, String)
*/
public void launch(ISelection selection, final String mode) {
RunOnServerActionDelegate ros = new RunOnServerActionDelegate();
@@ -40,7 +42,7 @@
}
/* (non-Javadoc)
- * @see org.eclipse.debug.ui.ILaunchShortcut#launch(org.eclipse.ui.IEditorPart, java.lang.String)
+ * @see ILaunchShortcut#launch(IEditorPart, String)
*/
public void launch(IEditorPart editor, String mode) {
if (editor == null)
@@ -59,4 +61,74 @@
launch(new StructuredSelection(file), mode);
}
}
+
+ /**
+ * Given the specified <code>ISelection</code> this method returns an array of
+ * <code>ILaunchConfiguration</code>s that apply to the current selection,
+ * i.e. all of the launch configurations that could be used to launch the given
+ * selection.
+ * @param selection the current selection
+ * @return an array of <code>ILaunchConfiguration</code>s that could be
+ * used to launch the given selection, or an empty array, never <code>null</code>
+ */
+ public ILaunchConfiguration[] getLaunchConfigurations(ISelection selection) {
+ return new ILaunchConfiguration[0];
+ }
+
+ /* (non-Javadoc)
+ * @see ILaunchShortcut2#getLaunchConfigurations(IEditorPart)
+ */
+ public ILaunchConfiguration[] getLaunchConfigurations(IEditorPart editor) {
+ if (editor == null)
+ return new ILaunchConfiguration[0];
+
+ // check if the editor input itself can be run. Otherwise, check if
+ // the editor has a file input that can be run
+ IEditorInput input = editor.getEditorInput();
+
+ if (ServerPlugin.hasModuleArtifact(input)) {
+ return getLaunchConfigurations(new StructuredSelection(input));
+ } else if (input instanceof IFileEditorInput) {
+ IFileEditorInput fei = (IFileEditorInput) input;
+ IFile file = fei.getFile();
+ if (ServerPlugin.hasModuleArtifact(file))
+ return getLaunchConfigurations(new StructuredSelection(file));
+ }
+ return new ILaunchConfiguration[0];
+ }
+
+ /**
+ * Given the specified <code>ISelection</code> this method returns an
+ * <code>IResource</code> that directly maps to the current selection.
+ * This mapping is then leveraged by the context launching framework
+ * to try and launch the resource.
+ * @param selection the current selection
+ * @return an <code>IResource</code> that would be used during context
+ * sensitive launching or <code>null</code> if one is not to be provided or does not exist.
+ */
+ public IResource getLaunchableResource(ISelection selection) {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see ILaunchShortcut2#getLaunchableResource(IEditorPart)
+ */
+ public IResource getLaunchableResource(IEditorPart editor) {
+ if (editor == null)
+ return null;
+
+ // check if the editor input itself can be run. Otherwise, check if
+ // the editor has a file input that can be run
+ IEditorInput input = editor.getEditorInput();
+
+ if (ServerPlugin.hasModuleArtifact(input)) {
+ return getLaunchableResource(new StructuredSelection(input));
+ } else if (input instanceof IFileEditorInput) {
+ IFileEditorInput fei = (IFileEditorInput) input;
+ IFile file = fei.getFile();
+ if (ServerPlugin.hasModuleArtifact(file))
+ return getLaunchableResource(new StructuredSelection(file));
+ }
+ return null;
+ }
}
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/RunOnServerActionDelegate.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/RunOnServerActionDelegate.java
index 19578f6..093b443 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/RunOnServerActionDelegate.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/RunOnServerActionDelegate.java
@@ -16,6 +16,8 @@
import java.util.Map;
import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.*;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.debug.core.*;
@@ -457,8 +459,15 @@
config.setAttribute(RunOnServerLaunchConfigurationDelegate.ATTR_MODULE_ARTIFACT_CLASS, moduleArtifact.getClass().getName());
config.setAttribute(RunOnServerLaunchConfigurationDelegate.ATTR_LAUNCHABLE_ADAPTER_ID, launchableAdapter.getId());
config.setAttribute(RunOnServerLaunchConfigurationDelegate.ATTR_CLIENT_ID, client.getId());
- }
-
+
+ try {
+ IProject project = moduleArtifact.getModule().getProject();
+ config.setMappedResources(new IResource[] { project });
+ } catch (Exception e) {
+ Trace.trace(Trace.WARNING, "Could not associate launch with a project", e);
+ }
+ }
+
protected ILaunchConfiguration getLaunchConfiguration(IServer server, ModuleArtifactDelegate moduleArtifact, ILaunchableAdapter launchableAdapter2, IClient client2, IProgressMonitor monitor) throws CoreException {
String serverId = server.getId();
ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();