You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gu...@apache.org on 2010/05/18 17:13:31 UTC
svn commit: r945691 [30/39] - in
/commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src:
main/java/org.apache.commons.scxml.diagram/
main/java/org.apache.commons.scxml.diagram/META-INF/
main/java/org.apache.commons.scxml.diagram/icons/obj16/ main/java/org....
Modified: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.edit/src/org/apache/commons/scxml/modeling/provider/TranslationItemProvider.java
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.edit/src/org/apache/commons/scxml/modeling/provider/TranslationItemProvider.java?rev=945691&r1=945690&r2=945691&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.edit/src/org/apache/commons/scxml/modeling/provider/TranslationItemProvider.java (original)
+++ commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.edit/src/org/apache/commons/scxml/modeling/provider/TranslationItemProvider.java Tue May 18 15:13:13 2010
@@ -1,19 +1,6 @@
/**
- * 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.
- *
+ * <copyright>
+ * </copyright>
*
* $Id$
*/
@@ -23,7 +10,7 @@ package org.apache.commons.scxml.modelin
import java.util.Collection;
import java.util.List;
-import org.apache.commons.scxml.modeling.ScxmlPackage;
+import org.apache.commons.scxml.modeling.ModelingPackage;
import org.apache.commons.scxml.modeling.Translation;
import org.eclipse.emf.common.notify.AdapterFactory;
@@ -98,7 +85,7 @@ public class TranslationItemProvider
getResourceLocator(),
getString("_UI_Translation_targetStatus_feature"),
getString("_UI_PropertyDescriptor_description", "_UI_Translation_targetStatus_feature", "_UI_Translation_type"),
- ScxmlPackage.Literals.TRANSLATION__TARGET_STATUS,
+ ModelingPackage.Literals.TRANSLATION__TARGET_STATUS,
true,
false,
true,
@@ -120,7 +107,7 @@ public class TranslationItemProvider
getResourceLocator(),
getString("_UI_Translation_sourceStatus_feature"),
getString("_UI_PropertyDescriptor_description", "_UI_Translation_sourceStatus_feature", "_UI_Translation_type"),
- ScxmlPackage.Literals.TRANSLATION__SOURCE_STATUS,
+ ModelingPackage.Literals.TRANSLATION__SOURCE_STATUS,
true,
false,
true,
@@ -142,7 +129,7 @@ public class TranslationItemProvider
getResourceLocator(),
getString("_UI_Translation_event_feature"),
getString("_UI_PropertyDescriptor_description", "_UI_Translation_event_feature", "_UI_Translation_type"),
- ScxmlPackage.Literals.TRANSLATION__EVENT,
+ ModelingPackage.Literals.TRANSLATION__EVENT,
true,
false,
false,
@@ -164,7 +151,7 @@ public class TranslationItemProvider
getResourceLocator(),
getString("_UI_Translation_cond_feature"),
getString("_UI_PropertyDescriptor_description", "_UI_Translation_cond_feature", "_UI_Translation_type"),
- ScxmlPackage.Literals.TRANSLATION__COND,
+ ModelingPackage.Literals.TRANSLATION__COND,
true,
false,
false,
@@ -186,7 +173,7 @@ public class TranslationItemProvider
getResourceLocator(),
getString("_UI_Translation_target_feature"),
getString("_UI_PropertyDescriptor_description", "_UI_Translation_target_feature", "_UI_Translation_type"),
- ScxmlPackage.Literals.TRANSLATION__TARGET,
+ ModelingPackage.Literals.TRANSLATION__TARGET,
true,
false,
false,
@@ -208,7 +195,7 @@ public class TranslationItemProvider
getResourceLocator(),
getString("_UI_Translation_anchor_feature"),
getString("_UI_PropertyDescriptor_description", "_UI_Translation_anchor_feature", "_UI_Translation_type"),
- ScxmlPackage.Literals.TRANSLATION__ANCHOR,
+ ModelingPackage.Literals.TRANSLATION__ANCHOR,
true,
false,
false,
@@ -251,10 +238,10 @@ public class TranslationItemProvider
updateChildren(notification);
switch (notification.getFeatureID(Translation.class)) {
- case ScxmlPackage.TRANSLATION__EVENT:
- case ScxmlPackage.TRANSLATION__COND:
- case ScxmlPackage.TRANSLATION__TARGET:
- case ScxmlPackage.TRANSLATION__ANCHOR:
+ case ModelingPackage.TRANSLATION__EVENT:
+ case ModelingPackage.TRANSLATION__COND:
+ case ModelingPackage.TRANSLATION__TARGET:
+ case ModelingPackage.TRANSLATION__ANCHOR:
fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true));
return;
}
@@ -279,7 +266,7 @@ public class TranslationItemProvider
* @generated
*/
public ResourceLocator getResourceLocator() {
- return ScxmlEditPlugin.INSTANCE;
+ return ModelingEditPlugin.INSTANCE;
}
}
Modified: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.edit/src/org/apache/commons/scxml/modeling/provider/ValidateItemProvider.java
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.edit/src/org/apache/commons/scxml/modeling/provider/ValidateItemProvider.java?rev=945691&r1=945690&r2=945691&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.edit/src/org/apache/commons/scxml/modeling/provider/ValidateItemProvider.java (original)
+++ commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.edit/src/org/apache/commons/scxml/modeling/provider/ValidateItemProvider.java Tue May 18 15:13:13 2010
@@ -1,19 +1,6 @@
/**
- * 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.
- *
+ * <copyright>
+ * </copyright>
*
* $Id$
*/
@@ -23,7 +10,7 @@ package org.apache.commons.scxml.modelin
import java.util.Collection;
import java.util.List;
-import org.apache.commons.scxml.modeling.ScxmlPackage;
+import org.apache.commons.scxml.modeling.ModelingPackage;
import org.apache.commons.scxml.modeling.Validate;
import org.eclipse.emf.common.notify.AdapterFactory;
@@ -91,7 +78,7 @@ public class ValidateItemProvider
getResourceLocator(),
getString("_UI_Validate_location_feature"),
getString("_UI_PropertyDescriptor_description", "_UI_Validate_location_feature", "_UI_Validate_type"),
- ScxmlPackage.Literals.VALIDATE__LOCATION,
+ ModelingPackage.Literals.VALIDATE__LOCATION,
true,
false,
false,
@@ -113,7 +100,7 @@ public class ValidateItemProvider
getResourceLocator(),
getString("_UI_Validate_schema_feature"),
getString("_UI_PropertyDescriptor_description", "_UI_Validate_schema_feature", "_UI_Validate_type"),
- ScxmlPackage.Literals.VALIDATE__SCHEMA,
+ ModelingPackage.Literals.VALIDATE__SCHEMA,
true,
false,
false,
@@ -156,8 +143,8 @@ public class ValidateItemProvider
updateChildren(notification);
switch (notification.getFeatureID(Validate.class)) {
- case ScxmlPackage.VALIDATE__LOCATION:
- case ScxmlPackage.VALIDATE__SCHEMA:
+ case ModelingPackage.VALIDATE__LOCATION:
+ case ModelingPackage.VALIDATE__SCHEMA:
fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true));
return;
}
Modified: 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=945691&r1=945690&r2=945691&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/META-INF/MANIFEST.MF (original)
+++ commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/META-INF/MANIFEST.MF Tue May 18 15:13:13 2010
@@ -4,7 +4,7 @@ Bundle-Name: %pluginName
Bundle-SymbolicName: org.apache.commons.scxml.modeling.editor;singleton:=true
Bundle-Version: 1.0.0
Bundle-ClassPath: .
-Bundle-Activator: org.apache.commons.scxml.modeling.presentation.ScxmlEditorPlugin$Implementation
+Bundle-Activator: org.apache.commons.scxml.modeling.presentation.ModelingEditorPlugin$Implementation
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Export-Package: org.apache.commons.scxml.modeling.presentation
Modified: 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=945691&r1=945690&r2=945691&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/build.properties (original)
+++ commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/build.properties Tue May 18 15:13:13 2010
@@ -1,18 +1,6 @@
-# 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.
-#
+
+# <copyright>
+# </copyright>
#
# $Id$
Added: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/icons/full/obj16/ModelingModelFile.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/ModelingModelFile.gif?rev=945691&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/ModelingModelFile.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/NewModeling.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/NewModeling.gif?rev=945691&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/NewModeling.gif
------------------------------------------------------------------------------
svn:mime-type = image/gif
Modified: 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=945691&r1=945690&r2=945691&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/plugin.properties (original)
+++ commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/plugin.properties Tue May 18 15:13:13 2010
@@ -1,25 +1,13 @@
-# 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.
-#
+
+# <copyright>
+# </copyright>
#
# $Id$
-pluginName = Scxml Editor
+pluginName = Modeling Editor
providerName = www.example.org
-_UI_ScxmlEditor_menu = &Scxml Editor
+_UI_ModelingEditor_menu = &Modeling Editor
_UI_CreateChild_menu_item = &New Child
_UI_CreateSibling_menu_item = N&ew Sibling
@@ -46,13 +34,13 @@ _UI_Wizard_category = Example EMF Model
_UI_CreateModelError_message = Problems encountered in file "{0}"
-_UI_ScxmlModelWizard_label = Scxml Model
-_UI_ScxmlModelWizard_description = Create a new Scxml model
+_UI_ModelingModelWizard_label = Modeling Model
+_UI_ModelingModelWizard_description = Create a new Modeling model
-_UI_ScxmlEditor_label = Scxml Model Editor
+_UI_ModelingEditor_label = Modeling Model Editor
-_UI_ScxmlEditorFilenameDefaultBase = My
-_UI_ScxmlEditorFilenameExtensions = scxml
+_UI_ModelingEditorFilenameDefaultBase = My
+_UI_ModelingEditorFilenameExtensions = modeling
_UI_Wizard_label = New
Modified: 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=945691&r1=945690&r2=945691&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/plugin.xml (original)
+++ commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/plugin.xml Tue May 18 15:13:13 2010
@@ -2,21 +2,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.
-
+ <copyright>
+ </copyright>
$Id$
-->
@@ -28,24 +15,24 @@
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.modeling.presentation.ScxmlModelWizard"
+ id="org.apache.commons.scxml.modeling.presentation.ModelingModelWizardID"
+ name="%_UI_ModelingModelWizard_label"
+ class="org.apache.commons.scxml.modeling.presentation.ModelingModelWizard"
category="org.eclipse.emf.ecore.Wizard.category.ID"
- icon="icons/full/obj16/ScxmlModelFile.gif">
- <description>%_UI_ScxmlModelWizard_description</description>
+ icon="icons/full/obj16/ModelingModelFile.gif">
+ <description>%_UI_ModelingModelWizard_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.modeling.presentation.ScxmlEditor"
- contributorClass="org.apache.commons.scxml.modeling.presentation.ScxmlActionBarContributor">
+ id="org.apache.commons.scxml.modeling.presentation.ModelingEditorID"
+ name="%_UI_ModelingEditor_label"
+ icon="icons/full/obj16/ModelingModelFile.gif"
+ extensions="modeling"
+ class="org.apache.commons.scxml.modeling.presentation.ModelingEditor"
+ contributorClass="org.apache.commons.scxml.modeling.presentation.ModelingActionBarContributor">
</editor>
</extension>
Added: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/src/org/apache/commons/scxml/modeling/presentation/ModelingActionBarContributor.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/modeling/presentation/ModelingActionBarContributor.java?rev=945691&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/src/org/apache/commons/scxml/modeling/presentation/ModelingActionBarContributor.java (added)
+++ commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.editor/src/org/apache/commons/scxml/modeling/presentation/ModelingActionBarContributor.java Tue May 18 15:13:13 2010
@@ -0,0 +1,420 @@
+/**
+ * <copyright>
+ * </copyright>
+ *
+ * $Id$
+ */
+package org.apache.commons.scxml.modeling.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 Modeling model editor.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+public class ModelingActionBarContributor
+ 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(ModelingEditorPlugin.INSTANCE.getString("_UI_ShowPropertiesView_menu_item")) {
+ public void run() {
+ try {
+ getPage().showView("org.eclipse.ui.views.PropertySheet");
+ }
+ catch (PartInitException exception) {
+ ModelingEditorPlugin.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(ModelingEditorPlugin.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 ModelingActionBarContributor() {
+ 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("modeling-settings"));
+ toolBarManager.add(new Separator("modeling-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(ModelingEditorPlugin.INSTANCE.getString("_UI_ModelingEditor_menu"), "org.apache.commons.scxml.modelingMenuID");
+ 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(ModelingEditorPlugin.INSTANCE.getString("_UI_CreateChild_menu_item"));
+ submenuManager.insertBefore("additions", createChildMenuManager);
+
+ // Prepare for CreateSibling item addition or removal.
+ //
+ createSiblingMenuManager = new MenuManager(ModelingEditorPlugin.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(ModelingEditorPlugin.INSTANCE.getString("_UI_CreateChild_menu_item"));
+ populateManager(submenuManager, createChildActions, null);
+ menuManager.insertBefore("edit", submenuManager);
+
+ submenuManager = new MenuManager(ModelingEditorPlugin.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/modeling/presentation/ModelingActionBarContributor.java
------------------------------------------------------------------------------
svn:eol-style = native