diff options
Diffstat (limited to 'plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers')
11 files changed, 1066 insertions, 1066 deletions
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/AbstractShapeCompartmentEditPartProvider.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/AbstractShapeCompartmentEditPartProvider.java index d0ba42f17c9..59aff66b123 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/AbstractShapeCompartmentEditPartProvider.java +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/AbstractShapeCompartmentEditPartProvider.java @@ -1,85 +1,85 @@ -/*****************************************************************************
- * Copyright (c) 2012 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.gmfdiag.common.providers;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.gmf.runtime.common.core.service.IOperation;
-import org.eclipse.gmf.runtime.diagram.ui.services.editpart.AbstractEditPartProvider;
-import org.eclipse.gmf.runtime.diagram.ui.services.editpart.IEditPartOperation;
-import org.eclipse.gmf.runtime.notation.Edge;
-import org.eclipse.gmf.runtime.notation.Node;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IShapeCompartmentEditPart;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.ShapeDisplayCompartmentEditPart;
-
-/**
- * provides editpart to display shapes in compartment.
- */
-public abstract class AbstractShapeCompartmentEditPartProvider extends AbstractEditPartProvider {
-
- /** Map containing node view types supported by this provider */
- protected Map<String, Class<?>> nodeMap = new HashMap<String, Class<?>>();
-
- /** Map containing edge view types supported by this provider */
- protected Map<String, Class<?>> edgeMap = new HashMap<String, Class<?>>();
-
- /** Default constructor */
- public AbstractShapeCompartmentEditPartProvider() {
- super();
- nodeMap.put(IShapeCompartmentEditPart.VIEW_TYPE, ShapeDisplayCompartmentEditPart.class);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean provides(IOperation operation) {
- if (operation instanceof IEditPartOperation) {
- View newView = ((IEditPartOperation) operation).getView();
- if (newView == null) {
- return false;
- }
-
- String graphicalType = newView.getType();
-
- if ((newView instanceof Node) && (!nodeMap.containsKey(graphicalType))) {
- return false;
- }
-
- if ((newView instanceof Edge) && (!edgeMap.containsKey(graphicalType))) {
- return false;
- }
- }
-
- return super.provides(operation);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected Class<?> getNodeEditPartClass(View view) {
- return nodeMap.get(view.getType());
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected Class<?> getEdgeEditPartClass(View view) {
- return edgeMap.get(view.getType());
- }
-}
+/***************************************************************************** + * Copyright (c) 2012 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * CEA LIST - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.gmfdiag.common.providers; + +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.gmf.runtime.common.core.service.IOperation; +import org.eclipse.gmf.runtime.diagram.ui.services.editpart.AbstractEditPartProvider; +import org.eclipse.gmf.runtime.diagram.ui.services.editpart.IEditPartOperation; +import org.eclipse.gmf.runtime.notation.Edge; +import org.eclipse.gmf.runtime.notation.Node; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IShapeCompartmentEditPart; +import org.eclipse.papyrus.infra.gmfdiag.common.editpart.ShapeDisplayCompartmentEditPart; + +/** + * provides editpart to display shapes in compartment. + */ +public abstract class AbstractShapeCompartmentEditPartProvider extends AbstractEditPartProvider { + + /** Map containing node view types supported by this provider */ + protected Map<String, Class<?>> nodeMap = new HashMap<String, Class<?>>(); + + /** Map containing edge view types supported by this provider */ + protected Map<String, Class<?>> edgeMap = new HashMap<String, Class<?>>(); + + /** Default constructor */ + public AbstractShapeCompartmentEditPartProvider() { + super(); + nodeMap.put(IShapeCompartmentEditPart.VIEW_TYPE, ShapeDisplayCompartmentEditPart.class); + } + + /** + * {@inheritDoc} + */ + @Override + public boolean provides(IOperation operation) { + if (operation instanceof IEditPartOperation) { + View newView = ((IEditPartOperation) operation).getView(); + if (newView == null) { + return false; + } + + String graphicalType = newView.getType(); + + if ((newView instanceof Node) && (!nodeMap.containsKey(graphicalType))) { + return false; + } + + if ((newView instanceof Edge) && (!edgeMap.containsKey(graphicalType))) { + return false; + } + } + + return super.provides(operation); + } + + /** + * {@inheritDoc} + */ + @Override + protected Class<?> getNodeEditPartClass(View view) { + return nodeMap.get(view.getType()); + } + + /** + * {@inheritDoc} + */ + @Override + protected Class<?> getEdgeEditPartClass(View view) { + return edgeMap.get(view.getType()); + } +} diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/AbstractViewProvider.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/AbstractViewProvider.java index 2d7c5b48387..df7a8ac6517 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/AbstractViewProvider.java +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/AbstractViewProvider.java @@ -1,322 +1,322 @@ -/******************************************************************************
- * Copyright (c) 2002, 2010 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- * CEA LIST - createNode and createEdge final statement removed
- * in order to provide different implementation in subclasses.
- * The original class is {@link AbstractViewProvider}.
- *
- ****************************************************************************/
-package org.eclipse.papyrus.infra.gmfdiag.common.providers;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
-import java.util.HashMap;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.emf.transaction.util.TransactionUtil;
-import org.eclipse.gmf.runtime.common.core.service.AbstractProvider;
-import org.eclipse.gmf.runtime.common.core.service.IOperation;
-import org.eclipse.gmf.runtime.common.core.util.Log;
-import org.eclipse.gmf.runtime.diagram.core.internal.DiagramPlugin;
-import org.eclipse.gmf.runtime.diagram.core.internal.DiagramStatusCodes;
-import org.eclipse.gmf.runtime.diagram.core.internal.l10n.DiagramCoreMessages;
-import org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint;
-import org.eclipse.gmf.runtime.diagram.core.providers.IViewProvider;
-import org.eclipse.gmf.runtime.diagram.core.services.view.CreateDiagramViewOperation;
-import org.eclipse.gmf.runtime.diagram.core.services.view.CreateEdgeViewOperation;
-import org.eclipse.gmf.runtime.diagram.core.services.view.CreateNodeViewOperation;
-import org.eclipse.gmf.runtime.diagram.core.services.view.CreateViewForKindOperation;
-import org.eclipse.gmf.runtime.diagram.core.services.view.CreateViewOperation;
-import org.eclipse.gmf.runtime.emf.core.util.EMFCoreUtil;
-import org.eclipse.gmf.runtime.emf.type.core.IElementType;
-import org.eclipse.gmf.runtime.notation.Diagram;
-import org.eclipse.gmf.runtime.notation.Edge;
-import org.eclipse.gmf.runtime.notation.Node;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.osgi.util.NLS;
-
-/**
- * Implements of the <code>IViewProvider</code> interface. This
- * implementations invokes the appropriate factory method by inspecting the
- * supplied operation and provides the actual view creation functionality.
- */
-public class AbstractViewProvider extends AbstractProvider implements IViewProvider {
-
- private static String viewCreationMethodName = "createView"; //$NON-NLS-1$
-
- private static String diagramCreationMethodName = "createDiagram"; //$NON-NLS-1$
-
- static protected class ClassToCreationMethodMap extends HashMap<Class<?>, Method> {
-
- static final long serialVersionUID = 1;
-
- public void addMethod(Class<?> clazz, Method method) {
- if (get(clazz) == null) {
- put(clazz, method);
- }
- }
-
- public Method getCreationMethod(Class<?> clazz) {
- return get(clazz);
- }
- }
-
- public static final ClassToCreationMethodMap classToCreateMethod = new ClassToCreationMethodMap();
-
- /**
- * Determines whether this view provider can provide for the required
- * operation It inspects the type of view operation and calls the
- * corresponding <code>provides</code> method.
- *
- * @see org.eclipse.gmf.runtime.common.core.service.IProvider#provides(IOperation)
- */
- @Override
- public final boolean provides(IOperation operation) {
- /* if this is the CreateViewForKindOperation operation */
- if (operation instanceof CreateViewForKindOperation) {
- return provides((CreateViewForKindOperation) operation);
- }
- /* Make sure it is a view operation */
- assert operation instanceof CreateViewOperation : "operation is not CreateViewOperation in AbstractViewProvider";//$NON-NLS-1$
- /* call the specific provides method */
- if (operation instanceof CreateDiagramViewOperation) {
- return provides((CreateDiagramViewOperation) operation);
- } else if (operation instanceof CreateEdgeViewOperation) {
- return provides((CreateEdgeViewOperation) operation);
- } else if (operation instanceof CreateNodeViewOperation) {
- return provides((CreateNodeViewOperation) operation);
- }
- return false;
- }
-
- @Override
- public final Diagram createDiagram(IAdaptable contextElement, String diagramKind, PreferencesHint preferencesHint) {
- return (Diagram) createNewView(getDiagramViewClass(contextElement, diagramKind), new Object[] { contextElement, diagramKind, preferencesHint });
- }
-
- // Papyrus - final statement removed
- @Override
- public Edge createEdge(IAdaptable semanticAdapter, View containerView, String semanticHint, int index, boolean persisted, PreferencesHint preferencesHint) {
- return (Edge) createNewView(getEdgeViewClass(semanticAdapter, containerView, semanticHint), new Object[] { semanticAdapter, containerView, semanticHint, new Integer(index), Boolean.valueOf(persisted), preferencesHint });
- }
-
- // Papyrus - final statement removed
- @Override
- public Node createNode(IAdaptable semanticAdapter, View containerView, String semanticHint, int index, boolean persisted, PreferencesHint preferencesHint) {
- return (Node) createNewView(getNodeViewClass(semanticAdapter, containerView, semanticHint), new Object[] { semanticAdapter, containerView, semanticHint, new Integer(index), Boolean.valueOf(persisted), preferencesHint });
- }
-
- /**
- * Determines whether this provider can provide for the specified view
- * creation operation
- *
- * @param operation
- * Contains a semantic kind and a containerView
- * @return boolean
- */
- protected boolean provides(CreateViewForKindOperation op) {
- if (op.getViewKind() == Node.class) {
- return getNodeViewClass(op.getSemanticAdapter(), op.getContainerView(), op.getSemanticHint()) != null;
- }
- if (op.getViewKind() == Edge.class) {
- return getEdgeViewClass(op.getSemanticAdapter(), op.getContainerView(), op.getSemanticHint()) != null;
- }
- return true;
- }
-
- /**
- * Determines whether this provider can provide for the specified diagram
- * view operation
- *
- * @param operation
- * @return boolean
- */
- protected boolean provides(CreateDiagramViewOperation operation) {
- return getDiagramViewClass(operation.getSemanticAdapter(), operation.getSemanticHint()) != null;
- }
-
- /**
- * Determines whether this provider can provide for the specified edge view
- * operation
- *
- * @param operation
- * @return boolean
- */
- protected boolean provides(CreateEdgeViewOperation operation) {
- return (getEdgeViewClass(operation.getSemanticAdapter(), operation.getContainerView(), operation.getSemanticHint()) != null);
- }
-
- /**
- * Determines whether this provider can provide for the specified node view
- * operation
- *
- * @param operation
- * @return boolean
- */
- protected boolean provides(CreateNodeViewOperation operation) {
- return (getNodeViewClass(operation.getSemanticAdapter(), operation.getContainerView(), operation.getSemanticHint()) != null);
- }
-
- /**
- * Returns the diagram view class to instantiate based on the passed params
- *
- * @param semanticAdapter
- * TODO
- * @param semanticAdapter
- * @return Class
- */
- protected Class<?> getDiagramViewClass(IAdaptable semanticAdapter, String diagramKind) {
- return null;
- }
-
- /**
- * Returns the edge view class to instantiate based on the passed params
- *
- * @param semanticAdapter
- * @param containerView
- * @param semanticHint
- * @return Class
- */
- protected Class<?> getEdgeViewClass(IAdaptable semanticAdapter, View containerView, String semanticHint) {
- return null;
- }
-
- /**
- * Returns the node view class to instantiate based on the passed params
- *
- * @param semanticAdapter
- * @param containerView
- * @param semanticHint
- * @return Class
- */
- protected Class<?> getNodeViewClass(IAdaptable semanticAdapter, View containerView, String semanticHint) {
- return null;
- }
-
- /**
- * creates a view instance via reflection.
- *
- * @param constructorParams
- * the view's constructor parameters.
- */
- private View createNewView(Class<?> viewClass, Object[] constructorParams) {
- try {
- assert null != viewClass : "Null viewClass in AbstractProvider";//$NON-NLS-1$
- assert null != constructorParams : "Null constructorParams in AbstractProvider";//$NON-NLS-1$
- Constructor<?> constructor = getFactoryConstructor(viewClass);
- if (constructor == null) {
- Log.error(DiagramPlugin.getInstance(), DiagramStatusCodes.SERVICE_FAILURE, "View (" + viewClass + ") is missing a proper creation Factory"); //$NON-NLS-1$//$NON-NLS-2$
- return null;
- }
- Object factory = constructor.newInstance(new Object[] {});
- Method method = getCreationMethod(viewClass, constructorParams);
- if (method == null) {
- Log.error(DiagramPlugin.getInstance(), DiagramStatusCodes.SERVICE_FAILURE, "View (" + viewClass + ") is missing a proper creation Factory"); //$NON-NLS-1$//$NON-NLS-2$
- return null;
- }
- return (View) method.invoke(factory, constructorParams);
- } catch (Throwable e) {
- String eMsg = NLS.bind(DiagramCoreMessages.AbstractViewProvider_create_view_failed_ERROR_, viewClass.getName());
- Log.warning(DiagramPlugin.getInstance(), IStatus.WARNING, eMsg, e);
- return null;
- }
- }
-
- private Constructor<?> getFactoryConstructor(Class<?> viewClass) {
- if (viewClass != null) {
- Constructor<?>[] ctors = viewClass.getConstructors();
- for (int i = 0; i < ctors.length; i++) {
- if (ctors[i].getParameterTypes().length == 0) {
- return ctors[i];
- }
- }
- }
- return null;
- }
-
- /** Return the <i>creation</i> constructor for the cached view class. */
- private Method getCreationMethod(Class<?> viewClass, Object[] params) {
- if (viewClass != null) {
- Method method = classToCreateMethod.getCreationMethod(viewClass);
- if (method != null) {
- return method;
- }
- Method[] methods = viewClass.getMethods();
- for (int i = 0; i < methods.length; i++) {
- method = methods[i];
- String methodName = method.getName();
- if (methodName.equals(viewCreationMethodName) || methodName.equals(diagramCreationMethodName)) {
- classToCreateMethod.addMethod(viewClass, method);
- return method;
- }
- }
- }
- return null;
- }
-
- /**
- * Returns the EClass associated with the semantic adapter
- *
- * @param semanticAdapter
- * @return EClass
- */
- protected EClass getSemanticEClass(IAdaptable semanticAdapter) {
- if (semanticAdapter == null) {
- return null;
- }
- EObject eObject = semanticAdapter.getAdapter(EObject.class);
- if (eObject != null) {
- return EMFCoreUtil.getProxyClass(eObject);
- }
- IElementType type = semanticAdapter.getAdapter(IElementType.class);
- if (type != null) {
- return type.getEClass();
- }
- return null;
- }
-
- /**
- * Returns the semantic element associated with the semantic adapter
- *
- * @param semanticAdapter
- * @return EClass
- */
- protected EObject getSemanticElement(IAdaptable semanticAdapter) {
- if (semanticAdapter == null) {
- return null;
- }
- EObject eObject = semanticAdapter.getAdapter(EObject.class);
- if (eObject != null) {
- return EMFCoreUtil.resolve(TransactionUtil.getEditingDomain(eObject), eObject);
- }
- return null;
- }
-
- /**
- * Returns the semantic element associated with the semantic adapter
- *
- * @param semanticAdapter
- * @return EClass
- */
- protected EObject getSemanticElement(IAdaptable semanticAdapter, TransactionalEditingDomain domain) {
- if (semanticAdapter == null) {
- return null;
- }
- EObject eObject = semanticAdapter.getAdapter(EObject.class);
- if (eObject != null) {
- return EMFCoreUtil.resolve(domain, eObject);
- }
- return null;
- }
-}
+/****************************************************************************** + * Copyright (c) 2002, 2010 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * + * CEA LIST - createNode and createEdge final statement removed + * in order to provide different implementation in subclasses. + * The original class is {@link AbstractViewProvider}. + * + ****************************************************************************/ +package org.eclipse.papyrus.infra.gmfdiag.common.providers; + +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; +import java.util.HashMap; + +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.emf.transaction.util.TransactionUtil; +import org.eclipse.gmf.runtime.common.core.service.AbstractProvider; +import org.eclipse.gmf.runtime.common.core.service.IOperation; +import org.eclipse.gmf.runtime.common.core.util.Log; +import org.eclipse.gmf.runtime.diagram.core.internal.DiagramPlugin; +import org.eclipse.gmf.runtime.diagram.core.internal.DiagramStatusCodes; +import org.eclipse.gmf.runtime.diagram.core.internal.l10n.DiagramCoreMessages; +import org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint; +import org.eclipse.gmf.runtime.diagram.core.providers.IViewProvider; +import org.eclipse.gmf.runtime.diagram.core.services.view.CreateDiagramViewOperation; +import org.eclipse.gmf.runtime.diagram.core.services.view.CreateEdgeViewOperation; +import org.eclipse.gmf.runtime.diagram.core.services.view.CreateNodeViewOperation; +import org.eclipse.gmf.runtime.diagram.core.services.view.CreateViewForKindOperation; +import org.eclipse.gmf.runtime.diagram.core.services.view.CreateViewOperation; +import org.eclipse.gmf.runtime.emf.core.util.EMFCoreUtil; +import org.eclipse.gmf.runtime.emf.type.core.IElementType; +import org.eclipse.gmf.runtime.notation.Diagram; +import org.eclipse.gmf.runtime.notation.Edge; +import org.eclipse.gmf.runtime.notation.Node; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.osgi.util.NLS; + +/** + * Implements of the <code>IViewProvider</code> interface. This + * implementations invokes the appropriate factory method by inspecting the + * supplied operation and provides the actual view creation functionality. + */ +public class AbstractViewProvider extends AbstractProvider implements IViewProvider { + + private static String viewCreationMethodName = "createView"; //$NON-NLS-1$ + + private static String diagramCreationMethodName = "createDiagram"; //$NON-NLS-1$ + + static protected class ClassToCreationMethodMap extends HashMap<Class<?>, Method> { + + static final long serialVersionUID = 1; + + public void addMethod(Class<?> clazz, Method method) { + if (get(clazz) == null) { + put(clazz, method); + } + } + + public Method getCreationMethod(Class<?> clazz) { + return get(clazz); + } + } + + public static final ClassToCreationMethodMap classToCreateMethod = new ClassToCreationMethodMap(); + + /** + * Determines whether this view provider can provide for the required + * operation It inspects the type of view operation and calls the + * corresponding <code>provides</code> method. + * + * @see org.eclipse.gmf.runtime.common.core.service.IProvider#provides(IOperation) + */ + @Override + public final boolean provides(IOperation operation) { + /* if this is the CreateViewForKindOperation operation */ + if (operation instanceof CreateViewForKindOperation) { + return provides((CreateViewForKindOperation) operation); + } + /* Make sure it is a view operation */ + assert operation instanceof CreateViewOperation : "operation is not CreateViewOperation in AbstractViewProvider";//$NON-NLS-1$ + /* call the specific provides method */ + if (operation instanceof CreateDiagramViewOperation) { + return provides((CreateDiagramViewOperation) operation); + } else if (operation instanceof CreateEdgeViewOperation) { + return provides((CreateEdgeViewOperation) operation); + } else if (operation instanceof CreateNodeViewOperation) { + return provides((CreateNodeViewOperation) operation); + } + return false; + } + + @Override + public final Diagram createDiagram(IAdaptable contextElement, String diagramKind, PreferencesHint preferencesHint) { + return (Diagram) createNewView(getDiagramViewClass(contextElement, diagramKind), new Object[] { contextElement, diagramKind, preferencesHint }); + } + + // Papyrus - final statement removed + @Override + public Edge createEdge(IAdaptable semanticAdapter, View containerView, String semanticHint, int index, boolean persisted, PreferencesHint preferencesHint) { + return (Edge) createNewView(getEdgeViewClass(semanticAdapter, containerView, semanticHint), new Object[] { semanticAdapter, containerView, semanticHint, new Integer(index), Boolean.valueOf(persisted), preferencesHint }); + } + + // Papyrus - final statement removed + @Override + public Node createNode(IAdaptable semanticAdapter, View containerView, String semanticHint, int index, boolean persisted, PreferencesHint preferencesHint) { + return (Node) createNewView(getNodeViewClass(semanticAdapter, containerView, semanticHint), new Object[] { semanticAdapter, containerView, semanticHint, new Integer(index), Boolean.valueOf(persisted), preferencesHint }); + } + + /** + * Determines whether this provider can provide for the specified view + * creation operation + * + * @param operation + * Contains a semantic kind and a containerView + * @return boolean + */ + protected boolean provides(CreateViewForKindOperation op) { + if (op.getViewKind() == Node.class) { + return getNodeViewClass(op.getSemanticAdapter(), op.getContainerView(), op.getSemanticHint()) != null; + } + if (op.getViewKind() == Edge.class) { + return getEdgeViewClass(op.getSemanticAdapter(), op.getContainerView(), op.getSemanticHint()) != null; + } + return true; + } + + /** + * Determines whether this provider can provide for the specified diagram + * view operation + * + * @param operation + * @return boolean + */ + protected boolean provides(CreateDiagramViewOperation operation) { + return getDiagramViewClass(operation.getSemanticAdapter(), operation.getSemanticHint()) != null; + } + + /** + * Determines whether this provider can provide for the specified edge view + * operation + * + * @param operation + * @return boolean + */ + protected boolean provides(CreateEdgeViewOperation operation) { + return (getEdgeViewClass(operation.getSemanticAdapter(), operation.getContainerView(), operation.getSemanticHint()) != null); + } + + /** + * Determines whether this provider can provide for the specified node view + * operation + * + * @param operation + * @return boolean + */ + protected boolean provides(CreateNodeViewOperation operation) { + return (getNodeViewClass(operation.getSemanticAdapter(), operation.getContainerView(), operation.getSemanticHint()) != null); + } + + /** + * Returns the diagram view class to instantiate based on the passed params + * + * @param semanticAdapter + * TODO + * @param semanticAdapter + * @return Class + */ + protected Class<?> getDiagramViewClass(IAdaptable semanticAdapter, String diagramKind) { + return null; + } + + /** + * Returns the edge view class to instantiate based on the passed params + * + * @param semanticAdapter + * @param containerView + * @param semanticHint + * @return Class + */ + protected Class<?> getEdgeViewClass(IAdaptable semanticAdapter, View containerView, String semanticHint) { + return null; + } + + /** + * Returns the node view class to instantiate based on the passed params + * + * @param semanticAdapter + * @param containerView + * @param semanticHint + * @return Class + */ + protected Class<?> getNodeViewClass(IAdaptable semanticAdapter, View containerView, String semanticHint) { + return null; + } + + /** + * creates a view instance via reflection. + * + * @param constructorParams + * the view's constructor parameters. + */ + private View createNewView(Class<?> viewClass, Object[] constructorParams) { + try { + assert null != viewClass : "Null viewClass in AbstractProvider";//$NON-NLS-1$ + assert null != constructorParams : "Null constructorParams in AbstractProvider";//$NON-NLS-1$ + Constructor<?> constructor = getFactoryConstructor(viewClass); + if (constructor == null) { + Log.error(DiagramPlugin.getInstance(), DiagramStatusCodes.SERVICE_FAILURE, "View (" + viewClass + ") is missing a proper creation Factory"); //$NON-NLS-1$//$NON-NLS-2$ + return null; + } + Object factory = constructor.newInstance(new Object[] {}); + Method method = getCreationMethod(viewClass, constructorParams); + if (method == null) { + Log.error(DiagramPlugin.getInstance(), DiagramStatusCodes.SERVICE_FAILURE, "View (" + viewClass + ") is missing a proper creation Factory"); //$NON-NLS-1$//$NON-NLS-2$ + return null; + } + return (View) method.invoke(factory, constructorParams); + } catch (Throwable e) { + String eMsg = NLS.bind(DiagramCoreMessages.AbstractViewProvider_create_view_failed_ERROR_, viewClass.getName()); + Log.warning(DiagramPlugin.getInstance(), IStatus.WARNING, eMsg, e); + return null; + } + } + + private Constructor<?> getFactoryConstructor(Class<?> viewClass) { + if (viewClass != null) { + Constructor<?>[] ctors = viewClass.getConstructors(); + for (int i = 0; i < ctors.length; i++) { + if (ctors[i].getParameterTypes().length == 0) { + return ctors[i]; + } + } + } + return null; + } + + /** Return the <i>creation</i> constructor for the cached view class. */ + private Method getCreationMethod(Class<?> viewClass, Object[] params) { + if (viewClass != null) { + Method method = classToCreateMethod.getCreationMethod(viewClass); + if (method != null) { + return method; + } + Method[] methods = viewClass.getMethods(); + for (int i = 0; i < methods.length; i++) { + method = methods[i]; + String methodName = method.getName(); + if (methodName.equals(viewCreationMethodName) || methodName.equals(diagramCreationMethodName)) { + classToCreateMethod.addMethod(viewClass, method); + return method; + } + } + } + return null; + } + + /** + * Returns the EClass associated with the semantic adapter + * + * @param semanticAdapter + * @return EClass + */ + protected EClass getSemanticEClass(IAdaptable semanticAdapter) { + if (semanticAdapter == null) { + return null; + } + EObject eObject = semanticAdapter.getAdapter(EObject.class); + if (eObject != null) { + return EMFCoreUtil.getProxyClass(eObject); + } + IElementType type = semanticAdapter.getAdapter(IElementType.class); + if (type != null) { + return type.getEClass(); + } + return null; + } + + /** + * Returns the semantic element associated with the semantic adapter + * + * @param semanticAdapter + * @return EClass + */ + protected EObject getSemanticElement(IAdaptable semanticAdapter) { + if (semanticAdapter == null) { + return null; + } + EObject eObject = semanticAdapter.getAdapter(EObject.class); + if (eObject != null) { + return EMFCoreUtil.resolve(TransactionUtil.getEditingDomain(eObject), eObject); + } + return null; + } + + /** + * Returns the semantic element associated with the semantic adapter + * + * @param semanticAdapter + * @return EClass + */ + protected EObject getSemanticElement(IAdaptable semanticAdapter, TransactionalEditingDomain domain) { + if (semanticAdapter == null) { + return null; + } + EObject eObject = semanticAdapter.getAdapter(EObject.class); + if (eObject != null) { + return EMFCoreUtil.resolve(domain, eObject); + } + return null; + } +} diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/CustomEditPolicyProvider.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/CustomEditPolicyProvider.java index c9a3f7e8d5e..d3d717f2201 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/CustomEditPolicyProvider.java +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/CustomEditPolicyProvider.java @@ -1,101 +1,101 @@ -/*****************************************************************************
- * Copyright (c) 2015 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Francois Le Fevre (CEA LIST) francois.le-fevre@cea.fr - Initial API and implementation
- *****************************************************************************/
-package org.eclipse.papyrus.infra.gmfdiag.common.providers;
-
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gmf.runtime.common.core.service.IOperation;
-import org.eclipse.gmf.runtime.common.core.service.IProviderChangeListener;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.CreateEditPoliciesOperation;
-import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.IEditPolicyProvider;
-import org.eclipse.papyrus.infra.core.services.ServiceException;
-import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
-import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.HighlightEditPolicy;
-import org.eclipse.papyrus.infra.gmfdiag.common.utils.ServiceUtilsForEditPart;
-
-/**
- * this is an editpolicy provider in charge to install a policy to navigate between diagrams and elements
- *
- */
-public class CustomEditPolicyProvider implements IEditPolicyProvider {
-
- /**
- *
- * {@inheritDoc}
- */
- @Override
- public void addProviderChangeListener(IProviderChangeListener listener) {
- }
-
- /**
- *
- * {@inheritDoc}
- */
- @Override
- public void createEditPolicies(final EditPart editPart) {
- installEditPolicy(editPart, new HighlightEditPolicy(), HighlightEditPolicy.HIGHLIGHT_ROLE);
- }
-
- /**
- * Safely install a EditPolicy, if the editpolicy with given role is existed in editpart, ignore it.
- *
- * @param editPart
- * @param editPolicy
- * @param role
- */
- private void installEditPolicy(EditPart editPart, EditPolicy editPolicy, String role) {
- if (editPart == null || editPolicy == null) {
- return;
- }
- EditPolicy myEditPolicy = editPart.getEditPolicy(role);
- if (myEditPolicy == null) {
- editPart.installEditPolicy(role, editPolicy);
- }
- }
-
- /**
- *
- * {@inheritDoc}
- */
- @Override
- public boolean provides(IOperation operation) {
- CreateEditPoliciesOperation epOperation = (CreateEditPoliciesOperation) operation;
- try {
- EditPart editPart = epOperation.getEditPart();
- if (!(editPart instanceof GraphicalEditPart)) {
- return false;
- }
-
- EditingDomain domain = EMFHelper.resolveEditingDomain(editPart);
- if (domain == null) {
- return false;
- }
-
- ServicesRegistry registry = ServiceUtilsForEditPart.getInstance().getServiceRegistry(epOperation.getEditPart());
- return registry != null;
- } catch (ServiceException e) {
- return false;
- }
-
- }
-
- /**
- *
- * {@inheritDoc}
- */
- @Override
- public void removeProviderChangeListener(IProviderChangeListener listener) {
- }
-}
+/***************************************************************************** + * Copyright (c) 2015 CEA LIST. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Francois Le Fevre (CEA LIST) francois.le-fevre@cea.fr - Initial API and implementation + *****************************************************************************/ +package org.eclipse.papyrus.infra.gmfdiag.common.providers; + +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.gef.EditPart; +import org.eclipse.gef.EditPolicy; +import org.eclipse.gmf.runtime.common.core.service.IOperation; +import org.eclipse.gmf.runtime.common.core.service.IProviderChangeListener; +import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart; +import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.CreateEditPoliciesOperation; +import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.IEditPolicyProvider; +import org.eclipse.papyrus.infra.core.services.ServiceException; +import org.eclipse.papyrus.infra.core.services.ServicesRegistry; +import org.eclipse.papyrus.infra.emf.utils.EMFHelper; +import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.HighlightEditPolicy; +import org.eclipse.papyrus.infra.gmfdiag.common.utils.ServiceUtilsForEditPart; + +/** + * this is an editpolicy provider in charge to install a policy to navigate between diagrams and elements + * + */ +public class CustomEditPolicyProvider implements IEditPolicyProvider { + + /** + * + * {@inheritDoc} + */ + @Override + public void addProviderChangeListener(IProviderChangeListener listener) { + } + + /** + * + * {@inheritDoc} + */ + @Override + public void createEditPolicies(final EditPart editPart) { + installEditPolicy(editPart, new HighlightEditPolicy(), HighlightEditPolicy.HIGHLIGHT_ROLE); + } + + /** + * Safely install a EditPolicy, if the editpolicy with given role is existed in editpart, ignore it. + * + * @param editPart + * @param editPolicy + * @param role + */ + private void installEditPolicy(EditPart editPart, EditPolicy editPolicy, String role) { + if (editPart == null || editPolicy == null) { + return; + } + EditPolicy myEditPolicy = editPart.getEditPolicy(role); + if (myEditPolicy == null) { + editPart.installEditPolicy(role, editPolicy); + } + } + + /** + * + * {@inheritDoc} + */ + @Override + public boolean provides(IOperation operation) { + CreateEditPoliciesOperation epOperation = (CreateEditPoliciesOperation) operation; + try { + EditPart editPart = epOperation.getEditPart(); + if (!(editPart instanceof GraphicalEditPart)) { + return false; + } + + EditingDomain domain = EMFHelper.resolveEditingDomain(editPart); + if (domain == null) { + return false; + } + + ServicesRegistry registry = ServiceUtilsForEditPart.getInstance().getServiceRegistry(epOperation.getEditPart()); + return registry != null; + } catch (ServiceException e) { + return false; + } + + } + + /** + * + * {@inheritDoc} + */ + @Override + public void removeProviderChangeListener(IProviderChangeListener listener) { + } +} diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/ExternalReferenceEditPolicyProvider.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/ExternalReferenceEditPolicyProvider.java index 6c7f760ce35..39dd468c4b0 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/ExternalReferenceEditPolicyProvider.java +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/ExternalReferenceEditPolicyProvider.java @@ -1,55 +1,55 @@ -/*****************************************************************************
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
- *****************************************************************************/
-package org.eclipse.papyrus.infra.gmfdiag.common.providers;
-
-import org.eclipse.gef.EditPart;
-import org.eclipse.gmf.runtime.common.core.service.AbstractProvider;
-import org.eclipse.gmf.runtime.common.core.service.IOperation;
-import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.CreateEditPoliciesOperation;
-import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.IEditPolicyProvider;
-import org.eclipse.gmf.runtime.notation.Node;
-import org.eclipse.papyrus.infra.core.services.ServiceException;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.ExternalReferenceEditPolicy;
-import org.eclipse.papyrus.infra.gmfdiag.common.utils.ServiceUtilsForEditPart;
-
-/**
- * The EditPolicyProvider for {@link ExternalReferenceEditPolicy} It provides an {@link ExternalReferenceEditPolicy} for Papyrus edit parts, when the
- * ServicesRegistry is available
- * This edit policy in only installed on Shapes (Graphical Edges are typically owned by the Diagram, which makes it difficult
- * to determine whether they are imported or not)
- *
- * @author Camille Letavernier
- */
-public class ExternalReferenceEditPolicyProvider extends AbstractProvider implements IEditPolicyProvider {
-
- @Override
- public boolean provides(IOperation operation) {
- if (operation instanceof CreateEditPoliciesOperation) {
- CreateEditPoliciesOperation createOperation = (CreateEditPoliciesOperation) operation;
- try {
- if (ServiceUtilsForEditPart.getInstance().getServiceRegistry(createOperation.getEditPart()) != null) {
- return createOperation.getEditPart().getModel() instanceof Node;
- }
- } catch (ServiceException ex) {
- // Do nothing: the services registry is not available.
- }
- }
-
- return false;
- }
-
- @Override
- public void createEditPolicies(EditPart editPart) {
- editPart.installEditPolicy(ExternalReferenceEditPolicy.EDIT_POLICY_ROLE, new ExternalReferenceEditPolicy());
- }
-
-}
+/***************************************************************************** + * Copyright (c) 2014 CEA LIST. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation + *****************************************************************************/ +package org.eclipse.papyrus.infra.gmfdiag.common.providers; + +import org.eclipse.gef.EditPart; +import org.eclipse.gmf.runtime.common.core.service.AbstractProvider; +import org.eclipse.gmf.runtime.common.core.service.IOperation; +import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.CreateEditPoliciesOperation; +import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.IEditPolicyProvider; +import org.eclipse.gmf.runtime.notation.Node; +import org.eclipse.papyrus.infra.core.services.ServiceException; +import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.ExternalReferenceEditPolicy; +import org.eclipse.papyrus.infra.gmfdiag.common.utils.ServiceUtilsForEditPart; + +/** + * The EditPolicyProvider for {@link ExternalReferenceEditPolicy} It provides an {@link ExternalReferenceEditPolicy} for Papyrus edit parts, when the + * ServicesRegistry is available + * This edit policy in only installed on Shapes (Graphical Edges are typically owned by the Diagram, which makes it difficult + * to determine whether they are imported or not) + * + * @author Camille Letavernier + */ +public class ExternalReferenceEditPolicyProvider extends AbstractProvider implements IEditPolicyProvider { + + @Override + public boolean provides(IOperation operation) { + if (operation instanceof CreateEditPoliciesOperation) { + CreateEditPoliciesOperation createOperation = (CreateEditPoliciesOperation) operation; + try { + if (ServiceUtilsForEditPart.getInstance().getServiceRegistry(createOperation.getEditPart()) != null) { + return createOperation.getEditPart().getModel() instanceof Node; + } + } catch (ServiceException ex) { + // Do nothing: the services registry is not available. + } + } + + return false; + } + + @Override + public void createEditPolicies(EditPart editPart) { + editPart.installEditPolicy(ExternalReferenceEditPolicy.EDIT_POLICY_ROLE, new ExternalReferenceEditPolicy()); + } + +} diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/IThemeInitializer.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/IThemeInitializer.java index b5f2d409e4c..6614ea2f560 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/IThemeInitializer.java +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/IThemeInitializer.java @@ -1,20 +1,20 @@ -/*****************************************************************************
- * Copyright (c) 2012 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
- *****************************************************************************/
-package org.eclipse.papyrus.infra.gmfdiag.common.providers;
-
-import org.eclipse.gmf.runtime.notation.View;
-
-
-public interface IThemeInitializer {
-
- public boolean usePreferenceInitializer(View view);
-}
+/***************************************************************************** + * Copyright (c) 2012 CEA LIST. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation + *****************************************************************************/ +package org.eclipse.papyrus.infra.gmfdiag.common.providers; + +import org.eclipse.gmf.runtime.notation.View; + + +public interface IThemeInitializer { + + public boolean usePreferenceInitializer(View view); +} diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/LineStyleLabelProvider.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/LineStyleLabelProvider.java index 474046f8ae1..2e7360f9a88 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/LineStyleLabelProvider.java +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/LineStyleLabelProvider.java @@ -1,126 +1,126 @@ -/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *
- * CEA LIST - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.gmfdiag.common.providers;
-
-import org.eclipse.draw2d.Graphics;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.swt.graphics.Image;
-
-/**
- *
- * Label Provider for line style
- *
- */
-public class LineStyleLabelProvider implements ILabelProvider {
-
-
- public static final String LINE_STYLE_SOLID_STRING = "Solid";
-
- public static final String LINE_STYLE_DASH_STRING = "Dash";
-
- public static final String LINE_STYLE_DOT_STRING = "Dot";
-
- public static final String LINE_STYLE_DASH_DOT_STRING = "Dash Dot";
-
- public static final String LINE_STYLE_DASH_DOT_DOT_STRING = "Dash Dot Dot";
-
- public static final String LINE_STYLE_CUSTOM = "Custom";
-
- /**
- *
- * @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener)
- *
- * @param listener
- */
- @Override
- public void addListener(ILabelProviderListener listener) {
- }
-
- /**
- *
- * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose()
- *
- */
- @Override
- public void dispose() {
- }
-
- /**
- *
- * @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String)
- *
- * @param element
- * @param property
- * @return
- */
- @Override
- public boolean isLabelProperty(Object element, String property) {
- return false;
- }
-
- /**
- *
- * @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener)
- *
- * @param listener
- */
- @Override
- public void removeListener(ILabelProviderListener listener) {
- }
-
- /**
- *
- * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
- *
- * @param element
- * @return
- */
- @Override
- public Image getImage(Object element) {
- return null;
- }
-
- /**
- *
- * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
- *
- * @param element
- * @return
- */
- @Override
- public String getText(Object element) {
- if (element instanceof Integer) {
- int lineStyle = (Integer) element;
- switch (lineStyle) {
- case Graphics.LINE_SOLID:
- return LINE_STYLE_SOLID_STRING;
- case Graphics.LINE_DASH:
- return LINE_STYLE_DASH_STRING;
- case Graphics.LINE_DOT:
- return LINE_STYLE_DOT_STRING;
- case Graphics.LINE_DASHDOT:
- return LINE_STYLE_DASH_DOT_STRING;
- case Graphics.LINE_DASHDOTDOT:
- return LINE_STYLE_DASH_DOT_DOT_STRING;
- case Graphics.LINE_CUSTOM:
- return LINE_STYLE_CUSTOM;
- default:
- break;
- }
- }
- return null;
- }
-
-}
+/***************************************************************************** + * Copyright (c) 2013 CEA LIST. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * + * CEA LIST - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.gmfdiag.common.providers; + +import org.eclipse.draw2d.Graphics; +import org.eclipse.jface.viewers.ILabelProvider; +import org.eclipse.jface.viewers.ILabelProviderListener; +import org.eclipse.swt.graphics.Image; + +/** + * + * Label Provider for line style + * + */ +public class LineStyleLabelProvider implements ILabelProvider { + + + public static final String LINE_STYLE_SOLID_STRING = "Solid"; + + public static final String LINE_STYLE_DASH_STRING = "Dash"; + + public static final String LINE_STYLE_DOT_STRING = "Dot"; + + public static final String LINE_STYLE_DASH_DOT_STRING = "Dash Dot"; + + public static final String LINE_STYLE_DASH_DOT_DOT_STRING = "Dash Dot Dot"; + + public static final String LINE_STYLE_CUSTOM = "Custom"; + + /** + * + * @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener) + * + * @param listener + */ + @Override + public void addListener(ILabelProviderListener listener) { + } + + /** + * + * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose() + * + */ + @Override + public void dispose() { + } + + /** + * + * @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String) + * + * @param element + * @param property + * @return + */ + @Override + public boolean isLabelProperty(Object element, String property) { + return false; + } + + /** + * + * @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener) + * + * @param listener + */ + @Override + public void removeListener(ILabelProviderListener listener) { + } + + /** + * + * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object) + * + * @param element + * @return + */ + @Override + public Image getImage(Object element) { + return null; + } + + /** + * + * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object) + * + * @param element + * @return + */ + @Override + public String getText(Object element) { + if (element instanceof Integer) { + int lineStyle = (Integer) element; + switch (lineStyle) { + case Graphics.LINE_SOLID: + return LINE_STYLE_SOLID_STRING; + case Graphics.LINE_DASH: + return LINE_STYLE_DASH_STRING; + case Graphics.LINE_DOT: + return LINE_STYLE_DOT_STRING; + case Graphics.LINE_DASHDOT: + return LINE_STYLE_DASH_DOT_STRING; + case Graphics.LINE_DASHDOTDOT: + return LINE_STYLE_DASH_DOT_DOT_STRING; + case Graphics.LINE_CUSTOM: + return LINE_STYLE_CUSTOM; + default: + break; + } + } + return null; + } + +} diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/NotationFilteredLabelProvider.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/NotationFilteredLabelProvider.java index 579d04aec64..22b070ab26d 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/NotationFilteredLabelProvider.java +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/NotationFilteredLabelProvider.java @@ -1,57 +1,57 @@ -/*****************************************************************************
- * Copyright (c) 2012 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
- *****************************************************************************/
-package org.eclipse.papyrus.infra.gmfdiag.common.providers;
-
-import java.util.Iterator;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gmf.runtime.notation.NotationPackage;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
-import org.eclipse.papyrus.infra.services.labelprovider.service.IFilteredLabelProvider;
-
-/**
- * A FilteredLabelProvider for GMF Notation model
- *
- * @author Camille Letavernier
- */
-public class NotationFilteredLabelProvider extends NotationLabelProvider implements IFilteredLabelProvider {
-
-
- public boolean accept(IStructuredSelection selection) {
- if (selection.isEmpty()) {
- return false;
- }
-
- Iterator<?> iterator = selection.iterator();
- while (iterator.hasNext()) {
- Object element = iterator.next();
- if (!accept(element)) {
- return false;
- }
- }
-
- return true;
- }
-
- @Override
- public boolean accept(Object element) {
- if (element instanceof IStructuredSelection) {
- return accept((IStructuredSelection) element);
- }
-
- // Accept elements from the Notation metamodel
- EObject eObject = EMFHelper.getEObject(element);
- return eObject != null && eObject.eClass().getEPackage() == NotationPackage.eINSTANCE;
- }
-
-}
+/***************************************************************************** + * Copyright (c) 2012 CEA LIST. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation + *****************************************************************************/ +package org.eclipse.papyrus.infra.gmfdiag.common.providers; + +import java.util.Iterator; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.gmf.runtime.notation.NotationPackage; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.papyrus.infra.emf.utils.EMFHelper; +import org.eclipse.papyrus.infra.services.labelprovider.service.IFilteredLabelProvider; + +/** + * A FilteredLabelProvider for GMF Notation model + * + * @author Camille Letavernier + */ +public class NotationFilteredLabelProvider extends NotationLabelProvider implements IFilteredLabelProvider { + + + public boolean accept(IStructuredSelection selection) { + if (selection.isEmpty()) { + return false; + } + + Iterator<?> iterator = selection.iterator(); + while (iterator.hasNext()) { + Object element = iterator.next(); + if (!accept(element)) { + return false; + } + } + + return true; + } + + @Override + public boolean accept(Object element) { + if (element instanceof IStructuredSelection) { + return accept((IStructuredSelection) element); + } + + // Accept elements from the Notation metamodel + EObject eObject = EMFHelper.getEObject(element); + return eObject != null && eObject.eClass().getEPackage() == NotationPackage.eINSTANCE; + } + +} diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/RestrictedAbstractEditPartProvider.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/RestrictedAbstractEditPartProvider.java index 03643c6bd2d..a04559bd35d 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/RestrictedAbstractEditPartProvider.java +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/RestrictedAbstractEditPartProvider.java @@ -1,61 +1,61 @@ -/*****************************************************************************
- * Copyright (c) 2014 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Patrick Tessier (CEA LIST) - Initial API and implementation
- /*****************************************************************************/
-package org.eclipse.papyrus.infra.gmfdiag.common.providers;
-
-/*****************************************************************************
- * Copyright (c) 2012 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- *
- *****************************************************************************/
-import org.eclipse.gmf.runtime.common.core.service.IOperation;
-import org.eclipse.gmf.runtime.diagram.ui.services.editpart.AbstractEditPartProvider;
-import org.eclipse.gmf.runtime.diagram.ui.services.editpart.CreateGraphicEditPartOperation;
-import org.eclipse.gmf.runtime.diagram.ui.services.editpart.IEditPartOperation;
-
-/**
- * This abstract edit part provider restricts its contribution to view that are owned by
- * a given type of diagram.
- */
-public abstract class RestrictedAbstractEditPartProvider extends AbstractEditPartProvider {
-
- /** The provides only provides for this diagram type */
- protected String diagramType;
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean provides(IOperation operation) {
- if (operation instanceof CreateGraphicEditPartOperation) {
- String currentDiagramType = ((IEditPartOperation) operation).getView().getDiagram().getType();
-
- if ((diagramType == null) || (!diagramType.equals(currentDiagramType))) {
- return false;
- }
- }
-
- return super.provides(operation);
- }
-
-
-
-
-}
+/***************************************************************************** + * Copyright (c) 2014 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Patrick Tessier (CEA LIST) - Initial API and implementation + /*****************************************************************************/ +package org.eclipse.papyrus.infra.gmfdiag.common.providers; + +/***************************************************************************** + * Copyright (c) 2012 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * CEA LIST - Initial API and implementation + * + *****************************************************************************/ +import org.eclipse.gmf.runtime.common.core.service.IOperation; +import org.eclipse.gmf.runtime.diagram.ui.services.editpart.AbstractEditPartProvider; +import org.eclipse.gmf.runtime.diagram.ui.services.editpart.CreateGraphicEditPartOperation; +import org.eclipse.gmf.runtime.diagram.ui.services.editpart.IEditPartOperation; + +/** + * This abstract edit part provider restricts its contribution to view that are owned by + * a given type of diagram. + */ +public abstract class RestrictedAbstractEditPartProvider extends AbstractEditPartProvider { + + /** The provides only provides for this diagram type */ + protected String diagramType; + + /** + * {@inheritDoc} + */ + @Override + public boolean provides(IOperation operation) { + if (operation instanceof CreateGraphicEditPartOperation) { + String currentDiagramType = ((IEditPartOperation) operation).getView().getDiagram().getType(); + + if ((diagramType == null) || (!diagramType.equals(currentDiagramType))) { + return false; + } + } + + return super.provides(operation); + } + + + + +} diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/ShapeDecoratorProvider.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/ShapeDecoratorProvider.java index a36cd20a1c6..f30c5dc7fba 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/ShapeDecoratorProvider.java +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/ShapeDecoratorProvider.java @@ -1,76 +1,76 @@ -/*****************************************************************************
- * Copyright (c) 2009-2010 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.gmfdiag.common.providers;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.gmf.runtime.common.core.service.AbstractProvider;
-import org.eclipse.gmf.runtime.common.core.service.IOperation;
-import org.eclipse.gmf.runtime.diagram.ui.services.decorator.CreateDecoratorsOperation;
-import org.eclipse.gmf.runtime.diagram.ui.services.decorator.IDecoratorProvider;
-import org.eclipse.gmf.runtime.diagram.ui.services.decorator.IDecoratorTarget;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
-import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
-import org.eclipse.papyrus.infra.gmfdiag.common.helper.NotationHelper;
-
-/**
- * Provides the decorator for the shape, based on the shape service
- */
-public class ShapeDecoratorProvider extends AbstractProvider implements IDecoratorProvider {
-
- /** The key used for the mood decoration */
- public static final String SHAPE_DECORATOR = "ShapeDecorator"; //$NON-NLS-1$
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void createDecorators(IDecoratorTarget decoratorTarget) {
- View node = ShapeDecorator.getDecoratorTargetNode(decoratorTarget);
- if (node != null) {
- decoratorTarget.installDecorator(SHAPE_DECORATOR, new ShapeDecorator(decoratorTarget));
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean provides(IOperation operation) {
- Assert.isNotNull(operation);
-
- if (!(operation instanceof CreateDecoratorsOperation)) {
- return false;
- }
-
- IDecoratorTarget decoratorTarget = ((CreateDecoratorsOperation) operation).getDecoratorTarget();
-
- View notationElement = NotationHelper.findView(decoratorTarget);
- if (notationElement == null) {
- return false;
- }
-
- try {
- ServicesRegistry papyrusRegistry = ServiceUtilsForEObject.getInstance().getServiceRegistry(notationElement);
- if (papyrusRegistry == null) {
- return false;
- }
- } catch (Exception ex) {
- return false; // Not a Papyrus model
- }
-
- return ShapeDecorator.getDecoratorTargetNode(decoratorTarget) != null;
- }
-
-}
+/***************************************************************************** + * Copyright (c) 2009-2010 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.gmfdiag.common.providers; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.gmf.runtime.common.core.service.AbstractProvider; +import org.eclipse.gmf.runtime.common.core.service.IOperation; +import org.eclipse.gmf.runtime.diagram.ui.services.decorator.CreateDecoratorsOperation; +import org.eclipse.gmf.runtime.diagram.ui.services.decorator.IDecoratorProvider; +import org.eclipse.gmf.runtime.diagram.ui.services.decorator.IDecoratorTarget; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.papyrus.infra.core.services.ServicesRegistry; +import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject; +import org.eclipse.papyrus.infra.gmfdiag.common.helper.NotationHelper; + +/** + * Provides the decorator for the shape, based on the shape service + */ +public class ShapeDecoratorProvider extends AbstractProvider implements IDecoratorProvider { + + /** The key used for the mood decoration */ + public static final String SHAPE_DECORATOR = "ShapeDecorator"; //$NON-NLS-1$ + + /** + * {@inheritDoc} + */ + @Override + public void createDecorators(IDecoratorTarget decoratorTarget) { + View node = ShapeDecorator.getDecoratorTargetNode(decoratorTarget); + if (node != null) { + decoratorTarget.installDecorator(SHAPE_DECORATOR, new ShapeDecorator(decoratorTarget)); + } + } + + /** + * {@inheritDoc} + */ + @Override + public boolean provides(IOperation operation) { + Assert.isNotNull(operation); + + if (!(operation instanceof CreateDecoratorsOperation)) { + return false; + } + + IDecoratorTarget decoratorTarget = ((CreateDecoratorsOperation) operation).getDecoratorTarget(); + + View notationElement = NotationHelper.findView(decoratorTarget); + if (notationElement == null) { + return false; + } + + try { + ServicesRegistry papyrusRegistry = ServiceUtilsForEObject.getInstance().getServiceRegistry(notationElement); + if (papyrusRegistry == null) { + return false; + } + } catch (Exception ex) { + return false; // Not a Papyrus model + } + + return ShapeDecorator.getDecoratorTargetNode(decoratorTarget) != null; + } + +} diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/ThemeInitializerManager.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/ThemeInitializerManager.java index 5902e1a6789..bac77861514 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/ThemeInitializerManager.java +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/ThemeInitializerManager.java @@ -1,51 +1,51 @@ -/*****************************************************************************
- * Copyright (c) 2012 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
- *****************************************************************************/
-package org.eclipse.papyrus.infra.gmfdiag.common.providers;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.gmfdiag.common.Activator;
-
-
-public class ThemeInitializerManager {
-
- private static final String EXTENSION_ID = Activator.ID + ".initializeView";
-
- public static final IThemeInitializer instance = loadThemeInitializer();
-
- private static IThemeInitializer loadThemeInitializer() {
- IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(EXTENSION_ID);
-
- for (IConfigurationElement e : config) {
- try {
- final IThemeInitializer initializer = (IThemeInitializer) e.createExecutableExtension("initializeView"); //$NON-NLS-1$
- if (initializer != null) {
- return initializer;
- }
- } catch (Exception ex) {
- Activator.log.error("The plugin " + e.getContributor().getName() + " contributed an invalid extension for " + EXTENSION_ID, ex);
- }
- }
-
- return new DefaultThemeInitializer();
- }
-
- private static class DefaultThemeInitializer implements IThemeInitializer {
-
- @Override
- public boolean usePreferenceInitializer(View view) {
- return true;
- }
-
- }
-}
+/***************************************************************************** + * Copyright (c) 2012 CEA LIST. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation + *****************************************************************************/ +package org.eclipse.papyrus.infra.gmfdiag.common.providers; + +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.Platform; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.papyrus.infra.gmfdiag.common.Activator; + + +public class ThemeInitializerManager { + + private static final String EXTENSION_ID = Activator.ID + ".initializeView"; + + public static final IThemeInitializer instance = loadThemeInitializer(); + + private static IThemeInitializer loadThemeInitializer() { + IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(EXTENSION_ID); + + for (IConfigurationElement e : config) { + try { + final IThemeInitializer initializer = (IThemeInitializer) e.createExecutableExtension("initializeView"); //$NON-NLS-1$ + if (initializer != null) { + return initializer; + } + } catch (Exception ex) { + Activator.log.error("The plugin " + e.getContributor().getName() + " contributed an invalid extension for " + EXTENSION_ID, ex); + } + } + + return new DefaultThemeInitializer(); + } + + private static class DefaultThemeInitializer implements IThemeInitializer { + + @Override + public boolean usePreferenceInitializer(View view) { + return true; + } + + } +} diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/UnitsLabelProvider.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/UnitsLabelProvider.java index ed279286ea7..238ac1214ea 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/UnitsLabelProvider.java +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/UnitsLabelProvider.java @@ -1,112 +1,112 @@ -/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *
- * CEA LIST - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.gmfdiag.common.providers;
-
-import org.eclipse.gef.rulers.RulerProvider;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.papyrus.infra.gmfdiag.common.utils.UnitsConstants;
-import org.eclipse.swt.graphics.Image;
-
-/**
- *
- * Label provider for Units
- *
- */
-public class UnitsLabelProvider implements ILabelProvider {
-
- /**
- *
- * @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener)
- *
- * @param listener
- */
- @Override
- public void addListener(ILabelProviderListener listener) {
- // not used
- }
-
- /**
- *
- * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose()
- *
- */
- @Override
- public void dispose() {
- // not used
- }
-
- /**
- *
- * @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String)
- *
- * @param element
- * @param property
- * @return
- */
- @Override
- public boolean isLabelProperty(Object element, String property) {
- return false;
- }
-
- /**
- *
- * @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener)
- *
- * @param listener
- */
- @Override
- public void removeListener(ILabelProviderListener listener) {
- // not used
- }
-
- /**
- *
- * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
- *
- * @param element
- * @return
- */
- @Override
- public Image getImage(Object element) {
- // not used
- return null;
- }
-
- /**
- *
- * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
- *
- * @param element
- * @return
- */
- @Override
- public String getText(Object element) {
- if (element instanceof Integer) {
- final int unit = (Integer) element;
- switch (unit) {
- case RulerProvider.UNIT_INCHES:
- return UnitsConstants.INCHES;
- case RulerProvider.UNIT_CENTIMETERS:
- return UnitsConstants.CENTIMETERS;
- case RulerProvider.UNIT_PIXELS:
- return UnitsConstants.PIXELS;
- default:
- break;
- }
- }
- return "";
- }
-
-}
+/***************************************************************************** + * Copyright (c) 2013 CEA LIST. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * + * CEA LIST - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.gmfdiag.common.providers; + +import org.eclipse.gef.rulers.RulerProvider; +import org.eclipse.jface.viewers.ILabelProvider; +import org.eclipse.jface.viewers.ILabelProviderListener; +import org.eclipse.papyrus.infra.gmfdiag.common.utils.UnitsConstants; +import org.eclipse.swt.graphics.Image; + +/** + * + * Label provider for Units + * + */ +public class UnitsLabelProvider implements ILabelProvider { + + /** + * + * @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener) + * + * @param listener + */ + @Override + public void addListener(ILabelProviderListener listener) { + // not used + } + + /** + * + * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose() + * + */ + @Override + public void dispose() { + // not used + } + + /** + * + * @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String) + * + * @param element + * @param property + * @return + */ + @Override + public boolean isLabelProperty(Object element, String property) { + return false; + } + + /** + * + * @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener) + * + * @param listener + */ + @Override + public void removeListener(ILabelProviderListener listener) { + // not used + } + + /** + * + * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object) + * + * @param element + * @return + */ + @Override + public Image getImage(Object element) { + // not used + return null; + } + + /** + * + * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object) + * + * @param element + * @return + */ + @Override + public String getText(Object element) { + if (element instanceof Integer) { + final int unit = (Integer) element; + switch (unit) { + case RulerProvider.UNIT_INCHES: + return UnitsConstants.INCHES; + case RulerProvider.UNIT_CENTIMETERS: + return UnitsConstants.CENTIMETERS; + case RulerProvider.UNIT_PIXELS: + return UnitsConstants.PIXELS; + default: + break; + } + } + return ""; + } + +} |