[savara-commits] savara SVN: r575 - in branches/experimental/2.0.x: bundles/org.savara.scenario/src/main/java/org/savara/scenario and 37 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Thu Jan 13 17:03:07 EST 2011
Author: objectiser
Date: 2011-01-13 17:03:06 -0500 (Thu, 13 Jan 2011)
New Revision: 575
Added:
branches/experimental/2.0.x/bundles/org.savara.scenario/src/main/java/org/savara/scenario/simulation/
branches/experimental/2.0.x/bundles/org.savara.scenario/src/main/java/org/savara/scenario/simulation/ScenarioSimulator.java
branches/experimental/2.0.x/bundles/org.savara.scenario/src/main/java/org/savara/scenario/util/ScenarioDefinitions.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.core/src/java/org/savara/tools/
branches/experimental/2.0.x/tools/plugins/org.savara.tools.core/src/java/org/savara/tools/core/
branches/experimental/2.0.x/tools/plugins/org.savara.tools.core/src/java/org/savara/tools/core/ScribbleServices.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.core/src/java/org/savara/tools/core/osgi/
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/.classpath
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/.project
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/.settings/
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/.settings/org.eclipse.jdt.core.prefs
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/Copyright.txt
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/META-INF/
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/META-INF/MANIFEST.MF
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/build.properties
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/plugin.xml
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/pom.xml
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/DesignerDefinitions.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/DesignerImages.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/commands/
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/commands/AddCommand.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/commands/ConnectionCommand.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/commands/CreateComponentCommand.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/commands/DeleteComponentCommand.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/commands/DeleteLinkCommand.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/commands/MoveCommand.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/commands/PasteComponentCommand.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/commands/RoleConnectionCommand.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/dnd/
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/dnd/ScenarioTemplateTransferDropTargetListener.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/AbstractEditorPage.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/CopyAction.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/CreateLinksAction.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/DelegatingCommandStack.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/DelegatingZoomManager.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/DesignerActionBarContributor.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/Editor.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/EditorContextMenuProvider.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/GenerateImageAction.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/MultiPageCommandStackListener.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/NewScenarioWizard.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/PasteAction.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/ResetSimulationAction.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/ScenarioDesigner.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/ScenarioEditorPage.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/ScenarioPaletteRoot.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/SimulateScenarioAction.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/SimulationEntityFocusAction.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/SimulationLogPage.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/properties/
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/properties/DesignerTabbedPropertySheetPage.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/figures/
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/figures/EventFigure.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/figures/GroupFigure.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/figures/GroupingFigure.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/figures/ImportFigure.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/figures/MessageEventFigure.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/figures/ReceiveMessageEventFigure.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/figures/RoleFigure.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/figures/ScenarioFigure.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/figures/SendMessageEventFigure.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/figures/StartTagFigure.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/figures/TimeElapsedEventFigure.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/images/
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/images/GenerateImage.gif
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/images/Group.gif
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/images/Import.gif
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/images/Link.gif
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/images/Receive.gif
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/images/ResetSimulation.gif
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/images/ResetSimulation.png
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/images/Role.gif
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/images/Send.gif
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/images/Simulate.gif
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/images/Simulate.png
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/images/SimulateTB.gif
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/images/TimeElapsed.gif
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/model/
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/model/Bean.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/model/ModelCreationFactory.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/model/ModelSupport.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/model/ScenarioDiagram.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/parts/
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/parts/EventEditPart.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/parts/GroupEditPart.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/parts/ImportEditPart.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/parts/LinkEditPart.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/parts/MessageEventEditPart.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/parts/RoleEditPart.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/parts/ScenarioBaseEditPart.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/parts/ScenarioEditPart.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/parts/ScenarioEditPartsFactory.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/parts/StructuredGroupEditPart.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/parts/TimeElapsedEventEditPart.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/policies/
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/policies/ConnectableMessageEventEditPolicy.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/policies/ConnectableRoleEditPolicy.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/policies/LinkComponentEditPolicy.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/policies/LinkConnectionEditPolicy.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/policies/LinkEndpointEditPolicy.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/policies/LinkSelectionHandlesEditPolicy.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/policies/ScenarioComponentEditPolicy.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/policies/ScenarioContainerEditPolicy.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/policies/ScenarioContainerHighlightEditPolicy.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/policies/ScenarioContainerXYLayoutEditPolicy.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/preferences/
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/preferences/PreferenceInitializer.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/preferences/ScenarioPreferencePage.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/simulate/
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/simulate/ScenarioDesignerSimulationLauncher.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/simulate/ScenarioSimulation.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/simulate/SimulationEntity.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/tools/
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/tools/CreateLinksTool.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/util/
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/util/PropertySource.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/view/
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/view/FileURLCellEditor.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/view/GraphicalComponent.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/view/LinkPropertySource.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/view/RolePropertySource.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/view/ScenarioPropertySource.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/view/URLPropertyDescriptor.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/view/ViewSupport.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/osgi/
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/osgi/Activator.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/simulation/
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/simulation/ScenarioDetails.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/simulation/ScenarioSimulationAction.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/simulation/ScenarioSimulationImages.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/simulation/ScenarioSimulationLaunchConfigurationConstants.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/simulation/ScenarioSimulationLauncher.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/simulation/ScenarioSimulationMainTab.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/simulation/ScenarioSimulationTabGroup.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/simulation/ScenarioSimulationUILauncher.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/simulation/ScenarioSimulationWindow.java
Removed:
branches/experimental/2.0.x/tools/plugins/org.savara.tools.core/src/java/org/savara/core/eclipse/ScribbleServices.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.core/src/java/org/savara/core/eclipse/osgi/
Modified:
branches/experimental/2.0.x/bundles/org.savara.scenario/META-INF/MANIFEST.MF
branches/experimental/2.0.x/tools/plugins/org.savara.tools.bpel/src/java/org/savara/tools/bpel/dialogs/GenerateDialog.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.bpel/src/java/org/savara/tools/bpel/generator/Generator.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.core/META-INF/MANIFEST.MF
branches/experimental/2.0.x/tools/plugins/org.savara.tools.core/src/java/org/savara/tools/core/osgi/Activator.java
branches/experimental/2.0.x/tools/plugins/pom.xml
Log:
Added initial version of a scenario editor based on the pi4soa implementation, but uses the new Savara scenario model.
Modified: branches/experimental/2.0.x/bundles/org.savara.scenario/META-INF/MANIFEST.MF
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.scenario/META-INF/MANIFEST.MF 2011-01-13 11:59:28 UTC (rev 574)
+++ branches/experimental/2.0.x/bundles/org.savara.scenario/META-INF/MANIFEST.MF 2011-01-13 22:03:06 UTC (rev 575)
@@ -10,4 +10,6 @@
org.osgi.framework
Require-Bundle: org.scribble.common,
org.savara.common
-Export-Package: org.savara.scenario.model
+Export-Package: org.savara.scenario.model,
+ org.savara.scenario.simulation,
+ org.savara.scenario.util
Added: branches/experimental/2.0.x/bundles/org.savara.scenario/src/main/java/org/savara/scenario/simulation/ScenarioSimulator.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.scenario/src/main/java/org/savara/scenario/simulation/ScenarioSimulator.java (rev 0)
+++ branches/experimental/2.0.x/bundles/org.savara.scenario/src/main/java/org/savara/scenario/simulation/ScenarioSimulator.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,22 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.savara.scenario.simulation;
+
+public interface ScenarioSimulator {
+
+}
Added: branches/experimental/2.0.x/bundles/org.savara.scenario/src/main/java/org/savara/scenario/util/ScenarioDefinitions.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.scenario/src/main/java/org/savara/scenario/util/ScenarioDefinitions.java (rev 0)
+++ branches/experimental/2.0.x/bundles/org.savara.scenario/src/main/java/org/savara/scenario/util/ScenarioDefinitions.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.savara.scenario.util;
+
+public class ScenarioDefinitions {
+
+ public static final String SCENARIO_FILE_EXTENSION="scr";
+
+}
Modified: branches/experimental/2.0.x/tools/plugins/org.savara.tools.bpel/src/java/org/savara/tools/bpel/dialogs/GenerateDialog.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.bpel/src/java/org/savara/tools/bpel/dialogs/GenerateDialog.java 2011-01-13 11:59:28 UTC (rev 574)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.bpel/src/java/org/savara/tools/bpel/dialogs/GenerateDialog.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -24,8 +24,8 @@
import org.eclipse.swt.events.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;
-import org.savara.core.eclipse.ScribbleServices;
import org.savara.tools.bpel.generator.*;
+import org.savara.tools.core.ScribbleServices;
import org.scribble.common.logging.CachedJournal;
import org.scribble.common.logging.Journal;
import org.scribble.protocol.model.*;
Modified: branches/experimental/2.0.x/tools/plugins/org.savara.tools.bpel/src/java/org/savara/tools/bpel/generator/Generator.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.bpel/src/java/org/savara/tools/bpel/generator/Generator.java 2011-01-13 11:59:28 UTC (rev 574)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.bpel/src/java/org/savara/tools/bpel/generator/Generator.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -40,7 +40,7 @@
import org.savara.contract.model.Contract;
import org.savara.contract.model.Interface;
import org.savara.contract.model.Namespace;
-import org.savara.core.eclipse.ScribbleServices;
+import org.savara.tools.core.ScribbleServices;
import org.savara.wsdl.generator.WSDLGeneratorFactory;
import org.savara.wsdl.generator.soap.SOAPDocLitWSDLBinding;
import org.scribble.common.logging.CachedJournal;
Modified: branches/experimental/2.0.x/tools/plugins/org.savara.tools.core/META-INF/MANIFEST.MF
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.core/META-INF/MANIFEST.MF 2011-01-13 11:59:28 UTC (rev 574)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.core/META-INF/MANIFEST.MF 2011-01-13 22:03:06 UTC (rev 575)
@@ -3,7 +3,7 @@
Bundle-Name: SAVARA Tools Core
Bundle-SymbolicName: org.savara.tools.core;singleton:=true
Bundle-Version: 2.0.0.qualifier
-Bundle-Activator: org.savara.core.eclipse.osgi.Activator
+Bundle-Activator: org.savara.tools.core.osgi.Activator
Bundle-Vendor: www.savara.org
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
@@ -14,4 +14,4 @@
org.scribble.protocol.parser
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
-Export-Package: org.savara.core.eclipse
+Export-Package: org.savara.tools.core
Deleted: branches/experimental/2.0.x/tools/plugins/org.savara.tools.core/src/java/org/savara/core/eclipse/ScribbleServices.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.core/src/java/org/savara/core/eclipse/ScribbleServices.java 2011-01-13 11:59:28 UTC (rev 574)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.core/src/java/org/savara/core/eclipse/ScribbleServices.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -1,76 +0,0 @@
-/*
- * Copyright 2009 www.scribble.org
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.savara.core.eclipse;
-
-import org.scribble.protocol.export.ProtocolExportManager;
-import org.scribble.protocol.monitor.ProtocolMonitor;
-import org.scribble.protocol.parser.ProtocolParserManager;
-import org.scribble.protocol.projection.ProtocolProjector;
-import org.scribble.protocol.validation.ProtocolValidationManager;
-
-/**
- * This class provides a manager for accessing services used
- * by the designer.
- *
- */
-public class ScribbleServices {
-
- private static ProtocolValidationManager m_validationManager=null;
- private static ProtocolParserManager m_parserManager=null;
- private static ProtocolProjector m_protocolProjector=null;
- private static ProtocolMonitor m_protocolMonitor=null;
- private static ProtocolExportManager m_protocolExportManager=null;
-
- public static ProtocolValidationManager getValidationManager() {
- return(m_validationManager);
- }
-
- public static void setValidationManager(ProtocolValidationManager vm) {
- m_validationManager = vm;
- }
-
- public static ProtocolParserManager getParserManager() {
- return(m_parserManager);
- }
-
- public static void setParserManager(ProtocolParserManager pm) {
- m_parserManager = pm;
- }
-
- public static ProtocolMonitor getProtocolMonitor() {
- return(m_protocolMonitor);
- }
-
- public static void setProtocolMonitor(ProtocolMonitor parser) {
- m_protocolMonitor = parser;
- }
-
- public static ProtocolProjector getProtocolProjector() {
- return(m_protocolProjector);
- }
-
- public static void setProtocolProjector(ProtocolProjector projector) {
- m_protocolProjector = projector;
- }
-
- public static ProtocolExportManager getProtocolExportManager() {
- return(m_protocolExportManager);
- }
-
- public static void setProtocolExportManager(ProtocolExportManager pem) {
- m_protocolExportManager = pem;
- }
-}
\ No newline at end of file
Copied: branches/experimental/2.0.x/tools/plugins/org.savara.tools.core/src/java/org/savara/tools/core/ScribbleServices.java (from rev 558, branches/experimental/2.0.x/tools/plugins/org.savara.tools.core/src/java/org/savara/core/eclipse/ScribbleServices.java)
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.core/src/java/org/savara/tools/core/ScribbleServices.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.core/src/java/org/savara/tools/core/ScribbleServices.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2009 www.scribble.org
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.savara.tools.core;
+
+import org.scribble.protocol.export.ProtocolExportManager;
+import org.scribble.protocol.monitor.ProtocolMonitor;
+import org.scribble.protocol.parser.ProtocolParserManager;
+import org.scribble.protocol.projection.ProtocolProjector;
+import org.scribble.protocol.validation.ProtocolValidationManager;
+
+/**
+ * This class provides a manager for accessing services used
+ * by the designer.
+ *
+ */
+public class ScribbleServices {
+
+ private static ProtocolValidationManager m_validationManager=null;
+ private static ProtocolParserManager m_parserManager=null;
+ private static ProtocolProjector m_protocolProjector=null;
+ private static ProtocolMonitor m_protocolMonitor=null;
+ private static ProtocolExportManager m_protocolExportManager=null;
+
+ public static ProtocolValidationManager getValidationManager() {
+ return(m_validationManager);
+ }
+
+ public static void setValidationManager(ProtocolValidationManager vm) {
+ m_validationManager = vm;
+ }
+
+ public static ProtocolParserManager getParserManager() {
+ return(m_parserManager);
+ }
+
+ public static void setParserManager(ProtocolParserManager pm) {
+ m_parserManager = pm;
+ }
+
+ public static ProtocolMonitor getProtocolMonitor() {
+ return(m_protocolMonitor);
+ }
+
+ public static void setProtocolMonitor(ProtocolMonitor parser) {
+ m_protocolMonitor = parser;
+ }
+
+ public static ProtocolProjector getProtocolProjector() {
+ return(m_protocolProjector);
+ }
+
+ public static void setProtocolProjector(ProtocolProjector projector) {
+ m_protocolProjector = projector;
+ }
+
+ public static ProtocolExportManager getProtocolExportManager() {
+ return(m_protocolExportManager);
+ }
+
+ public static void setProtocolExportManager(ProtocolExportManager pem) {
+ m_protocolExportManager = pem;
+ }
+}
\ No newline at end of file
Copied: branches/experimental/2.0.x/tools/plugins/org.savara.tools.core/src/java/org/savara/tools/core/osgi (from rev 558, branches/experimental/2.0.x/tools/plugins/org.savara.tools.core/src/java/org/savara/core/eclipse/osgi)
Modified: branches/experimental/2.0.x/tools/plugins/org.savara.tools.core/src/java/org/savara/tools/core/osgi/Activator.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.core/src/java/org/savara/core/eclipse/osgi/Activator.java 2011-01-07 20:02:45 UTC (rev 558)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.core/src/java/org/savara/tools/core/osgi/Activator.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -15,12 +15,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
-package org.savara.core.eclipse.osgi;
+package org.savara.tools.core.osgi;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
-import org.savara.core.eclipse.ScribbleServices;
+import org.savara.tools.core.ScribbleServices;
import org.scribble.protocol.parser.ProtocolParserManager;
import org.scribble.protocol.projection.ProtocolProjector;
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/.classpath
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/.classpath (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/.classpath 2011-01-13 22:03:06 UTC (rev 575)
@@ -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/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src/java"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/.project
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/.project (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/.project 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.savara.tools.scenario</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>
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/.settings/org.eclipse.jdt.core.prefs (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/.settings/org.eclipse.jdt.core.prefs 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,8 @@
+#Wed Jan 12 21:57:04 GMT 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/Copyright.txt
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/Copyright.txt (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/Copyright.txt 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,17 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/META-INF/MANIFEST.MF
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/META-INF/MANIFEST.MF (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/META-INF/MANIFEST.MF 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,24 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: SAVARA Scenario Tools
+Bundle-SymbolicName: org.savara.tools.scenario;singleton:=true
+Bundle-Version: 2.0.0.qualifier
+Bundle-Activator: org.savara.tools.scenario.osgi.Activator
+Bundle-Vendor: www.savara.org
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.savara.scenario,
+ org.scribble.protocol,
+ org.eclipse.draw2d,
+ org.eclipse.ui.views,
+ org.eclipse.gef,
+ org.eclipse.core.resources,
+ org.eclipse.debug.core,
+ org.eclipse.debug.ui,
+ org.eclipse.jdt.launching,
+ org.eclipse.jdt.core,
+ org.eclipse.ui.ide,
+ org.eclipse.ui.views.properties.tabbed,
+ org.eclipse.jdt.debug.ui
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-ActivationPolicy: lazy
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/build.properties
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/build.properties (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/build.properties 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,5 @@
+source.. = src/java/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/plugin.xml
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/plugin.xml (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/plugin.xml 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point = "org.eclipse.ui.newWizards">
+ <category
+ id = "org.savara.Wizard.category.ID"
+ name="Savara">
+ </category>
+ <wizard
+ id = "org.savara.tools.scenario.designer.editor.ScenarioModelWizardID"
+ name = "Scenario"
+ class = "org.savara.tools.scenario.designer.editor.NewScenarioWizard"
+ category = "org.savara.Wizard.category.ID"
+ icon = "icons/full/obj16/ScenarioFile.gif">
+ <description>Create a new Scenario</description>
+ <selection class = "org.eclipse.core.resources.IResource" />
+ </wizard>
+ </extension>
+ <extension point = "org.eclipse.ui.editors">
+ <editor
+ class="org.savara.tools.scenario.designer.editor.ScenarioDesigner"
+ icon="icons/full/obj16/ScenarioFile.gif"
+ contributorClass="org.savara.tools.scenario.designer.editor.DesignerActionBarContributor"
+ name="Scenario Designer"
+ id="org.savara.tools.scenario.designer.ScenarioDesignerID"
+ extensions="scr">
+ </editor>
+ </extension>
+
+ <extension point="org.eclipse.ui.views.properties.tabbed.propertyContributor">
+ <propertyContributor
+ contributorId="org.savara.tools.scenario.designer.ScenarioDesignerID"
+ typeMapper="org.savara.tools.designer.editor.properties.TypeMapper">
+ <propertyCategory category="Savara"/>
+ </propertyContributor>
+ </extension>
+
+ <extension point="org.eclipse.ui.views.properties.tabbed.propertyTabs">
+ <propertyTabs contributorId="org.savara.tools.scenario.designer.ScenarioDesignerID">
+ <propertyTab
+ category="Savara"
+ id="org.savara.tools.scenario.designer.ScenarioDesignerID.GeneralTab"
+ label="General"/>
+ <propertyTab
+ afterTab="org.pi4soa.scenario.designer.ScenarioDesignerID.GeneralTab"
+ category="Savara"
+ id="org.savara.tools.scenario.designer.ScenarioDesignerID.AdvancedTab"
+ label="Advanced"/>
+ <propertyTab
+ afterTab="org.savara.tools.scenario.designer.ScenarioDesignerID.AdvancedTab"
+ category="Savara"
+ id="org.savara.tools.scenario.designer.ScenarioDesignerID.AllTab"
+ label="All"/>
+ </propertyTabs>
+ </extension>
+
+ <extension point="org.eclipse.ui.views.properties.tabbed.propertySections">
+ <propertySections contributorId="org.savara.tools.scenario.designer.ScenarioDesignerID">
+ <propertySection
+ class="org.savara.tools.designer.editor.properties.AllPropertySheetSection"
+ enablesFor="1"
+ id="org.savara.tools.scenario.scenario.AllSection"
+ tab="org.savara.tools.scenario.designer.ScenarioDesignerID.AllTab">
+ <input type="org.savara.scenario.model.Scenario"/>
+ <input type="org.savara.scenario.model.Event"/>
+ <input type="org.savara.scenario.model.Link"/>
+ <input type="org.savara.scenario.model.Role"/>
+ </propertySection>
+ </propertySections>
+ </extension>
+
+ <extension
+ point="org.eclipse.ui.preferencePages">
+ <page
+ category="org.savara.tools.preferences.SavaraPreferencePage"
+ class="org.savara.tools.scenario.designer.eclipse.preferences.ScenarioPreferencePage"
+ id="org.savara.tools.scenario.designer.eclipse.preferences.ScenarioPreferencePage"
+ name="Scenario">
+ </page>
+ </extension>
+ <extension
+ point="org.eclipse.core.runtime.preferences">
+ <initializer
+ class="org.savara.tools.scenario.designer.preferences.PreferenceInitializer">
+ </initializer>
+ </extension>
+
+</plugin>
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/pom.xml
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/pom.xml (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/pom.xml 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,24 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.savara.tools</groupId>
+ <artifactId>org.savara.tools.scenario</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ <packaging>eclipse-plugin</packaging>
+ <name>Savara::Tools::Plugins::ToolsScenario</name>
+
+ <parent>
+ <groupId>org.savara.tools</groupId>
+ <artifactId>plugins</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ </parent>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.savara.bundles</groupId>
+ <artifactId>org.savara.scenario</artifactId>
+ <version>${scribble.version}</version>
+ </dependency>
+ </dependencies>
+
+</project>
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/DesignerDefinitions.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/DesignerDefinitions.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/DesignerDefinitions.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2005 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Jul 5, 2005 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer;
+
+//import org.pi4soa.common.resource.ResourceLocator;
+
+/**
+ * This interface contains general definitions used within the
+ * designer.
+ */
+public class DesignerDefinitions {
+
+ /**
+ * This method returns a configuration message for the
+ * designer plugin.
+ *
+ * @param key The key
+ * @param params The list of parameters
+ * @return The message
+ */
+ /*
+ public static String getMessage(String key, Object[] params) {
+ return(ResourceLocator.getMessage(DesignerDefinitions.DESIGNER_RESOURCE,
+ key, params));
+ }
+ */
+
+ /**
+ * This method returns the boolean preference value associated
+ * with the supplied name.
+ *
+ * @param pref The preference name
+ * @return Whether the boolean preference is true
+ */
+ public static boolean isPreference(String pref) {
+ return(org.savara.tools.scenario.osgi.Activator.getDefault().getPreferenceStore().
+ getBoolean(pref));
+ }
+
+ public static final String DESIGNER_PLUGIN_ID=
+ org.savara.tools.scenario.osgi.Activator.PLUGIN_ID;
+
+ public static final String DESIGNER_RESOURCE="tsdesigner";
+
+ public static final String BUSINESS_VIEW="businessView";
+
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/DesignerImages.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/DesignerImages.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/DesignerImages.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2005-7 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Feb 22, 2007 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer;
+
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.jface.resource.ImageDescriptor;
+
+/**
+ * This class provides access to images configured within the
+ * environment.
+ */
+public class DesignerImages {
+
+ /**
+ * This method returns the image associated with the
+ * supplied name.
+ *
+ * @param name The name
+ * @return The image
+ */
+ public static Image getImage(String name) {
+ Image ret=null;
+
+ // Make sure the image descriptor is registered
+ getImageDescriptor(name);
+
+ ret = m_registry.get(name);
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the image descriptor associated with the
+ * supplied name.
+ *
+ * @param name The name
+ * @return The descriptor
+ */
+ public static ImageDescriptor getImageDescriptor(String name) {
+ ImageDescriptor ret=null;
+
+ if ((ret = m_registry.getDescriptor(name)) == null) {
+ ret = ImageDescriptor.createFromFile(DesignerImages.class,
+ IMAGES_LOCATION+name);
+
+ m_registry.put(name, ret);
+ }
+
+ return(ret);
+ }
+
+ private static final String IMAGES_LOCATION = "images/";
+
+ private static org.eclipse.jface.resource.ImageRegistry m_registry=
+ new org.eclipse.jface.resource.ImageRegistry();
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/commands/AddCommand.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/commands/AddCommand.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/commands/AddCommand.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,107 @@
+/*
+ * Copyright 2005 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Jul 16, 2005 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.commands;
+
+import org.eclipse.gef.commands.Command;
+import org.savara.scenario.model.*;
+import org.savara.tools.scenario.designer.model.ModelSupport;
+
+/**
+ * This command represents an orphaned child.
+ */
+public class AddCommand extends Command {
+
+ public AddCommand () {
+ super("AddChild");
+ }
+
+ public boolean canExecute() {
+ boolean ret=false;
+
+ if (m_newParent != null && m_oldParent != null &&
+ m_child != null &&
+ m_newParent != m_oldParent) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ public void execute() {
+ java.util.List list=ModelSupport.getChildren(m_oldParent);
+
+ // Check if child is a scenario event
+ if (m_child instanceof Event &&
+ m_role != null) {
+ m_oldRole = (Role)((Event)m_child).getRole();
+
+ ((Event)m_child).setRole(m_role);
+ }
+
+ m_oldIndex = list.indexOf(m_child);
+
+ ModelSupport.removeChild(m_oldParent, m_child);
+ ModelSupport.addChild(m_newParent, m_child, m_index);
+ }
+
+ public void redo() {
+ execute();
+ }
+
+ public void setChild(Object child) {
+ m_child = child;
+ }
+
+ public void setNewParent(Object parent) {
+ m_newParent = parent;
+ }
+
+ public void setOldParent(Object parent) {
+ m_oldParent = parent;
+ }
+
+ public void setRole(Role participant) {
+ m_role = participant;
+ }
+
+ public void setIndex(int index) {
+ m_index = index;
+ }
+
+ public void undo() {
+ ModelSupport.removeChild(m_newParent, m_child);
+
+ // Check if child is a scenario event
+ if (m_child instanceof Event &&
+ m_role != null) {
+ ((Event)m_child).setRole(m_oldRole);
+ }
+
+ ModelSupport.addChild(m_oldParent, m_child, m_oldIndex);
+ }
+
+ private Object m_newParent;
+ private Object m_oldParent;
+ private Object m_child;
+ private int m_oldIndex=0;
+ private int m_index=-1;
+ private Role m_role=null;
+ private Role m_oldRole=null;
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/commands/ConnectionCommand.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/commands/ConnectionCommand.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/commands/ConnectionCommand.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,278 @@
+/*
+ * Copyright 2005-7 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Feb 21, 2007 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.commands;
+
+import org.eclipse.gef.commands.Command;
+import org.savara.scenario.model.*;
+import org.savara.tools.scenario.designer.model.*;
+
+/**
+ * This class provides the connection command for the message link.
+ */
+public class ConnectionCommand extends Command {
+
+ /**
+ * Creates a ConnectionCommand
+ */
+ public ConnectionCommand() {
+ super(ConnectionCommand_Label);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.commands.Command#canExecute()
+ */
+ public boolean canExecute() {
+
+ if (oldSource == null && oldTarget == null) {
+ // It is a connection create command
+
+ // Source and target must be pointing to some
+ // real connection point
+ if (source == null) {
+ return false;
+ }
+ if (target == null) {
+ return false;
+ }
+ // Avoid loop on a node
+ if (source == target) {
+ return false;
+ }
+
+ if ((source instanceof SendEvent) == false) {
+ return false;
+ }
+
+ if ((target instanceof ReceiveEvent) == false) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.commands.Command#execute()
+ */
+ public void execute() {
+ // It is a delete connection command
+ if (source == null && target == null) {
+
+ // Deletion of the connection is actually handled by
+ // the component policy, but left in as a placeholder
+ // in case required
+
+ /* TODO: GPB: need scenario
+ if (m_link != null &&
+ m_link.getScenario() != null) {
+
+ m_link.getScenario().
+ getMessageLinks().remove(m_link);
+ }
+ */
+
+ }
+ // It is a reconnect source command
+ if (oldSource != null && source != null) {
+ // The edge is still linked to the oldSource
+ /* TODO: GPB May need to check for existing value and
+ * do relevant update
+ if (m_relationshipType.getFirstRole() != null) {
+ .....
+ }
+ */
+
+ m_link.setSource(source);
+ }
+ // It is a reconnect target command
+ if (oldTarget != null && target != null) {
+ // The target is still linked to the oldTarget
+ /* same as above
+ if (m_relationshipType.getTarget() != null) {
+ ....
+ }
+ */
+
+ m_link.setTarget(target);
+ }
+
+ // It is a connection create command
+ if (oldSource == null && oldTarget == null) {
+ m_link.setSource(source);
+ m_link.setTarget(target);
+
+ if (m_pasteParent != null) {
+ ModelSupport.addChild(m_pasteParent, source, -1);
+ ModelSupport.addChild(m_pasteParent, target, -1);
+ }
+
+ /* TODO: GPB: need scenario
+ source.getScenario().
+ getLinks().add(m_link);
+ */
+ }
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.commands.Command#getLabel()
+ */
+ public String getLabel() {
+ return ConnectionCommand_Description;
+ }
+
+ /**
+ * Returns the source
+ * @return
+ */
+ public MessageEvent getSource() {
+ return(source);
+ }
+
+ /**
+ * Returns the target.
+ * @return
+ */
+ public MessageEvent getTarget() {
+ return(target);
+ }
+
+ /**
+ * Returns the edge.
+ * @return
+ */
+ public Link getLink() {
+ return m_link;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.commands.Command#redo()
+ */
+ public void redo() {
+ execute();
+ }
+
+ public void setPasteParent(Object parent) {
+ m_pasteParent = parent;
+ }
+
+ /**
+ * Sets the source.
+ * @param newSource
+ */
+ public void setSource(MessageEvent newSource) {
+ source = newSource;
+ }
+
+ /**
+ * Sets the target.
+ * @param newTarget
+ */
+ public void setTarget(MessageEvent newTarget) {
+ target = newTarget;
+ }
+
+ /**
+ * Sets the edge.
+ * @param edge
+ */
+ public void setLink(Link rel) {
+ this.m_link = rel;
+ oldSource = (MessageEvent)m_link.getSource();
+ oldTarget = (MessageEvent)m_link.getTarget();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.commands.Command#undo()
+ */
+ public void undo() {
+ // It is a delete connection command
+ if (source == null && target == null) {
+ // Deletion currently handled by component command
+ // policy
+ m_link = new Link();
+ m_link.setSource(oldSource);
+ m_link.setTarget(oldTarget);
+
+ /* TODO: GPB: need scenario
+ oldSource.getScenario().
+ getLinks().add(m_link);
+ */
+ }
+
+ // It was a reconnect source command
+ if (oldSource != null && source != null) {
+ m_link.setSource(oldSource);
+ }
+
+ // It was a reconnect target command
+ if (oldTarget != null && target != null) {
+ m_link.setTarget(oldTarget);
+ }
+
+ // It was a connection create command
+ if (oldSource == null && oldTarget == null) {
+
+ /* TODO: GPB: need scenario
+ m_link.getScenario().
+ getLinks().remove(m_link);
+ */
+
+ if (m_pasteParent != null) {
+ ModelSupport.removeChild(m_pasteParent, source);
+ ModelSupport.removeChild(m_pasteParent, target);
+ }
+ }
+ }
+
+ /**
+ * Sets the old source (for reconnecting)
+ * @param port
+ */
+ public void setOldSource(MessageEvent source) {
+ oldSource = source;
+ }
+
+ /**
+ * Sets the old target (for reconnecting)
+ * @param port
+ */
+ public void setOldTarget(MessageEvent target) {
+ oldTarget = target;
+ }
+
+ private static final String ConnectionCommand_Label = "connect message events";
+ private static final String ConnectionCommand_Description =
+ "message event connection command";
+
+ // Connection are made from an output to an input port
+ protected MessageEvent source;
+ protected MessageEvent target;
+
+ // Old source and target
+ protected MessageEvent oldSource;
+ protected MessageEvent oldTarget;
+
+ private Object m_pasteParent=null;
+
+ // Selected edge. It can be given to the command or
+ // created by the command itself.
+ protected Link m_link=null;
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/commands/CreateComponentCommand.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/commands/CreateComponentCommand.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/commands/CreateComponentCommand.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2005-7 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Jul 7, 2005 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.commands;
+
+import org.savara.scenario.model.*;
+import org.savara.tools.scenario.designer.model.*;
+
+/**
+ * This class implements the activity creation command.
+ */
+public class CreateComponentCommand
+ extends org.eclipse.gef.commands.Command {
+
+ public CreateComponentCommand() {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.commands.Command#execute()
+ */
+ public void execute() {
+
+ // Check if child is a scenario event
+ if (m_child instanceof Event &&
+ m_role != null) {
+ ((Event)m_child).setRole(m_role);
+ }
+
+ // note that the model adds the ports to the node in this call
+ ModelSupport.addChild(m_parent, m_child, m_index);
+
+ }
+
+ public Object getParent() {
+ return(m_parent);
+ }
+
+ public void setRole(Role participant) {
+ m_role = participant;
+ }
+
+ public void redo() {
+ ModelSupport.addChild(m_parent, m_child, m_index);
+ }
+
+ public void setChild(Object newNode) {
+ m_child = newNode;
+ }
+
+ public void setIndex(int index) {
+ m_index = index;
+ }
+
+ public void setParent(Object newParent) {
+ m_parent = newParent;
+ }
+
+ public void undo() {
+ ModelSupport.removeChild(m_parent, m_child);
+ }
+
+ private Object m_child=null;
+ private Object m_parent=null;
+ private Role m_role=null;
+ private int m_index = -1;
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/commands/DeleteComponentCommand.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/commands/DeleteComponentCommand.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/commands/DeleteComponentCommand.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,237 @@
+/*
+ * Copyright 2005-7 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Feb 20, 2007 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.commands;
+
+import org.savara.scenario.model.*;
+import org.savara.tools.scenario.designer.model.*;
+import org.eclipse.gef.commands.Command;
+
+/**
+ * This class implements the activity deletion command.
+ */
+public class DeleteComponentCommand
+ extends org.eclipse.gef.commands.Command {
+
+ public DeleteComponentCommand() {
+ }
+
+ public boolean canExecute() {
+ boolean ret=false;
+
+ if (m_parent != null && m_child != null) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.commands.Command#execute()
+ */
+ public void execute() {
+
+ if (m_child instanceof MessageEvent) {
+ /* TODO: GPB: need links associated with an event
+
+ java.util.List list=((MessageEvent)m_child).getSourceMessageLinks();
+
+ for (int i=list.size()-1; i >= 0; i--) {
+ Link link=(Link)list.get(i);
+
+ link.setSource(null);
+ link.setTarget(null);
+
+ ((MessageEvent)m_child).getScenario().getLinks().remove(link);
+ }
+
+ list=((MessageEvent)m_child).getTargetMessageLinks();
+
+ for (int i=list.size()-1; i >= 0; i--) {
+ Link link=(Link)list.get(i);
+
+ link.setSource(null);
+ link.setTarget(null);
+
+ ((MessageEvent)m_child).getScenario().getLinks().remove(link);
+ }
+ */
+ } else if (m_child instanceof Role) {
+ // Construct deletion commands for each nessage event
+ // related to the participant
+
+ /* TODO: GPB: need scenario and visitor mechanism
+
+ ((Role)m_child).getScenario().visit(new DefaultScenarioVisitor() {
+
+ public void messageEvent(MessageEvent message) {
+
+ if (message.getRole() == m_child) {
+ DeleteComponentCommand command=
+ new DeleteComponentCommand();
+
+ command.setChild(message);
+ command.setParent(message.eContainer());
+
+ command.setIndex(ModelSupport.getChildIndex(
+ message.eContainer(), message));
+
+ m_propagatedCommands.add(command);
+ }
+ }
+ });
+ */
+ }
+
+ for (int i=0; i < m_propagatedCommands.size(); i++) {
+ Command command=(Command)m_propagatedCommands.get(i);
+
+ command.execute();
+ }
+
+ ModelSupport.removeChild(m_parent, m_child);
+
+ if (m_child instanceof Group) {
+ Scenario scenario=null;
+
+ if (m_parent instanceof Scenario) {
+ scenario = (Scenario)m_parent;
+ } else if (m_parent instanceof Event) {
+ /* TODO: GPB: need scenario
+ scenario = ((Event)m_parent).getScenario();
+ */
+ }
+
+ // Scan list of message links to see if any no longer have
+ // a message event that is attached to the scenario - and
+ // then save these in case of an undo
+ for (int i=scenario.getLinks().size()-1;
+ i >= 0; i--) {
+ Link link=(Link)scenario.getLinks().get(i);
+
+ /* TODO: GPB: need scenario
+ if ((link.getSource() != null &&
+ link.getSource().getScenario() == null) ||
+ (link.getTarget() != null &&
+ link.getTarget().getScenario() == null)) {
+
+ // Remove link
+ scenario.getLinks().remove(link);
+
+ m_removedMessageLinks.add(0, link);
+ }
+ */
+ }
+ }
+ }
+
+ public Object getParent() {
+ return(m_parent);
+ }
+
+ public void redo() {
+ execute();
+ }
+
+ public void setChild(Object newNode) {
+ m_child = newNode;
+
+ // Determine connected children
+ if (newNode instanceof MessageEvent) {
+ /* TODO: GPB: need source/target message links
+ java.util.List list=((MessageEvent)newNode).getSourceMessageLinks();
+
+ for (int i=0; i < list.size(); i++) {
+ Link link=(Link)list.get(i);
+
+ m_targetConnectedEvents.add(link.getTarget());
+ }
+
+ list=((MessageEvent)newNode).getTargetMessageLinks();
+
+ for (int i=0; i < list.size(); i++) {
+ Link link=(Link)list.get(i);
+
+ m_sourceConnectedEvents.add(link.getSource());
+ }
+ */
+ }
+ }
+
+ public void setIndex(int index) {
+ m_index = index;
+ }
+
+ public void setParent(Object newParent) {
+ m_parent = newParent;
+ }
+
+ public void undo() {
+
+ ModelSupport.addChild(m_parent, m_child, m_index);
+
+ for (int i=m_propagatedCommands.size()-1; i >= 0; i--) {
+ Command command=(Command)m_propagatedCommands.get(i);
+
+ command.undo();
+ }
+
+ m_propagatedCommands.clear();
+
+ if (m_child instanceof MessageEvent) {
+ /* TODO: GPB: need scenario
+ for (int i=0; i < m_sourceConnectedEvents.size(); i++) {
+ Link link=new Link();
+
+ link.setSource((MessageEvent)m_sourceConnectedEvents.get(i));
+ link.setTarget((MessageEvent)m_child);
+
+ ((MessageEvent)m_child).getScenario().getLinks().add(link);
+ }
+
+ for (int i=0; i < m_targetConnectedEvents.size(); i++) {
+ Link link=new Link();
+
+ link.setSource((MessageEvent)m_child);
+ link.setTarget((MessageEvent)m_targetConnectedEvents.get(i));
+
+ ((MessageEvent)m_child).getScenario().getLinks().add(link);
+ }
+ */
+ } else if (m_child instanceof Group) {
+
+ for (int i=0; i < m_removedMessageLinks.size(); i++) {
+ /* TODO: GPB: need scenario
+ ((Group)m_child).getScenario().getMessageLinks().add(
+ m_removedMessageLinks.get(i));
+ */
+ }
+
+ m_removedMessageLinks.clear();
+ }
+ }
+
+ private Object m_child=null;
+ private Object m_parent=null;
+ private int m_index = -1;
+ private java.util.Vector<MessageEvent> m_sourceConnectedEvents=new java.util.Vector<MessageEvent>();
+ private java.util.Vector<MessageEvent> m_targetConnectedEvents=new java.util.Vector<MessageEvent>();
+ private java.util.Vector<Link> m_removedMessageLinks=new java.util.Vector<Link>();
+ private java.util.Vector m_propagatedCommands=new java.util.Vector();
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/commands/DeleteLinkCommand.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/commands/DeleteLinkCommand.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/commands/DeleteLinkCommand.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,136 @@
+/*
+ * Copyright 2005-7 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Feb 20, 2007 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.commands;
+
+import org.savara.scenario.model.*;
+import org.savara.tools.scenario.designer.model.ModelSupport;
+
+/**
+ * This class implements the activity deletion command.
+ */
+public class DeleteLinkCommand
+ extends org.eclipse.gef.commands.Command {
+
+ public DeleteLinkCommand() {
+ }
+
+ public boolean canExecute() {
+ boolean ret=false;
+
+ if (m_parent != null && m_child != null) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.commands.Command#execute()
+ */
+ public void execute() {
+ m_index = m_parent.getLinks().indexOf(m_child);
+
+ m_parent.getLinks().remove(m_child);
+
+ /* TODO: GPB: need source and target links
+ if (m_sourceParent != null && m_sourceEvent != null &&
+ m_sourceEvent.getSourceMessageLinks().size() == 1) {
+ m_sourceEventIndex = ModelSupport.getChildIndex(m_sourceParent, m_sourceEvent);
+
+ ModelSupport.removeChild(m_sourceParent, m_sourceEvent);
+ }
+
+ if (m_targetParent != null && m_targetEvent != null &&
+ m_targetEvent.getTargetMessageLinks().size() == 1) {
+ m_targetEventIndex = ModelSupport.getChildIndex(m_targetParent, m_targetEvent);
+
+ ModelSupport.removeChild(m_targetParent, m_targetEvent);
+ }
+ */
+
+ m_child.setSource(null);
+ m_child.setTarget(null);
+ }
+
+ public Object getParent() {
+ return(m_parent);
+ }
+
+ public void redo() {
+ execute();
+ }
+
+ public void setChild(Link newNode) {
+ m_child = newNode;
+
+ m_sourceEvent = (MessageEvent)m_child.getSource();
+ m_targetEvent = (MessageEvent)m_child.getTarget();
+
+ /* TODO: GPB: need parent
+ if (m_sourceEvent != null) {
+ m_sourceParent = m_sourceEvent.eContainer();
+ }
+ if (m_targetEvent != null) {
+ m_targetParent = m_targetEvent.eContainer();
+ }
+ */
+ }
+
+ public void setParent(Scenario newParent) {
+ m_parent = newParent;
+ }
+
+ public void undo() {
+ if (m_index != -1) {
+
+ if (m_targetParent != null && m_targetEvent != null &&
+ m_targetEventIndex != -1) {
+
+ ModelSupport.addChild(m_targetParent, m_targetEvent,
+ m_targetEventIndex);
+ }
+
+ if (m_sourceParent != null && m_sourceEvent != null &&
+ m_sourceEventIndex != -1) {
+
+ ModelSupport.addChild(m_sourceParent, m_sourceEvent,
+ m_sourceEventIndex);
+ }
+
+ m_child.setTarget(m_targetEvent);
+ m_child.setSource(m_sourceEvent);
+
+ m_parent.getLinks().add(m_index, m_child);
+
+ m_targetEventIndex = -1;
+ m_sourceEventIndex = -1;
+ }
+ }
+
+ private Link m_child=null;
+ private Object m_sourceParent=null;
+ private Object m_targetParent=null;
+ private MessageEvent m_sourceEvent=null;
+ private MessageEvent m_targetEvent=null;
+ private int m_sourceEventIndex=-1;
+ private int m_targetEventIndex=-1;
+ private Scenario m_parent=null;
+ private int m_index = -1;
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/commands/MoveCommand.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/commands/MoveCommand.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/commands/MoveCommand.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,149 @@
+/*
+ * Copyright 2005-7 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Feb 16, 2007 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.commands;
+
+import org.eclipse.gef.commands.Command;
+import org.savara.scenario.model.*;
+import org.savara.tools.scenario.designer.model.ModelSupport;
+
+/**
+ * This class provides the move command.
+ */
+public class MoveCommand extends Command {
+
+ /**
+ * Creates a move command
+ */
+ public MoveCommand() {
+ super(MoveCommand_Label);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.commands.Command#canExecute()
+ */
+ public boolean canExecute() {
+
+ if (m_container == null ||
+ m_component == null) {
+ return(false);
+ }
+
+ if (m_container == m_component) {
+ return(false);
+ }
+
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.commands.Command#execute()
+ */
+ public void execute() {
+ java.util.List list=ModelSupport.getChildren(m_container);
+
+ m_oldIndex = list.indexOf(m_component);
+
+ // Check if child is a scenario event
+ if (m_component instanceof Event &&
+ m_participant != null) {
+ m_oldParticipant = (Role)((Event)m_component).getRole();
+
+ ((Event)m_component).setRole(m_participant);
+ }
+
+ // Remove from old container
+ ModelSupport.removeChild(m_container, m_component);
+
+ // Add to new container
+ int index=m_index;
+
+ if (index > m_oldIndex) {
+ index--;
+ }
+ ModelSupport.addChild(m_container, m_component, index);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.commands.Command#getLabel()
+ */
+ public String getLabel() {
+ return MoveCommand_Description;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.commands.Command#redo()
+ */
+ public void redo() {
+ execute();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.commands.Command#undo()
+ */
+ public void undo() {
+
+ // Remove from new container
+ ModelSupport.removeChild(m_container, m_component);
+
+ // Check if child is a scenario event
+ if (m_component instanceof Event &&
+ m_participant != null) {
+ ((Event)m_component).setRole(m_oldParticipant);
+ }
+
+ // Add to old container
+ ModelSupport.addChild(m_container, m_component, m_oldIndex);
+ }
+
+ public void setContainer(Object container) {
+ m_container = container;
+ }
+
+ public void setComponent(Object component) {
+ m_component = component;
+ }
+
+ public void setRole(Role participant) {
+ m_participant = participant;
+ }
+
+ public void setIndex(int index) {
+ m_index = index;
+ }
+
+ public Object getContainer() {
+ return(m_container);
+ }
+
+ public Object getComponent() {
+ return(m_component);
+ }
+
+ private Object m_container=null;
+ private Object m_component=null;
+ private int m_index=-1;
+ private int m_oldIndex=-1;
+ private Role m_participant=null;
+ private Role m_oldParticipant=null;
+
+ private static final String MoveCommand_Label = "move";
+ private static final String MoveCommand_Description =
+ "move command";
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/commands/PasteComponentCommand.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/commands/PasteComponentCommand.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/commands/PasteComponentCommand.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,110 @@
+/*
+ * Copyright 2005-7 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Jul 7, 2005 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.commands;
+
+import org.savara.scenario.model.*;
+import org.savara.tools.scenario.designer.model.*;
+import org.savara.tools.scenario.designer.tools.CreateLinksTool;
+
+/**
+ * This class implements the activity creation command.
+ */
+public class PasteComponentCommand
+ extends org.eclipse.gef.commands.Command {
+
+ public PasteComponentCommand() {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.commands.Command#execute()
+ */
+ public void execute() {
+
+ // Check if child is a scenario event
+ if (m_child instanceof Event &&
+ m_role != null) {
+ ((Event)m_child).setRole(m_role);
+ }
+
+ // note that the model adds the ports to the node in this call
+ ModelSupport.addChild(m_parent, m_child, m_index);
+
+ // Check if source is an event group. If so, then
+ // create message links
+ if (m_child instanceof Group) {
+ /* TODO: GPB: need scenario
+ CreateLinksTool tool=
+ new CreateLinksTool(((Group)m_child).getScenario());
+
+ int numlinks=((Group)m_child).getScenario().getLinks().size();
+
+ tool.run(((Group)m_child).getEvents());
+
+ for (int i=numlinks; i <
+ ((Group)m_child).getScenario().getLinks().size(); i++) {
+ m_additionalLinks.add(((Group)m_child).getScenario().getLinks().get(i));
+ }
+ */
+ }
+ }
+
+ public Object getParent() {
+ return(m_parent);
+ }
+
+ public void setRole(Role role) {
+ m_role = role;
+ }
+
+ public void redo() {
+ ModelSupport.addChild(m_parent, m_child, m_index);
+ }
+
+ public void setChild(Object newNode) {
+ m_child = newNode;
+ }
+
+ public void setIndex(int index) {
+ m_index = index;
+ }
+
+ public void setParent(Object newParent) {
+ m_parent = newParent;
+ }
+
+ public void undo() {
+ for (int i=0; i < m_additionalLinks.size(); i++) {
+ /* TODO: GPB: need scenario
+ ((Group)m_child).getScenario().getMessageLinks().remove(
+ m_additionalLinks.get(i));
+ */
+ }
+
+ m_additionalLinks.clear();
+
+ ModelSupport.removeChild(m_parent, m_child);
+ }
+
+ private Object m_child=null;
+ private Object m_parent=null;
+ private Role m_role=null;
+ private int m_index = -1;
+ private java.util.Vector m_additionalLinks=new java.util.Vector();
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/commands/RoleConnectionCommand.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/commands/RoleConnectionCommand.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/commands/RoleConnectionCommand.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,285 @@
+/*
+ * Copyright 2005-7 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Feb 21, 2007 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.commands;
+
+import org.eclipse.gef.commands.Command;
+import org.savara.scenario.model.*;
+import org.savara.tools.scenario.designer.model.*;
+
+/**
+ * This class provides the connection command for the message link.
+ */
+public class RoleConnectionCommand extends Command {
+
+ /**
+ * Creates a ConnectionCommand
+ */
+ public RoleConnectionCommand() {
+ super(ConnectionCommand_Label);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.commands.Command#canExecute()
+ */
+ public boolean canExecute() {
+
+ // Source and target must be pointing to some
+ // real connection point
+ if (source == null) {
+ return false;
+ }
+ if (target == null) {
+ return false;
+ }
+
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.commands.Command#execute()
+ */
+ public void execute() {
+ // It is a delete connection command
+ /*
+ if (source == null && target == null) {
+
+ // Deletion of the connection is actually handled by
+ // the component policy, but left in as a placeholder
+ // in case required
+ if (m_messageLink != null &&
+ m_messageLink.getScenario() != null) {
+
+ m_messageLink.getScenario().
+ getMessageLinks().remove(m_messageLink);
+ }
+
+ }
+ */
+
+ if (m_sourceEvent == null && source instanceof Role) {
+ m_sourceEvent=new SendEvent();
+ m_sourceEvent.setRole((Role)source);
+
+ m_link.setSource(m_sourceEvent);
+ } else {
+ m_link.setSource(m_sourceEvent);
+ }
+
+ if (m_targetEvent == null) {
+ m_targetEvent=new ReceiveEvent();
+ m_targetEvent.setRole(target);
+
+ if (source instanceof MessageEvent) {
+ m_targetEvent.setErrorExpected(
+ ((MessageEvent)source).isErrorExpected());
+ m_targetEvent.setFaultName(
+ ((MessageEvent)source).getFaultName());
+ m_targetEvent.setType(
+ ((MessageEvent)source).getType());
+ m_targetEvent.setOperationName(
+ ((MessageEvent)source).getOperationName());
+ m_targetEvent.setValue(
+ ((MessageEvent)source).getValue());
+ }
+
+ m_link.setTarget(m_targetEvent);
+ }
+
+ /* TODO: GPB: How to get scenario?
+ if (source instanceof Role) {
+ ((Role)source).getScenario().
+ getMessageLinks().add(m_link);
+ } else if (source instanceof MessageEvent) {
+ ((MessageEvent)source).getScenario().
+ getMessageLinks().add(m_link);
+ }
+ */
+
+ if (source instanceof Role) {
+ ModelSupport.addChild(m_sourceParent, m_sourceEvent, m_sourceIndex);
+ }
+ ModelSupport.addChild(m_targetParent, m_targetEvent, m_targetIndex);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.commands.Command#getLabel()
+ */
+ public String getLabel() {
+ return ConnectionCommand_Description;
+ }
+
+ /**
+ * Returns the source
+ * @return
+ */
+ public Object getSource() {
+ return(source);
+ }
+
+ /**
+ * Returns the target.
+ * @return
+ */
+ public Role getTarget() {
+ return(target);
+ }
+
+ public void setSourceIndex(int index) {
+ m_sourceIndex = index;
+ }
+
+ public void setTargetIndex(int index) {
+ m_targetIndex = index;
+ }
+
+ /**
+ * Returns the edge.
+ * @return
+ */
+ public Link getLink() {
+ return m_link;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.commands.Command#redo()
+ */
+ public void redo() {
+ execute();
+ }
+
+ /**
+ * Sets the source.
+ * @param newSource
+ */
+ public void setSource(Object newSource) {
+ source = newSource;
+
+ if (newSource instanceof MessageEvent) {
+ m_sourceEvent = (MessageEvent)newSource;
+ }
+ }
+
+ public void setSourceParent(Object parent) {
+ m_sourceParent = parent;
+ }
+
+ public Object getSourceParent() {
+ return(m_sourceParent);
+ }
+
+ /**
+ * Sets the target.
+ * @param newTarget
+ */
+ public void setTarget(Role newTarget) {
+ target = newTarget;
+ }
+
+ public void setTargetParent(Object parent) {
+ m_targetParent = parent;
+ }
+
+ public Object getTargetParent() {
+ return(m_targetParent);
+ }
+
+ /**
+ * Sets the edge.
+ * @param edge
+ */
+ public void setLink(Link rel) {
+ this.m_link = rel;
+ /*
+ oldSource = m_messageLink.getSource();
+ oldTarget = m_messageLink.getTarget();
+ */
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.commands.Command#undo()
+ */
+ public void undo() {
+ /*
+ // It is a delete connection command
+ if (source == null && target == null) {
+ // Deletion currently handled by component command
+ // policy
+ m_messageLink = ScenarioFactory.eINSTANCE.createMessageLink();
+ m_messageLink.setSource(oldSource);
+ m_messageLink.setTarget(oldTarget);
+
+ oldSource.getScenario().
+ getMessageLinks().add(m_messageLink);
+ }
+
+ // It was a reconnect source command
+ if (oldSource != null && source != null) {
+ m_messageLink.setSource(oldSource);
+ }
+
+ // It was a reconnect target command
+ if (oldTarget != null && target != null) {
+ m_messageLink.setTarget(oldTarget);
+ }
+
+ // It was a connection create command
+ if (oldSource == null && oldTarget == null) {
+
+ m_messageLink.getScenario().
+ getMessageLinks().remove(m_messageLink);
+ }
+ */
+
+ /* TODO: GPB: How to obtain scenario?
+ if (source instanceof Role) {
+ ((Role)source).getScenario().
+ getMessageLinks().remove(m_link);
+ } else if (source instanceof MessageEvent) {
+ ((MessageEvent)source).getScenario().
+ getMessageLinks().remove(m_link);
+ }
+ */
+
+ if (source instanceof Role) {
+ ModelSupport.removeChild(m_sourceParent, m_sourceEvent);
+ }
+ ModelSupport.removeChild(m_targetParent, m_targetEvent);
+ }
+
+ private static final String ConnectionCommand_Label = "connect participants";
+ private static final String ConnectionCommand_Description =
+ "participant connection command";
+
+ // Connection are made from an output to an input port
+ protected Object source;
+ private Object m_sourceParent=null;
+ protected Role target;
+ private Object m_targetParent=null;
+
+ private int m_sourceIndex=-1;
+ private int m_targetIndex=-1;
+
+ private MessageEvent m_sourceEvent=null;
+ private MessageEvent m_targetEvent=null;
+
+ // Selected edge. It can be given to the command or
+ // created by the command itself.
+ protected Link m_link=null;
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/dnd/ScenarioTemplateTransferDropTargetListener.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/dnd/ScenarioTemplateTransferDropTargetListener.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/dnd/ScenarioTemplateTransferDropTargetListener.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2005-7 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Feb 16, 2007 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.dnd;
+
+import org.eclipse.gef.EditPartViewer;
+import org.eclipse.gef.dnd.TemplateTransferDropTargetListener;
+import org.eclipse.gef.requests.CreationFactory;
+import org.savara.tools.scenario.designer.model.ModelCreationFactory;
+
+/**
+ * This class implements the template transfer drop target listener
+ * for the scenario.
+ */
+public class ScenarioTemplateTransferDropTargetListener
+ extends TemplateTransferDropTargetListener {
+
+ /**
+ * Creates a new ScenarioTemplateTransferDropTargetListener instance.
+ * @param viewer
+ */
+ public ScenarioTemplateTransferDropTargetListener(EditPartViewer viewer) {
+ super(viewer);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.dnd.TemplateTransferDropTargetListener#getFactory(java.lang.Object)
+ */
+ protected CreationFactory getFactory(Object template) {
+ CreationFactory ret=null;
+
+ ret = new ModelCreationFactory(template);
+
+ return(ret);
+ }
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/AbstractEditorPage.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/AbstractEditorPage.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/AbstractEditorPage.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,451 @@
+/*
+ * Copyright 2005 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Jul 5, 2005 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.editor;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.gef.ContextMenuProvider;
+import org.eclipse.gef.EditDomain;
+import org.eclipse.gef.EditPartViewer;
+import org.eclipse.gef.GraphicalViewer;
+import org.eclipse.gef.commands.CommandStack;
+import org.eclipse.gef.dnd.TemplateTransferDragSourceListener;
+import org.eclipse.gef.palette.PaletteRoot;
+import org.eclipse.gef.ui.palette.PaletteViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.part.EditorPart;
+import org.savara.tools.scenario.designer.DesignerDefinitions;
+
+/**
+ * This class provides the common features associated with all
+ * pages in the Choreography Description Editor.
+ */
+public abstract class AbstractEditorPage extends EditorPart {
+
+ /**
+ * Creates a new AbstractEditorPage instance.
+ *
+ * @param parent the parent multi page editor
+ * @param domain the edit domain
+ */
+ public AbstractEditorPage(Editor parent,
+ EditDomain domain) {
+ m_parent = parent;
+ m_domain = domain;
+ }
+
+ /**
+ * Refresh the editor page.
+ *
+ * @param input The editor input
+ */
+ public void refresh(IEditorInput input) {
+ super.setInput(input);
+
+ getViewer().setContents(getDescription());
+
+ focus(getDescription());
+ }
+
+ /**
+ * Refresh the editor page without a new input.
+ *
+ */
+ public void refresh() {
+ }
+
+ /**
+ * This method returns the Description
+ *
+ * @return The description
+ */
+ public Object getDescription() {
+ return(m_parent.getDescription());
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.ISaveablePart#doSave(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public final void doSave(IProgressMonitor monitor) {
+ // our policy: delegate saving to the parent
+ getEditor().doSave(monitor);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.ISaveablePart#doSaveAs()
+ */
+ public final void doSaveAs() {
+ // our policy: delegate saving to the parent
+ getEditor().doSaveAs();
+ }
+
+ /**
+ * This method focuses on the editor page on the supplied
+ * component.
+ *
+ * @param component The component
+ */
+ public void focus(Object component) {
+ }
+
+ /**
+ * This method returns the current model component which
+ * is the focus of the editor page.
+ *
+ * @return The focus component
+ */
+ public Object getFocusComponent() {
+ return(null);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IEditorPart#init(org.eclipse.ui.IEditorSite, org.eclipse.ui.IEditorInput)
+ */
+ public void init(IEditorSite site, IEditorInput input)
+ throws PartInitException {
+ setSite(site);
+ setInput(input);
+ setPartName(input.getName() + ": " + getPageName());
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.ISaveablePart#isDirty()
+ */
+ public final boolean isDirty() {
+ // our policy: delegate saving to the parent
+ // note: this method shouldn't get called anyway
+ return getEditor().isDirty();
+ }
+
+ /**
+ * Returns the <code>CommandStack</code> of this editor page.
+ * @return the <code>CommandStack</code> of this editor page
+ */
+ protected final CommandStack getCommandStack()
+ {
+ return getEditDomain().getCommandStack();
+ }
+
+ /**
+ * Returns the <code>PaletteRoot</code> this editor page uses.
+ * @return the <code>PaletteRoot</code>
+ */
+ protected PaletteRoot getPaletteRoot() {
+ // by default we use the root provided by the multi-page editor
+ return(getEditor().getPaletteRoot());
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.ISaveablePart#isSaveAsAllowed()
+ */
+ public final boolean isSaveAsAllowed() {
+ // our policy: delegate saving to the parent
+ return(getEditor().isSaveAsAllowed());
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWorkbenchPart#setFocus()
+ */
+ public void setFocus() {
+ try {
+ getViewer().getControl().setFocus();
+ } catch(Exception e) {
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine("Failed to set focus: "+e);
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
+ */
+ public final void createPartControl(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ layout.verticalSpacing = 5;
+ layout.horizontalSpacing = 5;
+ layout.numColumns = 1;
+ composite.setLayout(layout);
+ composite.setBackground(
+ parent.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
+ composite.setForeground(
+ parent.getDisplay().getSystemColor(SWT.COLOR_LIST_FOREGROUND));
+
+ // label on top
+ /*
+ Label label =
+ new Label(composite, SWT.HORIZONTAL | SWT.SHADOW_OUT | SWT.LEFT);
+ label.setText(getTitle());
+ label.setFont(
+ JFaceResources.getFontRegistry().get(JFaceResources.HEADER_FONT));
+ label.setBackground(
+ parent.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
+ label.setForeground(
+ parent.getDisplay().getSystemColor(SWT.COLOR_LIST_FOREGROUND));
+ label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+*/
+ createBannerControl(composite);
+
+
+ // now the main editor page
+ composite = new Composite(composite, SWT.NONE);
+ composite.setLayout(new FillLayout());
+ composite.setBackground(
+ parent.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
+ composite.setForeground(
+ parent.getDisplay().getSystemColor(SWT.COLOR_LIST_FOREGROUND));
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+ createPageControl(composite);
+ }
+
+ /**
+ * Returns the human readable name of this editor page.
+ * @return the human readable name of this editor page
+ */
+ protected abstract String getPageName();
+
+ /**
+ * Creates the control of this editor banner.
+ * @param parent
+ */
+ protected void createBannerControl(Composite parent) {
+
+ }
+
+ /**
+ * Creates the cotrol of this editor page.
+ * @param parent
+ */
+ protected abstract void createPageControl(Composite parent);
+
+ /**
+ * Returns the multi page workflow editor this editor page is contained in.
+ * @return the parent multi page editor
+ */
+ protected final Editor getEditor() {
+ return(m_parent);
+ }
+
+ /**
+ * Returns the edit domain this editor page uses.
+ * @return the edit domain this editor page uses
+ */
+ public final EditDomain getEditDomain() {
+ return(m_domain);
+ }
+
+ /**
+ * Hooks a <code>EditPartViewer</code> to the rest of the Editor.
+ *
+ * <p>By default, the viewer is added to the SelectionSynchronizer,
+ * which can be used to keep 2 or more EditPartViewers in sync.
+ * The viewer is also registered as the ISelectionProvider
+ * for the Editor's PartSite.
+ *
+ * @param viewer the viewer to hook into the editor
+ */
+ protected void registerEditPartViewer(EditPartViewer viewer) {
+
+ // register viewer to edit domain
+ getEditDomain().addViewer(viewer);
+
+ // the multi page workflow editor keeps track of synchronizing
+ getEditor().getSelectionSynchronizer().addViewer(viewer);
+
+ // add viewer as selection provider
+ getSite().setSelectionProvider(viewer);
+ }
+
+ /**
+ * Configures the specified <code>EditPartViewer</code>.
+ *
+ * @param viewer
+ */
+ protected void configureEditPartViewer(EditPartViewer viewer) {
+
+ // configure the shared key handler
+ if (viewer.getKeyHandler() != null) {
+ viewer.getKeyHandler().setParent(
+ getEditor().getSharedKeyHandler());
+ }
+
+ // configure the context menu
+ ContextMenuProvider provider = createContextMenuProvider(viewer);
+
+ // TODO: GPB - check if 'flow.editor.contextmenu' maps
+ // to anything
+ viewer.setContextMenu(provider);
+ getSite().registerContextMenu(DesignerDefinitions.DESIGNER_PLUGIN_ID+
+ ".flow.editor.contextmenu", provider,
+ getSite().getSelectionProvider()); //$NON-NLS-1$
+
+ // enable viewer as drop target for template transfers
+ viewer.addDropTargetListener(createTransferDropTargetListener(viewer));
+ }
+
+ /**
+ * This method returns the context menu provider.
+ *
+ * @param viewer The edit part viewer
+ * @return The context menu provider
+ */
+ protected ContextMenuProvider createContextMenuProvider(EditPartViewer viewer) {
+ return(new EditorContextMenuProvider(viewer,
+ getEditor().getActionRegistry()));
+ }
+
+ /**
+ * This method returns a transfer drop target listener.
+ *
+ * @param viewer The edit part viewer
+ * @return The transfer drop target listener
+ */
+ protected abstract org.eclipse.jface.util.TransferDropTargetListener createTransferDropTargetListener(EditPartViewer viewer);
+
+ /**
+ * Creates the createPaletteViewer on the specified <code>Composite</code>.
+ * @param parent the parent composite
+ */
+ protected void createPaletteViewer(Composite parent) {
+ // create graphical viewer
+ m_paletteViewer = new PaletteViewer();
+ m_paletteViewer.createControl(parent);
+
+ // configure the viewer
+ m_paletteViewer.getControl().setBackground(parent.getBackground());
+
+ // hook the viewer into the EditDomain (only one palette per EditDomain)
+ getEditDomain().setPaletteViewer(m_paletteViewer);
+
+ // important: the palette is initialized via EditDomain
+ //fancy palette: paletteViewer.setEditPartFactory(new CustomizedPaletteEditPartFactory());
+ getEditDomain().setPaletteRoot(getPaletteRoot());
+
+ // enable the palette as source for drag operations
+ m_paletteViewer.addDragSourceListener(
+ new TemplateTransferDragSourceListener(m_paletteViewer));
+ }
+
+ /**
+ * Returns the palette viewer.
+ * @return the palette viewer
+ */
+ protected PaletteViewer getPaletteViewer() {
+ return(m_paletteViewer);
+ }
+
+ /**
+ * Returns the viewer of this page.
+ *
+ * <p>This viewer is used for example for zoom support
+ * and for the thumbnail in the overview of the outline page.
+ *
+ * @return the viewer
+ */
+ protected abstract EditPartViewer getViewer();
+
+ /**
+ * This method returns the appropriate adapter for the
+ * supplied type.
+ *
+ * @param type The type
+ * @return The adapter
+ */
+ public Object getAdapter(Class type) {
+ if (type == GraphicalViewer.class &&
+ getViewer() instanceof GraphicalViewer) {
+ return(getViewer());
+ }
+ return(super.getAdapter(type));
+ }
+
+ /**
+ * This method recursively scans the editpart hierarchy to
+ * locate the editpart associated with the supplied
+ * component.
+ *
+ * @param editpart The current editpart to traverse
+ * @param component The component
+ * @return The located editpart, or null if not found
+ */
+ protected org.eclipse.gef.EditPart findSelectedEditPart(org.eclipse.gef.EditPart editpart,
+ Object component) {
+ org.eclipse.gef.EditPart ret=null;
+
+ if (component != null && editpart != null) {
+
+ if (editpart.getModel().equals(component)) {
+ ret = editpart;
+ } else {
+
+ if (editpart instanceof org.eclipse.gef.GraphicalEditPart) {
+ java.util.List cons=((org.eclipse.gef.GraphicalEditPart)editpart).getSourceConnections();
+
+ for (int i=0; ret == null && i < cons.size(); i++) {
+ org.eclipse.gef.EditPart subpart=
+ (org.eclipse.gef.EditPart)cons.get(i);
+
+ if (subpart.getModel().equals(component)) {
+ ret = subpart;
+ }
+ }
+ }
+
+ java.util.List list=editpart.getChildren();
+ java.util.Iterator iter=list.iterator();
+
+ while (ret == null && iter.hasNext()) {
+ org.eclipse.gef.EditPart subpart=(org.eclipse.gef.EditPart)
+ iter.next();
+
+ ret = findSelectedEditPart(subpart, component);
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * The <code>WorkbenchPart</code> implementation of this
+ * <code>IWorkbenchPart</code> method disposes the title image
+ * loaded by <code>setInitializationData</code>. Subclasses may extend.
+ */
+ public void dispose() {
+ super.dispose();
+ }
+
+ private static Logger logger = Logger.getLogger("org.pi4soa.designer.editor");
+
+ private final Editor m_parent;
+ private final EditDomain m_domain;
+ private PaletteViewer m_paletteViewer=null;
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/CopyAction.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/CopyAction.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/CopyAction.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2005 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Aug 10, 2005 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.editor;
+
+import org.eclipse.gef.EditPart;
+import org.eclipse.ui.IWorkbenchPart;
+
+/**
+ * This class provides the copy action implementation.
+ *
+ */
+public class CopyAction extends org.eclipse.gef.ui.actions.SelectionAction {
+
+ /**
+ * Creates a <code>SelectionAction</code> and associates it with the given workbench part.
+ * @param part the workbench part
+ */
+ public CopyAction(IWorkbenchPart part) {
+ super(part);
+ }
+
+ /**
+ * Initializes this action.
+ */
+ protected void init() {
+ setId(org.eclipse.ui.actions.ActionFactory.COPY.getId());
+ setText("Copy");
+ }
+
+ /**
+ * Calculates and returns the enabled state of this action.
+ * @return <code>true</code> if the action is enabled
+ */
+ protected boolean calculateEnabled() {
+ boolean ret=false;
+
+ if (getSelectedObjects() != null &&
+ getSelectedObjects().size() > 0) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ /**
+ * Perform this action.
+ *
+ */
+ public void run() {
+
+ if (getSelectedObjects().size() == 1 &&
+ getSelectedObjects().get(0) instanceof EditPart) {
+ EditPart ep=(EditPart)getSelectedObjects().get(0);
+
+ m_currentTarget = ep.getModel();
+ }
+ }
+
+ public static Object getCurrentTarget() {
+ return(m_currentTarget);
+ }
+
+ private static Object m_currentTarget=null;
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/CreateLinksAction.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/CreateLinksAction.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/CreateLinksAction.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2005-7 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Feb 23, 2007 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.editor;
+
+import org.eclipse.gef.EditPart;
+import org.eclipse.ui.IWorkbenchPart;
+
+/**
+ * This class provides the 'create message links' action implementation.
+ *
+ */
+public class CreateLinksAction extends org.eclipse.gef.ui.actions.SelectionAction {
+
+ public static final String ID = "org.pi4soa.service.test.designer.editor.CreateMessageLinksID";
+
+ /**
+ * Creates a <code>CreateMessageLinksAction</code> and
+ * associates it with the given workbench part.
+ * @param part the workbench part
+ */
+ public CreateLinksAction(IWorkbenchPart part) {
+ super(part);
+ }
+
+ /**
+ * Initializes this action.
+ */
+ protected void init() {
+ setId(ID);
+ setText("Create Message Links");
+ }
+
+ /**
+ * Calculates and returns the enabled state of this action.
+ * @return <code>true</code> if the action is enabled
+ */
+ protected boolean calculateEnabled() {
+ return(true);
+ }
+
+ /**
+ * Perform this action.
+ *
+ */
+ public void run() {
+
+ org.savara.scenario.model.Scenario scenario=
+ ((ScenarioDesigner)getWorkbenchPart()).getScenario();
+
+ org.savara.tools.scenario.designer.tools.CreateLinksTool tool=
+ new org.savara.tools.scenario.designer.tools.CreateLinksTool(scenario);
+
+ tool.run();
+
+ if (tool.isScenarioChanged()) {
+ ((ScenarioDesigner)getWorkbenchPart()).setDirty(true);
+ }
+ }
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/DelegatingCommandStack.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/DelegatingCommandStack.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/DelegatingCommandStack.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,224 @@
+/*
+ * Copyright 2005 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Jul 5, 2005 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.editor;
+
+import java.util.EventObject;
+
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.CommandStack;
+import org.eclipse.gef.commands.CommandStackListener;
+import org.eclipse.gef.commands.UnexecutableCommand;
+
+/**
+ * This class implements the delegating command stack.
+ */
+public class DelegatingCommandStack extends CommandStack
+ implements CommandStackListener {
+
+ /**
+ * Returns the current <code>CommandStack</code>.
+ * @return the current <code>CommandStack</code>
+ */
+ public CommandStack getCurrentCommandStack()
+ {
+ return currentCommandStack;
+ }
+
+ /**
+ * Sets the current <code>CommandStack</code>.
+ * @param stack the <code>CommandStack</code> to set
+ */
+ public void setCurrentCommandStack(CommandStack stack) {
+ if (currentCommandStack == stack) {
+ return;
+ }
+
+ // remove from old command stack
+ if (null != currentCommandStack) {
+ currentCommandStack.removeCommandStackListener(this);
+ }
+
+ // set new command stack
+ currentCommandStack = stack;
+
+ // watch new command stack
+ currentCommandStack.addCommandStackListener(this);
+
+ // the command stack changed
+ notifyListeners();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.commands.CommandStack#canRedo()
+ */
+ public boolean canRedo() {
+ if (null == currentCommandStack) {
+ return false;
+ }
+
+ return currentCommandStack.canRedo();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.commands.CommandStack#canUndo()
+ */
+ public boolean canUndo() {
+ if (null == currentCommandStack) {
+ return false;
+ }
+
+ return currentCommandStack.canUndo();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.commands.CommandStack#dispose()
+ */
+ public void dispose() {
+ if (null != currentCommandStack) {
+ currentCommandStack.dispose();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.commands.CommandStack#execute(org.eclipse.gef.commands.Command)
+ */
+ public void execute(Command command) {
+ if (null != currentCommandStack) {
+ currentCommandStack.execute(command);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.commands.CommandStack#flush()
+ */
+ public void flush() {
+ if (null != currentCommandStack) {
+ currentCommandStack.flush();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.commands.CommandStack#getCommands()
+ */
+ public Object[] getCommands() {
+ if (null == currentCommandStack) {
+ return EMPTY_OBJECT_ARRAY;
+ }
+
+ return currentCommandStack.getCommands();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.commands.CommandStack#getRedoCommand()
+ */
+ public Command getRedoCommand() {
+ if (null == currentCommandStack) {
+ return UnexecutableCommand.INSTANCE;
+ }
+
+ return currentCommandStack.getRedoCommand();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.commands.CommandStack#getUndoCommand()
+ */
+ public Command getUndoCommand() {
+ if (null == currentCommandStack) {
+ return UnexecutableCommand.INSTANCE;
+ }
+
+ return currentCommandStack.getUndoCommand();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.commands.CommandStack#getUndoLimit()
+ */
+ public int getUndoLimit() {
+ if (null == currentCommandStack) {
+ return -1;
+ }
+
+ return currentCommandStack.getUndoLimit();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.commands.CommandStack#isDirty()
+ */
+ public boolean isDirty() {
+ if (null == currentCommandStack) {
+ return false;
+ }
+
+ return currentCommandStack.isDirty();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.commands.CommandStack#markSaveLocation()
+ */
+ public void markSaveLocation() {
+ if (null != currentCommandStack) {
+ currentCommandStack.markSaveLocation();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.commands.CommandStack#redo()
+ */
+ public void redo() {
+ if (null != currentCommandStack) {
+ currentCommandStack.redo();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.commands.CommandStack#setUndoLimit(int)
+ */
+ public void setUndoLimit(int undoLimit) {
+ if (null != currentCommandStack) {
+ currentCommandStack.setUndoLimit(undoLimit);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.commands.CommandStack#undo()
+ */
+ public void undo() {
+ if (null != currentCommandStack) {
+ currentCommandStack.undo();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ public String toString() {
+ return "DelegatingCommandStack(" + currentCommandStack + ")";
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.commands.CommandStackListener#commandStackChanged(java.util.EventObject)
+ */
+ public void commandStackChanged(EventObject event) {
+ notifyListeners();
+ }
+
+ private static final Object[] EMPTY_OBJECT_ARRAY = new Object[] {};
+ private CommandStack currentCommandStack;
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/DelegatingZoomManager.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/DelegatingZoomManager.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/DelegatingZoomManager.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,332 @@
+/*
+ * Copyright 2005 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Jul 5, 2005 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.editor;
+
+import org.eclipse.draw2d.ScalableFigure;
+import org.eclipse.draw2d.Viewport;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gef.editparts.ZoomListener;
+import org.eclipse.gef.editparts.ZoomManager;
+import org.eclipse.jface.util.ListenerList;
+
+/**
+ * The zoom manager.
+ */
+public class DelegatingZoomManager extends ZoomManager implements ZoomListener {
+
+ /**
+ * Creates a new DelegatingZoomManager instance.
+ */
+ public DelegatingZoomManager()
+ {
+ super((ScalableFigure) null, (Viewport) null);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.editparts.ZoomListener#zoomChanged(double)
+ */
+ public void zoomChanged(double zoom)
+ {
+ Object[] listeners = m_zoomListeners.getListeners();
+ for (int i = 0; i < listeners.length; ++i)
+ {
+ ((ZoomListener) listeners[i]).zoomChanged(zoom);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.editparts.ZoomManager#addZoomListener(org.eclipse.gef.editparts.ZoomListener)
+ */
+ public void addZoomListener(ZoomListener listener)
+ {
+ m_zoomListeners.add(listener);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.editparts.ZoomManager#removeZoomListener(org.eclipse.gef.editparts.ZoomListener)
+ */
+ public void removeZoomListener(ZoomListener listener)
+ {
+ m_zoomListeners.remove(listener);
+ }
+
+ /**
+ * Sets the ZoomManager all work should be delegated to.
+ * @param zoomManager
+ */
+ public void setCurrentZoomManager(ZoomManager zoomManager)
+ {
+ if (null != m_currentZoomManager)
+ m_currentZoomManager.removeZoomListener(this);
+
+ m_currentZoomManager = zoomManager;
+ if(null != m_currentZoomManager)
+ {
+ m_currentZoomManager.addZoomListener(this);
+ zoomChanged(m_currentZoomManager.getZoom());
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.editparts.ZoomManager#canZoomIn()
+ */
+ public boolean canZoomIn()
+ {
+ if(null == m_currentZoomManager)
+ return false;
+
+ return m_currentZoomManager.canZoomIn();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.editparts.ZoomManager#canZoomOut()
+ */
+ public boolean canZoomOut()
+ {
+ if(null == m_currentZoomManager)
+ return false;
+
+ return m_currentZoomManager.canZoomOut();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.editparts.ZoomManager#getMaxZoom()
+ */
+ public double getMaxZoom()
+ {
+ if(null == m_currentZoomManager)
+ return 1;
+
+ return m_currentZoomManager.getMaxZoom();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.editparts.ZoomManager#getMinZoom()
+ */
+ public double getMinZoom()
+ {
+ if(null == m_currentZoomManager)
+ return 1;
+
+ return m_currentZoomManager.getMinZoom();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.editparts.ZoomManager#getNextZoomLevel()
+ */
+ public double getNextZoomLevel()
+ {
+ if(null == m_currentZoomManager)
+ return 1;
+
+ return m_currentZoomManager.getNextZoomLevel();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.editparts.ZoomManager#getPreviousZoomLevel()
+ */
+ public double getPreviousZoomLevel()
+ {
+ if(null == m_currentZoomManager)
+ return 1;
+
+ return m_currentZoomManager.getPreviousZoomLevel();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.editparts.ZoomManager#getScalableFigure()
+ */
+ public ScalableFigure getScalableFigure()
+ {
+ if(null == m_currentZoomManager)
+ return null;
+
+ return m_currentZoomManager.getScalableFigure();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.editparts.ZoomManager#getUIMultiplier()
+ */
+ public double getUIMultiplier()
+ {
+ if(null == m_currentZoomManager)
+ return 1;
+
+ return m_currentZoomManager.getUIMultiplier();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.editparts.ZoomManager#getViewport()
+ */
+ public Viewport getViewport()
+ {
+ if(null == m_currentZoomManager)
+ return null;
+
+ return m_currentZoomManager.getViewport();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.editparts.ZoomManager#getZoom()
+ */
+ public double getZoom()
+ {
+ if(null == m_currentZoomManager)
+ return 1;
+
+ return m_currentZoomManager.getZoom();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.editparts.ZoomManager#getZoomAsText()
+ */
+ public String getZoomAsText()
+ {
+ if(null == m_currentZoomManager)
+ return " 100%";
+
+ return m_currentZoomManager.getZoomAsText();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.editparts.ZoomManager#getZoomLevels()
+ */
+ public double[] getZoomLevels()
+ {
+ if(null == m_currentZoomManager)
+ return new double[] {1};
+
+ return m_currentZoomManager.getZoomLevels();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.editparts.ZoomManager#getZoomLevelsAsText()
+ */
+ public String[] getZoomLevelsAsText()
+ {
+ if(null == m_currentZoomManager)
+ return new String[] {" 100%"};
+
+ return m_currentZoomManager.getZoomLevelsAsText();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.editparts.ZoomManager#setUIMultiplier(double)
+ */
+ public void setUIMultiplier(double multiplier)
+ {
+ if(null == m_currentZoomManager)
+ return ;
+
+ m_currentZoomManager.setUIMultiplier(multiplier);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.editparts.ZoomManager#setViewLocation(org.eclipse.draw2d.geometry.Point)
+ */
+ public void setViewLocation(Point p)
+ {
+ if(null == m_currentZoomManager)
+ return ;
+
+ m_currentZoomManager.setViewLocation(p);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.editparts.ZoomManager#setZoom(double)
+ */
+ public void setZoom(double zoom)
+ {
+ if(null == m_currentZoomManager)
+ return ;
+
+ m_currentZoomManager.setZoom(zoom);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.editparts.ZoomManager#setZoomAnimationStyle(int)
+ */
+ public void setZoomAnimationStyle(int style)
+ {
+ if(null == m_currentZoomManager)
+ return ;
+
+ m_currentZoomManager.setZoomAnimationStyle(style);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.editparts.ZoomManager#setZoomAsText(java.lang.String)
+ */
+ public void setZoomAsText(String zoomString)
+ {
+ if(null == m_currentZoomManager)
+ return ;
+
+ m_currentZoomManager.setZoomAsText(zoomString);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.editparts.ZoomManager#setZoomLevels(double[])
+ */
+ public void setZoomLevels(double[] zoomLevels)
+ {
+ if(null == m_currentZoomManager)
+ return ;
+
+ m_currentZoomManager.setZoomLevels(zoomLevels);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.editparts.ZoomManager#zoomIn()
+ */
+ public void zoomIn()
+ {
+ if(null == m_currentZoomManager)
+ return ;
+
+ m_currentZoomManager.zoomIn();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.editparts.ZoomManager#zoomOut()
+ */
+ public void zoomOut()
+ {
+ if(null == m_currentZoomManager)
+ return ;
+
+ m_currentZoomManager.zoomOut();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.editparts.ZoomManager#zoomTo(org.eclipse.draw2d.geometry.Rectangle)
+ */
+ public void zoomTo(Rectangle rect)
+ {
+ if(null == m_currentZoomManager)
+ return ;
+
+ m_currentZoomManager.zoomTo(rect);
+ }
+
+ private ZoomManager m_currentZoomManager;
+ private ListenerList m_zoomListeners = new ListenerList(3);
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/DesignerActionBarContributor.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/DesignerActionBarContributor.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/DesignerActionBarContributor.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,118 @@
+/*
+ * Copyright 2005-7 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Feb 14, 2007 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.editor;
+
+import org.eclipse.gef.ui.actions.ActionBarContributor;
+import org.eclipse.gef.ui.actions.DeleteRetargetAction;
+import org.eclipse.gef.ui.actions.GEFActionConstants;
+import org.eclipse.gef.ui.actions.RedoRetargetAction;
+import org.eclipse.gef.ui.actions.UndoRetargetAction;
+import org.eclipse.gef.ui.actions.ZoomComboContributionItem;
+import org.eclipse.gef.ui.actions.ZoomInRetargetAction;
+import org.eclipse.gef.ui.actions.ZoomOutRetargetAction;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.IWorkbenchWindow;
+
+/**
+ * Adds commands to the action bar.
+ */
+public class DesignerActionBarContributor extends ActionBarContributor {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.ui.actions.ActionBarContributor#buildActions()
+ */
+ protected void buildActions() {
+ addRetargetAction(new UndoRetargetAction());
+ addRetargetAction(new RedoRetargetAction());
+ addRetargetAction(new DeleteRetargetAction());
+
+ IWorkbenchWindow iww = getPage().getWorkbenchWindow();
+ addRetargetAction((org.eclipse.ui.actions.RetargetAction)
+ org.eclipse.ui.actions.ActionFactory.COPY.create(iww));
+ addRetargetAction((org.eclipse.ui.actions.RetargetAction)
+ org.eclipse.ui.actions.ActionFactory.PASTE.create(iww));
+
+ addRetargetAction(new ZoomInRetargetAction());
+ addRetargetAction(new ZoomOutRetargetAction());
+
+ org.eclipse.ui.actions.RetargetAction act=
+ new org.eclipse.ui.actions.RetargetAction(
+ SimulateScenarioAction.ID, "Simulate Scenario");
+ act.setImageDescriptor(org.savara.tools.scenario.designer.DesignerImages.getImageDescriptor("Simulate.png"));
+ addRetargetAction(act);
+
+ act = new org.eclipse.ui.actions.RetargetAction(
+ ResetSimulationAction.ID, "Reset Simulation");
+ act.setImageDescriptor(org.savara.tools.scenario.designer.DesignerImages.getImageDescriptor("ResetSimulation.png"));
+ addRetargetAction(act);
+
+ act = new org.eclipse.ui.actions.RetargetAction(
+ GenerateImageAction.ID, "Generate Image");
+ act.setImageDescriptor(org.savara.tools.scenario.designer.DesignerImages.getImageDescriptor("GenerateImage.gif"));
+ addRetargetAction(act);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.ui.actions.ActionBarContributor#declareGlobalActionKeys()
+ */
+ protected void declareGlobalActionKeys() {
+ addGlobalActionKey(org.eclipse.ui.actions.ActionFactory.PRINT.getId());
+ addGlobalActionKey(org.eclipse.ui.actions.ActionFactory.DELETE.getId());
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.part.EditorActionBarContributor#contributeToMenu(org.eclipse.jface.action.IMenuManager)
+ */
+ public void contributeToMenu(IMenuManager menuManager) {
+ super.contributeToMenu(menuManager);
+
+ // add a "View" menu after "Edit"
+ MenuManager viewMenu = new MenuManager("View");
+ viewMenu.add(getAction(GEFActionConstants.ZOOM_IN));
+ viewMenu.add(getAction(GEFActionConstants.ZOOM_OUT));
+
+ menuManager.insertAfter(IWorkbenchActionConstants.M_EDIT, viewMenu);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.part.EditorActionBarContributor#contributeToToolBar(org.eclipse.jface.action.IToolBarManager)
+ */
+ public void contributeToToolBar(IToolBarManager toolBarManager) {
+ super.contributeToToolBar(toolBarManager);
+
+ toolBarManager.add(getAction(org.eclipse.ui.actions.ActionFactory.UNDO.getId()));
+ toolBarManager.add(getAction(org.eclipse.ui.actions.ActionFactory.REDO.getId()));
+
+ toolBarManager.add(getAction(org.eclipse.ui.actions.ActionFactory.COPY.getId()));
+ toolBarManager.add(getAction(org.eclipse.ui.actions.ActionFactory.PASTE.getId()));
+
+ toolBarManager.add(new Separator());
+ toolBarManager.add(new ZoomComboContributionItem(getPage()));
+
+ toolBarManager.add(new Separator());
+ toolBarManager.add(getAction(org.savara.tools.scenario.designer.editor.SimulateScenarioAction.ID));
+ toolBarManager.add(getAction(org.savara.tools.scenario.designer.editor.ResetSimulationAction.ID));
+ toolBarManager.add(getAction(org.savara.tools.scenario.designer.editor.GenerateImageAction.ID));
+ }
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/Editor.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/Editor.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/Editor.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,146 @@
+/*
+ * Copyright 2005 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Jan 5, 2006 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.editor;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.gef.KeyHandler;
+import org.eclipse.gef.palette.PaletteRoot;
+import org.eclipse.gef.ui.actions.ActionRegistry;
+import org.eclipse.gef.ui.parts.SelectionSynchronizer;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IWorkbenchPartSite;
+
+/**
+ * This interface represents an editor within the pi4soa designer.
+ *
+ */
+public interface Editor {
+
+ /**
+ * This method returns the dirty status of the edited content.
+ *
+ * @return Whether the content is dirty.
+ * @see org.eclipse.ui.part.MultiPageEditorPart#isDirty()
+ */
+ public boolean isDirty();
+
+ /**
+ * This method indicates that the edited content is dirty.
+ *
+ * @param dirty The dirty status
+ */
+ public void setDirty(boolean dirty);
+
+ /**
+ * This method determines if the editor is currently in
+ * the process of saving its modified content.
+ *
+ * @return Whether the editor is currently saving
+ */
+ public boolean isEditorSaving();
+
+ /**
+ * Closes this editor.
+ * @param save
+ */
+ public void closeEditor(final boolean save);
+
+ /**
+ * This method returns the editor input.
+ *
+ * @return The editor input
+ */
+ public IEditorInput getEditorInput();
+
+ /**
+ * This method sets the editor input.
+ *
+ * @param input The editor input
+ */
+ public void setInput(IEditorInput input);
+
+ /**
+ * This method returns the editor site.
+ *
+ * @return The editor site
+ */
+ public IWorkbenchPartSite getSite();
+
+ /**
+ * This method return the primary description being
+ * presented by the editor.
+ *
+ * @return The description
+ */
+ public Object getDescription();
+
+ /**
+ * This method saves the content.
+ *
+ * @param monitor Progress monitor
+ * @see org.eclipse.ui.part.EditorPart#doSave(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public void doSave(IProgressMonitor monitor);
+
+ /**
+ * This method enables the user to select where the choreography
+ * description should be saved to.
+ *
+ * @see org.eclipse.ui.ISaveablePart#doSaveAs()
+ */
+ public void doSaveAs();
+
+ /**
+ * This method determines whether the contents can be saved.
+ *
+ * @return Whether the contents can be saved
+ * @see org.eclipse.ui.part.EditorPart#isSaveAsAllowed()
+ */
+ public boolean isSaveAsAllowed();
+
+ /**
+ * Returns the default <code>PaletteRoot</code> for this editor and all
+ * its pages.
+ * @return the default <code>PaletteRoot</code>
+ */
+ public PaletteRoot getPaletteRoot();
+
+ /**
+ * Returns the selection syncronizer object.
+ * The synchronizer can be used to sync the selection of 2 or more
+ * EditPartViewers.
+ * @return the syncrhonizer
+ */
+ public SelectionSynchronizer getSelectionSynchronizer();
+
+ /**
+ * Returns the action registry of this editor.
+ * @return the action registry
+ */
+ public ActionRegistry getActionRegistry();
+
+ /**
+ * This method returns the shared key handler.
+ *
+ * @return The shared key handler
+ */
+ public KeyHandler getSharedKeyHandler();
+
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/EditorContextMenuProvider.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/EditorContextMenuProvider.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/EditorContextMenuProvider.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,157 @@
+/*
+ * Copyright 2005-7 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Feb 23, 2007 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.editor;
+
+import org.eclipse.gef.ContextMenuProvider;
+import org.eclipse.gef.EditPartViewer;
+import org.eclipse.gef.ui.actions.ActionRegistry;
+import org.eclipse.gef.ui.actions.GEFActionConstants;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+
+/**
+ * The editor's context menu.
+ */
+public class EditorContextMenuProvider extends ContextMenuProvider {
+
+ /**
+ * Creates a new WorkflowEditorContextMenuProvider instance.
+ * @param viewer
+ */
+ public EditorContextMenuProvider(EditPartViewer viewer,
+ ActionRegistry actionRegistry) {
+ super(viewer);
+ m_actionRegistry = actionRegistry;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.ContextMenuProvider#buildContextMenu(org.eclipse.jface.action.IMenuManager)
+ */
+ public void buildContextMenu(IMenuManager menuManager) {
+ GEFActionConstants.addStandardActionGroups(menuManager);
+
+ appendActionToUndoGroup(menuManager, org.eclipse.ui.actions.ActionFactory.UNDO.getId());
+ appendActionToUndoGroup(menuManager, org.eclipse.ui.actions.ActionFactory.REDO.getId());
+
+ appendActionToEditGroup(menuManager, org.eclipse.ui.actions.ActionFactory.COPY.getId());
+ appendActionToEditGroup(menuManager, org.eclipse.ui.actions.ActionFactory.PASTE.getId());
+ appendActionToEditGroup(menuManager, org.eclipse.ui.actions.ActionFactory.DELETE.getId());
+ appendActionToEditGroup(menuManager, GEFActionConstants.DIRECT_EDIT);
+
+ appendScenarioSubmenu(menuManager);
+
+ appendActionToMenu(
+ menuManager,
+ org.eclipse.ui.actions.ActionFactory.SAVE.getId(),
+ GEFActionConstants.GROUP_SAVE);
+ }
+
+ /**
+ * Appends the alignment subment.
+ * @param menuManager
+ */
+ private void appendScenarioSubmenu(IMenuManager menuManager) {
+
+ // Scenario Actions
+ MenuManager submenu = new MenuManager("Scenario");
+
+ IAction action = getActionRegistry().getAction(org.savara.tools.scenario.designer.editor.SimulateScenarioAction.ID);
+ if (null != action && action.isEnabled())
+ submenu.add(action);
+
+ action = getActionRegistry().getAction(org.savara.tools.scenario.designer.editor.ResetSimulationAction.ID);
+ if (null != action && action.isEnabled())
+ submenu.add(action);
+
+ action = getActionRegistry().getAction(org.savara.tools.scenario.designer.editor.GenerateImageAction.ID);
+ if (null != action && action.isEnabled()) {
+ submenu.add(new Separator());
+
+ submenu.add(action);
+ }
+
+ submenu.add(new Separator());
+
+ action = getActionRegistry().getAction(org.savara.tools.scenario.designer.editor.CreateLinksAction.ID);
+ if (null != action && action.isEnabled())
+ submenu.add(action);
+
+ submenu.add(new Separator());
+
+ /*
+ action = getActionRegistry().getAction(org.savara.tools.scenario.designer.editor.ShowIdentityDetailsAction.ID);
+ if (null != action && action.isEnabled())
+ submenu.add(action);
+ */
+
+ if (!submenu.isEmpty())
+ menuManager.appendToGroup(GEFActionConstants.GROUP_REST, submenu);
+ }
+
+ /**
+ * Returns the action registry.
+ * @return the action registry
+ */
+ protected ActionRegistry getActionRegistry() {
+ return m_actionRegistry;
+ }
+
+ /**
+ * Appends the specified action to the specified menu group
+ * @param actionId
+ * @param menuGroup
+ */
+ private void appendActionToMenu(IMenuManager menu,
+ String actionId, String menuGroup) {
+ IAction action = getActionRegistry().getAction(actionId);
+ if (null != action && action.isEnabled()) {
+ menu.appendToGroup(menuGroup, action);
+ }
+ }
+
+ /**
+ * Appends the specified action to the specified menu group
+ * @param actionId
+ * @param menuGroup
+ */
+ private void appendActionToUndoGroup(IMenuManager menu, String actionId) {
+ IAction action = getActionRegistry().getAction(actionId);
+ if (null != action && action.isEnabled()) {
+ menu.appendToGroup(GEFActionConstants.GROUP_UNDO, action);
+ }
+ }
+
+ /**
+ * Appends the specified action to the specified menu group
+ * @param actionId
+ * @param menuGroup
+ */
+ private void appendActionToEditGroup(IMenuManager menu, String actionId) {
+ IAction action = getActionRegistry().getAction(actionId);
+ if (null != action && action.isEnabled()) {
+ menu.appendToGroup(GEFActionConstants.GROUP_EDIT, action);
+ }
+ }
+
+ /** the action registry */
+ private ActionRegistry m_actionRegistry=null;
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/GenerateImageAction.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/GenerateImageAction.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/GenerateImageAction.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,315 @@
+/*
+ * Copyright 2005-7 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Feb 23, 2007 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.editor;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.ImageData;
+import org.eclipse.swt.graphics.ImageLoader;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.draw2d.Graphics;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.SWTGraphics;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gef.GraphicalViewer;
+import org.eclipse.gef.LayerConstants;
+import org.eclipse.gef.editparts.LayerManager;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.util.Assert;
+import org.savara.tools.scenario.designer.parts.ScenarioEditPart;
+
+/**
+ * This class provides the 'reset simulation' action implementation.
+ *
+ */
+public class GenerateImageAction extends org.eclipse.gef.ui.actions.SelectionAction {
+
+ public static final String ID = "org.pi4soa.service.test.designer.editor.GenerateImageID";
+
+ /**
+ * Creates a <code>CreateMessageLinksAction</code> and
+ * associates it with the given workbench part.
+ * @param part the workbench part
+ */
+ public GenerateImageAction(IWorkbenchPart part) {
+ super(part);
+ }
+
+ /**
+ * Initializes this action.
+ */
+ protected void init() {
+ setId(ID);
+ setText("Generate Image...");
+
+ setImageDescriptor(org.savara.tools.scenario.designer.DesignerImages.getImageDescriptor("GenerateImage.gif"));
+ }
+
+ /**
+ * Calculates and returns the enabled state of this action.
+ * @return <code>true</code> if the action is enabled
+ */
+ protected boolean calculateEnabled() {
+ boolean ret=false;
+
+ if (getWorkbenchPart() instanceof ScenarioDesigner &&
+ ((ScenarioDesigner)getWorkbenchPart()).getScenarioEditorPage().getViewer()
+ instanceof GraphicalViewer) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ /**
+ * Perform this action.
+ *
+ */
+ public void run() {
+ save(getWorkbenchPart().getSite().getPage().getActiveEditor(),
+ (GraphicalViewer)((ScenarioDesigner)
+ getWorkbenchPart()).getScenarioEditorPage().getViewer());
+ }
+
+ public boolean save(IEditorPart editorPart, GraphicalViewer viewer) {
+ Assert.isNotNull(editorPart, "null editorPart passed to ImageSaveUtil::save");
+ Assert.isNotNull(viewer, "null viewer passed to ImageSaveUtil::save");
+
+ String saveFilePath = getSaveFilePath(editorPart, viewer, -1);
+ if( saveFilePath == null ) return false;
+
+ int format = SWT.IMAGE_JPEG;
+ if( saveFilePath.endsWith(".jpeg") )
+ format = SWT.IMAGE_JPEG;
+ else if( saveFilePath.endsWith(".gif") )
+ format = SWT.IMAGE_GIF;
+ else if( saveFilePath.endsWith(".png") )
+ format = SWT.IMAGE_PNG;
+ else if( saveFilePath.endsWith(".bmp") )
+ format = SWT.IMAGE_BMP;
+ else if( saveFilePath.endsWith(".ico") )
+ format = SWT.IMAGE_ICO;
+
+ // GIF currently throughs 'unsupported color depth'
+ if( format != SWT.IMAGE_BMP && format != SWT.IMAGE_JPEG
+ /*&& format != SWT.IMAGE_GIF*/
+ && format != SWT.IMAGE_PNG
+ && format != SWT.IMAGE_ICO )
+ throw new IllegalArgumentException("Save format not supported");
+
+ try {
+ saveEditorContentsAsImage(editorPart, viewer, saveFilePath, format);
+ } catch (Exception ex) {
+ MessageDialog.openError(editorPart.getEditorSite().getShell(), "Save Error", "Could not save editor contents");
+ //org.pi4soa.designer.eclipse.Activator.logError("Failed to save image", ex);
+ return false;
+ }
+
+ return true;
+ }
+
+ private String getSaveFilePath(IEditorPart editorPart, GraphicalViewer viewer, int format) {
+ FileDialog fileDialog = new FileDialog(editorPart.getEditorSite().getShell(), SWT.SAVE);
+
+ String[] filterExtensions = new String[] {"*.jpeg", "*.bmp", "*.ico", "*.png"/*"*.gif", "*.png"*/};
+ if( format == SWT.IMAGE_BMP )
+ filterExtensions = new String[] {"*.bmp"};
+ else if( format == SWT.IMAGE_JPEG )
+ filterExtensions = new String[] {"*.jpeg"};
+ else if( format == SWT.IMAGE_GIF )
+ filterExtensions = new String[] {"*.gif"};
+ else if( format == SWT.IMAGE_PNG )
+ filterExtensions = new String[] {"*.png"};
+ else if( format == SWT.IMAGE_ICO )
+ filterExtensions = new String[] {"*.ico"};
+ fileDialog.setFilterExtensions(filterExtensions);
+
+ return fileDialog.open();
+ }
+
+ private void saveEditorContentsAsImage(IEditorPart editorPart, GraphicalViewer viewer, String saveFilePath, int format) {
+ /* 1. First get the figure whose visuals we want to save as image.
+ * So we would like to save the rooteditpart which actually hosts all the printable layers.
+ *
+ * NOTE: ScalableRootEditPart manages layers and is registered graphicalviewer's editpartregistry with
+ * the key LayerManager.ID ... well that is because ScalableRootEditPart manages all layers that
+ * are hosted on a FigureCanvas. Many layers exist for doing different things */
+ //ScalableRootEditPart rootEditPart = (ScalableRootEditPart)viewer.getEditPartRegistry().get(LayerManager.ID);
+ org.eclipse.gef.editparts.LayerManager lm=
+ (org.eclipse.gef.editparts.LayerManager)
+ viewer.getEditPartRegistry().get(LayerManager.ID);
+
+ IFigure rootFigure = lm.getLayer(LayerConstants.PRINTABLE_LAYERS);
+ Rectangle rootFigureBounds = null;
+ Rectangle additionalBounds = null;
+ java.util.List children=null;
+
+ if (lm instanceof org.eclipse.gef.RootEditPart) {
+ org.eclipse.gef.EditPart ep=((org.eclipse.gef.RootEditPart)lm).getContents();
+
+ if (ep instanceof ScenarioEditPart) {
+ children = ep.getChildren();
+
+ rootFigureBounds = ((ScenarioEditPart)ep).getComponentBoundsWithoutIdentityDetails();
+ additionalBounds = ((ScenarioEditPart)ep).getIdentityDetailsBounds();
+ }
+ }
+
+ if (rootFigureBounds == null) {
+ rootFigureBounds = rootFigure.getBounds();
+ }
+
+ /* 2. Now we want to get the GC associated with the control on which all figures are
+ * painted by SWTGraphics. For that first get the SWT Control associated with the viewer on which the
+ * rooteditpart is set as contents */
+ Control figureCanvas = viewer.getControl();
+ GC figureCanvasGC = new GC(figureCanvas);
+
+ /* 3. Create a new Graphics for an Image onto which we want to paint rootFigure */
+ Image img = new Image(null, rootFigureBounds.width, rootFigureBounds.height);
+ GC imageGC = new GC(img);
+ imageGC.setBackground(figureCanvasGC.getBackground());
+ imageGC.setForeground(figureCanvasGC.getForeground());
+ imageGC.setFont(figureCanvasGC.getFont());
+ imageGC.setLineStyle(figureCanvasGC.getLineStyle());
+ imageGC.setLineWidth(figureCanvasGC.getLineWidth());
+ imageGC.setXORMode(figureCanvasGC.getXORMode());
+ Graphics imgGraphics = new SWTGraphics(imageGC);
+
+ /* 4. Draw rootFigure onto image. After that image will be ready for save */
+ rootFigure.paint(imgGraphics);
+
+ /* 5. Save image */
+ ImageData[] imgData = new ImageData[1];
+ imgData[0] = img.getImageData();
+
+ ImageLoader imgLoader = new ImageLoader();
+ imgLoader.data = imgData;
+ imgLoader.save(saveFilePath, format);
+
+ /* release OS resources */
+ imageGC.dispose();
+ img.dispose();
+
+ if (additionalBounds != null &&
+ additionalBounds.width > 0 &&
+ additionalBounds.height > 0) {
+ /* 3. Create a new Graphics for an Image onto which we want to paint rootFigure */
+ int width=additionalBounds.width;
+ if (rootFigureBounds.width > width) {
+ width = rootFigureBounds.width;
+ }
+
+ img = new Image(null, width,
+ rootFigureBounds.height+additionalBounds.height);
+ imageGC = new GC(img);
+ imageGC.setBackground(figureCanvasGC.getBackground());
+ imageGC.setForeground(figureCanvasGC.getForeground());
+ imageGC.setFont(figureCanvasGC.getFont());
+ imageGC.setLineStyle(figureCanvasGC.getLineStyle());
+ imageGC.setLineWidth(figureCanvasGC.getLineWidth());
+ imageGC.setXORMode(figureCanvasGC.getXORMode());
+ imgGraphics = new SWTGraphics(imageGC);
+
+ /* 4. Draw rootFigure onto image. After that image will be ready for save */
+ rootFigure.paint(imgGraphics);
+
+ Image copy=new Image(null, additionalBounds.width,
+ additionalBounds.height);
+ imageGC.copyArea(copy, 0, rootFigureBounds.height);
+
+ StringBuffer filepath=new StringBuffer();
+ filepath.append(saveFilePath);
+
+ int ind=saveFilePath.lastIndexOf('.');
+ if (ind != -1) {
+ filepath.insert(ind, "-ids");
+ } else {
+ filepath.append("-ids");
+ }
+
+ /* 5. Save image */
+ imgData = new ImageData[1];
+ imgData[0] = copy.getImageData();
+
+ imgLoader = new ImageLoader();
+ imgLoader.data = imgData;
+ imgLoader.save(filepath.toString(), format);
+
+ /* release OS resources */
+ figureCanvasGC.dispose();
+ imageGC.dispose();
+ img.dispose();
+ copy.dispose();
+
+ // Write message link information in tabular form
+ //saveMessageLinkTable(editorPart, filepath.toString(), children);
+ }
+
+ figureCanvasGC.dispose();
+ }
+
+ /*
+ protected void saveMessageLinkTable(IEditorPart editorPart,
+ String imageFilePath, java.util.List children) {
+ String filepath=imageFilePath;
+ int ind=filepath.lastIndexOf('.');
+
+ if (ind != -1) {
+ filepath = imageFilePath.substring(0, ind);
+ filepath += ".csv";
+ } else {
+ filepath += ".csv";
+ }
+
+ try {
+ java.io.FileWriter writer=new java.io.FileWriter(filepath);
+
+ writer.write("Ref,Identity Tokens,Identity Values," +
+ "Query Expressions,Message File\r\n");
+
+ for (int i=0; i < children.size(); i++) {
+
+ if (children.get(i) instanceof MessageLinkInfoEditPart) {
+ MessageLinkInfo mli=(MessageLinkInfo)
+ ((MessageLinkInfoEditPart)children.get(i)).getModel();
+
+ writer.write(mli.getReference()+","+
+ mli.getIdentityTokens()+","+
+ mli.getIdentityValues()+","+
+ mli.getQueryExpressions()+","+
+ mli.getFile()+"\r\n");
+ }
+ }
+
+ writer.flush();
+ writer.close();
+
+ } catch(Exception e) {
+ MessageDialog.openError(editorPart.getEditorSite().getShell(), "Save Error", "Could not save csv file");
+ //org.pi4soa.designer.eclipse.Activator.logError("Failed to save csv file", e);
+ }
+ }
+ */
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/MultiPageCommandStackListener.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/MultiPageCommandStackListener.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/MultiPageCommandStackListener.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2005 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Jul 5, 2005 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.editor;
+
+import org.eclipse.gef.commands.CommandStack;
+import org.eclipse.gef.commands.CommandStackListener;
+
+/**
+ * This class listeners for command stacks associated with multiple
+ * pages.
+ */
+class MultiPageCommandStackListener implements CommandStackListener {
+
+ public MultiPageCommandStackListener(Editor editor) {
+ m_editor = editor;
+ }
+
+ /**
+ * Adds a <code>CommandStack</code> to observe.
+ * @param commandStack
+ */
+ public void addCommandStack(CommandStack commandStack) {
+ commandStacks.add(commandStack);
+ commandStack.addCommandStackListener(this);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.commands.CommandStackListener#commandStackChanged(java.util.EventObject)
+ */
+ public void commandStackChanged(java.util.EventObject event) {
+ if (((CommandStack) event.getSource()).isDirty()) {
+ // at least one command stack is dirty,
+ // so the multi page editor is dirty too
+ m_editor.setDirty(true);
+ } else {
+ // probably a save, we have to check all command stacks
+ boolean oneIsDirty = false;
+ for (java.util.Iterator stacks = commandStacks.iterator();
+ stacks.hasNext();) {
+ CommandStack stack = (CommandStack) stacks.next();
+ if (stack.isDirty()) {
+ oneIsDirty = true;
+ break;
+ }
+ }
+ m_editor.setDirty(oneIsDirty);
+ }
+ }
+
+ /**
+ * Disposed the listener
+ */
+ public void dispose() {
+ for (java.util.Iterator stacks = commandStacks.iterator();
+ stacks.hasNext();) {
+ ((CommandStack) stacks.next()).removeCommandStackListener(this);
+ }
+ commandStacks.clear();
+ }
+
+ /**
+ * Marks every observed command stack beeing saved.
+ * This method should be called whenever the editor/model
+ * was saved.
+ */
+ public void markSaveLocations() {
+ for (java.util.Iterator stacks = commandStacks.iterator();
+ stacks.hasNext();) {
+ CommandStack stack = (CommandStack) stacks.next();
+ stack.markSaveLocation();
+ }
+ }
+
+ /** the observed command stacks */
+ private java.util.List commandStacks = new java.util.ArrayList();
+ private Editor m_editor=null;
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/NewScenarioWizard.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/NewScenarioWizard.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/NewScenarioWizard.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,322 @@
+/*
+ * Copyright 2004-5 Enigmatec Corporation Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * 04-Feb-2005 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.editor;
+
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
+
+import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.ui.part.ISetSelectionTarget;
+
+import org.eclipse.core.runtime.Path;
+
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+import org.savara.scenario.util.ScenarioDefinitions;
+import org.savara.scenario.util.ScenarioModelUtil;
+
+/**
+ * This class provides the wizard responsible for creating
+ * new Scenario object models.
+ */
+public class NewScenarioWizard extends Wizard implements INewWizard {
+
+ /**
+ * This method initializes the wizard.
+ *
+ * @param workbench The workbench
+ * @param selection The selected resource
+ */
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ m_workbench = workbench;
+ m_selection = selection;
+ setWindowTitle("New");
+ }
+
+ /**
+ * This method is invoked when the new Service Test Scenario object model
+ * should be created.
+ */
+ public boolean performFinish() {
+ try {
+ // Remember the file.
+ //
+ final IFile modelFile = getModelFile();
+
+ // Do the work within an operation.
+ //
+ WorkspaceModifyOperation operation =
+ new WorkspaceModifyOperation() {
+ protected void execute(IProgressMonitor progressMonitor) {
+ try {
+
+ // Add the initial model object to the contents.
+ //
+ org.savara.scenario.model.Scenario scenario=
+ new org.savara.scenario.model.Scenario();
+
+ ByteArrayOutputStream os=new ByteArrayOutputStream();
+
+ ScenarioModelUtil.serialize(scenario, os);
+
+ os.close();
+
+ ByteArrayInputStream is=new ByteArrayInputStream(os.toByteArray());
+
+ modelFile.create(is, true, null);
+
+ is.close();
+ }
+ catch (Exception exception) {
+ //scenarioEditorPlugin.INSTANCE.log(exception);
+ org.savara.tools.scenario.osgi.Activator.logError(
+ exception.getMessage(), exception);
+ }
+ finally {
+ progressMonitor.done();
+ }
+ }
+ };
+
+ getContainer().run(false, false, operation);
+
+ // Select the new file resource in the current view.
+ //
+ IWorkbenchWindow workbenchWindow =
+ m_workbench.getActiveWorkbenchWindow();
+ IWorkbenchPage page = workbenchWindow.getActivePage();
+ final IWorkbenchPart activePart = page.getActivePart();
+ if (activePart instanceof ISetSelectionTarget) {
+ final ISelection targetSelection = new StructuredSelection(modelFile);
+ getShell().getDisplay().asyncExec
+ (new Runnable() {
+ public void run() {
+ ((ISetSelectionTarget)activePart).selectReveal(targetSelection);
+ }
+ });
+ }
+
+ // Open an editor on the new file.
+ //
+ try {
+ page.openEditor
+ (new FileEditorInput(modelFile),
+ m_workbench.getEditorRegistry().getDefaultEditor(modelFile.getFullPath().toString()).getId());
+ }
+ catch (PartInitException exception) {
+ MessageDialog.openError(workbenchWindow.getShell(),
+ "Open Editor", exception.getMessage());
+ //scenarioEditorPlugin.INSTANCE.getString("_UI_OpenEditorError_label"), exception.getMessage());
+ return false;
+ }
+
+ return true;
+ }
+ catch (Exception exception) {
+ //scenarioEditorPlugin.INSTANCE.log(exception);
+ org.savara.tools.scenario.osgi.Activator.logError(
+ exception.getMessage(), exception);
+
+ return false;
+ }
+ }
+
+ /**
+ * Get the file from the page.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public IFile getModelFile() {
+ return m_newFileCreationPage.getModelFile();
+ }
+
+ /**
+ * The framework calls this to create the contents of the wizard.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void addPages() {
+ // Create a page, set the title, and the initial model file name.
+ //
+ m_newFileCreationPage = new ScenarioModelWizardNewFileCreationPage("Whatever", m_selection);
+ //m_newFileCreationPage.setTitle(scenarioEditorPlugin.INSTANCE.getString("_UI_ScenarioModelWizard_label"));
+ //m_newFileCreationPage.setDescription(scenarioEditorPlugin.INSTANCE.getString("_UI_ScenarioModelWizard_description"));
+ //m_newFileCreationPage.setFileName(scenarioEditorPlugin.INSTANCE.getString("_UI_ScenarioEditorFilenameDefaultBase") + "." + scenarioEditorPlugin.INSTANCE.getString("_UI_ScenarioEditorFilenameExtension"));
+ m_newFileCreationPage.setTitle("Scenario");
+ m_newFileCreationPage.setDescription("Create a new Scenario");
+ m_newFileCreationPage.setFileName("My"+"."+
+ ScenarioDefinitions.SCENARIO_FILE_EXTENSION);
+ addPage(m_newFileCreationPage);
+
+ // Try and get the resource selection to determine a current directory for the file dialog.
+ //
+ if (m_selection != null && !m_selection.isEmpty()) {
+ // Get the resource...
+ //
+ Object selectedElement = m_selection.iterator().next();
+ if (selectedElement instanceof IResource) {
+ // Get the resource parent, if its a file.
+ //
+ IResource selectedResource = (IResource)selectedElement;
+ if (selectedResource.getType() == IResource.FILE) {
+ selectedResource = selectedResource.getParent();
+ }
+
+ // This gives us a directory...
+ //
+ if (selectedResource instanceof IFolder || selectedResource instanceof IProject) {
+ // Set this for the container.
+ //
+ m_newFileCreationPage.setContainerFullPath(selectedResource.getFullPath());
+
+ // Make up a unique new name here.
+ //
+ //String defaultModelBaseFilename = scenarioEditorPlugin.INSTANCE.getString("_UI_ScenarioEditorFilenameDefaultBase");
+ //String defaultModelFilenameExtension = scenarioEditorPlugin.INSTANCE.getString("_UI_ScenarioEditorFilenameExtension");
+ String defaultModelBaseFilename = "My";
+ String defaultModelFilenameExtension =
+ ScenarioDefinitions.SCENARIO_FILE_EXTENSION;
+ String modelFilename = defaultModelBaseFilename + "." + defaultModelFilenameExtension;
+ for (int i = 1; ((IContainer)selectedResource).findMember(modelFilename) != null; ++i) {
+ modelFilename = defaultModelBaseFilename + i + "." + defaultModelFilenameExtension;
+ }
+ m_newFileCreationPage.setFileName(modelFilename);
+ }
+ }
+ }
+ }
+
+ private IWorkbench m_workbench=null;
+ private IStructuredSelection m_selection=null;
+ private ScenarioModelWizardNewFileCreationPage m_newFileCreationPage=null;
+
+ /**
+ * This is the one page of the wizard.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public class ScenarioModelWizardNewFileCreationPage extends WizardNewFileCreationPage {
+ /**
+ * Remember the model file.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected IFile modelFile;
+
+ /**
+ * Pass in the selection.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public ScenarioModelWizardNewFileCreationPage(String pageId, IStructuredSelection selection) {
+ super(pageId, selection);
+ }
+
+ /**
+ * The framework calls this to see if the file is correct.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected boolean validatePage() {
+ if (super.validatePage()) {
+ // Make sure the file ends in ".scenario".
+ //
+ //String requiredExt = scenarioEditorPlugin.INSTANCE.getString("_UI_ScenarioEditorFilenameExtension");
+
+ if (new Path(getFileName()).getFileExtension().equals(ScenarioDefinitions.SCENARIO_FILE_EXTENSION)) {
+ return true;
+ } else {
+ setErrorMessage("The filename must end in \"."+ScenarioDefinitions.SCENARIO_FILE_EXTENSION+"\"");
+ return false;
+ }
+ /*
+ String requiredExt = "scenario";
+ String enteredExt = new Path(getFileName()).getFileExtension();
+ if (enteredExt == null || !enteredExt.equals(requiredExt)) {
+ //setErrorMessage(scenarioEditorPlugin.INSTANCE.getString("_WARN_FilenameExtension", new Object [] { requiredExt }));
+ setErrorMessage("The filename must end in \".scenario\"");
+ return false;
+ }
+ else {
+ return true;
+ }
+ */
+ }
+ else {
+ return false;
+ }
+ }
+
+ /**
+ * Store the dialog field settings upon completion.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public boolean performFinish() {
+ modelFile = getModelFile();
+ return true;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public IFile getModelFile() {
+ return
+ modelFile == null ?
+ ResourcesPlugin.getWorkspace().getRoot().getFile(getContainerFullPath().append(getFileName())) :
+ modelFile;
+ }
+ }
+
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/PasteAction.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/PasteAction.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/PasteAction.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,116 @@
+/*
+ * Copyright 2005 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Aug 10, 2005 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.editor;
+
+import org.eclipse.gef.EditPart;
+import org.eclipse.ui.IWorkbenchPart;
+import org.savara.scenario.model.*;
+import org.savara.tools.scenario.designer.commands.ConnectionCommand;
+import org.savara.tools.scenario.designer.commands.PasteComponentCommand;
+import org.savara.tools.scenario.designer.model.ModelSupport;
+import org.savara.tools.scenario.designer.tools.*;
+
+/**
+ * This class provides the paste action implementation.
+ *
+ */
+public class PasteAction extends org.eclipse.gef.ui.actions.SelectionAction {
+
+ /**
+ * Creates a <code>SelectionAction</code> and associates it with the given workbench part.
+ * @param part the workbench part
+ */
+ public PasteAction(IWorkbenchPart part) {
+ super(part);
+ }
+
+ /**
+ * Initializes this action.
+ */
+ protected void init() {
+ setId(org.eclipse.ui.actions.ActionFactory.PASTE.getId());
+ setText("Paste");
+ }
+
+ /**
+ * Calculates and returns the enabled state of this action.
+ * @return <code>true</code> if the action is enabled
+ */
+ protected boolean calculateEnabled() {
+ boolean ret=false;
+
+ if (getSelectedObjects() != null &&
+ getSelectedObjects().size() == 1 &&
+ getSelectedObjects().get(0) instanceof EditPart) {
+ EditPart ep=(EditPart)getSelectedObjects().get(0);
+
+ // Check if the copied model object is suitable to be
+ // pasted into the currently selected object
+ if (ModelSupport.isValidTarget(CopyAction.getCurrentTarget(),
+ ep.getModel())) {
+ ret = true;
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * Perform this action.
+ *
+ */
+ public void run() {
+
+ if (getSelectedObjects().size() == 1 &&
+ getSelectedObjects().get(0) instanceof EditPart) {
+ EditPart ep=(EditPart)getSelectedObjects().get(0);
+ Object source=CopyAction.getCurrentTarget();
+
+ if (source instanceof Link) {
+ Link link=new Link();
+
+ ConnectionCommand command=new ConnectionCommand();
+ command.setLink(link);
+
+ // TODO: GPB: Need to consider whether copy is necessary
+ command.setSource((MessageEvent)//EcoreUtil.copy(
+ ((Link)source).getSource()); //);
+ command.setTarget((MessageEvent)//EcoreUtil.copy(
+ ((Link)source).getTarget()); //);
+
+ command.setPasteParent(ep.getModel());
+
+ execute(command);
+
+ } else if (source != null) {
+ // Make a copy of the source
+ //source = EcoreUtil.copy((EObject)source);
+
+ // Build create component command
+ PasteComponentCommand command=new PasteComponentCommand();
+
+ command.setChild(source);
+ command.setParent(ep.getModel());
+
+ execute(command);
+ }
+ }
+ }
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/ResetSimulationAction.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/ResetSimulationAction.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/ResetSimulationAction.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2005-7 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Feb 23, 2007 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.editor;
+
+import org.eclipse.ui.IWorkbenchPart;
+
+import org.savara.tools.scenario.designer.simulate.*;
+
+/**
+ * This class provides the 'reset simulation' action implementation.
+ *
+ */
+public class ResetSimulationAction extends org.eclipse.gef.ui.actions.SelectionAction {
+
+ public static final String ID = "org.pi4soa.service.test.designer.editor.ResetSimulationID";
+
+ /**
+ * Creates a <code>CreateMessageLinksAction</code> and
+ * associates it with the given workbench part.
+ * @param part the workbench part
+ */
+ public ResetSimulationAction(IWorkbenchPart part) {
+ super(part);
+ }
+
+ /**
+ * Initializes this action.
+ */
+ protected void init() {
+ setId(ID);
+ setText("Reset Simulation");
+
+ setImageDescriptor(org.savara.tools.scenario.designer.DesignerImages.getImageDescriptor("ResetSimulation.png"));
+ }
+
+ /**
+ * Calculates and returns the enabled state of this action.
+ * @return <code>true</code> if the action is enabled
+ */
+ protected boolean calculateEnabled() {
+ boolean ret=false;
+
+ if (getWorkbenchPart() instanceof ScenarioDesigner) {
+ ScenarioSimulation view=((ScenarioDesigner)getWorkbenchPart()).getScenarioSimulation();
+
+ if (view != null) {
+ ret = view.isSimulationRunning();
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * Perform this action.
+ *
+ */
+ public void run() {
+ ((ScenarioDesigner)getWorkbenchPart()).getScenarioSimulation().resetSimulation();
+ ((ScenarioDesigner)getWorkbenchPart()).updateEditPartActions();
+ }
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/ScenarioDesigner.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/ScenarioDesigner.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/ScenarioDesigner.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,1178 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Feb 14, 2007 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.editor;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+
+import org.eclipse.ui.part.MultiPageEditorPart;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubProgressMonitor;
+//import org.eclipse.emf.common.util.URI;
+//import org.eclipse.emf.ecore.EValidator;
+import org.eclipse.gef.KeyHandler;
+import org.eclipse.gef.KeyStroke;
+import org.eclipse.gef.RootEditPart;
+import org.eclipse.gef.GEFPlugin;
+import org.eclipse.gef.commands.CommandStack;
+import org.eclipse.gef.commands.CommandStackListener;
+import org.eclipse.gef.editparts.ScalableFreeformRootEditPart;
+import org.eclipse.gef.editparts.ScalableRootEditPart;
+import org.eclipse.gef.editparts.ZoomManager;
+import org.eclipse.gef.palette.PaletteRoot;
+import org.eclipse.gef.ui.actions.ActionRegistry;
+import org.eclipse.gef.ui.actions.DeleteAction;
+import org.eclipse.gef.ui.actions.EditorPartAction;
+import org.eclipse.gef.ui.actions.GEFActionConstants;
+import org.eclipse.gef.ui.actions.RedoAction;
+import org.eclipse.gef.ui.actions.SelectionAction;
+import org.eclipse.gef.ui.actions.StackAction;
+import org.eclipse.gef.ui.actions.UndoAction;
+import org.eclipse.gef.ui.actions.UpdateAction;
+import org.eclipse.gef.ui.parts.SelectionSynchronizer;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.ISelectionListener;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.dialogs.SaveAsDialog;
+import org.eclipse.ui.ide.IGotoMarker;
+import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
+import org.eclipse.ui.views.properties.IPropertySheetPage;
+import org.eclipse.ui.views.properties.PropertySheetPage;
+import org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor;
+//import org.pi4soa.designer.util.ModelSupport;
+import org.eclipse.gef.ui.actions.ZoomInAction;
+import org.eclipse.gef.ui.actions.ZoomOutAction;
+import org.eclipse.gef.ui.actions.PrintAction;
+//import org.savara.tools.scenario.designer.editor.*;
+import org.savara.scenario.util.ScenarioModelUtil;
+import org.savara.tools.scenario.designer.editor.properties.DesignerTabbedPropertySheetPage;
+//import org.savara.tools.scenario.ScenarioManager;
+import org.savara.tools.scenario.designer.DesignerDefinitions;
+
+import org.eclipse.draw2d.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.ui.actions.*;
+import org.eclipse.ui.*;
+import org.eclipse.ui.part.*;
+import org.eclipse.jface.action.*;
+import org.eclipse.gef.*;
+import org.eclipse.ui.views.contentoutline.*;
+
+/**
+ * This class provides the implementation for the choreography
+ * description editor within the pi4soa designer tool.
+ */
+public class ScenarioDesigner
+ extends MultiPageEditorPart implements IAdaptable,
+ IGotoMarker, Editor,
+ ITabbedPropertySheetPageContributor {
+
+ public ScenarioDesigner() {
+ }
+
+ public String getContributorId() {
+ return getSite().getId();
+ }
+
+ /**
+ * This method creates the pages for the
+ * @see org.eclipse.ui.part.MultiPageEditorPart#createPages()
+ */
+ protected void createPages() {
+ try {
+ m_scenarioEditorPageID = addPage(new ScenarioEditorPage(this), getEditorInput());
+ setPageText(m_scenarioEditorPageID,
+ getScenarioEditorPage().getPageName());
+
+ m_simulationLogPageID = addPage(new SimulationLogPage(this), getEditorInput());
+ setPageText(m_simulationLogPageID,
+ getSimulationLogPage().getPageName());
+
+ // add command stacks
+ getMultiPageCommandStackListener().addCommandStack(
+ getScenarioEditorPage().getCommandStack2());
+
+ // activate delegating command stack
+ getDelegatingCommandStack().setCurrentCommandStack(
+ getScenarioEditorPage().getCommandStack2());
+
+ // set active page
+ setActivePage(m_scenarioEditorPageID);
+
+ } catch (PartInitException e) {
+ ErrorDialog.openError(
+ getSite().getShell(),
+ "Open Error",
+ "An error occured during opening the editor.",
+ e.getStatus());
+ }
+ }
+
+ /**
+ * Method is notified when the active page is changed.
+ *
+ */
+ protected void pageChange(int index) {
+ super.pageChange(index);
+
+ updateAfterPageChange(index);
+ }
+
+ /**
+ * This method performs the updates following a page change.
+ *
+ */
+ protected void updateAfterPageChange(int newPage) {
+
+ if (getCurrentPage() != null) {
+ // Update zoom actions
+ getDelegatingZoomManager().setCurrentZoomManager(
+ getZoomManager(getCurrentPage().getViewer()));
+
+ // Update delegating command stack
+ getDelegatingCommandStack().setCurrentCommandStack(
+ getCurrentPage().getCommandStack2());
+ } else {
+ getDelegatingZoomManager().setCurrentZoomManager(null);
+ }
+ }
+
+ /**
+ * This method returns the Scenario.
+ *
+ * @return The scenario
+ */
+ public org.savara.scenario.model.Scenario getScenario() {
+ return(m_scenario);
+ }
+
+ /**
+ * This method returns the scenario view used for simulating
+ * the scenario.
+ *
+ * @return The scenario view
+ */
+ public org.savara.tools.scenario.designer.simulate.ScenarioSimulation getScenarioSimulation() {
+ return((org.savara.tools.scenario.designer.simulate.ScenarioSimulation)getScenarioEditorPage());
+ }
+
+ /**
+ * This method return the primary description being
+ * presented by the editor.
+ *
+ * @return The description
+ */
+ public Object getDescription() {
+ return(getScenario());
+ }
+
+ /**
+ * This method returns the simulation log page.
+ *
+ * @return The simulation log page
+ */
+ protected SimulationLogPage getSimulationLogPage() {
+ if (m_simulationLogPageID == -1) {
+ return(null);
+ }
+ return((SimulationLogPage)
+ getEditor(m_simulationLogPageID));
+ }
+
+ /**
+ * This method returns the scenario editor page.
+ *
+ * @return The scenario editor page
+ */
+ protected ScenarioEditorPage getScenarioEditorPage() {
+ if (m_scenarioEditorPageID == -1) {
+ return(null);
+ }
+ return((ScenarioEditorPage)
+ getEditor(m_scenarioEditorPageID));
+ }
+
+ /**
+ * Returns the current active page.
+ * @return the current active page or <code>null</code>
+ */
+ private ScenarioEditorPage getCurrentPage() {
+ if (getActivePage() == -1) {
+ return null;
+ }
+
+ Object obj=getEditor(getActivePage());
+
+ if (obj instanceof ScenarioEditorPage) {
+ return((ScenarioEditorPage)obj);
+ }
+
+ return(null);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.part.MultiPageEditorPart#init(org.eclipse.ui.IEditorSite, org.eclipse.ui.IEditorInput)
+ */
+ public void init(IEditorSite site, IEditorInput input)
+ throws PartInitException {
+
+
+ // read choreography description from input
+ try {
+ // we expect IFileEditorInput here,
+ // ClassCassException is catched to force PartInitException
+ if (input instanceof IFileEditorInput) {
+ m_file = ((IFileEditorInput) input).getFile();
+ }
+
+ if (input instanceof IStorageEditorInput) {
+ m_scenario = create(input);
+ }
+
+ // validate s
+ if (null == getScenario()) {
+ throw new PartInitException("The specified input is not a scenario.");
+ }
+ } catch (CoreException e) {
+ throw new PartInitException(e.getStatus());
+ } catch (Exception e) {
+ throw new PartInitException(
+ "The specified input is not a valid scenario.",
+ e);
+ }
+
+ setPartName(input.getName());
+
+ // choreography is ok
+ super.init(site, input);
+
+ // add delegating CommandStackListener
+ getDelegatingCommandStack().addCommandStackListener(
+ getDelegatingCommandStackListener());
+
+ // add selection change listener
+ getSite().getWorkbenchWindow().getSelectionService().
+ addSelectionListener(getSelectionListener());
+
+ // initialize actions
+ createActions();
+
+ /* TODO: GPB: do we need a 'savara perspective'?
+ org.eclipse.swt.widgets.Display.getCurrent().asyncExec(new Runnable() {
+ public void run() {
+
+ try {
+ getSite().getWorkbenchWindow().getWorkbench().
+ showPerspective(SOAPerspective.ID,
+ getSite().getWorkbenchWindow());
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+ });
+ */
+ }
+
+ public IFile getFile() {
+ return(m_file);
+ }
+
+ /**
+ * Creates actions and registers them to the ActionRegistry.
+ */
+ protected void createActions() {
+ addStackAction(new UndoAction(this));
+ addStackAction(new RedoAction(this));
+
+ addEditPartAction(new DeleteAction((IWorkbenchPart)this));
+ addEditPartAction(new org.savara.tools.scenario.designer.editor.CopyAction((IWorkbenchPart) this));
+ addEditPartAction(new org.savara.tools.scenario.designer.editor.PasteAction((IWorkbenchPart) this));
+
+ m_printAction = new PrintAction(this);
+
+ addAction(m_printAction);
+
+ IAction zoomIn = new ZoomInAction(getDelegatingZoomManager());
+ IAction zoomOut = new ZoomOutAction(getDelegatingZoomManager());
+ addAction(zoomIn);
+ addAction(zoomOut);
+ getSite().getKeyBindingService().registerAction(zoomIn);
+ getSite().getKeyBindingService().registerAction(zoomOut);
+
+ // Add edit annotations action
+ addEditPartAction(new CreateLinksAction((IWorkbenchPart)this));
+
+ if (getEditorInput() instanceof IFileEditorInput) {
+ addEditPartAction(new SimulateScenarioAction((IWorkbenchPart)this));
+ addEditPartAction(new ResetSimulationAction((IWorkbenchPart)this));
+ }
+
+ //addEditPartAction(new ShowIdentityDetailsAction((IWorkbenchPart)this));
+
+ addEditPartAction(new GenerateImageAction((IWorkbenchPart)this));
+
+ addEditPartAction(new SimulationEntityFocusAction((IWorkbenchPart)this));
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.part.EditorPart#setInput(org.eclipse.ui.IEditorInput)
+ */
+ public void setInput(IEditorInput input)
+ {
+ if (getEditorInput() instanceof IFileEditorInput)
+ {
+ IFile file = ((IFileEditorInput) getEditorInput()).getFile();
+
+ /* TODO: GPB: resource tracker
+ file.getWorkspace().removeResourceChangeListener(
+ getResourceTracker());
+ */
+ }
+
+ super.setInput(input);
+
+ if (getEditorInput() instanceof IFileEditorInput) {
+ m_file = ((IFileEditorInput) getEditorInput()).getFile();
+ /* TODO: GPB: resource tracker
+ m_file.getWorkspace().addResourceChangeListener(getResourceTracker());
+ */
+ }
+
+ if (getEditorInput() instanceof IStorageEditorInput) {
+ setPartName(getEditorInput().getName());
+
+ // If editor is not saving, then we need to reset the
+ // choreography description
+ if (!isEditorSaving()) {
+ try {
+ m_scenario = create(getEditorInput());
+
+ AbstractEditorPage page=getScenarioEditorPage();
+
+ if (page != null) {
+ page.refresh(input);
+ }
+
+ } catch(Exception e) {
+
+ // Need to close down after reporting failure
+ org.savara.tools.scenario.osgi.Activator.
+ logError("Failed to re-load Scenario " +
+ "after external update", e);
+
+ closeEditor(false);
+ }
+ }
+ }
+ }
+
+ protected org.savara.scenario.model.Scenario create(IEditorInput input)
+ throws Exception {
+ org.savara.scenario.model.Scenario ret=null;
+
+ if (input instanceof IFileEditorInput) {
+ ret = org.savara.scenario.util.ScenarioModelUtil.deserialize(
+ ((IFileEditorInput)input).getFile().getContents());
+ } else if (input instanceof IStorageEditorInput) {
+ ret = org.savara.scenario.util.ScenarioModelUtil.deserialize(
+ ((IStorageEditorInput)input).
+ getStorage().getContents());
+ }
+
+ return(ret);
+ }
+
+ /**
+ * Returns the resource tracker instance
+ * @return
+ */
+ /*
+ private ResourceTracker getResourceTracker() {
+ if (m_resourceTracker == null) {
+ m_resourceTracker = new ResourceTracker(this);
+ }
+
+ return(m_resourceTracker);
+ }
+ */
+
+ /**
+ * Adds an action to this editor's <code>ActionRegistry</code>.
+ * (This is a helper method.)
+ *
+ * @param action the action to add.
+ */
+ protected void addAction(IAction action) {
+ getActionRegistry().registerAction(action);
+ }
+
+ /**
+ * Adds an editor action to this editor.
+ *
+ * <p><Editor actions are actions that depend
+ * and work on the editor.
+ *
+ * @param action the editor action
+ */
+ protected void addEditorAction(EditorPartAction action) {
+ getActionRegistry().registerAction(action);
+ m_editorActionIDs.add(action.getId());
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.part.WorkbenchPart#firePropertyChange(int)
+ */
+ protected void firePropertyChange(int propertyId) {
+ super.firePropertyChange(propertyId);
+ updateActions(m_editorActionIDs);
+ }
+
+ /**
+ * Adds an <code>EditPart</code> action to this editor.
+ *
+ * <p><code>EditPart</code> actions are actions that depend
+ * and work on the selected <code>EditPart</code>s.
+ *
+ * @param action the <code>EditPart</code> action
+ */
+ protected void addEditPartAction(SelectionAction action) {
+ getActionRegistry().registerAction(action);
+ m_editPartActionIDs.add(action.getId());
+ }
+
+ /**
+ * Adds an <code>CommandStack</code> action to this editor.
+ *
+ * <p><code>CommandStack</code> actions are actions that depend
+ * and work on the <code>CommandStack</code>.
+ *
+ * @param action the <code>CommandStack</code> action
+ */
+ protected void addStackAction(StackAction action) {
+ getActionRegistry().registerAction(action);
+ m_stackActionIDs.add(action.getId());
+ }
+
+ /**
+ * This method indicates that the edited content is dirty.
+ *
+ * @param dirty The dirty status
+ */
+ public void setDirty(boolean dirty) {
+ if (m_isDirty != dirty) {
+ m_isDirty = dirty;
+ firePropertyChange(IEditorPart.PROP_DIRTY);
+ }
+ }
+
+ /**
+ * Returns the test scenario object from the
+ * specified file.
+ *
+ * @param file The file
+ * @return The test scenario object from the specified file
+ */
+ /*
+ private org.pi4soa.scenario.Scenario create(IFile file) throws CoreException {
+ org.pi4soa.scenario.Scenario ret=null;
+
+ if (file.exists()) {
+ try {
+ ret = org.pi4soa.scenario.ScenarioManager.load(file.getLocation().toString());
+ } catch (Exception e) {
+ throw new CoreException(
+ new Status(
+ IStatus.ERROR,
+ DesignerDefinitions.DESIGNER_PLUGIN_ID,
+ 0,
+ "Error loading the test scenario.",
+ e));
+ }
+
+ if (null == ret) {
+ throw new CoreException(
+ new Status(
+ IStatus.ERROR,
+ DesignerDefinitions.DESIGNER_PLUGIN_ID,
+ 0,
+ "Error loading the test scenario.",
+ null));
+ }
+ }
+
+ return(ret);
+ }
+ */
+
+ /**
+ * This method returns the dirty status of the edited content.
+ *
+ * @return Whether the content is dirty.
+ * @see org.eclipse.ui.part.MultiPageEditorPart#isDirty()
+ */
+ public boolean isDirty() {
+ return(m_isDirty);
+ }
+
+ /**
+ * This method determines whether the contents can be saved.
+ *
+ * @return Whether the contents can be saved
+ * @see org.eclipse.ui.part.EditorPart#isSaveAsAllowed()
+ */
+ public boolean isSaveAsAllowed() {
+ return(true);
+ }
+
+ /**
+ * This method saves the content.
+ *
+ * @param monitor Progress monitor
+ * @see org.eclipse.ui.part.EditorPart#doSave(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public void doSave(IProgressMonitor monitor) {
+
+ if (getEditorInput() instanceof IFileEditorInput) {
+ try {
+ IFile file = ((IFileEditorInput) getEditorInput()).getFile();
+ save(file, monitor);
+ getMultiPageCommandStackListener().markSaveLocations();
+ } catch (CoreException e) {
+ ErrorDialog.openError(
+ getSite().getShell(),
+ "Error During Save",
+ "The Choreography Description could not be saved.",
+ e.getStatus());
+ }
+ } else {
+ // Do save as, as edited version is not a local file
+ doSaveAs();
+ }
+ }
+
+ /**
+ * This method enables the user to select where the choreography
+ * description should be saved to.
+ *
+ * @see org.eclipse.ui.ISaveablePart#doSaveAs()
+ */
+ public void doSaveAs() {
+ SaveAsDialog dialog = new SaveAsDialog(getSite().getShell());
+
+ if (getEditorInput() instanceof IFileEditorInput) {
+ dialog.setOriginalFile(((IFileEditorInput) getEditorInput()).getFile());
+ }
+
+ dialog.open();
+ IPath path = dialog.getResult();
+
+ if (path == null)
+ return;
+
+ ProgressMonitorDialog progressMonitorDialog =
+ new ProgressMonitorDialog(getSite().getShell());
+ IProgressMonitor progressMonitor = null;
+ //progressMonitorDialog.getProgressMonitor();
+
+ try
+ {
+ save(ResourcesPlugin.getWorkspace().getRoot().getFile(path),
+ progressMonitor);
+ getMultiPageCommandStackListener().markSaveLocations();
+ }
+ catch (CoreException e)
+ {
+ ErrorDialog.openError(
+ getSite().getShell(),
+ "Error During Save",
+ "The Scenario could not be saved.",
+ e.getStatus());
+ }
+ }
+
+ /**
+ * Saves the choreography description under the specified path.
+ *
+ * @param file The file to be saved
+ * @param path workspace relative path
+ * @param progressMonitor
+ */
+ private synchronized void save(IFile file, IProgressMonitor progressMonitor)
+ throws CoreException {
+
+ // NOTE: Made method synchronized due to 'editor saving' flag, as
+ // another thread may cause this to be unset while a second invocation
+ // of the method is just starting, causing issues when it evaluates
+ // a resource change event in the ResourceTracker
+ //URI uri=m_scenario.eResource().getURI();
+
+ if (null == progressMonitor) {
+ progressMonitor = new NullProgressMonitor();
+ }
+
+ progressMonitor.beginTask("Saving " + file, 2);
+
+ m_editorSaving = true;
+
+ try {
+ ByteArrayOutputStream baos=new ByteArrayOutputStream();
+
+ ScenarioModelUtil.serialize(m_scenario, baos);
+
+ //ScenarioManager.save(m_scenario, baos, file.getCharset(true));
+ //org.pi4soa.scenario.ScenarioManager.save(m_Scenario,
+ // baos, file.getCharset(true));
+
+ baos.close();
+
+ ByteArrayInputStream bais=
+ new ByteArrayInputStream(baos.toByteArray());
+
+ if (file.exists() == false) {
+ file.create(bais, true, progressMonitor);
+ } else {
+ file.setContents(bais, true, true, progressMonitor);
+ }
+
+ bais.close();
+
+ progressMonitor.worked(1);
+ file.refreshLocal(
+ IResource.DEPTH_ZERO,
+ new SubProgressMonitor(progressMonitor, 1));
+ progressMonitor.done();
+
+ AbstractEditorPage page=
+ getCurrentPage();
+
+ if (page != null) {
+
+ // Get current focus
+ //Object focusComponent=page.getFocusComponent();
+
+ page.refresh();
+
+ //if (focusComponent != null) {
+ // page.focus(focusComponent);
+ //}
+ }
+
+ // Need to re-apply the URI, as this seems
+ // to get cleared when the scenario is saved
+ //m_scenario.eResource().setURI(uri);
+
+ } catch (java.io.FileNotFoundException e) {
+ IStatus status =
+ new Status(
+ IStatus.ERROR,
+ DesignerDefinitions.DESIGNER_PLUGIN_ID,
+ 0,
+ "Error writing file.",
+ e);
+ throw new CoreException(status);
+ } catch (java.io.IOException e) {
+ IStatus status =
+ new Status(
+ IStatus.ERROR,
+ DesignerDefinitions.DESIGNER_PLUGIN_ID,
+ 0,
+ "Error writing file.",
+ e);
+ throw new CoreException(status);
+ } finally {
+ m_editorSaving = false;
+ }
+ }
+
+ /**
+ * This method determines if the editor is currently in
+ * the process of saving its modified content.
+ *
+ * @return Whether the editor is currently saving
+ */
+ public boolean isEditorSaving() {
+ return(m_editorSaving);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.part.MultiPageEditorPart#dispose()
+ */
+ public void dispose() {
+
+ if (getEditorInput() instanceof IFileEditorInput) {
+ IFile file = ((IFileEditorInput) getEditorInput()).getFile();
+
+ /* TODO: GPB: resource tracker
+ file.getWorkspace().removeResourceChangeListener(
+ getResourceTracker());
+ */
+ }
+
+ // dispose multi page command stack listener
+ getMultiPageCommandStackListener().dispose();
+
+ // remove delegating CommandStackListener
+ getDelegatingCommandStack().removeCommandStackListener(
+ getDelegatingCommandStackListener());
+
+ // remove selection listener
+ getSite().getWorkbenchWindow().getSelectionService().
+ removeSelectionListener(getSelectionListener());
+
+ // disposy the ActionRegistry (will dispose all actions)
+ getActionRegistry().dispose();
+
+ if (m_outlinePage != null) {
+ m_outlinePage.dispose();
+ }
+
+ // important: always call super implementation of dispose
+ super.dispose();
+ }
+
+ /**
+ * Closes this editor.
+ * @param save
+ */
+ public void closeEditor(final boolean save) {
+ getSite().getShell().getDisplay().syncExec(new Runnable() {
+ public void run()
+ {
+ getSite().getPage().closeEditor(
+ ScenarioDesigner.this, save);
+ }
+ });
+ }
+
+ /**
+ * This method returns the multipage command stack listener.
+ *
+ * @return The command stack listener
+ */
+ protected MultiPageCommandStackListener getMultiPageCommandStackListener() {
+ if (null == m_multiPageCommandStackListener) {
+ m_multiPageCommandStackListener = new MultiPageCommandStackListener(this);
+ }
+ return(m_multiPageCommandStackListener);
+ }
+
+ /**
+ * Returns the <code>CommandStack</code> for this editor.
+ * @return the <code>CommandStack</code>
+ */
+ protected DelegatingCommandStack getDelegatingCommandStack() {
+ if (null == m_delegatingCommandStack) {
+ m_delegatingCommandStack = new DelegatingCommandStack();
+ if (null != getCurrentPage()) {
+ m_delegatingCommandStack.setCurrentCommandStack(
+ getCurrentPage().getCommandStack2());
+ }
+ }
+
+ return(m_delegatingCommandStack);
+ }
+
+ /**
+ * Returns the <code>CommandStackListener</code> for
+ * the <code>DelegatingCommandStack</code>.
+ * @return the <code>CommandStackListener</code>
+ */
+ protected CommandStackListener getDelegatingCommandStackListener() {
+ return(m_delegatingCommandStackListener);
+ }
+
+ /**
+ * Returns the <code>DelegatingZoomManager</code> for this editor.
+ * @return the <code>DelegatingZoomManager</code>
+ */
+ protected DelegatingZoomManager getDelegatingZoomManager() {
+ if (null == m_delegatingZoomManager) {
+ m_delegatingZoomManager = new DelegatingZoomManager();
+ if (null != getCurrentPage()
+ && null != getCurrentPage().getViewer()) {
+ m_delegatingZoomManager.setCurrentZoomManager(
+ getZoomManager(getCurrentPage().getViewer()));
+ }
+ }
+
+ return(m_delegatingZoomManager);
+ }
+
+ /**
+ * Returns the undoable <code>PropertySheetPage</code> for
+ * this editor.
+ *
+ * @return the undoable <code>PropertySheetPage</code>
+ */
+ protected IPropertySheetPage getPropertySheetPage() {
+ if (null == m_undoablePropertySheetPage) {
+ m_undoablePropertySheetPage =
+ new DesignerTabbedPropertySheetPage(this,
+ getDelegatingCommandStack());
+
+ //m_undoablePropertySheetPage = new PropertySheetPage();
+ //m_undoablePropertySheetPage.setRootEntry(
+ // GEFPlugin.createUndoablePropertySheetEntry(
+ // getDelegatingCommandStack()));
+// Change to make to get rid of the deprecation warning, however,
+// this makes the designer dependent upon GEF3.1
+// new org.eclipse.gef.ui.properties.UndoablePropertySheetEntry(
+// getDelegatingCommandStack()));
+ }
+
+ return(m_undoablePropertySheetPage);
+ }
+
+ /**
+ * Returns the zoom manager of the specified viewer.
+ * @param viewer the viewer to get the zoom manager from
+ * @return the zoom manager
+ */
+ private ZoomManager getZoomManager(org.eclipse.gef.EditPartViewer viewer) {
+ // get zoom manager from root edit part
+ RootEditPart rootEditPart = viewer.getRootEditPart();
+ ZoomManager zoomManager = null;
+ if (rootEditPart instanceof ScalableFreeformRootEditPart) {
+ zoomManager =
+ ((ScalableFreeformRootEditPart) rootEditPart).getZoomManager();
+ } else if (rootEditPart instanceof ScalableRootEditPart) {
+ zoomManager =
+ ((ScalableRootEditPart) rootEditPart).getZoomManager();
+ }
+ return zoomManager;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.part.EditorPart#gotoMarker(org.eclipse.core.resources.IMarker)
+ */
+ public void gotoMarker(IMarker marker) {
+
+ try {
+ /* TODO: GPB: handle navigation to object
+ *
+ if (marker.getType().equals(EValidator.MARKER)) {
+ String uriAttribute = marker.getAttribute(EValidator.URI_ATTRIBUTE, null);
+ if (uriAttribute != null) {
+ URI uri = URI.createURI(uriAttribute);
+
+ org.eclipse.emf.ecore.EObject scenarioObject=
+ (org.eclipse.emf.ecore.EObject)
+ m_scenario.eResource().getEObject(uri.fragment());
+
+ if (scenarioObject != null) {
+ getCurrentPage().focus(scenarioObject);
+ }
+ }
+ }
+ */
+ } catch (Exception exception) {
+ exception.printStackTrace();
+ }
+ }
+
+ /**
+ * Sets the currently active page.
+ *
+ * @param pageIndex the index of the page to be activated; the index must be valid
+ */
+ protected void setActivePage(int pageIndex) {
+ super.setActivePage(pageIndex);
+
+ updateAfterPageChange(pageIndex);
+ }
+
+ /**
+ * Returns the default <code>PaletteRoot</code> for this editor and all
+ * its pages.
+ * @return the default <code>PaletteRoot</code>
+ */
+ public PaletteRoot getPaletteRoot() {
+ if (null == m_paletteRoot) {
+ // create root
+ m_paletteRoot = new ScenarioPaletteRoot();
+ }
+ return(m_paletteRoot);
+ }
+
+ /**
+ * Returns the selection syncronizer object.
+ * The synchronizer can be used to sync the selection of 2 or more
+ * EditPartViewers.
+ * @return the syncrhonizer
+ */
+ public SelectionSynchronizer getSelectionSynchronizer() {
+ if (m_synchronizer == null) {
+ m_synchronizer = new SelectionSynchronizer();
+ }
+ return(m_synchronizer);
+ }
+
+ /**
+ * Updates the specified actions.
+ *
+ * @param actionIds the list of ids of actions to update
+ */
+ private void updateActions(java.util.List actionIds) {
+ for (java.util.Iterator ids = actionIds.iterator();
+ ids.hasNext();) {
+ IAction action = getActionRegistry().getAction(ids.next());
+ if (null != action && action instanceof UpdateAction) {
+ ((UpdateAction) action).update();
+ }
+ }
+ }
+
+ protected void updateEditPartActions() {
+ updateActions(m_editPartActionIDs);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
+ */
+ public Object getAdapter(Class type) {
+
+ if (type == IPropertySheetPage.class) {
+ return getPropertySheetPage();
+ } else if (type == CommandStack.class) {
+ return getDelegatingCommandStack();
+ } else if (type == ActionRegistry.class) {
+ return getActionRegistry();
+ } else if (type == IContentOutlinePage.class) {
+ return getOutlinePage();
+ } else if (type == ZoomManager.class) {
+ return getDelegatingZoomManager();
+ } else {
+ Object ret=null;
+
+ if (getCurrentPage() != null) {
+ ret = getCurrentPage().getAdapter(type);
+ }
+
+ if (ret != null) {
+ return(ret);
+ }
+ }
+
+ return super.getAdapter(type);
+ }
+
+ /**
+ * Returns the selection listener.
+ *
+ * @return the <code>ISelectionListener</code>
+ */
+ protected ISelectionListener getSelectionListener() {
+ return(m_selectionListener);
+ }
+
+ /**
+ * Returns the action registry of this editor.
+ * @return the action registry
+ */
+ public ActionRegistry getActionRegistry() {
+ if (m_actionRegistry == null) {
+ m_actionRegistry = new ActionRegistry();
+ }
+
+ return(m_actionRegistry);
+ }
+
+ public KeyHandler getSharedKeyHandler() {
+ if (m_sharedKeyHandler == null) {
+ m_sharedKeyHandler = new KeyHandler();
+ m_sharedKeyHandler.put(
+ KeyStroke.getPressed(SWT.DEL, 127, 0),
+ getActionRegistry().getAction(org.eclipse.ui.actions.ActionFactory.DELETE.getId()));
+ m_sharedKeyHandler.put(
+ KeyStroke.getPressed(SWT.F2, 0),
+ getActionRegistry().getAction(GEFActionConstants.DIRECT_EDIT));
+ }
+ return(m_sharedKeyHandler);
+ }
+
+ protected FigureCanvas getEditor(){
+ return (FigureCanvas)getScenarioEditorPage().getViewer().getControl();
+ }
+
+ protected OutlinePage getOutlinePage() {
+ if (m_outlinePage == null) {
+ m_outlinePage = new OutlinePage();
+ }
+ return(m_outlinePage);
+ }
+
+ private boolean m_isDirty=false;
+ private boolean m_editorSaving=false;
+ private MultiPageCommandStackListener m_multiPageCommandStackListener=null;
+ private PaletteRoot m_paletteRoot=null;
+ private KeyHandler m_sharedKeyHandler=null;
+ private SelectionSynchronizer m_synchronizer=null;
+ private int m_scenarioEditorPageID=-1;
+ private int m_simulationLogPageID=-1;
+ private DelegatingCommandStack m_delegatingCommandStack=null;
+ private DelegatingZoomManager m_delegatingZoomManager=null;
+ private org.savara.scenario.model.Scenario m_scenario=null;
+ private org.eclipse.core.resources.IFile m_file=null;
+ private java.util.List m_stackActionIDs = new java.util.ArrayList();
+ private java.util.List m_editPartActionIDs = new java.util.ArrayList();
+ private java.util.List m_editorActionIDs = new java.util.ArrayList();
+ private ActionRegistry m_actionRegistry=null;
+ private IPropertySheetPage m_undoablePropertySheetPage=null;
+ //private ResourceTracker m_resourceTracker=null;
+ private PrintAction m_printAction=null;
+
+ private OutlinePage m_outlinePage=null;
+
+ /**
+ * The <code>CommandStackListener</code> that listens for
+ * changes of the <code>DelegatingCommandStack</code>.
+ */
+ private CommandStackListener m_delegatingCommandStackListener =
+ new CommandStackListener() {
+ public void commandStackChanged(java.util.EventObject event) {
+ updateActions(m_stackActionIDs);
+ }
+ };
+
+ private ISelectionListener m_selectionListener = new ISelectionListener() {
+ public void selectionChanged(IWorkbenchPart part, ISelection selection) {
+ updateActions(m_editPartActionIDs);
+ }
+ };
+
+ class OutlinePage extends ContentOutlinePage
+ implements IAdaptable {
+
+ public OutlinePage(){
+ super();
+ }
+
+ public void init(IPageSite pageSite) {
+ super.init(pageSite);
+ ActionRegistry registry = getActionRegistry();
+ IActionBars bars = pageSite.getActionBars();
+ String id = ActionFactory.UNDO.getId();
+ bars.setGlobalActionHandler(id, registry.getAction(id));
+ id = ActionFactory.REDO.getId();
+ bars.setGlobalActionHandler(id, registry.getAction(id));
+ id = ActionFactory.DELETE.getId();
+ bars.setGlobalActionHandler(id, registry.getAction(id));
+ bars.updateActionBars();
+ }
+
+ protected void configureOutlineViewer(){
+ if (thumbnail == null)
+ initializeOverview();
+ pageBook.showPage(overview);
+ thumbnail.setVisible(true);
+ }
+
+ public void createControl(Composite parent){
+ pageBook = new PageBook(parent, SWT.NONE);
+ overview = new Canvas(pageBook, SWT.NONE);
+ pageBook.showPage(outline);
+ configureOutlineViewer();
+ }
+
+ public void dispose(){
+ if (thumbnail != null) {
+ thumbnail.deactivate();
+ thumbnail = null;
+ }
+ //unhookOverview();
+
+ super.dispose();
+ }
+
+ public Object getAdapter(Class type) {
+ if (type == ZoomManager.class)
+ return getScenarioEditorPage().getViewer().getProperty(ZoomManager.class.toString());
+ return null;
+ }
+
+ public Control getControl() {
+ return pageBook;
+ }
+
+ protected void initializeOverview() {
+ LightweightSystem lws = new LightweightSystem(overview);
+ RootEditPart rep = getScenarioEditorPage().getViewer().getRootEditPart();
+ if (rep instanceof ScalableFreeformRootEditPart) {
+ ScalableFreeformRootEditPart root = (ScalableFreeformRootEditPart)rep;
+ thumbnail = new org.eclipse.draw2d.parts.ScrollableThumbnail((Viewport)root.getFigure());
+ thumbnail.setBorder(new MarginBorder(3));
+ thumbnail.setSource(root.getLayer(LayerConstants.PRINTABLE_LAYERS));
+ lws.setContents(thumbnail);
+ /*
+ disposeListener = new DisposeListener() {
+ public void widgetDisposed(DisposeEvent e) {
+ if (thumbnail != null) {
+ thumbnail.deactivate();
+ thumbnail = null;
+ }
+ }
+ };
+ getEditor().addDisposeListener(disposeListener);
+ */
+ }
+ }
+
+ public void setFocus() {
+ }
+
+ public void setContents(Object contents) {
+ getScenarioEditorPage().getViewer().setContents(contents);
+ }
+
+ /*
+ protected void unhookOverview(){
+ if (disposeListener != null && getEditor() != null && !getEditor().isDisposed())
+ getEditor().removeDisposeListener(disposeListener);
+ }
+ */
+
+ private PageBook pageBook;
+ private Control outline;
+ private Canvas overview;
+ private org.eclipse.draw2d.parts.Thumbnail thumbnail;
+ //private DisposeListener disposeListener;
+ }
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/ScenarioEditorPage.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/ScenarioEditorPage.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/ScenarioEditorPage.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,410 @@
+/*
+ * Copyright 2005 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Jul 5, 2005 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.editor;
+
+import org.eclipse.draw2d.FigureCanvas;
+import org.eclipse.draw2d.Viewport;
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gef.ContextMenuProvider;
+import org.eclipse.gef.EditDomain;
+import org.eclipse.gef.EditPartViewer;
+import org.eclipse.gef.GraphicalViewer;
+import org.eclipse.gef.commands.CommandStack;
+import org.eclipse.gef.editparts.ScalableFreeformRootEditPart;
+import org.eclipse.gef.ui.parts.GraphicalViewerKeyHandler;
+import org.eclipse.gef.ui.parts.ScrollingGraphicalViewer;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.part.FileEditorInput;
+
+import org.savara.tools.scenario.designer.dnd.ScenarioTemplateTransferDropTargetListener;
+import org.savara.tools.scenario.designer.parts.*;
+import org.savara.tools.scenario.designer.simulate.SimulationEntity;
+import org.savara.tools.scenario.designer.view.GraphicalComponent;
+
+/**
+ * This class represents the flow based representation of a
+ * choreography.
+ */
+public class ScenarioEditorPage extends AbstractEditorPage
+ implements org.savara.tools.scenario.designer.simulate.ScenarioSimulation {
+
+ /**
+ * The constructor for the choreography flow page.
+ *
+ * @param parent The multipage editor
+ */
+ public ScenarioEditorPage(ScenarioDesigner parent) {
+ super(parent, new EditDomain());
+ }
+
+ /**
+ * This method returns the page name.
+ *
+ * @return The page name
+ */
+ public String getPageName() {
+ return("Scenario Editor");
+ }
+
+ protected CommandStack getCommandStack2() {
+ return(super.getCommandStack());
+ }
+
+ /**
+ * This method returns the scenario.
+ *
+ * @return The scenario
+ */
+ public org.savara.scenario.model.Scenario getScenario() {
+ return((org.savara.scenario.model.Scenario)getDescription());
+ }
+
+ /**
+ * This method creates the page control.
+ */
+ protected void createPageControl(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setBackground(parent.getBackground());
+ composite.setLayout(new GridLayout(2, false));
+
+ createPaletteViewer(composite);
+ GridData gd = new GridData(GridData.FILL_VERTICAL);
+ gd.widthHint = 125;
+ getPaletteViewer().getControl().setLayoutData(gd);
+
+ createGraphicalViewer(composite);
+ gd = new GridData(GridData.FILL_BOTH);
+ gd.widthHint = 275;
+ getViewer().getControl().setLayoutData(gd);
+ }
+
+ /**
+ * Creates the GraphicalViewer on the specified <code>Composite</code>.
+ * @param parent the parent composite
+ */
+ private void createGraphicalViewer(Composite parent) {
+ m_viewer = new ScrollingGraphicalViewer();
+ m_viewer.createControl(parent);
+
+ // configure the viewer
+ m_viewer.getControl().setBackground(parent.getBackground());
+ m_viewer.setRootEditPart(new ScalableFreeformRootEditPart());
+ m_viewer.setKeyHandler(new GraphicalViewerKeyHandler(m_viewer));
+
+ // hook the viewer into the editor
+ registerEditPartViewer(m_viewer);
+
+ // configure the viewer with drag and drop
+ configureEditPartViewer(m_viewer);
+
+ // initialize the viewer with input
+ m_viewer.setEditPartFactory(
+ new org.savara.tools.scenario.designer.parts.ScenarioEditPartsFactory(this));
+
+ m_viewer.setContents(getScenario());
+
+ focus(getScenario());
+ }
+
+ protected void resetViewer() {
+ if (m_viewer != null &&
+ getScenario() != null) {
+ m_viewer.setContents(getScenario());
+ }
+ }
+
+ /**
+ * This method returns the GraphicalViewer.
+ *
+ * @return The graphical viewer
+ * @see com.ibm.itso.sal330r.gefdemo.editor.AbstractEditorPage#getGraphicalViewerForZoomSupport()
+ */
+ public org.eclipse.gef.EditPartViewer getViewer() {
+ return(m_viewer);
+ }
+
+ /**
+ * This method returns the context menu provider.
+ *
+ * @param viewer The edit part viewer
+ * @return The context menu provider
+ */
+ protected ContextMenuProvider createContextMenuProvider(EditPartViewer viewer) {
+ return(new EditorContextMenuProvider(viewer,
+ getEditor().getActionRegistry()));
+ }
+
+ /**
+ * This method returns a transfer drop target listener.
+ *
+ * @param viewer The edit part viewer
+ * @return The transfer drop target listener
+ */
+ protected org.eclipse.jface.util.TransferDropTargetListener createTransferDropTargetListener(EditPartViewer viewer) {
+ return(new ScenarioTemplateTransferDropTargetListener(viewer));
+ }
+
+ /**
+ * This method returns the title.
+ *
+ * @return The title
+ * @see org.eclipse.ui.IWorkbenchPart#getTitle()
+ */
+ public String getTitle() {
+ return("Edit the test scenario");
+ }
+
+ /**
+ * This method focuses the editor page on the supplied
+ * component.
+ *
+ * @param component The component
+ */
+ public void focus(Object scenarioObject) {
+
+ /*
+ if ((component instanceof org.pi4soa.scenario.ScenarioObject) == false) {
+ return;
+ }
+
+ org.pi4soa.scenario.ScenarioObject scenarioObject=
+ (org.pi4soa.scenario.ScenarioObject)component;
+ */
+
+ resetViewer();
+
+ m_viewer.flush();
+
+ focusOnEditPart(scenarioObject);
+ }
+
+ /**
+ * This method finds an editpart associated with the
+ * supplied scenario object.
+ *
+ * @param scenarioObject The scenario object
+ * @return The edit part
+ */
+ protected org.eclipse.gef.EditPart findEditPart(Object scenarioObject) {
+ org.eclipse.gef.EditPart ret=null;
+
+ if (scenarioObject instanceof org.savara.scenario.model.Link) {
+ if (m_viewer.getContents() instanceof ScenarioBaseEditPart) {
+ ret = ((ScenarioBaseEditPart)m_viewer.getContents()).
+ findEditPartForModel(scenarioObject);
+ }
+
+ } else {
+ ret = m_viewer.getContents();
+ if (ret instanceof ScenarioBaseEditPart) {
+
+ ret = findSelectedEditPart((ScenarioBaseEditPart)ret,
+ scenarioObject);
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method focuses on the editpart associated with the
+ * supplied scenario object, and moves the viewport (if
+ * necessary) to ensure the editpart is visible.
+ *
+ * @param scenarioObject The scenario object
+ * @return The edit part
+ */
+ protected org.eclipse.gef.EditPart focusOnEditPart(Object scenarioObject) {
+ org.eclipse.gef.EditPart ret=findEditPart(scenarioObject);
+
+ if (ret != null) {
+ m_viewer.select(ret);
+ }
+
+ if (ret instanceof ScenarioEditPart) {
+
+ FigureCanvas canvas=(FigureCanvas)
+ m_viewer.getControl();
+
+ canvas.scrollSmoothTo(0, 0);
+
+ } else if (ret instanceof GraphicalComponent) {
+ GraphicalComponent ep=(GraphicalComponent)ret;
+ int x=0;
+ int y=0;
+ int width=ep.getComponentBounds().width;
+ int height=ep.getComponentBounds().height;
+
+ while (ep != null) {
+ Rectangle r=ep.getComponentBounds();
+
+ x += r.x;
+ y += r.y;
+
+ if (ep.getComponentParent() instanceof GraphicalComponent) {
+ ep = (GraphicalComponent)ep.getComponentParent();
+ } else {
+ ep = null;
+ }
+ }
+
+ FigureCanvas canvas=(FigureCanvas)
+ m_viewer.getControl();
+
+ Viewport port = canvas.getViewport();
+ Dimension viewportSize = port.getClientArea().getSize();
+
+ x -= (viewportSize.width - width)/2;
+ y -= (viewportSize.height - height)/2;
+
+ canvas.scrollSmoothTo(x, y);
+ }
+
+ return(ret);
+ }
+
+ public void startSimulation() {
+ m_simulationRunning = true;
+ }
+
+ public void resetSimulation() {
+ if (m_viewer.getContents() instanceof SimulationEntity) {
+ ((SimulationEntity)m_viewer.getContents()).reset();
+ }
+
+ m_log = new StringBuffer();
+
+ m_simulationRunning = false;
+
+ if (m_viewer.getContents() instanceof SimulationEntity) {
+ focusOnEditPart(((SimulationEntity)m_viewer.getContents()));
+ }
+ }
+
+ public boolean isSimulationRunning() {
+ return(m_simulationRunning);
+ }
+
+ public SimulationEntity getSimulationEntity(Object model, boolean focus) {
+ SimulationEntity ret=null;
+
+ m_simulationRunning = true;
+
+ org.eclipse.gef.EditPart ep=null;
+
+ if (focus) {
+ ep = focusOnEditPart(model);
+ } else {
+ ep = findEditPart(model);
+ }
+
+ if (ep instanceof SimulationEntity) {
+ ret = (SimulationEntity)ep;
+ }
+
+ return(ret);
+ }
+
+ public void appendLogEntry(String results) {
+ m_log.append(results);
+ }
+
+ public String getLogEntry(int start, int end) {
+ String ret=null;
+
+ if (start >= 0 && end >= 0 && end >= start &&
+ end < m_log.length()) {
+ ret = m_log.substring(start, end);
+ }
+
+ return(ret);
+ }
+
+ public String getLogEntry(Object scenarioObject) {
+ String ret=null;
+
+ org.eclipse.gef.EditPart ep=findEditPart(scenarioObject);
+
+ if (ep instanceof SimulationEntity) {
+ ret = getLogEntry(((SimulationEntity)ep).getLogStartPosition(),
+ ((SimulationEntity)ep).getLogEndPosition());
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method focuses the environment on the supplied
+ * URL and region name.
+ *
+ * @param scenarioURL The scenario path
+ * @param regionName The optional region name
+ */
+ public void focus(String scenarioURL, String regionName) {
+
+ if (getEditorInput() instanceof FileEditorInput) {
+ FileEditorInput fei=(FileEditorInput)getEditorInput();
+
+ org.eclipse.core.resources.IFile modelFile=
+ fei.getFile().getParent().getFile(
+ new org.eclipse.core.runtime.Path(scenarioURL));
+
+ IWorkbenchWindow workbenchWindow=
+ getSite().getWorkbenchWindow();
+ try {
+ org.eclipse.ui.IEditorPart editorPart=
+ workbenchWindow.getActivePage().openEditor
+ (new FileEditorInput(modelFile),
+ workbenchWindow.getWorkbench().
+ getEditorRegistry().
+ getDefaultEditor(modelFile.getFullPath().toString()).getId());
+
+ if (regionName != null &&
+ editorPart instanceof ScenarioDesigner) {
+ ScenarioDesigner designer=(ScenarioDesigner)editorPart;
+
+ /* TODO: GPB: need to recursively check for group by name
+ org.savara.scenario.model.Group region=
+ designer.getScenario().getRegion(regionName);
+
+ if (region != null) {
+ designer.getScenarioEditorPage().focus(region);
+ }
+ */
+ }
+ } catch (PartInitException exception) {
+ MessageDialog.openError(workbenchWindow.getShell(),
+ "Open Editor", exception.getMessage());
+ }
+ }
+ }
+
+
+ private GraphicalViewer m_viewer=null;
+ private boolean m_simulationRunning=false;
+ private StringBuffer m_log=new StringBuffer();
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/ScenarioPaletteRoot.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/ScenarioPaletteRoot.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/ScenarioPaletteRoot.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,142 @@
+/*
+ * Copyright 2005-7 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Feb 14, 2007 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.editor;
+
+import org.eclipse.gef.palette.CombinedTemplateCreationEntry;
+import org.eclipse.gef.palette.PaletteDrawer;
+import org.eclipse.gef.palette.PaletteGroup;
+import org.eclipse.gef.palette.PaletteRoot;
+import org.eclipse.gef.palette.PaletteSeparator;
+import org.eclipse.gef.palette.SelectionToolEntry;
+import org.eclipse.gef.palette.ToolEntry;
+import org.savara.scenario.model.Group;
+import org.savara.scenario.model.Import;
+import org.savara.scenario.model.ReceiveEvent;
+import org.savara.scenario.model.Role;
+import org.savara.scenario.model.SendEvent;
+import org.savara.scenario.model.TimeElapsedEvent;
+import org.savara.tools.scenario.designer.DesignerImages;
+import org.savara.tools.scenario.designer.model.ModelCreationFactory;
+import org.eclipse.gef.palette.ConnectionCreationToolEntry;
+import org.eclipse.swt.widgets.Link;
+
+/**
+ * This class implements the palette root for the designer.
+ */
+public class ScenarioPaletteRoot extends PaletteRoot {
+
+ /**
+ * Default constructor.
+ *
+ */
+ public ScenarioPaletteRoot() {
+ // create root
+ super();
+
+ // a group of default control tools
+ PaletteGroup controls = new PaletteGroup("Controls");
+ add(controls);
+
+ // the selection tool
+ ToolEntry tool = new SelectionToolEntry();
+ controls.add(tool);
+
+ // use selection tool as default entry
+ setDefaultEntry(tool);
+
+ PaletteDrawer drawer=new PaletteDrawer("Scenario");
+
+ controls.add(drawer);
+
+ CombinedTemplateCreationEntry entry =
+ new CombinedTemplateCreationEntry(
+ "Role",
+ "Creates a role",
+ new Role(),
+ new ModelCreationFactory(Role.class),
+ DesignerImages.getImageDescriptor("Role.gif"),
+ null);
+ drawer.add(entry);
+
+ entry = new CombinedTemplateCreationEntry(
+ "Event Group",
+ "Creates an event group",
+ new Group(),
+ new ModelCreationFactory(Group.class),
+ DesignerImages.getImageDescriptor("Group.gif"),
+ null);
+ drawer.add(entry);
+
+ drawer.add(new PaletteSeparator());
+
+ // conection creation
+ drawer.add(
+ new ConnectionCreationToolEntry(
+ "Message Link",
+ "Creates a link between two message events",
+ new ModelCreationFactory(Link.class),
+ DesignerImages.getImageDescriptor("Link.gif"),
+ null));
+
+ drawer.add(new PaletteSeparator());
+
+ entry = new CombinedTemplateCreationEntry(
+ "Send",
+ "Creates a send",
+ new SendEvent(),
+ new ModelCreationFactory(SendEvent.class),
+ DesignerImages.getImageDescriptor("Send.gif"),
+ null);
+ drawer.add(entry);
+
+ // Using the interface MessageEvent, instead of the MessageEvent
+ // (EMF) EClass, to distinguish the receive from the send
+ // until potentially we explicitly model these as separate
+ // events.
+ entry = new CombinedTemplateCreationEntry(
+ "Receive",
+ "Creates a receive",
+ new ReceiveEvent(),
+ new ModelCreationFactory(ReceiveEvent.class),
+ DesignerImages.getImageDescriptor("Receive.gif"),
+ null);
+ drawer.add(entry);
+
+ entry = new CombinedTemplateCreationEntry(
+ "Elapsed Time",
+ "Creates an elapsed time event",
+ new TimeElapsedEvent(),
+ new ModelCreationFactory(TimeElapsedEvent.class),
+ DesignerImages.getImageDescriptor("TimeElapsed.gif"),
+ null);
+ drawer.add(entry);
+
+ drawer.add(new PaletteSeparator());
+
+ entry = new CombinedTemplateCreationEntry(
+ "Import Scenario",
+ "Import another scenario",
+ new Import(),
+ new ModelCreationFactory(Import.class),
+ DesignerImages.getImageDescriptor("Import.gif"),
+ null);
+ drawer.add(entry);
+ }
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/SimulateScenarioAction.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/SimulateScenarioAction.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/SimulateScenarioAction.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,165 @@
+/*
+ * Copyright 2005-7 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Feb 23, 2007 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.editor;
+
+import java.util.logging.Logger;
+
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.core.Launch;
+import org.eclipse.ui.IWorkbenchPart;
+import org.savara.tools.scenario.designer.simulate.*;
+import org.savara.tools.scenario.simulation.ScenarioSimulationLaunchConfigurationConstants;
+
+
+/**
+ * This class provides the 'create message links' action implementation.
+ *
+ */
+public class SimulateScenarioAction extends org.eclipse.gef.ui.actions.SelectionAction {
+
+ public static final String ID = "org.pi4soa.service.test.designer.editor.SimulateScenarioID";
+
+ /**
+ * Creates a <code>CreateMessageLinksAction</code> and
+ * associates it with the given workbench part.
+ * @param part the workbench part
+ */
+ public SimulateScenarioAction(IWorkbenchPart part) {
+ super(part);
+ }
+
+ /**
+ * Initializes this action.
+ */
+ protected void init() {
+ setId(ID);
+ setText("Simulate");
+
+ setImageDescriptor(org.savara.tools.scenario.designer.DesignerImages.getImageDescriptor("Simulate.png"));
+ }
+
+ /**
+ * Calculates and returns the enabled state of this action.
+ * @return <code>true</code> if the action is enabled
+ */
+ protected boolean calculateEnabled() {
+ boolean ret=false;
+
+ if (getWorkbenchPart() instanceof ScenarioDesigner) { //&&
+ //ResourceUtil.hasErrors(((ScenarioDesigner)getWorkbenchPart()).getFile()) == false) {
+ ScenarioSimulation view=((ScenarioDesigner)getWorkbenchPart()).getScenarioSimulation();
+
+ if (view.getScenario() != null &&
+ //org.pi4soa.common.util.NamesUtil.isSet(
+ // view.getScenario().getChoreographyDescriptionURL()) &&
+ view.getScenario().getEvents().size() > 0) {
+ ret = !view.isSimulationRunning();
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * Perform this action.
+ *
+ */
+ public void run() {
+
+ org.savara.scenario.model.Scenario scenario=
+ ((ScenarioDesigner)getWorkbenchPart()).getScenario();
+
+ org.savara.tools.scenario.designer.simulate.ScenarioDesignerSimulationLauncher launcher=
+ new org.savara.tools.scenario.designer.simulate.ScenarioDesignerSimulationLauncher(
+ getWorkbenchPart().getSite().getShell().getDisplay(),
+ scenario, ((ScenarioDesigner)getWorkbenchPart()).getScenarioSimulation());
+
+ try {
+ ILaunchManager manager =
+ DebugPlugin.getDefault().getLaunchManager();
+
+ ILaunchConfigurationType type =
+ manager.getLaunchConfigurationType(
+ ScenarioSimulationLaunchConfigurationConstants.LAUNCH_CONFIG_TYPE);
+ ILaunchConfiguration[] configurations =
+ manager.getLaunchConfigurations(type);
+
+ for (int i = 0; i < configurations.length; i++) {
+ ILaunchConfiguration configuration = configurations[i];
+ if (configuration.getName().equals(PI4SOA_SCENARIO_TEST)) {
+ configuration.delete();
+ break;
+ }
+ }
+
+ ILaunchConfigurationWorkingCopy workingCopy =
+ type.newInstance(null, PI4SOA_SCENARIO_TEST);
+
+ workingCopy.setAttribute(ScenarioSimulationLaunchConfigurationConstants.ATTR_PROJECT_NAME,
+ ((ScenarioDesigner)getWorkbenchPart()).getFile().getProject().getName());
+ workingCopy.setAttribute(ScenarioSimulationLaunchConfigurationConstants.ATTR_SCENARIO,
+ ((ScenarioDesigner)getWorkbenchPart()).getFile().getProjectRelativePath().toString());
+
+ /*
+ String services=getServiceList();
+ if (services != null) {
+ workingCopy.setAttribute(ScenarioTestLaunchConfigurationConstants.ATTR_EXECUTE_SERVICES,
+ services);
+ }
+ */
+
+ ILaunchConfiguration configuration=workingCopy.doSave();
+
+
+ Launch launch=new Launch(configuration, LAUNCH_MODE, null);
+
+ launcher.launch(configuration, LAUNCH_MODE, launch, null);
+
+ ScenarioSimulation view=((ScenarioDesigner)getWorkbenchPart()).getScenarioSimulation();
+ view.startSimulation();
+
+ ((ScenarioDesigner)getWorkbenchPart()).updateEditPartActions();
+
+ } catch(Exception e) {
+ logger.severe("Failed to launch scenario tester: "+e);
+
+ e.printStackTrace();
+ }
+ /*
+ org.pi4soa.service.test.designer.tools.CreateMessageLinksTool tool=
+ new org.pi4soa.service.test.designer.tools.CreateMessageLinksTool(scenario);
+
+ tool.run();
+
+ if (tool.isScenarioChanged()) {
+ ((ScenarioEditor)getWorkbenchPart()).setDirty(true);
+ }
+ */
+ }
+
+ private static Logger logger = Logger.getLogger("org.pi4soa.service.test.designer.editor");
+
+ private static final String LAUNCH_MODE = "run";
+ private static final String PI4SOA_SCENARIO_TEST = "Pi4SOA Scenario Test";
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/SimulationEntityFocusAction.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/SimulationEntityFocusAction.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/SimulationEntityFocusAction.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2005-7 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Feb 23, 2007 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.editor;
+
+import org.eclipse.ui.IWorkbenchPart;
+
+import org.savara.tools.scenario.designer.simulate.*;
+
+/**
+ * This class provides the 'reset simulation' action implementation.
+ *
+ */
+public class SimulationEntityFocusAction extends org.eclipse.gef.ui.actions.SelectionAction {
+
+ public static final String ID="org.pi4soa.service.test.designer.editor.SimulationEntityFocusActionID";
+
+ /**
+ * Creates a <code>CreateMessageLinksAction</code> and
+ * associates it with the given workbench part.
+ * @param part the workbench part
+ */
+ public SimulationEntityFocusAction(IWorkbenchPart part) {
+ super(part);
+ setId(ID);
+ }
+
+ protected void handleSelectionChanged() {
+ String text="<Select message event or event group>";
+
+ if (getSelectedObjects().size() == 1) {
+ Object obj=getSelectedObjects().get(0);
+
+ if (obj instanceof SimulationEntity) {
+ SimulationEntity se=(SimulationEntity)obj;
+
+ text=((ScenarioDesigner)getWorkbenchPart()).
+ getScenarioSimulation().getLogEntry(
+ se.getLogStartPosition(),
+ se.getLogEndPosition());
+
+ if (text != null && text.trim().length() == 0) {
+ text = "<No simulation log information available>";
+ }
+ }
+ }
+
+ if (text != null) {
+ ((ScenarioDesigner)getWorkbenchPart()).
+ getSimulationLogPage().setText(text);
+ }
+ }
+
+ public boolean calculateEnabled() {
+ return(true);
+ }
+}
\ No newline at end of file
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/SimulationLogPage.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/SimulationLogPage.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/SimulationLogPage.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,107 @@
+/*
+ * Copyright 2005 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Jul 5, 2005 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.editor;
+
+import org.eclipse.gef.EditDomain;
+import org.eclipse.gef.EditPartViewer;
+import org.eclipse.jface.util.TransferDropTargetListener;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * This class represents the flow based representation of a
+ * choreography.
+ */
+public class SimulationLogPage extends AbstractEditorPage {
+
+ private org.eclipse.swt.widgets.Text m_text=null;
+
+ /**
+ * The constructor for the choreography flow page.
+ *
+ * @param parent The multipage editor
+ */
+ public SimulationLogPage(ScenarioDesigner parent) {
+ super(parent, new EditDomain());
+ }
+
+ /**
+ * This method returns the page name.
+ *
+ * @return The page name
+ */
+ public String getPageName() {
+ return("Simulation Log");
+ }
+
+ /**
+ * This method creates the page control.
+ */
+ protected void createPageControl(Composite parent) {
+ m_text =
+ new org.eclipse.swt.widgets.Text(parent,
+ SWT.MULTI|SWT.READ_ONLY|SWT.H_SCROLL|SWT.V_SCROLL);
+ }
+
+ /**
+ * This method returns the TreeViewer.
+ *
+ * @return The tree viewer
+ * @see com.ibm.itso.sal330r.gefdemo.editor.AbstractEditorPage#getGraphicalViewerForZoomSupport()
+ */
+ protected org.eclipse.gef.EditPartViewer getViewer() {
+ return(null);
+ }
+
+ /**
+ * This method returns the title.
+ *
+ * @return The title
+ * @see org.eclipse.ui.IWorkbenchPart#getTitle()
+ */
+ public String getTitle() {
+ return("Simulation logs");
+ }
+
+ /**
+ * Refresh the editor page without a new input.
+ *
+ */
+ public void refresh() {
+ }
+
+ /**
+ * This method focuses on the editor page on the supplied
+ * component.
+ */
+ public void focus(Object component) {
+ }
+
+ public void setText(String text) {
+ m_text.setText(text);
+ }
+
+ @Override
+ protected TransferDropTargetListener createTransferDropTargetListener(
+ EditPartViewer viewer) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/properties/DesignerTabbedPropertySheetPage.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/properties/DesignerTabbedPropertySheetPage.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/editor/properties/DesignerTabbedPropertySheetPage.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * 18 Jan 2008 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.editor.properties;
+
+import org.eclipse.ui.views.properties.tabbed.*;
+import org.eclipse.gef.commands.*;
+
+/**
+ * This class provides the designer specific implementation
+ * of the tabbed property sheet page, supporting an undo
+ * command stack.
+ */
+public class DesignerTabbedPropertySheetPage extends TabbedPropertySheetPage {
+
+ /**
+ * This is the constructor for the designer tabbed
+ * property page.
+ *
+ * @param tabbedPropertySheetPageContributor
+ */
+ public DesignerTabbedPropertySheetPage(
+ ITabbedPropertySheetPageContributor contributor,
+ CommandStack commandStack) {
+ super(contributor);
+
+ m_commandStack = commandStack;
+ m_contributor = contributor;
+ }
+
+ /**
+ * This method returns the command stack.
+ *
+ * @return The command stack
+ */
+ public CommandStack getCommandStack() {
+ return(m_commandStack);
+ }
+
+ /**
+ * This method returns the resource associated with the
+ * tabbed properties sheet.
+ *
+ * @return The resource
+ */
+ public org.eclipse.core.resources.IResource getResource() {
+ org.eclipse.core.resources.IResource ret=null;
+
+ if (m_contributor instanceof org.eclipse.ui.part.MultiPageEditorPart) {
+ ret = (org.eclipse.core.resources.IResource)
+ ((org.eclipse.ui.part.MultiPageEditorPart)m_contributor).
+ getEditorInput().getAdapter(
+ org.eclipse.core.resources.IResource.class);
+ }
+
+ return(ret);
+ }
+
+ private CommandStack m_commandStack=null;
+ private ITabbedPropertySheetPageContributor m_contributor=null;
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/figures/EventFigure.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/figures/EventFigure.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/figures/EventFigure.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,123 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * 15 May, 2008 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.figures;
+
+import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.draw2d.Graphics;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.draw2d.geometry.Rectangle;
+
+/**
+ * This class provides a figure for the lifeline items.
+ */
+public abstract class EventFigure extends org.eclipse.draw2d.Figure {
+
+ public EventFigure() {
+ }
+
+ protected boolean useLocalCoordinates() {
+ return(true);
+ }
+
+ /**
+ * Sets the selection state of this SimpleActivityLabel
+ * @param b true will cause the label to appear selected
+ */
+ public void setSelected(boolean b) {
+ selected = b;
+ repaint();
+ }
+
+ /**
+ * Sets the focus state of this SimpleActivityLabel
+ * @param b true will cause a focus rectangle to be drawn around the text of the Label
+ */
+ public void setFocus(boolean b) {
+ hasFocus = b;
+ repaint();
+ }
+
+ public void setErrorExpected(Boolean exc) {
+ m_errorExpected = exc;
+ }
+
+ protected boolean isErrorExpected() {
+ boolean ret=false;
+
+ if (m_errorExpected != null) {
+ ret = m_errorExpected.booleanValue();
+ }
+
+ return(ret);
+ }
+
+ protected Color getBoundaryColor() {
+ Color ret=ColorConstants.gray;
+
+ if (isErrorExpected()) {
+ ret = ColorConstants.red;
+ }
+
+ return(ret);
+ }
+
+ protected int getBoundaryWidth() {
+ int ret=1;
+
+ if (isErrorExpected()) {
+ ret = 2;
+ }
+
+ return(ret);
+ }
+
+ protected Color getFillColor() {
+ Color ret=ColorConstants.menuBackground;
+
+ if (getState() == STATE_SUCCESSFUL) {
+ ret = ColorConstants.green;
+ } else if (getState() == STATE_UNSUCCESSFUL) {
+ ret = ColorConstants.red;
+ } else if (getState() == STATE_PROCESSING) {
+ ret = ColorConstants.yellow;
+ }
+
+ return(ret);
+ }
+
+ public void setState(int state) {
+ m_state = state;
+ repaint();
+ }
+
+ public int getState() {
+ return(m_state);
+ }
+
+ private boolean selected;
+ private boolean hasFocus;
+ private Boolean m_errorExpected=null;
+ private int m_state=STATE_RESET;
+
+ public static final int STATE_RESET=0;
+ public static final int STATE_PROCESSING=1;
+ public static final int STATE_SUCCESSFUL=2;
+ public static final int STATE_UNSUCCESSFUL=3;
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/figures/GroupFigure.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/figures/GroupFigure.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/figures/GroupFigure.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2005 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Jul 6, 2005 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.figures;
+
+import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.draw2d.Graphics;
+import org.eclipse.draw2d.MarginBorder;
+import org.eclipse.draw2d.geometry.PointList;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
+import org.savara.tools.scenario.designer.view.ViewSupport;
+
+/**
+ * This figure represents a sequential grouping construct.
+ */
+public class GroupFigure extends GroupingFigure {
+
+ static final MarginBorder MARGIN_BORDER = new MarginBorder(0, 8, 0, 0);
+
+ static final PointList ARROW = new PointList(3); {
+ ARROW.addPoint(0,0);
+ ARROW.addPoint(10,0);
+ ARROW.addPoint(5,5);
+ }
+
+ /**
+ * @param header
+ * @param footer
+ */
+ public GroupFigure(Image image) {
+ super(new StartTagFigure("", image, false));
+ setBorder(MARGIN_BORDER);
+ setOpaque(false);
+ }
+
+ protected void paintFigure(Graphics graphics) {
+ super.paintFigure(graphics);
+ graphics.setBackgroundColor(ColorConstants.buttonDarker);
+ Rectangle r = getBounds().getCopy();
+
+ r.y += ViewSupport.TYPES_INITIAL_YPADDING;
+ r.height -= (1 + ViewSupport.TYPES_INITIAL_YPADDING);
+ r.width -= 1;
+
+ graphics.setLineStyle(graphics.LINE_DASH);
+ graphics.setForegroundColor(getBoundaryColor());
+ graphics.drawRoundRectangle(r, 10, 10);
+ }
+
+ protected Color getBoundaryColor() {
+ Color ret=ColorConstants.gray;
+
+ if (getState() == STATE_SUCCESSFUL) {
+ ret = ColorConstants.green;
+ } else if (getState() == STATE_UNSUCCESSFUL) {
+ ret = ColorConstants.red;
+ } else if (getState() == STATE_PROCESSING) {
+ ret = ColorConstants.yellow;
+ }
+
+ return(ret);
+ }
+
+ public void setState(int state) {
+ m_state = state;
+ repaint();
+ }
+
+ public int getState() {
+ return(m_state);
+ }
+
+ private int m_state=STATE_RESET;
+
+ public static final int STATE_RESET=0;
+ public static final int STATE_PROCESSING=1;
+ public static final int STATE_SUCCESSFUL=2;
+ public static final int STATE_UNSUCCESSFUL=3;
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/figures/GroupingFigure.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/figures/GroupingFigure.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/figures/GroupingFigure.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2005 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Jul 6, 2005 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.figures;
+
+import org.eclipse.draw2d.Figure;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.XYLayout;
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Rectangle;
+
+/**
+ * This class represents a grouping figure, that can be expanded,
+ * or collapsed.
+ */
+public class GroupingFigure extends Figure {
+
+ public GroupingFigure(IFigure header) {
+ contents = new Figure();
+ //contents.setLayoutManager(new DummyLayout());
+ contents.setLayoutManager(new XYLayout());
+ add(contents);
+ add(this.header = header);
+ }
+
+ public IFigure getContents() {
+ return contents;
+ }
+
+ public IFigure getHeader() {
+ return header;
+ }
+
+ /**
+ * @see org.eclipse.draw2d.Figure#getPreferredSize(int, int)
+ */
+ public Dimension getPreferredSize(int wHint, int hHint) {
+ Dimension dim = new Dimension();
+ //dim.width = getFooter().getPreferredSize().width;
+ dim.width += getInsets().getWidth();
+ dim.height = 50;
+ return dim;
+ }
+
+ public void setBounds(Rectangle rect) {
+ super.setBounds(rect);
+ rect = Rectangle.SINGLETON;
+ getClientArea(rect);
+ contents.setBounds(rect);
+ //Dimension size = footer.getPreferredSize();
+ //footer.setLocation(rect.getBottomLeft().translate(0, -size.height));
+ //footer.setSize(size);
+
+ Dimension size = header.getPreferredSize();
+ header.setSize(size);
+ header.setLocation(rect.getLocation());
+ }
+
+ public void setSelected(boolean value) {
+ }
+
+ IFigure contents;
+ IFigure header;
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/figures/ImportFigure.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/figures/ImportFigure.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/figures/ImportFigure.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,131 @@
+/*
+ * Copyright 2005 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Jul 14, 2005 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.figures;
+
+import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.draw2d.Graphics;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.swt.graphics.Color;
+import org.savara.scenario.model.*;
+import org.savara.tools.scenario.designer.model.*;
+import org.savara.tools.scenario.designer.view.*;
+
+/**
+ * This class provides a figure for the simple type.
+ */
+public class ImportFigure extends org.eclipse.draw2d.Figure {
+
+ public ImportFigure(ScenarioDiagram diagram) {
+ m_diagram = diagram;
+ }
+
+ protected boolean useLocalCoordinates() {
+ return(true);
+ }
+
+ public void setURL(String url) {
+ m_url = url;
+ repaint();
+ }
+
+ /**
+ * @see org.eclipse.draw2d.Label#paintFigure(org.eclipse.draw2d.Graphics)
+ */
+ protected void paintFigure(Graphics graphics) {
+ super.paintFigure(graphics);
+
+ Rectangle r=getBounds();
+
+ //graphics.setBackgroundColor(getFillColor());
+
+ graphics.setBackgroundColor(ColorConstants.white);
+ graphics.fillRectangle(r);
+
+ if (m_diagram != null) {
+ java.util.List list=m_diagram.getScenario().getRoles();
+
+ graphics.setBackgroundColor(getFillColor());
+ graphics.fillRectangle(r);
+
+ for (int i=0; i < list.size(); i++) {
+ Role p=(Role)list.get(i);
+
+ int xpos=ViewSupport.getChildXPosition(m_diagram.getScenario(),
+ p, m_diagram);
+
+ if (xpos > 0) {
+
+ graphics.setBackgroundColor(ColorConstants.lightBlue);
+
+ graphics.fillRectangle(xpos, r.y, 10, r.height);
+ }
+ }
+ }
+
+ graphics.setForegroundColor(ColorConstants.black);
+
+ org.eclipse.swt.graphics.Font font =
+ new org.eclipse.swt.graphics.Font(org.eclipse.swt.widgets.Display.getCurrent(),
+ "Arial",6,org.eclipse.swt.SWT.ITALIC);
+
+ graphics.setFont(font);
+
+ String text="Import: ";
+ if (m_url != null) {
+ text += m_url;
+ }
+ graphics.drawText(text, r.x+5, r.y+2);
+
+ font.dispose();
+ }
+
+ protected Color getFillColor() {
+ Color ret=ColorConstants.menuBackground;
+
+ if (getState() == STATE_SUCCESSFUL) {
+ ret = ColorConstants.green;
+ } else if (getState() == STATE_UNSUCCESSFUL) {
+ ret = ColorConstants.red;
+ } else if (getState() == STATE_PROCESSING) {
+ ret = ColorConstants.yellow;
+ }
+
+ return(ret);
+ }
+
+ public void setState(int state) {
+ m_state = state;
+ repaint();
+ }
+
+ public int getState() {
+ return(m_state);
+ }
+
+ private String m_url=null;
+ private ScenarioDiagram m_diagram=null;
+
+ private int m_state=STATE_RESET;
+
+ public static final int STATE_RESET=0;
+ public static final int STATE_PROCESSING=1;
+ public static final int STATE_SUCCESSFUL=2;
+ public static final int STATE_UNSUCCESSFUL=3;
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/figures/MessageEventFigure.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/figures/MessageEventFigure.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/figures/MessageEventFigure.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,129 @@
+/*
+ * Copyright 2005 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Jul 14, 2005 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.figures;
+
+import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.draw2d.ConnectionAnchor;
+
+/**
+ * This class provides a figure for the simple type.
+ */
+public class MessageEventFigure extends org.eclipse.draw2d.Figure {
+
+ public MessageEventFigure() {
+ m_connectionAnchor = new org.eclipse.draw2d.ChopboxAnchor(this);
+ }
+
+ protected boolean useLocalCoordinates() {
+ return(true);
+ }
+
+ /**
+ * Sets the selection state of this SimpleActivityLabel
+ * @param b true will cause the label to appear selected
+ */
+ public void setSelected(boolean b) {
+ selected = b;
+ repaint();
+ }
+
+ /**
+ * Sets the focus state of this SimpleActivityLabel
+ * @param b true will cause a focus rectangle to be drawn around the text of the Label
+ */
+ public void setFocus(boolean b) {
+ hasFocus = b;
+ repaint();
+ }
+
+ public ConnectionAnchor getConnectionAnchor() {
+ return(m_connectionAnchor);
+ }
+
+ public void setErrorExpected(Boolean exc) {
+ m_errorExpected = exc;
+ }
+
+ protected boolean isErrorExpected() {
+ boolean ret=false;
+
+ if (m_errorExpected != null) {
+ ret = m_errorExpected.booleanValue();
+ }
+
+ return(ret);
+ }
+
+ protected Color getBoundaryColor() {
+ Color ret=ColorConstants.gray;
+
+ if (isErrorExpected()) {
+ ret = ColorConstants.red;
+ }
+
+ return(ret);
+ }
+
+ protected int getBoundaryWidth() {
+ int ret=1;
+
+ if (isErrorExpected()) {
+ ret = 2;
+ }
+
+ return(ret);
+ }
+
+ protected Color getFillColor() {
+ Color ret=ColorConstants.menuBackground;
+
+ if (getState() == STATE_SUCCESSFUL) {
+ ret = ColorConstants.green;
+ } else if (getState() == STATE_UNSUCCESSFUL) {
+ ret = ColorConstants.red;
+ } else if (getState() == STATE_PROCESSING) {
+ ret = ColorConstants.yellow;
+ }
+
+ return(ret);
+ }
+
+ public void setState(int state) {
+ m_state = state;
+ repaint();
+ }
+
+ public int getState() {
+ return(m_state);
+ }
+
+ private ConnectionAnchor m_connectionAnchor=null;
+
+ private boolean selected;
+ private boolean hasFocus;
+ private Boolean m_errorExpected=null;
+ private int m_state=STATE_RESET;
+
+ public static final int STATE_RESET=0;
+ public static final int STATE_PROCESSING=1;
+ public static final int STATE_SUCCESSFUL=2;
+ public static final int STATE_UNSUCCESSFUL=3;
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/figures/ReceiveMessageEventFigure.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/figures/ReceiveMessageEventFigure.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/figures/ReceiveMessageEventFigure.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2005 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Jul 14, 2005 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.figures;
+
+import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.draw2d.Graphics;
+import org.eclipse.draw2d.Label;
+import org.eclipse.draw2d.geometry.Insets;
+import org.eclipse.draw2d.geometry.Rectangle;
+
+/**
+ * This class provides a figure for the simple type.
+ */
+public class ReceiveMessageEventFigure extends MessageEventFigure {
+
+ /**
+ * @see org.eclipse.draw2d.Label#paintFigure(org.eclipse.draw2d.Graphics)
+ */
+ protected void paintFigure(Graphics graphics) {
+ /*
+ if (selected) {
+ graphics.pushState();
+ graphics.setBackgroundColor(ColorConstants.menuBackgroundSelected);
+ graphics.fillRectangle(getSelectionRectangle());
+ graphics.popState();
+ graphics.setForegroundColor(ColorConstants.white);
+ }
+ if (hasFocus) {
+ graphics.pushState();
+ graphics.setXORMode(true);
+ graphics.setForegroundColor(ColorConstants.menuBackgroundSelected);
+ graphics.setBackgroundColor(ColorConstants.white);
+ graphics.drawFocus(getSelectionRectangle().resize(-1, -1));
+ graphics.popState();
+ }
+ */
+ super.paintFigure(graphics);
+
+ Rectangle r=getBounds();
+
+ /*
+ r.resize(-1, -1);
+ r.expand(1, 1);
+ r.width -= 1;
+ r.x -= 2;
+ */
+
+ graphics.setBackgroundColor(getFillColor());
+ graphics.fillPolygon(new int[]{
+ r.x+2, r.bottom()-2,
+ r.x+10, r.y + r.height / 2,
+ r.x+2, r.y+2,
+ r.right()-2, r.y+2,
+ r.right()-2, r.bottom()-2
+ });
+
+ graphics.setForegroundColor(getBoundaryColor());
+ graphics.setLineWidth(getBoundaryWidth());
+
+ graphics.drawLine(r.x+10, r.y + r.height / 2, r.x+2, r.y+2);
+ graphics.drawLine(r.x+10, r.y + r.height / 2, r.x+2, r.bottom()-2);
+
+ graphics.drawLine(r.x+2, r.y+2, r.right()-2, r.y+2); //Top line
+ graphics.drawLine(r.x+2, r.bottom()-2, r.right()-2, r.bottom()-2); //Bottom line
+ graphics.drawLine(r.right()-2, r.bottom()-2, r.right()-2, r.y+2); //right line
+ }
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/figures/RoleFigure.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/figures/RoleFigure.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/figures/RoleFigure.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,152 @@
+/*
+ * Copyright 2005 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Jul 14, 2005 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.figures;
+
+import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.draw2d.ConnectionAnchor;
+import org.eclipse.draw2d.Graphics;
+import org.eclipse.draw2d.Label;
+import org.eclipse.draw2d.geometry.Insets;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.savara.tools.scenario.designer.view.ViewSupport;
+import org.eclipse.draw2d.MarginBorder;
+
+/**
+ * This class provides a figure for the simple type.
+ */
+public class RoleFigure extends GroupingFigure {//org.eclipse.draw2d.Figure {
+
+ public RoleFigure() {
+ super(new StartTagFigure("", null, true));
+ setOpaque(true);
+
+ ((org.eclipse.draw2d.Label)getHeader()).setBackgroundColor(ColorConstants.menuBackground);
+ ((org.eclipse.draw2d.Label)getHeader()).setForegroundColor(ColorConstants.black);
+
+ ((org.eclipse.draw2d.Label)getHeader()).setTextAlignment(
+ org.eclipse.draw2d.PositionConstants.LEFT);
+
+ m_connectionAnchor = new org.eclipse.draw2d.ChopboxAnchor(this);
+ }
+
+ /*
+ private Rectangle getSelectionRectangle() {
+ Rectangle bounds = getBounds();
+ bounds.expand(new Insets(2,2,0,0));
+ translateToParent(bounds);
+ bounds.intersect(getBounds());
+ return bounds;
+ }
+ */
+
+ protected boolean useLocalCoordinates() {
+ return(true);
+ }
+
+ /**
+ * @see org.eclipse.draw2d.Label#paintFigure(org.eclipse.draw2d.Graphics)
+ */
+ protected void paintFigure(Graphics graphics) {
+ /*
+ if (selected) {
+ graphics.pushState();
+ graphics.setBackgroundColor(ColorConstants.menuBackgroundSelected);
+ graphics.fillRectangle(getSelectionRectangle());
+ graphics.popState();
+ graphics.setForegroundColor(ColorConstants.white);
+ }
+ if (hasFocus) {
+ graphics.pushState();
+ graphics.setXORMode(true);
+ graphics.setForegroundColor(ColorConstants.menuBackgroundSelected);
+ graphics.setBackgroundColor(ColorConstants.white);
+ graphics.drawFocus(getSelectionRectangle().resize(-1, -1));
+ graphics.popState();
+ }
+ */
+ super.paintFigure(graphics);
+
+ Rectangle r=getBounds();
+
+ graphics.setBackgroundColor(ColorConstants.lightGray);
+ graphics.fillRectangle(r.x+(r.width/2)-5, r.y+40, 10, r.height-40);
+
+
+ /*
+ r.resize(-1, -1);
+ r.expand(1, 1);
+ r.width -= 1;
+ r.x -= 2;
+ */
+
+ /*
+ graphics.drawLine(r.x+2, r.bottom()-2, r.x+2, r.y+2); //right line
+ graphics.drawLine(r.x+2, r.y+2, r.right()-2, r.y+2); //Top line
+ graphics.drawLine(r.x+2, r.bottom()-2, r.right()-2, r.bottom()-2); //Bottom line
+ graphics.drawLine(r.right()-2, r.bottom()-2, r.right()-2, r.y+2); //right line
+ */
+ }
+
+ public void setBounds(Rectangle rect) {
+
+ if (getHeader().getPreferredSize().width < rect.width) {
+ getHeader().getPreferredSize().width = rect.width;
+ }
+
+ if (getHeader().getPreferredSize().height < 46) {
+ getHeader().getPreferredSize().height = 46;
+ }
+
+ super.setBounds(rect);
+ }
+
+ public void setText(String text) {
+ m_text = text;
+ ((Label)getHeader()).setText(text);
+ }
+
+ /**
+ * Sets the selection state of this SimpleActivityLabel
+ * @param b true will cause the label to appear selected
+ */
+ public void setSelected(boolean b) {
+ selected = b;
+ repaint();
+ }
+
+ /**
+ * Sets the focus state of this SimpleActivityLabel
+ * @param b true will cause a focus rectangle to be drawn around the text of the Label
+ */
+ public void setFocus(boolean b) {
+ hasFocus = b;
+ repaint();
+ }
+
+ public ConnectionAnchor getConnectionAnchor() {
+ return(m_connectionAnchor);
+ }
+
+ private ConnectionAnchor m_connectionAnchor=null;
+
+ private boolean selected;
+ private boolean hasFocus;
+ private String m_text=null;
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/figures/ScenarioFigure.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/figures/ScenarioFigure.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/figures/ScenarioFigure.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,115 @@
+/*
+ * Copyright 2005 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Jul 6, 2005 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.figures;
+
+import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.draw2d.FreeformLayer;
+import org.eclipse.draw2d.Graphics;
+import org.eclipse.draw2d.MarginBorder;
+import org.eclipse.draw2d.geometry.PointList;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * This figure represents a sequential grouping construct.
+ */
+public class ScenarioFigure extends FreeformLayer {
+
+ /**
+ * @param header
+ * @param footer
+ */
+ public ScenarioFigure() {
+ //setOpaque(false);
+ }
+
+ protected void paintFigure(Graphics graphics) {
+ super.paintFigure(graphics);
+
+ int height=25;
+ int width=0;
+
+ if (m_name != null) {
+ width = (int)((m_name.length()+6)*6.5);
+ }
+
+ if (m_author != null) {
+ height += 25;
+ if (width == 0 || m_author.length() > m_name.length()) {
+ width = (int)((m_author.length()+7)*6.5);
+ }
+ }
+
+ //Rectangle r2=new Rectangle(5, 5, 200, 50);
+ graphics.setForegroundColor(ColorConstants.buttonDarker);
+
+ //graphics.setBackgroundColor(ColorConstants.button);
+ //graphics.drawRoundRectangle(r2, 5, 5);
+
+ //Rectangle r = getBounds().getCopy();
+
+ String text=m_name;
+ if (text == null || text.trim().length() == 0) {
+ text = "<unknown>";
+ }
+ text = "Name: "+text;
+
+ graphics.drawText(text, 10, 5);
+
+ if (m_author != null) {
+ text = "Author: "+m_author;
+
+ graphics.drawText(text, 10, 25);
+ }
+
+ if (width < 200) {
+ width = 200;
+ } else {
+ width += 20;
+ }
+
+ graphics.drawLine(0, height, width, height);
+ graphics.drawLine(width, height, width+height, 0);
+
+ /*
+ r.y += ViewSupport.TYPES_INITIAL_YPADDING;
+ r.height -= (1 + ViewSupport.TYPES_INITIAL_YPADDING);
+ r.width -= 1;
+
+ graphics.setLineStyle(graphics.LINE_DASH);
+ graphics.setForegroundColor(getBoundaryColor());
+ graphics.drawRoundRectangle(r, 10, 10);
+ */
+ }
+
+ public void setName(String name) {
+ m_name = name;
+ repaint();
+ }
+
+ public void setAuthor(String author) {
+ m_author = author;
+ repaint();
+ }
+
+ private String m_name=null;
+ private String m_author=null;
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/figures/SendMessageEventFigure.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/figures/SendMessageEventFigure.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/figures/SendMessageEventFigure.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,85 @@
+/*
+ * Copyright 2005 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Jul 14, 2005 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.figures;
+
+import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.draw2d.ConnectionAnchor;
+import org.eclipse.draw2d.Graphics;
+import org.eclipse.draw2d.Label;
+import org.eclipse.draw2d.geometry.Insets;
+import org.eclipse.draw2d.geometry.Rectangle;
+
+/**
+ * This class provides a figure for the simple type.
+ */
+public class SendMessageEventFigure extends MessageEventFigure {
+
+ /**
+ * @see org.eclipse.draw2d.Label#paintFigure(org.eclipse.draw2d.Graphics)
+ */
+ protected void paintFigure(Graphics graphics) {
+ /*
+ if (selected) {
+ graphics.pushState();
+ graphics.setBackgroundColor(ColorConstants.menuBackgroundSelected);
+ graphics.fillRectangle(getSelectionRectangle());
+ graphics.popState();
+ graphics.setForegroundColor(ColorConstants.white);
+ }
+ if (hasFocus) {
+ graphics.pushState();
+ graphics.setXORMode(true);
+ graphics.setForegroundColor(ColorConstants.menuBackgroundSelected);
+ graphics.setBackgroundColor(ColorConstants.white);
+ graphics.drawFocus(getSelectionRectangle().resize(-1, -1));
+ graphics.popState();
+ }
+ */
+ super.paintFigure(graphics);
+
+ Rectangle r=getBounds();
+
+ /*
+ r.resize(-1, -1);
+ r.expand(1, 1);
+ r.width -= 1;
+ r.x -= 2;
+ */
+
+ graphics.setBackgroundColor(getFillColor());
+ graphics.fillPolygon(new int[]{
+ r.x+3, r.y+2,
+ r.right()-10, r.y+2,
+ r.right()-2, r.y + r.height / 2,
+ r.right()-10, r.bottom()-2,
+ r.x+3, r.bottom()-2
+ });
+
+ graphics.setForegroundColor(getBoundaryColor());
+ graphics.setLineWidth(getBoundaryWidth());
+
+ graphics.drawLine(r.x+3, r.y+2, r.right()-10, r.y+2); //Top line
+ graphics.drawLine(r.x+3, r.bottom()-2, r.right()-10, r.bottom()-2); //Bottom line
+ graphics.drawLine(r.x+3, r.bottom()-2, r.x+3, r.y+2); //left line
+
+ graphics.drawLine(r.right()-2, r.y + r.height / 2, r.right()-10, r.y+2);
+ graphics.drawLine(r.right()-2, r.y + r.height / 2, r.right()-10, r.bottom()-2);
+ }
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/figures/StartTagFigure.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/figures/StartTagFigure.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/figures/StartTagFigure.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2005 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Jul 6, 2005 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.figures;
+
+import org.eclipse.draw2d.Border;
+import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.draw2d.Graphics;
+import org.eclipse.draw2d.Label;
+import org.eclipse.draw2d.MarginBorder;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ *
+ */
+public class StartTagFigure extends Label {
+
+
+ static final Border BORDER = new MarginBorder(2,0,2,9);
+
+ /**
+ * Creates a new StartTag
+ * @param name the text to display in this StartTag
+ */
+ public StartTagFigure(String name, Image image, boolean border) {
+ setText(name);
+
+ if (image != null) {
+ setIconTextGap(4);
+ setIcon(image);
+ }
+
+ setForegroundColor(ColorConstants.lightGray);
+ setOpaque(true);
+
+ if (border) {
+ setBorder(new MarginBorder(2,0,2,9));
+ }
+ setTextAlignment(org.eclipse.draw2d.PositionConstants.LEFT);
+ //setBackgroundColor(ColorConstants.tooltipBackground);
+ }
+
+ /*
+ protected void paintFigure(Graphics g) {
+ super.paintFigure(g);
+ Rectangle r = getTextBounds();
+
+ /*
+ r.resize(-1, -1);
+ r.expand(1, 1);
+ r.width -= 1;
+ r.x -= 2;
+ g.drawLine(r.x, r.y, r.right(), r.y); //Top line
+ g.drawLine(r.x, r.bottom(), r.right(), r.bottom()); //Bottom line
+ g.drawLine(r.x, r.bottom(), r.x, r.y); //left line
+
+ g.drawLine(r.right() + 7, r.y + r.height / 2, r.right(), r.y);
+ g.drawLine(r.right()+7, r.y + r.height / 2, r.right(), r.bottom());
+ */
+ //}
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/figures/TimeElapsedEventFigure.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/figures/TimeElapsedEventFigure.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/figures/TimeElapsedEventFigure.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,115 @@
+/*
+ * Copyright 2005 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Jul 14, 2005 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.figures;
+
+import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.draw2d.Graphics;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.savara.scenario.model.*;
+import org.savara.tools.scenario.designer.model.*;
+import org.savara.tools.scenario.designer.view.*;
+
+/**
+ * This class provides a figure for the simple type.
+ */
+public class TimeElapsedEventFigure extends org.eclipse.draw2d.Figure {
+
+ public TimeElapsedEventFigure(ScenarioDiagram diagram) {
+ m_diagram = diagram;
+ }
+
+ protected boolean useLocalCoordinates() {
+ return(true);
+ }
+
+ public void setElapsedTime(String elapsedTime) {
+ m_elapsedTime = elapsedTime;
+ repaint();
+ }
+
+ /**
+ * @see org.eclipse.draw2d.Label#paintFigure(org.eclipse.draw2d.Graphics)
+ */
+ protected void paintFigure(Graphics graphics) {
+ super.paintFigure(graphics);
+
+ Rectangle r=getBounds();
+
+ //graphics.setBackgroundColor(getFillColor());
+
+ graphics.setBackgroundColor(ColorConstants.white);
+ graphics.fillRectangle(r);
+
+ if (m_diagram != null) {
+ java.util.List list=m_diagram.getScenario().getRoles();
+
+ for (int i=0; i < list.size(); i++) {
+ Role p=(Role)list.get(i);
+
+ int xpos=ViewSupport.getChildXPosition(m_diagram.getScenario(),
+ p, m_diagram);
+
+ if (xpos > 0) {
+
+ graphics.setBackgroundColor(ColorConstants.lightGray);
+ graphics.fillPolygon(new int[]{
+ xpos, r.y,
+ xpos-10, r.y+(r.height/3),
+ xpos, r.y+(r.height/3),
+ xpos+10, r.y
+ });
+ graphics.fillPolygon(new int[]{
+ xpos-10, r.y+(r.height/3),
+ xpos+10, r.y +(2*r.height / 3),
+ xpos+20, r.y +(2*r.height / 3),
+ xpos, r.y+(r.height/3)
+ });
+ graphics.fillPolygon(new int[]{
+ xpos+10, r.y +(2*r.height / 3),
+ xpos, r.y +r.height,
+ xpos+10, r.y +r.height,
+ xpos+20, r.y +(2*r.height / 3)
+ });
+ }
+ }
+ }
+
+ graphics.setForegroundColor(ColorConstants.black);
+
+ org.eclipse.swt.graphics.Font font =
+ new org.eclipse.swt.graphics.Font(org.eclipse.swt.widgets.Display.getCurrent(),
+ "Arial",6,org.eclipse.swt.SWT.ITALIC);
+
+ graphics.setFont(font);
+
+ String text="Elapsed: ";
+
+ if (m_elapsedTime != null) {
+ text += m_elapsedTime;
+ }
+
+ graphics.drawText(text, r.x+5, r.y+2);
+
+ font.dispose();
+ }
+
+ private String m_elapsedTime=null;
+ private ScenarioDiagram m_diagram=null;
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/images/GenerateImage.gif
===================================================================
(Binary files differ)
Property changes on: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/images/GenerateImage.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/images/Group.gif
===================================================================
(Binary files differ)
Property changes on: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/images/Group.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/images/Import.gif
===================================================================
(Binary files differ)
Property changes on: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/images/Import.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/images/Link.gif
===================================================================
(Binary files differ)
Property changes on: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/images/Link.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/images/Receive.gif
===================================================================
(Binary files differ)
Property changes on: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/images/Receive.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/images/ResetSimulation.gif
===================================================================
(Binary files differ)
Property changes on: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/images/ResetSimulation.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/images/ResetSimulation.png
===================================================================
(Binary files differ)
Property changes on: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/images/ResetSimulation.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/images/Role.gif
===================================================================
(Binary files differ)
Property changes on: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/images/Role.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/images/Send.gif
===================================================================
(Binary files differ)
Property changes on: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/images/Send.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/images/Simulate.gif
===================================================================
(Binary files differ)
Property changes on: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/images/Simulate.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/images/Simulate.png
===================================================================
(Binary files differ)
Property changes on: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/images/Simulate.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/images/SimulateTB.gif
===================================================================
(Binary files differ)
Property changes on: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/images/SimulateTB.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/images/TimeElapsed.gif
===================================================================
(Binary files differ)
Property changes on: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/images/TimeElapsed.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/model/Bean.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/model/Bean.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/model/Bean.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2005-6 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * 16 Feb 2007 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.model;
+
+public interface Bean {
+
+ public void addPropertyChangeListener(java.beans.PropertyChangeListener l);
+
+ public void removePropertyChangeListener(java.beans.PropertyChangeListener l);
+
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/model/ModelCreationFactory.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/model/ModelCreationFactory.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/model/ModelCreationFactory.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2005-7 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Feb 14, 2007 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.model;
+
+import java.util.logging.Logger;
+
+import org.eclipse.gef.requests.CreationFactory;
+
+/**
+ * This class is responsible for creating new instances of the
+ * Test Scenario model.
+ */
+public class ModelCreationFactory implements CreationFactory {
+
+ public ModelCreationFactory(Object targetClass) {
+ m_targetClass = targetClass;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.requests.CreationFactory#getNewObject()
+ */
+ public Object getNewObject() {
+ Object ret=null;
+
+ try {
+ ret = ((Class<?>)m_targetClass).newInstance();
+ } catch(Exception e) {
+ logger.severe("Failed to create new object of type '"+
+ m_targetClass+"': "+e);
+ }
+
+ return(ret);
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.requests.CreationFactory#getObjectType()
+ */
+ public Object getObjectType() {
+ return(m_targetClass);
+ }
+
+ private static Logger logger = Logger.getLogger("org.pi4soa.service.test.designer.view");
+
+ private Object m_targetClass=null;
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/model/ModelSupport.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/model/ModelSupport.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/model/ModelSupport.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,202 @@
+/*
+ * Copyright 2005-7 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * 16 Feb 2007 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.model;
+
+import java.util.logging.Logger;
+import org.savara.scenario.model.*;
+
+public class ModelSupport {
+
+ public static java.util.List<Event> getChildren(Object component) {
+ java.util.List<Event> ret=null;
+
+ if (component instanceof Scenario) {
+ ret = ((Scenario)component).getEvents();
+ } else if (component instanceof Group) {
+ ret = ((Group)component).getEvents();
+ }
+
+ return(ret);
+ }
+
+ public static Object getParent(Object component) {
+ Object ret=null;
+
+ // TODO: GPB: how to get parent???
+
+ /*
+ if (component instanceof org.eclipse.emf.ecore.EObject) {
+ ret = ((org.eclipse.emf.ecore.EObject)component).eContainer();
+ //} else if (component instanceof Participant) {
+ // ret = ((Participant)component).getDiagram();
+ }
+ */
+
+ return(ret);
+ }
+
+ public static int getChildIndex(Object parent, Object child) {
+ int ret=0;
+
+ if (child instanceof Role) {
+ // TODO: GPB: Need to get scenario??
+ //ret = ((Participant)child).getScenario().
+ // getParticipants().indexOf(child);
+ } else {
+ java.util.List children=getChildren(parent);
+
+ ret = children.indexOf(child);
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method adds a new child to the parent.
+ *
+ * @param parent The parent
+ * @param child The child
+ * @param index The index of the new child
+ */
+ public static void addChild(Object parent, Object child,
+ int index) {
+
+ if (parent != null && child != null) {
+ java.util.List list=null;
+
+ if (child instanceof Role && parent instanceof Scenario) {
+ list = ((Scenario)parent).getRoles();
+ } else {
+ list = getChildren(parent);
+ }
+
+ if (list != null) {
+
+ if (index == -1 || index > list.size()) {
+ list.add(child);
+ } else {
+ list.add(index, child);
+ }
+
+ } else {
+ logger.severe("DON'T KNOW HOW TO ADD: child class="+child+
+ " to parent="+parent);
+ }
+ }
+ }
+
+ /**
+ * This method removes a child from the parent.
+ *
+ * @param parent The parent
+ * @param child The child
+ */
+ public static void removeChild(Object parent, Object child) {
+
+ if (parent != null && child != null) {
+ java.util.List list=null;
+
+ if (parent instanceof Scenario &&
+ child instanceof Role) {
+
+ // TODO: GPB: Need to get scenario???
+ //list = ((Role)child).getScenario().getParticipants();
+ } else {
+ list = getChildren(parent);
+ }
+
+ if (list != null) {
+ list.remove(child);
+
+ } else {
+ logger.severe("DON'T KNOW HOW TO REMOVE: child class="+child+
+ " to parent="+parent);
+ }
+ }
+ }
+
+ public static boolean isValidTarget(Object child, Object parent) {
+ boolean ret=false;
+
+ if ((parent instanceof Scenario ||
+ parent instanceof Group) &&
+ child instanceof Role) {
+ ret = true;
+ } else if ((parent instanceof Scenario ||
+ parent instanceof Group) &&
+ child instanceof Event) {
+ ret = true;
+ } else if ((parent instanceof Scenario || parent
+ instanceof Group) &&
+ child instanceof Link) {
+ ret = true;
+ }
+
+ logger.info("Is valid target: parent="+parent+" child="+child+" ret="+ret);
+
+ return(ret);
+ }
+
+ public static java.util.List getSourceConnections(Object component) {
+ java.util.List ret=new java.util.Vector();
+
+ if (component instanceof MessageEvent) {
+ /* TODO: GPB: Need to get scenario???
+ Scenario scenario = ((MessageEvent)component).getScenario();
+
+ java.util.List links=scenario.getLinks();
+
+ for (int i=0; i < links.size(); i++) {
+ Link link=(Link)links.get(i);
+
+ if (link.getSource() == component) {
+ ret.add(link);
+ }
+ }
+ */
+ }
+
+ return(ret);
+ }
+
+ public static java.util.List getTargetConnections(Object component) {
+ java.util.List ret=new java.util.Vector();
+
+ if (component instanceof MessageEvent) {
+ /* TODO: GPB: Need to get scenario???
+ Scenario scenario = ((MessageEvent)component).getScenario();
+
+ java.util.List links=scenario.getLinks();
+
+ for (int i=0; i < links.size(); i++) {
+ Link link=(Link)links.get(i);
+
+ if (link.getTarget() == component) {
+ ret.add(link);
+ }
+ }
+ */
+ }
+
+ return(ret);
+ }
+
+ private static Logger logger = Logger.getLogger("org.pi4soa.service.test.designer.model");
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/model/ScenarioDiagram.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/model/ScenarioDiagram.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/model/ScenarioDiagram.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2005-6 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * 15 Feb 2007 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.model;
+
+import org.eclipse.draw2d.geometry.Point;
+import org.savara.tools.scenario.designer.parts.ScenarioBaseEditPart;
+
+
+public interface ScenarioDiagram {
+
+ public int getHeight();
+
+ public void update();
+
+ public org.savara.scenario.model.Scenario getScenario();
+
+ public ScenarioBaseEditPart findEditPartAtLocation(Point loc,
+ Class modelClass);
+
+ public org.savara.tools.scenario.designer.simulate.ScenarioSimulation getSimulation();
+
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/parts/EventEditPart.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/parts/EventEditPart.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/parts/EventEditPart.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,96 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * 15 May, 2008 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.parts;
+
+import org.savara.scenario.model.*;
+import org.savara.tools.scenario.designer.figures.*;
+
+/**
+ * This class provides a 'lifeline item' part.
+ */
+public abstract class EventEditPart extends ScenarioBaseEditPart {
+
+ public EventEditPart(Object elem) {
+ super(elem);
+ }
+
+ public int getXOffset() {
+ return(-10);
+ }
+
+ /* TODO: GPB: Need some way to notify of change
+ public void notifyChanged(Notification notification) {
+ int type = notification.getEventType();
+
+ if (type != Notification.SET) {
+ super.notifyChanged(notification);
+ } else {
+ getFigure().invalidateTree();
+ refresh();
+ getFigure().repaint();
+ }
+ }
+ */
+
+ /**
+ * @see org.eclipse.gef.editparts.AbstractEditPart#refreshVisuals()
+ */
+ protected void refreshVisuals() {
+ ((EventFigure)getFigure()).setErrorExpected(
+ ((Event)getModel()).isErrorExpected());
+
+ super.refreshVisuals();
+ }
+
+ public int getHeight() {
+ int ret=20; //ViewSupport.getHeight(getModel());
+
+ return(ret);
+ }
+
+ public int getWidth() {
+ int ret=30; //ViewSupport.getWidth(getModel());
+
+ return(ret);
+ }
+
+ public void reset() {
+ ((EventFigure)getFigure()).setState(EventFigure.STATE_RESET);
+
+ super.reset();
+ }
+
+ public void processing() {
+ ((EventFigure)getFigure()).setState(EventFigure.STATE_PROCESSING);
+ }
+
+ public void successful() {
+ ((EventFigure)getFigure()).setState(EventFigure.STATE_SUCCESSFUL);
+ }
+
+ public void unsuccessful() {
+ ((EventFigure)getFigure()).setState(EventFigure.STATE_UNSUCCESSFUL);
+ }
+
+ public boolean isUnsuccessful() {
+ return(((EventFigure)getFigure()).getState() ==
+ EventFigure.STATE_UNSUCCESSFUL);
+ }
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/parts/GroupEditPart.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/parts/GroupEditPart.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/parts/GroupEditPart.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,120 @@
+/*
+ * Copyright 2005 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Jul 14, 2005 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.parts;
+
+import java.util.Iterator;
+
+import org.eclipse.draw2d.IFigure;
+import org.savara.tools.scenario.designer.figures.*;
+import org.savara.tools.scenario.designer.simulate.*;
+import org.savara.tools.scenario.designer.view.ViewSupport;
+
+/**
+ * This class represents a sequentially order grouping construct's
+ * edit part.
+ */
+public class GroupEditPart extends StructuredGroupEditPart {
+
+ /**
+ * This is the constructor.
+ *
+ * @param cdlType
+ */
+ public GroupEditPart(Object elem) {
+ super(elem);
+ }
+
+ public int getChildX(ScenarioBaseEditPart child) {
+ int ret=0;
+
+ ret = ViewSupport.getChildXPosition(getModel(),
+ child.getModel(), getScenarioDiagram());
+
+ return(ret);
+ }
+
+ public int getChildY(ScenarioBaseEditPart child) {
+ int ret=0;
+
+ ret = ViewSupport.getChildYPosition(getModel(),
+ child.getModel(), getScenarioDiagram());
+
+ return(ret);
+ }
+
+ protected void refreshChildren() {
+ super.refreshChildren();
+
+ Iterator iter=getChildren().iterator();
+ while (iter.hasNext()) {
+ Object obj=iter.next();
+ if (obj instanceof ScenarioBaseEditPart) {
+ ((ScenarioBaseEditPart)obj).refreshVisuals();
+ ((ScenarioBaseEditPart)obj).refreshChildren();
+ }
+ }
+ }
+
+ /**
+ * @see org.eclipse.gef.examples.flow.parts.StructuredActivityPart#createFigure()
+ */
+ protected IFigure createFigure() {
+ IFigure f=new GroupFigure(null);
+
+ return(f);
+ }
+
+ public void reset() {
+ ((GroupFigure)getFigure()).setState(GroupFigure.STATE_RESET);
+
+ super.reset();
+ }
+
+ public void processing() {
+ ((GroupFigure)getFigure()).setState(GroupFigure.STATE_PROCESSING);
+ }
+
+ public void successful() {
+ boolean unsuccessful=false;
+
+ Iterator iter=getChildren().iterator();
+ while (unsuccessful == false && iter.hasNext()) {
+ Object obj=iter.next();
+ if (obj instanceof SimulationEntity) {
+ unsuccessful = ((SimulationEntity)obj).isUnsuccessful();
+ }
+ }
+
+ if (unsuccessful) {
+ unsuccessful();
+ } else {
+ ((GroupFigure)getFigure()).setState(GroupFigure.STATE_SUCCESSFUL);
+ }
+ }
+
+ public void unsuccessful() {
+ ((GroupFigure)getFigure()).setState(GroupFigure.STATE_UNSUCCESSFUL);
+ }
+
+ public boolean isUnsuccessful() {
+ return(((GroupFigure)getFigure()).getState() ==
+ GroupFigure.STATE_UNSUCCESSFUL);
+ }
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/parts/ImportEditPart.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/parts/ImportEditPart.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/parts/ImportEditPart.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,159 @@
+/*
+ * Copyright 2005-7 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Mar 29, 2007 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.parts;
+
+import org.eclipse.core.runtime.Path;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.part.FileEditorInput;
+import org.savara.scenario.model.*;
+import org.savara.tools.scenario.designer.figures.*;
+import org.savara.tools.scenario.designer.policies.*;
+import org.savara.tools.scenario.designer.view.ViewSupport;
+
+/**
+ * This class provides a time elapse event edit part.
+ */
+public class ImportEditPart extends ScenarioBaseEditPart {
+
+ public ImportEditPart(Object elem) {
+ super(elem);
+ }
+
+ /**
+ * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#createFigure()
+ */
+ protected IFigure createFigure() {
+ IFigure ret=null;
+
+ ret = new ImportFigure(getScenarioDiagram());
+
+ return(ret);
+ }
+
+ /**
+ * @see org.eclipse.gef.editparts.AbstractEditPart#createEditPolicies()
+ */
+ protected void createEditPolicies() {
+ installEditPolicy(EditPolicy.COMPONENT_ROLE, new ScenarioComponentEditPolicy());
+
+ installEditPolicy(EditPolicy.LAYOUT_ROLE,
+ new ScenarioContainerXYLayoutEditPolicy());
+ }
+
+ public void performRequest(org.eclipse.gef.Request request) {
+
+ org.eclipse.gef.EditPartViewer viewer=getRoot().getViewer();
+
+ // GPB: Not the ideal way to get to the workbench, but
+ // quickest for now, using the scenario simulation interface
+ // but need to tidy up and find how an editpart can
+ // more easily navigate to the workbench
+ if (viewer.getEditPartFactory() instanceof ScenarioEditPartsFactory) {
+ ScenarioEditPartsFactory factory=(ScenarioEditPartsFactory)
+ viewer.getEditPartFactory();
+
+ factory.getSimulation().focus(
+ ((Import)getModel()).getUrl(),
+ ((Import)getModel()).getGroup());
+ }
+ }
+
+ /*
+ }
+ int getAnchorOffset() {
+ return 9;
+ }
+ */
+
+ /*
+ protected void performDirectEdit() {
+ if (manager == null) {
+ Label l = (Label)getFigure();
+ manager =
+ new ActivityDirectEditManager(
+ this,
+ TextCellEditor.class,
+ new ActivityCellEditorLocator(l), l);
+ }
+ manager.show();
+ }
+ */
+
+ public int getXOffset() {
+ return(-10);
+ }
+
+ /**
+ * @see org.eclipse.gef.editparts.AbstractEditPart#refreshVisuals()
+ */
+ protected void refreshVisuals() {
+ String text=((Import)getModel()).getUrl();
+
+ if (((Import)getModel()).getGroup() != null) {
+ text += "["+((Import)getModel()).getGroup()+"]";
+ }
+
+ ((ImportFigure)getFigure()).setURL(text);
+
+ ViewSupport.setTooltip(getFigure(), getModel());
+
+ super.refreshVisuals();
+ }
+
+ public int getHeight() {
+ int ret=20; //ViewSupport.getHeight(getModel());
+
+ return(ret);
+ }
+
+ public int getWidth() {
+ int ret=ViewSupport.getWidth(getModel(), getScenarioDiagram());
+
+ return(ret);
+ }
+
+ public void reset() {
+ ((ImportFigure)getFigure()).setState(ImportFigure.STATE_RESET);
+
+ super.reset();
+ }
+
+ public void processing() {
+ ((ImportFigure)getFigure()).setState(ImportFigure.STATE_PROCESSING);
+ }
+
+ public void successful() {
+ ((ImportFigure)getFigure()).setState(ImportFigure.STATE_SUCCESSFUL);
+ }
+
+ public void unsuccessful() {
+ ((ImportFigure)getFigure()).setState(ImportFigure.STATE_UNSUCCESSFUL);
+ }
+
+ public boolean isUnsuccessful() {
+ return(((ImportFigure)getFigure()).getState() ==
+ ImportFigure.STATE_UNSUCCESSFUL);
+ }
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/parts/LinkEditPart.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/parts/LinkEditPart.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/parts/LinkEditPart.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,362 @@
+/*
+ * Copyright 2005-7 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Feb 21, 2007 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.parts;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.RelativeBendpoint;
+import org.eclipse.draw2d.Label;
+import org.eclipse.draw2d.PolylineConnection;
+import org.eclipse.draw2d.PolygonDecoration;
+import org.eclipse.draw2d.ConnectionEndpointLocator;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.editparts.AbstractConnectionEditPart;
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.savara.scenario.model.*;
+import org.savara.tools.scenario.designer.model.ScenarioDiagram;
+import org.savara.tools.scenario.designer.policies.LinkComponentEditPolicy;
+import org.savara.tools.scenario.designer.policies.LinkConnectionEditPolicy;
+import org.savara.tools.scenario.designer.policies.LinkEndpointEditPolicy;
+import org.savara.tools.scenario.designer.policies.LinkSelectionHandlesEditPolicy;
+import org.savara.tools.scenario.designer.simulate.*;
+import org.savara.tools.scenario.designer.view.ViewSupport;
+import org.savara.tools.scenario.designer.view.GraphicalComponent;
+
+/**
+ * This class represents the edit part for the message
+ * link connection.
+ */
+public class LinkEditPart
+ extends AbstractConnectionEditPart
+ implements SimulationEntity {
+
+ /**
+ * @param element
+ */
+ public LinkEditPart(Link element) {
+ super();
+
+ setModel(element);
+ }
+
+ /**
+ * This method returns the scenario diagram associated with
+ * the edit part.
+ *
+ * @return The scenario diagram
+ */
+ public ScenarioDiagram getScenarioDiagram() {
+ ScenarioDiagram ret=null;
+
+ if (getParent() != null) {
+ java.util.List children=getParent().getChildren();
+
+ for (int i=0; ret == null && i < children.size(); i++) {
+ Object child=children.get(i);
+ if (child instanceof ScenarioBaseEditPart) {
+ ret = ((ScenarioBaseEditPart)child).getScenarioDiagram();
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#createFigure()
+ */
+ protected IFigure createFigure() {
+ PolylineConnection connection = new PolylineConnection();
+ PolygonDecoration arrow = new PolygonDecoration();
+ arrow.setTemplate(PolygonDecoration.TRIANGLE_TIP);
+ arrow.setScale(10, 5);
+ connection.setTargetDecoration(arrow);
+
+ m_label = new Label("");
+ m_label.setOpaque(true);
+ m_label.setBackgroundColor(org.eclipse.draw2d.ColorConstants.buttonLightest);
+ m_label.setBorder(new org.eclipse.draw2d.LineBorder());
+ connection.add(m_label, new org.eclipse.draw2d.MidpointLocator(connection, 0));
+
+ //ViewSupport.setTooltip(connection, getModel());
+
+ return(connection);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.editparts.AbstractEditPart#createEditPolicies()
+ */
+ protected void createEditPolicies() {
+ installEditPolicy(EditPolicy.COMPONENT_ROLE,
+ new LinkComponentEditPolicy());
+ installEditPolicy(
+ EditPolicy.CONNECTION_ENDPOINTS_ROLE,
+ new LinkEndpointEditPolicy());
+ installEditPolicy(
+ EditPolicy.CONNECTION_BENDPOINTS_ROLE,
+ new LinkSelectionHandlesEditPolicy());
+ installEditPolicy(EditPolicy.CONNECTION_ROLE,
+ new LinkConnectionEditPolicy());
+ }
+
+ public void setText(String text) {
+ m_label.setText(text);
+ }
+
+ /**
+ * @see org.eclipse.gef.editparts.AbstractEditPart#refreshVisuals()
+ */
+ protected void refreshVisuals() {
+ setText(ViewSupport.getName(getModel(), getScenarioDiagram()));
+
+ if (getTarget() != null && getSource() != null) {
+ PolylineConnection connection=(PolylineConnection)getFigure();
+
+ connection.remove(m_label);
+
+ int diffy=((MessageEventEditPart)getTarget()).getComponentBounds().y -
+ ((MessageEventEditPart)getSource()).getComponentBounds().y;
+ int diffx=((MessageEventEditPart)getTarget()).getComponentBounds().x -
+ ((MessageEventEditPart)getSource()).getComponentBounds().x;
+ //boolean backlink=(diff<0);
+
+
+ diffy = java.lang.Math.abs(diffy);
+
+ if (diffx == 0 || diffy > 50) {
+ int vdist=0;//(backlink ? -10:10);
+ int udist=20;
+
+ if (diffx == 0) {
+ udist = 40;
+ }
+
+ ConnectionEndpointLocator sourceEndpointLocator =
+ new ConnectionEndpointLocator(connection, false);
+ sourceEndpointLocator.setVDistance(vdist);
+ sourceEndpointLocator.setUDistance(udist);
+ connection.add(m_label, sourceEndpointLocator);
+ } else {
+ connection.add(m_label, new org.eclipse.draw2d.MidpointLocator(connection, 0));
+ }
+ }
+
+ refreshBendpoints();
+
+ super.refreshVisuals();
+ }
+
+ public Rectangle getEditPartBounds() {
+ return(getFigure().getBounds());
+ }
+
+ public GraphicalComponent getEditPartParent() {
+ return(null);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.EditPart#activate()
+ */
+ public void activate() {
+ /*
+ ((Link)getModel()).eAdapters().add(m_adapter);
+
+ if (((Link)getModel()).getTarget() != null) {
+ ((Link)getModel()).getTarget().eAdapters().add(m_adapter);
+ }
+
+ if (((MessageLink)getModel()).getSource() != null) {
+ ((MessageLink)getModel()).getSource().eAdapters().add(m_adapter);
+ }
+ */
+
+ super.activate();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.EditPart#deactivate()
+ */
+ public void deactivate() {
+ /*
+ ((MessageLink)getModel()).eAdapters().remove(m_adapter);
+
+ if (((MessageLink)getModel()).getTarget() != null) {
+ ((MessageLink)getModel()).getTarget().eAdapters().remove(m_adapter);
+ }
+
+ if (((MessageLink)getModel()).getSource() != null) {
+ ((MessageLink)getModel()).getSource().eAdapters().remove(m_adapter);
+ }
+ */
+
+ super.deactivate();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.emf.common.notify.Adapter#setTarget(org.eclipse.emf.common.notify.Notifier)
+ */
+ /*
+ public void setTarget(Notifier newTarget) {
+ }
+ */
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
+ */
+ public Object getAdapter(Class key)
+ {
+ /* override the default behavior defined in AbstractEditPart
+ * which would expect the model to be a property sourced.
+ * instead the editpart can provide a property source
+ */
+ if (IPropertySource.class == key)
+ {
+ return getPropertySource();
+ }
+ return super.getAdapter(key);
+ }
+
+ /* (non-Javadoc)
+ * @see com.ibm.itso.sal330r.gefdemo.edit.WorkflowElementEditPart#getPropertySource()
+ */
+ protected IPropertySource getPropertySource() {
+ if (propertySource == null) {
+ propertySource = new org.savara.tools.scenario.designer.view.LinkPropertySource(
+ (org.savara.scenario.model.Link)getModel());
+ }
+
+ return propertySource;
+ }
+
+
+ public int getLogEndPosition() {
+ if (getTarget() == null) {
+ return(-1);
+ }
+ return(((SimulationEntity)getTarget()).getLogEndPosition());
+ }
+
+ public int getLogStartPosition() {
+ if (getSource() == null) {
+ return(-1);
+ }
+ return(((SimulationEntity)getSource()).getLogStartPosition());
+ }
+
+ public boolean isUnsuccessful() {
+ return false;
+ }
+
+ public void processing() {
+ }
+
+ public void reset() {
+ }
+
+ public void setLogEndPosition(int pos) {
+ }
+
+ public void setLogStartPosition(int pos) {
+ }
+
+ public void successful() {
+ }
+
+ public void unsuccessful() {
+ }
+
+ protected void refreshBendpoints() {
+ java.util.List figureConstraint = new java.util.ArrayList();
+
+ if (getTarget() != null && getSource() != null) {
+ if (((MessageEventEditPart)getTarget()).getComponentBounds().x ==
+ ((MessageEventEditPart)getSource()).getComponentBounds().x) {
+ int height=((MessageEventEditPart)getTarget()).getComponentBounds().y -
+ ((MessageEventEditPart)getSource()).getComponentBounds().y;
+ int inset=60;
+
+ RelativeBendpoint rbp = new RelativeBendpoint(getConnectionFigure());
+ rbp.setRelativeDimensions(new org.eclipse.draw2d.geometry.Dimension(inset, 0),
+ new org.eclipse.draw2d.geometry.Dimension(inset, -height));
+ //rbp.setWeight((i+1) / ((float)modelConstraint.size()+1));
+ rbp.setWeight(1);
+ figureConstraint.add(rbp);
+
+ rbp = new RelativeBendpoint(getConnectionFigure());
+ rbp.setRelativeDimensions(new org.eclipse.draw2d.geometry.Dimension(inset, height),
+ new org.eclipse.draw2d.geometry.Dimension(inset, 0));
+ //rbp.setWeight((i+1) / ((float)modelConstraint.size()+1));
+ rbp.setWeight(1);
+ figureConstraint.add(rbp);
+ }
+ }
+
+ getConnectionFigure().setRoutingConstraint(figureConstraint);
+
+ getConnectionFigure().repaint();
+ getConnectionFigure().revalidate();
+ }
+
+ private IPropertySource propertySource = null;
+ private Label m_label=null;
+
+ /* TODO: GPB: Need way to setup a list for change
+ private MessageLinkAdapter m_adapter=new MessageLinkAdapter();
+
+ private class MessageLinkAdapter implements Adapter {
+ Notifier newTarget;
+
+ public Notifier getTarget()
+ {
+ return newTarget;
+ }
+
+ public boolean isAdapterForType(Object type)
+ {
+ return getModel().getClass() == type;
+ }
+
+ public void notifyChanged(Notification notification) {
+ if (notification.getEventType() == Notification.SET) {
+/*
+ int featureId =
+ notification.getFeatureID(WorkflowPackage.class);
+
+ // TODO: need to handle edge reattachments here?
+ switch (featureId)
+ {
+ case WorkflowPackage.EDGE__SOURCE :
+ break;
+ case WorkflowPackage.EDGE__TARGET :
+ break;
+ }
+ */
+ /*
+ refreshVisuals();
+ }
+ }
+
+ public void setTarget(Notifier newTarget)
+ {
+ this.newTarget = newTarget;
+ }
+ }
+ */
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/parts/MessageEventEditPart.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/parts/MessageEventEditPart.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/parts/MessageEventEditPart.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,350 @@
+/*
+ * Copyright 2005 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Jul 14, 2005 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.parts;
+
+import org.eclipse.draw2d.ConnectionAnchor;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.Label;
+import org.eclipse.draw2d.PositionConstants;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.gef.ConnectionEditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.requests.DropRequest;
+import org.savara.scenario.model.*;
+import org.savara.tools.scenario.designer.figures.*;
+import org.savara.tools.scenario.designer.model.ModelSupport;
+import org.savara.tools.scenario.designer.policies.ConnectableMessageEventEditPolicy;
+import org.savara.tools.scenario.designer.policies.ScenarioComponentEditPolicy;
+import org.savara.tools.scenario.designer.policies.ScenarioContainerXYLayoutEditPolicy;
+import org.savara.tools.scenario.designer.view.ViewSupport;
+
+/**
+ * This class provides a simple type part.
+ */
+public class MessageEventEditPart extends ScenarioBaseEditPart
+ implements org.eclipse.gef.NodeEditPart {
+
+ public MessageEventEditPart(Object elem) {
+ super(elem);
+ }
+
+ /**
+ * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#createFigure()
+ */
+ protected IFigure createFigure() {
+ IFigure ret=null;
+ org.savara.scenario.model.MessageEvent me=
+ (org.savara.scenario.model.MessageEvent)getModel();
+
+ if (me instanceof SendEvent) {
+ ret = new SendMessageEventFigure();
+ } else {
+ ret = new ReceiveMessageEventFigure();
+ }
+
+ return(ret);
+ }
+
+ /**
+ * @see org.eclipse.gef.editparts.AbstractEditPart#createEditPolicies()
+ */
+ protected void createEditPolicies() {
+ installEditPolicy(EditPolicy.COMPONENT_ROLE, new ScenarioComponentEditPolicy());
+
+ installEditPolicy(EditPolicy.LAYOUT_ROLE,
+ new ScenarioContainerXYLayoutEditPolicy());
+
+ installEditPolicy(org.eclipse.gef.EditPolicy.GRAPHICAL_NODE_ROLE,
+ new ConnectableMessageEventEditPolicy());
+
+ //installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new ActivityNodeEditPolicy());
+ //installEditPolicy(EditPolicy.CONTAINER_ROLE, new ActivitySourceEditPolicy());
+ //installEditPolicy(EditPolicy.COMPONENT_ROLE, new ActivityEditPolicy());
+ //installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new ActivityDirectEditPolicy());
+ }
+
+ /*
+ int getAnchorOffset() {
+ return 9;
+ }
+ */
+
+ /*
+ protected void performDirectEdit() {
+ if (manager == null) {
+ Label l = (Label)getFigure();
+ manager =
+ new ActivityDirectEditManager(
+ this,
+ TextCellEditor.class,
+ new ActivityCellEditorLocator(l), l);
+ }
+ manager.show();
+ }
+ */
+
+ public int getXOffset() {
+ return(-10);
+ }
+
+ /* TODO: GPB: Way to handle notification
+ public void notifyChanged(Notification notification) {
+ int type = notification.getEventType();
+
+ if (type != Notification.SET) {
+ super.notifyChanged(notification);
+ } else {
+ getFigure().invalidateTree();
+ refresh();
+ getFigure().repaint();
+ }
+ }
+ */
+
+ /**
+ * @see org.eclipse.gef.editparts.AbstractEditPart#refreshVisuals()
+ */
+ protected void refreshVisuals() {
+ //((Label)getFigure()).setText(ViewSupport.getName(getModel()));
+
+ //((Label)getFigure()).setIcon(ViewSupport.getImage(getModel()));
+ ((MessageEventFigure)getFigure()).setErrorExpected(
+ ((MessageEvent)getModel()).isErrorExpected());
+
+ for (int i=0; i < getSourceConnections().size(); i++) {
+ if (getSourceConnections().get(i) instanceof LinkEditPart) {
+ ((LinkEditPart)getSourceConnections().get(i)).refreshBendpoints();
+ }
+ }
+
+ ViewSupport.setTooltip(getFigure(), getModel());
+
+ super.refreshVisuals();
+ }
+
+ public int getHeight() {
+ int ret=20; //ViewSupport.getHeight(getModel());
+
+ return(ret);
+ }
+
+ public int getWidth() {
+ int ret=30; //ViewSupport.getWidth(getModel());
+
+ return(ret);
+ }
+
+ public org.eclipse.gef.EditPart findEditPartForModel(Object model) {
+ org.eclipse.gef.EditPart ret=null;
+
+ if (model instanceof Link) {
+ // Check the source and target links for this
+ // message event
+ java.util.List list=getSourceConnections();
+
+ for (int i=0; ret == null && i < list.size(); i++) {
+ ret = (org.eclipse.gef.EditPart)list.get(i);
+
+ if (ret.getModel() != model) {
+ ret = null;
+ }
+ }
+
+ list=getTargetConnections();
+
+ for (int i=0; ret == null && i < list.size(); i++) {
+ ret = (org.eclipse.gef.EditPart)list.get(i);
+
+ if (ret.getModel() != model) {
+ ret = null;
+ }
+ }
+ }
+
+ if (ret == null) {
+ ret = super.findEditPartForModel(model);
+ }
+
+ return(ret);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#getModelSourceConnections()
+ */
+ protected java.util.List getModelSourceConnections() {
+ return(ModelSupport.getSourceConnections(getModel()));
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#getModelTargetConnections()
+ */
+ protected java.util.List getModelTargetConnections() {
+ return(ModelSupport.getTargetConnections(getModel()));
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.NodeEditPart#getSourceConnectionAnchor(org.eclipse.gef.ConnectionEditPart)
+ */
+ public ConnectionAnchor getSourceConnectionAnchor(ConnectionEditPart connection) {
+ return(((MessageEventFigure)getFigure()).getConnectionAnchor());
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.NodeEditPart#getSourceConnectionAnchor(org.eclipse.gef.Request)
+ */
+ public ConnectionAnchor getSourceConnectionAnchor(Request request) {
+ ConnectionAnchor ret=null;
+
+ if (((org.savara.scenario.model.MessageEvent)getModel()) instanceof SendEvent) {
+ Point pt = new Point(((DropRequest) request).getLocation());
+
+ // TODO: ISSUE - if figure is outside normal scroll region,
+ // then this 'contains' check will not work, as the point
+ // is based on the location within the viewport
+ if (getFigure() != null &&
+ getFigure().getBounds().contains(pt)) {
+ ret = ((MessageEventFigure)getFigure()).getConnectionAnchor();
+ }
+ }
+
+ return(ret);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.NodeEditPart#getSourceConnectionAnchor(org.eclipse.gef.Request)
+ */
+ public ConnectionAnchor getSourceConnectionAnchor() {
+ ConnectionAnchor ret=((MessageEventFigure)getFigure()).getConnectionAnchor();
+ return(ret);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.NodeEditPart#getTargetConnectionAnchor(org.eclipse.gef.ConnectionEditPart)
+ */
+ public ConnectionAnchor getTargetConnectionAnchor(ConnectionEditPart connection) {
+ return(((MessageEventFigure)getFigure()).getConnectionAnchor());
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.NodeEditPart#getTargetConnectionAnchor(org.eclipse.gef.Request)
+ */
+ public ConnectionAnchor getTargetConnectionAnchor(Request request) {
+ Point pt = new Point(((DropRequest) request).getLocation());
+
+ // TODO: ISSUE - if figure is outside normal scroll region,
+ // then this 'contains' check will not work, as the point
+ // is based on the location within the viewport
+ if (getFigure() != null &&
+ getFigure().getBounds().contains(pt)) {
+ return(((MessageEventFigure)getFigure()).getConnectionAnchor());
+ }
+ return(null);
+ }
+
+ public ConnectionAnchor getTargetConnectionAnchor() {
+ return(((MessageEventFigure)getFigure()).getConnectionAnchor());
+ }
+
+ protected org.eclipse.gef.ConnectionEditPart createConnection(Object model) {
+ org.eclipse.gef.ConnectionEditPart ret=super.createConnection(model);
+
+ // Highlight this connection
+ getViewer().select(ret);
+
+ return(ret);
+ }
+
+ public void reset() {
+ ((MessageEventFigure)getFigure()).setState(MessageEventFigure.STATE_RESET);
+
+ refreshLinks();
+
+ super.reset();
+ }
+
+ public void processing() {
+ ((MessageEventFigure)getFigure()).setState(MessageEventFigure.STATE_PROCESSING);
+ }
+
+ public void successful() {
+ ((MessageEventFigure)getFigure()).setState(MessageEventFigure.STATE_SUCCESSFUL);
+
+ refreshLinks();
+ }
+
+ public void unsuccessful() {
+ ((MessageEventFigure)getFigure()).setState(MessageEventFigure.STATE_UNSUCCESSFUL);
+
+ refreshLinks();
+ }
+
+ public boolean isUnsuccessful() {
+ return(((MessageEventFigure)getFigure()).getState() ==
+ MessageEventFigure.STATE_UNSUCCESSFUL);
+ }
+
+ protected void refreshLinks() {
+
+ // Refresh any message links
+ java.util.List links=null;
+
+ /* Not at present, as this may cause the link info
+ * to be derived twice - after both the source and target
+ * message events have been set
+ links = getSourceConnections();
+ for (int i=0; i < links.size(); i++) {
+ MessageLinkEditPart ep=(MessageLinkEditPart)links.get(i);
+
+ org.pi4soa.service.test.designer.model.MessageLinkInfo info=
+ (org.pi4soa.service.test.designer.model.MessageLinkInfo)
+ org.pi4soa.scenario.ScenarioManager.getCachedInformation(
+ org.pi4soa.service.test.designer.model.MessageLinkInfo.class, ep.getModel());
+
+ if (info != null) {
+ info.refresh();
+ }
+ }
+ */
+
+ /* GPB: Commented out as not using message link info now
+ boolean f_update=false;
+
+ links = getTargetConnections();
+ for (int i=0; i < links.size(); i++) {
+ LinkEditPart ep=(LinkEditPart)links.get(i);
+
+ org.savara.tools.scenario.designer.model.MessageLinkInfo info=
+ (org.savara.tools.scenario.designer.model.MessageLinkInfo)
+ org.pi4soa.scenario.ScenarioManager.getCachedInformation(
+ org.savara.tools.scenario.designer.model.MessageLinkInfo.class, ep.getModel());
+
+ if (info != null) {
+ info.refresh();
+ f_update = true;
+ }
+ }
+
+ if (f_update) {
+ getScenarioDiagram().update();
+ }
+ */
+ }
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/parts/RoleEditPart.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/parts/RoleEditPart.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/parts/RoleEditPart.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,279 @@
+/*
+ * Copyright 2005 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Jul 14, 2005 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.parts;
+
+import java.beans.PropertyChangeEvent;
+
+import org.eclipse.draw2d.ConnectionAnchor;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.Label;
+import org.eclipse.draw2d.PositionConstants;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.gef.ConnectionEditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.requests.DropRequest;
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.savara.scenario.model.*;
+import org.savara.tools.scenario.designer.figures.*;
+import org.savara.tools.scenario.designer.model.*;
+import org.savara.tools.scenario.designer.policies.*;
+import org.savara.tools.scenario.designer.view.ViewSupport;
+
+/**
+ * This class provides a simple type part.
+ */
+public class RoleEditPart extends ScenarioBaseEditPart
+ implements org.eclipse.gef.NodeEditPart {
+
+ public RoleEditPart(Object elem) {
+ super(elem);
+ }
+
+ /**
+ * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#createFigure()
+ */
+ protected IFigure createFigure() {
+ IFigure ret=null;
+
+ ret = new RoleFigure();
+
+ ((RoleFigure)ret).setText(ViewSupport.getName(getModel(), getScenarioDiagram()));
+
+ return(ret);
+ }
+
+ /**
+ * @see org.eclipse.gef.editparts.AbstractEditPart#createEditPolicies()
+ */
+ protected void createEditPolicies() {
+ installEditPolicy(EditPolicy.COMPONENT_ROLE, new ScenarioComponentEditPolicy());
+ //installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new ActivityNodeEditPolicy());
+ //installEditPolicy(EditPolicy.CONTAINER_ROLE, new ActivitySourceEditPolicy());
+ //installEditPolicy(EditPolicy.COMPONENT_ROLE, new ActivityEditPolicy());
+ //installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new ActivityDirectEditPolicy());
+
+ installEditPolicy(org.eclipse.gef.EditPolicy.GRAPHICAL_NODE_ROLE,
+ new ConnectableRoleEditPolicy());
+ }
+
+ int getAnchorOffset() {
+ return 9;
+ }
+
+ /*
+ protected void performDirectEdit() {
+ if (manager == null) {
+ Label l = (Label)getFigure();
+ manager =
+ new ActivityDirectEditManager(
+ this,
+ TextCellEditor.class,
+ new ActivityCellEditorLocator(l), l);
+ }
+ manager.show();
+ }
+ */
+
+ public int getXOffset() {
+ //return(7);
+ int ret=-((getWidth() - 10)/2);
+
+ return(ret);
+ }
+
+ /**
+ * This is the property change notification method.
+ *
+ */
+ public void propertyChange(PropertyChangeEvent evt) {
+ super.propertyChange(evt);
+
+ int index=ViewSupport.getNearestParticipantIndex(getX(),
+ getScenarioDiagram());
+
+ // Recursively find all message event objects and update
+ // the values associated with the objects in this column
+ ScenarioBaseEditPart ep=(ScenarioBaseEditPart)getParent();
+
+ Role participant=(Role)getModel();
+
+ updateParticipant(ep, index, participant);
+ }
+
+ protected void updateParticipant(ScenarioBaseEditPart ep, int index,
+ Role participant) {
+ java.util.List children=ep.getChildren();
+
+ for (int i=0; i < children.size(); i++) {
+ if (children.get(i) instanceof ScenarioBaseEditPart) {
+ ScenarioBaseEditPart subep=
+ (ScenarioBaseEditPart)children.get(i);
+
+ if (subep instanceof MessageEventEditPart) {
+ org.savara.scenario.model.MessageEvent me=
+ (org.savara.scenario.model.MessageEvent)
+ ((MessageEventEditPart)subep).getModel();
+
+ // Use last known location, rather than
+ // subep.getX(), as this method return potential
+ // an incorrect value based on the new location
+ // which may not be valid, if the participant
+ // instance is being renamed.
+ if (ViewSupport.getNearestParticipantIndex(subep.getFigure().getBounds().x,
+ getScenarioDiagram()) == index) {
+ me.setRole(participant);
+ }
+
+ } else {
+ updateParticipant(subep, index, participant);
+ }
+ }
+ }
+ }
+
+ /**
+ * @see org.eclipse.gef.editparts.AbstractEditPart#refreshVisuals()
+ */
+ protected void refreshVisuals() {
+
+ ((RoleFigure)getFigure()).setText(
+ ViewSupport.getName(getModel(), getScenarioDiagram()));
+
+ // Update the participant header width according to the
+ // width of the participant (governed by the text
+ // associated with the participant).
+ org.eclipse.draw2d.geometry.Dimension dim=
+ ((RoleFigure)getFigure()).getPreferredSize();
+
+ dim.width = getWidth();
+
+ ((RoleFigure)getFigure()).setPreferredSize(dim);
+
+ /*
+ ((ParticipantFigure)getFigure()).setText(ViewSupport.getName(getModel()));
+ ((Label)((ParticipantFigure)getFigure()).getHeader()).setPreferredSize(100, 40);
+ ((Label)((ParticipantFigure)getFigure()).getHeader()).setSize(100, 40);
+ ((Label)((ParticipantFigure)getFigure()).getHeader()).setBounds(new org.eclipse.draw2d.geometry.Rectangle(0, 0, 100, 40));
+ ((Label)((ParticipantFigure)getFigure()).getHeader()).setLabelAlignment(org.eclipse.draw2d.PositionConstants.CENTER);
+ */
+ //((ParticipantFigure)getFigure()).setBounds(new org.eclipse.draw2d.geometry.Rectangle(0, 0, 100, 40));
+ super.refreshVisuals();
+ }
+
+ public int getHeight() {
+ int ret=getScenarioDiagram().getHeight();
+
+ ret -= ViewSupport.PARTICIPANT_PADDING_Y*2 +
+ ViewSupport.getHeaderPadding(getScenarioDiagram().getScenario());
+
+ return(ret);
+ }
+
+ public int getWidth() {
+ //int ret=100; //ViewSupport.getWidth(getModel());
+ int ret=ViewSupport.getWidth(getModel(), getScenarioDiagram());
+
+ return(ret);
+ }
+
+ /* (non-Javadoc)
+ * @see com.ibm.itso.sal330r.gefdemo.edit.WorkflowElementEditPart#getPropertySource()
+ */
+ protected IPropertySource getPropertySource() {
+ if (propertySource == null) {
+ propertySource = new org.savara.tools.scenario.designer.view.RolePropertySource(
+ (org.savara.scenario.model.Role)getModel());
+ }
+
+ return propertySource;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.NodeEditPart#getSourceConnectionAnchor(org.eclipse.gef.ConnectionEditPart)
+ */
+ public ConnectionAnchor getSourceConnectionAnchor(ConnectionEditPart connection) {
+ return(((RoleFigure)getFigure()).getConnectionAnchor());
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.NodeEditPart#getSourceConnectionAnchor(org.eclipse.gef.Request)
+ */
+ public ConnectionAnchor getSourceConnectionAnchor(Request request) {
+ ConnectionAnchor ret=null;
+
+ //if (((Participant)getModel()).getDirection()
+ // == org.pi4soa.scenario.MessageDirection.SEND) {
+ Point pt = new Point(((DropRequest) request).getLocation());
+
+ // TODO: ISSUE - if figure is outside normal scroll region,
+ // then this 'contains' check will not work, as the point
+ // is based on the location within the viewport
+ if (getFigure() != null &&
+ getFigure().getBounds().contains(pt)) {
+ pt.x = getFigure().getBounds().x +
+ (getWidth()/2);
+ //ret = ((ParticipantFigure)getFigure()).getConnectionAnchor();
+ ret = new org.eclipse.draw2d.XYAnchor(pt);
+ }
+ //}
+
+ return(ret);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.NodeEditPart#getSourceConnectionAnchor(org.eclipse.gef.Request)
+ */
+ public ConnectionAnchor getSourceConnectionAnchor() {
+ ConnectionAnchor ret=((RoleFigure)getFigure()).getConnectionAnchor();
+ return(ret);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.NodeEditPart#getTargetConnectionAnchor(org.eclipse.gef.ConnectionEditPart)
+ */
+ public ConnectionAnchor getTargetConnectionAnchor(ConnectionEditPart connection) {
+ return(((RoleFigure)getFigure()).getConnectionAnchor());
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.NodeEditPart#getTargetConnectionAnchor(org.eclipse.gef.Request)
+ */
+ public ConnectionAnchor getTargetConnectionAnchor(Request request) {
+ Point pt = new Point(((DropRequest) request).getLocation());
+
+ // TODO: ISSUE - if figure is outside normal scroll region,
+ // then this 'contains' check will not work, as the point
+ // is based on the location within the viewport
+ if (getFigure() != null &&
+ getFigure().getBounds().contains(pt)) {
+// return(((ParticipantFigure)getFigure()).getConnectionAnchor());
+ return(new org.eclipse.draw2d.XYAnchor(pt));
+ }
+
+ return(null);
+ }
+
+ public ConnectionAnchor getTargetConnectionAnchor() {
+ return(((RoleFigure)getFigure()).getConnectionAnchor());
+ }
+
+ private IPropertySource propertySource = null;
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/parts/ScenarioBaseEditPart.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/parts/ScenarioBaseEditPart.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/parts/ScenarioBaseEditPart.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,448 @@
+/*
+ * Copyright 2005 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Jul 14, 2005 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.parts;
+
+import java.beans.PropertyChangeEvent;
+
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.editparts.AbstractGraphicalEditPart;
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.savara.scenario.model.*;
+import org.savara.tools.scenario.designer.model.ScenarioDiagram;
+import org.savara.tools.scenario.designer.simulate.*;
+import org.savara.tools.scenario.designer.view.GraphicalComponent;
+
+/**
+ * The edit part for the generic scenario component.
+ */
+public abstract class ScenarioBaseEditPart extends AbstractGraphicalEditPart
+ implements java.beans.PropertyChangeListener,
+ GraphicalComponent, SimulationEntity {
+
+ /**
+ * This is the default constructor.
+ *
+ * @param element The scenario component
+ */
+ protected ScenarioBaseEditPart(Object element) {
+ setModel(element);
+ }
+
+ /**
+ * This method returns the scenario diagram associated with
+ * the edit part.
+ *
+ * @return The scenario diagram
+ */
+ public ScenarioDiagram getScenarioDiagram() {
+ ScenarioDiagram ret=null;
+
+ if (getParent() instanceof ScenarioBaseEditPart) {
+ ret = ((ScenarioBaseEditPart)getParent()).getScenarioDiagram();
+ }
+
+ return(ret);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#activate()
+ */
+ public void activate() {
+ if (isActive())
+ return;
+
+ // start listening for changes in the model
+ hookIntoScenarioObject(getModel());
+
+ super.activate();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#deactivate()
+ */
+ public void deactivate() {
+ if (!isActive())
+ return;
+
+ // stop listening for changes in the model
+ unhookFromScenarioObject(getModel());
+
+ super.deactivate();
+ }
+
+ protected boolean isContained(Point loc) {
+ boolean ret=false;
+
+ Rectangle r=getBounds();
+ if (r.width == -1) {
+ r = this.getFigure().getBounds();
+ }
+ if (r.contains(loc)) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ protected ScenarioBaseEditPart getEditPartAt(Point loc,
+ Class modelClass) {
+ ScenarioBaseEditPart ret=null;
+ Point newpoint=loc.getTranslated(-getBounds().x,
+ -getBounds().y);
+
+ if (isContained(loc)) {
+
+ // Check if one of the children contains the point
+ java.util.Iterator iter=getChildren().iterator();
+
+ while (ret == null && iter.hasNext()) {
+ ScenarioBaseEditPart part=(ScenarioBaseEditPart)iter.next();
+
+ //Point newpoint=loc.getTranslated(-getChildX(part),
+ // -getChildY(part));
+ //Point newpoint=loc.getTranslated(-part.getBounds().x,
+ // -part.getBounds().y);
+
+ ret = part.getEditPartAt(newpoint, modelClass);
+ }
+
+ if (ret == null && (modelClass == null ||
+ modelClass.isAssignableFrom(getModel().getClass()))) {
+ ret = this;
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method propagates the request up to an appropriate
+ * edit part that can perform the getEditPartAt request.
+ *
+ * @param loc
+ * @return The editpart
+ */
+ /*
+ public ScenarioBaseEditPart findEditPartAtLocation(Point loc) {
+ ScenarioBaseEditPart ret=null;
+
+ if (getParent() instanceof ScenarioBaseEditPart) {
+ ret = ((ScenarioBaseEditPart)getParent()).
+ findEditPartAtLocation(loc);
+ }
+
+ return(ret);
+ }
+ */
+
+ public org.eclipse.gef.EditPart findEditPartForModel(Object model) {
+ org.eclipse.gef.EditPart ret=null;
+
+ if (getModel() == model) {
+ ret = this;
+ } else {
+ java.util.List list=getChildren();
+
+ for (int i=0; ret == null && i < list.size(); i++) {
+ if (list.get(i) instanceof ScenarioBaseEditPart) {
+ ret = ((ScenarioBaseEditPart)list.get(i)).findEditPartForModel(model);
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.emf.common.notify.Adapter#getTarget()
+ */
+ /*
+ public Notifier getTarget() {
+ return target;
+ }
+ */
+
+ /* (non-Javadoc)
+ * @see org.eclipse.emf.common.notify.Adapter#isAdapterForType(java.lang.Object)
+ */
+ public boolean isAdapterForType(Object type) {
+ return type.equals(getModel().getClass());
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.emf.common.notify.Adapter#setTarget(org.eclipse.emf.common.notify.Notifier)
+ */
+ /*
+ public void setTarget(Notifier newTarget) {
+ target = newTarget;
+ }
+ */
+
+ protected void refreshVisuals() {
+ Rectangle r=getComponentBounds();
+
+ ((GraphicalEditPart) getParent()).setLayoutConstraint(
+ this, getFigure(), r);
+ }
+
+ protected void refreshChildren() {
+ super.refreshChildren();
+ }
+
+ public int getWidth() {
+ return(-1);
+ }
+
+ public int getHeight() {
+ return(-1);
+ }
+
+ public int getXOffset() {
+ return(0);
+ }
+
+ protected boolean useLocalCoordinates() {
+ return(true);
+ }
+
+ public int getX() {
+ int ret=20;
+
+ if (getParent() instanceof ScenarioBaseEditPart) {
+ ret = ((ScenarioBaseEditPart)getParent()).getChildX(this);
+ }
+
+ ret += getXOffset();
+
+ return(ret);
+ }
+
+ public int getY() {
+ int ret=20;
+
+ if (getParent() instanceof ScenarioBaseEditPart) {
+ ret = ((ScenarioBaseEditPart)getParent()).getChildY(this);
+ }
+
+ return(ret);
+ }
+
+ public int getChildX(ScenarioBaseEditPart child) {
+ return(20);
+ }
+
+ public int getChildY(ScenarioBaseEditPart child) {
+ return(20);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
+ */
+ public Object getAdapter(Class key)
+ {
+ /* override the default behavior defined in AbstractEditPart
+ * which would expect the model to be a property sourced.
+ * instead the editpart can provide a property source
+ */
+ if (IPropertySource.class == key)
+ {
+ return getPropertySource();
+ }
+ return super.getAdapter(key);
+ }
+
+ /* (non-Javadoc)
+ * @see com.ibm.itso.sal330r.gefdemo.edit.WorkflowElementEditPart#getPropertySource()
+ */
+ protected IPropertySource getPropertySource() {
+ if (propertySource == null) {
+ propertySource = new org.savara.tools.scenario.designer.view.ScenarioPropertySource(getModel());
+ }
+
+ return propertySource;
+ }
+
+ /* TODO: GPB notification
+ public void notifyChanged(Notification notification) {
+ int type = notification.getEventType();
+
+ switch (type) {
+ case Notification.ADD :
+ case Notification.ADD_MANY :
+ case Notification.REMOVE :
+ case Notification.REMOVE_MANY :
+
+ // Refresh parent parts
+ ScenarioBaseEditPart part=this;
+ while (part != null) {
+
+ part.refreshChildren();
+ part.refreshVisuals();
+
+ // Refresh visuals for immediate children
+ java.util.Iterator iter=part.getChildren().iterator();
+ while (iter.hasNext()) {
+ Object obj=iter.next();
+
+ if (obj instanceof ScenarioBaseEditPart) {
+ ((ScenarioBaseEditPart)obj).refreshVisuals();
+ }
+ }
+
+ if (part.getParent() instanceof ScenarioBaseEditPart) {
+ part = (ScenarioBaseEditPart)part.getParent();
+ } else {
+ part = null;
+ }
+ }
+ break;
+
+ case Notification.SET :
+ refreshVisuals();
+ break;
+ }
+ }
+ */
+
+ /**
+ * This is the property change notification method.
+ *
+ */
+ public void propertyChange(PropertyChangeEvent evt) {
+ refreshVisuals();
+ }
+
+ /**
+ * Registers this edit part as a listener for change notifications
+ * to the specified workflow element.
+ *
+ * @param element the worklfow element that should be observed
+ * for change notifications
+ */
+ protected void hookIntoScenarioObject(Object element) {
+ /* TODO: GPB: How to listen for changes?
+ if (element instanceof org.eclipse.emf.ecore.EObject) {
+ ((org.eclipse.emf.ecore.EObject)element).eAdapters().add(this);
+ } else if (element instanceof org.savara.tools.scenario.designer.model.Bean) {
+ ((org.savara.tools.scenario.designer.model.Bean)element).addPropertyChangeListener(this);
+ }
+ */
+ }
+
+ /**
+ * Removes this edit part from the specified workflow element.
+ * Thus, it will no longe receive change notifications.
+ *
+ * @param element the worklfow element that should not be observed
+ * any more
+ */
+ protected void unhookFromScenarioObject(Object element) {
+ /* TODO: GPB: How to listen for changes?
+ if (element instanceof org.eclipse.emf.ecore.EObject) {
+ ((org.eclipse.emf.ecore.EObject)element).eAdapters().remove(this);
+ }
+ */
+ }
+
+ public Rectangle getComponentBounds() {
+ Rectangle ret=new Rectangle(getX(), getY(), getWidth(),
+ getHeight());
+
+ return(ret);
+ }
+
+ public Rectangle getBounds() {
+ return(getComponentBounds());
+ }
+
+ public GraphicalComponent getComponentParent() {
+ GraphicalComponent ret=null;
+
+ if (getParent() instanceof GraphicalComponent) {
+ ret = (GraphicalComponent)getParent();
+ }
+
+ return(ret);
+ }
+
+ protected void propagateConnectionRefresh(ScenarioBaseEditPart part) {
+ refreshSourceConnections();
+ refreshTargetConnections();
+
+ java.util.Iterator iter=getChildren().iterator();
+ while (iter.hasNext()) {
+ Object obj=iter.next();
+
+ if (obj instanceof ScenarioBaseEditPart) {
+ ((ScenarioBaseEditPart)part).propagateConnectionRefresh((ScenarioBaseEditPart)obj);
+ }
+ }
+ }
+
+ public void reset() {
+ m_logStartPosition = 0;
+ m_logEndPosition = 0;
+
+ java.util.Iterator iter=getChildren().iterator();
+ while (iter.hasNext()) {
+ Object obj=iter.next();
+
+ if (obj instanceof SimulationEntity) {
+ ((SimulationEntity)obj).reset();
+ }
+ }
+ }
+
+ public void processing() {
+ }
+
+ public void successful() {
+ }
+
+ public void unsuccessful() {
+ }
+
+ public boolean isUnsuccessful() {
+ return(false);
+ }
+
+ public void setLogStartPosition(int pos) {
+ m_logStartPosition = pos;
+ }
+
+ public void setLogEndPosition(int pos) {
+ m_logEndPosition = pos;
+ }
+
+ public int getLogStartPosition() {
+ return(m_logStartPosition);
+ }
+
+ public int getLogEndPosition() {
+ return(m_logEndPosition);
+ }
+
+ private IPropertySource propertySource = null;
+ //private Notifier target;
+ private int m_logStartPosition=0;
+ private int m_logEndPosition=0;
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/parts/ScenarioEditPart.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/parts/ScenarioEditPart.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/parts/ScenarioEditPart.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,352 @@
+/*
+ * Copyright 2005 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Jul 14, 2005 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.parts;
+
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Vector;
+
+import org.eclipse.draw2d.*;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+//import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.editpolicies.RootComponentEditPolicy;
+import org.savara.scenario.model.*;
+import org.savara.tools.scenario.designer.figures.ScenarioFigure;
+import org.savara.tools.scenario.designer.model.*;
+import org.savara.tools.scenario.designer.policies.ScenarioContainerEditPolicy;
+import org.savara.tools.scenario.designer.policies.ScenarioContainerXYLayoutEditPolicy;
+import org.savara.tools.scenario.designer.view.ViewSupport;
+
+/**
+ * This edit part represents the complete choreography description.
+ */
+public class ScenarioEditPart extends ScenarioBaseEditPart
+ implements ScenarioDiagram {
+
+ /**
+ * Creates a new WorkflowEditPart instance.
+ * @param element
+ */
+ protected ScenarioEditPart(org.savara.scenario.model.Scenario scenario,
+ org.savara.tools.scenario.designer.simulate.ScenarioSimulation sim) {
+ super(scenario);
+
+ m_simulation = sim;
+ }
+
+ /**
+ * This method returns the scenario diagram associated with
+ * the edit part.
+ *
+ * @return The scenario diagram
+ */
+ public ScenarioDiagram getScenarioDiagram() {
+ return(this);
+ }
+
+
+ public org.savara.scenario.model.Scenario getScenario() {
+ return((org.savara.scenario.model.Scenario)getModel());
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#createFigure()
+ */
+ protected IFigure createFigure() {
+ FreeformLayer layer = new ScenarioFigure();
+ layer.setLayoutManager(new FreeformLayout());
+ layer.setBorder(new LineBorder(1));
+
+ //ViewSupport.setTooltip(layer, getModel());
+
+ ConnectionLayer cLayer = (ConnectionLayer) getLayer(org.eclipse.gef.LayerConstants.CONNECTION_LAYER);
+
+ BendpointConnectionRouter router=new BendpointConnectionRouter();
+ cLayer.setConnectionRouter(router);
+
+ return layer;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.editparts.AbstractEditPart#createEditPolicies()
+ */
+ protected void createEditPolicies() {
+ installEditPolicy(EditPolicy.CONTAINER_ROLE,
+ new ScenarioContainerEditPolicy());
+ installEditPolicy(EditPolicy.LAYOUT_ROLE,
+ new ScenarioContainerXYLayoutEditPolicy());
+
+ installEditPolicy(EditPolicy.NODE_ROLE, null);
+ installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, null);
+ installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, null);
+ installEditPolicy(EditPolicy.COMPONENT_ROLE, new RootComponentEditPolicy());
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.editparts.AbstractEditPart#getModelChildren()
+ */
+ protected List<Object> getModelChildren() {
+ org.savara.scenario.model.Scenario scenario=
+ (org.savara.scenario.model.Scenario)getModel();
+
+ java.util.List<Object> ret=new java.util.Vector<Object>();
+
+ ret.addAll(scenario.getRoles());
+
+ ret.addAll(scenario.getEvents());
+
+ return(ret);
+ }
+
+ protected void refreshChildren() {
+ super.refreshChildren();
+
+ Iterator<?> iter=getChildren().iterator();
+ while (iter.hasNext()) {
+ Object obj=iter.next();
+ if (obj instanceof ScenarioBaseEditPart) {
+ ((ScenarioBaseEditPart)obj).refreshVisuals();
+ ((ScenarioBaseEditPart)obj).refreshChildren();
+ }
+ }
+ }
+
+ protected void refreshVisuals() {
+ ((ScenarioFigure)getFigure()).setName(getScenario().getName());
+ ((ScenarioFigure)getFigure()).setAuthor(getScenario().getAuthor());
+
+ super.refreshVisuals();
+ }
+
+ protected void refreshMessageLinks() {
+
+ // Need to update the text on all links
+ for (int i=0; i < getScenario().getLinks().size(); i++) {
+ Link link=(Link)
+ getScenario().getLinks().get(i);
+
+ Object ep=findEditPartForModel(link);
+
+ if (ep instanceof LinkEditPart) {
+ ((LinkEditPart)ep).refresh();
+ }
+ }
+ }
+
+ public void update() {
+ refreshChildren();
+
+ refreshMessageLinks();
+ }
+
+ public int getChildX(ScenarioBaseEditPart child) {
+ int ret=20;
+
+ ret = org.savara.tools.scenario.designer.view.ViewSupport.getChildXPosition(getModel(),
+ child.getModel(), getScenarioDiagram());
+
+ return(ret);
+ }
+
+ public int getChildY(ScenarioBaseEditPart child) {
+ int ret=20;
+
+ ret = org.savara.tools.scenario.designer.view.ViewSupport.getChildYPosition(getModel(),
+ child.getModel(), getScenarioDiagram());
+
+ return(ret);
+ }
+
+ public int getHeight() {
+ int ret=ViewSupport.getHeight(getModel(), getScenarioDiagram());
+
+ return(ret);
+ }
+
+ public int getWidth() {
+ int ret=ViewSupport.getWidth(getModel(), getScenarioDiagram());
+
+ return(ret);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.emf.common.notify.Adapter#notifyChanged(org.eclipse.emf.common.notify.Notification)
+ */
+ /* TODO: GPB
+ public void notifyChanged(Notification notification) {
+ int type = notification.getEventType();
+
+ switch( type ) {
+ case Notification.ADD:
+ case Notification.ADD_MANY:
+ refreshVisuals();
+ refreshChildren();
+
+ if (notification.getNewValue() instanceof Link) {
+ // Need to update the text on all links
+ /*
+ for (int i=0; i < getScenario().getMessageLinks().size(); i++) {
+ MessageLink link=(MessageLink)
+ getScenario().getMessageLinks().get(i);
+
+ Object ep=findEditPartForModel(link);
+
+ if (ep instanceof MessageLinkEditPart) {
+ ((MessageLinkEditPart)ep).refresh();
+ }
+ }
+ */
+
+ /*
+ refreshMessageLinks();
+ }
+
+ // Refresh source and target connections on all children
+ propagateConnectionRefresh(this);
+
+ break;
+
+ case Notification.REMOVE_MANY:
+ case Notification.REMOVE:
+ refreshVisuals();
+ refreshChildren();
+
+ if (notification.getOldValue() instanceof Link) {
+ // Need to update the text on all links
+ /*
+ for (int i=0; i < getScenario().getMessageLinks().size(); i++) {
+ MessageLink link=(MessageLink)
+ getScenario().getMessageLinks().get(i);
+
+ Object ep=findEditPartForModel(link);
+
+ if (ep instanceof MessageLinkEditPart) {
+ ((MessageLinkEditPart)ep).refresh();
+ }
+ }
+ */
+ /*
+ refreshMessageLinks();
+ }
+
+ // Refresh source and target connections on all children
+ propagateConnectionRefresh(this);
+
+ break;
+
+ case Notification.SET:
+ refreshVisuals();
+
+ refreshChildren();
+
+ // Refresh source and target connections on all children
+ propagateConnectionRefresh(this);
+ break;
+ }
+ }
+ */
+
+ /**
+ * This method propagates the request up to an appropriate
+ * edit part that can perform the getEditPartAt request.
+ *
+ * @param loc
+ * @param modelClass The optional model class to find
+ * @return The editpart
+ */
+ public ScenarioBaseEditPart findEditPartAtLocation(Point loc,
+ Class modelClass) {
+ ScenarioBaseEditPart ret=null;
+
+ Point newpoint=loc.getTranslated(getBounds().x,
+ getBounds().y);
+
+ ret = getEditPartAt(newpoint, modelClass);
+
+ return(ret);
+ }
+
+ public org.savara.tools.scenario.designer.simulate.ScenarioSimulation getSimulation() {
+ return(m_simulation);
+ }
+
+ public Rectangle getComponentBoundsWithoutIdentityDetails() {
+ return(super.getComponentBounds());
+ }
+
+ public Rectangle getIdentityDetailsBounds() {
+ Rectangle ret=new Rectangle(0, 0, 0, 0);
+
+ return(ret);
+ }
+
+ public Rectangle getComponentBounds() {
+ Rectangle ret=super.getComponentBounds();
+
+ // As ScenarioEditPart is the top level edit part,
+ // we also need to add additional height to take care of
+ // the information displayed below the actual diagram.
+ // This can be moved to a higher level editpart, if
+ // one is created into the future. However the diagram
+ // itself should not be considered to include this
+ // additional information in its dimensions.
+
+ /* GPB: Not showing identity details
+ if (getShowIdentityDetails()) {
+ Rectangle idbounds=getIdentityDetailsBounds();
+
+ ret.height += idbounds.height;
+ if (idbounds.width > ret.width) {
+ ret.width = idbounds.width;
+ }
+
+ /*
+ java.util.List links=getScenario().getMessageLinks();
+
+ for (int i=0; i < links.size(); i++) {
+ MessageLinkInfo info=MessageLinkInfo.getInstance((MessageLink)
+ links.get(i),
+ getScenarioDiagram());
+
+ int height = ViewSupport.getHeight(info, this);
+
+ int width = ViewSupport.getWidth(info, this)+
+ ViewSupport.getChildXPosition(getScenario(),
+ info, this);
+
+ ret.height += height+5; // height + padding
+
+ if (width > ret.width) {
+ ret.width = width;
+ }
+ }
+ */
+ //}
+
+
+ return(ret);
+ }
+
+ private org.savara.tools.scenario.designer.simulate.ScenarioSimulation m_simulation=null;
+ private boolean m_showIdentityDetails=false;
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/parts/ScenarioEditPartsFactory.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/parts/ScenarioEditPartsFactory.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/parts/ScenarioEditPartsFactory.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2005 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Jul 5, 2005 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.parts;
+
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPartFactory;
+
+/**
+ * This is the factory class for the Graphical edit parts.
+ */
+public class ScenarioEditPartsFactory implements EditPartFactory {
+
+ public ScenarioEditPartsFactory(org.savara.tools.scenario.designer.simulate.ScenarioSimulation sim) {
+ m_simulation = sim;
+ }
+
+ /**
+ * This method returns the relevant edit part for the supplied
+ * model component.
+ *
+ * @param context The Edit Part context
+ * @param model The model object
+ * @return The edit part
+ */
+ public EditPart createEditPart(EditPart context, Object model) {
+ EditPart ret=null;
+
+ if (model instanceof org.savara.scenario.model.Scenario) {
+ ret = new ScenarioEditPart((org.savara.scenario.model.Scenario)model,
+ m_simulation);
+ } else if (model instanceof org.savara.scenario.model.Group) {
+ ret = new GroupEditPart(model);
+ } else if (model instanceof org.savara.scenario.model.TimeElapsedEvent) {
+ ret = new TimeElapsedEventEditPart(model);
+ } else if (model instanceof org.savara.scenario.model.Import) {
+ ret = new ImportEditPart(model);
+ } else if (model instanceof org.savara.scenario.model.MessageEvent) {
+ ret = new MessageEventEditPart(model);
+ } else if (model instanceof org.savara.scenario.model.Link) {
+ ret = new LinkEditPart((org.savara.scenario.model.Link)model);
+ } else if (model instanceof org.savara.scenario.model.Role) {
+ ret = new RoleEditPart(model);
+ }
+
+ if (ret == null) {
+ System.out.println("NOT RETURNING PART FOR MODEL = "+model);
+ }
+
+ return(ret);
+ }
+
+ public org.savara.tools.scenario.designer.simulate.ScenarioSimulation getSimulation() {
+ return(m_simulation);
+ }
+
+ private org.savara.tools.scenario.designer.simulate.ScenarioSimulation m_simulation=null;
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/parts/StructuredGroupEditPart.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/parts/StructuredGroupEditPart.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/parts/StructuredGroupEditPart.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,140 @@
+/*
+ * Copyright 2005 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Jul 6, 2005 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.parts;
+
+import java.util.List;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.geometry.Point;
+
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.RequestConstants;
+import org.eclipse.gef.requests.DirectEditRequest;
+import org.eclipse.draw2d.Label;
+import org.savara.tools.scenario.designer.figures.GroupingFigure;
+import org.savara.tools.scenario.designer.model.ModelSupport;
+import org.savara.tools.scenario.designer.policies.ScenarioComponentEditPolicy;
+import org.savara.tools.scenario.designer.policies.ScenarioContainerEditPolicy;
+import org.savara.tools.scenario.designer.policies.ScenarioContainerHighlightEditPolicy;
+import org.savara.tools.scenario.designer.policies.ScenarioContainerXYLayoutEditPolicy;
+import org.savara.tools.scenario.designer.view.ViewSupport;
+
+/**
+ * This edit part represents a structured group of other parts.
+ */
+public abstract class StructuredGroupEditPart extends ScenarioBaseEditPart {
+
+ public StructuredGroupEditPart(Object elem) {
+ super(elem);
+ }
+
+ /**
+ * @see org.eclipse.gef.examples.flow.parts.ActivityPart#createEditPolicies()
+ */
+ protected void createEditPolicies() {
+ installEditPolicy(EditPolicy.COMPONENT_ROLE, new ScenarioComponentEditPolicy());
+ installEditPolicy(
+ EditPolicy.SELECTION_FEEDBACK_ROLE,
+ new ScenarioContainerHighlightEditPolicy());
+
+ installEditPolicy(EditPolicy.CONTAINER_ROLE, new ScenarioContainerEditPolicy());
+ installEditPolicy(EditPolicy.LAYOUT_ROLE, new ScenarioContainerXYLayoutEditPolicy());
+ }
+
+ private boolean directEditHitTest(Point requestLoc) {
+ /*
+ IFigure header = ((GroupFigure)getFigure()).getHeader();
+ header.translateToRelative(requestLoc);
+ if (header.containsPoint(requestLoc))
+ return true;
+ */
+ return false;
+ }
+
+ /**
+ * @see org.eclipse.gef.EditPart#performRequest(org.eclipse.gef.Request)
+ */
+ public void performRequest(Request request) {
+ if (request.getType() == RequestConstants.REQ_DIRECT_EDIT) {
+ if (request instanceof DirectEditRequest
+ && !directEditHitTest(((DirectEditRequest) request)
+ .getLocation()
+ .getCopy()))
+ return;
+ performDirectEdit();
+ }
+ }
+
+ int getAnchorOffset() {
+ return -1;
+ }
+
+ public IFigure getContentPane() {
+ if (getFigure() instanceof GroupingFigure)
+ return ((GroupingFigure)getFigure()).getContents();
+ return getFigure();
+ }
+
+ protected List getModelChildren() {
+ return(ModelSupport.getChildren(getModel()));
+ }
+
+ /**
+ * @see org.eclipse.gef.examples.flow.parts.ActivityPart#performDirectEdit()
+ */
+ protected void performDirectEdit() {
+ /*
+ if (manager == null) {
+ Label l = ((Label)((SubgraphFigure) getFigure()).getHeader());
+ manager =
+ new ActivityDirectEditManager(
+ this,
+ TextCellEditor.class,
+ new ActivityCellEditorLocator(l),l);
+ }
+ manager.show();
+ */
+ }
+
+ /**
+ * @see org.eclipse.gef.editparts.AbstractEditPart#refreshVisuals()
+ */
+ protected void refreshVisuals() {
+ ((Label)((GroupingFigure)getFigure()).getHeader()).setText(
+ ViewSupport.getName(getModel(), getScenarioDiagram()));
+
+ ViewSupport.setTooltip(getFigure(), getModel());
+
+ super.refreshVisuals();
+ }
+
+ public int getHeight() {
+ int ret=ViewSupport.getHeight(getModel(), getScenarioDiagram());
+
+ return(ret);
+ }
+
+ public int getWidth() {
+ int ret=ViewSupport.getWidth(getModel(), getScenarioDiagram());
+
+ return(ret);
+ }
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/parts/TimeElapsedEventEditPart.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/parts/TimeElapsedEventEditPart.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/parts/TimeElapsedEventEditPart.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,150 @@
+/*
+ * Copyright 2005-7 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Mar 21, 2007 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.parts;
+
+import org.eclipse.draw2d.ConnectionAnchor;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.Label;
+import org.eclipse.draw2d.PositionConstants;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.gef.ConnectionEditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.requests.DropRequest;
+import org.savara.scenario.model.*;
+import org.savara.tools.scenario.designer.figures.*;
+import org.savara.tools.scenario.designer.model.ModelSupport;
+import org.savara.tools.scenario.designer.policies.ConnectableMessageEventEditPolicy;
+import org.savara.tools.scenario.designer.policies.ScenarioComponentEditPolicy;
+import org.savara.tools.scenario.designer.policies.ScenarioContainerXYLayoutEditPolicy;
+import org.savara.tools.scenario.designer.view.ViewSupport;
+
+/**
+ * This class provides a time elapse event edit part.
+ */
+public class TimeElapsedEventEditPart extends ScenarioBaseEditPart {
+
+ public TimeElapsedEventEditPart(Object elem) {
+ super(elem);
+ }
+
+ /**
+ * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#createFigure()
+ */
+ protected IFigure createFigure() {
+ IFigure ret=null;
+
+ ret = new TimeElapsedEventFigure(getScenarioDiagram());
+
+ return(ret);
+ }
+
+ /**
+ * @see org.eclipse.gef.editparts.AbstractEditPart#createEditPolicies()
+ */
+ protected void createEditPolicies() {
+ installEditPolicy(EditPolicy.COMPONENT_ROLE, new ScenarioComponentEditPolicy());
+
+ installEditPolicy(EditPolicy.LAYOUT_ROLE,
+ new ScenarioContainerXYLayoutEditPolicy());
+
+ //installEditPolicy(org.eclipse.gef.EditPolicy.GRAPHICAL_NODE_ROLE,
+ // new ConnectableMessageEventEditPolicy());
+
+ //installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new ActivityNodeEditPolicy());
+ //installEditPolicy(EditPolicy.CONTAINER_ROLE, new ActivitySourceEditPolicy());
+ //installEditPolicy(EditPolicy.COMPONENT_ROLE, new ActivityEditPolicy());
+ //installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new ActivityDirectEditPolicy());
+ }
+
+ /*
+ int getAnchorOffset() {
+ return 9;
+ }
+ */
+
+ /*
+ protected void performDirectEdit() {
+ if (manager == null) {
+ Label l = (Label)getFigure();
+ manager =
+ new ActivityDirectEditManager(
+ this,
+ TextCellEditor.class,
+ new ActivityCellEditorLocator(l), l);
+ }
+ manager.show();
+ }
+ */
+
+ public int getXOffset() {
+ return(-10);
+ }
+
+ /**
+ * @see org.eclipse.gef.editparts.AbstractEditPart#refreshVisuals()
+ */
+ protected void refreshVisuals() {
+
+ ((TimeElapsedEventFigure)getFigure()).setElapsedTime(
+ ((TimeElapsedEvent)getModel()).getDuration());
+
+ ViewSupport.setTooltip(getFigure(), getModel());
+
+ super.refreshVisuals();
+ }
+
+ public int getHeight() {
+ int ret=20; //ViewSupport.getHeight(getModel());
+
+ return(ret);
+ }
+
+ public int getWidth() {
+ int ret=ViewSupport.getWidth(getModel(), getScenarioDiagram());
+
+ return(ret);
+ }
+
+ /*
+ public void reset() {
+ ((MessageEventFigure)getFigure()).setState(MessageEventFigure.STATE_RESET);
+
+ super.reset();
+ }
+
+ public void processing() {
+ ((MessageEventFigure)getFigure()).setState(MessageEventFigure.STATE_PROCESSING);
+ }
+
+ public void successful() {
+ ((MessageEventFigure)getFigure()).setState(MessageEventFigure.STATE_SUCCESSFUL);
+ }
+
+ public void unsuccessful() {
+ ((MessageEventFigure)getFigure()).setState(MessageEventFigure.STATE_UNSUCCESSFUL);
+ }
+
+ public boolean isUnsuccessful() {
+ return(((MessageEventFigure)getFigure()).getState() ==
+ MessageEventFigure.STATE_UNSUCCESSFUL);
+ }
+ */
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/policies/ConnectableMessageEventEditPolicy.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/policies/ConnectableMessageEventEditPolicy.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/policies/ConnectableMessageEventEditPolicy.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,127 @@
+/*
+ * Copyright 2005 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Jul 14, 2005 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.policies;
+
+import org.eclipse.draw2d.ConnectionAnchor;
+
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.requests.CreateConnectionRequest;
+import org.eclipse.gef.requests.ReconnectRequest;
+import org.savara.scenario.model.*;
+import org.savara.tools.scenario.designer.commands.ConnectionCommand;
+import org.savara.tools.scenario.designer.parts.*;
+
+/**
+ * This class provides the edit policy for the connectable
+ * types container.
+ */
+public class ConnectableMessageEventEditPolicy
+ extends org.eclipse.gef.editpolicies.GraphicalNodeEditPolicy {
+
+ /**
+ *
+ */
+ public ConnectableMessageEventEditPolicy() {
+ super();
+ // TODO Auto-generated constructor stub
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.editpolicies.GraphicalNodeEditPolicy#getConnectionCompleteCommand(org.eclipse.gef.requests.CreateConnectionRequest)
+ */
+ protected Command getConnectionCompleteCommand(CreateConnectionRequest request) {
+ ConnectionCommand command =null;
+ ConnectionAnchor anchor =
+ getConnectableEditPart().getTargetConnectionAnchor();
+
+ if (anchor != null &&
+ request.getStartCommand() instanceof ConnectionCommand) {
+ command = (ConnectionCommand)request.getStartCommand();
+
+ if (command.getSource() != getMessageEvent()) {
+ command.setTarget((MessageEvent)getMessageEvent());
+ } else {
+ command = null;
+ }
+ }
+
+ return command;
+ }
+
+ /**
+ * Feedback should be added to the scaled feedback layer.
+ * @see org.eclipse.gef.editpolicies.GraphicalEditPolicy#getFeedbackLayer()
+ */
+ protected org.eclipse.draw2d.IFigure getFeedbackLayer() {
+ return getLayer(org.eclipse.gef.LayerConstants.SCALED_FEEDBACK_LAYER);
+ }
+
+ protected MessageEventEditPart getConnectableEditPart() {
+ return((MessageEventEditPart)getHost());
+ }
+
+ protected MessageEvent getMessageEvent() {
+ return((MessageEvent)getHost().getModel());
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.editpolicies.GraphicalNodeEditPolicy#getConnectionCreateCommand(org.eclipse.gef.requests.CreateConnectionRequest)
+ */
+ protected Command getConnectionCreateCommand(CreateConnectionRequest request) {
+ ConnectionCommand command=null;
+
+ if (getMessageEvent() instanceof SendEvent) {
+ command = new ConnectionCommand();
+
+ command.setLink((Link)request.getNewObject());
+
+ command.setSource((MessageEvent)getMessageEvent());
+ request.setStartCommand(command);
+ }
+
+ return(command);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.editpolicies.GraphicalNodeEditPolicy#getReconnectTargetCommand(org.eclipse.gef.requests.ReconnectRequest)
+ */
+ protected Command getReconnectTargetCommand(ReconnectRequest request) {
+ ConnectionCommand command = new ConnectionCommand();
+ Link rel = (Link)((LinkEditPart) request.getConnectionEditPart()).getModel();
+ command.setLink(rel);
+ command.setOldTarget((MessageEvent)rel.getTarget());
+ command.setTarget((MessageEvent)getMessageEvent());
+
+ return command;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.editpolicies.GraphicalNodeEditPolicy#getReconnectSourceCommand(org.eclipse.gef.requests.ReconnectRequest)
+ */
+ protected Command getReconnectSourceCommand(ReconnectRequest request) {
+ ConnectionCommand command = new ConnectionCommand();
+ Link rel = (Link)((LinkEditPart) request.getConnectionEditPart()).getModel();
+ command.setLink(rel);
+ command.setOldSource((MessageEvent)rel.getSource());
+ command.setSource((MessageEvent)getMessageEvent());
+
+ return command;
+ }
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/policies/ConnectableRoleEditPolicy.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/policies/ConnectableRoleEditPolicy.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/policies/ConnectableRoleEditPolicy.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,306 @@
+/*
+ * Copyright 2005 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Jul 14, 2005 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.policies;
+
+import org.eclipse.draw2d.ConnectionAnchor;
+import org.eclipse.draw2d.FigureCanvas;
+import org.eclipse.draw2d.Viewport;
+
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.requests.CreateConnectionRequest;
+import org.eclipse.gef.requests.ReconnectRequest;
+import org.savara.scenario.model.*;
+import org.savara.tools.scenario.designer.commands.*;
+import org.savara.tools.scenario.designer.model.*;
+import org.savara.tools.scenario.designer.parts.*;
+import org.savara.tools.scenario.designer.view.ViewSupport;
+
+/**
+ * This class provides the edit policy for the connectable
+ * types container.
+ */
+public class ConnectableRoleEditPolicy
+ extends org.eclipse.gef.editpolicies.GraphicalNodeEditPolicy {
+
+ /**
+ *
+ */
+ public ConnectableRoleEditPolicy() {
+ super();
+ // TODO Auto-generated constructor stub
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.editpolicies.GraphicalNodeEditPolicy#getConnectionCompleteCommand(org.eclipse.gef.requests.CreateConnectionRequest)
+ */
+ protected Command getConnectionCompleteCommand(CreateConnectionRequest request) {
+ Command command =null;
+ Command requestCommand=request.getStartCommand();
+
+ if (requestCommand instanceof ConnectionCommand) {
+ RoleConnectionCommand newCommand=new RoleConnectionCommand();
+
+ newCommand.setSource(((ConnectionCommand)requestCommand).getSource());
+ newCommand.setLink(((ConnectionCommand)requestCommand).getLink());
+
+ requestCommand = newCommand;
+ }
+
+ if (requestCommand instanceof RoleConnectionCommand) {
+ command = requestCommand;
+
+ ((RoleConnectionCommand)command).setTarget((Role)getRole());
+
+ ScenarioBaseEditPart target=null;
+ FigureCanvas canvas=(FigureCanvas)
+ getHost().getViewer().getControl();
+
+ Viewport port = canvas.getViewport();
+ org.eclipse.draw2d.geometry.Point point=
+ request.getLocation().getTranslated(port.getClientArea().getTopLeft());
+
+ if (request.getTargetEditPart() instanceof EventEditPart) {
+ target = ((EventEditPart)request.getTargetEditPart()).getScenarioDiagram().findEditPartAtLocation(point,
+ Event.class);
+ if (target == null) {
+ target = ((ScenarioBaseEditPart)request.getTargetEditPart()).getScenarioDiagram().findEditPartAtLocation(point,
+ Scenario.class);
+ }
+ } else if (request.getSourceEditPart() instanceof EventEditPart) {
+ target = ((EventEditPart)request.getSourceEditPart()).getScenarioDiagram().findEditPartAtLocation(point,
+ Event.class);
+ if (target == null) {
+ target = ((ScenarioBaseEditPart)request.getSourceEditPart()).getScenarioDiagram().findEditPartAtLocation(point,
+ Scenario.class);
+ }
+ }
+
+ /* GPB: WAS
+ if (request.getTargetEditPart() instanceof ScenarioBaseEditPart) {
+ target = ((ScenarioBaseEditPart)request.getTargetEditPart()).getScenarioDiagram().findEditPartAtLocation(point,
+ ScenarioObject.class);
+ if (target == null) {
+ target = ((ScenarioBaseEditPart)request.getTargetEditPart()).getScenarioDiagram().findEditPartAtLocation(point,
+ Scenario.class);
+ }
+ } else if (request.getSourceEditPart() instanceof ScenarioBaseEditPart) {
+ target = ((ScenarioBaseEditPart)request.getSourceEditPart()).getScenarioDiagram().findEditPartAtLocation(point,
+ ScenarioObject.class);
+ if (target == null) {
+ target = ((ScenarioBaseEditPart)request.getSourceEditPart()).getScenarioDiagram().findEditPartAtLocation(point,
+ Scenario.class);
+ }
+ }
+ */
+
+ // GPB: TODO Mislocating target editpart - put
+ // into to ensure does not try to drop on message
+ // event part
+ // Need to check how an edit part is found based
+ // on bounds and locations
+
+ if (target instanceof MessageEventEditPart) {
+ if (request.getTargetEditPart() instanceof EventEditPart) {
+ target = ((EventEditPart)request.getTargetEditPart()).getScenarioDiagram().findEditPartAtLocation(point,
+ Event.class);
+ } else if (request.getSourceEditPart() instanceof EventEditPart) {
+ target = ((EventEditPart)request.getSourceEditPart()).getScenarioDiagram().findEditPartAtLocation(point,
+ Event.class);
+ }
+ return(null);
+ }
+
+ /* GPB: WAS
+ if (target instanceof MessageEventEditPart) {
+ if (request.getTargetEditPart() instanceof ScenarioBaseEditPart) {
+ target = ((ScenarioBaseEditPart)request.getTargetEditPart()).getScenarioDiagram().findEditPartAtLocation(point,
+ ScenarioObject.class);
+ } else if (request.getSourceEditPart() instanceof ScenarioBaseEditPart) {
+ target = ((ScenarioBaseEditPart)request.getSourceEditPart()).getScenarioDiagram().findEditPartAtLocation(point,
+ ScenarioObject.class);
+ }
+ return(null);
+ }
+ */
+
+ // Calculate the index position
+ int y=port.getClientArea().y + request.getLocation().y
+ - ViewSupport.getHeaderPadding(target.getModel()); /* -
+ ViewSupport.INITIAL_YPADDING
+ - ViewSupport.YPADDING;*/
+ y -= target.getFigure().getBounds().y;
+
+ int index=0;
+ java.util.List list=ModelSupport.getChildren(target.getModel());
+
+ for (int i=0; y > 0 && i < list.size(); i++) {
+ index++;
+
+ y -= ViewSupport.getHeight(list.get(i),
+ target.getScenarioDiagram());
+
+ y -= ViewSupport.getPadding(list, i);
+ }
+
+ ((RoleConnectionCommand)command).setTargetParent(target.getModel());
+
+ if (((RoleConnectionCommand)command).getSourceParent() == target.getModel()) {
+ index++;
+ }
+
+ ((RoleConnectionCommand)command).setTargetIndex(index);
+ }
+
+ return command;
+ }
+
+ /**
+ * Feedback should be added to the scaled feedback layer.
+ * @see org.eclipse.gef.editpolicies.GraphicalEditPolicy#getFeedbackLayer()
+ */
+ protected org.eclipse.draw2d.IFigure getFeedbackLayer() {
+ return getLayer(org.eclipse.gef.LayerConstants.SCALED_FEEDBACK_LAYER);
+ }
+
+ protected RoleEditPart getConnectableEditPart() {
+ return((RoleEditPart)getHost());
+ }
+
+ protected Role getRole() {
+ return((Role)getHost().getModel());
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.editpolicies.GraphicalNodeEditPolicy#getConnectionCreateCommand(org.eclipse.gef.requests.CreateConnectionRequest)
+ */
+ protected Command getConnectionCreateCommand(CreateConnectionRequest request) {
+ RoleConnectionCommand command=null;
+
+ ScenarioBaseEditPart source=null;
+
+ FigureCanvas canvas=(FigureCanvas)
+ getHost().getViewer().getControl();
+
+ Viewport port = canvas.getViewport();
+
+ org.eclipse.draw2d.geometry.Point point=
+ request.getLocation().getTranslated(port.getClientArea().getTopLeft());
+
+ if (request.getSourceEditPart() instanceof EventEditPart) {
+ source = ((EventEditPart)request.getSourceEditPart()).getScenarioDiagram().findEditPartAtLocation(point,
+ Event.class);
+ if (source == null) {
+ source = ((EventEditPart)request.getSourceEditPart()).getScenarioDiagram().findEditPartAtLocation(point,
+ Scenario.class);
+ }
+ } else if (request.getTargetEditPart() instanceof EventEditPart) {
+ source = ((EventEditPart)request.getTargetEditPart()).getScenarioDiagram().findEditPartAtLocation(point,
+ Event.class);
+ if (source == null) {
+ source = ((EventEditPart)request.getTargetEditPart()).getScenarioDiagram().findEditPartAtLocation(point,
+ Scenario.class);
+ }
+ }
+
+ /* GPB: WAS
+ if (request.getSourceEditPart() instanceof ScenarioBaseEditPart) {
+ source = ((ScenarioBaseEditPart)request.getSourceEditPart()).getScenarioDiagram().findEditPartAtLocation(point,
+ ScenarioObject.class);
+ if (source == null) {
+ source = ((ScenarioBaseEditPart)request.getSourceEditPart()).getScenarioDiagram().findEditPartAtLocation(point,
+ Scenario.class);
+ }
+ } else if (request.getTargetEditPart() instanceof ScenarioBaseEditPart) {
+ source = ((ScenarioBaseEditPart)request.getTargetEditPart()).getScenarioDiagram().findEditPartAtLocation(point,
+ ScenarioObject.class);
+ if (source == null) {
+ source = ((ScenarioBaseEditPart)request.getTargetEditPart()).getScenarioDiagram().findEditPartAtLocation(point,
+ Scenario.class);
+ }
+ }
+
+ */
+ //if (getParticipant() != null &&
+ // getParticipant().getDirection() ==
+ // MessageDirection.SEND) {
+ if (source instanceof GroupEditPart ||
+ source instanceof ScenarioEditPart) {
+
+ command = new RoleConnectionCommand();
+
+ command.setLink((Link) request.getNewObject());
+
+ command.setSource((Role)getRole());
+ request.setStartCommand(command);
+
+ // Calculate the index position
+ int y=port.getClientArea().y + request.getLocation().y
+ - ViewSupport.getHeaderPadding(source.getModel()); /* -
+ ViewSupport.INITIAL_YPADDING
+ - ViewSupport.YPADDING;*/
+ y -= source.getFigure().getBounds().y;
+
+ int index=0;
+ java.util.List list=ModelSupport.getChildren(source.getModel());
+
+ for (int i=0; y > 0 && i < list.size(); i++) {
+ index++;
+
+ y -= ViewSupport.getHeight(list.get(i), source.getScenarioDiagram());
+
+ y -= ViewSupport.getPadding(list, i);
+ }
+
+ command.setSourceIndex(index);
+ command.setSourceParent(source.getModel());
+ }
+
+ return(command);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.editpolicies.GraphicalNodeEditPolicy#getReconnectTargetCommand(org.eclipse.gef.requests.ReconnectRequest)
+ */
+ protected Command getReconnectTargetCommand(ReconnectRequest request) {
+ RoleConnectionCommand command = null; //new ParticipantConnectionCommand();
+
+ /*
+ MessageLink rel = (MessageLink)((MessageLinkEditPart) request.getConnectionEditPart()).getModel();
+ command.setMessageLink(rel);
+ command.setOldTarget(rel.getTarget());
+ command.setTarget((MessageEvent)getParticipant());
+*/
+ return command;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.editpolicies.GraphicalNodeEditPolicy#getReconnectSourceCommand(org.eclipse.gef.requests.ReconnectRequest)
+ */
+ protected Command getReconnectSourceCommand(ReconnectRequest request) {
+ RoleConnectionCommand command = null; //new ParticipantConnectionCommand();
+ /*
+ MessageLink rel = (MessageLink)((MessageLinkEditPart) request.getConnectionEditPart()).getModel();
+ command.setMessageLink(rel);
+ command.setOldSource(rel.getSource());
+ command.setSource((MessageEvent)getParticipant());
+*/
+ return command;
+ }
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/policies/LinkComponentEditPolicy.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/policies/LinkComponentEditPolicy.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/policies/LinkComponentEditPolicy.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2005 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Jul 14, 2005 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.policies;
+
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.editpolicies.ComponentEditPolicy;
+import org.eclipse.gef.requests.GroupRequest;
+import org.savara.scenario.model.*;
+import org.savara.tools.scenario.designer.commands.DeleteLinkCommand;
+
+/**
+ * This is the component edit policy.
+ */
+public class LinkComponentEditPolicy extends ComponentEditPolicy {
+
+ /**
+ * @see ComponentEditPolicy#createDeleteCommand(org.eclipse.gef.requests.GroupRequest)
+ */
+ protected Command createDeleteCommand(GroupRequest deleteRequest) {
+ DeleteLinkCommand deleteCmd = new DeleteLinkCommand();
+
+ Object child=(Object)(getHost().getModel());
+
+ if (child instanceof Link) {
+ deleteCmd.setChild((Link)child);
+
+ // TODO: GPB - how to find scenario
+ //deleteCmd.setParent(((Link)child).getScenario());
+ }
+
+ return deleteCmd;
+ }
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/policies/LinkConnectionEditPolicy.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/policies/LinkConnectionEditPolicy.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/policies/LinkConnectionEditPolicy.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2005 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Jul 14, 2005 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.policies;
+
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.editpolicies.ConnectionEditPolicy;
+import org.eclipse.gef.requests.GroupRequest;
+
+/**
+ * This is the edit policy for the relationship type connection.
+ */
+public class LinkConnectionEditPolicy extends ConnectionEditPolicy {
+
+ /**
+ *
+ */
+ public LinkConnectionEditPolicy() {
+ super();
+ // TODO Auto-generated constructor stub
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.editpolicies.ConnectionEditPolicy#getDeleteCommand(org.eclipse.gef.requests.GroupRequest)
+ */
+ protected Command getDeleteCommand(GroupRequest request) {
+ // Deletion handled by the component policy
+ return(null);
+ }
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/policies/LinkEndpointEditPolicy.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/policies/LinkEndpointEditPolicy.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/policies/LinkEndpointEditPolicy.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2005 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Jul 14, 2005 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.policies;
+
+import org.eclipse.draw2d.PolylineConnection;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.editpolicies.ConnectionEndpointEditPolicy;
+
+/**
+ *
+ */
+public class LinkEndpointEditPolicy extends ConnectionEndpointEditPolicy {
+
+ /**
+ *
+ */
+ public LinkEndpointEditPolicy() {
+ super();
+ }
+
+ protected void addSelectionHandles(){
+ super.addSelectionHandles();
+ getConnectionFigure().setLineWidth(2);
+ }
+
+ protected PolylineConnection getConnectionFigure(){
+ return (PolylineConnection)((GraphicalEditPart)getHost()).getFigure();
+ }
+
+ protected void removeSelectionHandles(){
+ super.removeSelectionHandles();
+ getConnectionFigure().setLineWidth(1);
+ }
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/policies/LinkSelectionHandlesEditPolicy.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/policies/LinkSelectionHandlesEditPolicy.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/policies/LinkSelectionHandlesEditPolicy.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2005 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Jul 14, 2005 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.policies;
+
+import org.eclipse.draw2d.BendpointLocator;
+import org.eclipse.draw2d.Connection;
+import org.eclipse.draw2d.geometry.PointList;
+import org.eclipse.gef.ConnectionEditPart;
+import org.eclipse.gef.editpolicies.SelectionHandlesEditPolicy;
+import org.eclipse.gef.handles.BendpointCreationHandle;
+import org.eclipse.gef.handles.BendpointHandle;
+
+/**
+ *
+ */
+public class LinkSelectionHandlesEditPolicy
+ extends SelectionHandlesEditPolicy {
+
+ /**
+ *
+ */
+ public LinkSelectionHandlesEditPolicy() {
+ super();
+ // TODO Auto-generated constructor stub
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.editpolicies.SelectionHandlesEditPolicy#createSelectionHandles()
+ */
+ protected java.util.List createSelectionHandles() {
+ java.util.List list = new java.util.ArrayList();
+ ConnectionEditPart connPart = (ConnectionEditPart)getHost();
+ PointList points = getConnection().getPoints();
+ for (int i = 0; i < points.size() - 2; i++) {
+ BendpointHandle handle = new BendpointCreationHandle(connPart, 0,
+ new BendpointLocator(getConnection(), i + 1));
+ list.add(handle);
+ }
+ return list;
+ }
+
+ protected Connection getConnection() {
+ return (Connection)getHostFigure();
+ }
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/policies/ScenarioComponentEditPolicy.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/policies/ScenarioComponentEditPolicy.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/policies/ScenarioComponentEditPolicy.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2005 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Jul 14, 2005 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.policies;
+
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.editpolicies.ComponentEditPolicy;
+import org.eclipse.gef.requests.GroupRequest;
+import org.savara.tools.scenario.designer.commands.DeleteComponentCommand;
+import org.savara.tools.scenario.designer.model.ModelSupport;
+import org.savara.tools.scenario.designer.parts.ScenarioBaseEditPart;
+
+/**
+ * This is the component edit policy.
+ */
+public class ScenarioComponentEditPolicy extends ComponentEditPolicy {
+
+ /**
+ * @see ComponentEditPolicy#createDeleteCommand(org.eclipse.gef.requests.GroupRequest)
+ */
+ protected Command createDeleteCommand(GroupRequest deleteRequest) {
+ Object parent = (getHost().getParent().getModel());
+ DeleteComponentCommand deleteCmd = new DeleteComponentCommand();
+
+ Object child=(Object)(getHost().getModel());
+
+ deleteCmd.setChild(child);
+
+ if (getHost().getParent() instanceof ScenarioBaseEditPart) {
+ deleteCmd.setParent(((ScenarioBaseEditPart)getHost().getParent()).getModel());
+ }
+
+ int index=ModelSupport.getChildIndex(parent, child);
+
+ deleteCmd.setIndex(index);
+
+ return deleteCmd;
+ }
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/policies/ScenarioContainerEditPolicy.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/policies/ScenarioContainerEditPolicy.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/policies/ScenarioContainerEditPolicy.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,100 @@
+/*
+ * Copyright 2005 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Jul 6, 2005 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.policies;
+
+import org.eclipse.draw2d.FigureCanvas;
+import org.eclipse.draw2d.Viewport;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.editpolicies.ContainerEditPolicy;
+import org.eclipse.gef.requests.CreateRequest;
+import org.savara.scenario.model.*;
+import org.savara.tools.scenario.designer.commands.CreateComponentCommand;
+import org.savara.tools.scenario.designer.model.*;
+import org.savara.tools.scenario.designer.parts.ScenarioBaseEditPart;
+import org.savara.tools.scenario.designer.view.ViewSupport;
+
+/**
+ * This class represents the edit policy for the generic container
+ * edit part.
+ */
+public class ScenarioContainerEditPolicy extends ContainerEditPolicy {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.editpolicies.ContainerEditPolicy#getCreateCommand(org.eclipse.gef.requests.CreateRequest)
+ */
+ protected Command getCreateCommand(CreateRequest request) {
+ CreateComponentCommand ret=null;
+
+ if (getHost() instanceof ScenarioBaseEditPart &&
+ ModelSupport.isValidTarget(request.getNewObject(),
+ ((ScenarioBaseEditPart)getHost()).getModel())) {
+ ScenarioBaseEditPart part=(ScenarioBaseEditPart)getHost();
+
+ FigureCanvas canvas=(FigureCanvas)
+ getHost().getViewer().getControl();
+
+ Viewport port = canvas.getViewport();
+
+ ret = new CreateComponentCommand();
+
+ ret.setChild(request.getNewObject());
+ ret.setParent(part.getModel());
+
+ if (request.getNewObject() instanceof Event) { //ScenarioObject) {
+ int x=port.getClientArea().x + request.getLocation().x;
+
+ Role participant=ViewSupport.getNearestRole(x, part.getScenarioDiagram());
+
+ // Calculate the index position
+ int y=port.getClientArea().y + request.getLocation().y
+ - ViewSupport.getHeaderPadding(((ScenarioBaseEditPart)getHost()).getModel()); /* -
+ ViewSupport.INITIAL_YPADDING
+ - ViewSupport.YPADDING;*/
+ y -= ((ScenarioBaseEditPart)getHost()).getFigure().getBounds().y;
+
+ int index=0;
+ java.util.List list=ModelSupport.getChildren(((ScenarioBaseEditPart)getHost()).getModel());
+
+ for (int i=0; y > 0 && i < list.size(); i++) {
+ index++;
+
+ y -= ViewSupport.getHeight(list.get(i),
+ ((ScenarioBaseEditPart)getHost()).getScenarioDiagram());
+
+ y -= ViewSupport.getPadding(list, i);
+ }
+
+ ret.setRole(participant);
+ ret.setIndex(index);
+
+ } else if (request.getNewObject() instanceof Role) {
+ int x=port.getClientArea().x + request.getLocation().x;
+ int index=ViewSupport.getNewParticipantIndex(x,
+ part.getScenarioDiagram());
+
+ ret.setIndex(index);
+
+ //((Participant)request.getNewObject()).setDiagram(part.getScenarioDiagram());
+ }
+ }
+
+ return(ret);
+ }
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/policies/ScenarioContainerHighlightEditPolicy.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/policies/ScenarioContainerHighlightEditPolicy.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/policies/ScenarioContainerHighlightEditPolicy.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2005 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Jul 7, 2005 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.policies;
+
+import org.eclipse.swt.graphics.Color;
+
+import org.eclipse.draw2d.IFigure;
+
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.RequestConstants;
+import org.eclipse.gef.editpolicies.GraphicalEditPolicy;
+
+/**
+ * This class implements the highlight edit policy.
+ */
+public class ScenarioContainerHighlightEditPolicy
+ extends GraphicalEditPolicy {
+
+ /**
+ * @see org.eclipse.gef.EditPolicy#eraseTargetFeedback(org.eclipse.gef.Request)
+ */
+ public void eraseTargetFeedback(Request request) {
+ if (revertColor != null) {
+ setContainerBackground(revertColor);
+ revertColor = null;
+ }
+ }
+
+ private Color getContainerBackground() {
+ return getContainerFigure().getBackgroundColor();
+ }
+
+ private IFigure getContainerFigure() {
+ return ((GraphicalEditPart)getHost()).getFigure();
+ }
+
+ /**
+ * @see org.eclipse.gef.EditPolicy#getTargetEditPart(org.eclipse.gef.Request)
+ */
+ public EditPart getTargetEditPart(Request request) {
+ return request.getType().equals(RequestConstants.REQ_SELECTION_HOVER)
+ ? getHost() : null;
+ }
+
+ private void setContainerBackground(Color c) {
+ getContainerFigure().setBackgroundColor(c);
+ }
+
+ /**
+ * Changes the background color of the container to the highlight color
+ */
+ protected void showHighlight() {
+ if (revertColor == null) {
+ revertColor = getContainerBackground();
+ setContainerBackground(highLightColor);
+ }
+ }
+
+ /**
+ * @see org.eclipse.gef.EditPolicy#showTargetFeedback(org.eclipse.gef.Request)
+ */
+ public void showTargetFeedback(Request request) {
+ if (request.getType().equals(RequestConstants.REQ_CREATE)
+ || request.getType().equals(RequestConstants.REQ_ADD))
+ showHighlight();
+ }
+
+ private Color revertColor;
+ private static Color highLightColor = new Color(null, 200, 200, 240);
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/policies/ScenarioContainerXYLayoutEditPolicy.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/policies/ScenarioContainerXYLayoutEditPolicy.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/policies/ScenarioContainerXYLayoutEditPolicy.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,226 @@
+/*
+ * Copyright 2005 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Jul 6, 2005 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.policies;
+
+import org.eclipse.draw2d.FigureCanvas;
+import org.eclipse.draw2d.Viewport;
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.editpolicies.XYLayoutEditPolicy;
+import org.eclipse.gef.requests.ChangeBoundsRequest;
+import org.eclipse.gef.requests.CreateRequest;
+import org.savara.scenario.model.Role;
+import org.savara.tools.scenario.designer.commands.AddCommand;
+import org.savara.tools.scenario.designer.commands.MoveCommand;
+import org.savara.tools.scenario.designer.model.ModelSupport;
+import org.savara.tools.scenario.designer.parts.ScenarioBaseEditPart;
+import org.savara.tools.scenario.designer.view.ViewSupport;
+
+/**
+ * This class provides the XY layout implementation for the generic
+ * container.
+ */
+public class ScenarioContainerXYLayoutEditPolicy extends XYLayoutEditPolicy {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.editpolicies.ConstrainedLayoutEditPolicy#createAddCommand(org.eclipse.gef.EditPart, java.lang.Object)
+ */
+ protected Command createAddCommand(EditPart child, Object constraint) {
+
+ AddCommand ret=null;
+ ScenarioBaseEditPart comppart=null;
+ if (child instanceof ScenarioBaseEditPart) {
+ comppart = (ScenarioBaseEditPart)child;
+ }
+ if (comppart != null && getHost() instanceof ScenarioBaseEditPart
+ && ModelSupport.isValidTarget(comppart.getModel(),
+ ((ScenarioBaseEditPart)getHost()).getModel())) {
+ Object oldParent=ModelSupport.getParent(comppart.getModel());
+
+ ret = new AddCommand();
+
+ if (constraint instanceof org.eclipse.draw2d.geometry.Rectangle) {
+
+ FigureCanvas canvas=(FigureCanvas)
+ getHost().getViewer().getControl();
+
+ Viewport port = canvas.getViewport();
+
+ // TODO: The rect is the region being moved, so
+ // need to locate its real position within the
+ // diagram as opposed to just the containing host
+ org.eclipse.draw2d.geometry.Rectangle rect=
+ (org.eclipse.draw2d.geometry.Rectangle)constraint;
+
+ int x=port.getClientArea().x + rect.x;
+
+ Role participant=ViewSupport.getNearestRole(x,
+ comppart.getScenarioDiagram());
+
+ ret.setRole(participant);
+
+ // Calculate the index position
+ int y = port.getClientArea().y + rect.y -
+ ViewSupport.getHeaderPadding(((ScenarioBaseEditPart)getHost()).getModel());
+
+ int index=0;
+ java.util.List list=ModelSupport.getChildren(((ScenarioBaseEditPart)getHost()).getModel());
+
+ for (int i=0; y > 0 && i < list.size(); i++) {
+ index++;
+
+ y -= ViewSupport.getHeight(list.get(i),
+ ((ScenarioBaseEditPart)getHost()).getScenarioDiagram());
+
+ y -= ViewSupport.getPadding(list, i);
+ }
+
+ ret.setIndex(index);
+ }
+
+ ret.setNewParent(((ScenarioBaseEditPart)getHost()).getModel());
+ ret.setOldParent(oldParent);
+ ret.setChild(comppart.getModel());
+ }
+
+ return(ret);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.editpolicies.ConstrainedLayoutEditPolicy#createChangeConstraintCommand(org.eclipse.gef.EditPart, java.lang.Object)
+ */
+ protected Command createChangeConstraintCommand( EditPart child,
+ Object constraint) {
+ return(null);
+ }
+
+ protected Command createChangeConstraintCommand(ChangeBoundsRequest request,
+ EditPart child, Object constraint) {
+ return(null);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.editpolicies.LayoutEditPolicy#getCreateCommand(org.eclipse.gef.requests.CreateRequest)
+ */
+ protected Command getCreateCommand(CreateRequest request) {
+ Command createCommand = null;
+
+ return createCommand;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.editpolicies.LayoutEditPolicy#getDeleteDependantCommand(org.eclipse.gef.Request)
+ */
+ protected Command getDeleteDependantCommand(Request request) {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.editpolicies.LayoutEditPolicy#createChildEditPolicy(org.eclipse.gef.EditPart)
+ */
+ protected EditPolicy createChildEditPolicy(EditPart child) {
+ return super.createChildEditPolicy( child );
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.gef.editpolicies.XYLayoutEditPolicy#getMinimumSizeFor(org.eclipse.gef.GraphicalEditPart)
+ */
+ protected Dimension getMinimumSizeFor(GraphicalEditPart child) {
+ return child.getContentPane().getMinimumSize();
+ }
+
+
+ protected Command getMoveChildrenCommand(Request request) {
+ Command ret=null;
+
+ ChangeBoundsRequest req=(ChangeBoundsRequest)request;
+
+ ScenarioBaseEditPart comppart=null;
+ if (req.getEditParts().size() == 1 &&
+ req.getEditParts().get(0) instanceof ScenarioBaseEditPart) {
+ comppart = (ScenarioBaseEditPart)req.getEditParts().get(0);
+ }
+
+ if (getHost() instanceof ScenarioBaseEditPart) {
+
+ ret = new MoveCommand();
+
+ ((MoveCommand)ret).setComponent(comppart.getModel());
+ ((MoveCommand)ret).setContainer(((ScenarioBaseEditPart)getHost()).getModel());
+
+ FigureCanvas canvas=(FigureCanvas)
+ getHost().getViewer().getControl();
+
+ Viewport port = canvas.getViewport();
+
+ int x=port.getClientArea().x + req.getLocation().x;
+
+ Role participant=ViewSupport.getNearestRole(x,
+ comppart.getScenarioDiagram());
+
+ ((MoveCommand)ret).setRole(participant);
+
+ // Calculate the index position
+ int y=port.getClientArea().y + req.getLocation().y
+ - ViewSupport.getHeaderPadding(((ScenarioBaseEditPart)getHost()).getModel()); /* -
+ ViewSupport.INITIAL_YPADDING
+ - ViewSupport.YPADDING;*/
+ y -= ((ScenarioBaseEditPart)getHost()).getFigure().getBounds().y;
+
+ int index=0;
+ java.util.List list=ModelSupport.getChildren(((ScenarioBaseEditPart)getHost()).getModel());
+
+ for (int i=0; y > 0 && i < list.size(); i++) {
+ index++;
+
+ y -= ViewSupport.getHeight(list.get(i),
+ ((ScenarioBaseEditPart)getHost()).getScenarioDiagram());
+
+ y -= ViewSupport.getPadding(list, i);
+ }
+
+ ((MoveCommand)ret).setIndex(index);
+ }
+
+ return(ret);
+ }
+
+ protected Command getOrphanChildrenCommand(Request request) {
+ return(null);
+ }
+
+ protected Command getAddCommand(Request generic) {
+ Command ret=null;
+ try {
+ ret = super.getAddCommand(generic);
+ } catch(NullPointerException e) {
+ // Ignore - thrown for inappropriate containers
+ // based on lack of XYlayout origin. Tried setting
+ // this, but it moved the problem, so instead
+ // taking the pragmatic approach of ignoring it.
+ }
+ return(ret);
+ }
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/preferences/PreferenceInitializer.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/preferences/PreferenceInitializer.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/preferences/PreferenceInitializer.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * 30 March 2010 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.preferences;
+
+import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
+import org.eclipse.jface.preference.IPreferenceStore;
+
+import org.savara.tools.scenario.designer.*;
+
+/**
+ * Class used to initialize default preference values.
+ */
+public class PreferenceInitializer extends AbstractPreferenceInitializer {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
+ */
+ public void initializeDefaultPreferences() {
+ IPreferenceStore store = org.savara.tools.scenario.osgi.Activator.getDefault().getPreferenceStore();
+ store.setDefault(DesignerDefinitions.BUSINESS_VIEW, true);
+ }
+
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/preferences/ScenarioPreferencePage.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/preferences/ScenarioPreferencePage.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/preferences/ScenarioPreferencePage.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2005-10 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * 30 March 2010 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.preferences;
+
+import org.eclipse.jface.preference.*;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.eclipse.ui.IWorkbench;
+import org.savara.tools.scenario.designer.*;
+
+/**
+ * This class represents a preference page that
+ * is contributed to the Preferences dialog. By
+ * subclassing <samp>FieldEditorPreferencePage</samp>, we
+ * can use the field support built into JFace that allows
+ * us to create a page that is small and knows how to
+ * save, restore and apply itself.
+ * <p>
+ * This page is used to modify preferences only. They
+ * are stored in the preference store that belongs to
+ * the main plug-in class. That way, preferences can
+ * be accessed directly via the preference store.
+ */
+
+public class ScenarioPreferencePage
+ extends FieldEditorPreferencePage
+ implements IWorkbenchPreferencePage {
+
+ public ScenarioPreferencePage() {
+ super(GRID);
+ setPreferenceStore(org.savara.tools.scenario.osgi.Activator.getDefault().getPreferenceStore());
+ setDescription("Preferences for the Scenario Designer");
+ }
+
+ /**
+ * Creates the field editors. Field editors are abstractions of
+ * the common GUI blocks needed to manipulate various types
+ * of preferences. Each field editor knows how to save and
+ * restore itself.
+ */
+ public void createFieldEditors() {
+ addField(new BooleanFieldEditor(
+ DesignerDefinitions.BUSINESS_VIEW,
+ "&Business View", getFieldEditorParent()));
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
+ */
+ public void init(IWorkbench workbench) {
+ }
+
+}
\ No newline at end of file
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/simulate/ScenarioDesignerSimulationLauncher.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/simulate/ScenarioDesignerSimulationLauncher.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/simulate/ScenarioDesignerSimulationLauncher.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,206 @@
+/*
+ * Copyright 2005-7 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Feb 26, 2007 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.simulate;
+
+
+import java.util.StringTokenizer;
+//import java.util.logging.Logger;
+
+import org.savara.scenario.simulation.ScenarioSimulator;
+import org.eclipse.swt.widgets.Display;
+import org.savara.tools.scenario.simulation.ScenarioSimulationLauncher;
+
+/**
+ * This class is derived from the scenario simulation launcher with the
+ * ability to present the results in a graphical form.
+ */
+public class ScenarioDesignerSimulationLauncher extends ScenarioSimulationLauncher {
+
+ public ScenarioDesignerSimulationLauncher(Display display,
+ org.savara.scenario.model.Scenario scenario,
+ ScenarioSimulation simulation) {
+ m_display = display;
+ m_scenario = scenario;
+ m_scenarioSimulation = simulation;
+ }
+
+ /**
+ * This method handles the results produced by the launched
+ * test.
+ *
+ * @param results The results
+ * @param errorStream Whether the results are from the error
+ * stream
+ */
+ protected void handleResults(String results, boolean errorStream) {
+ final String text=results;
+
+ if (errorStream) {
+
+ try {
+ m_display.asyncExec(new Runnable() {
+ public void run() {
+ processResults(text);
+ }
+ });
+ } catch(Throwable e) {
+ org.savara.tools.scenario.osgi.Activator.logError(
+ "Failed to display scenario test results", e);
+ }
+ }
+ }
+
+ protected void processResults(String results) {
+ boolean f_entryFound=false;
+
+ m_scenarioSimulation.appendLogEntry(results);
+
+ m_log.append(results);
+
+ do {
+ int infoPos=0;
+ f_entryFound=false;
+
+ // Check if "INFO: <" is found
+ // GPB(4/7/08) removed 'INFO' to ensure internationalization
+ // of java logging tags is catered for - issue is how to
+ // detect SEVERE messages?
+ infoPos=m_log.indexOf(": <",
+ m_currentPosition);
+
+ int tmpPos=m_log.indexOf("SEVERE: <",
+ m_currentPosition);
+
+ if (tmpPos != -1 && tmpPos < infoPos) {
+ infoPos = tmpPos;
+ }
+
+ if (infoPos != -1) {
+ int newlinePos=0;
+
+ // Check if newline found
+ if ((newlinePos=m_log.indexOf("\r",
+ infoPos)) != -1 ||
+ (newlinePos=m_log.indexOf("\n",
+ infoPos)) != -1) {
+
+ // Complete line found
+ processResultLine(infoPos,
+ newlinePos);
+
+ m_currentPosition = newlinePos;
+
+ f_entryFound = true;
+ }
+ }
+ } while(f_entryFound);
+ }
+
+ protected void processResultLine(int start, int end) {
+ /* TODO: GPB: Need to decide how simulator would return its info on stdout
+ *
+ *
+ String tag=null;
+ String line=m_log.substring(start, end);
+
+ if (line.startsWith("INFO:")) {
+ int tagEndPos=line.indexOf(' ', 7);
+ tag = line.substring(7, tagEndPos);
+ } else if (line.startsWith(": <")) {
+ int tagEndPos=line.indexOf(' ', 3);
+ tag = line.substring(3, tagEndPos);
+ } else if (line.startsWith("SEVERE:")) {
+ int tagEndPos=line.indexOf(' ', 9);
+ tag = line.substring(9, tagEndPos);
+ }
+
+ if (tag.equals(ScenarioSimulator.PROCESSING_TAG) == false &&
+ tag.equals(ScenarioSimulator.COMPLETED_TAG) == false &&
+ tag.equals(ScenarioSimulator.FAILED_TAG) == false) {
+ return;
+ }
+
+ // Get id
+ int idPos=line.indexOf(ScenarioSimulator.ID_ATTR+"=\"");
+ int idEndPos=line.indexOf('"', idPos+2+
+ ScenarioSimulator.ID_ATTR.length());
+ String id=line.substring(idPos+2+
+ ScenarioSimulator.ID_ATTR.length(), idEndPos);
+
+ // Get scenario entity
+ SimulationEntity se=getScenarioEntity(id);
+
+ if (se != null) {
+ if (tag.equals(ScenarioSimulator.PROCESSING_TAG)) {
+ se.processing();
+ se.setLogStartPosition(start);
+ } else {
+ if (tag.equals(ScenarioSimulator.COMPLETED_TAG)) {
+ se.successful();
+ } else {
+ se.unsuccessful();
+ }
+
+ se.setLogEndPosition(end);
+ }
+ }
+ */
+ }
+
+ protected SimulationEntity getScenarioEntity(String id) {
+ SimulationEntity ret=null;
+ StringTokenizer st=new StringTokenizer(id, "/");
+
+ // Ignore scenario identity - may be useful in constructing
+ // tree items when multiple scenarios are being run
+ st.nextToken();
+
+ Object cur=m_scenario;
+
+ while (st.hasMoreTokens()) {
+ String token=st.nextToken();
+
+ try {
+ int pos=Integer.parseInt(token);
+
+ java.util.List children=org.savara.tools.scenario.designer.model.ModelSupport.getChildren(cur);
+
+ cur = children.get(pos);
+
+ } catch(Exception e) {
+ // Ignore
+ }
+ }
+
+ // Focus if element is a message event
+ ret = m_scenarioSimulation.getSimulationEntity(cur,
+ (cur instanceof org.savara.scenario.model.MessageEvent));
+
+ return(ret);
+ }
+
+ //private static Logger logger = Logger.getLogger("org.pi4soa.scenario.provider");
+
+ private Display m_display=null;
+ private ScenarioSimulation m_scenarioSimulation=null;
+ private org.savara.scenario.model.Scenario m_scenario=null;
+ private int m_currentPosition=0;
+ private StringBuffer m_log=new StringBuffer();
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/simulate/ScenarioSimulation.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/simulate/ScenarioSimulation.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/simulate/ScenarioSimulation.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2005-7 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * 26 Feb 2007 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.simulate;
+
+public interface ScenarioSimulation {
+
+ /**
+ * This method returns the scenario.
+ *
+ * @return The scenario
+ */
+ public org.savara.scenario.model.Scenario getScenario();
+
+ public void startSimulation();
+
+ public void resetSimulation();
+
+ public boolean isSimulationRunning();
+
+ public SimulationEntity getSimulationEntity(Object model, boolean focus);
+
+ public void appendLogEntry(String results);
+
+ public String getLogEntry(int start, int end);
+
+ public String getLogEntry(Object scenarioObject);
+
+ /**
+ * This method focuses the environment on the supplied
+ * URL and region name.
+ *
+ * @param scenarioURL The scenario path
+ * @param regionName The optional region name
+ */
+ public void focus(String scenarioURL, String regionName);
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/simulate/SimulationEntity.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/simulate/SimulationEntity.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/simulate/SimulationEntity.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2005-7 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * 26 Feb 2007 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.simulate;
+
+public interface SimulationEntity {
+
+ public void reset();
+
+ public void processing();
+
+ public void successful();
+
+ public void unsuccessful();
+
+ public boolean isUnsuccessful();
+
+ public void setLogStartPosition(int pos);
+
+ public int getLogStartPosition();
+
+ public void setLogEndPosition(int pos);
+
+ public int getLogEndPosition();
+
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/tools/CreateLinksTool.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/tools/CreateLinksTool.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/tools/CreateLinksTool.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,157 @@
+/*
+ * Copyright 2005-7 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * 23 Feb 2007 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.tools;
+
+import org.savara.scenario.model.*;
+
+public class CreateLinksTool {
+
+ public CreateLinksTool(Scenario scenario) {
+ m_scenario = scenario;
+ }
+
+ public void run() {
+ run(m_scenario.getEvents());
+ }
+
+ public void run(java.util.List list) {
+ scanEvents(list);
+ }
+
+ protected void scanEvents(java.util.List list) {
+
+ // Scan for sends that are not associated with an
+ // existing message link
+ for (int i=0; i < list.size(); i++) {
+ Event obj=(Event)list.get(i);
+
+ if (obj instanceof SendEvent) {
+
+ if (getLinks((MessageEvent)obj).size() == 0) {
+
+ // Search for an appropriate receive message
+ // event within the same group
+ MessageEvent recv=findReceive((MessageEvent)obj,
+ list, i+1);
+
+ if (recv != null) {
+ Link link=new Link();
+
+ link.setSource((MessageEvent)obj);
+ link.setTarget(recv);
+
+ m_scenario.getLinks().add(link);
+
+ m_changed = true;
+ }
+ }
+
+ } else if (obj instanceof Group) {
+ scanEvents(((Group)obj).getEvents());
+ }
+ }
+ }
+
+ /**
+ * This method attempts to locate a compatible receive for
+ * the supplied send message event, within the supplied list
+ * starting at the specified index.
+ *
+ * @param send The send message event
+ * @param list The list
+ * @param index The starting index
+ * @return The receive message event, or null if not found
+ */
+ protected MessageEvent findReceive(MessageEvent send,
+ java.util.List list, int index) {
+ MessageEvent ret=null;
+
+ for (int i=index; ret == null && i < list.size(); i++) {
+ if (list.get(i) instanceof MessageEvent) {
+ MessageEvent me=(MessageEvent)list.get(i);
+
+ if (me instanceof ReceiveEvent &&
+ getLinks(me).size() == 0) {
+ if (isSame(me.getOperationName(),
+ send.getOperationName()) &&
+ isSame(me.getFaultName(),
+ send.getFaultName()) &&
+ isSame(me.getType(),
+ send.getType())) {
+
+ ret = me;
+ }
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+ protected boolean isSame(String val1, String val2) {
+ boolean ret=false;
+
+ if (val1 != null &&
+ val2 != null &&
+ val1.equals(val2)) {
+ ret = true;
+ } else if (val1 == null &&
+ val2 == null) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the links that are associated with the
+ * supplied message event.
+ *
+ * @param me The message event
+ * @return The list of message links
+ */
+ protected java.util.List getLinks(MessageEvent me) {
+ java.util.Vector ret=new java.util.Vector();
+
+ for (int i=0; i < m_scenario.getLinks().size(); i++) {
+ Link link=(Link)
+ m_scenario.getLinks().get(i);
+
+ if (link.getSource() == me || link.getTarget() == me) {
+ ret.add(link);
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method determines whether the scenario has been
+ * changed.
+ *
+ * @return Whether the scenario has been changed
+ */
+ public boolean isScenarioChanged() {
+ return(m_changed);
+ }
+
+ private Scenario m_scenario=null;
+ private boolean m_changed=false;
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/util/PropertySource.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/util/PropertySource.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/util/PropertySource.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,789 @@
+/*
+ * Copyright 2005 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Jul 8, 2005 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.util;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Vector;
+import java.util.logging.Logger;
+
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.eclipse.ui.views.properties.TextPropertyDescriptor;
+import org.eclipse.ui.views.properties.ComboBoxPropertyDescriptor;
+
+/**
+ * This class implements the property source for a CDL type.
+ */
+public abstract class PropertySource implements IPropertySource {
+
+ protected PropertySource(Object element) {
+ m_element = element;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.views.properties.IPropertySource#getEditableValue()
+ */
+ public Object getEditableValue() {
+ return(m_element);
+ }
+
+ /**
+ * This method returns the raw property value.
+ *
+ * @param pd The property descriptor
+ * @return The raw value
+ */
+ public Object getRawPropertyValue(IPropertyDescriptor pd) {
+ Object ret=null;
+
+ /* GPB:
+ EStructuralFeature feature=m_element.eClass().getEStructuralFeature(
+ Integer.parseInt((String)pd.getId()));
+
+ if (feature instanceof EReference ||
+ feature instanceof EAttribute) {
+ ret = m_element.eGet(feature);
+ }
+ */
+
+ return(ret);
+ }
+
+ /* GPB
+ public IPropertyDescriptor createAttributePropertyDescriptor(EAttribute attr) {
+ IPropertyDescriptor ret=null;
+
+ EDataType type = attr.getEAttributeType();
+
+ if (isEditableList(attr)) {
+ ret = new EditableListPropertyDescriptor(
+ Integer.toString(attr.getFeatureID()),
+ getLabel(attr),
+ getStringValues(attr));
+ } else if (isDerivedList(attr)) {
+ java.util.List list=getStringValues(attr);
+ String[] values=new String[list.size()];
+ list.toArray(values);
+
+ ret = new ComboBoxPropertyDescriptor(
+ Integer.toString(attr.getFeatureID()),
+ getLabel(attr),
+ values);
+ } else if (isTextRegion(attr)) {
+ ret = new TextRegionPropertyDescriptor(
+ Integer.toString(attr.getFeatureID()),
+ getLabel(attr));
+ } else if (type.getInstanceClass() == String.class) {
+ ret = new TextPropertyDescriptor(
+ Integer.toString(attr.getFeatureID()),
+ getLabel(attr));
+ } else if (type.getInstanceClass() == Boolean.class) {
+ ret = new ComboBoxPropertyDescriptor(
+ Integer.toString(attr.getFeatureID()),
+ getLabel(attr),
+ new String[]{
+ Boolean.FALSE.toString(),
+ Boolean.TRUE.toString()});
+ } else if (type.getInstanceClass() == int.class) {
+ ret = new TextPropertyDescriptor(
+ Integer.toString(attr.getFeatureID()),
+ getLabel(attr));
+ } else if (type instanceof EEnum) {
+ EEnum enumval=(EEnum)type;
+ java.util.List list=enumval.getELiterals();
+ String[] vals=new String[list.size()];
+ for (int i=0; i < list.size(); i++) {
+ EEnumLiteral literal=(EEnumLiteral)list.get(i);
+ vals[i] = literal.getName();
+ }
+ ret = new ComboBoxPropertyDescriptor(
+ Integer.toString(attr.getFeatureID()),
+ getLabel(attr), vals);
+ }
+
+ return(ret);
+ }
+
+ public IPropertyDescriptor createReferencePropertyDescriptor(EReference ref) {
+ IPropertyDescriptor ret=null;
+
+ if (ref.isContainment() == false) {
+ if (ref.getUpperBound() == 1) {
+ java.util.List list=getValues(ref);
+
+ if (list.size() < COMBO_SIZE_LIMIT) {
+ String[] vals=getStringValues(ref);
+
+ ret = new ComboBoxPropertyDescriptor(
+ Integer.toString(ref.getFeatureID()),
+ getLabel(ref), vals);
+ } else {
+ Object cur=m_element.eGet(ref);
+
+ ret = new FilteredListPropertyDescriptor(
+ Integer.toString(ref.getFeatureID()),
+ getLabel(ref), getLabel(ref),
+ cur, list.toArray());
+ }
+ } else {
+ java.util.List current=(java.util.List)
+ m_element.eGet(ref);
+
+ ret = new MultiRefPropertyDescriptor(
+ Integer.toString(ref.getFeatureID()),
+ getLabel(ref), getLabel(ref),
+ m_element, current,
+ getValues(ref));
+ }
+ }
+
+ return(ret);
+ }
+ */
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors()
+ */
+ public IPropertyDescriptor[] getPropertyDescriptors() {
+ Iterator iter=null;
+ //EClass cls = m_element.eClass();
+ Collection descriptors = new Vector();
+
+ /* TODO: GPB
+ iter = cls.getEAllAttributes().iterator();
+ while(iter.hasNext()) {
+ EAttribute attr=(EAttribute)iter.next();
+
+ if (attr.isTransient() == false) {
+ IPropertyDescriptor pd=createAttributePropertyDescriptor(attr);
+
+ if (pd != null) {
+ descriptors.add(pd);
+ }
+ }
+ }
+
+ iter = cls.getEAllReferences().iterator();
+ while (iter.hasNext()) {
+ EReference ref=(EReference)iter.next();
+
+ if (ref.isTransient() == false) {
+ IPropertyDescriptor pd=createReferencePropertyDescriptor(ref);
+
+ if (pd != null) {
+ descriptors.add(pd);
+ }
+ }
+ }
+ */
+
+ return (IPropertyDescriptor[])descriptors.toArray( new IPropertyDescriptor[] {} );
+ }
+
+ /**
+ * This method determines whether the supplied property
+ * represents a derived list of values.
+ *
+ * @param feature The feature
+ * @return Whether the feature has a derived list
+ */
+ /*
+ public boolean isDerivedList(EStructuralFeature feature) {
+ boolean ret=false;
+
+ return(ret);
+ }
+ */
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object)
+ */
+ public Object getPropertyValue(Object id) {
+ /* TODO: GPB
+ EStructuralFeature feature=m_element.eClass().getEStructuralFeature( Integer.parseInt( (String)id ) );
+
+ Object result = m_element.eGet(feature);
+
+ if (feature instanceof EReference) {
+
+ if ((feature.getUpperBound() > 1 ||
+ feature.getUpperBound() == -1) &&
+ result instanceof java.util.List) {
+ java.util.List list=(java.util.List)result;
+
+ String str="";
+ for (int i=0; i < list.size(); i++) {
+ if (i > 0) {
+ str += ", ";
+ }
+ str += ViewSupport.getName(list.get(i));
+ }
+
+ result = str;
+
+ } else {
+ java.util.List values=getValues((EReference)feature);
+
+ if (values.size() < COMBO_SIZE_LIMIT) {
+ if (result == null) {
+ result = new Integer(0);
+ } else {
+ int index=values.indexOf(result);
+ index++;
+
+ result = new Integer(index);
+ }
+ } else {
+ result = ViewSupport.getName(result);
+ }
+ }
+ } else if (feature instanceof EAttribute) {
+ EDataType type = ((EAttribute)feature).getEAttributeType();
+
+ if (isDerivedList(feature) && isEditableList((EAttribute)feature) == false) {
+ java.util.List list=getStringValues((EAttribute)feature);
+
+ int index=list.indexOf(result);
+
+ if (index != -1) {
+ result = new Integer(index);
+ } else {
+ result = new Integer(0);
+ }
+
+ } else if (type.getInstanceClass() == Boolean.class) {
+
+ if (result == null) {
+ result = new Integer(0);
+ } else if (result instanceof Boolean) {
+ if (((Boolean)result).booleanValue()) {
+ result = new Integer(1);
+ } else {
+ result = new Integer(0);
+ }
+ }
+ } else if (type instanceof EEnum &&
+ result instanceof Enumerator) {
+ EEnum enumval=(EEnum)type;
+ Enumerator res=(Enumerator)result;
+
+ java.util.List list=enumval.getELiterals();
+
+ int pos=-1;
+
+ for (int i=0; pos == -1 && i < list.size(); i++) {
+ EEnumLiteral literal=(EEnumLiteral)list.get(i);
+
+ if (literal.getName().equals(res.getName())) {
+ pos = i;
+ }
+ }
+
+ result = null;
+ if (pos != -1) {
+ result = new Integer(pos);
+ }
+ } else if (type.getInstanceClass() == int.class) {
+
+ if (result instanceof Integer &&
+ ((Integer)result).intValue() == 0 &&
+ isZeroBlank((EAttribute)feature)) {
+ result = "";
+ } else {
+ result = ""+result;
+ }
+
+ } else if (result == null) {
+ result = "";
+ }
+ }
+
+ return(result);
+ */
+ return(null);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.views.properties.IPropertySource#isPropertySet(java.lang.Object)
+ */
+ public boolean isPropertySet(Object id) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.views.properties.IPropertySouce#resetPropertyValue(java.lang.Object)
+ */
+ public void resetPropertyValue(Object id) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object)
+ */
+ public void setPropertyValue(Object id, Object value) {
+ /* TODO: GPB
+ EStructuralFeature feature=m_element.eClass().getEStructuralFeature(Integer.parseInt((String)id ));
+
+ if (feature instanceof EReference) {
+
+ if (value instanceof Integer) {
+ int index=((Integer)value).intValue();
+ value = getSelectedValue((EReference)feature, index);
+ } else if (value instanceof java.util.List) {
+
+ // Get the list and then update each element
+ java.util.List list=(java.util.List)
+ m_element.eGet(feature);
+
+ list.clear();
+
+ Iterator iter=((java.util.List)value).iterator();
+ while (iter.hasNext()) {
+ list.add(iter.next());
+ }
+ } else {
+ org.pi4soa.designer.inference.InferenceManager.propertyChange(m_element,
+ ((EReference)feature).getName(), value);
+ }
+
+ } else if (feature instanceof EAttribute) {
+ EDataType type=((EAttribute)feature).getEAttributeType();
+
+ if (value instanceof Integer) {
+
+ if (value instanceof Integer && isDerivedList(feature)) {
+ java.util.List list=getStringValues((EAttribute)feature);
+ int index=((Integer)value).intValue();
+
+ if (index != -1) {
+ value = list.get(((Integer)value).intValue());
+ } else {
+ value = "";
+ }
+
+ } else if (type.getInstanceClass() == Boolean.class) {
+ if (((Integer)value).intValue() == 0) {
+ value = Boolean.FALSE;
+ } else {
+ value = Boolean.TRUE;
+ }
+ } else if (type instanceof EEnum) {
+ int val=((Integer)value).intValue();
+
+ value = getEnumValue((EEnum)type, val);
+ }
+ } else {
+ if (type.getInstanceClass() == int.class) {
+
+ if (value instanceof String &&
+ ((String)value).trim().length() > 0) {
+ value = getIntegerValue((EAttribute)feature,
+ (String)value);
+ }
+
+ if (value == null) {
+ // Default value for empty field
+ value = new Integer(0);
+ }
+ } else if (type.getInstanceClass() == String.class) {
+
+ org.pi4soa.designer.inference.InferenceManager.propertyChange(m_element,
+ ((EAttribute)feature).getName(), value);
+
+ } else if (type instanceof EEnum) {
+
+ if (value instanceof String) {
+ org.pi4soa.designer.inference.InferenceManager.propertyChange(m_element,
+ ((EAttribute)feature).getName(), value);
+
+ value = getEnumValue((EEnum)type, (String)value);
+ } else if (value instanceof Enumerator) {
+ org.pi4soa.designer.inference.InferenceManager.propertyChange(m_element,
+ ((EAttribute)feature).getName(),
+ ((Enumerator)value).getLiteral());
+ }
+ }
+ }
+ }
+
+ m_element.eSet(feature, value);
+ */
+ }
+
+ /**
+ * This method returns the integer associated with the supplied
+ * string value and attribute.
+ *
+ * @param attr The attribute
+ * @param value The string value
+ * @return The integer, or null if the conversion failed
+ */
+ /*
+ protected Integer getIntegerValue(EAttribute attr, String value) {
+ Integer ret=null;
+
+ try {
+ ret = new Integer(value);
+ } catch(Exception e) {
+ logger.severe("Failed to convert string '"+
+ value+"' to integer: "+e);
+ }
+
+ return(ret);
+ }
+ */
+
+ /**
+ * This method returns whether the supplied integer
+ * attribute should use a blank string when the
+ * integer value is zero.
+ *
+ * @param attr The atribute
+ * @return Whether a blank string should be used for zero
+ */
+ /*
+ protected boolean isZeroBlank(EAttribute attr) {
+ boolean ret=false;
+
+ return(ret);
+ }
+ */
+
+ /**
+ * This method determines if the supplied attribute can be
+ * provided as a text region.
+ *
+ * @param attr The attribute
+ * @return Whether it can be provided as a text region
+ */
+ /*
+ public boolean isTextRegion(EAttribute attr) {
+ boolean ret=false;
+
+ return(ret);
+ }
+ */
+
+ /**
+ * This method determines if the supplied attribute can be
+ * provided as an editable list.
+ *
+ * @param attr The attribute
+ * @return Whether it can be provided as an editable list
+ */
+ /*
+ public boolean isEditableList(EAttribute attr) {
+ boolean ret=false;
+
+ return(ret);
+ }
+ */
+
+ /**
+ * This method provides the list of values that can be
+ * provided in an editable property field with associated
+ * list.
+ *
+ * @param attr The attribute
+ * @return The list of values
+ */
+ /*
+ public java.util.List getStringValues(EAttribute attr) {
+ java.util.List ret=new java.util.Vector();
+ return(ret);
+ }
+ */
+
+ /**
+ * This method returns the list of values appropriate for
+ * the reference.
+ *
+ * @param ref The reference
+ * @return The list of values
+ */
+ /*
+ public String[] getStringValues(EReference ref) {
+ String[] ret=new String[0];
+
+ java.util.List list=getValues(ref);
+ if (list != null) {
+ ret = new String[list.size()+1];
+ ret[0] = "";
+
+ for (int i=0; i < list.size(); i++) {
+ ret[i+1] = ViewSupport.getName(list.get(i));
+ }
+ }
+
+ return(ret);
+ }
+ */
+
+ /**
+ * This method returns the selected value associated with
+ * the reference and the index.
+ *
+ * @param ref The reference
+ * @param index The index
+ * @return The selected value
+ */
+ /*
+ public Object getSelectedValue(EReference ref, int index) {
+ Object ret=null;
+
+ // Subtract 1 from the index to account for the initial
+ // empty slot
+ index--;
+
+ // Check for known referenced class types
+ java.util.List list=getValues(ref);
+
+ if (list != null && index >= 0 &&
+ index < list.size()) {
+ ret = list.get(index);
+ }
+
+ return(ret);
+ }
+ */
+
+ /**
+ * This method returns the list of values relevant for the
+ * supplied reference.
+ *
+ * @param ref The reference
+ * @return The list of values
+ */
+ public java.util.List getValues(IPropertyDescriptor pd) {
+ java.util.List ret=null;
+
+ /* TODO: GPB
+ EStructuralFeature feature=m_element.eClass().getEStructuralFeature(
+ Integer.parseInt((String)pd.getId()));
+
+ if (feature instanceof EReference) {
+ ret = getValues((EReference)feature);
+ } else if (feature instanceof EAttribute) {
+ ret = getValues((EAttribute)feature);
+ }
+ */
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the list of values relevant for the
+ * supplied attribute.
+ *
+ * @param attr The attribute
+ * @return The list of values
+ */
+ /*
+ public java.util.List getValues(EAttribute attr) {
+ java.util.List ret=new java.util.Vector();
+
+ if (attr.getEAttributeType() instanceof EEnum) {
+ EEnum enumval=(EEnum)attr.getEAttributeType();
+ java.util.List list=enumval.getELiterals();
+ for (int i=0; i < list.size(); i++) {
+ EEnumLiteral literal=(EEnumLiteral)list.get(i);
+ ret.add(literal.getName());
+ }
+ } else {
+ ret = getStringValues(attr);
+ }
+
+ return(ret);
+ }
+ */
+
+ /**
+ * This method returns the list of values relevant for the
+ * supplied reference.
+ *
+ * @param ref The reference
+ * @return The list of values
+ */
+ //public abstract java.util.List getValues(EReference ref);
+
+ /**
+ * This method returns the enumeration value.
+ *
+ * @param enumval The enumeration
+ * @param index The index position
+ * @return The value
+ */
+ /*
+ public Object getEnumValue(EEnum enumval, int index) {
+ Object ret=null;
+
+ try {
+ String clsName=getEnumClassName(enumval);
+
+ Class cls=Class.forName(clsName);
+
+ java.lang.reflect.Method met=
+ cls.getMethod("get", new Class[]{int.class});
+
+ ret = met.invoke(null, new Object[]{new Integer(index+1)});
+
+ } catch(Exception e) {
+ // Log error
+ logger.severe("Failed to get enumeration value: "+e);
+ }
+
+ return(ret);
+ }
+ */
+
+ /**
+ * This method returns the enumeration value.
+ *
+ * @param enumval The enumeration
+ * @param val The selection text
+ * @return The value
+ */
+ /*
+ public Object getEnumValue(EEnum enumval, String val) {
+ Object ret=null;
+
+ try {
+ String clsName=getEnumClassName(enumval);
+
+ Class cls=Class.forName(clsName);
+
+ java.lang.reflect.Method met=
+ cls.getMethod("get", new Class[]{String.class});
+
+ ret = met.invoke(null, new Object[]{val});
+
+ } catch(Exception e) {
+ // Log error
+ logger.severe("Failed to get enumeration value: "+e);
+ }
+
+ return(ret);
+ }
+ */
+
+ /**
+ * This method returns the class name for the enumeration
+ * value.
+ *
+ * @param enumval The enumeration value
+ * @return The class name
+ */
+ //protected abstract String getEnumClassName(EEnum enumval);
+
+ /**
+ * This method returns the element.
+ *
+ * @return The element
+ */
+ public Object getElement() {
+ return(m_element);
+ }
+
+ public void addPropertyChangeListener(java.beans.PropertyChangeListener l) {
+ if (logger.isLoggable(java.util.logging.Level.FINEST)) {
+ logger.finest(">> "+this+" add "+l);
+ }
+
+ synchronized(m_propertyChangeListeners) {
+ if (m_propertyChangeListeners.size() == 0) {
+ // Register to receive notifications
+
+ // TODO: GPB How to register for events
+ //m_element.eAdapters().add(m_adapter);
+ }
+
+ if (m_propertyChangeListeners.contains(l) == false) {
+ m_propertyChangeListeners.add(l);
+ }
+ }
+ }
+
+ public void removePropertyChangeListener(java.beans.PropertyChangeListener l) {
+ if (logger.isLoggable(java.util.logging.Level.FINEST)) {
+ logger.finest(">> "+this+" remove "+l);
+ }
+
+ synchronized(m_propertyChangeListeners) {
+ m_propertyChangeListeners.remove(l);
+
+ if (m_propertyChangeListeners.size() == 0) {
+ // Un-Register to receive notifications
+
+ // TODO: GPB How to register for events
+ //m_element.eAdapters().remove(m_adapter);
+ }
+ }
+ }
+
+ private static Logger logger = Logger.getLogger("org.pi4soa.designer.util");
+
+ private static final int COMBO_SIZE_LIMIT = 15;
+
+ private Object m_element=null;
+ //private org.eclipse.emf.common.notify.Adapter m_adapter=new PropertySourceAdapter();
+ private java.util.Vector m_propertyChangeListeners=new java.util.Vector();
+
+ /* GPB: Need to find another solution
+ public class PropertySourceAdapter implements org.eclipse.emf.common.notify.Adapter {
+
+ public Notifier getTarget() {
+ return getElement();
+ }
+
+ public boolean isAdapterForType(Object type) {
+ return false;
+ }
+
+ public void notifyChanged(Notification notification) {
+ String propName=null;
+ if (notification.getFeature() instanceof EAttribute) {
+ propName = ((EAttribute)notification.getFeature()).getName();
+ } else if (notification.getFeature() instanceof EReference) {
+ propName = ((EReference)notification.getFeature()).getName();
+ }
+
+ if (propName != null) {
+ java.beans.PropertyChangeEvent evt=
+ new java.beans.PropertyChangeEvent(PropertySource.this,
+ propName, notification.getOldValue(),
+ notification.getNewValue());
+
+ for (int i=0; i < m_propertyChangeListeners.size(); i++) {
+ java.beans.PropertyChangeListener l=
+ (java.beans.PropertyChangeListener)
+ m_propertyChangeListeners.get(i);
+ l.propertyChange(evt);
+ }
+ }
+ }
+
+ public void setTarget(Notifier newTarget) {
+ }
+ }
+ */
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/view/FileURLCellEditor.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/view/FileURLCellEditor.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/view/FileURLCellEditor.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,552 @@
+/*
+ * Copyright 2005-7 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Feb 12, 2007 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.view;
+
+import java.text.MessageFormat;
+
+import org.eclipse.jface.util.Assert;
+import org.eclipse.jface.viewers.DialogCellEditor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.FocusAdapter;
+import org.eclipse.swt.events.FocusEvent;
+import org.eclipse.swt.events.KeyAdapter;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.TraverseEvent;
+import org.eclipse.swt.events.TraverseListener;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.window.Window;
+
+/**
+ * This class implements the editable file selection cell editor.
+ */
+public class FileURLCellEditor extends DialogCellEditor {
+
+ /**
+ * This is the constructor for the editable file
+ * selection cell editor.
+ *
+ * @param parent The parent
+ */
+ public FileURLCellEditor(Composite parent, String value,
+ Object selectedObject) {
+ super(parent);
+
+ m_value = value;
+ m_selectedObject = selectedObject;
+ }
+
+ /**
+ * Checks to see if the "deleteable" state (can delete/
+ * nothing to delete) has changed and if so fire an
+ * enablement changed notification.
+ */
+ private void checkDeleteable() {
+ boolean oldIsDeleteable = isDeleteable;
+ isDeleteable = isDeleteEnabled();
+ if (oldIsDeleteable != isDeleteable) {
+ fireEnablementChanged(DELETE);
+ }
+ }
+
+ /**
+ * Checks to see if the "selectable" state (can select)
+ * has changed and if so fire an enablement changed notification.
+ */
+ private void checkSelectable() {
+ boolean oldIsSelectable = isSelectable;
+ isSelectable = isSelectAllEnabled();
+ if (oldIsSelectable != isSelectable) {
+ fireEnablementChanged(SELECT_ALL);
+ }
+ }
+
+ /**
+ * Checks to see if the selection state (selection /
+ * no selection) has changed and if so fire an
+ * enablement changed notification.
+ */
+ private void checkSelection() {
+ boolean oldIsSelection = isSelection;
+ isSelection = m_textField.getSelectionCount() > 0;
+ if (oldIsSelection != isSelection) {
+ fireEnablementChanged(COPY);
+ fireEnablementChanged(CUT);
+ }
+ }
+
+ /**
+ * Opens a dialog box under the given parent control and returns the
+ * dialog's value when it closes, or <code>null</code> if the dialog
+ * was cancelled or no selection was made in the dialog.
+ * <p>
+ * This framework method must be implemented by concrete subclasses.
+ * It is called when the user has pressed the button and the dialog
+ * box must pop up.
+ * </p>
+ *
+ * @param cellEditorWindow the parent control cell editor's window
+ * so that a subclass can adjust the dialog box accordingly
+ * @return the selected value, or <code>null</code> if the dialog was
+ * cancelled or no selection was made in the dialog
+ */
+ protected Object openDialogBox(Control cellEditorWindow) {
+ String ret=null;
+
+ m_dirty = false;
+
+ org.eclipse.swt.widgets.FileDialog dialog=
+ new org.eclipse.swt.widgets.FileDialog(getControl().getShell());
+
+ dialog.setFileName(m_value);
+
+ ret = dialog.open();
+
+ if (ret != null) {
+ try {
+ org.eclipse.core.runtime.Path path=
+ new org.eclipse.core.runtime.Path(ret);
+
+ /* TODO: GPB locate resource
+ *
+ *
+ org.eclipse.emf.ecore.EObject m_eobject=null;
+
+ if (m_selectedObject instanceof org.eclipse.emf.ecore.EObject) {
+ m_eobject = (org.eclipse.emf.ecore.EObject)m_selectedObject;
+ }
+
+ if (m_eobject != null && m_eobject.eResource() != null) {
+
+ ret = getRelativePath(m_eobject.eResource().getURI(),
+ org.eclipse.emf.common.util.URI.createFileURI(path.toPortableString()));
+ }
+ */
+
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method identifies the relative path difference between
+ * two files specified by a 'from' and 'to' URI.
+ *
+ * @param from The 'from' file
+ * @param to The 'to' file
+ * @return The relative path between the two files
+ */
+ /*
+ protected String getRelativePath(org.eclipse.emf.common.util.URI from,
+ org.eclipse.emf.common.util.URI to) {
+ StringBuffer ret=new StringBuffer();
+
+ // Find common root segment
+ int common=0;
+ for (; common < from.segmentCount() &&
+ common < to.segmentCount() &&
+ from.segments()[common].equals(to.segments()[common]);
+ common++) {
+ }
+
+ for (int i=common; i < from.segmentCount()-1; i++) {
+ ret.append("..");
+ ret.append('/');
+ }
+
+ for (int i=common; i < to.segmentCount(); i++) {
+ ret.append(to.segments()[i]);
+
+ if (i < to.segmentCount()-1) {
+ ret.append('/');
+ }
+ }
+
+ return(ret.toString());
+ }
+ */
+
+ /**
+ * This method creates the contents for the cell editor.
+ *
+ * @param cell The cell
+ */
+ protected Control createContents(Composite cell) {
+ m_textField = new Text(cell, getStyle());
+ m_textField.addSelectionListener(new SelectionAdapter() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ handleDefaultSelection(e);
+ }
+ });
+ m_textField.addKeyListener(new KeyAdapter() {
+ // hook key pressed - see PR 14201
+ public void keyPressed(KeyEvent e) {
+ keyReleaseOccured(e);
+
+ // as a result of processing the above call, clients may have
+ // disposed this cell editor
+ if ((getControl() == null) || getControl().isDisposed())
+ return;
+ checkSelection(); // see explaination below
+ checkDeleteable();
+ checkSelectable();
+ }
+ });
+ m_textField.addTraverseListener(new TraverseListener() {
+ public void keyTraversed(TraverseEvent e) {
+ if (e.detail == SWT.TRAVERSE_ESCAPE
+ || e.detail == SWT.TRAVERSE_RETURN) {
+ e.doit = false;
+ }
+ }
+ });
+ // We really want a selection listener but it is not supported so we
+ // use a key listener and a mouse listener to know when selection changes
+ // may have occured
+ m_textField.addMouseListener(new MouseAdapter() {
+ public void mouseUp(MouseEvent e) {
+ checkSelection();
+ checkDeleteable();
+ checkSelectable();
+ }
+ });
+ m_textField.addFocusListener(new FocusAdapter() {
+ public void focusLost(FocusEvent e) {
+ FileURLCellEditor.this.focusLost();
+ }
+ });
+ m_textField.setFont(cell.getFont());
+ m_textField.setBackground(cell.getBackground());
+ m_textField.setText("");//$NON-NLS-1$
+ m_textField.addModifyListener(getModifyListener());
+
+ return(m_textField);
+ }
+
+ /**
+ * This method updates the contents field.
+ */
+ protected void updateContents(Object value) {
+ if (m_textField == null) {
+ return;
+ }
+
+ String text = "";//$NON-NLS-1$
+ if (value != null)
+ text = value.toString();
+
+ //if (text.equals(m_textField.getText()) == false) {
+ m_textField.setText(text);
+ //}
+ }
+
+ protected Object doGetValue() {
+ /*
+ if (m_textField == null) {
+ return(m_initialValue);
+ }
+ */
+ return(m_textField.getText());
+ //return(m_value);
+ }
+
+ protected void doSetFocus() {
+ if (m_textField != null) {
+ m_textField.selectAll();
+ m_textField.setFocus();
+ checkSelection();
+ checkDeleteable();
+ checkSelectable();
+ }
+ }
+
+ protected void doSetValue(Object value) {
+ Assert.isTrue(m_textField != null && (value instanceof String));
+ m_textField.removeModifyListener(getModifyListener());
+ m_textField.setText((String) value);
+ m_textField.addModifyListener(getModifyListener());
+ }
+
+ protected void editOccured(ModifyEvent e) {
+ String value = m_textField.getText();
+ if (value == null) {
+ value = "";
+ }
+
+ Object typedValue = value;
+ boolean oldValidState = isValueValid();
+ boolean newValidState = isCorrect(typedValue);
+
+ if (typedValue == null && newValidState) {
+ Assert.isTrue(false,
+ "Validator isn't limiting the cell editor's type range");//$NON-NLS-1$
+ }
+
+ if (!newValidState) {
+ // try to insert the current value into the error message.
+ setErrorMessage(MessageFormat.format(getErrorMessage(),
+ new Object[] { value }));
+ }
+
+ valueChanged(oldValidState, newValidState);
+ }
+
+ /**
+ * Since a text editor field is scrollable we don't
+ * set a minimumSize.
+ */
+ public LayoutData getLayoutData() {
+ return new LayoutData();
+ }
+
+ /**
+ * Return the modify listener.
+ */
+ private ModifyListener getModifyListener() {
+ if (modifyListener == null) {
+ modifyListener = new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ editOccured(e);
+ }
+ };
+ }
+ return modifyListener;
+ }
+
+ /**
+ * Handles a default selection event from the text control by applying the editor
+ * value and deactivating this cell editor.
+ *
+ * @param event the selection event
+ *
+ * @since 3.0
+ */
+ protected void handleDefaultSelection(SelectionEvent event) {
+ // same with enter-key handling code in keyReleaseOccured(e);
+ fireApplyEditorValue();
+ deactivate();
+ }
+
+ /**
+ * The <code>TextCellEditor</code> implementation of this
+ * <code>CellEditor</code> method returns <code>true</code> if
+ * the current selection is not empty.
+ */
+ public boolean isCopyEnabled() {
+ if (m_textField == null || m_textField.isDisposed())
+ return false;
+ return m_textField.getSelectionCount() > 0;
+ }
+
+ /**
+ * The <code>TextCellEditor</code> implementation of this
+ * <code>CellEditor</code> method returns <code>true</code> if
+ * the current selection is not empty.
+ */
+ public boolean isCutEnabled() {
+ if (m_textField == null || m_textField.isDisposed())
+ return false;
+ return m_textField.getSelectionCount() > 0;
+ }
+
+ /**
+ * The <code>TextCellEditor</code> implementation of this
+ * <code>CellEditor</code> method returns <code>true</code>
+ * if there is a selection or if the caret is not positioned
+ * at the end of the text.
+ */
+ public boolean isDeleteEnabled() {
+ if (m_textField == null || m_textField.isDisposed())
+ return false;
+ return m_textField.getSelectionCount() > 0
+ || m_textField.getCaretPosition() < m_textField.getCharCount();
+ }
+
+ /**
+ * The <code>TextCellEditor</code> implementation of this
+ * <code>CellEditor</code> method always returns <code>true</code>.
+ */
+ public boolean isPasteEnabled() {
+ if (m_textField == null || m_textField.isDisposed())
+ return false;
+ return true;
+ }
+
+ /**
+ * The <code>TextCellEditor</code> implementation of this
+ * <code>CellEditor</code> method always returns <code>true</code>.
+ */
+ public boolean isSaveAllEnabled() {
+ if (m_textField == null || m_textField.isDisposed())
+ return false;
+ return true;
+ }
+
+ /**
+ * Returns <code>true</code> if this cell editor is
+ * able to perform the select all action.
+ * <p>
+ * This default implementation always returns
+ * <code>false</code>.
+ * </p>
+ * <p>
+ * Subclasses may override
+ * </p>
+ * @return <code>true</code> if select all is possible,
+ * <code>false</code> otherwise
+ */
+ public boolean isSelectAllEnabled() {
+ if (m_textField == null || m_textField.isDisposed())
+ return false;
+ return m_textField.getCharCount() > 0;
+ }
+
+ /**
+ * Processes a key release event that occurred in this cell editor.
+ * <p>
+ * The <code>TextCellEditor</code> implementation of this framework method
+ * ignores when the RETURN key is pressed since this is handled in
+ * <code>handleDefaultSelection</code>.
+ * An exception is made for Ctrl+Enter for multi-line texts, since
+ * a default selection event is not sent in this case.
+ * </p>
+ *
+ * @param keyEvent the key event
+ */
+ protected void keyReleaseOccured(KeyEvent keyEvent) {
+ if (keyEvent.character == '\r') { // Return key
+ // Enter is handled in handleDefaultSelection.
+ // Do not apply the editor value in response to an Enter key event
+ // since this can be received from the IME when the intent is -not-
+ // to apply the value.
+ // See bug 39074 [CellEditors] [DBCS] canna input mode fires bogus event from Text Control
+ //
+ // An exception is made for Ctrl+Enter for multi-line texts, since
+ // a default selection event is not sent in this case.
+ if (m_textField != null && !m_textField.isDisposed()
+ && (m_textField.getStyle() & SWT.MULTI) != 0) {
+ if ((keyEvent.stateMask & SWT.CTRL) != 0) {
+ super.keyReleaseOccured(keyEvent);
+ }
+ }
+ return;
+ }
+ super.keyReleaseOccured(keyEvent);
+ }
+
+ /**
+ * The <code>TextCellEditor</code> implementation of this
+ * <code>CellEditor</code> method copies the
+ * current selection to the clipboard.
+ */
+ public void performCopy() {
+ m_textField.copy();
+ }
+
+ /**
+ * The <code>TextCellEditor</code> implementation of this
+ * <code>CellEditor</code> method cuts the
+ * current selection to the clipboard.
+ */
+ public void performCut() {
+ m_textField.cut();
+ checkSelection();
+ checkDeleteable();
+ checkSelectable();
+ }
+
+ /**
+ * The <code>TextCellEditor</code> implementation of this
+ * <code>CellEditor</code> method deletes the
+ * current selection or, if there is no selection,
+ * the character next character from the current position.
+ */
+ public void performDelete() {
+ if (m_textField.getSelectionCount() > 0)
+ // remove the contents of the current selection
+ m_textField.insert(""); //$NON-NLS-1$
+ else {
+ // remove the next character
+ int pos = m_textField.getCaretPosition();
+ if (pos < m_textField.getCharCount()) {
+ m_textField.setSelection(pos, pos + 1);
+ m_textField.insert(""); //$NON-NLS-1$
+ }
+ }
+ checkSelection();
+ checkDeleteable();
+ checkSelectable();
+ }
+
+ /**
+ * The <code>TextCellEditor</code> implementation of this
+ * <code>CellEditor</code> method pastes the
+ * the clipboard contents over the current selection.
+ */
+ public void performPaste() {
+ m_textField.paste();
+ checkSelection();
+ checkDeleteable();
+ checkSelectable();
+ }
+
+ /**
+ * The <code>TextCellEditor</code> implementation of this
+ * <code>CellEditor</code> method selects all of the
+ * current text.
+ */
+ public void performSelectAll() {
+ m_textField.selectAll();
+ checkSelection();
+ checkDeleteable();
+ }
+
+ /**
+ * This method returns whether a change has occurred.
+ *
+ * @return Whether a change has occurred
+ */
+ public boolean isDirty() {
+ return(m_dirty);
+ }
+
+ //private java.util.List m_values=null;
+ //private String m_title=null;
+ private String m_value=null;
+ private Object m_selectedObject=null;
+ private boolean m_dirty=false;
+ private Text m_textField;
+ private ModifyListener modifyListener;
+ private boolean isSelection = false;
+ private boolean isDeleteable = false;
+ private boolean isSelectable = false;
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/view/GraphicalComponent.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/view/GraphicalComponent.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/view/GraphicalComponent.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2005-7 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * 23 Feb 2007 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.view;
+
+import org.eclipse.draw2d.geometry.Rectangle;
+
+public interface GraphicalComponent {
+
+ public Rectangle getComponentBounds();
+
+ public GraphicalComponent getComponentParent();
+
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/view/LinkPropertySource.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/view/LinkPropertySource.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/view/LinkPropertySource.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,285 @@
+/*
+ * Copyright 2005-7 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Feb 21, 2007 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.view;
+
+import java.util.logging.Logger;
+
+import org.eclipse.ui.views.properties.ComboBoxPropertyDescriptor;
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.savara.scenario.model.*;
+import org.savara.tools.scenario.designer.DesignerDefinitions;
+
+/**
+ * This class implements the property source for a scenario
+ * message link.
+ */
+public class LinkPropertySource implements IPropertySource {
+
+ private static final String MESSAGE_PROPERTY = "MessageProperty";
+
+ public LinkPropertySource(org.savara.scenario.model.Link element) {
+ m_element = element;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.views.properties.IPropertySource#getEditableValue()
+ */
+ public Object getEditableValue() {
+ return(m_element);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors()
+ */
+ public IPropertyDescriptor[] getPropertyDescriptors() {
+ IPropertyDescriptor[] ret=new IPropertyDescriptor[] {};
+
+ /*
+ if (m_element.getSource() != null &&
+ m_element.getTarget() != null) {
+ ScenarioPropertySource sps=new ScenarioPropertySource(m_element.getSource());
+ boolean f_businessView=DesignerDefinitions.isPreference(DesignerDefinitions.BUSINESS_VIEW);
+
+ java.util.Vector pds=new java.util.Vector();
+
+ String[] values=getMessageEntries();
+
+ // Only display message combobox if messages available
+ // to select
+ if (values.length > 1 &&
+ NamesUtil.isSet(m_element.getScenario().
+ getChoreographyDescriptionURL())) {
+ pds.add(new ComboBoxPropertyDescriptor(
+ MESSAGE_PROPERTY,
+ "Message",
+ values));
+ } else {
+ pds.add(sps.createAttributePropertyDescriptor(
+ ScenarioPackage.eINSTANCE.getMessageEvent_IsRequest()));
+ pds.add(sps.createAttributePropertyDescriptor(
+ ScenarioPackage.eINSTANCE.getMessageEvent_OperationName()));
+ pds.add(sps.createAttributePropertyDescriptor(
+ ScenarioPackage.eINSTANCE.getMessageEvent_FaultName()));
+ pds.add(sps.createAttributePropertyDescriptor(
+ ScenarioPackage.eINSTANCE.getMessageEvent_MessageType()));
+ }
+
+ pds.add(sps.createAttributePropertyDescriptor(
+ ScenarioPackage.eINSTANCE.getScenarioObject_Description()));
+
+ pds.add(sps.createAttributePropertyDescriptor(
+ ScenarioPackage.eINSTANCE.getLifelineItem_CausesException()));
+
+ pds.add(sps.createAttributePropertyDescriptor(
+ ScenarioPackage.eINSTANCE.getMessageEvent_ValueURL()));
+
+ ret = new IPropertyDescriptor[pds.size()];
+ pds.copyInto(ret);
+ } else {
+ ret = new IPropertyDescriptor[] {};
+ }
+ */
+
+ return(ret);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object)
+ */
+ public Object getPropertyValue(Object id) {
+ Object ret=null;
+
+ if (m_element.getSource() != null &&
+ m_element.getTarget() != null) {
+
+ /* TODO: GPB:
+ if (id == MESSAGE_PROPERTY) {
+ java.util.List list=ModelUtil.getMessageDefinitions(
+ m_element.getSource(), m_element.getTarget());
+
+ org.pi4soa.service.behavior.MessageDefinition mdef=
+ ModelUtil.getMessageDefinition(m_element,
+ list);
+
+ if (mdef != null && list != null) {
+ int index=list.indexOf(mdef);
+
+ if (index != -1) {
+ ret = new Integer(index+1);
+ }
+ }
+
+ if (ret == null) {
+ ret = new Integer(0);
+ }
+ } else {
+ ScenarioPropertySource sps=new ScenarioPropertySource(m_element.getSource());
+
+ ret = sps.getPropertyValue(id);
+ }
+ */
+ }
+
+ return(ret);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.views.properties.IPropertySource#isPropertySet(java.lang.Object)
+ */
+ public boolean isPropertySet(Object id) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.views.properties.IPropertySouce#resetPropertyValue(java.lang.Object)
+ */
+ public void resetPropertyValue(Object id) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object)
+ */
+ public void setPropertyValue(Object id, Object value) {
+
+ if (m_element.getSource() != null &&
+ m_element.getTarget() != null) {
+
+ if (id == MESSAGE_PROPERTY) {
+ if (value instanceof Integer) {
+ /* TODO: GPB:
+ java.util.List list=ModelUtil.getMessageDefinitions(m_element.getSource(),
+ m_element.getTarget());
+ int index=((Integer)value).intValue();
+
+ // Deduct 1 from the index to fid the real list position
+ // as we need to take into account the empty initial
+ // entry representing no message definition
+ index--;
+
+ if (list != null && index != -1 && index < list.size()) {
+ org.pi4soa.service.behavior.MessageDefinition mdef=
+ (org.pi4soa.service.behavior.MessageDefinition)list.get(index);
+
+ // Set the fields on both the source and target
+ if (mdef.getOperationDefinition() != null) {
+ m_element.getSource().setOperationName(mdef.getOperationDefinition().getName());
+ m_element.getTarget().setOperationName(mdef.getOperationDefinition().getName());
+ }
+
+ if (mdef.getInformationType() != null) {
+ if (NamesUtil.isSet(mdef.getInformationType().getFullyQualifiedType())) {
+ m_element.getSource().setMessageType(mdef.getInformationType().getFullyQualifiedType());
+ m_element.getTarget().setMessageType(mdef.getInformationType().getFullyQualifiedType());
+ } else if (NamesUtil.isSet(mdef.getInformationType().getFullyQualifiedElement())) {
+ m_element.getSource().setMessageType(mdef.getInformationType().getFullyQualifiedElement());
+ m_element.getTarget().setMessageType(mdef.getInformationType().getFullyQualifiedElement());
+ }
+ }
+
+ // 9/6/08 - removed service type
+ //m_element.getSource().setServiceType(
+ // mdef.getOperationDefinition().getServiceType().getFullyQualifiedName());
+ //m_element.getTarget().setServiceType(
+ // mdef.getOperationDefinition().getServiceType().getFullyQualifiedName());
+
+ m_element.getSource().setFaultName(mdef.getFullyQualifiedFaultName());
+ m_element.getTarget().setFaultName(mdef.getFullyQualifiedFaultName());
+
+ m_element.getSource().setIsRequest(Boolean.valueOf(
+ mdef.getClassification() ==
+ org.pi4soa.service.behavior.MessageClassification.REQUEST));
+ m_element.getTarget().setIsRequest(Boolean.valueOf(
+ mdef.getClassification() ==
+ org.pi4soa.service.behavior.MessageClassification.REQUEST));
+ } else {
+ // Clear the source and target fields
+ m_element.getSource().setOperationName(null);
+ m_element.getTarget().setOperationName(null);
+
+ m_element.getSource().setMessageType(null);
+ m_element.getTarget().setMessageType(null);
+
+ //m_element.getSource().setServiceType(null);
+ //m_element.getTarget().setServiceType(null);
+
+ m_element.getSource().setFaultName(null);
+ m_element.getTarget().setFaultName(null);
+
+ m_element.getSource().setIsRequest(Boolean.TRUE);
+ m_element.getTarget().setIsRequest(Boolean.TRUE);
+ }
+ */
+ }
+ } else {
+ ScenarioPropertySource sps=new ScenarioPropertySource(m_element.getSource());
+ //ScenarioPropertySource tps=new ScenarioPropertySource(m_element.getTarget());
+
+ sps.setPropertyValue(id, value);
+ //tps.setPropertyValue(id, value);
+
+ // Copy value from source to target
+ // TODO: Need to tidy up property sources so can
+ // easily deal with delegating copy - but issue
+ // is that the list of values may be different
+ // for a particular field, due to other values in
+ // the message events - so ideally need to just
+ // set a value, rather than passing a list index
+
+ /* TODO: GPB:
+ EStructuralFeature feature=
+ m_element.getSource().eClass().getEStructuralFeature(
+ Integer.parseInt( (String)id ) );
+
+ m_element.getTarget().eSet(feature,
+ m_element.getSource().eGet(feature));
+ */
+ }
+ }
+ }
+
+ protected String[] getMessageEntries() {
+ /* TODO: GPB:
+ java.util.List list=ModelUtil.getMessageDefinitions(m_element.getSource(),
+ m_element.getTarget());
+ String[] ret=new String[list.size()+1];
+
+ ret[0] = "";
+
+ for (int i=0; i < list.size(); i++) {
+ org.pi4soa.service.behavior.MessageDefinition mdef=
+ (org.pi4soa.service.behavior.MessageDefinition)
+ list.get(i);
+
+ ret[i+1] = ModelUtil.getMessageDefinitionText(mdef);
+ }
+
+ return(ret);
+ */
+ return(new String[0]);
+ }
+
+ private static Logger logger = Logger.getLogger("org.pi4soa.service.test.designer.view");
+
+ private org.savara.scenario.model.Link m_element=null;
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/view/RolePropertySource.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/view/RolePropertySource.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/view/RolePropertySource.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,313 @@
+/*
+ * Copyright 2005 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Jul 8, 2005 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.view;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Vector;
+import java.util.logging.Logger;
+
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.eclipse.ui.views.properties.TextPropertyDescriptor;
+import org.eclipse.ui.views.properties.ComboBoxPropertyDescriptor;
+import org.savara.scenario.model.*;
+
+/**
+ * This class implements the property source for a scenario
+ * participant.
+ */
+public class RolePropertySource implements IPropertySource {
+
+ public RolePropertySource(Role element) {
+ m_element = element;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.views.properties.IPropertySource#getEditableValue()
+ */
+ public Object getEditableValue() {
+ return(m_element);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors()
+ */
+ public IPropertyDescriptor[] getPropertyDescriptors() {
+ Collection descriptors = new Vector();
+
+ /* TODO: GPB:
+ java.util.List list=ItemProviderSupport.getChoiceOfValues(
+ m_element.getScenario(),
+ ScenarioPackage.eINSTANCE.getParticipant_Type());
+
+ String[] values=new String[0];
+
+ if (list != null && list.size() > 0) {
+ values = new String[list.size()];
+ list.toArray(values);
+ }
+
+ descriptors.add(new ComboBoxPropertyDescriptor(
+ TYPE_ID, "Type",
+ values));
+
+ descriptors.add(new TextPropertyDescriptor(
+ INSTANCE_ID,"Instance"));
+ */
+
+ return (IPropertyDescriptor[])descriptors.toArray( new IPropertyDescriptor[] {} );
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object)
+ */
+ public Object getPropertyValue(Object id) {
+ Object ret=null;
+
+ /* TODO: GPB:
+ if (id == TYPE_ID) {
+ ret = getElement().getType();
+
+ java.util.List list=ItemProviderSupport.getChoiceOfValues(
+ m_element.getScenario(),
+ ScenarioPackage.eINSTANCE.getParticipant_Type());
+
+ if (list != null) {
+ int index=list.indexOf(ret);
+
+ if (index != -1) {
+ ret = new Integer(index);
+ } else {
+ ret = new Integer(0);
+ }
+ } else {
+ ret = new Integer(0);
+ }
+ } else if (id == INSTANCE_ID) {
+ ret = getElement().getInstance();
+ }
+ */
+ if (ret == null) {
+ ret = "";
+ }
+
+ return(ret);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.views.properties.IPropertySource#isPropertySet(java.lang.Object)
+ */
+ public boolean isPropertySet(Object id) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.views.properties.IPropertySouce#resetPropertyValue(java.lang.Object)
+ */
+ public void resetPropertyValue(Object id) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object)
+ */
+ public void setPropertyValue(Object id, Object value) {
+
+ /* TODO: GPB:
+ if (id == TYPE_ID) {
+
+ if (value instanceof Integer) {
+ java.util.List list=ItemProviderSupport.getChoiceOfValues(
+ m_element.getScenario(),
+ ScenarioPackage.eINSTANCE.getParticipant_Type());
+
+ if (((Integer)value).intValue() != -1) {
+ getElement().setType((String)
+ list.get(((Integer)value).intValue()));
+ }
+ }
+ } else if (id == INSTANCE_ID) {
+ if (value instanceof String) {
+ getElement().setInstance((String)value);
+ }
+ }
+ */
+ }
+
+ /**
+ * This method determines if the supplied attribute can be
+ * provided as a text region.
+ *
+ * @param attr The attribute
+ * @return Whether it can be provided as a text region
+ */
+ /* TODO: GPB:
+ public boolean isTextRegion(EAttribute attr) {
+ boolean ret=false;
+
+ return(ret);
+ }
+ */
+
+ /**
+ * This method determines if the supplied attribute can be
+ * provided as an editable list.
+ *
+ * @param attr The attribute
+ * @return Whether it can be provided as an editable list
+ */
+ /* TODO: GPB:
+ public boolean isEditableList(EAttribute attr) {
+ boolean ret=false;
+
+ return(ret);
+ }
+ */
+
+ /**
+ * This method provides the list of values that can be
+ * provided in an editable property field with associated
+ * list.
+ *
+ * @param attr The attribute
+ * @return The list of values
+ */
+ /* TODO: GPB:
+ public java.util.List getStringValues(EAttribute attr) {
+ java.util.List ret=new java.util.Vector();
+ return(ret);
+ }
+ */
+
+ /**
+ * This method returns the list of values appropriate for
+ * the reference.
+ *
+ * @param ref The reference
+ * @return The list of values
+ */
+ /* TODO: GPB:
+ public String[] getStringValues(EReference ref) {
+ String[] ret=new String[0];
+
+ java.util.List list=getValues(m_element, ref);
+ if (list != null) {
+ ret = new String[list.size()+1];
+ ret[0] = "";
+
+ for (int i=0; i < list.size(); i++) {
+ ret[i+1] = ViewSupport.getName(list.get(i),
+ null);
+ }
+ }
+
+ return(ret);
+ }
+ */
+
+ /**
+ * This method returns the selected value associated with
+ * the reference and the index.
+ *
+ * @param ref The reference
+ * @param index The index
+ * @return The selected value
+ */
+ /* TODO: GPB:
+ public Object getSelectedValue(EReference ref, int index) {
+ Object ret=null;
+
+ // Subtract 1 from the index to account for the initial
+ // empty slot
+ index--;
+
+ // Check for known referenced class types
+ java.util.List list=getValues(m_element, ref);
+
+ if (list != null && index >= 0 &&
+ index < list.size()) {
+ ret = list.get(index);
+ }
+
+ return(ret);
+ }
+ */
+
+ /**
+ * This method returns the list of values relevant for the
+ * supplied reference.
+ *
+ * @param src The source object
+ * @param ref The reference
+ * @return The list of values
+ */
+ /* TODO: GPB:
+ public java.util.List getValues(Object src, EReference ref) {
+ return(null);
+ }
+ */
+
+ /**
+ * This method returns a displayable version of the supplied
+ * property name.
+ *
+ * @param propName The property name
+ * @return A displayable version
+ */
+ public String getPropertyName(String propName) {
+ StringBuffer ret=new StringBuffer();
+
+ for (int i=0; i < propName.length(); i++) {
+ char ch=propName.charAt(i);
+
+ if (i == 0) {
+ ret.append(Character.toUpperCase(ch));
+ } else {
+ if (Character.isUpperCase(ch)) {
+ ret.append(' ');
+ }
+ ret.append(ch);
+ }
+ }
+
+ return(ret.toString());
+ }
+
+ /**
+ * This method returns the element.
+ *
+ * @return The element
+ */
+ protected Role getElement() {
+ return(m_element);
+ }
+
+ private static Logger logger = Logger.getLogger("org.pi4soa.scenario.designer.view");
+
+ private static final String INSTANCE_ID = "instance";
+ private static final String TYPE_ID = "type";
+
+ private static final int COMBO_SIZE_LIMIT = 15;
+
+ private Role m_element=null;
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/view/ScenarioPropertySource.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/view/ScenarioPropertySource.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/view/ScenarioPropertySource.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,248 @@
+/*
+ * Copyright 2005 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Jan 10, 2006 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.view;
+
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+import org.savara.scenario.model.*;
+import org.savara.tools.scenario.designer.DesignerDefinitions;
+
+public class ScenarioPropertySource extends org.savara.tools.scenario.designer.util.PropertySource {
+
+ /**
+ * This is the constructor for the property source.
+ *
+ * @param elem The source
+ */
+ public ScenarioPropertySource(Object elem) {
+ super(elem);
+ }
+
+ /* TODO: GPB:
+ public IPropertyDescriptor createAttributePropertyDescriptor(EAttribute attr) {
+ IPropertyDescriptor ret=null;
+ String label=getLabel(attr);
+
+ if (label.indexOf("URL") != -1) {
+ ret = new URLPropertyDescriptor(Integer.toString(attr.getFeatureID()),
+ label, getElement());
+ } else {
+ ret = super.createAttributePropertyDescriptor(attr);
+ }
+
+ return(ret);
+ }
+ */
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors()
+ */
+ public IPropertyDescriptor[] getPropertyDescriptors() {
+ IPropertyDescriptor[] ret=super.getPropertyDescriptors();
+
+ /* TODO: GPB:
+ java.util.Vector list=new java.util.Vector();
+ boolean f_changed=false;
+ boolean f_businessView=DesignerDefinitions.isPreference(DesignerDefinitions.BUSINESS_VIEW);
+
+ for (int i=0; i < ret.length; i++) {
+
+ if (ret[i].getDisplayName().endsWith("Id") &&
+ (ItemProviderSupport.isShowIds((ScenarioObject)getElement()) == false ||
+ f_businessView)) {
+ f_changed = true;
+ } else if (ret[i].getDisplayName().startsWith("Participant") ||
+ ret[i].getDisplayName().startsWith("Direction")) {
+ f_changed = true;
+ } else if (ret[i].getDisplayName().equals("Service Type")) {
+ f_changed = true;
+ } else if (ret[i].getDisplayName().equals("Value") && f_businessView) {
+ f_changed = true;
+ //} else if (ret[i].getDisplayName().equals("Causes Exception") && f_businessView) {
+ // f_changed = true;
+ } else {
+ list.add(ret[i]);
+ }
+ }
+
+ if (f_changed) {
+ ret = new IPropertyDescriptor[list.size()];
+ list.toArray(ret);
+ }
+ */
+
+ return(ret);
+ }
+
+ /* TODO: GPB:
+ @Override
+ protected String getLabel(EStructuralFeature feature) {
+ if (feature == ScenarioPackage.eINSTANCE.getLifelineItem_CausesException()) {
+ return("Expected To Fail");
+ } else {
+ return(super.getLabel(feature));
+ }
+ }
+ */
+
+ /**
+ * This method determines whether the supplied property
+ * represents a derived list of values.
+ *
+ * @param feature The feature
+ * @return Whether the feature has a derived list
+ */
+ /* TODO: GPB:
+ public boolean isDerivedList(EStructuralFeature feature) {
+ boolean ret=ItemProviderSupport.isChoice(feature,
+ getElement());
+
+ return(ret);
+ }
+ */
+
+ /**
+ * This method returns the list of values relevant for the
+ * supplied reference.
+ *
+ * @param src The source object
+ * @param ref The reference
+ * @return The list of values
+ */
+ /* TODO: GPB:
+ public java.util.List getValues(EReference ref) {
+ java.util.List ret=null;
+
+ if (getElement() instanceof ScenarioObject) {
+ ret = ItemProviderSupport.getChoiceOfValues((ScenarioObject)getElement(), ref);
+ }
+
+ if (ret == null) {
+ ret = new java.util.Vector();
+ }
+
+ return(ret);
+ }
+ */
+
+ /**
+ * This method returns the class name for the enumeration
+ * value.
+ *
+ * @param enumval The enumeration value
+ * @return The class name
+ */
+ /* TODO: GPB:
+ protected String getEnumClassName(EEnum enumval) {
+ return("org.pi4soa.cdl."+enumval.getName());
+ }
+ */
+
+ /**
+ * This method determines if the supplied attribute can be
+ * provided as a text region.
+ *
+ * @param attr The attribute
+ * @return Whether it can be provided as a text region
+ */
+ /* TODO: GPB:
+ public boolean isTextRegion(EAttribute attr) {
+ boolean ret=false;
+
+ if (attr == ScenarioPackage.eINSTANCE.getScenarioObject_Description() ||
+ attr == ScenarioPackage.eINSTANCE.getMessageEvent_Value() ||
+ attr == ScenarioPackage.eINSTANCE.getScenario_Description()) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+ */
+
+ /**
+ * This method determines if the supplied attribute can be
+ * provided as an editable list.
+ *
+ * @param attr The attribute
+ * @return Whether it can be provided as an editable list
+ */
+ /* TODO: GPB:
+ public boolean isEditableList(EAttribute attr) {
+ boolean ret=false;
+
+ if (getElement() instanceof LifelineItem &&
+ ((LifelineItem)getElement()).getCausesException() != null &&
+ ((LifelineItem)getElement()).getCausesException().booleanValue()) {
+ ret = ItemProviderSupport.isChoice(attr,
+ getElement());
+ }
+
+ return(ret);
+ }
+ */
+
+ /**
+ * This method provides the list of values that can be
+ * provided in an editable property field with associated
+ * list.
+ *
+ * @param attr The attribute
+ * @return The list of values
+ */
+ /* TODO: GPB:
+ public java.util.List getStringValues(EAttribute attr) {
+ java.util.List ret=new java.util.Vector();
+
+ if (getElement() instanceof ScenarioObject) {
+ java.util.List choices=
+ ItemProviderSupport.getChoiceOfValues((ScenarioObject)getElement(),
+ attr);
+
+ if (choices != null) {
+ ret.addAll(choices);
+ }
+
+ if (ret.size() > 0 && ret.get(0).equals("") &&
+ getElement() instanceof LifelineItem &&
+ ((LifelineItem)getElement()).getCausesException() != null &&
+ ((LifelineItem)getElement()).getCausesException().booleanValue()) {
+ ret.remove(0);
+ }
+ }
+
+ return(ret);
+ }
+ */
+
+ /**
+ * This method returns whether the supplied integer
+ * attribute should use a blank string when the
+ * integer value is zero.
+ *
+ * @param attr The atribute
+ * @return Whether a blank string should be used for zero
+ */
+ /* TODO: GPB:
+ protected boolean isZeroBlank(EAttribute attr) {
+ boolean ret=false;
+
+ return(ret);
+ }
+ */
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/view/URLPropertyDescriptor.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/view/URLPropertyDescriptor.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/view/URLPropertyDescriptor.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2005-7 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Feb 22, 2007 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.view;
+
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.views.properties.PropertyDescriptor;
+
+/**
+ * This class provides a URL property descriptor.
+ *
+ */
+public class URLPropertyDescriptor extends PropertyDescriptor {
+
+ /**
+ * The constructor for the text region property descriptor.
+ *
+ * @param id The id
+ * @param displayName The display name
+ */
+ public URLPropertyDescriptor(Object id, String displayName,
+ Object selectedObject) {
+ super(id, displayName);
+
+ m_selectedObject = selectedObject;
+ }
+
+ /**
+ * This method returns the cell editor.
+ *
+ * @param parent The parent
+ * @return The cell editor
+ */
+ public CellEditor createPropertyEditor(Composite parent) {
+ CellEditor ret=new FileURLCellEditor(parent,
+ null, m_selectedObject);
+
+ if (getValidator() != null) {
+ ret.setValidator(getValidator());
+ }
+
+ return(ret);
+ }
+
+ private Object m_selectedObject=null;
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/view/ViewSupport.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/view/ViewSupport.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/designer/view/ViewSupport.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,502 @@
+/*
+ * Copyright 2005-6 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * 14 Feb 2007 : Initial version created by gary
+ */
+package org.savara.tools.scenario.designer.view;
+
+import java.util.logging.Logger;
+
+import org.eclipse.swt.graphics.Image;
+import org.savara.scenario.model.*;
+import org.savara.tools.scenario.designer.DesignerImages;
+import org.savara.tools.scenario.designer.model.*;
+
+public class ViewSupport {
+
+ /**
+ * This method returns the appropriate image for this scenario
+ * component on the main display area.
+ *
+ * @param component The scenario component
+ * @return The image
+ */
+ public static Image getImage(Object component, ScenarioDiagram diagram) {
+ Image ret=null;
+
+ String imageName=component.getClass().getName();
+
+ int index=imageName.lastIndexOf('.');
+ if (index != -1) {
+ imageName = imageName.substring(index+1);
+ }
+
+ if (imageName != null) {
+ try {
+ ret = DesignerImages.getImage(imageName+".gif");
+
+ } catch(Exception e) {
+ logger.severe("Image for '"+imageName+
+ "' could not be found");
+ }
+ }
+
+ return(ret);
+ }
+
+ public static String getName(Object component, ScenarioDiagram diagram) {
+ String ret=null;
+
+ if (component instanceof Group) {
+ ret = ((Group)component).getName();
+
+ } else if (component instanceof Role) {
+ ret = ((Role)component).getName();
+
+ } else if (component instanceof Link) {
+ ret = getLinkText((Link)component);
+ }
+
+ if (ret == null) {
+ ret = "<unknown>";
+ }
+
+ return(ret);
+ }
+
+ protected static String getLinkText(Link link) {
+ String ret=null;
+
+ if (ret == null && link.getSource() != null) {
+ String operation=((MessageEvent)link.getSource()).getOperationName();
+ String messageType=((MessageEvent)link.getSource()).getType();
+ String faultName=((MessageEvent)link.getSource()).getFaultName();
+
+ String label="";
+
+ if (operation != null) {
+ label += operation;
+ }
+
+ if (messageType != null) {
+ label += "("+messageType+")";
+ }
+
+ if (faultName != null) {
+ label += " fault "+faultName;
+ }
+
+ if (label.length() > 0) {
+ ret = label;
+ }
+ }
+
+ return(ret);
+ }
+
+ public static String getFullDescription(Object model) {
+ String ret=null;
+
+ /* TODO: GPB:
+ if (model instanceof ScenarioObject) {
+ ret = ((ScenarioObject)model).getDescription();
+ }
+ */
+
+ return(ret);
+ }
+
+ /**
+ * This method sets the tooltip for the supplied figure,
+ * associated with the supplied model.
+ *
+ * @param figure The figure
+ * @param model The model
+ */
+ public static void setTooltip(org.eclipse.draw2d.IFigure figure,
+ Object model) {
+
+ org.eclipse.draw2d.ScrollPane tooltip=new org.eclipse.draw2d.ScrollPane();
+
+ org.eclipse.draw2d.text.FlowPage page=new org.eclipse.draw2d.text.FlowPage();
+ tooltip.setContents(page);
+
+ String description=getFullDescription(model);
+
+ if (description != null) {
+ org.eclipse.draw2d.text.BlockFlow block1=new org.eclipse.draw2d.text.BlockFlow();
+ page.add(block1);
+
+ org.eclipse.draw2d.text.TextFlow text1=new org.eclipse.draw2d.text.TextFlow();
+ block1.add(text1);
+ text1.setText(description);
+
+ figure.setToolTip(tooltip);
+ }
+ }
+
+ public static int getHeight(Object component, ScenarioDiagram diagram) {
+ int ret=0;
+ java.util.List children=ModelSupport.getChildren(component);
+
+ if (children != null && children.size() > 0) {
+ ret += 40;
+
+ for (int i=0; i < children.size(); i++) {
+ ret += getHeight(children.get(i), diagram);
+
+ ret += getPadding(children, i); // padding
+ }
+ }
+
+ if (ret == 0) {
+
+ if (component instanceof org.savara.scenario.model.Group) {
+ ret = 70;
+ } else {
+ ret = 30;
+ }
+ }
+
+ if (component instanceof Scenario) {
+ ret += getHeaderPadding(component);
+
+ ret += 40; // Additional padding
+
+ // If test scenario is less than 300 high, make
+ // it 300
+ if (ret < 300) {
+ ret = 300;
+ }
+ }
+
+ return(ret);
+ }
+
+ public static int getWidth(Object component, ScenarioDiagram diagram) {
+ int ret=0;
+
+ if (component instanceof Role) {
+ String name=((Role)component).getName();
+
+ if (name != null) {
+ ret = (int)(name.length()*6.5);
+ }
+
+ if (ret < 100) {
+ ret = 100;
+ } else if (ret > 180) {
+ ret = 180;
+ }
+
+ } else if (component instanceof TimeElapsedEvent) {
+ /* TODO: GPB: Need to get parent of the event
+
+ ret = getWidth(((TimeElapsedEvent)component).eContainer(),
+ diagram);
+
+ ret -= 10;
+ */
+ } else {
+ java.util.List children=ModelSupport.getChildren(component);
+ boolean f_foundSubGroup = false;
+
+ if (children != null) {
+ for (int i=0; i < children.size(); i++) {
+ if (children.get(i) instanceof
+ org.savara.scenario.model.Group) {
+ int wid=getWidth(children.get(i), diagram);
+
+ if (ret < (wid+15)) {
+ ret = wid + 15; // added padding
+ }
+
+ f_foundSubGroup = true;
+ }
+ }
+ }
+
+ if (f_foundSubGroup == false) {
+ // Need to add width for participants
+ ret = getSidebarWidth(diagram)+
+ (diagram.getScenario().getRoles().size()*
+ ROLE_PADDING_X-
+ (int)(ROLE_PADDING_X*0.6));
+ }
+ }
+
+ return(ret);
+ }
+
+ public static int getChildYPosition(Object parent, Object child,
+ ScenarioDiagram diagram) {
+ int ret=0;
+
+ if (child instanceof Role) {
+ ret = getHeaderPadding(child);
+
+ } else {
+ java.util.List children=ModelSupport.getChildren(parent);
+
+ if (children != null) {
+ int pos=children.indexOf(child);
+
+ ret = getHeaderPadding(parent);
+
+ if (pos > 0) {
+
+ for (int i=0; i < pos; i++) {
+ ret += getHeight(children.get(i), diagram);
+
+ ret += getPadding(children, i);
+ }
+ }
+ }
+ }
+
+ /*
+ if (parent instanceof Scenario) {
+ ret += getTopBorderHeight(diagram);
+ }
+ */
+
+ return(ret);
+ }
+
+ /**
+ * This method determines how much padding should be included
+ * after the specified child index in the list of children.
+ *
+ * @param children The list of children
+ * @param index The index of the child prior to the padding
+ * @return The amount of padding
+ */
+ public static int getPadding(java.util.List children,
+ int index) {
+ int ret=PADDING_Y;
+
+ if (index < children.size()-1) {
+ Object child1=children.get(index);
+ Object child2=children.get(index+1);
+
+ if (child1 instanceof org.savara.scenario.model.MessageEvent &&
+ child2 instanceof org.savara.scenario.model.MessageEvent) {
+
+ // Is there a message link between these children
+
+ /* TODO: GPB: need to get scenario
+ java.util.List links=
+ ((org.savara.scenario.model.MessageEvent)child1).getScenario().getMessageLinks();
+ boolean f_found=false;
+
+ for (int i=0; f_found == false &&
+ i < links.size(); i++) {
+ org.savara.scenario.Link link=
+ (org.savara.scenario.Link)
+ links.get(i);
+
+ if ((link.getSource() == child1 &&
+ link.getTarget() == child2) ||
+ (link.getSource() == child2 &&
+ link.getTarget() == child1)) {
+ f_found = true;
+ }
+ }
+
+ if (f_found == false) {
+ ret = 0;
+ }
+ */
+
+ } else {
+ ret = 10;
+ }
+ }
+
+ return(ret);
+ }
+
+ public static int getChildXPosition(Object parent, Object child,
+ ScenarioDiagram diagram) {
+ int ret=0;
+
+ if (child instanceof Role) {
+ int pos=diagram.getScenario().getRoles().indexOf(child);
+ //int pos=diagram.getParticipantIndex((Participant)child);
+
+ if (pos != -1) {
+ ret = getSidebarWidth(diagram) + (pos * ROLE_PADDING_X);
+ } else {
+ ret = ROLE_PADDING_X;
+ }
+
+ } else if (child instanceof Event) {
+ Event me=(Event)child;
+
+ Role participant=getRoleForEvent(
+ diagram.getScenario().getRoles(), me);
+
+ if (participant != null) {
+ ret = getChildXPosition(null, participant, diagram);
+
+ // For each contained event group, we need to adjust
+ // the X position
+ Object cur=ModelSupport.getParent(me);
+ while (cur != null && (cur instanceof Scenario) == false) {
+ ret -= EVENT_GROUP_PADDING_X;
+ cur=ModelSupport.getParent(cur);
+ }
+ } else {
+ ret = 50;
+ }
+ } else if (child instanceof TimeElapsedEvent) {
+ ret = 5;
+ } else if (child instanceof Import) {
+ ret = 5;
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the participant associated with the
+ * supplied scenario event. If a participant type is not
+ * defined, then a participant will not be returned.
+ *
+ * @param list The list of participants
+ * @param evt The scenario event
+ * @return The participant, or null if not found
+ */
+ public static Role getRoleForEvent(java.util.List list,
+ Event evt) {
+ Role ret=(Role)evt.getRole();
+
+ /* 9/6/08 - phased out participant type name/instance
+ if (evt.getParticipant() == null &&
+ org.pi4soa.common.util.NamesUtil.isSet(evt.getParticipantTypeName())) {
+
+ for (int i=0; ret == null && i < list.size(); i++) {
+ ret = (Participant)list.get(i);
+
+ if ((evt.getParticipantTypeName() == null &&
+ ret.getType() != null) ||
+ (evt.getParticipantTypeName() != null &&
+ evt.getParticipantTypeName().equals(ret.getType()) == false)) {
+ ret = null;
+ } else if ((evt.getParticipantInstance() == null &&
+ ret.getInstance() != null) ||
+ (evt.getParticipantInstance() != null &&
+ evt.getParticipantInstance().equals(ret.getInstance()) == false)) {
+ ret = null;
+ }
+ }
+
+ if (ret != null) {
+ evt.setParticipant(ret);
+ }
+ }
+ */
+
+ return(ret);
+ }
+
+ public static int getNewParticipantIndex(int x,
+ ScenarioDiagram diagram) {
+ int start=getSidebarWidth(diagram) - ROLE_PADDING_X;
+ int pos=(x - start) / ROLE_PADDING_X;
+
+ return(pos);
+ }
+
+ public static int getNearestParticipantIndex(int x,
+ ScenarioDiagram diagram) {
+ int pos=(x - getSidebarWidth(diagram) + (ROLE_PADDING_X/2)) /
+ ROLE_PADDING_X;
+
+ return(pos);
+ }
+
+ public static Role getNearestRole(int x, ScenarioDiagram diagram) {
+ int pos=getNearestParticipantIndex(x, diagram);
+ Role ret=null;
+
+ java.util.List roles=diagram.getScenario().getRoles();
+
+ if (roles.size() > 0) {
+ if (pos < 0) {
+ ret = (Role)roles.get(0);
+ } else if (pos >= roles.size()) {
+ ret = (Role)roles.get(roles.size()-1);
+ } else {
+ ret = (Role)roles.get(pos);
+ }
+ }
+
+ return(ret);
+ }
+
+ public static int getHeaderPadding(Object parent) {
+ int ret=EVENT_GROUP_PADDING_Y;
+
+ if (parent instanceof Scenario) {
+ ret = HEADER_HEIGHT;
+
+ ret += 30; // For the name in the header
+
+ if (((Scenario)parent).getAuthor() != null) {
+ ret += 30;
+ }
+ } else if (parent instanceof Role) {
+ ret = PARTICIPANT_PADDING_Y;
+
+ ret += 30; // For the name in the header
+
+ /* TODO: GPB: Need to find scenario
+ if (((Role)parent).getScenario().getAuthor() != null) {
+ ret += 30;
+ }
+ */
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method calculates an appropriate width for the
+ * left hand side bar.
+ *
+ * @param diagram The diagram
+ * @return The width
+ */
+ public static int getSidebarWidth(ScenarioDiagram diagram) {
+ // This can become dynamic, if necessary, based on the
+ // depth of the event groups
+ return(100);
+ }
+
+ private static Logger logger = Logger.getLogger("org.pi4soa.service.test.designer.view");
+
+ public static int TYPES_INITIAL_YPADDING=26;
+
+ public static final int EVENT_GROUP_PADDING_X=8;
+ public static final int EVENT_GROUP_PADDING_Y=35;
+ public static final int PARTICIPANT_PADDING_Y=10;
+ public static final int HEADER_HEIGHT=60;
+ public static final int PADDING_Y=10;
+ //public static final int SIDEBAR_WIDTH=300;
+ public static final int ROLE_PADDING_X=200;
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/osgi/Activator.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/osgi/Activator.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/osgi/Activator.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,74 @@
+package org.savara.tools.scenario.osgi;
+
+import java.util.logging.Logger;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.savara.tools.scenario"; //$NON-NLS-1$
+
+ // The shared instance
+ private static Activator plugin;
+
+ private static Logger logger = Logger.getLogger(Activator.class.getName());
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @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 Activator getDefault() {
+ return plugin;
+ }
+
+ /**
+ * This method logs an error against the plugin.
+ *
+ * @param mesg The error message
+ * @param t The optional exception
+ */
+ public static void logError(String mesg, Throwable t) {
+
+ if (getDefault() != null) {
+ Status status=new Status(IStatus.ERROR,
+ PLUGIN_ID, 0, mesg, t);
+
+ getDefault().getLog().log(status);
+ }
+
+ logger.severe("LOG ERROR: "+mesg+
+ (t == null ? "" : ": "+t));
+ }
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/simulation/ScenarioDetails.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/simulation/ScenarioDetails.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/simulation/ScenarioDetails.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2005 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Jan 5, 2006 : Initial version created by gary
+ */
+package org.savara.tools.scenario.simulation;
+
+/**
+ * This class represents details obtained from analysing the
+ * scenario execution results.
+ *
+ */
+public class ScenarioDetails {
+
+ /**
+ * This is the default constructor.
+ *
+ */
+ public ScenarioDetails() {
+ }
+
+ /**
+ * This method sets the start position for the scenario
+ * details.
+ *
+ * @param startPos The start position
+ */
+ public void setStartPosition(int startPos) {
+ m_startPosition = startPos;
+ }
+
+ /**
+ * This method returns the start position for the scenario
+ * details.
+ *
+ * @return The start position
+ */
+ public int getStartPosition() {
+ return(m_startPosition);
+ }
+
+ /**
+ * This method sets the end position for the scenario
+ * details.
+ *
+ * @param endPos The end position
+ */
+ public void setEndPosition(int endPos) {
+ m_endPosition = endPos;
+ }
+
+ /**
+ * This method returns the end position for the scenario
+ * details.
+ *
+ * @return The end position
+ */
+ public int getEndPosition() {
+ return(m_endPosition);
+ }
+
+ private int m_startPosition=0;
+ private int m_endPosition=0;
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/simulation/ScenarioSimulationAction.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/simulation/ScenarioSimulationAction.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/simulation/ScenarioSimulationAction.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,199 @@
+/*
+ * Copyright 2004-5 Enigmatec Corporation Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Feb 22, 2005 : Initial version created by gary
+ */
+package org.savara.tools.scenario.simulation;
+
+import java.io.IOException;
+import java.util.logging.Logger;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+
+/**
+ * This class invokes the scenario test action on the selected
+ * folder or scenario file.
+ *
+ */
+public class ScenarioSimulationAction implements IObjectActionDelegate {
+
+ /**
+ * This method implements the action's run method.
+ *
+ * @param action The action
+ */
+ public void run(IAction action) {
+
+ if (m_selection instanceof StructuredSelection) {
+ StructuredSelection sel=(StructuredSelection)m_selection;
+
+ IResource res=(IResource)sel.getFirstElement();
+
+ // Make sure there are no markers associated
+ // with the resource
+ /* TODO: GPB: How to manage errors?
+ //if (ResourceUtil.hasErrors(res) == false) {
+
+ // Load the test scenario and return the CDL resource
+ IResource cdlResource=getCDLResource(res);
+
+ if (cdlResource != null) {
+
+ // Make sure there are no markers associated
+ // with the resource
+
+ if (ResourceUtil.hasErrors(cdlResource) == false) {
+
+ // Load the CDL model
+ org.pi4soa.cdl.Package cdlpack=null;
+ String path=cdlResource.getLocation().toOSString();
+
+ try {
+ cdlpack = CDLManager.load(path);
+
+ } catch(IOException ioe) {
+ logger.severe("Failed to load CDL '"+path+"': "+ioe);
+
+ error(ERROR_LOADING_CDL);
+ }
+
+ if (cdlpack != null) {
+ ScenarioSimulationWindow dialog=
+ new ScenarioSimulationWindow(m_targetPart.getSite().getShell(),
+ res.getProject().getName(),
+ res.getProjectRelativePath().toString(),
+ cdlpack, res);
+
+ dialog.open();
+ }
+
+ //launch(res.getLocation().toString(),
+ // res.getProject().getName(),
+ // res.getProjectRelativePath().toString());
+ } else {
+ error(ERRORS_NO_TEST);
+ }
+ }
+ } else {
+ error(SCENARIO_ERRORS_NO_TEST);
+ }
+ */
+ }
+ }
+
+ /**
+ * This method returns the CDL resource associated with
+ * the supplied test scenario resource.
+ *
+ * @param res The test scenario resource
+ * @return The CDL resource, or null if not found
+ */
+ /* TODO: GPB: CDL specific
+
+ protected IResource getCDLResource(IResource res) {
+ IResource ret=null;
+
+ try {
+ Scenario scenario=
+ ScenarioManager.load(res.getLocation().toString());
+
+ java.io.File f=new java.io.File(scenario.getChoreographyDescriptionURL());
+
+ if (f.isAbsolute()) {
+ org.eclipse.core.runtime.Path urlpath=
+ new org.eclipse.core.runtime.Path(scenario.getChoreographyDescriptionURL());
+
+ ret = res.getWorkspace().getRoot().getFileForLocation(urlpath);
+ } else {
+ ret = res.getParent().findMember(
+ scenario.getChoreographyDescriptionURL());
+ }
+
+ if (ret == null) {
+ error(ERROR_LOCATING_CDL);
+ }
+ } catch(Exception e) {
+ logger.info("Failed to load scenario '"+
+ res.getLocation().toOSString()+"': "+e);
+
+ error(ERROR_LOADING_SCENARIO);
+ }
+
+ return(ret);
+ }
+ */
+
+ /**
+ * This method is used to report an error.
+ *
+ * @param mesg The error message
+ */
+ public void error(String mesg) {
+
+ logger.severe("Error occurred: "+mesg);
+
+ MessageBox mbox=new MessageBox(m_targetPart.getSite().getShell(),
+ SWT.ICON_ERROR|SWT.OK);
+
+ if (mesg == null) {
+ mesg = "Null pointer exception has occurred";
+ }
+
+ mbox.setMessage(mesg);
+ mbox.open();
+ }
+
+ /**
+ * This method indicates that the selection has changed.
+ *
+ * @param action The action
+ * @param selection The selection
+ */
+ public void selectionChanged(IAction action,
+ ISelection selection) {
+ m_selection = selection;
+ }
+
+ /**
+ * This method sets the currently active workbench part.
+ *
+ * @param action The action
+ * @param targetPart The active workbench part
+ */
+ public void setActivePart(IAction action,
+ IWorkbenchPart targetPart) {
+ m_targetPart = targetPart;
+ }
+
+ private static Logger logger = Logger.getLogger("org.pi4soa.service.test.eclipse");
+
+ private ISelection m_selection=null;
+ private IWorkbenchPart m_targetPart=null;
+
+ private static final String SCENARIO_ERRORS_NO_TEST = "Scenario has errors, so cannot run test scenario";
+ private static final String ERRORS_NO_TEST = "Choreography Description has errors, so cannot run test scenario";
+ private static final String ERROR_LOCATING_CDL = "Choreography Description could not be located";
+ private static final String ERROR_LOADING_CDL = "Choreography Description could not be loaded";
+ private static final String ERROR_LOADING_SCENARIO = "Test Scenario could not be loaded";
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/simulation/ScenarioSimulationImages.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/simulation/ScenarioSimulationImages.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/simulation/ScenarioSimulationImages.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2005 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Jan 5, 2006 : Initial version created by gary
+ */
+package org.savara.tools.scenario.simulation;
+
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.jface.resource.ImageDescriptor;
+
+/**
+ * This class provides access to images configured within the
+ * environment.
+ */
+public class ScenarioSimulationImages {
+
+ /**
+ * This method returns the image associated with the
+ * supplied name.
+ *
+ * @param name The name
+ * @return The image
+ */
+ public static Image getImage(String name) {
+ Image ret = new Image(null,
+ ScenarioSimulationImages.class.
+ getResourceAsStream(IMAGES_LOCATION+name));
+ return(ret);
+ }
+
+ /**
+ * This method returns the image descriptor associated with the
+ * supplied name.
+ *
+ * @param name The name
+ * @return The descriptor
+ */
+ public static ImageDescriptor getImageDescriptor(String name) {
+ ImageDescriptor ret=
+ ImageDescriptor.createFromFile(ScenarioSimulationImages.class,
+ IMAGES_LOCATION+name);
+
+ return(ret);
+ }
+
+ private static final String IMAGES_LOCATION = "images/";
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/simulation/ScenarioSimulationLaunchConfigurationConstants.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/simulation/ScenarioSimulationLaunchConfigurationConstants.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/simulation/ScenarioSimulationLaunchConfigurationConstants.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2004-5 Enigmatec Corporation Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Feb 17, 2005 : Initial version created by gary
+ */
+package org.savara.tools.scenario.simulation;
+
+/**
+ * This interface defines the constants for the scenario test
+ * launch configuration.
+ */
+public interface ScenarioSimulationLaunchConfigurationConstants {
+
+ public static final String ATTR_PROJECT_NAME="project";
+
+ public static final String ATTR_SCENARIO="scenario";
+
+ public static final String ATTR_EXECUTE_SERVICES="execute_services";
+
+ public static final String LAUNCH_CONFIG_TYPE=
+ "org.pi4soa.scenario.eclipse.ScenarioTestLauncher";
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/simulation/ScenarioSimulationLauncher.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/simulation/ScenarioSimulationLauncher.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/simulation/ScenarioSimulationLauncher.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,383 @@
+/*
+ * Copyright 2004-5 Enigmatec Corporation Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Feb 17, 2005 : Initial version created by gary
+ */
+package org.savara.tools.scenario.simulation;
+
+import java.io.File;
+import java.text.MessageFormat;
+import java.util.Map;
+import java.util.Vector;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.IStreamListener;
+import org.eclipse.debug.core.model.IStreamMonitor;
+import org.eclipse.debug.core.model.IProcess;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.launching.AbstractJavaLaunchConfigurationDelegate;
+import org.eclipse.jdt.launching.ExecutionArguments;
+import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
+import org.eclipse.jdt.launching.IVMInstall;
+import org.eclipse.jdt.launching.IVMRunner;
+import org.eclipse.jdt.launching.VMRunnerConfiguration;
+import org.eclipse.osgi.util.ManifestElement;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.Constants;
+import org.savara.scenario.simulation.ScenarioSimulator;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.Path;
+
+/**
+ * This class is responsible for launching a scenario test against
+ * a test scenario.
+ */
+public class ScenarioSimulationLauncher
+ extends AbstractJavaLaunchConfigurationDelegate {
+
+ /**
+ * This is the default constructor.
+ *
+ */
+ public ScenarioSimulationLauncher() {
+ }
+
+ /**
+ * This method launches the scenario test.
+ *
+ * @param configuration The launch configuration
+ * @param mode The mode (run or debug)
+ * @param launch The launch object
+ * @param monitor The optional progress monitor
+ */
+ public void launch(ILaunchConfiguration configuration,
+ String mode, ILaunch launch, IProgressMonitor monitor)
+ throws CoreException {
+ if (monitor == null) {
+ monitor = new NullProgressMonitor();
+ }
+
+ monitor.beginTask(MessageFormat.format("{0}...", new String[]{configuration.getName()}), 3); //$NON-NLS-1$
+ // check for cancellation
+ if (monitor.isCanceled()) {
+ return;
+ }
+
+ monitor.subTask("Verifying launch configuration....");
+
+ String mainTypeName = ScenarioSimulator.class.getName();
+
+ IVMInstall vm = verifyVMInstall(configuration);
+
+ IVMRunner runner = vm.getVMRunner(mode);
+ if (runner == null) {
+ abort("VM runner does not exist",
+ null, IJavaLaunchConfigurationConstants.ERR_VM_RUNNER_DOES_NOT_EXIST); //$NON-NLS-1$
+ }
+
+ File workingDir = verifyWorkingDirectory(configuration);
+ String workingDirName = null;
+ if (workingDir != null) {
+ workingDirName = workingDir.getAbsolutePath();
+ }
+
+ // Environment variables
+ String[] envp= DebugPlugin.getDefault().getLaunchManager().getEnvironment(configuration);
+
+ // Program & VM args
+ String filename=configuration.getAttribute(
+ ScenarioSimulationLaunchConfigurationConstants.ATTR_PROJECT_NAME, "")+
+ "/"+configuration.getAttribute(
+ ScenarioSimulationLaunchConfigurationConstants.ATTR_SCENARIO, "");
+
+ String execServices=configuration.getAttribute(
+ ScenarioSimulationLaunchConfigurationConstants.ATTR_EXECUTE_SERVICES,
+ "");
+
+ if (execServices.length() != 0) {
+ execServices = " \""+execServices+"\"";
+ }
+
+ String pgmArgs="\""+getPathForScenario(filename)+
+ "\""+execServices;
+
+ logger.fine("Launching scenario test with args: "+pgmArgs);
+
+ String vmArgs = getVMArguments(configuration);
+ ExecutionArguments execArgs = new ExecutionArguments(vmArgs, pgmArgs);
+
+ // VM-specific attributes
+ Map vmAttributesMap = getVMSpecificAttributesMap(configuration);
+
+ // Classpath
+ String[] classpath = getClasspath(configuration);
+
+ // Create VM config
+ VMRunnerConfiguration runConfig = new VMRunnerConfiguration(mainTypeName, classpath);
+ runConfig.setProgramArguments(execArgs.getProgramArgumentsArray());
+ runConfig.setEnvironment(envp);
+ runConfig.setVMArguments(execArgs.getVMArgumentsArray());
+ runConfig.setWorkingDirectory(workingDirName);
+ runConfig.setVMSpecificAttributesMap(vmAttributesMap);
+
+ // Bootpath
+ runConfig.setBootClassPath(getBootpath(configuration));
+
+ // check for cancellation
+ if (monitor.isCanceled()) {
+ return;
+ }
+
+ // stop in main
+ prepareStopInMain(configuration);
+
+ // done the verification phase
+ monitor.worked(1);
+
+ // Launch the configuration - 1 unit of work
+ runner.run(runConfig, launch, monitor);
+
+ IProcess[] processes=launch.getProcesses();
+ if (processes.length > 0) {
+ processes[0].getStreamsProxy().getOutputStreamMonitor().
+ addListener(new IStreamListener() {
+ public void streamAppended(String str, IStreamMonitor mon) {
+ handleResults(str, false);
+ }
+ });
+ processes[0].getStreamsProxy().getErrorStreamMonitor().
+ addListener(new IStreamListener() {
+ public void streamAppended(String str, IStreamMonitor mon) {
+ handleResults(str, true);
+ }
+ });
+ }
+
+ // check for cancellation
+ if (monitor.isCanceled()) {
+ return;
+ }
+
+ monitor.done();
+ }
+
+ /**
+ * This method handles the results produced by the launched
+ * test.
+ *
+ * @param results The results
+ * @param errorStream Whether the results are from the error
+ * stream
+ */
+ protected void handleResults(String results, boolean errorStream) {
+ System.out.println(results);
+ }
+
+ /**
+ * This method returns the full path to the scenario.
+ *
+ * @param relativePath The is the scenario path begining at
+ * the project
+ * @return The full path
+ */
+ protected String getPathForScenario(String relativePath) {
+ String ret=null;
+
+ IFile file=ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(relativePath));
+ if (file != null && file.exists()) {
+ ret = file.getLocation().toString();
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method derives the classpath required to run the
+ * ScenarioTester utility.
+ *
+ * @param configuration The launch configuation
+ * @return The list of classpath entries
+ */
+ public String[] getClasspath(ILaunchConfiguration configuration) {
+ String[] ret=null;
+ java.util.Vector<String> classpathEntries=new java.util.Vector<String>();
+
+ // Add classpath entry for current Java project
+ try {
+ String projname=configuration.getAttribute(
+ ScenarioSimulationLaunchConfigurationConstants.ATTR_PROJECT_NAME, "");
+
+ IProject project=
+ ResourcesPlugin.getWorkspace().getRoot().getProject(projname);
+
+ IJavaProject jproject=JavaCore.create(project);
+
+ // Add output location
+ IPath outputLocation=jproject.getOutputLocation();
+
+ IFolder folder=
+ ResourcesPlugin.getWorkspace().getRoot().getFolder(outputLocation);
+
+ String path=folder.getLocation().toString();
+
+ classpathEntries.add(path);
+
+ // Add other libraries to the classpath
+ IClasspathEntry[] curclspath=jproject.getRawClasspath();
+ for (int i=0; curclspath != null &&
+ i < curclspath.length; i++) {
+
+ if (curclspath[i].getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
+ IFile file=
+ ResourcesPlugin.getWorkspace().
+ getRoot().getFile(curclspath[i].getPath());
+
+ if (file.exists()) {
+ // Library is within the workspace
+ classpathEntries.add(file.getLocation().toString());
+ } else {
+ // Assume library is external to workspace
+ classpathEntries.add(curclspath[i].getPath().toString());
+ }
+
+ } else if (curclspath[i].getEntryKind() ==
+ IClasspathEntry.CPE_CONTAINER) {
+ // Container's not currently handled - but
+ // problem need to retrieve from project and
+ // iterate over container entries
+ }
+ }
+
+ } catch(Exception e) {
+ // TODO: report error
+ }
+
+ buildClassPath("org.pi4soa.scenario", classpathEntries);
+ buildClassPath("org.pi4soa.service", classpathEntries);
+ buildClassPath("org.pi4soa.common", classpathEntries);
+ buildClassPath("org.pi4soa.cdl", classpathEntries);
+ buildClassPath("org.eclipse.emf.ecore", classpathEntries);
+ buildClassPath("org.eclipse.emf.ecore.xmi", classpathEntries);
+ buildClassPath("org.eclipse.emf.common", classpathEntries);
+ buildClassPath("org.apache.xalan", classpathEntries);
+ buildClassPath("org.apache.xml.serializer", classpathEntries);
+
+ ret = new String[classpathEntries.size()];
+ classpathEntries.copyInto(ret);
+
+ if (logger.isLoggable(Level.FINEST)) {
+ logger.finest("Scenario Simulation Classpath:");
+ for (int i=0; i < ret.length; i++) {
+ logger.finest(" ["+i+"] "+ret[i]);
+ }
+ }
+
+ return(ret);
+ }
+
+ protected void buildClassPath(String bundleId, java.util.List<String> entries) {
+ Bundle bundle= Platform.getBundle(bundleId);
+ if (bundle != null) {
+ java.net.URL installLocation= bundle.getEntry("/");
+ java.net.URL local= null;
+ try {
+ local= Platform.asLocalURL(installLocation);
+ } catch (java.io.IOException e) {
+ e.printStackTrace();
+ }
+
+ String baseLocation = local.getFile();
+
+ try {
+ String requires = (String)bundle.getHeaders().get(Constants.BUNDLE_CLASSPATH);
+ ManifestElement[] elements = ManifestElement.parseHeader(Constants.BUNDLE_CLASSPATH, requires);
+
+ for (int i=0; elements != null && i < elements.length; i++) {
+
+ String path=baseLocation+elements[i].getValue();
+
+ // Check if path is for a Jar and that the
+ // file exists - if not see if a classes
+ // directory exists
+ if (path.endsWith(".jar")) {
+
+ if ((new File(path)).exists() == false) {
+ if ((new File(baseLocation+"classes")).exists()) {
+ path = baseLocation+"classes";
+ }
+ }
+ }
+
+ if (entries.contains(path) == false) {
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine("Adding classpath entry '"+
+ path+"'");
+ }
+ entries.add(path);
+
+ if (elements[i].getValue().equals(".")) {
+ if ((new File(baseLocation+"classes")).exists()) {
+ path = baseLocation+"classes";
+
+ entries.add(path);
+ }
+ }
+ }
+ }
+
+ if (elements == null) {
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine("Adding classpath entry '"+
+ baseLocation+"'");
+ }
+ entries.add(baseLocation);
+ }
+
+ /*
+ requires = (String)bundle.getHeaders().get(Constants.REQUIRE_BUNDLE);
+ elements = ManifestElement.parseHeader(Constants.REQUIRE_BUNDLE, requires);
+
+ for (int i=0; recursive &&
+ elements != null && i < elements.length; i++) {
+ buildClasspathEntries(elements[i].getValue(),
+ entries, false);
+ }
+ */
+
+ } catch(Exception e) {
+ logger.severe("Failed to construct classpath: "+e);
+ e.printStackTrace();
+ }
+ }
+ }
+
+ private static Logger logger = Logger.getLogger("org.pi4soa.service.test.eclipse");
+}
\ No newline at end of file
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/simulation/ScenarioSimulationMainTab.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/simulation/ScenarioSimulationMainTab.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/simulation/ScenarioSimulationMainTab.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,524 @@
+/*
+ * Copyright 2004-5 Enigmatec Corporation Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Feb 17, 2005 : Initial version created by gary
+ */
+package org.savara.tools.scenario.simulation;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
+import org.eclipse.debug.ui.ILaunchConfigurationTab;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.dialogs.ElementListSelectionDialog;
+
+/**
+ * This class represents the first main tab within the tab group
+ * associated with the scenario test launch configuration.
+ */
+public class ScenarioSimulationMainTab extends AbstractLaunchConfigurationTab {
+
+ /**
+ * @see ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createControl(Composite parent) {
+ Composite comp = new Composite(parent, SWT.NONE);
+ setControl(comp);
+
+ GridLayout topLayout = new GridLayout();
+ topLayout.numColumns= 3;
+ comp.setLayout(topLayout);
+
+ Label label = new Label(comp, SWT.NONE);
+ GridData gd = new GridData();
+ gd.horizontalSpan = 3;
+ label.setLayoutData(gd);
+
+ createScenarioSection(comp);
+
+ label = new Label(comp, SWT.NONE);
+ gd = new GridData();
+ gd.horizontalSpan = 3;
+ label.setLayoutData(gd);
+
+ Dialog.applyDialogFont(comp);
+ validatePage();
+ }
+
+ /**
+ * This method creates the GUI components for the
+ * scenario test tab.
+ *
+ * @param comp The composite
+ */
+ protected void createScenarioSection(Composite comp) {
+ GridData gd = new GridData();
+ gd.horizontalSpan = 3;
+
+ m_projectLabel = new Label(comp, SWT.NONE);
+ m_projectLabel.setText("Project");
+ gd= new GridData();
+ gd.horizontalIndent = 25;
+ m_projectLabel.setLayoutData(gd);
+
+ m_project= new Text(comp, SWT.SINGLE | SWT.BORDER);
+ m_project.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ m_project.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent evt) {
+ validatePage();
+ updateLaunchConfigurationDialog();
+ m_scenarioSearch.setEnabled(m_project.getText().length() > 0);
+ }
+ });
+
+ m_projectButton = new Button(comp, SWT.PUSH);
+ m_projectButton.setText("Browse");
+ m_projectButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent evt) {
+ handleProjectButtonSelected();
+ }
+ });
+ setButtonGridData(m_projectButton);
+
+ m_scenarioLabel = new Label(comp, SWT.NONE);
+ gd = new GridData();
+ gd.horizontalIndent = 25;
+ m_scenarioLabel.setLayoutData(gd);
+ m_scenarioLabel.setText("Test Scenario");
+
+ m_scenario = new Text(comp, SWT.SINGLE | SWT.BORDER);
+ m_scenario.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ m_scenario.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent evt) {
+ validatePage();
+ updateLaunchConfigurationDialog();
+ }
+ });
+
+ m_scenarioSearch = new Button(comp, SWT.PUSH);
+ m_scenarioSearch.setEnabled(m_project.getText().length() > 0);
+ m_scenarioSearch.setText("Search");
+ m_scenarioSearch.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent evt) {
+ handleSearchButtonSelected();
+ }
+ });
+ setButtonGridData(m_scenarioSearch);
+ }
+
+ protected static Image createImage(String path) {
+ return null;
+ }
+
+
+ /**
+ * @see ILaunchConfigurationTab#initializeFrom(ILaunchConfiguration)
+ */
+ public void initializeFrom(ILaunchConfiguration config) {
+ String projectName= "";
+ String scenario= "";
+
+ try {
+ projectName = config.getAttribute(ScenarioSimulationLaunchConfigurationConstants.ATTR_PROJECT_NAME, ""); //$NON-NLS-1$
+ } catch (CoreException ce) {
+ }
+ m_project.setText(projectName);
+
+ try {
+ scenario = config.getAttribute(ScenarioSimulationLaunchConfigurationConstants.ATTR_SCENARIO, ""); //$NON-NLS-1$
+ } catch (CoreException ce) {
+ }
+ m_scenario.setText(scenario);
+ }
+
+ /**
+ * @see ILaunchConfigurationTab#performApply(ILaunchConfigurationWorkingCopy)
+ */
+ public void performApply(ILaunchConfigurationWorkingCopy config) {
+ }
+
+ /**
+ * @see ILaunchConfigurationTab#dispose()
+ */
+ public void dispose() {
+ super.dispose();
+ }
+
+ /**
+ * @see AbstractLaunchConfigurationTab#getImage()
+ */
+ public Image getImage() {
+ return(null);
+ }
+
+ /**
+ * This method sets the grid data for the button.
+ *
+ * @param button The button
+ */
+ protected void setButtonGridData(Button button) {
+ GridData gridData= new GridData();
+ button.setLayoutData(gridData);
+ //SWTUtil.setButtonDimensionHint(button);
+ }
+
+ /**
+ * Show a dialog that lists all scenario files within the
+ * selected project
+ */
+ protected void handleSearchButtonSelected() {
+
+ IProject project = getProject();
+
+ ILabelProvider labelProvider=new LabelProvider() {
+ public String getText(Object obj) {
+ String ret="<unknown>";
+ if (obj instanceof IResource) {
+ String filename=((IResource)obj).getName();
+
+ /* TODO: GPB:
+ if (filename.endsWith(ScenarioManager.SCENARIO_FILE_EXTENSION)) {
+ filename = filename.substring(0, filename.length()-
+ ScenarioManager.SCENARIO_FILE_EXTENSION.length()-1);
+ }
+ */
+ ret = filename+" ["+
+ ((IResource)obj).getParent().
+ getProjectRelativePath()+"]";
+ }
+ return(ret);
+ }
+ };
+
+ IResource[] scenarios=null;
+
+ if (project.exists() == false) {
+ scenarios = new IResource[0];
+ } else {
+ scenarios = getScenarios(project);
+ }
+
+ ElementListSelectionDialog dialog= new ElementListSelectionDialog(getShell(), labelProvider);
+ dialog.setTitle("Scenarios");
+ dialog.setMessage("Select the relevant scenario");
+ dialog.setElements(scenarios);
+
+ if (dialog.open() == Window.OK) {
+ IResource file=(IResource)dialog.getFirstResult();
+ m_scenario.setText(file.getProjectRelativePath().toString());
+ }
+ }
+
+ /**
+ * This method returns the list of scenario resource files within
+ * the supplied project.
+ *
+ * @param project The project
+ * @return The list of scenario resource files
+ */
+ protected IResource[] getScenarios(IProject project) {
+ IResource[] ret=null;
+ final java.util.Vector list=new java.util.Vector();
+
+ try {
+ project.accept(new org.eclipse.core.resources.IResourceVisitor() {
+ public boolean visit(IResource res) {
+
+ /* TODO: GPB:
+ if (res.getFileExtension() != null &&
+ res.getFileExtension().equals(
+ ScenarioManager.SCENARIO_FILE_EXTENSION)) {
+ list.add(res);
+ }
+ */
+
+ return(true);
+ }
+ });
+
+ ret = new IResource[list.size()];
+ list.copyInto(ret);
+
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+
+ return(ret);
+ }
+
+ /**
+ * Show a dialog that lets the user select a project. This in turn provides
+ * context for the main type, allowing the user to key a main type name, or
+ * constraining the search for main types to the specified project.
+ */
+ protected void handleProjectButtonSelected() {
+ IProject project = chooseProject();
+ if (project == null) {
+ return;
+ }
+
+ String projectName = project.getName();
+ m_project.setText(projectName);
+ }
+
+ /**
+ * Realize a Java Project selection dialog and return the first selected project,
+ * or null if there was none.
+ */
+ protected IProject chooseProject() {
+ IProject[] projects;
+ try {
+ projects= getWorkspaceRoot().getProjects();
+ } catch (Exception e) {
+ projects= new IProject[0];
+ }
+
+ ILabelProvider labelProvider=new LabelProvider() {
+ public String getText(Object obj) {
+ String ret="<unknown>";
+ if (obj instanceof IResource) {
+ ret = ((IResource)obj).getName();
+ }
+ return(ret);
+ }
+ };
+
+ ElementListSelectionDialog dialog= new ElementListSelectionDialog(getShell(), labelProvider);
+ dialog.setTitle("Projects");
+ dialog.setMessage("Select the relevant project");
+ dialog.setElements(projects);
+
+ IProject project = getProject();
+ if (project != null) {
+ dialog.setInitialSelections(new Object[] { project });
+ }
+ if (dialog.open() == Window.OK) {
+ return (IProject) dialog.getFirstResult();
+ }
+ return null;
+ }
+
+ /**
+ * Return the IProject corresponding to the project name in the project name
+ * text field, or null if the text does not match a project name.
+ */
+ protected IProject getProject() {
+ String projectName = m_project.getText().trim();
+ if (projectName.length() < 1) {
+ return null;
+ }
+ return(getWorkspaceRoot().getProject(projectName));
+ }
+
+ /**
+ * Convenience method to get the workspace root.
+ */
+ private IWorkspaceRoot getWorkspaceRoot() {
+ return ResourcesPlugin.getWorkspace().getRoot();
+ }
+
+ /**
+ * @see ILaunchConfigurationTab#isValid(ILaunchConfiguration)
+ */
+ public boolean isValid(ILaunchConfiguration config) {
+ return getErrorMessage() == null;
+ }
+
+ /**
+ * This method validates the page.
+ *
+ */
+ private void validatePage() {
+ setErrorMessage(null);
+ setMessage(null);
+
+ String projectName = m_project.getText().trim();
+ if (projectName.length() == 0) {
+ setErrorMessage("Project name not specified");
+ return;
+ }
+
+ IProject project = getWorkspaceRoot().getProject(projectName);
+ if (!project.exists()) {
+ setErrorMessage("Project '"+projectName+"' does not exist");
+ return;
+ }
+
+ try {
+ String scenarioName = m_scenario.getText().trim();
+ if (scenarioName.length() == 0) {
+ setErrorMessage("Scenario has not been defined");
+ return;
+ }
+ IResource resource = project.findMember(scenarioName);
+ if (resource == null) {
+ setErrorMessage("Could not find scenario '"+scenarioName+"'");
+ } else {
+
+ // TODO: Check is valid scenario model
+ }
+ } catch (Exception e) {
+ }
+ }
+
+ /**
+ * @see ILaunchConfigurationTab#setDefaults(ILaunchConfigurationWorkingCopy)
+ */
+ public void setDefaults(ILaunchConfigurationWorkingCopy config) {
+
+ IResource resource = getContext();
+ if (resource != null) {
+ initializeProject(resource, config);
+ } else {
+ config.setAttribute(ScenarioSimulationLaunchConfigurationConstants.ATTR_PROJECT_NAME, "");
+ config.setAttribute(ScenarioSimulationLaunchConfigurationConstants.ATTR_SCENARIO, "");
+ }
+ initializeTestAttributes(resource, config);
+ }
+
+ /**
+ * This method identifies the context associated with the
+ * service test.
+ *
+ * @return The context resource
+ */
+ protected IResource getContext() {
+ IResource ret=null;
+ IWorkbenchPage page =
+ org.eclipse.ui.PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+
+ if (page != null) {
+ ISelection selection = page.getSelection();
+ if (selection instanceof IStructuredSelection) {
+ IStructuredSelection ss = (IStructuredSelection)selection;
+ if (!ss.isEmpty()) {
+ Object obj = ss.getFirstElement();
+ if (obj instanceof IResource) {
+ ret = (IResource)obj;
+ }
+ }
+ }
+
+ if (ret == null) {
+ IEditorPart part = page.getActiveEditor();
+ if (part != null) {
+ IEditorInput input = part.getEditorInput();
+ ret =(IResource)input.getAdapter(IResource.class);
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method initializes the project details.
+ *
+ * @param resource The resource
+ * @param config The configuration
+ */
+ protected void initializeProject(IResource resource, ILaunchConfigurationWorkingCopy config) {
+ IProject project = resource.getProject();
+ String name = null;
+ if (project != null && project.exists()) {
+ name = project.getName();
+ }
+ config.setAttribute(ScenarioSimulationLaunchConfigurationConstants.ATTR_PROJECT_NAME, name);
+ }
+
+ /**
+ * This method initializes the scenario details.
+ *
+ * @param resource The selected resource
+ * @param config The configuration
+ */
+ private void initializeTestAttributes(IResource resource, ILaunchConfigurationWorkingCopy config) {
+ /* TODO: GPB:
+
+ if (resource != null && (resource.getType() == IResource.FOLDER ||
+ (resource.getType() == IResource.FILE &&
+ resource.getFileExtension().equals(
+ ScenarioManager.SCENARIO_FILE_EXTENSION)))) {
+
+ config.setAttribute(ScenarioSimulationLaunchConfigurationConstants.ATTR_SCENARIO,
+ resource.getProjectRelativePath().toString());
+
+ initializeName(config, resource.getName());
+ }
+ */
+ }
+
+ /**
+ * This method initializes the launch configuration name.
+ *
+ * @param config The configuration
+ * @param name The name
+ */
+ private void initializeName(ILaunchConfigurationWorkingCopy config, String name) {
+ if (name == null) {
+ name= "";
+ }
+ if (name.length() > 0) {
+
+ int index = name.lastIndexOf('.');
+ if (index > 0) {
+ name = name.substring(0, index);
+ }
+ name= getLaunchConfigurationDialog().generateName(name);
+ config.rename(name);
+ }
+ }
+
+ /**
+ * @see ILaunchConfigurationTab#getName()
+ */
+ public String getName() {
+ return("Scenario Test");
+ }
+
+ private Label m_projectLabel=null;
+ private Text m_project=null;
+ private Button m_projectButton=null;
+ private Label m_scenarioLabel=null;
+ private Text m_scenario=null;
+ private Button m_scenarioSearch=null;
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/simulation/ScenarioSimulationTabGroup.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/simulation/ScenarioSimulationTabGroup.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/simulation/ScenarioSimulationTabGroup.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2004-5 Enigmatec Corporation Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Feb 17, 2005 : Initial version created by gary
+ */
+package org.savara.tools.scenario.simulation;
+
+import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
+import org.eclipse.debug.ui.CommonTab;
+import org.eclipse.debug.ui.ILaunchConfigurationDialog;
+import org.eclipse.debug.ui.ILaunchConfigurationTab;
+import org.eclipse.jdt.debug.ui.launchConfigurations.JavaJRETab;
+
+/**
+ * This class represents the UI tab group for the Scenario Test
+ * launcher.
+ */
+public class ScenarioSimulationTabGroup extends
+ AbstractLaunchConfigurationTabGroup {
+
+ /**
+ * The default constructor for the scenario type tab group.
+ */
+ public ScenarioSimulationTabGroup() {
+ }
+
+ /**
+ * This method creates the tabs for the scenario test launch
+ * configuration.
+ *
+ * @param dialog The launch configuration dialog
+ * @param mode The mode
+ */
+ public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
+ ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] {
+ new ScenarioSimulationMainTab(),
+ new JavaJRETab(),
+ new CommonTab()
+ };
+ setTabs(tabs);
+ }
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/simulation/ScenarioSimulationUILauncher.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/simulation/ScenarioSimulationUILauncher.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/simulation/ScenarioSimulationUILauncher.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,292 @@
+/*
+ * Copyright 2004-5 Enigmatec Corporation Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Feb 23, 2005 : Initial version created by gary
+ */
+package org.savara.tools.scenario.simulation;
+
+import java.util.StringTokenizer;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+import org.savara.scenario.simulation.ScenarioSimulator;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+
+/**
+ * This class is derived from the scenario test launcher with the
+ * ability to present the results in a graphical form.
+ */
+public class ScenarioSimulationUILauncher extends ScenarioSimulationLauncher {
+
+ public ScenarioSimulationUILauncher(Display display,
+ Tree results, Text output) {
+ m_display = display;
+ m_results = results;
+ m_output = output;
+
+ m_results.addSelectionListener(new SelectionListener() {
+
+ public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
+ if (e.item instanceof TreeItem &&
+ e.item.getData() instanceof ScenarioDetails) {
+ ScenarioDetails details=(ScenarioDetails)
+ e.item.getData();
+
+ m_output.clearSelection();
+
+ if (details.getStartPosition() <
+ details.getEndPosition()) {
+ m_output.setSelection(details.getStartPosition(),
+ details.getEndPosition());
+ }
+ }
+ }
+
+ public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
+ widgetSelected(e);
+ }
+ });
+ }
+
+ /**
+ * This method handles the results produced by the launched
+ * test.
+ *
+ * @param results The results
+ * @param errorStream Whether the results are from the error
+ * stream
+ */
+ protected void handleResults(String results, boolean errorStream) {
+ final String text=results;
+
+ if (errorStream) {
+
+ try {
+ m_display.asyncExec(new Runnable() {
+ public void run() {
+ processResults(text);
+
+ m_output.append(text);
+ }
+ });
+ } catch(Throwable e) {
+ org.savara.tools.scenario.osgi.Activator.logError(
+ "Failed to display scenario test results", e);
+ }
+ }
+ }
+
+ protected void processResults(String results) {
+ boolean f_entryFound=false;
+
+ m_buffer.append(results);
+
+ do {
+ int infoPos=0;
+ f_entryFound=false;
+
+ // Check if "INFO: <" is found
+ infoPos=m_buffer.indexOf("INFO: <",
+ m_currentPosition);
+
+ int tmpPos=m_buffer.indexOf("SEVERE: <",
+ m_currentPosition);
+
+ if (tmpPos != -1 && tmpPos < infoPos) {
+ infoPos = tmpPos;
+ }
+
+ if (infoPos != -1) {
+ int newlinePos=0;
+
+ // Check if newline found
+ if ((newlinePos=m_buffer.indexOf("\r\n",
+ infoPos)) != -1) {
+
+ // Complete line found
+ processResultLine(infoPos,
+ newlinePos);
+
+ m_currentPosition = newlinePos;
+
+ f_entryFound = true;
+ }
+ }
+ } while(f_entryFound);
+ }
+
+ protected void processResultLine(int start, int end) {
+ /* TODO: GPB: How is the stdout processed?
+ *
+ *
+ String tag=null;
+ String line=m_buffer.substring(start, end);
+
+ if (line.startsWith("INFO:")) {
+ int tagEndPos=line.indexOf(' ', 7);
+ tag = line.substring(7, tagEndPos);
+ } else if (line.startsWith("SEVERE:")) {
+ int tagEndPos=line.indexOf(' ', 9);
+ tag = line.substring(9, tagEndPos);
+ }
+
+ if (tag.equals(ScenarioSimulator.PROCESSING_TAG) == false &&
+ tag.equals(ScenarioSimulator.COMPLETED_TAG) == false &&
+ tag.equals(ScenarioSimulator.FAILED_TAG) == false) {
+ return;
+ }
+
+ // Get id
+ int idPos=line.indexOf(ScenarioSimulator.ID_ATTR+"=\"");
+ int idEndPos=line.indexOf('"', idPos+2+
+ ScenarioSimulator.ID_ATTR.length());
+ String id=line.substring(idPos+2+
+ ScenarioSimulator.ID_ATTR.length(), idEndPos);
+
+ // Get text
+ int textPos=line.indexOf(ScenarioSimulator.TEXT_ATTR+"=\"");
+ int textEndPos=line.indexOf('"', textPos+2+
+ ScenarioSimulator.TEXT_ATTR.length());
+ String text=line.substring(textPos+2+
+ ScenarioSimulator.TEXT_ATTR.length(), textEndPos);
+
+ boolean create=tag.equals(ScenarioSimulator.PROCESSING_TAG);
+ TreeItem ti=getTreeItem(id, create);
+
+ if (ti != null) {
+ if (create) {
+ ti.setText(text);
+ ti.setForeground(m_results.getShell().getDisplay().
+ getSystemColor(SWT.COLOR_DARK_YELLOW));
+
+ // Add data to tree item to indicate position
+ // information
+ ScenarioDetails details=new ScenarioDetails();
+ details.setStartPosition(start);
+
+ ti.setData(details);
+ } else {
+
+ if (tag.equals(ScenarioSimulator.COMPLETED_TAG)) {
+ ti.setForeground(m_results.getShell().getDisplay().
+ getSystemColor(SWT.COLOR_DARK_GREEN));
+ } else {
+
+ ti.setForeground(m_results.getShell().getDisplay().
+ getSystemColor(SWT.COLOR_RED));
+
+ // Need to propagate error to parent tree items
+ TreeItem parent=ti;
+ Image image=ScenarioSimulationImages.getImage("error_obj.gif");
+
+ while (parent != null) {
+ parent.setImage(image);
+
+ parent = parent.getParentItem();
+ }
+ }
+
+ ScenarioDetails details=(ScenarioDetails)ti.getData();
+ if (details != null) {
+ details.setEndPosition(end);
+
+ // Check for signs of SEVERE messages
+ String substr=null;
+
+ if (ti.getItemCount() == 0) {
+
+ // Only check leaf nodes if they have not completed
+ // successfully - otherwise it means that the
+ // exceptions (errors) are being ignored (i.e. they
+ // are expected)
+ if (tag.equals(ScenarioSimulator.COMPLETED_TAG) == false) {
+ substr = m_buffer.substring(details.getStartPosition(),
+ details.getEndPosition());
+ }
+
+ } else {
+ TreeItem sub1=ti.getItem(0);
+ ScenarioDetails sub1data=(ScenarioDetails)sub1.getData();
+ TreeItem sub2=ti.getItem(ti.getItemCount()-1);
+ ScenarioDetails sub2data=(ScenarioDetails)sub2.getData();
+
+ substr = m_buffer.substring(details.getStartPosition(),
+ sub1data.getStartPosition());
+
+ substr += m_buffer.substring(sub2data.getEndPosition(),
+ details.getEndPosition());
+ }
+
+ if (substr != null && substr.indexOf("SEVERE:") != -1) {
+
+ Image image=ScenarioSimulationImages.getImage("error_obj.gif");
+ ti.setImage(image);
+
+ }
+ }
+
+ m_results.update();
+ }
+ }
+ */
+ }
+
+ protected TreeItem getTreeItem(String id, boolean create) {
+ TreeItem ret=null;
+ StringTokenizer st=new StringTokenizer(id, "/");
+
+ // Ignore scenario identity - may be useful in constructing
+ // tree items when multiple scenarios are being run
+ st.nextToken();
+
+ while (st.hasMoreTokens()) {
+ String token=st.nextToken();
+
+ try {
+ int pos=Integer.parseInt(token);
+
+ if (ret == null) {
+ if (create && st.hasMoreTokens()==false) {
+ ret = new TreeItem(m_results, SWT.NONE);
+ } else {
+ ret = m_results.getItem(pos);
+ }
+ } else {
+ if (create && st.hasMoreTokens()==false) {
+ ret = new TreeItem(ret, SWT.NONE);
+ } else {
+ ret = ret.getItem(pos);
+ }
+ }
+ } catch(Exception e) {
+ // Ignore
+ }
+ }
+
+ return(ret);
+ }
+
+ private Display m_display=null;
+ private Tree m_results=null;
+ private Text m_output=null;
+ private int m_currentPosition=0;
+ private StringBuffer m_buffer=new StringBuffer();
+}
Added: branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/simulation/ScenarioSimulationWindow.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/simulation/ScenarioSimulationWindow.java (rev 0)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.scenario/src/java/org/savara/tools/scenario/simulation/ScenarioSimulationWindow.java 2011-01-13 22:03:06 UTC (rev 575)
@@ -0,0 +1,346 @@
+/*
+ * Copyright 2005 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * Oct 24, 2005 : Initial version created by gary
+ */
+package org.savara.tools.scenario.simulation;
+
+import java.util.logging.Logger;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.core.Launch;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.TabFolder;
+import org.eclipse.swt.widgets.TabItem;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+
+/**
+ * This class provides the dialog window to obtain relevant service
+ * scenario test information from the user and then present the
+ * results of running the scenario.
+ *
+ */
+public class ScenarioSimulationWindow extends org.eclipse.jface.window.Window {
+
+ /**
+ * Constructor for the scenario test dialog.
+ *
+ * @param shell The shell
+ * @param project The project
+ * @param relativePath The project relative path of the
+ * choreography description
+ * @param cdlpack The CDL package
+ * @param cdlres The CDL resource
+ */
+ public ScenarioSimulationWindow(Shell shell, String project,
+ String relativePath, org.scribble.protocol.model.ProtocolModel protocol,
+ IResource cdlres) {
+ super(shell);
+
+ m_relativePath = relativePath;
+ m_protocol = protocol;
+ m_project = project;
+ m_cdlResource = cdlres;
+ }
+
+ /**
+ * This method creates the dialog details.
+ *
+ * @param parent The parent control
+ * @return The control containing the dialog components
+ */
+ protected Control createContents(Composite parent) {
+ Composite composite=(Composite)super.createContents(parent);
+
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 1;
+ composite.setLayout(layout);
+
+ GridData gd=null;
+
+ gd=new GridData();
+ gd.horizontalAlignment = SWT.FILL;
+ gd.verticalAlignment = SWT.FILL;
+ gd.horizontalSpan = 1;
+ gd.verticalSpan = 1;
+ gd.widthHint = 700;
+ gd.heightHint = 500;
+ gd.grabExcessHorizontalSpace = true;
+ gd.grabExcessVerticalSpace = true;
+ composite.setLayoutData(gd);
+
+ Group servgroup=new Group(composite, SWT.H_SCROLL|SWT.V_SCROLL);
+
+ gd=new GridData();
+ gd.horizontalAlignment = SWT.FILL;
+ gd.verticalAlignment = SWT.FILL;
+ gd.horizontalSpan = 1;
+ gd.widthHint = 700;
+ gd.grabExcessHorizontalSpace = true;
+ gd.grabExcessVerticalSpace = true;
+ servgroup.setLayoutData(gd);
+
+ layout = new GridLayout();
+ layout.numColumns = 4;
+ servgroup.setLayout(layout);
+
+ Tree tree=new Tree(servgroup, SWT.CHECK|
+ SWT.H_SCROLL|SWT.V_SCROLL);
+
+ gd=new GridData();
+ //gd.horizontalAlignment = SWT.FILL;
+ gd.verticalAlignment = SWT.FILL;
+ gd.horizontalSpan = 1;
+ gd.widthHint = 180;
+ gd.heightHint = 200;
+ gd.grabExcessVerticalSpace = true;
+ tree.setLayoutData(gd);
+
+ m_services = new TreeItem(tree, SWT.CHECK);
+
+ m_services.setText("Execute Services");
+
+ tree.addSelectionListener(new org.eclipse.swt.events.SelectionListener() {
+ public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
+ if (e.item == m_services &&
+ m_allServiceState != m_services.getChecked()) {
+ TreeItem[] treeItems=m_services.getItems();
+
+ for (int i=0; i < treeItems.length; i++) {
+ treeItems[i].setChecked(m_services.getChecked());
+ }
+
+ m_allServiceState = m_services.getChecked();
+ }
+ }
+
+ public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
+ widgetSelected(e);
+ }
+ });
+
+ java.util.Iterator<org.scribble.protocol.model.Role> iter=m_protocol.getRoles().iterator();
+
+ while (iter.hasNext()) {
+ org.scribble.protocol.model.Role role=
+ (org.scribble.protocol.model.Role)iter.next();
+
+ TreeItem ti=new TreeItem(m_services, SWT.CHECK);
+ ti.setText(role.getName());
+ ti.setChecked(false);
+ }
+
+ m_services.setExpanded(true);
+
+ TabFolder tabfolder=new TabFolder(servgroup, SWT.NONE);
+
+ gd=new GridData();
+ gd.horizontalAlignment = SWT.FILL;
+ gd.verticalAlignment = SWT.FILL;
+ gd.horizontalSpan = 3;
+ gd.widthHint = 400;
+ gd.grabExcessHorizontalSpace = true;
+ gd.grabExcessVerticalSpace = true;
+ tabfolder.setLayoutData(gd);
+
+ TabItem treePanel=new TabItem(tabfolder, SWT.NONE);
+ treePanel.setText("Scenario Results");
+
+ m_results = new Tree(tabfolder, SWT.H_SCROLL|SWT.V_SCROLL);
+ treePanel.setControl(m_results);
+
+ TabItem tracePanel=new TabItem(tabfolder, SWT.NONE);
+ tracePanel.setText("Trace Output");
+
+ m_output=new Text(tabfolder, SWT.MULTI|SWT.READ_ONLY|SWT.H_SCROLL|SWT.V_SCROLL);
+ tracePanel.setControl(m_output);
+
+ gd=new GridData();
+ gd.horizontalAlignment = SWT.FILL;
+ gd.verticalAlignment = SWT.FILL;
+ gd.horizontalSpan = 3;
+ gd.widthHint = 400;
+ gd.grabExcessHorizontalSpace = true;
+ gd.grabExcessVerticalSpace = true;
+ m_output.setLayoutData(gd);
+
+ Group buttons=new Group(composite, SWT.NONE);
+
+ layout = new GridLayout();
+ layout.numColumns = 2;
+ buttons.setLayout(layout);
+
+ gd=new GridData();
+ gd.horizontalAlignment = SWT.CENTER;
+
+ buttons.setLayoutData(gd);
+
+ Button run=new Button(buttons, SWT.NONE);
+ run.setText("Run Scenario");
+
+ run.addSelectionListener(new org.eclipse.swt.events.SelectionListener() {
+ public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
+ clearResults();
+
+ launch(m_cdlResource.getLocation().toString(),
+ m_project, m_relativePath);
+ }
+
+ public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
+ widgetSelected(e);
+ }
+ });
+
+ Button close=new Button(buttons, SWT.NONE);
+ close.setText("Close");
+
+ close.addSelectionListener(new org.eclipse.swt.events.SelectionListener() {
+ public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
+ close();
+ }
+
+ public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
+ widgetSelected(e);
+ }
+ });
+
+ return(composite);
+ }
+
+ protected void clearResults() {
+ m_output.setText("");
+ m_results.removeAll();
+ }
+
+ /**
+ * Configure the dialog shell.
+ *
+ * @param shell The shell
+ */
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+
+ String text="Scenario Tester ["+m_cdlResource.getName()+"]";
+
+ newShell.setText(text);
+ }
+
+ /**
+ * This method invokes the launch action.
+ *
+ * @param path The full path
+ * @param project The project
+ * @param relativePath The relative path within the project
+ */
+ protected void launch(String path, String project, String relativePath) {
+
+ ScenarioSimulationUILauncher launcher=
+ new ScenarioSimulationUILauncher(
+ getShell().getDisplay(), m_results, m_output);
+
+ try {
+ ILaunchManager manager =
+ DebugPlugin.getDefault().getLaunchManager();
+
+ ILaunchConfigurationType type =
+ manager.getLaunchConfigurationType(
+ ScenarioSimulationLaunchConfigurationConstants.LAUNCH_CONFIG_TYPE);
+ ILaunchConfiguration[] configurations =
+ manager.getLaunchConfigurations(type);
+
+ for (int i = 0; i < configurations.length; i++) {
+ ILaunchConfiguration configuration = configurations[i];
+ if (configuration.getName().equals(PI4SOA_TEST_SCENARIO)) {
+ configuration.delete();
+ break;
+ }
+ }
+
+ ILaunchConfigurationWorkingCopy workingCopy =
+ type.newInstance(null, PI4SOA_TEST_SCENARIO);
+
+ workingCopy.setAttribute(ScenarioSimulationLaunchConfigurationConstants.ATTR_PROJECT_NAME,
+ project);
+ workingCopy.setAttribute(ScenarioSimulationLaunchConfigurationConstants.ATTR_SCENARIO,
+ relativePath);
+
+ String services=getServiceList();
+ if (services != null) {
+ workingCopy.setAttribute(ScenarioSimulationLaunchConfigurationConstants.ATTR_EXECUTE_SERVICES,
+ services);
+ }
+
+ ILaunchConfiguration configuration=workingCopy.doSave();
+
+
+ Launch launch=new Launch(configuration, LAUNCH_MODE, null);
+
+ launcher.launch(configuration, LAUNCH_MODE, launch, null);
+
+ } catch(Exception e) {
+ logger.severe("Failed to launch scenario tester: "+e);
+
+ e.printStackTrace();
+ }
+ }
+
+ protected String getServiceList() {
+ String ret=null;
+
+ TreeItem[] treeItems=m_services.getItems();
+ for (int i=0; i < treeItems.length; i++) {
+
+ if (treeItems[i].getChecked()) {
+ if (ret == null) {
+ ret = treeItems[i].getText();
+ } else {
+ ret += ","+treeItems[i].getText();
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+ private static Logger logger = Logger.getLogger("org.pi4soa.service.test.eclipse");
+
+ private String m_relativePath=null;
+ private String m_project=null;
+ private org.scribble.protocol.model.ProtocolModel m_protocol=null;
+ private boolean m_allServiceState=false;
+ private IResource m_cdlResource=null;
+ private Text m_output=null;
+ private Tree m_results=null;
+ private TreeItem m_services=null;
+
+ private static final String LAUNCH_MODE = "run";
+ private static final String PI4SOA_TEST_SCENARIO = "Pi4SOA Test Scenario";
+}
Modified: branches/experimental/2.0.x/tools/plugins/pom.xml
===================================================================
--- branches/experimental/2.0.x/tools/plugins/pom.xml 2011-01-13 11:59:28 UTC (rev 574)
+++ branches/experimental/2.0.x/tools/plugins/pom.xml 2011-01-13 22:03:06 UTC (rev 575)
@@ -20,12 +20,13 @@
<module>org.savara.tap.model</module>
<module>org.savara.tap.validation</module>
-->
+ <module>org.savara.tools.core</module>
<module>org.savara.tools.bpel</module>
<module>org.savara.tools.bpmn</module>
- <module>org.savara.tools.core</module>
<module>org.savara.tools.monitor</module>
<module>org.savara.tools.validator</module>
<module>org.savara.tools.wsdl</module>
+ <module>org.savara.tools.scenario</module>
</modules>
</project>
More information about the savara-commits
mailing list