Initial AMP Contribution per CQ 3295.
diff --git a/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/.classpath b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/.classpath
new file mode 100644
index 0000000..2d1a430
--- /dev/null
+++ b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/.project b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/.project
new file mode 100644
index 0000000..d35e31b
--- /dev/null
+++ b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.amp.axf.ide</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/META-INF/MANIFEST.MF b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..cceb2b5
--- /dev/null
+++ b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/META-INF/MANIFEST.MF
@@ -0,0 +1,39 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %pluginName
+Bundle-Vendor: %providerName
+Bundle-SymbolicName: org.eclipse.amp.axf.ide;singleton:=true
+Bundle-Version: 0.2.0.qualifier
+Bundle-Activator: org.eclipse.amp.axf.ide.AXFWorkbenchPlugin
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.core.commands;bundle-version="3.4.0",
+ org.eclipse.ui;bundle-version="3.4.0",
+ org.eclipse.core.expressions;bundle-version="3.4.0",
+ org.eclipse.ui.views;bundle-version="3.3.0",
+ org.eclipse.pde.runtime;bundle-version="3.4.100",
+ org.eclipse.pde.ui;bundle-version="3.5.0",
+ org.eclipse.amp.axf.core,
+ org.eclipse.amp.axf.views
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Export-Package: org.eclipse.amp.axf.ide;
+ uses:="org.eclipse.core.runtime,
+ org.eclipse.ui,
+ org.eclipse.ui.plugin,
+ org.eclipse.amp.axf.core,
+ org.eclipse.ui.part,
+ org.eclipse.amp.axf.ide.view,
+ org.eclipse.amp.axf.ide.handlers,
+ org.eclipse.swt.graphics,
+ org.eclipse.jface.viewers,
+ org.osgi.framework,
+ org.eclipse.swt.widgets",
+ org.eclipse.amp.axf.ide.handlers;uses:="org.eclipse.core.runtime,org.eclipse.amp.axf.core,org.eclipse.core.commands",
+ org.eclipse.amp.axf.ide.view;
+ uses:="org.eclipse.core.runtime,
+ org.eclipse.swt.events,
+ org.eclipse.ui,
+ org.eclipse.ui.menus,
+ org.eclipse.amp.axf.view,
+ org.eclipse.amp.axf.core,
+ org.eclipse.swt.widgets"
+Bundle-ActivationPolicy: lazy
diff --git a/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/build.properties b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/build.properties
new file mode 100644
index 0000000..79785ac
--- /dev/null
+++ b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/build.properties
@@ -0,0 +1,6 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ icons/,\
+ plugin.xml
diff --git a/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/icons/dtool16/run_close.gif b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/icons/dtool16/run_close.gif
new file mode 100755
index 0000000..9e14298
--- /dev/null
+++ b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/icons/dtool16/run_close.gif
Binary files differ
diff --git a/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/icons/dtool16/run_exc.gif b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/icons/dtool16/run_exc.gif
new file mode 100755
index 0000000..010581b
--- /dev/null
+++ b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/icons/dtool16/run_exc.gif
Binary files differ
diff --git a/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/icons/dtool16/run_pause.gif b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/icons/dtool16/run_pause.gif
new file mode 100755
index 0000000..e47777b
--- /dev/null
+++ b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/icons/dtool16/run_pause.gif
Binary files differ
diff --git a/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/icons/dtool16/run_resume.gif b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/icons/dtool16/run_resume.gif
new file mode 100755
index 0000000..8652797
--- /dev/null
+++ b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/icons/dtool16/run_resume.gif
Binary files differ
diff --git a/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/icons/dtool16/run_step.gif b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/icons/dtool16/run_step.gif
new file mode 100755
index 0000000..319fe8d
--- /dev/null
+++ b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/icons/dtool16/run_step.gif
Binary files differ
diff --git a/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/icons/dtool16/run_stop.gif b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/icons/dtool16/run_stop.gif
new file mode 100755
index 0000000..4f3dcba
--- /dev/null
+++ b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/icons/dtool16/run_stop.gif
Binary files differ
diff --git a/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/icons/etool16/generic_agent.gif b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/icons/etool16/generic_agent.gif
new file mode 100644
index 0000000..0f07692
--- /dev/null
+++ b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/icons/etool16/generic_agent.gif
Binary files differ
diff --git a/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/icons/etool16/listener.gif b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/icons/etool16/listener.gif
new file mode 100644
index 0000000..7d1ece1
--- /dev/null
+++ b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/icons/etool16/listener.gif
Binary files differ
diff --git a/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/icons/etool16/model_mananger.gif b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/icons/etool16/model_mananger.gif
new file mode 100644
index 0000000..0a1fa96
--- /dev/null
+++ b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/icons/etool16/model_mananger.gif
Binary files differ
diff --git a/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/icons/etool16/model_paused.gif b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/icons/etool16/model_paused.gif
new file mode 100644
index 0000000..45c23a9
--- /dev/null
+++ b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/icons/etool16/model_paused.gif
Binary files differ
diff --git a/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/icons/etool16/model_running.gif b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/icons/etool16/model_running.gif
new file mode 100644
index 0000000..b8ca14a
--- /dev/null
+++ b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/icons/etool16/model_running.gif
Binary files differ
diff --git a/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/icons/etool16/model_stopped.gif b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/icons/etool16/model_stopped.gif
new file mode 100644
index 0000000..a7302ed
--- /dev/null
+++ b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/icons/etool16/model_stopped.gif
Binary files differ
diff --git a/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/icons/etool16/run_close.gif b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/icons/etool16/run_close.gif
new file mode 100755
index 0000000..b6922ac
--- /dev/null
+++ b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/icons/etool16/run_close.gif
Binary files differ
diff --git a/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/icons/etool16/run_exc.gif b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/icons/etool16/run_exc.gif
new file mode 100644
index 0000000..ec477ea
--- /dev/null
+++ b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/icons/etool16/run_exc.gif
Binary files differ
diff --git a/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/icons/etool16/run_pause.gif b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/icons/etool16/run_pause.gif
new file mode 100644
index 0000000..161e3f5
--- /dev/null
+++ b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/icons/etool16/run_pause.gif
Binary files differ
diff --git a/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/icons/etool16/run_restart.gif b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/icons/etool16/run_restart.gif
new file mode 100644
index 0000000..88276ce
--- /dev/null
+++ b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/icons/etool16/run_restart.gif
Binary files differ
diff --git a/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/icons/etool16/run_resume.gif b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/icons/etool16/run_resume.gif
new file mode 100644
index 0000000..16f4e25
--- /dev/null
+++ b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/icons/etool16/run_resume.gif
Binary files differ
diff --git a/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/icons/etool16/run_step.gif b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/icons/etool16/run_step.gif
new file mode 100755
index 0000000..e3a7cc7
--- /dev/null
+++ b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/icons/etool16/run_step.gif
Binary files differ
diff --git a/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/icons/etool16/run_stop.gif b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/icons/etool16/run_stop.gif
new file mode 100644
index 0000000..69c31f4
--- /dev/null
+++ b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/icons/etool16/run_stop.gif
Binary files differ
diff --git a/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/plugin.properties b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/plugin.properties
new file mode 100644
index 0000000..b7890d5
--- /dev/null
+++ b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/plugin.properties
@@ -0,0 +1,32 @@
+# /**
+# * <copyright>
+# *
+# * Copyright (c) 2009 Metascape, LLC.
+# * 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:
+# * Metascape - Initial API and Implementation
+# *
+# * </copyright>
+# *
+# * $Id: plugin.properties
+# */
+
+
+# ====================================================================
+# To code developer:
+# Do NOT change the properties between this line and the
+# "%%% END OF TRANSLATED PROPERTIES %%%" line.
+# Make a new property name, append to the end of the file and change
+# the code to use the new property.
+# ====================================================================
+
+# ====================================================================
+# %%% END OF TRANSLATED PROPERTIES %%%
+# ====================================================================
+
+pluginName = Agent Execution Framework IDE Integration
+providerName = Eclipse.org
diff --git a/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/plugin.xml b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/plugin.xml
new file mode 100644
index 0000000..08aea84
--- /dev/null
+++ b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/plugin.xml
@@ -0,0 +1,477 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
+
+<!--
+ <copyright>
+ </copyright>
+
+ $Id: plugin.xml,v 1.1 2009/06/24 03:17:07 mparker Exp $
+-->
+
+<plugin>
+ <extension
+ point="org.eclipse.ui.commands">
+ <category
+ description="Running and Exploring Models"
+ id="org.eclipse.amp.axf.ui"
+ name="Model Execution Engine">
+ </category>
+ <command
+ categoryId="org.eclipse.amp.axf.ui"
+ id="org.eclipse.amp.axf.ui.start"
+ name="Start">
+ </command>
+ <command
+ categoryId="org.eclipse.amp.axf.ui"
+ id="org.eclipse.amp.axf.ui.pause"
+ name="Pause">
+ </command>
+ <command
+ categoryId="org.eclipse.amp.axf.ui"
+ id="org.eclipse.amp.axf.ui.step"
+ name="Step">
+ </command>
+ <command
+ categoryId="org.eclipse.amp.axf.ui"
+ id="org.eclipse.amp.axf.ui.resume"
+ name="Resume">
+ </command>
+ <command
+ categoryId="org.eclipse.amp.axf.ui"
+ id="org.eclipse.amp.axf.ui.stop"
+ name="Stop">
+ </command>
+ <command
+ categoryId="org.eclipse.amp.axf.ui"
+ id="org.eclipse.amp.axf.ui.restart"
+ name="Restart">
+ </command>
+ <command
+ categoryId="org.eclipse.amp.axf.ui"
+ id="org.eclipse.amp.axf.ui.close"
+ name="Close">
+ </command>
+ </extension>
+ <extension
+ point="org.eclipse.ui.menus">
+ <menuContribution
+ locationURI="toolbar:org.eclipse.ui.main.toolbar?after=additions">
+ <toolbar
+ id="org.eclipse.amp.axf.ui.execute">
+
+ </toolbar>
+ </menuContribution>
+ <menuContribution
+ locationURI="menu:org.eclipse.ui.main.menu?after=additions">
+ <menu
+ id="org.eclipse.amp.axf.ui.menu"
+ label="Control">
+ <command
+ commandId="org.eclipse.amp.axf.ui.start"
+ disabledIcon="icons/dtool16/run_exc.gif"
+ icon="icons/etool16/run_exc.gif"
+ label="Start"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <reference
+ definitionId="org.eclipse.amp.axf.ui.active">
+ </reference>
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.amp.axf.ui.restart"
+ icon="icons/etool16/run_restart.gif"
+ label="Restart"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <reference
+ definitionId="org.eclipse.amp.axf.ui.active">
+ </reference>
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.amp.axf.ui.pause"
+ disabledIcon="icons/dtool16/run_pause.gif"
+ icon="icons/etool16/run_pause.gif"
+ label="Pause"
+ style="push"
+ tooltip="Pause the model.">
+ <visibleWhen
+ checkEnabled="false">
+ <reference
+ definitionId="org.eclipse.amp.axf.ui.active">
+ </reference>
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.amp.axf.ui.step"
+ disabledIcon="icons/dtool16/run_step.gif"
+ icon="icons/etool16/run_step.gif"
+ label="Step"
+ style="push"
+ tooltip="Move forward one step.">
+ <visibleWhen
+ checkEnabled="false">
+ <reference
+ definitionId="org.eclipse.amp.axf.ui.active">
+ </reference>
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.amp.axf.ui.resume"
+ disabledIcon="icons/dtool16/run_resume.gif"
+ icon="icons/etool16/run_resume.gif"
+ label="Resume"
+ style="push"
+ tooltip="Resume the active model.">
+ <visibleWhen
+ checkEnabled="false">
+ <reference
+ definitionId="org.eclipse.amp.axf.ui.active">
+ </reference>
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.amp.axf.ui.stop"
+ disabledIcon="icons/dtool16/run_stop.gif"
+ icon="icons/etool16/run_stop.gif"
+ label="Stop"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <reference
+ definitionId="org.eclipse.amp.axf.ui.active">
+ </reference>
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.amp.axf.ui.close"
+ disabledIcon="icons/dtool16/run_close.gif"
+ icon="icons/etool16/run_close.gif"
+ label="Close"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <reference
+ definitionId="org.eclipse.amp.axf.ui.active">
+ </reference>
+ </visibleWhen>
+ </command>
+ </menu>
+ </menuContribution>
+ <menuContribution
+ locationURI="toolbar:org.eclipse.amp.axf.ui.execute">
+ <separator
+ name="org.eclipse.amp.axf.ide.separator2">
+ </separator>
+ <command
+ commandId="org.eclipse.amp.axf.ui.start"
+ disabledIcon="icons/dtool16/run_exc.gif"
+ icon="icons/etool16/run_exc.gif"
+ label="Start"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <reference
+ definitionId="org.eclipse.amp.axf.ui.active">
+ </reference>
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.amp.axf.ui.restart"
+ icon="icons/etool16/run_restart.gif"
+ label="Restart"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <reference
+ definitionId="org.eclipse.amp.axf.ui.active">
+ </reference>
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.amp.axf.ui.pause"
+ disabledIcon="icons/dtool16/run_pause.gif"
+ icon="icons/etool16/run_pause.gif"
+ label="Pause"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <reference
+ definitionId="org.eclipse.amp.axf.ui.active">
+ </reference>
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.amp.axf.ui.step"
+ disabledIcon="icons/dtool16/run_step.gif"
+ icon="icons/etool16/run_step.gif"
+ label="Step"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <reference
+ definitionId="org.eclipse.amp.axf.ui.active">
+ </reference>
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.amp.axf.ui.resume"
+ disabledIcon="icons/dtool16/run_resume.gif"
+ icon="icons/etool16/run_resume.gif"
+ label="Resume"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <reference
+ definitionId="org.eclipse.amp.axf.ui.active">
+ </reference>
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.amp.axf.ui.stop"
+ disabledIcon="icons/dtool16/run_stop.gif"
+ icon="icons/etool16/run_stop.gif"
+ label="Stop"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <reference
+ definitionId="org.eclipse.amp.axf.ui.active">
+ </reference>
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.amp.axf.ui.close"
+ disabledIcon="icons/dtool16/run_close.gif"
+ icon="icons/etool16/run_close.gif"
+ label="Close"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <reference
+ definitionId="org.eclipse.amp.axf.ui.active">
+ </reference>
+ </visibleWhen>
+ </command>
+<!-- <control
+ class="org.eclipse.amp.axf.ide.view.ScaleGranularityControl"
+ id="org.eclipse.amp.axf.view.ui.slider">
+ <visibleWhen
+ checkEnabled="false">
+ <reference
+ definitionId="org.eclipse.amp.axf.ui.active">
+ </reference>
+ </visibleWhen>
+ </control>-->
+ </menuContribution>
+ </extension>
+ <extension point="org.eclipse.core.expressions.definitions">
+ <definition
+ id="org.eclipse.amp.axf.ui.active">
+ <with
+ variable="activeContexts">
+ <iterate
+ operator="or">
+ <equals
+ value="org.eclipse.amp.axf.executionContext">
+ </equals>
+ </iterate>
+ </with>
+ </definition>
+ </extension>
+ <extension
+ point="org.eclipse.ui.bindings">
+ <key
+ commandId="org.eclipse.amp.axf.ui.start"
+ contextId="org.eclipse.amp.axf.activeEditorContext"
+ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+ sequence="M2+M3+.">
+ </key>
+ <key
+ commandId="org.eclipse.amp.axf.ui.restart"
+ contextId="org.eclipse.amp.axf.activeEditorContext"
+ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+ sequence="M2+M3+,">
+ </key>
+ <key
+ commandId="org.eclipse.amp.axf.ui.pause"
+ contextId="org.eclipse.amp.axf.activeEditorContext"
+ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+ sequence="M2+M3+K">
+ </key>
+ <key
+ commandId="org.eclipse.amp.axf.ui.resume"
+ contextId="org.eclipse.amp.axf.activeEditorContext"
+ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+ sequence="M2+M3+L">
+ </key>
+ <key
+ commandId="org.eclipse.amp.axf.ui.step"
+ contextId="org.eclipse.amp.axf.activeEditorContext"
+ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+ sequence="M2+M3+SPACE">
+ </key>
+ </extension>
+ <extension
+ point="org.eclipse.ui.contexts">
+ <context
+ description="Executing model within Eclipse"
+ id="org.eclipse.amp.axf.executionContext"
+ name="Model Executing"
+ parentId="org.eclipse.ui.contexts.window">
+ </context>
+ <context
+ id="org.eclipse.amp.axf.activeEditorContext"
+ name="Model View">
+ </context>
+ </extension>
+
+ <extension
+ point="org.eclipse.ui.views">
+ <category
+ id="org.eclipse.amp.execution"
+ name="Model Execution">
+ </category>
+ <view
+ allowMultiple="false"
+ category="org.eclipse.amp.execution"
+ class="org.eclipse.amp.axf.ide.ModelManagerViewPart"
+ icon="icons/etool16/model_mananger.gif"
+ id="org.eclipse.amp.view.ModelManager"
+ name="Model Manager"
+ restorable="false">
+ </view>
+ </extension>
+ <extension
+ point="org.eclipse.ui.perspectives">
+ <perspective
+ class="org.eclipse.amp.axf.ide.ExecutionPerspectiveFactory"
+ icon="icons/etool16/generic_agent.gif"
+ id="org.eclipse.amp.axf.ExecutionPerspective"
+ name="Agent Execution">
+ <description>
+ Executing Escape models.
+ </description>
+ </perspective>
+ </extension>
+ <extension point="org.eclipse.ui.perspectiveExtensions">
+ <perspectiveExtension
+ targetID="org.eclipse.amp.axf.ExecutionPerspective">
+ <view
+ id="org.eclipse.jdt.ui.PackageExplorer"
+ minimized="false"
+ ratio=".25"
+ relationship="left"
+ relative="org.eclipse.ui.editorss"
+ standalone="false"
+ visible="true">
+ </view>
+ <view
+ id="org.eclipse.ui.views.ContentOutline"
+ minimized="true"
+ relationship="stack"
+ relative="org.eclipse.jdt.ui.PackageExplorer"
+ visible="true">
+ </view>
+ <view
+ id="org.eclipse.ui.views.PropertySheet"
+ minimized="false"
+ ratio=".70"
+ relationship="bottom"
+ relative="org.eclipse.jdt.ui.PackageExplorer"
+ visible="true">
+ </view>
+ <view
+ id="org.eclipse.ui.views.ProblemView"
+ minimized="true"
+ ratio=".8"
+ relationship="bottom"
+ relative="org.eclipse.ui.editorss"
+ visible="true">
+ </view>
+ <view
+ id="org.eclipse.ui.console.ConsoleView"
+ minimized="true"
+ relationship="stack"
+ relative="org.eclipse.ui.views.ProblemView"
+ visible="true">
+ </view>
+ <view
+ id="org.eclipse.pde.runtime.LogView"
+ minimized="true"
+ relationship="stack"
+ relative="org.eclipse.ui.views.ProblemView"
+ visible="true">
+ </view>
+ <view
+ id="org.eclipse.ui.views.ProgressView"
+ minimized="false"
+ relationship="stack"
+ relative="org.eclipse.ui.views.ProblemView">
+ </view>
+ <view
+ id="org.eclipse.amp.view.ModelManager"
+ relationship="stack"
+ relative="org.eclipse.jdt.ui.PackageExplorer"
+ visible="true">
+ </view>
+ <viewShortcut
+ id="org.eclipse.ui.views.PropertySheet">
+ </viewShortcut>
+ <viewShortcut
+ id="org.eclipse.ui.views.ProblemView">
+ </viewShortcut>
+ <viewShortcut
+ id="org.eclipse.ui.console.ConsoleView">
+ </viewShortcut>
+ <viewShortcut
+ id="org.eclipse.pde.runtime.LogView">
+ </viewShortcut>
+ <viewShortcut
+ id="org.eclipse.jdt.ui.SourceView">
+ </viewShortcut>
+ <viewShortcut
+ id="org.eclipse.ui.views.ProgressView">
+ </viewShortcut>
+ <newWizardShortcut
+ id="org.eclipse.amp.escape.wizards.newParameters">
+ </newWizardShortcut>
+ <newWizardShortcut
+ id="org.eclipse.amp.escape.wizards.newTest">
+ </newWizardShortcut>
+ <viewShortcut
+ id="org.eclipse.amp.view.ModelManager">
+ </viewShortcut>
+ </perspectiveExtension>
+<!-- <perspectiveExtension
+ targetID="???">
+ <perspectiveShortcut
+ id="org.eclipse.amp.axf.ExecutionPerspective">
+ </perspectiveShortcut>
+ <newWizardShortcut
+ id="org.eclipse.amp.escape.wizards.newProject">
+ </newWizardShortcut>
+ <newWizardShortcut
+ id="org.eclipse.amp.escape.wizards.newParameters">
+ </newWizardShortcut>
+ <newWizardShortcut
+ id="org.eclipse.amp.escape.wizards.newTest">
+ </newWizardShortcut>
+ </perspectiveExtension> -->
+ <perspectiveExtension
+ targetID="org.eclipse.jdt.ui.JavaPerspective">
+ <perspectiveShortcut
+ id="org.eclipse.amp.axf.ExecutionPerspective">
+ </perspectiveShortcut>
+ </perspectiveExtension>
+ </extension>
+ <extension
+ point="org.eclipse.ui.startup">
+ <startup>
+ </startup>
+ </extension>
+ </plugin>
+
diff --git a/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/AXFWorkbenchPlugin.java b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/AXFWorkbenchPlugin.java
new file mode 100644
index 0000000..e065aca
--- /dev/null
+++ b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/AXFWorkbenchPlugin.java
@@ -0,0 +1,94 @@
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2009 Metascape, LLC.
+ * 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:
+ * Metascape - Initial API and Implementation
+ *
+ * </copyright>
+ *
+ */
+package org.eclipse.amp.axf.ide;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.IStartup;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The activator class controls the plug-in life cycle.
+ */
+public class AXFWorkbenchPlugin extends AbstractUIPlugin implements IStartup {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.amp.axf.ide";
+
+ // The shared instance
+ private static AXFWorkbenchPlugin plugin;
+
+
+ private ModelViewManager manager;
+
+ /**
+ * The constructor.
+ */
+ public AXFWorkbenchPlugin() {
+ }
+
+
+ private Image loadImage(String name) {
+ ImageDescriptor desc = AbstractUIPlugin.imageDescriptorFromPlugin(PLUGIN_ID,
+ "icons/etool16/" + name);
+ return JFaceResources.getResources().createImageWithDefault(desc);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
+ */
+ /**
+ * @param context
+ * @throws Exception
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance.
+ *
+ * @return the shared instance
+ */
+ public static AXFWorkbenchPlugin getDefault() {
+ return plugin;
+ }
+
+ /**
+ * Gets the manager.
+ *
+ * @return the manager
+ */
+ public ModelViewManager getManager() {
+ return manager;
+ }
+
+ /**
+ *
+ * @see org.eclipse.ui.IStartup#earlyStartup()
+ */
+ public void earlyStartup() {
+ manager = new ModelViewManager();
+ plugin = this;
+ }
+}
diff --git a/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/ExecutionPerspectiveFactory.java b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/ExecutionPerspectiveFactory.java
new file mode 100644
index 0000000..c13ad77
--- /dev/null
+++ b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/ExecutionPerspectiveFactory.java
@@ -0,0 +1,35 @@
+/**
+ *
+ */
+package org.eclipse.amp.axf.ide;
+
+import org.eclipse.ui.IPageLayout;
+import org.eclipse.ui.IPerspectiveFactory;
+
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class ExecutionPerspectiveFactory.
+ *
+ * @author Miles Parker
+ */
+public class ExecutionPerspectiveFactory implements IPerspectiveFactory {
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * org.eclipse.ui.IPerspectiveFactory#createInitialLayout(org.eclipse.ui
+ * .IPageLayout)
+ */
+ /**
+ * @param layout
+ * @see org.eclipse.ui.IPerspectiveFactory#createInitialLayout(org.eclipse.ui.IPageLayout)
+ */
+ public void createInitialLayout(IPageLayout layout) {
+ layout.setEditorAreaVisible(false);
+// layout.addPlaceholder("org.eclipse.amp.escape.view.GraphicsView:S0", IPageLayout.RIGHT, .5f, "org.eclipse.jdt.ui.PackageExplorer");
+// layout.addPlaceholder("org.eclipse.amp.view.GEFView:S0", IPageLayout.RIGHT, .5f, "org.eclipse.jdt.ui.PackageExplorer");
+// layout.addPlaceholder("org.eclipse.amp.view.GEFView:S1", IPageLayout.RIGHT, .5f, "org.eclipse.jdt.ui.PackageExplorer");
+// layout.addPlaceholder("org.eclipse.amp.view.GEFView:S2", IPageLayout.RIGHT, .5f, "org.eclipse.jdt.ui.PackageExplorer");
+ }
+}
diff --git a/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/HandlerManager.java b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/HandlerManager.java
new file mode 100644
index 0000000..c96134b
--- /dev/null
+++ b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/HandlerManager.java
@@ -0,0 +1,76 @@
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2009 Metascape, LLC.
+ * 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:
+ * Metascape - Initial API and Implementation
+ *
+ * </copyright>
+ *
+ */
+
+package org.eclipse.amp.axf.ide;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.amp.axf.ide.handlers.ModelRunHandler;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.handlers.IHandlerActivation;
+import org.eclipse.ui.handlers.IHandlerService;
+
+/**
+ *
+ * @author mparker
+ *
+ */
+public class HandlerManager {
+
+ private IHandlerService handlerService;
+
+ private List<IHandlerActivation> handlerActivations;
+
+ private List<ModelRunHandler> handlers;
+
+ public synchronized void activate() {
+ handlerService = (IHandlerService) AXFWorkbenchPlugin.getDefault().getWorkbench()
+ .getService(IHandlerService.class);
+ handlerActivations = new ArrayList<IHandlerActivation>();
+ handlers = new ArrayList<ModelRunHandler>();
+ }
+
+ public synchronized void deactivate() {
+ if (handlerService != null) {
+ handlerService.deactivateHandlers(handlerActivations);
+ }
+ }
+
+ /**
+ * Adds the handler.
+ *
+ * @param id the id
+ * @param handler the handler
+ */
+ protected synchronized void addHandler(String id, final ModelRunHandler handler) {
+ handlers.add(handler);
+ handlerActivations.add(handlerService.activateHandler(id, handler));
+ ModelViewManager manager = AXFWorkbenchPlugin.getDefault().getManager();
+ manager.getWorkbenchListeners().addListener(handler);
+ manager.getManagerListeners().addModelManagerListener(handler);
+ }
+
+ public synchronized void notifyHandlers() {
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ for (ModelRunHandler handler : handlers) {
+ handler.notifyChange();
+ }
+ }
+ });
+ }
+}
diff --git a/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/IModelWorkbenchListener.java b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/IModelWorkbenchListener.java
new file mode 100644
index 0000000..f517c2f
--- /dev/null
+++ b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/IModelWorkbenchListener.java
@@ -0,0 +1,80 @@
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2009 Metascape, LLC.
+ * 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:
+ * Metascape - Initial API and Implementation
+ *
+ * </copyright>
+ *
+ */
+package org.eclipse.amp.axf.ide;
+
+import org.eclipse.amp.axf.core.IObservationProvider;
+import org.eclipse.ui.IWorkbenchPart;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The listener interface for receiving IModelManager events. The class that is interested in processing a IModelManager
+ * event implements this interface, and the object created with that class is registered with a component using the
+ * component's <code>addIModelManagerListener<code> method. When
+ * the IModelManager event occurs, that object's appropriate
+ * method is invoked.
+ *
+ * @see IModelManagerEvent
+ */
+public interface IModelWorkbenchListener {
+
+ /**
+ * Model added.
+ *
+ * @param model the model
+ */
+ void modelAdded(IObservationProvider model);
+
+ /**
+ * Model removed.
+ *
+ * @param model the model
+ */
+ void modelRemoved(IObservationProvider model);
+
+ /**
+ * Notifies the listener that the given model has been activated, that is in foreground and controllable. The model
+ * is not necessarily focused, nor even visible. Models can be executing but not activated. Note that this assumes
+ * that any already activated model is now deactivated, and it the listener's responsibility to keep a reference to
+ * that prior model as appropriate.
+ *
+ * Only one model may be active at any one time.
+ *
+ * @param model The model that is currently activated, or null if no models are now active. This usually indicates
+ * that no models exist.
+ */
+ void modelActivated(IObservationProvider model);
+
+ /**
+ * View added.
+ *
+ * @param part the part
+ */
+ void viewAdded(IWorkbenchPart part);
+
+ /**
+ * View removed.
+ *
+ * @param part the part
+ */
+ void viewRemoved(IWorkbenchPart part);
+
+ /**
+ * View activated.
+ *
+ * @param part the part
+ */
+ void viewActivated(IWorkbenchPart part);
+}
diff --git a/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/LifeCycleListeners.java b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/LifeCycleListeners.java
new file mode 100644
index 0000000..0e7ed06
--- /dev/null
+++ b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/LifeCycleListeners.java
@@ -0,0 +1,65 @@
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2009 Metascape, LLC.
+ * 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:
+ * Metascape - Initial API and Implementation
+ *
+ * </copyright>
+ *
+ */
+
+package org.eclipse.amp.axf.ide;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.amp.axf.core.ILifeCycleListener;
+import org.eclipse.amp.axf.core.IModel;
+
+/**
+ *
+ * @author mparker
+ *
+ */
+public class LifeCycleListeners {
+
+ List<ILifeCycleListener> workbenchListeners = new ArrayList<ILifeCycleListener>();
+
+ public synchronized void replaceModel(IModel oldModel, IModel newModel) {
+ if (oldModel != null) {
+ for (final ILifeCycleListener listener : workbenchListeners) {
+ oldModel.removeModelListener(listener);
+ }
+ }
+ if (newModel != null) {
+ for (final ILifeCycleListener listener : workbenchListeners) {
+ newModel.addModelListener(listener);
+ // listener.modelAdded(newModel);
+ }
+ }
+ }
+
+ /**
+ * Adds the workbench listener.
+ *
+ * @param listener the listener
+ */
+ public synchronized void addListener(ILifeCycleListener listener) {
+ workbenchListeners.add(listener);
+ }
+
+ /**
+ * Removes the workbench listener.
+ *
+ * @param listener the listener
+ */
+ public synchronized void removeListener(ILifeCycleListener listener) {
+ workbenchListeners.remove(listener);
+ }
+}
diff --git a/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/ModelManagerLabelProvider.java b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/ModelManagerLabelProvider.java
new file mode 100644
index 0000000..d1739fe
--- /dev/null
+++ b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/ModelManagerLabelProvider.java
@@ -0,0 +1,125 @@
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2009 Metascape, LLC.
+ * 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:
+ * Metascape - Initial API and Implementation
+ *
+ * </copyright>
+ *
+ */
+package org.eclipse.amp.axf.ide;
+
+import org.eclipse.amp.axf.core.ILifeCycleListener;
+import org.eclipse.amp.axf.core.IModel;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class ModelManagerLabelProvider.
+ */
+public class ModelManagerLabelProvider implements ILabelProvider {
+
+ public static Image RUN_IMAGE = AbstractUIPlugin.imageDescriptorFromPlugin("org.eclipse.amp.axf.ide",
+ "icons/etool16/model_running.gif").createImage();
+
+ public static Image PAUSE_IMAGE = AbstractUIPlugin.imageDescriptorFromPlugin("org.eclipse.amp.axf.ide",
+ "icons/etool16/model_paused.gif")
+ .createImage();
+
+ public static Image STOP_IMAGE = AbstractUIPlugin.imageDescriptorFromPlugin("org.eclipse.amp.axf.ide",
+ "icons/etool16/model_stopped.gif")
+ .createImage();
+
+ public static Image LISTENER_IMAGE = AbstractUIPlugin.imageDescriptorFromPlugin("org.eclipse.amp.axf.ide",
+ "icons/etool16/listener.gif")
+ .createImage();
+
+ /**
+ * @param element
+ * @return
+ * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
+ */
+ public Image getImage(Object element) {
+ if (element instanceof IModel) {
+ if (((IModel) element).getEngine().isPaused()) {
+ return PAUSE_IMAGE;
+ }
+ if (((IModel) element).getEngine().isRunning()) {
+ return RUN_IMAGE;
+ }
+ return STOP_IMAGE;
+ }
+ if (element instanceof ILifeCycleListener) {
+ if (element instanceof IAdaptable) {
+ IViewPart view = (IViewPart) ((IAdaptable) element).getAdapter(IViewPart.class);
+ if (view != null) {
+ return view.getTitleImage();
+ }
+ }
+ return LISTENER_IMAGE;
+ }
+ return null;
+ }
+
+ /**
+ * @param element
+ * @return
+ * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
+ */
+ public String getText(Object element) {
+ if (element instanceof IModel) {
+ ((IModel) element).getName();
+ }
+ return element.toString();
+ }
+
+ /**
+ * @param listener
+ * @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener)
+ */
+ public void addListener(ILabelProviderListener listener) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ *
+ * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose()
+ */
+ public void dispose() {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ * @param element
+ * @param property
+ * @return
+ * @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String)
+ */
+ public boolean isLabelProperty(Object element, String property) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /**
+ * @param listener
+ * @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener)
+ */
+ public void removeListener(ILabelProviderListener listener) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
diff --git a/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/ModelManagerListeners.java b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/ModelManagerListeners.java
new file mode 100644
index 0000000..f9f884b
--- /dev/null
+++ b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/ModelManagerListeners.java
@@ -0,0 +1,106 @@
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2009 Metascape, LLC.
+ * 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:
+ * Metascape - Initial API and Implementation
+ *
+ * </copyright>
+ *
+ */
+
+package org.eclipse.amp.axf.ide;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.amp.axf.core.IModel;
+import org.eclipse.ui.IViewPart;
+
+public class ModelManagerListeners {
+
+ List<IModelWorkbenchListener> manangerListeners = new ArrayList<IModelWorkbenchListener>();
+ /**
+ * @param modelViewManager
+ */
+ ModelManagerListeners() {
+ }
+
+ /**
+ * Adds the model manager listener.
+ *
+ * @param listener the listener
+ */
+ public synchronized void addModelManagerListener(IModelWorkbenchListener listener) {
+ manangerListeners.add(listener);
+ }
+
+ /**
+ * Removes the model manager listener.
+ *
+ * @param listener the listener
+ */
+ public synchronized void removeModelManagerListener(IModelWorkbenchListener listener) {
+ manangerListeners.remove(listener);
+ }
+
+ /**
+ * Notify view added.
+ *
+ * @param showViewPart the show view part
+ */
+ protected synchronized void notifyViewAdded(final IViewPart showViewPart) {
+ for (IModelWorkbenchListener viewListener : manangerListeners) {
+ viewListener.viewAdded(showViewPart);
+ }
+ };
+
+ /**
+ * Notify view removed.
+ *
+ * @param showViewPart the show view part
+ */
+ protected synchronized void notifyViewRemoved(final IViewPart showViewPart) {
+ for (IModelWorkbenchListener viewListener : manangerListeners) {
+ viewListener.viewRemoved(showViewPart);
+ }
+ };
+
+ /**
+ * Notify view removed.
+ *
+ * @param showViewPart the show view part
+ */
+ protected synchronized void notifyModelActivated(final IModel model) {
+ for (IModelWorkbenchListener viewListener : manangerListeners) {
+ viewListener.modelActivated(model);
+ }
+ };
+
+ /**
+ * Notify view removed.
+ *
+ * @param showViewPart the show view part
+ */
+ protected synchronized void notifyModelAdded(final IModel model) {
+ for (IModelWorkbenchListener viewListener : manangerListeners) {
+ viewListener.modelAdded(model);
+ }
+ };
+
+ /**
+ * Notify view removed.
+ *
+ * @param showViewPart the show view part
+ */
+ protected synchronized void notifyModelRemoved(final IModel model) {
+ for (IModelWorkbenchListener viewListener : manangerListeners) {
+ viewListener.modelRemoved(model);
+ }
+ };
+}
\ No newline at end of file
diff --git a/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/ModelManagerViewPart.java b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/ModelManagerViewPart.java
new file mode 100644
index 0000000..0a558b1
--- /dev/null
+++ b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/ModelManagerViewPart.java
@@ -0,0 +1,175 @@
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2009 Metascape, LLC.
+ * 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:
+ * Metascape - Initial API and Implementation
+ *
+ * </copyright>
+ *
+ */
+package org.eclipse.amp.axf.ide;
+
+import org.eclipse.amp.axf.core.AbstractLifecycleListener;
+import org.eclipse.amp.axf.core.ILifeCycleListener;
+import org.eclipse.amp.axf.core.IModel;
+import org.eclipse.amp.axf.core.IObservationProvider;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.part.ViewPart;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class ModelManagerViewPart.
+ */
+public class ModelManagerViewPart extends ViewPart {
+
+ private final class ModelContents implements ITreeContentProvider {
+ public Object[] getChildren(Object parentElement) {
+ if (parentElement instanceof IModel) {
+ return ((IObservationProvider) parentElement).getModelListeners().toArray();
+ }
+ return new Object[0];
+ }
+
+ public Object getParent(Object element) {
+ // if (element instanceof IModelObserver) {
+ // ((IModelObserver) element).getModel();
+ // }
+ return null;
+ }
+
+ public boolean hasChildren(Object element) {
+ return element instanceof IModel && getChildren(element).length > 0;
+ }
+
+ public Object[] getElements(Object inputElement) {
+ return ((ModelViewManager) inputElement).getModels().toArray();
+ }
+
+ public void dispose() {
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+ }
+
+ ILifeCycleListener genericModelListener = new AbstractLifecycleListener() {
+ @Override
+ public void observeStart(IObservationProvider model) {
+ refreshViewer();
+ }
+
+ @Override
+ public void observeStop(IObservationProvider model) {
+ refreshViewer();
+ }
+
+ boolean wasPaused;
+
+ @Override
+ public void stateChange(Object key, Object updated) {
+ super.stateChange(key, updated);
+ boolean pauseState = ((IModel) updated).getEngine().isPaused();
+ if (wasPaused != pauseState) {
+ refreshViewer();
+ wasPaused = pauseState;
+ }
+ }
+
+ public void observeUpdate(IObservationProvider model) {
+ if (((IModel) model).getPeriod() % 10 == 0) {
+ refreshViewer();
+ }
+ };
+ };
+
+ private class ManagerListener implements IModelWorkbenchListener {
+
+ public void modelActivated(IObservationProvider model) {
+ refreshViewer();
+ }
+
+ public void modelAdded(IObservationProvider model) {
+ refreshViewer();
+ model.addModelListener(genericModelListener);
+ }
+
+ public void modelRemoved(IObservationProvider model) {
+ refreshViewer();
+ model.removeModelListener(genericModelListener);
+ }
+
+ public void viewActivated(IWorkbenchPart part) {
+ }
+
+ public void viewAdded(IWorkbenchPart part) {
+ }
+
+ public void viewRemoved(IWorkbenchPart part) {
+ }
+ }
+
+ private TreeViewer viewer;
+
+ private void refreshViewer() {
+ viewer.getControl().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ viewer.refresh(true);
+ }
+ });
+ }
+
+ /**
+ * @param parent
+ * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ public void createPartControl(Composite parent) {
+ viewer = new TreeViewer(parent);
+ viewer.setContentProvider(new ModelContents());
+ assignManager();
+ }
+
+ private void assignManager() {
+ final ModelViewManager manager = AXFWorkbenchPlugin.getDefault().getManager();
+ ILabelProvider labelProvider = (ILabelProvider) Platform.getAdapterManager().getAdapter(manager,
+ ILabelProvider.class);
+ if (labelProvider == null) {
+ throw new RuntimeException("Label Provider not found for Model Manager.");
+ }
+ viewer.setLabelProvider(labelProvider);
+ viewer.setInput(manager);
+ manager.getManagerListeners().addModelManagerListener(new ManagerListener());
+ viewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ IStructuredSelection sel = (IStructuredSelection) event.getSelection();
+ if (sel.getFirstElement() instanceof IModel) {
+ manager.setActiveModel((IModel) sel.getFirstElement());
+ }
+ }
+ });
+ }
+
+ /**
+ *
+ * @see org.eclipse.ui.part.WorkbenchPart#setFocus()
+ */
+ @Override
+ public void setFocus() {
+ }
+
+}
diff --git a/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/ModelViewManager.java b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/ModelViewManager.java
new file mode 100644
index 0000000..728e6a3
--- /dev/null
+++ b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/ModelViewManager.java
@@ -0,0 +1,623 @@
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2009 Metascape, LLC.
+ * 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:
+ * Metascape - Initial API and Implementation
+ *
+ * </copyright>
+ *
+ */
+package org.eclipse.amp.axf.ide;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.eclipse.amp.axf.core.IEngine;
+import org.eclipse.amp.axf.core.IModel;
+import org.eclipse.amp.axf.core.IObservationProvider;
+import org.eclipse.amp.axf.ide.handlers.CloseHandler;
+import org.eclipse.amp.axf.ide.handlers.PauseHandler;
+import org.eclipse.amp.axf.ide.handlers.RestartHandler;
+import org.eclipse.amp.axf.ide.handlers.ResumeHandler;
+import org.eclipse.amp.axf.ide.handlers.StartHandler;
+import org.eclipse.amp.axf.ide.handlers.StepHandler;
+import org.eclipse.amp.axf.ide.handlers.StopHandler;
+import org.eclipse.amp.axf.ide.view.StatusLineView;
+import org.eclipse.amp.axf.view.IModelPart;
+import org.eclipse.amp.axf.view.ModelInput;
+import org.eclipse.amp.axf.view.ModelViewPart;
+import org.eclipse.amp.axf.view.SelectionSynchronizer;
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IPartListener;
+import org.eclipse.ui.IPerspectiveDescriptor;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchListener;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.contexts.IContextActivation;
+import org.eclipse.ui.contexts.IContextService;
+import org.eclipse.ui.internal.ErrorViewPart;
+import org.eclipse.ui.statushandlers.StatusManager;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class ModelViewManager.
+ */
+@SuppressWarnings("restriction")
+public class ModelViewManager implements IAdapterFactory {
+
+ public static final String EXECUTION_PERSPECTIVE_ID = "org.eclipse.amp.axf.ExecutionPerspective";
+
+ private IContextService contextService;
+
+ private IContextActivation ideContext;
+
+ private IContextActivation partContext;
+
+ List<IModel> models = new ArrayList<IModel>();
+
+ List<IViewPart> views = new ArrayList<IViewPart>();
+
+ Map<IEngine, IModel> runnerForModel = new HashMap<IEngine, IModel>();
+
+ Map<IModel, IEngine> modelForRunner = new HashMap<IModel, IEngine>();
+
+ Map<Object, IModel> modelForArbitrary = new HashMap<Object, IModel>();
+
+ Map<IModel, List<IViewPart>> viewsForModel = new HashMap<IModel, List<IViewPart>>();
+
+ LifeCycleListeners workbenchListeners = new LifeCycleListeners();
+
+ ModelManagerListeners managerListeners = new ModelManagerListeners();
+
+ HandlerManager handlers = new HandlerManager();
+
+ IModel activeModel;
+
+ IPartListener modelActivationListener;
+
+ private int updateCount;
+
+ private IObservationProvider[] modelSlots = new IObservationProvider[16];
+
+ private SelectionSynchronizer editSelection;
+
+ private String priorPerspectiveID;
+
+ /**
+ * Instantiates a new model view manager.
+ */
+ public ModelViewManager() {
+ }
+
+ /**
+ * Gets the active model.
+ *
+ * @return the active model
+ */
+ public IObservationProvider getActiveModel() {
+ return activeModel;
+ }
+
+ /**
+ * Sets the active model.
+ *
+ * @param newModel the new active model
+ */
+ public synchronized void setActiveModel(final IModel newModel) {
+ if (newModel != null && !models.contains(newModel)) {
+ // We have an unattached view..do nothing
+ return;
+ }
+ final IModel oldModel = this.activeModel;
+ this.activeModel = newModel;
+ if (newModel != oldModel) {
+ workbenchListeners.replaceModel(oldModel, newModel);
+ if (newModel != null) {
+ managerListeners.notifyModelActivated(newModel);
+ }
+ }
+
+ }
+
+ /**
+ * Gets the models.
+ *
+ * @return the models
+ */
+ public List<IModel> getModels() {
+ return models;
+ }
+
+ /**
+ * Gets the slot.
+ *
+ * @param model the model
+ *
+ * @return the slot
+ */
+ public int getSlot(IObservationProvider model) {
+ int i = 0;
+ for (IObservationProvider slot : modelSlots) {
+ if (slot == model) {
+ return i;
+ }
+ i++;
+ }
+ return -1;
+ }
+
+ /**
+ * Assign slot.
+ *
+ * @param model the model
+ *
+ * @return the int
+ */
+ public int assignSlot(IObservationProvider model) {
+ int i = 0;
+ for (IObservationProvider slot : modelSlots) {
+ if (slot == null) {
+ modelSlots[i] = model;
+ return i;
+ }
+ i++;
+ }
+ StatusManager.getManager().handle(
+ new Status(Status.WARNING, "org.eclipse.amp.axf.ui",
+ "Currently, the execution engine only supports " + modelSlots.length
+ + " slots. The UI may not perform properly."));
+ return -1;
+ }
+
+ /**
+ * Release slot.
+ *
+ * @param model the model
+ *
+ * @return the int
+ */
+ public int releaseSlot(IObservationProvider model) {
+ int i = 0;
+ for (IObservationProvider slot : modelSlots) {
+ if (slot == model) {
+ modelSlots[i] = null;
+ return i;
+ }
+ i++;
+ }
+ throw new RuntimeException(model + " has not been assigned to a slot.");
+ }
+
+ /**
+ * Register.
+ *
+ * @param model the model
+ * @param executor the executor
+ * @param modelObject the model object
+ */
+ public synchronized void register(final IModel model, IEngine executor, Object modelObject) {
+ if (model == null) {
+ throw new RuntimeException("Tried to register a null model.");
+ }
+ if (executor == null) {
+ throw new RuntimeException("Tried to register a null executor.");
+ }
+ if (modelActivationListener == null) {
+ activate();
+ }
+ models.add(model);
+ modelForRunner.put(model, executor);
+ runnerForModel.put(executor, model);
+ assignSlot(model);
+ if (modelObject != null) {
+ modelForArbitrary.put(modelObject, model);
+ }
+ managerListeners.notifyModelAdded(model);
+ viewsForModel.put(model, new ArrayList<IViewPart>());
+ setActiveModel(model);
+ }
+
+ /**
+ * Register.
+ *
+ * @param model the model
+ * @param executor the executor
+ */
+ public void register(final IModel model, IEngine executor) {
+ register(model, executor, null);
+ }
+
+ /**
+ * Register.
+ *
+ * @param part the part
+ */
+ public synchronized void register(IViewPart part) {
+ views.add(part);
+ }
+
+ /**
+ * Removes the.
+ *
+ * @param part the part
+ */
+ public synchronized void removed(IViewPart part) {
+ views.remove(part);
+ List<IViewPart> modelViews = getViews(activeModel);
+ if (modelViews != null) {
+ modelViews.remove(part);
+ }
+ managerListeners.notifyViewRemoved(part);
+ }
+
+ public List<IViewPart> getViews(IModel model) {
+ return viewsForModel.get(model);
+ }
+
+ private boolean updated;
+
+ /**
+ * Creates the view part.
+ *
+ * @param id the id
+ * @param editorInput the editor input
+ * @param name the name
+ */
+ public void createViewPart(final String id, final ModelInput editorInput, final String name) {
+ updated = false;
+ PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
+
+ public void run() {
+ try {
+ IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ IWorkbenchPage page = workbenchWindow.getActivePage();
+ int slot = getSlot(editorInput.getModel());
+ String secondaryID = slot + "";
+ int viewCount = 0;
+ for (IViewPart part : viewsForModel.get(editorInput.getModel())) {
+ if (part.getViewSite().getId().equals(id)) {
+ viewCount++;
+ }
+ }
+ secondaryID += "-" + viewCount;
+ final IViewPart showViewPart = page.showView(id, secondaryID, IWorkbenchPage.VIEW_VISIBLE);
+ if (showViewPart instanceof ModelViewPart) {
+ register(showViewPart);
+ ((ModelViewPart) showViewPart).setInput(editorInput);
+ ((ModelViewPart) showViewPart).setPartName(editorInput.getName() + " " + name);
+ ((ModelViewPart) showViewPart).createModelListeners();
+ getViews(editorInput.getModel()).add(showViewPart);
+ new Thread() {
+ public void run() {
+ managerListeners.notifyViewAdded(showViewPart);
+ }
+ }.start();
+ } else if (showViewPart instanceof ErrorViewPart) {
+ } else {
+ throw new RuntimeException("Couldn't create model view part.");
+ }
+ } catch (org.eclipse.ui.PartInitException e) {
+ throw new RuntimeException("Couldn't instantiate model view " + this, e);
+ } finally {
+ updated = true;
+ }
+ }
+ });
+ while (!updated) {
+ try {
+ Thread.sleep(50);
+
+ } catch (InterruptedException e) {
+ }
+ }
+ }
+
+ /**
+ * Close view.
+ *
+ * @param part the part
+ */
+ public void closeView(final IViewPart part) {
+ if (PlatformUI.getWorkbench() != null) {
+ Display display = PlatformUI.getWorkbench().getDisplay();
+ if (!display.isDisposed()) {
+ display.syncExec(new Runnable() {
+ public void run() {
+ IWorkbench workbench = PlatformUI.getWorkbench();
+ IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
+ if (workbenchWindow != null && workbenchWindow.getActivePage() != null) {
+ workbenchWindow.getActivePage().hideView(part);
+ }
+ }
+ });
+ }
+ } else {
+ new Thread() {
+ public void run() {
+ removed(part);
+ };
+ }.start();
+ }
+ }
+
+ /**
+ * Removes the.
+ *
+ * @param model the model
+ */
+ public synchronized void remove(final IModel model) {
+ if (models.remove(model)) {
+ modelForRunner.remove(model);
+ runnerForModel.remove(model.getEngine());
+ managerListeners.notifyModelRemoved(model);
+ for (IViewPart part : viewsForModel.get(model)) {
+ closeView(part);
+ }
+ viewsForModel.remove(model);
+ List<Object> arbitraries = new ArrayList<Object>();
+ for (Entry<Object, IModel> entry : modelForArbitrary.entrySet()) {
+ if (entry.getValue() == model) {
+ arbitraries.add(entry.getKey());
+ }
+ }
+ for (Object object : arbitraries) {
+ modelForArbitrary.remove(object);
+ }
+ releaseSlot(model);
+ if (!model.getEngine().isCloseRequested()) {
+ model.getEngine().close();
+ }
+ if (models.size() > 0) {
+ setActiveModel(models.get(models.size() - 1));
+ } else {
+ setActiveModel(null);
+ deactivate();
+ }
+ } else {
+ StatusManager.getManager().handle(
+ new Status(Status.WARNING, "org.eclipse.amp.axf.ui",
+ "Removing a model that no longer exists:" + model));
+ }
+ }
+
+ private IWorkbenchPage getPage() {
+ // TODO this is a quick hack and assumed we only have one workbench window and one page
+ final IWorkbench wb = AXFWorkbenchPlugin.getDefault().getWorkbench();
+ return wb.getWorkbenchWindows()[0].getPages()[0];
+ }
+
+ private void activate() {
+ final IWorkbench wb = AXFWorkbenchPlugin.getDefault().getWorkbench();
+
+ if (wb != null) {
+ wb.addWorkbenchListener(new IWorkbenchListener() {
+ public void postShutdown(IWorkbench workbench) {
+ }
+
+ public boolean preShutdown(IWorkbench workbench, boolean forced) {
+ if (!forced) {
+ synchronized (ModelViewManager.this) {
+ for (IModel model : new ArrayList<IModel>(getModels())) {
+ remove(model);
+ }
+ }
+ }
+ return true;
+ }
+ });
+
+ modelActivationListener = new IPartListener() {
+ public void partActivated(final IWorkbenchPart part) {
+ assignPart(part);
+ // if (updated != null) {
+ // }
+ }
+
+ private void assignPart(final IWorkbenchPart part) {
+ if (part instanceof IModelPart && ((IModelPart) part).getAdapter(IModel.class) != null) {
+ new Thread() {
+ public void run() {
+ IModel model = (IModel) ((IModelPart) part).getAdapter(IModel.class);
+ setActiveModel(model);
+ }
+ }.start();
+ }
+ }
+
+ public void partBroughtToTop(IWorkbenchPart part) {
+ assignPart(part);
+ }
+
+ public void partClosed(final IWorkbenchPart part) {
+ new Thread() {
+ public void run() {
+ removed((IViewPart) part);
+ }
+ }.start();
+ }
+
+ public void partDeactivated(IWorkbenchPart part) {
+ }
+
+ public void partOpened(IWorkbenchPart part) {
+ assignPart(part);
+ }
+
+ // private SpeedSliderWindowControl getSpeedControl(final IWorkbenchPart part) {
+ // IViewSite site = (IViewSite) part.getSite();
+ // IActionBars actionBars = site.getActionBars();
+ // return (SpeedSliderWindowControl) actionBars.getMenuManager()
+ // .find("org.eclipse.amp.axf.view.ui.slider");
+ // };
+ };
+ getPage().addPartListener(modelActivationListener);
+ activatePerspective(wb, EXECUTION_PERSPECTIVE_ID, false);
+ wb.getDisplay().syncExec(new Runnable() {
+ private StatusLineView statusView;
+
+ public void run() {
+ try {
+ contextService = (IContextService) wb.getService(IContextService.class);
+ ideContext = contextService.activateContext("org.eclipse.amp.axf.executionContext");
+ partContext = contextService.activateContext("org.eclipse.amp.axf.activeEditorContext");
+
+ handlers.activate();
+ handlers.addHandler("org.eclipse.amp.axf.ui.start", new StartHandler());
+ handlers.addHandler("org.eclipse.amp.axf.ui.stop", new StopHandler());
+ handlers.addHandler("org.eclipse.amp.axf.ui.pause", new PauseHandler());
+ handlers.addHandler("org.eclipse.amp.axf.ui.resume", new ResumeHandler());
+ handlers.addHandler("org.eclipse.amp.axf.ui.restart", new RestartHandler());
+ handlers.addHandler("org.eclipse.amp.axf.ui.close", new CloseHandler());
+ handlers.addHandler("org.eclipse.amp.axf.ui.step", new StepHandler());
+ // if (statusView == null) {
+ // statusView = new StatusLineView();
+ // new Thread() {
+ // public void run() {
+ // workbenchListeners.addListener(statusView);
+ // addModelManagerListener(statusView);
+ // };
+ // }.start();
+ // }
+ } catch (Exception e) {
+ throw new RuntimeException("Couldn't activate services.", e);
+ }
+ }
+ });
+ } else {
+ throw new RuntimeException("Attempted to activate a service with no workbench available.");
+ }
+ }
+
+ private void activatePerspective(final IWorkbench wb, final String perspectiveID, final boolean editors) {
+ wb.getDisplay().syncExec(new Runnable() {
+ public void run() {
+ IPerspectiveDescriptor perspective = wb.getPerspectiveRegistry().findPerspectiveWithId(perspectiveID);
+ if (perspective != null) {
+ IWorkbenchPage activePage = wb.getActiveWorkbenchWindow() != null ? wb.getActiveWorkbenchWindow()
+ .getActivePage() : null;
+ if (activePage != null && priorPerspectiveID == null
+ || !activePage.getPerspective().getId().equals(EXECUTION_PERSPECTIVE_ID)) {
+ priorPerspectiveID = activePage.getPerspective().getId();
+ }
+ activePage.setPerspective(perspective);
+ activePage.setEditorAreaVisible(editors);
+ }
+ updateCount++;
+ }
+ });
+ }
+
+ private void deactivate() {
+ final IWorkbench wb = AXFWorkbenchPlugin.getDefault().getWorkbench();
+ if (wb != null) {
+ workbenchListeners = new LifeCycleListeners();
+ wb.getDisplay().syncExec(new Runnable() {
+ public void run() {
+ if (contextService != null) {
+ contextService.deactivateContext(ideContext);
+ contextService.deactivateContext(partContext);
+ }
+ handlers.deactivate();
+ }
+ });
+ getPage().removePartListener(modelActivationListener);
+ // while (views.size() > 0) {
+ // try {
+ // Thread.sleep(50);
+ // } catch (InterruptedException e) {
+ // }
+ // }
+ if (priorPerspectiveID != null) {
+ activatePerspective(wb, priorPerspectiveID, true);
+ }
+ modelActivationListener = null;
+ }
+ }
+
+ private void waitForUpdate(int count) {
+ while (updateCount < count) {
+ try {
+ Thread.sleep(50);
+ } catch (InterruptedException e) {
+ }
+ }
+ updateCount = 0;
+ }
+
+ /**
+ * @param adaptableObject
+ * @param adapterType
+ * @return
+ * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
+ */
+ public Object getAdapter(Object adaptableObject, Class adapterType) {
+ if (adapterType == IEngine.class) {
+ return runnerForModel.get(adaptableObject);
+ } else if (adapterType == IModel.class) {
+ if (adaptableObject instanceof IEngine) {
+ return modelForRunner.get(adaptableObject);
+ } else {
+ return modelForArbitrary.get(adaptableObject);
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @return
+ * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
+ */
+ public Class[] getAdapterList() {
+ return new Class[] { IEngine.class, IModel.class };
+ }
+
+ /**
+ * Gets the selection synchronizer.
+ *
+ * @return the selection synchronizer
+ */
+ public SelectionSynchronizer getSelectionSynchronizer() {
+ return editSelection;
+ }
+
+ /**
+ * Sets the selection synchronizer.
+ *
+ * @param editSelection the new selection synchronizer
+ */
+ public void setSelectionSynchronizer(SelectionSynchronizer editSelection) {
+ if (this.editSelection != null) {
+ editSelection.replace(this.editSelection);
+ }
+ this.editSelection = editSelection;
+ }
+
+
+ public ModelManagerListeners getManagerListeners() {
+ return managerListeners;
+ }
+
+ public LifeCycleListeners getWorkbenchListeners() {
+ return workbenchListeners;
+ }
+
+ public HandlerManager getHandlers() {
+ return handlers;
+ }
+
+}
diff --git a/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/handlers/CloseHandler.java b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/handlers/CloseHandler.java
new file mode 100644
index 0000000..8b3454f
--- /dev/null
+++ b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/handlers/CloseHandler.java
@@ -0,0 +1,40 @@
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2009 Metascape, LLC.
+ * 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:
+ * Metascape - Initial API and Implementation
+ *
+ * </copyright>
+ *
+*/
+package org.eclipse.amp.axf.ide.handlers;
+
+import org.eclipse.amp.axf.core.EngineControl;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class CloseHandler.
+ */
+public class CloseHandler extends ModelRunHandler {
+
+ /**
+ * Instantiates a new close handler.
+ */
+ public CloseHandler() {
+ super(EngineControl.CLOSE);
+ }
+
+ /**
+ * @return
+ * @see org.eclipse.amp.axf.ide.handlers.ModelRunHandler#isEnabled()
+ */
+ public boolean isEnabled() {
+ return super.isEnabled() || getRunner().getModelThread().isAlive();
+ }
+}
diff --git a/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/handlers/ModelRunHandler.java b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/handlers/ModelRunHandler.java
new file mode 100644
index 0000000..2903dbd
--- /dev/null
+++ b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/handlers/ModelRunHandler.java
@@ -0,0 +1,153 @@
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2009 Metascape, LLC.
+ * 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:
+ * Metascape - Initial API and Implementation
+ *
+ * </copyright>
+ *
+ */
+package org.eclipse.amp.axf.ide.handlers;
+
+import org.eclipse.amp.axf.core.EngineControl;
+import org.eclipse.amp.axf.core.IEngine;
+import org.eclipse.amp.axf.core.ILifeCycleListener;
+import org.eclipse.amp.axf.core.IModel;
+import org.eclipse.amp.axf.core.IObservationProvider;
+import org.eclipse.amp.axf.core.IStateListener;
+import org.eclipse.amp.axf.core.LifecycleObservationAdapter;
+import org.eclipse.amp.axf.ide.AXFWorkbenchPlugin;
+import org.eclipse.amp.axf.ide.IModelWorkbenchListener;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.HandlerEvent;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPart;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class ModelRunHandler.
+ */
+public abstract class ModelRunHandler extends AbstractHandler implements ILifeCycleListener, IModelWorkbenchListener {
+
+
+ private IModel model;
+
+ private EngineControl control;
+
+ private IStateListener delegate;
+
+ /**
+ * Instantiates a new model run handler.
+ *
+ * @param control the control
+ */
+ public ModelRunHandler(EngineControl control) {
+ this.control = control;
+ delegate = new LifecycleObservationAdapter(this);
+ }
+
+ /**
+ * @param event
+ * @return
+ * @throws ExecutionException
+ * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ */
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ getRunner().control(control);
+ AXFWorkbenchPlugin.getDefault().getManager().getHandlers().notifyHandlers();
+ return null;
+ }
+
+ /**
+ * Gets the runner.
+ *
+ * @return the runner
+ */
+ public IEngine getRunner() {
+ return model != null ? model.getEngine() : null;
+ }
+
+ /**
+ * @return
+ * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
+ */
+ public boolean isEnabled() {
+ return getRunner() != null && !getRunner().isCloseRequested();
+ }
+
+ /**
+ * Notify change.
+ */
+ public void notifyChange() {
+ // its possible we've already left workbench
+ if (AXFWorkbenchPlugin.getDefault() != null) {
+ IWorkbench workbench = AXFWorkbenchPlugin.getDefault().getWorkbench();
+ if (model != null && workbench.getDisplay() != null && !workbench.getDisplay().isDisposed()) {
+ workbench.getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ fireHandlerChanged(new HandlerEvent(ModelRunHandler.this, true, false));
+ }
+ });
+ }
+ }
+ }
+
+ public void observing(IObservationProvider model) {
+ this.model = (IModel) model;
+ }
+
+ public void observationEnd(IObservationProvider model) {
+ this.model = null;
+ }
+
+ public void stateChange(Object key, Object updated) {
+ delegate.stateChange(key, updated);
+ notifyChange();
+ }
+
+ public void modelActivated(IObservationProvider model) {
+ this.model = (IModel) model;
+ notifyChange();
+ }
+
+ public void modelAdded(IObservationProvider model) {
+ }
+
+ public void modelRemoved(IObservationProvider model) {
+ }
+
+ public void viewActivated(IWorkbenchPart part) {
+ }
+
+ public void viewAdded(IWorkbenchPart part) {
+ }
+
+ public void viewRemoved(IWorkbenchPart part) {
+ }
+
+ public void observationEnding(IObservationProvider observed) {
+ }
+
+ public void observeCreate(IObservationProvider observed) {
+ }
+
+ public void observeInitialize(IObservationProvider observed) {
+ }
+
+ public void observeStart(IObservationProvider observed) {
+ }
+
+ public void observeStop(IObservationProvider observed) {
+ }
+
+ public void observeUpdate(IObservationProvider observed) {
+ }
+}
diff --git a/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/handlers/PauseHandler.java b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/handlers/PauseHandler.java
new file mode 100644
index 0000000..96b24f5
--- /dev/null
+++ b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/handlers/PauseHandler.java
@@ -0,0 +1,41 @@
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2009 Metascape, LLC.
+ * 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:
+ * Metascape - Initial API and Implementation
+ *
+ * </copyright>
+ *
+*/
+package org.eclipse.amp.axf.ide.handlers;
+
+import org.eclipse.amp.axf.core.EngineControl;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class PauseHandler.
+ */
+public class PauseHandler extends ModelRunHandler {
+
+ /**
+ * Instantiates a new pause handler.
+ */
+ public PauseHandler() {
+ super(EngineControl.PAUSE);
+ }
+
+ /**
+ * @return
+ * @see org.eclipse.amp.axf.ide.handlers.ModelRunHandler#isEnabled()
+ */
+ @Override
+ public boolean isEnabled() {
+ return super.isEnabled() && !getRunner().isPaused();
+ }
+}
diff --git a/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/handlers/RestartHandler.java b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/handlers/RestartHandler.java
new file mode 100644
index 0000000..750b98f
--- /dev/null
+++ b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/handlers/RestartHandler.java
@@ -0,0 +1,41 @@
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2009 Metascape, LLC.
+ * 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:
+ * Metascape - Initial API and Implementation
+ *
+ * </copyright>
+ *
+ */
+package org.eclipse.amp.axf.ide.handlers;
+
+import org.eclipse.amp.axf.core.EngineControl;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class RestartHandler.
+ */
+public class RestartHandler extends ModelRunHandler {
+
+ /**
+ * Instantiates a new restart handler.
+ */
+ public RestartHandler() {
+ super(EngineControl.RESTART);
+ }
+
+ /**
+ * @return
+ * @see org.eclipse.amp.axf.ide.handlers.ModelRunHandler#isEnabled()
+ */
+ public boolean isEnabled() {
+ // TODO Auto-generated method stub
+ return super.isEnabled() && getRunner().isRunning();
+ }
+}
diff --git a/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/handlers/ResumeHandler.java b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/handlers/ResumeHandler.java
new file mode 100644
index 0000000..7f3e3d6
--- /dev/null
+++ b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/handlers/ResumeHandler.java
@@ -0,0 +1,42 @@
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2009 Metascape, LLC.
+ * 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:
+ * Metascape - Initial API and Implementation
+ *
+ * </copyright>
+ *
+*/
+package org.eclipse.amp.axf.ide.handlers;
+
+import org.eclipse.amp.axf.core.EngineControl;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class ResumeHandler.
+ */
+public class ResumeHandler extends ModelRunHandler {
+
+ /**
+ * Instantiates a new resume handler.
+ */
+ public ResumeHandler() {
+ super(EngineControl.RESUME);
+ }
+
+ /**
+ * @return
+ * @see org.eclipse.amp.axf.ide.handlers.ModelRunHandler#isEnabled()
+ */
+ @Override
+ public boolean isEnabled() {
+ // TODO Auto-generated method stub
+ return super.isEnabled() && getRunner().isPaused();
+ }
+}
diff --git a/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/handlers/StartHandler.java b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/handlers/StartHandler.java
new file mode 100644
index 0000000..a473cfa
--- /dev/null
+++ b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/handlers/StartHandler.java
@@ -0,0 +1,40 @@
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2009 Metascape, LLC.
+ * 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:
+ * Metascape - Initial API and Implementation
+ *
+ * </copyright>
+ *
+*/
+package org.eclipse.amp.axf.ide.handlers;
+
+import org.eclipse.amp.axf.core.EngineControl;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class StartHandler.
+ */
+public class StartHandler extends ModelRunHandler {
+
+ /**
+ * Instantiates a new start handler.
+ */
+ public StartHandler() {
+ super(EngineControl.START);
+ }
+
+ /**
+ * @return
+ * @see org.eclipse.amp.axf.ide.handlers.ModelRunHandler#isEnabled()
+ */
+ public boolean isEnabled() {
+ return super.isEnabled() && !getRunner().isRunning();
+ }
+}
diff --git a/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/handlers/StepHandler.java b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/handlers/StepHandler.java
new file mode 100644
index 0000000..c9b3698
--- /dev/null
+++ b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/handlers/StepHandler.java
@@ -0,0 +1,40 @@
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2009 Metascape, LLC.
+ * 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:
+ * Metascape - Initial API and Implementation
+ *
+ * </copyright>
+ *
+*/
+package org.eclipse.amp.axf.ide.handlers;
+
+import org.eclipse.amp.axf.core.EngineControl;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class StepHandler.
+ */
+public class StepHandler extends ModelRunHandler {
+
+ /**
+ * Instantiates a new step handler.
+ */
+ public StepHandler() {
+ super(EngineControl.STEP);
+ }
+
+ /**
+ * @return
+ * @see org.eclipse.amp.axf.ide.handlers.ModelRunHandler#isEnabled()
+ */
+ public boolean isEnabled() {
+ return super.isEnabled() && getRunner().isRunning() && getRunner().isPaused();
+ }
+}
diff --git a/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/handlers/StopHandler.java b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/handlers/StopHandler.java
new file mode 100644
index 0000000..925d8ed
--- /dev/null
+++ b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/handlers/StopHandler.java
@@ -0,0 +1,40 @@
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2009 Metascape, LLC.
+ * 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:
+ * Metascape - Initial API and Implementation
+ *
+ * </copyright>
+ *
+*/
+package org.eclipse.amp.axf.ide.handlers;
+
+import org.eclipse.amp.axf.core.EngineControl;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class StopHandler.
+ */
+public class StopHandler extends ModelRunHandler {
+
+ /**
+ * Instantiates a new stop handler.
+ */
+ public StopHandler() {
+ super(EngineControl.STOP);
+ }
+
+ /**
+ * @return
+ * @see org.eclipse.amp.axf.ide.handlers.ModelRunHandler#isEnabled()
+ */
+ public boolean isEnabled() {
+ return super.isEnabled() && getRunner().isRunning();
+ }
+}
diff --git a/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/view/DelayView.java b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/view/DelayView.java
new file mode 100644
index 0000000..96b1a00
--- /dev/null
+++ b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/view/DelayView.java
@@ -0,0 +1,44 @@
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2009 Metascape, LLC.
+ * 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:
+ * Metascape - Initial API and Implementation
+ *
+ * </copyright>
+ *
+ */
+
+package org.eclipse.amp.axf.ide.view;
+
+import org.eclipse.amp.axf.core.AbstractLifecycleListener;
+import org.eclipse.amp.axf.core.IModel;
+import org.eclipse.amp.axf.core.IObservationProvider;
+import org.eclipse.amp.axf.core.TimeGranularity;
+
+/**
+ *
+ * @author mparker
+ *
+ */
+public class DelayView extends AbstractLifecycleListener {
+
+ /**
+ * @param observed
+ * @see org.eclipse.amp.axf.core.AbstractLifecycleListener#observeUpdate(org.eclipse.amp.axf.core.IObservationProvider)
+ */
+ public void observeUpdate(IObservationProvider observed) {
+ long delayPeriod = ((TimeGranularity) ((IModel) observed).getEngine().getUpdateGranularity()).getUpdateDelay();
+ if (delayPeriod > 0) {
+ try {
+ Thread.sleep(delayPeriod);
+ } catch (InterruptedException e) {
+ }
+ }
+ }
+}
diff --git a/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/view/MonitorView.java b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/view/MonitorView.java
new file mode 100644
index 0000000..e6572c3
--- /dev/null
+++ b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/view/MonitorView.java
@@ -0,0 +1,54 @@
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2009 Metascape, LLC.
+ * 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:
+ * Metascape - Initial API and Implementation
+ *
+ * </copyright>
+ *
+*/
+package org.eclipse.amp.axf.ide.view;
+
+import org.eclipse.amp.axf.core.AbstractLifecycleListener;
+import org.eclipse.amp.axf.core.IModel;
+import org.eclipse.amp.axf.core.IObservationProvider;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class MonitorView.
+ */
+public abstract class MonitorView extends AbstractLifecycleListener {
+
+ protected final IProgressMonitor monitor;
+
+ protected String modelDesc;
+
+ /**
+ * Instantiates a new monitor view.
+ *
+ * @param monitor the monitor
+ * @param name the name
+ */
+ public MonitorView(IProgressMonitor monitor, String name) {
+ super(name);
+ this.monitor = monitor;
+ }
+
+ /**
+ * @param model
+ * @see org.eclipse.amp.axf.core.AbstractLifecycleListener#observing(org.eclipse.amp.axf.core.IObservationProvider)
+ */
+ @Override
+ public void observing(IObservationProvider model) {
+ super.observing(model);
+ // TODO change to label provider
+ modelDesc = ((IModel) model).getName() + " [" + model.getClass() + "]";
+ }
+}
diff --git a/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/view/RunMonitorView.java b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/view/RunMonitorView.java
new file mode 100644
index 0000000..624bdb0
--- /dev/null
+++ b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/view/RunMonitorView.java
@@ -0,0 +1,97 @@
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2009 Metascape, LLC.
+ * 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:
+ * Metascape - Initial API and Implementation
+ *
+ * </copyright>
+ *
+*/
+package org.eclipse.amp.axf.ide.view;
+
+import org.eclipse.amp.axf.core.IModel;
+import org.eclipse.amp.axf.core.IObservationProvider;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class RunMonitorView.
+ */
+public class RunMonitorView extends MonitorView {
+
+ /**
+ * Instantiates a new run monitor view.
+ *
+ * @param monitor the monitor
+ */
+ public RunMonitorView(IProgressMonitor monitor) {
+ super(monitor, "Run Monitor View");
+ }
+
+ /**
+ * @param model
+ * @see org.eclipse.amp.axf.ide.view.MonitorView#observing(org.eclipse.amp.axf.core.IObservationProvider)
+ */
+ @Override
+ public void observing(IObservationProvider model) {
+ super.observing(model);
+ String mainDesc = "Run " + modelDesc;
+ monitor.setTaskName(mainDesc);
+ }
+
+ /**
+ * @param key
+ * @param model
+ * @see org.eclipse.amp.axf.core.AbstractLifecycleListener#stateChange(java.lang.Object, java.lang.Object)
+ */
+ @Override
+ public void stateChange(Object key, Object model) {
+ super.stateChange(key, model);
+ if (monitor.isCanceled() && ((IModel) model).getEngine().isRunning()) {
+ ((IModel) model).getEngine().stop();
+ }
+ }
+
+ /**
+ * @param model
+ * @see org.eclipse.amp.axf.core.AbstractLifecycleListener#observeUpdate(org.eclipse.amp.axf.core.IObservationProvider)
+ */
+ @Override
+ public void observeUpdate(IObservationProvider model) {
+ if (((IModel) model).getPeriod() % 10 == 0) {
+ monitor.subTask("Period " + ((IModel) model).getPeriod()
+ + (((IModel) model).getStopPeriod() > 0 ? " of " + ((IModel) model).getStopPeriod() : ""));
+ monitor.worked(10);
+ }
+ }
+
+ /**
+ * @param observed
+ * @see org.eclipse.amp.axf.core.AbstractLifecycleListener#observeStart(org.eclipse.amp.axf.core.IObservationProvider)
+ */
+ @Override
+ public void observeStart(IObservationProvider observed) {
+ IModel model = (IModel) observed;
+ monitor.beginTask("Run " + model.getName(), model.getStopPeriod() > 0 ? model.getStopPeriod()
+ : IProgressMonitor.UNKNOWN);
+ monitor.subTask("Started");
+ monitor.worked(1);
+ }
+
+ /**
+ * @param model
+ * @see org.eclipse.amp.axf.core.AbstractLifecycleListener#observeStop(org.eclipse.amp.axf.core.IObservationProvider)
+ */
+ @Override
+ public void observeStop(IObservationProvider model) {
+ monitor.subTask("Stopped");
+ monitor.done();
+ }
+
+}
diff --git a/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/view/ScaleGranularityControl.java b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/view/ScaleGranularityControl.java
new file mode 100644
index 0000000..3ca50dd
--- /dev/null
+++ b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/view/ScaleGranularityControl.java
@@ -0,0 +1,183 @@
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2009 Metascape, LLC.
+ * 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:
+ * Metascape - Initial API and Implementation
+ *
+ * </copyright>
+ *
+ */
+
+package org.eclipse.amp.axf.ide.view;
+
+import org.eclipse.amp.axf.core.IEngine;
+import org.eclipse.amp.axf.core.IModel;
+import org.eclipse.amp.axf.core.IObservationProvider;
+import org.eclipse.amp.axf.core.TimeGranularity;
+import org.eclipse.amp.axf.ide.AXFWorkbenchPlugin;
+import org.eclipse.amp.axf.ide.IModelWorkbenchListener;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Scale;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.menus.WorkbenchWindowControlContribution;
+
+/**
+ *
+ * @author mparker
+ *
+ */
+public class ScaleGranularityControl extends WorkbenchWindowControlContribution implements IModelWorkbenchListener {
+
+ IEngine engine;
+
+ Scale scale;
+
+ private static int SCALE_MID = 50;
+
+ private static int SCALE_MAX = 110;
+
+ // Around the center area we want to have scale snap to middle.
+ private static int CENTER_RANGE = 5;
+
+ /**
+ * @param parent
+ * @return
+ * @see org.eclipse.jface.action.ControlContribution#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ protected Control createControl(Composite parent) {
+ scale = new Scale(parent, SWT.HORIZONTAL);
+ scale.setMaximum(SCALE_MAX);
+ scale.setSelection(SCALE_MID);
+ scale.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ scaleToEngineGranularity();
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+ });
+ new Thread() {
+ public void run() {
+ AXFWorkbenchPlugin.getDefault().getManager().getManagerListeners()
+ .addModelManagerListener(ScaleGranularityControl.this);
+ };
+ }.start();
+ return scale;
+ }
+
+ private void scaleToEngineGranularity() {
+ if (Math.abs(scale.getSelection() - SCALE_MID) > CENTER_RANGE) {
+ if (scale.getSelection() > SCALE_MID) {
+ engine.setUpdateGranularity(TimeGranularity.createFrequencyGranularity((scale
+ .getSelection()
+ - SCALE_MID - CENTER_RANGE) * 2));
+ } else {
+ if (scale.getSelection() > 0) {
+ engine.setUpdateGranularity(TimeGranularity.createDelayGranularity((SCALE_MID - scale
+ .getSelection()) * 50));
+ }
+ }
+ } else {
+ if (scale.getSelection() != SCALE_MID) {
+ // recursive call w/o blocking
+ setScaleSelection(SCALE_MID);
+ } else {
+ engine.setUpdateGranularity(TimeGranularity.DEFAULT_GRANULARITY);
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ private void engineGranularityToScale() {
+ if (engine.getUpdateGranularity() instanceof TimeGranularity) {
+ TimeGranularity granularity = (TimeGranularity) engine.getUpdateGranularity();
+ if (granularity.getUpdateDelay() > 0) {
+ setScaleSelection((int) (granularity.getUpdateDelay() / 50));
+ } else if (granularity.getUpdateFrequency() > 1) {
+ setScaleSelection((granularity.getUpdateFrequency() / 2 + SCALE_MID));
+ } else {
+ setScaleSelection(SCALE_MID);
+ }
+ }
+ }
+
+ protected void setScaleSelection(final int value) {
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ scale.setSelection(value);
+ }
+ });
+ }
+
+ /**
+ * @param model
+ * @see org.eclipse.amp.axf.ide.IModelWorkbenchListener#modelActivated(org.eclipse.amp.axf.core.IObservationProvider)
+ */
+ public void modelActivated(IObservationProvider model) {
+ if (model != null) {
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ scale.setEnabled(true);
+ }
+ });
+ engine = ((IModel) model).getEngine();
+ engineGranularityToScale();
+ } else {
+ engine = null;
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ scale.setEnabled(false);
+ }
+ });
+ }
+
+ }
+
+ /**
+ * @param model
+ * @see org.eclipse.amp.axf.ide.IModelWorkbenchListener#modelAdded(org.eclipse.amp.axf.core.IObservationProvider)
+ */
+ public void modelAdded(IObservationProvider model) {
+ }
+
+ /**
+ * @param model
+ * @see org.eclipse.amp.axf.ide.IModelWorkbenchListener#modelRemoved(org.eclipse.amp.axf.core.IObservationProvider)
+ */
+ public void modelRemoved(IObservationProvider model) {
+ }
+
+ /**
+ * @param part
+ * @see org.eclipse.amp.axf.ide.IModelWorkbenchListener#viewActivated(org.eclipse.ui.IWorkbenchPart)
+ */
+ public void viewActivated(IWorkbenchPart part) {
+ }
+
+ /**
+ * @param part
+ * @see org.eclipse.amp.axf.ide.IModelWorkbenchListener#viewAdded(org.eclipse.ui.IWorkbenchPart)
+ */
+ public void viewAdded(IWorkbenchPart part) {
+ }
+
+ /**
+ * @param part
+ * @see org.eclipse.amp.axf.ide.IModelWorkbenchListener#viewRemoved(org.eclipse.ui.IWorkbenchPart)
+ */
+ public void viewRemoved(IWorkbenchPart part) {
+ }
+}
diff --git a/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/view/StatusLineView.java b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/view/StatusLineView.java
new file mode 100644
index 0000000..0550450
--- /dev/null
+++ b/org.eclipse.amp.axf/plugins/org.eclipse.amp.axf.ide/src/org/eclipse/amp/axf/ide/view/StatusLineView.java
@@ -0,0 +1,151 @@
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2009 Metascape, LLC.
+ * 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:
+ * Metascape - Initial API and Implementation
+ *
+ * </copyright>
+ *
+ */
+package org.eclipse.amp.axf.ide.view;
+
+import org.eclipse.amp.axf.core.IModel;
+import org.eclipse.amp.axf.core.IObservationProvider;
+import org.eclipse.amp.axf.ide.IModelWorkbenchListener;
+import org.eclipse.amp.axf.view.SWTAsyncModelListener;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.IViewSite;
+import org.eclipse.ui.IWorkbenchPart;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class StatusLineView.
+ */
+public class StatusLineView extends SWTAsyncModelListener implements IModelWorkbenchListener {
+
+ IViewPart part;
+
+ /**
+ * Instantiates a new status line view.
+ */
+ public StatusLineView() {
+ super(null, "Status Line View", 100);
+ }
+
+ /**
+ * @param model
+ * @see org.eclipse.amp.axf.core.AbstractLifecycleListener#observeStart(org.eclipse.amp.axf.core.IObservationProvider)
+ */
+ public void observeStart(IObservationProvider model) {
+ updateMessage("Started");
+ }
+
+ /**
+ * @param model
+ * @see org.eclipse.amp.axf.core.AbstractLifecycleListener#observeStop(org.eclipse.amp.axf.core.IObservationProvider)
+ */
+ public void observeStop(IObservationProvider model) {
+ updateMessage("Stopped");
+ }
+
+ /**
+ * @param model
+ * @see org.eclipse.amp.axf.view.SWTThreadModelListener#update(org.eclipse.amp.axf.core.IModel)
+ */
+ public void update(IModel model) {
+ // IViewPart viewPart = (IViewPart) part.getAdapter(IViewPart.class);
+
+ String msg = model.getName();
+ msg += " " + model.getTimeDescription();
+ if (model.getEngine().isPaused()) {
+ msg += " [PAUSED]";
+ } else {
+ msg += " " + model.getEngine().getUpdateGranularity();
+ }
+ updateMessage(msg);
+ }
+
+ private void updateMessage(String msg) {
+ if (part instanceof IViewPart) {
+ IViewSite site = (IViewSite) part.getSite();
+ IActionBars actionBars = site.getActionBars();
+ actionBars.getStatusLineManager().setMessage(msg);
+ actionBars.updateActionBars();
+ }
+ }
+
+ /**
+ * Sets the part.
+ *
+ * @param part the new part
+ */
+ public void setPart(IViewPart part) {
+ this.part = part;
+ }
+
+ /**
+ * Gets the part.
+ *
+ * @return the part
+ */
+ public IViewPart getPart() {
+ return part;
+ }
+
+ /**
+ * @param model
+ * @see org.eclipse.amp.axf.ide.IModelWorkbenchListener#modelActivated(org.eclipse.amp.axf.core.IObservationProvider)
+ */
+ public void modelActivated(IObservationProvider model) {
+ }
+
+ /**
+ * @param model
+ * @see org.eclipse.amp.axf.ide.IModelWorkbenchListener#modelAdded(org.eclipse.amp.axf.core.IObservationProvider)
+ */
+ public void modelAdded(IObservationProvider model) {
+ }
+
+ /**
+ * @param model
+ * @see org.eclipse.amp.axf.ide.IModelWorkbenchListener#modelRemoved(org.eclipse.amp.axf.core.IObservationProvider)
+ */
+ public void modelRemoved(IObservationProvider model) {
+ }
+
+ /**
+ * @param part
+ * @see org.eclipse.amp.axf.ide.IModelWorkbenchListener#viewActivated(org.eclipse.ui.IWorkbenchPart)
+ */
+ public void viewActivated(IWorkbenchPart part) {
+ if (part instanceof IViewPart) {
+ this.part = (IViewPart) part;
+ } else {
+ this.part = null;
+ }
+ }
+
+ /**
+ * @param part
+ * @see org.eclipse.amp.axf.ide.IModelWorkbenchListener#viewAdded(org.eclipse.ui.IWorkbenchPart)
+ */
+ public void viewAdded(IWorkbenchPart part) {
+ }
+
+ /**
+ * @param part
+ * @see org.eclipse.amp.axf.ide.IModelWorkbenchListener#viewRemoved(org.eclipse.ui.IWorkbenchPart)
+ */
+ public void viewRemoved(IWorkbenchPart part) {
+ if (part == this.part) {
+ this.part = null;
+ }
+ }
+}