Browse Source

launch configuration ui

Andreas Mülder 14 years ago
parent
commit
6a8db48a26

+ 3 - 1
plugins/org.yakindu.sct.ui.simulation/META-INF/MANIFEST.MF

@@ -10,6 +10,8 @@ Require-Bundle: org.eclipse.ui,
  org.eclipse.emf.ecore;bundle-version="2.7.0",
  de.itemis.gmf.runtime.commons;bundle-version="1.0.0",
  org.eclipse.gmf.runtime.diagram.ui.resources.editor;bundle-version="1.4.1",
- org.eclipse.gmf.runtime.diagram.ui;bundle-version="1.5.0"
+ org.eclipse.gmf.runtime.diagram.ui;bundle-version="1.5.0",
+ org.eclipse.debug.ui;bundle-version="3.7.0",
+ org.yakindu.sct.core.simulation;bundle-version="1.0.0"
 Bundle-RequiredExecutionEnvironment: J2SE-1.5
 Bundle-ActivationPolicy: lazy

BIN
plugins/org.yakindu.sct.ui.simulation/icons/yakindu.png


+ 42 - 3
plugins/org.yakindu.sct.ui.simulation/plugin.xml

@@ -1,15 +1,54 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?eclipse version="3.4"?>
 <plugin>
+	<!-- Editor Highlighting Adapter -->
    <extension
          point="org.eclipse.core.runtime.adapters">
       <factory
             adaptableType="org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor"
-            class="org.yakindu.sct.ui.simulation.IHighlightingSupportAdapterFactory">
+            class="org.yakindu.sct.ui.simulation.editor.IHighlightingSupportAdapterFactory">
          <adapter
-               type="org.yakindu.sct.ui.simulation.IHighlightingSupportAdapterFactory">
+               type="org.yakindu.sct.ui.simulation.editor.IHighlightingSupportAdapterFactory">
          </adapter>
       </factory>
    </extension>
-
+	
+	<!-- Launch configuration images -->
+   <extension point="org.eclipse.debug.ui.launchConfigurationTypeImages">
+    	<launchConfigurationTypeImage
+        	icon="icons/yakindu.png"
+        	configTypeID="org.yakindu.sct.core.simulation.launch.statechart"
+        	id="org.yakindu.sct.core.simulation.launch.statechartTypeImage">
+	    </launchConfigurationTypeImage>
+	</extension>
+	
+	<!-- launch tab group -->
+	<extension point="org.eclipse.debug.ui.launchConfigurationTabGroups">
+  	  <launchConfigurationTabGroup
+    	 type="org.yakindu.sct.core.simulation.launch.statechart"
+  	     class="org.yakindu.sct.ui.simulation.launch.tabs.StatechartLaunchConfigurationTabGroup"
+  	     id="org.yakindu.sct.ui.simulation.launch.tabs.statechart.tabs">
+   	 </launchConfigurationTabGroup>
+	</extension>
+	
+	<!-- launch shortcuts -->
+	<extension point="org.eclipse.debug.ui.launchShortcuts">
+	    <shortcut
+	        id="org.yakindu.sct.core.simulation.launch.shortcut"
+	        class="org.yakindu.sct.ui.simulation.launch.StatechartLaunchShortcut"
+	        label="YAKINDU Statechart"
+	        icon="icons/yakindu.png"
+	        modes="run, debug">
+	         <contextualLaunch>
+				<enablement>
+					<with variable="selection">
+					<count value="1"/>
+						<iterate>
+							<test property="org.eclipse.debug.ui.matchesPattern" value="*.sct"/>
+						</iterate>
+					</with>
+				</enablement>
+		  	 </contextualLaunch>
+	    </shortcut>
+	</extension>
 </plugin>

+ 12 - 2
plugins/org.yakindu.sct.ui.simulation/src/org/yakindu/sct/ui/simulation/IHighlightingSupportAdapterFactory.java

