\r
import org.argeo.slc.ui.launch.SlcUiLaunchPlugin;\r
import org.eclipse.core.resources.IFile;\r
-import org.eclipse.core.resources.IResource;\r
import org.eclipse.core.runtime.CoreException;\r
import org.eclipse.core.runtime.IPath;\r
+import org.eclipse.core.runtime.IStatus;\r
+import org.eclipse.core.runtime.Status;\r
import org.eclipse.debug.core.DebugPlugin;\r
import org.eclipse.debug.core.ILaunchConfiguration;\r
import org.eclipse.debug.core.ILaunchConfigurationType;\r
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;\r
import org.eclipse.debug.core.ILaunchManager;\r
+import org.eclipse.debug.ui.DebugUITools;\r
+import org.eclipse.debug.ui.IDebugUIConstants;\r
import org.eclipse.debug.ui.ILaunchShortcut;\r
import org.eclipse.jface.dialogs.ErrorDialog;\r
import org.eclipse.jface.viewers.ISelection;\r
import org.eclipse.ui.IEditorPart;\r
\r
public class SlcScriptLaunchShortcut implements ILaunchShortcut {\r
+ private boolean showDialog = false;\r
\r
public void launch(ISelection selection, String mode) {\r
try {\r
.getLaunchConfigurationType(SlcScriptLaunchDelegate.ID);\r
\r
// Find or create config\r
- ILaunchConfiguration config = findLaunchConfiguration(file, manager\r
- .getLaunchConfigurations(type));\r
+ String configLocation = SlcScriptUtils\r
+ .convertToWorkspaceLocation(file);\r
+ ILaunchConfiguration config = findLaunchConfiguration(\r
+ configLocation, manager.getLaunchConfigurations(type));\r
if (config == null) {\r
ILaunchConfigurationWorkingCopy wc = type.newInstance(null,\r
generateName(file));\r
+ wc.setAttribute(SlcScriptUtils.ATTR_SCRIPT, configLocation);\r
wc.setMappedResources(new IFile[] { file });\r
config = wc.doSave();\r
}\r
- \r
+\r
// Launch\r
- config.launch(mode, null);\r
+ launch(config, mode);\r
} catch (CoreException e) {\r
Shell shell = SlcUiLaunchPlugin.getDefault().getWorkbench()\r
.getActiveWorkbenchWindow().getShell();\r
return name;\r
}\r
\r
- protected ILaunchConfiguration findLaunchConfiguration(IFile file,\r
- ILaunchConfiguration[] configs) throws CoreException {\r
+ protected ILaunchConfiguration findLaunchConfiguration(\r
+ String configLocation, ILaunchConfiguration[] configs)\r
+ throws CoreException {\r
for (ILaunchConfiguration config : configs) {\r
- IResource[] res = config.getMappedResources();\r
- if (res.length > 1) {\r
- IFile fileT = (IFile) res[0];\r
- if (fileT.equals(file)) {\r
- return config;\r
- }\r
+ String loc = config.getAttribute(SlcScriptUtils.ATTR_SCRIPT, "");\r
+ if (loc.equals(configLocation)) {\r
+ return config;\r
}\r
}\r
return null;\r
}\r
\r
+ protected void launch(ILaunchConfiguration configuration, String mode)\r
+ throws CoreException {\r
+ if (showDialog) {\r
+ IStatus status = new Status(IStatus.INFO, SlcUiLaunchPlugin.ID,\r
+ "Configure SLC Launch");\r
+ String groupId;\r
+ if (mode.equals(ILaunchManager.DEBUG_MODE)) {\r
+ groupId = IDebugUIConstants.ID_DEBUG_LAUNCH_GROUP;\r
+ } else {\r
+ groupId = IDebugUIConstants.ID_RUN_LAUNCH_GROUP;\r
+ }\r
+ DebugUITools.openLaunchConfigurationDialog(SlcUiLaunchPlugin\r
+ .getDefault().getWorkbench().getActiveWorkbenchWindow()\r
+ .getShell(), configuration, groupId, status);\r
+ } else {\r
+ DebugUITools.launch(configuration, mode);\r
+ }\r
+\r
+ }\r
+\r
public void launch(IEditorPart editor, String mode) {\r
// not (yet) implemented\r
}\r
\r
+ public void setShowDialog(boolean showDialog) {\r
+ this.showDialog = showDialog;\r
+ }\r
+\r
}\r