commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gu...@apache.org
Subject svn commit: r945691 [16/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....
Date Tue, 18 May 2010 15:13:31 GMT
Modified: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/modeling/diagram/edit/policies/ValidateItemSemanticEditPolicy.java
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/modeling/diagram/edit/policies/ValidateItemSemanticEditPolicy.java?rev=945691&r1=945690&r2=945691&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/modeling/diagram/edit/policies/ValidateItemSemanticEditPolicy.java
(original)
+++ commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/modeling/diagram/edit/policies/ValidateItemSemanticEditPolicy.java
Tue May 18 15:13:13 2010
@@ -1,19 +1,3 @@
-/*
- * 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.
- */
 package org.apache.commons.scxml.modeling.diagram.edit.policies;
 
 import org.eclipse.gef.commands.Command;
@@ -25,7 +9,7 @@ import org.eclipse.gmf.runtime.emf.type.
  * @generated
  */
 public class ValidateItemSemanticEditPolicy extends
-		ScxmlBaseItemSemanticEditPolicy {
+		ModelingBaseItemSemanticEditPolicy {
 
 	/**
 	 * @generated

Added: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/modeling/diagram/navigator/ModelingAbstractNavigatorItem.java
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/modeling/diagram/navigator/ModelingAbstractNavigatorItem.java?rev=945691&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/modeling/diagram/navigator/ModelingAbstractNavigatorItem.java
(added)
+++ commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/modeling/diagram/navigator/ModelingAbstractNavigatorItem.java
Tue May 18 15:13:13 2010
@@ -0,0 +1,61 @@
+package org.apache.commons.scxml.modeling.diagram.navigator;
+
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.PlatformObject;
+import org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor;
+
+/**
+ * @generated
+ */
+public abstract class ModelingAbstractNavigatorItem extends PlatformObject {
+
+	/**
+	 * @generated
+	 */
+	static {
+		final Class[] supportedTypes = new Class[] { ITabbedPropertySheetPageContributor.class
};
+		final ITabbedPropertySheetPageContributor propertySheetPageContributor = new ITabbedPropertySheetPageContributor()
{
+			public String getContributorId() {
+				return "org.apache.commons.scxml.modeling.diagram"; //$NON-NLS-1$
+			}
+		};
+		Platform.getAdapterManager().registerAdapters(
+				new IAdapterFactory() {
+
+					public Object getAdapter(Object adaptableObject,
+							Class adapterType) {
+						if (adaptableObject instanceof org.apache.commons.scxml.modeling.diagram.navigator.ModelingAbstractNavigatorItem
+								&& adapterType == ITabbedPropertySheetPageContributor.class) {
+							return propertySheetPageContributor;
+						}
+						return null;
+					}
+
+					public Class[] getAdapterList() {
+						return supportedTypes;
+					}
+				},
+				org.apache.commons.scxml.modeling.diagram.navigator.ModelingAbstractNavigatorItem.class);
+	}
+
+	/**
+	 * @generated
+	 */
+	private Object myParent;
+
+	/**
+	 * @generated
+	 */
+	protected ModelingAbstractNavigatorItem(Object parent) {
+		myParent = parent;
+	}
+
+	/**
+	 * @generated
+	 */
+	public Object getParent() {
+		return myParent;
+	}
+
+}

Propchange: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/modeling/diagram/navigator/ModelingAbstractNavigatorItem.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/modeling/diagram/navigator/ModelingDomainNavigatorContentProvider.java
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/modeling/diagram/navigator/ModelingDomainNavigatorContentProvider.java?rev=945691&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/modeling/diagram/navigator/ModelingDomainNavigatorContentProvider.java
(added)
+++ commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/modeling/diagram/navigator/ModelingDomainNavigatorContentProvider.java
Tue May 18 15:13:13 2010
@@ -0,0 +1,234 @@
+package org.apache.commons.scxml.modeling.diagram.navigator;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+
+import org.apache.commons.scxml.modeling.diagram.part.ModelingDiagramEditorPlugin;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
+import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.emf.workspace.util.WorkspaceSynchronizer;
+import org.eclipse.gmf.runtime.emf.core.GMFEditingDomainFactory;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.navigator.ICommonContentExtensionSite;
+import org.eclipse.ui.navigator.ICommonContentProvider;
+
+/**
+ * @generated
+ */
+public class ModelingDomainNavigatorContentProvider implements
+		ICommonContentProvider {
+
+	/**
+	 * @generated
+	 */
+	private AdapterFactoryContentProvider myAdapterFctoryContentProvier;
+
+	/**
+	 * @generated
+	 */
+	private static final Object[] EMPTY_ARRAY = new Object[0];
+
+	/**
+	 * @generated
+	 */
+	private Viewer myViewer;
+
+	/**
+	 * @generated
+	 */
+	private AdapterFactoryEditingDomain myEditingDomain;
+
+	/**
+	 * @generated
+	 */
+	private WorkspaceSynchronizer myWorkspaceSynchronizer;
+
+	/**
+	 * @generated
+	 */
+	private Runnable myViewerRefreshRunnable;
+
+	/**
+	 * @generated
+	 */
+	public ModelingDomainNavigatorContentProvider() {
+		myAdapterFctoryContentProvier = new AdapterFactoryContentProvider(
+				ModelingDiagramEditorPlugin.getInstance()
+						.getItemProvidersAdapterFactory());
+		TransactionalEditingDomain editingDomain = GMFEditingDomainFactory.INSTANCE
+				.createEditingDomain();
+		myEditingDomain = (AdapterFactoryEditingDomain) editingDomain;
+		myEditingDomain.setResourceToReadOnlyMap(new HashMap() {
+			public Object get(Object key) {
+				if (!containsKey(key)) {
+					put(key, Boolean.TRUE);
+				}
+				return super.get(key);
+			}
+		});
+		myViewerRefreshRunnable = new Runnable() {
+			public void run() {
+				if (myViewer != null) {
+					myViewer.refresh();
+				}
+			}
+		};
+		myWorkspaceSynchronizer = new WorkspaceSynchronizer(editingDomain,
+				new WorkspaceSynchronizer.Delegate() {
+					public void dispose() {
+					}
+
+					public boolean handleResourceChanged(final Resource resource) {
+						for (Iterator it = myEditingDomain.getResourceSet()
+								.getResources().iterator(); it.hasNext();) {
+							Resource nextResource = (Resource) it.next();
+							nextResource.unload();
+						}
+						if (myViewer != null) {
+							myViewer.getControl().getDisplay().asyncExec(
+									myViewerRefreshRunnable);
+						}
+						return true;
+					}
+
+					public boolean handleResourceDeleted(Resource resource) {
+						for (Iterator it = myEditingDomain.getResourceSet()
+								.getResources().iterator(); it.hasNext();) {
+							Resource nextResource = (Resource) it.next();
+							nextResource.unload();
+						}
+						if (myViewer != null) {
+							myViewer.getControl().getDisplay().asyncExec(
+									myViewerRefreshRunnable);
+						}
+						return true;
+					}
+
+					public boolean handleResourceMoved(Resource resource,
+							final URI newURI) {
+						for (Iterator it = myEditingDomain.getResourceSet()
+								.getResources().iterator(); it.hasNext();) {
+							Resource nextResource = (Resource) it.next();
+							nextResource.unload();
+						}
+						if (myViewer != null) {
+							myViewer.getControl().getDisplay().asyncExec(
+									myViewerRefreshRunnable);
+						}
+						return true;
+					}
+				});
+	}
+
+	/**
+	 * @generated
+	 */
+	public void dispose() {
+		myWorkspaceSynchronizer.dispose();
+		myWorkspaceSynchronizer = null;
+		myViewerRefreshRunnable = null;
+		for (Iterator it = myEditingDomain.getResourceSet().getResources()
+				.iterator(); it.hasNext();) {
+			Resource resource = (Resource) it.next();
+			resource.unload();
+		}
+		((TransactionalEditingDomain) myEditingDomain).dispose();
+		myEditingDomain = null;
+	}
+
+	/**
+	 * @generated
+	 */
+	public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+		myViewer = viewer;
+	}
+
+	/**
+	 * @generated
+	 */
+	public Object[] getElements(Object inputElement) {
+		return getChildren(inputElement);
+	}
+
+	/**
+	 * @generated
+	 */
+	public void restoreState(IMemento aMemento) {
+	}
+
+	/**
+	 * @generated
+	 */
+	public void saveState(IMemento aMemento) {
+	}
+
+	/**
+	 * @generated
+	 */
+	public void init(ICommonContentExtensionSite aConfig) {
+	}
+
+	/**
+	 * @generated
+	 */
+	public Object[] getChildren(Object parentElement) {
+		if (parentElement instanceof IFile) {
+			IFile file = (IFile) parentElement;
+			URI fileURI = URI.createPlatformResourceURI(file.getFullPath()
+					.toString(), true);
+			Resource resource = myEditingDomain.getResourceSet().getResource(
+					fileURI, true);
+			return wrapEObjects(myAdapterFctoryContentProvier
+					.getChildren(resource), parentElement);
+		}
+
+		if (parentElement instanceof ModelingDomainNavigatorItem) {
+			return wrapEObjects(myAdapterFctoryContentProvier
+					.getChildren(((ModelingDomainNavigatorItem) parentElement)
+							.getEObject()), parentElement);
+		}
+		return EMPTY_ARRAY;
+	}
+
+	/**
+	 * @generated
+	 */
+	public Object[] wrapEObjects(Object[] objects, Object parentElement) {
+		Collection result = new ArrayList();
+		for (int i = 0; i < objects.length; i++) {
+			if (objects[i] instanceof EObject) {
+				result.add(new ModelingDomainNavigatorItem(
+						(EObject) objects[i], parentElement,
+						myAdapterFctoryContentProvier));
+			}
+		}
+		return result.toArray();
+	}
+
+	/**
+	 * @generated
+	 */
+	public Object getParent(Object element) {
+		if (element instanceof ModelingAbstractNavigatorItem) {
+			ModelingAbstractNavigatorItem abstractNavigatorItem = (ModelingAbstractNavigatorItem)
element;
+			return abstractNavigatorItem.getParent();
+		}
+		return null;
+	}
+
+	/**
+	 * @generated
+	 */
+	public boolean hasChildren(Object element) {
+		return element instanceof IFile || getChildren(element).length > 0;
+	}
+
+}

Propchange: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/modeling/diagram/navigator/ModelingDomainNavigatorContentProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/modeling/diagram/navigator/ModelingDomainNavigatorItem.java
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/modeling/diagram/navigator/ModelingDomainNavigatorItem.java?rev=945691&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/modeling/diagram/navigator/ModelingDomainNavigatorItem.java
(added)
+++ commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/modeling/diagram/navigator/ModelingDomainNavigatorItem.java
Tue May 18 15:13:13 2010
@@ -0,0 +1,118 @@
+package org.apache.commons.scxml.modeling.diagram.navigator;
+
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.PlatformObject;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.eclipse.ui.views.properties.IPropertySourceProvider;
+
+/**
+ * @generated
+ */
+public class ModelingDomainNavigatorItem extends PlatformObject {
+
+	/**
+	 * @generated
+	 */
+	static {
+		final Class[] supportedTypes = new Class[] { EObject.class,
+				IPropertySource.class };
+		Platform.getAdapterManager().registerAdapters(
+				new IAdapterFactory() {
+
+					public Object getAdapter(Object adaptableObject,
+							Class adapterType) {
+						if (adaptableObject instanceof org.apache.commons.scxml.modeling.diagram.navigator.ModelingDomainNavigatorItem)
{
+							org.apache.commons.scxml.modeling.diagram.navigator.ModelingDomainNavigatorItem domainNavigatorItem
= (org.apache.commons.scxml.modeling.diagram.navigator.ModelingDomainNavigatorItem) adaptableObject;
+							EObject eObject = domainNavigatorItem.getEObject();
+							if (adapterType == EObject.class) {
+								return eObject;
+							}
+							if (adapterType == IPropertySource.class) {
+								return domainNavigatorItem
+										.getPropertySourceProvider()
+										.getPropertySource(eObject);
+							}
+						}
+
+						return null;
+					}
+
+					public Class[] getAdapterList() {
+						return supportedTypes;
+					}
+				},
+				org.apache.commons.scxml.modeling.diagram.navigator.ModelingDomainNavigatorItem.class);
+	}
+
+	/**
+	 * @generated
+	 */
+	private Object myParent;
+
+	/**
+	 * @generated
+	 */
+	private EObject myEObject;
+
+	/**
+	 * @generated
+	 */
+	private IPropertySourceProvider myPropertySourceProvider;
+
+	/**
+	 * @generated
+	 */
+	public ModelingDomainNavigatorItem(EObject eObject, Object parent,
+			IPropertySourceProvider propertySourceProvider) {
+		myParent = parent;
+		myEObject = eObject;
+		myPropertySourceProvider = propertySourceProvider;
+	}
+
+	/**
+	 * @generated
+	 */
+	public Object getParent() {
+		return myParent;
+	}
+
+	/**
+	 * @generated
+	 */
+	public EObject getEObject() {
+		return myEObject;
+	}
+
+	/**
+	 * @generated
+	 */
+	public IPropertySourceProvider getPropertySourceProvider() {
+		return myPropertySourceProvider;
+	}
+
+	/**
+	 * @generated
+	 */
+	public boolean equals(Object obj) {
+		if (obj instanceof org.apache.commons.scxml.modeling.diagram.navigator.ModelingDomainNavigatorItem)
{
+			return EcoreUtil
+					.getURI(getEObject())
+					.equals(
+							EcoreUtil
+									.getURI(((org.apache.commons.scxml.modeling.diagram.navigator.ModelingDomainNavigatorItem)
obj)
+											.getEObject()));
+		}
+		return super.equals(obj);
+	}
+
+	/**
+	 * @generated
+	 */
+	public int hashCode() {
+		return EcoreUtil.getURI(getEObject()).hashCode();
+	}
+
+}

Propchange: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/modeling/diagram/navigator/ModelingDomainNavigatorItem.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/modeling/diagram/navigator/ModelingDomainNavigatorLabelProvider.java
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/modeling/diagram/navigator/ModelingDomainNavigatorLabelProvider.java?rev=945691&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/modeling/diagram/navigator/ModelingDomainNavigatorLabelProvider.java
(added)
+++ commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/modeling/diagram/navigator/ModelingDomainNavigatorLabelProvider.java
Tue May 18 15:13:13 2010
@@ -0,0 +1,101 @@
+package org.apache.commons.scxml.modeling.diagram.navigator;
+
+import org.apache.commons.scxml.modeling.diagram.part.ModelingDiagramEditorPlugin;
+import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.navigator.ICommonContentExtensionSite;
+import org.eclipse.ui.navigator.ICommonLabelProvider;
+
+/**
+ * @generated
+ */
+public class ModelingDomainNavigatorLabelProvider implements
+		ICommonLabelProvider {
+
+	/**
+	 * @generated
+	 */
+	private AdapterFactoryLabelProvider myAdapterFactoryLabelProvider = new AdapterFactoryLabelProvider(
+			ModelingDiagramEditorPlugin.getInstance()
+					.getItemProvidersAdapterFactory());
+
+	/**
+	 * @generated
+	 */
+	public void init(ICommonContentExtensionSite aConfig) {
+	}
+
+	/**
+	 * @generated
+	 */
+	public Image getImage(Object element) {
+		if (element instanceof ModelingDomainNavigatorItem) {
+			return myAdapterFactoryLabelProvider
+					.getImage(((ModelingDomainNavigatorItem) element)
+							.getEObject());
+		}
+		return null;
+	}
+
+	/**
+	 * @generated
+	 */
+	public String getText(Object element) {
+		if (element instanceof ModelingDomainNavigatorItem) {
+			return myAdapterFactoryLabelProvider
+					.getText(((ModelingDomainNavigatorItem) element)
+							.getEObject());
+		}
+		return null;
+	}
+
+	/**
+	 * @generated
+	 */
+	public void addListener(ILabelProviderListener listener) {
+		myAdapterFactoryLabelProvider.addListener(listener);
+	}
+
+	/**
+	 * @generated
+	 */
+	public void dispose() {
+		myAdapterFactoryLabelProvider.dispose();
+	}
+
+	/**
+	 * @generated
+	 */
+	public boolean isLabelProperty(Object element, String property) {
+		return myAdapterFactoryLabelProvider.isLabelProperty(element, property);
+	}
+
+	/**
+	 * @generated
+	 */
+	public void removeListener(ILabelProviderListener listener) {
+		myAdapterFactoryLabelProvider.removeListener(listener);
+	}
+
+	/**
+	 * @generated
+	 */
+	public void restoreState(IMemento aMemento) {
+	}
+
+	/**
+	 * @generated
+	 */
+	public void saveState(IMemento aMemento) {
+	}
+
+	/**
+	 * @generated
+	 */
+	public String getDescription(Object anElement) {
+		return null;
+	}
+
+}

Propchange: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/modeling/diagram/navigator/ModelingDomainNavigatorLabelProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/modeling/diagram/navigator/ModelingNavigatorActionProvider.java
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/modeling/diagram/navigator/ModelingNavigatorActionProvider.java?rev=945691&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/modeling/diagram/navigator/ModelingNavigatorActionProvider.java
(added)
+++ commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/modeling/diagram/navigator/ModelingNavigatorActionProvider.java
Tue May 18 15:13:13 2010
@@ -0,0 +1,179 @@
+package org.apache.commons.scxml.modeling.diagram.navigator;
+
+import java.util.Iterator;
+
+import org.apache.commons.scxml.modeling.diagram.edit.parts.ServiceTemplateEditPart;
+import org.apache.commons.scxml.modeling.diagram.part.Messages;
+import org.apache.commons.scxml.modeling.diagram.part.ModelingDiagramEditor;
+import org.apache.commons.scxml.modeling.diagram.part.ModelingDiagramEditorPlugin;
+import org.apache.commons.scxml.modeling.diagram.part.ModelingVisualIDRegistry;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.common.ui.URIEditorInput;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.workspace.util.WorkspaceSynchronizer;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.navigator.CommonActionProvider;
+import org.eclipse.ui.navigator.ICommonActionConstants;
+import org.eclipse.ui.navigator.ICommonActionExtensionSite;
+import org.eclipse.ui.navigator.ICommonViewerWorkbenchSite;
+import org.eclipse.ui.part.FileEditorInput;
+
+/**
+ * @generated
+ */
+public class ModelingNavigatorActionProvider extends CommonActionProvider {
+
+	/**
+	 * @generated
+	 */
+	private boolean myContribute;
+
+	/**
+	 * @generated
+	 */
+	private OpenDiagramAction myOpenDiagramAction;
+
+	/**
+	 * @generated
+	 */
+	public void init(ICommonActionExtensionSite aSite) {
+		super.init(aSite);
+		if (aSite.getViewSite() instanceof ICommonViewerWorkbenchSite) {
+			myContribute = true;
+			makeActions((ICommonViewerWorkbenchSite) aSite.getViewSite());
+		} else {
+			myContribute = false;
+		}
+	}
+
+	/**
+	 * @generated
+	 */
+	private void makeActions(ICommonViewerWorkbenchSite viewerSite) {
+		myOpenDiagramAction = new OpenDiagramAction(viewerSite);
+	}
+
+	/**
+	 * @generated
+	 */
+	public void fillActionBars(IActionBars actionBars) {
+		if (!myContribute) {
+			return;
+		}
+		IStructuredSelection selection = (IStructuredSelection) getContext()
+				.getSelection();
+		myOpenDiagramAction.selectionChanged(selection);
+		if (myOpenDiagramAction.isEnabled()) {
+			actionBars.setGlobalActionHandler(ICommonActionConstants.OPEN,
+					myOpenDiagramAction);
+		}
+	}
+
+	/**
+	 * @generated
+	 */
+	public void fillContextMenu(IMenuManager menu) {
+	}
+
+	/**
+	 * @generated
+	 */
+	private class OpenDiagramAction extends Action {
+
+		/**
+		 * @generated
+		 */
+		private Diagram myDiagram;
+
+		/**
+		 * @generated
+		 */
+		private ICommonViewerWorkbenchSite myViewerSite;
+
+		/**
+		 * @generated
+		 */
+		public OpenDiagramAction(ICommonViewerWorkbenchSite viewerSite) {
+			super(Messages.NavigatorActionProvider_OpenDiagramActionName);
+			myViewerSite = viewerSite;
+		}
+
+		/**
+		 * @generated
+		 */
+		public final void selectionChanged(IStructuredSelection selection) {
+			myDiagram = null;
+			if (selection.size() == 1) {
+				Object selectedElement = selection.getFirstElement();
+				if (selectedElement instanceof ModelingNavigatorItem) {
+					selectedElement = ((ModelingNavigatorItem) selectedElement)
+							.getView();
+				} else if (selectedElement instanceof IAdaptable) {
+					selectedElement = ((IAdaptable) selectedElement)
+							.getAdapter(View.class);
+				}
+				if (selectedElement instanceof Diagram) {
+					Diagram diagram = (Diagram) selectedElement;
+					if (ServiceTemplateEditPart.MODEL_ID
+							.equals(ModelingVisualIDRegistry
+									.getModelID(diagram))) {
+						myDiagram = diagram;
+					}
+				}
+			}
+			setEnabled(myDiagram != null);
+		}
+
+		/**
+		 * @generated
+		 */
+		public void run() {
+			if (myDiagram == null || myDiagram.eResource() == null) {
+				return;
+			}
+
+			IEditorInput editorInput = getEditorInput();
+			IWorkbenchPage page = myViewerSite.getPage();
+			try {
+				page.openEditor(editorInput, ModelingDiagramEditor.ID);
+			} catch (PartInitException e) {
+				ModelingDiagramEditorPlugin.getInstance().logError(
+						"Exception while openning diagram", e); //$NON-NLS-1$
+			}
+		}
+
+		/**
+		 * @generated
+		 */
+		private IEditorInput getEditorInput() {
+			for (Iterator it = myDiagram.eResource().getContents().iterator(); it
+					.hasNext();) {
+				EObject nextEObject = (EObject) it.next();
+				if (nextEObject == myDiagram) {
+					return new FileEditorInput(WorkspaceSynchronizer
+							.getFile(myDiagram.eResource()));
+				}
+				if (nextEObject instanceof Diagram) {
+					break;
+				}
+			}
+			URI uri = EcoreUtil.getURI(myDiagram);
+			String editorName = uri.lastSegment()
+					+ "#" + myDiagram.eResource().getContents().indexOf(myDiagram); //$NON-NLS-1$
+			IEditorInput editorInput = new URIEditorInput(uri, editorName);
+			return editorInput;
+		}
+
+	}
+
+}

Propchange: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/modeling/diagram/navigator/ModelingNavigatorActionProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message