commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gu...@apache.org
Subject svn commit: r945191 [1/2] - in /commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor: ./ META-INF/ bin/ icons/ icons/full/ icons/full/obj16/ icons/full/wizban/ src/ src/org/ src/org/apache/ src/org/apache/commons/...
Date Mon, 17 May 2010 14:52:53 GMT
Author: guixl
Date: Mon May 17 14:52:52 2010
New Revision: 945191

URL: http://svn.apache.org/viewvc?rev=945191&view=rev
Log:
Initial source code import by Gui Xun Long

Added:
    commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/.classpath
  (with props)
    commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/.project
  (with props)
    commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/META-INF/
    commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/META-INF/MANIFEST.MF
  (with props)
    commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/bin/
    commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/build.properties
  (with props)
    commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/icons/
    commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/icons/full/
    commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/icons/full/obj16/
    commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/icons/full/obj16/ScxmlModelFile.gif
  (with props)
    commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/icons/full/wizban/
    commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/icons/full/wizban/NewScxml.gif
  (with props)
    commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/plugin.properties
  (with props)
    commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/plugin.xml
  (with props)
    commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/src/
    commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/src/org/
    commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/src/org/apache/
    commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/src/org/apache/commons/
    commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/src/org/apache/commons/scxml/
    commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/src/org/apache/commons/scxml/presentation/
    commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/src/org/apache/commons/scxml/presentation/ScxmlActionBarContributor.java
  (with props)
    commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/src/org/apache/commons/scxml/presentation/ScxmlEditor.java
  (with props)
    commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/src/org/apache/commons/scxml/presentation/ScxmlEditorPlugin.java
  (with props)
    commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/src/org/apache/commons/scxml/presentation/ScxmlModelWizard.java
  (with props)

Added: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/.classpath
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/.classpath?rev=945191&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/.classpath
(added)
+++ commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/.classpath
Mon May 17 14:52:52 2010
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<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="output" path="bin"/>
+</classpath>

Propchange: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/.classpath
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/.project
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/.project?rev=945191&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/.project
(added)
+++ commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/.project
Mon May 17 14:52:52 2010
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>org.apache.commons.scxml.editor</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.jdt.core.javanature</nature>
+		<nature>org.eclipse.pde.PluginNature</nature>
+	</natures>
+</projectDescription>

Propchange: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/.project
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/META-INF/MANIFEST.MF?rev=945191&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/META-INF/MANIFEST.MF
(added)
+++ commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/META-INF/MANIFEST.MF
Mon May 17 14:52:52 2010
@@ -0,0 +1,18 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %pluginName
+Bundle-SymbolicName: org.apache.commons.scxml.editor;singleton:=true
+Bundle-Version: 1.0.0
+Bundle-ClassPath: .
+Bundle-Activator: org.apache.commons.scxml.presentation.ScxmlEditorPlugin$Implementation
+Bundle-Vendor: %providerName
+Bundle-Localization: plugin
+Export-Package: org.apache.commons.scxml.presentation
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.core.resources;visibility:=reexport,
+ org.apache.commons.scxml.edit;visibility:=reexport,
+ org.eclipse.emf.ecore.xmi;visibility:=reexport,
+ org.eclipse.emf.edit.ui;visibility:=reexport,
+ org.eclipse.ui.ide;visibility:=reexport
+Eclipse-LazyStart: true
+Bundle-ActivationPolicy: lazy

Propchange: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/META-INF/MANIFEST.MF
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/build.properties
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/build.properties?rev=945191&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/build.properties
(added)
+++ commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/build.properties
Mon May 17 14:52:52 2010
@@ -0,0 +1,26 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+# 
+#
+# $Id$
+
+bin.includes = .,\
+               icons/,\
+               META-INF/,\
+               plugin.xml,\
+               plugin.properties
+jars.compile.order = .
+source.. = src/
+output.. = bin/

Propchange: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/build.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/icons/full/obj16/ScxmlModelFile.gif
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/icons/full/obj16/ScxmlModelFile.gif?rev=945191&view=auto
==============================================================================
Binary file - no diff available.

Propchange: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/icons/full/obj16/ScxmlModelFile.gif
------------------------------------------------------------------------------
    svn:mime-type = image/gif

Added: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/icons/full/wizban/NewScxml.gif
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/icons/full/wizban/NewScxml.gif?rev=945191&view=auto
==============================================================================
Binary file - no diff available.

