diff --git a/bundles/io.openliberty.tools.eclipse.ui/META-INF/MANIFEST.MF b/bundles/io.openliberty.tools.eclipse.ui/META-INF/MANIFEST.MF index 31498492..09b6e000 100644 --- a/bundles/io.openliberty.tools.eclipse.ui/META-INF/MANIFEST.MF +++ b/bundles/io.openliberty.tools.eclipse.ui/META-INF/MANIFEST.MF @@ -27,6 +27,8 @@ Import-Package: org.eclipse.cdt.launch.ui, org.eclipse.debug.core, org.eclipse.debug.core.model, org.eclipse.debug.core.sourcelookup, + org.eclipse.debug.internal.ui, + org.eclipse.debug.internal.ui.actions, org.eclipse.debug.ui, org.eclipse.debug.ui.sourcelookup, org.eclipse.jdi, diff --git a/bundles/io.openliberty.tools.eclipse.ui/plugin.xml b/bundles/io.openliberty.tools.eclipse.ui/plugin.xml index c6cb7875..0c1921ec 100644 --- a/bundles/io.openliberty.tools.eclipse.ui/plugin.xml +++ b/bundles/io.openliberty.tools.eclipse.ui/plugin.xml @@ -713,4 +713,30 @@ name="Liberty"> + + + + + + + + + + + diff --git a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/DevModeOperations.java b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/DevModeOperations.java index 2817edcf..54387f2d 100644 --- a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/DevModeOperations.java +++ b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/DevModeOperations.java @@ -104,7 +104,7 @@ public class DevModeOperations { /** * Handles debug mode processing. */ - private DebugModeHandler debugModeHandler; + public DebugModeHandler debugModeHandler; /** * The instance of this class. diff --git a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/debug/LibertyDebugDisconnectActionDelegate.java b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/debug/LibertyDebugDisconnectActionDelegate.java new file mode 100644 index 00000000..7c81576f --- /dev/null +++ b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/debug/LibertyDebugDisconnectActionDelegate.java @@ -0,0 +1,24 @@ +package io.openliberty.tools.eclipse.debug; + +import java.util.Arrays; + +import org.eclipse.debug.core.DebugException; +import org.eclipse.debug.core.ILaunch; +import org.eclipse.debug.core.model.IDebugTarget; +import org.eclipse.debug.internal.ui.DebugUIPlugin; +import org.eclipse.debug.internal.ui.actions.AbstractDebugActionDelegate; + +public class LibertyDebugDisconnectActionDelegate extends AbstractDebugActionDelegate { + + @Override + protected void doAction(Object object) throws DebugException { + + ILaunch launch = DebugUIPlugin.getLaunch(object); + for (IDebugTarget target : Arrays.asList(launch.getDebugTargets())) { + if (target instanceof LibertyDebugTarget) { + ((LibertyDebugTarget) target).setRelaunch(false); + } + target.disconnect(); + } + } +} diff --git a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/debug/LibertyDebugRelaunchActionDelegate.java b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/debug/LibertyDebugRelaunchActionDelegate.java new file mode 100644 index 00000000..66093705 --- /dev/null +++ b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/debug/LibertyDebugRelaunchActionDelegate.java @@ -0,0 +1,37 @@ +package io.openliberty.tools.eclipse.debug; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.debug.core.ILaunch; +import org.eclipse.debug.internal.ui.DebugUIPlugin; +import org.eclipse.debug.internal.ui.actions.AbstractDebugActionDelegate; + +import io.openliberty.tools.eclipse.DevModeOperations; +import io.openliberty.tools.eclipse.Project; +import io.openliberty.tools.eclipse.ui.launch.StartTab; + +public class LibertyDebugRelaunchActionDelegate extends AbstractDebugActionDelegate { + + @Override + protected void doAction(Object object) { + ILaunch launch = DebugUIPlugin.getLaunch(object); + + if (launch != null) { + DevModeOperations devModeOps = DevModeOperations.getInstance(); + + String projectName = ""; + try { + projectName = launch.getLaunchConfiguration().getAttribute(StartTab.PROJECT_NAME, ""); + } catch (CoreException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + Project project = devModeOps.getProjectModel().getProject(projectName); + + if (!devModeOps.isProjectTerminalTabMarkedClosed(projectName)) { + devModeOps.debugModeHandler.startDebugAttacher(project, launch, null, true); + } + + } + } +} diff --git a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/debug/LibertyDebugTarget.java b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/debug/LibertyDebugTarget.java index aeb964ba..510b0ecd 100644 --- a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/debug/LibertyDebugTarget.java +++ b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/debug/LibertyDebugTarget.java @@ -16,11 +16,18 @@ public class LibertyDebugTarget extends JDIDebugTarget { private RestartDebugger restartDebugger; + private boolean relaunch; public LibertyDebugTarget(ILaunch launch, VirtualMachine jvm, String name, RestartDebugger restartDebugger) { super(launch, jvm, "Liberty Application Debug: " + name, true, true, null, true); this.restartDebugger = restartDebugger; + this.relaunch = true; + + } + + public void setRelaunch(boolean relaunch) { + this.relaunch = relaunch; } @Override @@ -44,9 +51,28 @@ protected void disconnected() { cleanup(); getLaunch().removeDebugTarget(this); - restartDebugger.restart(); - restartDebugger = null; + + // Attempt to restart the debugger + if (relaunch) { + restartDebugger.restart(); + restartDebugger = null; + } } } + // @Override + // public void disconnect() throws DebugException { + // // If we got here, the user explicitly called "disconnect" on the debugger. + // // We should not try to reconnect in this case but we should allow the user + // // to select "relaunch" which should just reconnect the debugger. + // // Since we cant differentiate between a normal "launch" and a "relaunch", + // // we will set a flag that we will use to determine if we should launch devMode + // // or just reconnect the debugger. + // restartDebugger = null; + // relaunch = true; + // + // super.disconnect(); + // + // } + } diff --git a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/LaunchConfigurationDelegateLauncher.java b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/LaunchConfigurationDelegateLauncher.java index 4fb2f7b6..68d2f54a 100644 --- a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/LaunchConfigurationDelegateLauncher.java +++ b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/LaunchConfigurationDelegateLauncher.java @@ -70,6 +70,8 @@ public void launch(ILaunchConfiguration configuration, String mode, ILaunch laun IWorkbench workbench = PlatformUI.getWorkbench(); Display display = workbench.getDisplay(); + // if (launch ==) + // Launch dev mode. display.syncExec(new Runnable() { public void run() {