@@ -1,4 +1,14 @@
-package org.yakindu.sct.ui.simulation;
+/**
+ * Copyright (c) 2011 committers of YAKINDU 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:
+ * 	committers of YAKINDU - initial API and implementation
+ * 
+ */
+package org.yakindu.sct.ui.simulation.editor;
 
 import org.eclipse.core.runtime.IAdapterFactory;
 import org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.DiagramDocumentEditor;
@@ -9,7 +19,7 @@ import de.itemis.gmf.runtime.commons.highlighting.IHighlightingSupport;
 /**
  * Adapts GMF Editors to a {@link IHighlightingSupport}
  * 
- * @author muelder
+ * @author andreas muelder
  * 
  */
 @SuppressWarnings({ "rawtypes" })

+ 77 - 0
plugins/org.yakindu.sct.ui.simulation/src/org/yakindu/sct/ui/simulation/launch/StatechartLaunchShortcut.java

@@ -0,0 +1,77 @@
+/**
+ * Copyright (c) 2011 committers of YAKINDU 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:
+ * 	committers of YAKINDU - initial API and implementation
+ * 
+ */
+package org.yakindu.sct.ui.simulation.launch;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+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.debug.core.ILaunchManager;
+import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.debug.ui.ILaunchShortcut;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IEditorPart;
+import org.yakindu.sct.core.simulation.launch.IStatechartLaunchConfigurationType;
+
+/**
+ * 
+ * @author andreas muelder
+ * 
+ */
+public class StatechartLaunchShortcut implements ILaunchShortcut,
+		IStatechartLaunchConfigurationType {
+
+	public void launch(ISelection selection, String mode) {
+		if (selection instanceof IStructuredSelection) {
+			final IStructuredSelection structuredSelection = (IStructuredSelection) selection;
+			final Object object = structuredSelection.getFirstElement();
+			if (object instanceof IAdaptable) {
+				IFile file = (IFile) ((IAdaptable) object)
+						.getAdapter(IResource.class);
+				launch(file, mode);
+			}
+		}
+	}
+
+	public void launch(IEditorPart editor, String mode) {
+		IResource resource = (IResource) editor.getEditorInput().getAdapter(
+				IResource.class);
+		launch((IFile) resource, mode);
+	}
+
+	protected void launch(IFile file, String mode) {
+		// TODO: Check for existing launch configuration
+		ILaunchConfiguration launchConfiguration = createNewLaunchConfiguration(file);
+		DebugUITools.launch(launchConfiguration, mode);
+	}
+
+	private ILaunchConfiguration createNewLaunchConfiguration(IFile file) {
+		final ILaunchManager launchManager = DebugPlugin.getDefault()
+				.getLaunchManager();
+		final ILaunchConfigurationType configType = launchManager
+				.getLaunchConfigurationType(CONFIG_TYPE);
+		try {
+			ILaunchConfigurationWorkingCopy newConfig = configType.newInstance(
+					null, launchManager.generateLaunchConfigurationName(file
+							.getName()));
+			return newConfig.doSave();
+		} catch (CoreException e) {
+			e.printStackTrace();
+		}
+		throw new IllegalStateException();
+	}
+
+}

+ 35 - 0
plugins/org.yakindu.sct.ui.simulation/src/org/yakindu/sct/ui/simulation/launch/tabs/StatechartLaunchConfigurationTabGroup.java

@@ -0,0 +1,35 @@
+/**
+ * Copyright (c) 2011 committers of YAKINDU 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:
+ * 	committers of YAKINDU - initial API and implementation
+ * 
+ */
+package org.yakindu.sct.ui.simulation.launch.tabs;
+
+import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
+import org.eclipse.debug.ui.ILaunchConfigurationDialog;
+import org.eclipse.debug.ui.ILaunchConfigurationTab;
+
+/**
+ * 
+ * @author andreas muelder
+ * 
+ */
+public class StatechartLaunchConfigurationTabGroup extends
+		AbstractLaunchConfigurationTabGroup {
+
+	public StatechartLaunchConfigurationTabGroup() {
+	}
+
+	public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
+		ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] {
+		// TODO: Tabs here....
+		};
+		setTabs(tabs);
+	}
+
+}