Propchange: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/icons/full/wizban/NewScxml.gif
------------------------------------------------------------------------------
    svn:mime-type = image/gif

Added: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/plugin.properties
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/plugin.properties?rev=945191&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/plugin.properties
(added)
+++ commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/plugin.properties
Mon May 17 14:52:52 2010
@@ -0,0 +1,69 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+# 
+#
+# $Id$
+
+pluginName = Scxml Editor
+providerName = www.example.org
+
+_UI_ScxmlEditor_menu = &Scxml Editor
+
+_UI_CreateChild_menu_item = &New Child
+_UI_CreateSibling_menu_item = N&ew Sibling
+
+_UI_ShowPropertiesView_menu_item = Show &Properties View
+_UI_RefreshViewer_menu_item = &Refresh
+
+_UI_SelectionPage_label = Selection
+_UI_ParentPage_label = Parent
+_UI_ListPage_label = List
+_UI_TreePage_label = Tree
+_UI_TablePage_label = Table
+_UI_TreeWithColumnsPage_label = Tree with Columns
+_UI_ObjectColumn_label = Object
+_UI_SelfColumn_label = Self
+
+_UI_NoObjectSelected = Selected Nothing
+_UI_SingleObjectSelected = Selected Object: {0}
+_UI_MultiObjectSelected = Selected {0} Objects
+
+_UI_OpenEditorError_label = Open Editor
+
+_UI_Wizard_category = Example EMF Model Creation Wizards
+
+_UI_CreateModelError_message = Problems encountered in file "{0}"
+
+_UI_ScxmlModelWizard_label = Scxml Model
+_UI_ScxmlModelWizard_description = Create a new Scxml model
+
+_UI_ScxmlEditor_label = Scxml Model Editor
+
+_UI_ScxmlEditorFilenameDefaultBase = My
+_UI_ScxmlEditorFilenameExtensions = scxml
+
+_UI_Wizard_label = New
+
+_WARN_FilenameExtension = The file name must end in ''.{0}''
+_WARN_FilenameExtensions = The file name must have one of the following extensions: {0}
+
+_UI_ModelObject = &Model Object
+_UI_XMLEncoding = &XML Encoding
+_UI_XMLEncodingChoices = UTF-8 ASCII UTF-16 UTF-16BE UTF-16LE ISO-8859-1
+_UI_Wizard_initial_object_description = Select a model object to create
+
+_UI_FileConflict_label = File Conflict
+_WARN_FileConflict = There are unsaved changes that conflict with changes made outside the
editor.  Do you wish to discard this editor's changes?
+

Propchange: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/plugin.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/plugin.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/plugin.xml?rev=945191&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/plugin.xml
(added)
+++ commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/plugin.xml
Mon May 17 14:52:52 2010
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
+
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements.  See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+ 
+
+ $Id$
+-->
+
+<plugin>
+
+   <extension point="org.eclipse.ui.newWizards">
+      <category
+            id="org.eclipse.emf.ecore.Wizard.category.ID"
+            name="%_UI_Wizard_category"/>
+      <wizard
+            id="org.apache.commons.scxml.presentation.ScxmlModelWizardID"
+            name="%_UI_ScxmlModelWizard_label"
+            class="org.apache.commons.scxml.presentation.ScxmlModelWizard"
+            category="org.eclipse.emf.ecore.Wizard.category.ID"
+            icon="icons/full/obj16/ScxmlModelFile.gif">
+         <description>%_UI_ScxmlModelWizard_description</description>
+         <selection class="org.eclipse.core.resources.IResource"/>
+      </wizard>
+   </extension>
+
+   <extension point="org.eclipse.ui.editors">
+      <editor
+            id="org.apache.commons.scxml.presentation.ScxmlEditorID"
+            name="%_UI_ScxmlEditor_label"
+            icon="icons/full/obj16/ScxmlModelFile.gif"
+            extensions="scxml"
+            class="org.apache.commons.scxml.presentation.ScxmlEditor"
+            contributorClass="org.apache.commons.scxml.presentation.ScxmlActionBarContributor">
+      </editor>
+   </extension>
+
+</plugin>

Propchange: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/plugin.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/src/org/apache/commons/scxml/presentation/ScxmlActionBarContributor.java
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/src/org/apache/commons/scxml/presentation/ScxmlActionBarContributor.java?rev=945191&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/src/org/apache/commons/scxml/presentation/ScxmlActionBarContributor.java
(added)
+++ commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/src/org/apache/commons/scxml/presentation/ScxmlActionBarContributor.java
Mon May 17 14:52:52 2010
@@ -0,0 +1,433 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ * 
+ *
+ * $Id$
+ */
+package org.apache.commons.scxml.presentation;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.eclipse.emf.common.ui.viewer.IViewerProvider;
+
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.edit.domain.IEditingDomainProvider;
+
+import org.eclipse.emf.edit.ui.action.ControlAction;
+import org.eclipse.emf.edit.ui.action.CreateChildAction;
+import org.eclipse.emf.edit.ui.action.CreateSiblingAction;
+import org.eclipse.emf.edit.ui.action.EditingDomainActionBarContributor;
+import org.eclipse.emf.edit.ui.action.LoadResourceAction;
+import org.eclipse.emf.edit.ui.action.ValidateAction;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.ActionContributionItem;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IContributionItem;
+import org.eclipse.jface.action.IContributionManager;
+import org.eclipse.jface.action.IMenuListener;
+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.jface.action.SubContributionItem;
+
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.Viewer;
+
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.PartInitException;
+
+/**
+ * This is the action bar contributor for the Scxml model editor.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+public class ScxmlActionBarContributor
+	extends EditingDomainActionBarContributor
+	implements ISelectionChangedListener {
+	/**
+	 * This keeps track of the active editor.
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @generated
+	 */
+	protected IEditorPart activeEditorPart;
+
+	/**
+	 * This keeps track of the current selection provider.
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @generated
+	 */
+	protected ISelectionProvider selectionProvider;
+
+	/**
+	 * This action opens the Properties view.
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @generated
+	 */
+	protected IAction showPropertiesViewAction =
+		new Action(ScxmlEditorPlugin.INSTANCE.getString("_UI_ShowPropertiesView_menu_item")) {
+			public void run() {
+				try {
+					getPage().showView("org.eclipse.ui.views.PropertySheet");
+				}
+				catch (PartInitException exception) {
+					ScxmlEditorPlugin.INSTANCE.log(exception);
+				}
+			}
+		};
+
+	/**
+	 * This action refreshes the viewer of the current editor if the editor
+	 * implements {@link org.eclipse.emf.common.ui.viewer.IViewerProvider}.
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @generated
+	 */
+	protected IAction refreshViewerAction =
+		new Action(ScxmlEditorPlugin.INSTANCE.getString("_UI_RefreshViewer_menu_item")) {
+			public boolean isEnabled() {
+				return activeEditorPart instanceof IViewerProvider;
+			}
+
+			public void run() {
+				if (activeEditorPart instanceof IViewerProvider) {
+					Viewer viewer = ((IViewerProvider)activeEditorPart).getViewer();
+					if (viewer != null) {
+						viewer.refresh();
+					}
+				}
+			}
+		};
+
+	/**
+	 * This will contain one {@link org.eclipse.emf.edit.ui.action.CreateChildAction} corresponding
to each descriptor
+	 * generated for the current selection by the item provider.
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @generated
+	 */
+	protected Collection createChildActions;
+
+	/**
+	 * This is the menu manager into which menu contribution items should be added for CreateChild
actions.
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @generated
+	 */
+	protected IMenuManager createChildMenuManager;
+
+	/**
+	 * This will contain one {@link org.eclipse.emf.edit.ui.action.CreateSiblingAction} corresponding
to each descriptor
+	 * generated for the current selection by the item provider.
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @generated
+	 */
+	protected Collection createSiblingActions;
+
+	/**
+	 * This is the menu manager into which menu contribution items should be added for CreateSibling
actions.
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @generated
+	 */
+	protected IMenuManager createSiblingMenuManager;
+
+	/**
+	 * This creates an instance of the contributor.
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @generated
+	 */
+	public ScxmlActionBarContributor() {
+		super(ADDITIONS_LAST_STYLE);
+		loadResourceAction = new LoadResourceAction();
+		validateAction = new ValidateAction();
+		controlAction = new ControlAction();
+	}
+
+	/**
+	 * This adds Separators for editor additions to the tool bar.
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @generated
+	 */
+	public void contributeToToolBar(IToolBarManager toolBarManager) {
+		toolBarManager.add(new Separator("scxml-settings"));
+		toolBarManager.add(new Separator("scxml-additions"));
+	}
+
+	/**
+	 * This adds to the menu bar a menu and some separators for editor additions,
+	 * as well as the sub-menus for object creation items.
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @generated
+	 */
+	public void contributeToMenu(IMenuManager menuManager) {
+		super.contributeToMenu(menuManager);
+
+		IMenuManager submenuManager = new MenuManager(ScxmlEditorPlugin.INSTANCE.getString("_UI_ScxmlEditor_menu"),
"org.apache.commons.scxmlMenuID");
+		menuManager.insertAfter("additions", submenuManager);
+		submenuManager.add(new Separator("settings"));
+		submenuManager.add(new Separator("actions"));
+		submenuManager.add(new Separator("additions"));
+		submenuManager.add(new Separator("additions-end"));
+
+		// Prepare for CreateChild item addition or removal.
+		//
+		createChildMenuManager = new MenuManager(ScxmlEditorPlugin.INSTANCE.getString("_UI_CreateChild_menu_item"));
+		submenuManager.insertBefore("additions", createChildMenuManager);
+
+		// Prepare for CreateSibling item addition or removal.
+		//
+		createSiblingMenuManager = new MenuManager(ScxmlEditorPlugin.INSTANCE.getString("_UI_CreateSibling_menu_item"));
+		submenuManager.insertBefore("additions", createSiblingMenuManager);
+
+		// Force an update because Eclipse hides empty menus now.
+		//
+		submenuManager.addMenuListener
+			(new IMenuListener() {
+				 public void menuAboutToShow(IMenuManager menuManager) {
+					 menuManager.updateAll(true);
+				 }
+			 });
+
+		addGlobalActions(submenuManager);
+	}
+
+	/**
+	 * When the active editor changes, this remembers the change and registers with it as a
selection provider.
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @generated
+	 */
+	public void setActiveEditor(IEditorPart part) {
+		super.setActiveEditor(part);
+		activeEditorPart = part;
+
+		// Switch to the new selection provider.
+		//
+		if (selectionProvider != null) {
+			selectionProvider.removeSelectionChangedListener(this);
+		}
+		if (part == null) {
+			selectionProvider = null;
+		}
+		else {
+			selectionProvider = part.getSite().getSelectionProvider();
+			selectionProvider.addSelectionChangedListener(this);
+
+			// Fake a selection changed event to update the menus.
+			//
+			if (selectionProvider.getSelection() != null) {
+				selectionChanged(new SelectionChangedEvent(selectionProvider, selectionProvider.getSelection()));
+			}
+		}
+	}
+
+	/**
+	 * This implements {@link org.eclipse.jface.viewers.ISelectionChangedListener},
+	 * handling {@link org.eclipse.jface.viewers.SelectionChangedEvent}s by querying for the
children and siblings
+	 * that can be added to the selected object and updating the menus accordingly.
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @generated
+	 */
+	public void selectionChanged(SelectionChangedEvent event) {
+		// Remove any menu items for old selection.
+		//
+		if (createChildMenuManager != null) {
+			depopulateManager(createChildMenuManager, createChildActions);
+		}
+		if (createSiblingMenuManager != null) {
+			depopulateManager(createSiblingMenuManager, createSiblingActions);
+		}
+
+		// Query the new selection for appropriate new child/sibling descriptors
+		//
+		Collection newChildDescriptors = null;
+		Collection newSiblingDescriptors = null;
+
+		ISelection selection = event.getSelection();
+		if (selection instanceof IStructuredSelection && ((IStructuredSelection)selection).size()
== 1) {
+			Object object = ((IStructuredSelection)selection).getFirstElement();
+
+			EditingDomain domain = ((IEditingDomainProvider)activeEditorPart).getEditingDomain();
+
+			newChildDescriptors = domain.getNewChildDescriptors(object, null);
+			newSiblingDescriptors = domain.getNewChildDescriptors(null, object);
+		}
+
+		// Generate actions for selection; populate and redraw the menus.
+		//
+		createChildActions = generateCreateChildActions(newChildDescriptors, selection);
+		createSiblingActions = generateCreateSiblingActions(newSiblingDescriptors, selection);
+
+		if (createChildMenuManager != null) {
+			populateManager(createChildMenuManager, createChildActions, null);
+			createChildMenuManager.update(true);
+		}
+		if (createSiblingMenuManager != null) {
+			populateManager(createSiblingMenuManager, createSiblingActions, null);
+			createSiblingMenuManager.update(true);
+		}
+	}
+
+	/**
+	 * This generates a {@link org.eclipse.emf.edit.ui.action.CreateChildAction} for each object
in <code>descriptors</code>,
+	 * and returns the collection of these actions.
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @generated
+	 */
+	protected Collection generateCreateChildActions(Collection descriptors, ISelection selection)
{
+		Collection actions = new ArrayList();
+		if (descriptors != null) {
+			for (Iterator i = descriptors.iterator(); i.hasNext(); ) {
+				actions.add(new CreateChildAction(activeEditorPart, selection, i.next()));
+			}
+		}
+		return actions;
+	}
+
+	/**
+	 * This generates a {@link org.eclipse.emf.edit.ui.action.CreateSiblingAction} for each
object in <code>descriptors</code>,
+	 * and returns the collection of these actions.
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @generated
+	 */
+	protected Collection generateCreateSiblingActions(Collection descriptors, ISelection selection)
{
+		Collection actions = new ArrayList();
+		if (descriptors != null) {
+			for (Iterator i = descriptors.iterator(); i.hasNext(); ) {
+				actions.add(new CreateSiblingAction(activeEditorPart, selection, i.next()));
+			}
+		}
+		return actions;
+	}
+
+	/**
+	 * This populates the specified <code>manager</code> with {@link org.eclipse.jface.action.ActionContributionItem}s
+	 * based on the {@link org.eclipse.jface.action.IAction}s contained in the <code>actions</code>
collection,
+	 * by inserting them before the specified contribution item <code>contributionID</code>.
+	 * If <code>contributionID</code> is <code>null</code>, they are
simply added.
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @generated
+	 */
+	protected void populateManager(IContributionManager manager, Collection actions, String
contributionID) {
+		if (actions != null) {
+			for (Iterator i = actions.iterator(); i.hasNext(); ) {
+				IAction action = (IAction)i.next();
+				if (contributionID != null) {
+					manager.insertBefore(contributionID, action);
+				}
+				else {
+					manager.add(action);
+				}
+			}
+		}
+	}
+		
+	/**
+	 * This removes from the specified <code>manager</code> all {@link org.eclipse.jface.action.ActionContributionItem}s
+	 * based on the {@link org.eclipse.jface.action.IAction}s contained in the <code>actions</code>
collection.
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @generated
+	 */
+	protected void depopulateManager(IContributionManager manager, Collection actions) {
+		if (actions != null) {
+			IContributionItem[] items = manager.getItems();
+			for (int i = 0; i < items.length; i++) {
+				// Look into SubContributionItems
+				//
+				IContributionItem contributionItem = items[i];
+				while (contributionItem instanceof SubContributionItem) {
+					contributionItem = ((SubContributionItem)contributionItem).getInnerItem();
+				}
+
+				// Delete the ActionContributionItems with matching action.
+				//
+				if (contributionItem instanceof ActionContributionItem) {
+					IAction action = ((ActionContributionItem)contributionItem).getAction();
+					if (actions.contains(action)) {
+						manager.remove(contributionItem);
+					}
+				}
+			}
+		}
+	}
+
+	/**
+	 * This populates the pop-up menu before it appears.
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @generated
+	 */
+	public void menuAboutToShow(IMenuManager menuManager) {
+		super.menuAboutToShow(menuManager);
+		MenuManager submenuManager = null;
+
+		submenuManager = new MenuManager(ScxmlEditorPlugin.INSTANCE.getString("_UI_CreateChild_menu_item"));
+		populateManager(submenuManager, createChildActions, null);
+		menuManager.insertBefore("edit", submenuManager);
+
+		submenuManager = new MenuManager(ScxmlEditorPlugin.INSTANCE.getString("_UI_CreateSibling_menu_item"));
+		populateManager(submenuManager, createSiblingActions, null);
+		menuManager.insertBefore("edit", submenuManager);
+	}
+
+	/**
+	 * This inserts global actions before the "additions-end" separator.
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @generated
+	 */
+	protected void addGlobalActions(IMenuManager menuManager) {
+		menuManager.insertAfter("additions-end", new Separator("ui-actions"));
+		menuManager.insertAfter("ui-actions", showPropertiesViewAction);
+
+		refreshViewerAction.setEnabled(refreshViewerAction.isEnabled());		
+		menuManager.insertAfter("ui-actions", refreshViewerAction);
+
+		super.addGlobalActions(menuManager);
+	}
+
+	/**
+	 * This ensures that a delete action will clean up all references to deleted objects.
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @generated
+	 */
+	protected boolean removeAllReferencesOnDelete() {
+		return true;
+	}
+
+}
\ No newline at end of file

Propchange: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/src/org/apache/commons/scxml/presentation/ScxmlActionBarContributor.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message