Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 196349 Details for
Bug 325610
[General] Papyrus shall enable to set dynamically decoration on elements within a diagram
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Model Explorer plugin patch
patch_ModelExplorer.txt (text/plain), 34.78 KB, created by
Amine EL KOUHEN
on 2011-05-23 10:59:52 EDT
(
hide
)
Description:
Model Explorer plugin patch
Filename:
MIME Type:
Creator:
Amine EL KOUHEN
Created:
2011-05-23 10:59:52 EDT
Size:
34.78 KB
patch
obsolete
>Index: plugin.properties >=================================================================== >--- plugin.properties (revision 4761) >+++ plugin.properties (working copy) >@@ -9,7 +9,7 @@ > # > # Contributors: > # Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation >-# >+# Amine EL KOUHEN (CEA LIST) Amine.elkouhen@cea.fr - Added the Menu Extension File Monitoring and Decoration Service > ######################################################################################## > pluginName=Papyrus Model Explorer (Incubation) > providerName=Eclipse Modeling Project >Index: plugin.xml >=================================================================== >--- plugin.xml (revision 4761) >+++ plugin.xml (working copy) >@@ -202,12 +202,6 @@ > </and> > </visibleWhen> > </command> >- <menu >- icon="icons/etool16/validate.gif" >- id="org.eclipse.papyrus.modelexplorer.popup.validation" >- label="Validation" >- path="papyrus"> >- </menu> > <separator > name="popup:org.eclipse.papyrus.modelexplorer.modelexplorer.popup.separator0" > visible="true"> >@@ -358,49 +352,6 @@ > </command> > </menuContribution> > <!-- ModelExplorer Contextual menu --> >- <menuContribution >- allPopups="true" >- locationURI="popup:org.eclipse.papyrus.modelexplorer.popup.validation"> >- <command >- commandId="org.eclipse.papyrus.modelexplorer.ValidateModelCommand" >- icon="icons/etool16/validate.gif" >- id="org.eclipse.papyrus.modelexplorer.ValidateModel" >- label="Validate model"> >- </command> >- <command >- commandId="org.eclipse.papyrus.modelexplorer.ValidateSubtreeCommand" >- icon="icons/etool16/validate.gif" >- id="org.eclipse.papyrus.modelexplorer.ValidateSubtree" >- label="Validate subtree"> >- </command> >- <command >- commandId="org.eclipse.papyrus.modelexplorer.SelectAndValidateModelCommand" >- icon="icons/etool16/validateSel.gif" >- id="org.eclipse.papyrus.modelexplorer.SelectAndValidateModel" >- label="Select constraints and Validate model"> >- </command> >- <command >- commandId="org.eclipse.papyrus.modelexplorer.SelectAndValidateSubtreeCommand" >- icon="icons/etool16/validateSel.gif" >- id="org.eclipse.papyrus.modelexplorer.SelectAndValidateSubtree" >- label="Select constraints and Validate subtree"> >- </command> >- <command >- commandId="org.eclipse.papyrus.modelexplorer.ValidateDelMarkersFromModelCommand" >- disabledIcon="IMG_TOOL_DELETE_DISABLED" >- icon="IMG_TOOL_DELETE" >- id="org.eclipse.papyrus.modelexplorer.DeleteMarkersFromModel" >- label="Remove markers from model"> >- </command> >- <command >- commandId="org.eclipse.papyrus.modelexplorer.ValidateDelMarkersFromSubtreeCommand" >- disabledIcon="IMG_TOOL_DELETE_DISABLED" >- icon="IMG_TOOL_DELETE" >- id="org.eclipse.papyrus.modelexplorer.DelMarkersFromSubtree" >- label="Remove markers from subtree"> >- </command> >- <!-- <visibleWhen checkEnabled="true"/> --> >- </menuContribution> > > </extension> > >@@ -433,49 +384,7 @@ > name="Delete" description="Delete" > categoryId="org.eclipse.papyrus.editor.category" > defaultHandler="org.eclipse.papyrus.modelexplorer.handler.DeleteCommandHandler"> >- </command> >- <command >- categoryId="org.eclipse.papyrus.editor.category" >- defaultHandler="org.eclipse.papyrus.modelexplorer.handler.ValidateModelHandler" >- description="ValidateModel" >- id="org.eclipse.papyrus.modelexplorer.ValidateModelCommand" >- name="ValidateModel"> >- </command> >- <command >- categoryId="org.eclipse.papyrus.editor.category" >- defaultHandler="org.eclipse.papyrus.modelexplorer.handler.ValidateSubtreeHandler" >- description="ValidateSubtree" >- id="org.eclipse.papyrus.modelexplorer.ValidateSubtreeCommand" >- name="ValidateSubtree"> >- </command> >- <command >- categoryId="org.eclipse.papyrus.editor.category" >- defaultHandler="org.eclipse.papyrus.modelexplorer.handler.SelectAndValidateSubtreeHandler" >- description="SelectAndValidate" >- id="org.eclipse.papyrus.modelexplorer.SelectAndValidateSubtreeCommand" >- name="SelectAndValidate"> >- </command> >- <command >- categoryId="org.eclipse.papyrus.editor.category" >- defaultHandler="org.eclipse.papyrus.modelexplorer.handler.SelectAndValidateModelHandler" >- description="SelectAndValidate" >- id="org.eclipse.papyrus.modelexplorer.SelectAndValidateModelCommand" >- name="SelectAndValidate"> >- </command> >- <command >- categoryId="org.eclipse.papyrus.editor.category" >- defaultHandler="org.eclipse.papyrus.modelexplorer.handler.ValidateDelMarkersFromModelHandler" >- description="ValidateDelMarkersFromModel" >- id="org.eclipse.papyrus.modelexplorer.ValidateDelMarkersFromModelCommand" >- name="ValidateDelMarkersFromModel"> >- </command> >- <command >- categoryId="org.eclipse.papyrus.editor.category" >- defaultHandler="org.eclipse.papyrus.modelexplorer.handler.ValidateDelMarkersFromSubtreeHandler" >- description="ValidateDelMarkersFromSubtree" >- id="org.eclipse.papyrus.modelexplorer.ValidateDelMarkersFromSubtreeCommand" >- name="ValidateDelMarkersFromSubtree"> >- </command> >+ </command> > </extension> > > >@@ -719,7 +628,6 @@ > class="org.eclipse.papyrus.modelexplorer.handler.DuplicateDiagramHandler" > commandId="org.eclipse.papyrus.modelexplorer.duplicate.command"> > <activeWhen> >- <and> > <with > variable="selection"> > <and> >@@ -735,15 +643,6 @@ > </iterate> > </and> > </with> >- <with >- variable="selection"> >- <test >- forcePluginActivation="true" >- property="org.eclipse.papyrus.modelexplorer.tester.isDiagram" >- value="true"> >- </test> >- </with> >- </and> > </activeWhen> > </handler> > <handler >Index: META-INF/MANIFEST.MF >=================================================================== >--- META-INF/MANIFEST.MF (revision 4761) >+++ META-INF/MANIFEST.MF (working copy) >@@ -18,7 +18,6 @@ > org.eclipse.emf.workspace.ui;bundle-version="1.3.0", > org.eclipse.core.expressions;bundle-version="3.4.200", > org.eclipse.papyrus.service.edit;bundle-version="0.8.0", >- org.eclipse.papyrus.validation;bundle-version="0.8.0", > org.eclipse.emf.facet.infra.browser;bundle-version="0.1.0", > org.eclipse.emf.facet.infra.browser.custom;bundle-version="0.1.0", > org.eclipse.emf.facet.infra.browser.custom.core;bundle-version="0.1.0", >@@ -28,7 +27,7 @@ > org.eclipse.emf.facet.infra.facet;bundle-version="0.1.0", > org.eclipse.emf.facet.infra.facet.core;bundle-version="0.1.0", > org.eclipse.emf.facet.infra.query.ui;bundle-version="0.1.0", >- org.eclipse.papyrus.ui.toolbox;bundle-version="0.8.0" >+ org.eclipse.papyrus.decoration;bundle-version="0.8.0" > Bundle-ActivationPolicy: lazy > Bundle-RequiredExecutionEnvironment: J2SE-1.5 > Bundle-Vendor: %providerName >@@ -42,3 +41,4 @@ > org.eclipse.papyrus.modelexplorer.factory, > org.eclipse.papyrus.modelexplorer.handler, > org.eclipse.papyrus.modelexplorer.preferences >+Import-Package: org.eclipse.papyrus.core.ui.pagebookview >Index: src/org/eclipse/papyrus/core/ui/pagebookview/ModelExplorerDecorationAdapter.java >=================================================================== >--- src/org/eclipse/papyrus/core/ui/pagebookview/ModelExplorerDecorationAdapter.java (revision 0) >+++ src/org/eclipse/papyrus/core/ui/pagebookview/ModelExplorerDecorationAdapter.java (revision 0) >@@ -0,0 +1,268 @@ >+/***************************************************************************** >+ * Copyright (c) 2011 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: >+ * Amine EL KOUHEN (CEA LIST/LIFL) - Amine.Elkouhen@cea.fr >+ *****************************************************************************/ >+package org.eclipse.papyrus.core.ui.pagebookview; >+ >+import org.eclipse.jface.resource.ImageDescriptor; >+import org.eclipse.jface.viewers.DecorationOverlayIcon; >+import org.eclipse.jface.viewers.IDecoration; >+import org.eclipse.papyrus.decoration.util.Decoration.PreferedPosition; >+import org.eclipse.papyrus.modelexplorer.Activator; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.graphics.Point; >+ >+ >+// TODO: Auto-generated Javadoc >+/** >+ * The Class ModelExplorerDecorationAdapter. >+ */ >+public class ModelExplorerDecorationAdapter { >+ >+ /** The decorator target. */ >+ protected Image decoratorTarget; >+ >+ /** The decoration. */ >+ protected ImageDescriptor decoration; >+ >+ /** The decoration position. */ >+ protected int decorationPosition; >+ >+ /** point corresponding to the size 16x16. */ >+ private final Point size16 = new Point(16, 16); >+ >+ >+ /** >+ * Instantiates a new model explorer decoration adapter. >+ * >+ * @param baseImage the base image >+ */ >+ public ModelExplorerDecorationAdapter(Image baseImage) { >+ this.decoratorTarget = baseImage; >+ } >+ >+ /** >+ * Gets the decorated image. >+ * >+ * @return the decorated image >+ */ >+ public Image getDecoratedImage() { >+ >+ if(getDecoration() == null && getDecoratorTarget() != null) >+ return getDecoratorTarget(); >+ >+ if(getDecoration() == null && getDecoratorTarget() == null) >+ return null; >+ >+ return getDecoratedImage(getDecoratorTarget(), getDecoration(), getDecorationPosition()); >+ } >+ >+ /** >+ * Gets the decoration. >+ * >+ * @return the decoration >+ */ >+ public ImageDescriptor getDecoration() { >+ return this.decoration; >+ } >+ >+ /** >+ * Gets the decorator target. >+ * >+ * @return the decorator target >+ */ >+ public Image getDecoratorTarget() { >+ return this.decoratorTarget; >+ } >+ >+ /** >+ * Sets the decoration. >+ * >+ * @param decoration the decoration >+ * @param decorationPosition the decoration position >+ */ >+ public void setDecoration(ImageDescriptor decoration, int decorationPosition) { >+ setDecoratedImage(getDecoratorTarget(), decoration, decorationPosition); >+ this.decoration = decoration; >+ this.decorationPosition = decorationPosition; >+ >+ } >+ >+ /** >+ * Sets the decoration. >+ * >+ * @param decoration the new decoration >+ */ >+ public void setDecoration(ImageDescriptor decoration) { >+ setDecoratedImage(getDecoratorTarget(), decoration, getDecorationPosition()); >+ this.decoration = decoration; >+ } >+ >+ /** >+ * Sets the decorator target. >+ * >+ * @param decoratorTarget the new decorator target >+ */ >+ public void setDecoratorTarget(Image decoratorTarget) { >+ this.decoratorTarget = decoratorTarget; >+ } >+ >+ >+ /** >+ * Gets the decoration position. >+ * >+ * @return the decoration position >+ */ >+ public int getDecorationPosition() { >+ //0 for TOP_LEFT, 1 for TOP_RIGHT, 2 for BOTTOM_LEFT, 3 for BOTTOM_RIGHT (Default), 4 for an UNDERLAY >+ return decorationPosition; >+ } >+ >+ >+ /** >+ * Sets the decoration position. >+ * >+ * @param decorationPosition the new decoration position >+ */ >+ public void setDecorationPosition(int decorationPosition) { >+ this.decorationPosition = decorationPosition; >+ } >+ >+ /** >+ * Sets the decorated image. >+ * >+ * @param baseImage the base image >+ * @param decoration the decoration >+ * @param decorationPosition the decoration position >+ */ >+ public void setDecoratedImage(Image baseImage, ImageDescriptor decoration, int decorationPosition) { >+ >+ if(decoration == null || baseImage == null) >+ return; >+ >+ DecorationOverlayIcon decoratedImage = null; >+ >+ // Construct a new image identifier >+ String decoratedImageId = baseImage.toString().concat(decoration.toString() + decorationPosition); >+ >+ // Return the stored image if we have one >+ if(Activator.getDefault().getImageRegistry().get(decoratedImageId) == null) { >+ // Otherwise create a new image and store it >+ switch(decorationPosition) { >+ >+ case IDecoration.TOP_LEFT: >+ decoratedImage = new DecorationOverlayIcon(baseImage, new ImageDescriptor[]{ decoration, null, null, null, null }, size16); >+ break; >+ case IDecoration.TOP_RIGHT: >+ decoratedImage = new DecorationOverlayIcon(baseImage, new ImageDescriptor[]{ null, decoration, null, null, null }, size16); >+ break; >+ case IDecoration.BOTTOM_LEFT: >+ decoratedImage = new DecorationOverlayIcon(baseImage, new ImageDescriptor[]{ null, null, decoration, null, null }, size16); >+ break; >+ case IDecoration.BOTTOM_RIGHT: >+ decoratedImage = new DecorationOverlayIcon(baseImage, new ImageDescriptor[]{ null, null, null, decoration, null }, size16); >+ break; >+ case IDecoration.UNDERLAY: >+ decoratedImage = new DecorationOverlayIcon(baseImage, new ImageDescriptor[]{ null, null, null, null, decoration }, size16); >+ break; >+ default: >+ decoratedImage = new DecorationOverlayIcon(baseImage, new ImageDescriptor[]{ null, null, decoration, null, null }, size16); >+ break; >+ } >+ Activator.getDefault().getImageRegistry().put(decoratedImageId, decoratedImage); >+ } >+ >+ } >+ >+ /** >+ * Gets the decorated image. >+ * >+ * @param baseImage the base image >+ * @param decoration the decoration >+ * @param decorationPosition the decoration position >+ * @return the decorated image >+ */ >+ public Image getDecoratedImage(Image baseImage, ImageDescriptor decoration, int decorationPosition) { >+ // Construct a new image identifier >+ String decoratedImageId = baseImage.toString().concat(decoration.toString() + decorationPosition); >+ >+ // Return the stored image if we have one >+ if(Activator.getDefault().getImageRegistry().get(decoratedImageId) == null) { >+ setDecoratedImage(baseImage, decoration, decorationPosition); >+ } >+ return Activator.getDefault().getImageRegistry().get(decoratedImageId); >+ } >+ >+ /** >+ * Sets the decorated image. >+ * >+ * @param baseImage the base image >+ * @param decorationArray the decoration array >+ * @param imageSize the image size >+ */ >+ public void setDecoratedImage(Image baseImage, ImageDescriptor[] decorationArray, Point imageSize) { >+ DecorationOverlayIcon decoratedImage = null; >+ >+ // Construct a new image identifier >+ String decoratedImageId = baseImage.toString().concat(decorationArray.toString()); >+ >+ // Return the stored image if we have one >+ if(Activator.getDefault().getImageRegistry().get(decoratedImageId) == null) { >+ // Otherwise create a new image and store it >+ decoratedImage = new DecorationOverlayIcon(baseImage, decorationArray, imageSize); >+ >+ Activator.getDefault().getImageRegistry().put(decoratedImageId, decoratedImage); >+ } >+ } >+ >+ /** >+ * Sets the decoration. >+ * >+ * @param decoration the decoration >+ * @param position the position >+ */ >+ public void setDecoration(ImageDescriptor decoration, PreferedPosition position) { >+ switch(position) { >+ >+ case NORTH_WEST: >+ setDecoration(decoration, IDecoration.TOP_LEFT); >+ break; >+ case NORTH: >+ setDecoration(decoration, IDecoration.TOP_RIGHT); >+ break; >+ case NORTH_EAST: >+ setDecoration(decoration, IDecoration.TOP_RIGHT); >+ break; >+ case EAST: >+ setDecoration(decoration, IDecoration.BOTTOM_RIGHT); >+ break; >+ case SOUTH_EAST: >+ setDecoration(decoration, IDecoration.BOTTOM_RIGHT); >+ break; >+ case SOUTH: >+ setDecoration(decoration, IDecoration.BOTTOM_LEFT); >+ break; >+ case SOUTH_WEST: >+ setDecoration(decoration, IDecoration.BOTTOM_LEFT); >+ break; >+ case WEST: >+ setDecoration(decoration, IDecoration.TOP_LEFT); >+ break; >+ case CENTER: >+ setDecoration(decoration, IDecoration.UNDERLAY); >+ break; >+ default: >+ setDecoration(decoration, IDecoration.BOTTOM_LEFT); >+ break; >+ >+ } >+ } >+} >Index: src/org/eclipse/papyrus/modelexplorer/Activator.java >=================================================================== >--- src/org/eclipse/papyrus/modelexplorer/Activator.java (revision 4761) >+++ src/org/eclipse/papyrus/modelexplorer/Activator.java (working copy) >@@ -14,31 +14,19 @@ > package org.eclipse.papyrus.modelexplorer; > > import java.net.URL; >-import java.util.ArrayList; >-import java.util.Collection; >-import java.util.HashSet; > import java.util.List; >-import java.util.Set; > > import org.eclipse.core.runtime.FileLocator; > import org.eclipse.core.runtime.IPath; > import org.eclipse.core.runtime.IStatus; > import org.eclipse.core.runtime.Path; > import org.eclipse.core.runtime.Status; >-import org.eclipse.emf.common.util.EList; >-import org.eclipse.emf.ecore.EClassifier; >-import org.eclipse.emf.ecore.EPackage; > import org.eclipse.emf.edit.EMFEditPlugin; >-import org.eclipse.emf.facet.infra.browser.Messages; > import org.eclipse.emf.facet.infra.browser.custom.MetamodelView; >-import org.eclipse.emf.facet.infra.browser.custom.TypeView; > import org.eclipse.emf.facet.infra.browser.custom.core.CustomizationsCatalog; > import org.eclipse.emf.facet.infra.browser.uicore.CustomizationManager; >-import org.eclipse.emf.facet.infra.facet.Facet; >-import org.eclipse.emf.facet.infra.facet.FacetSet; >-import org.eclipse.emf.facet.infra.facet.core.FacetSetCatalog; > import org.eclipse.jface.resource.ImageDescriptor; >-import org.eclipse.osgi.util.NLS; >+import org.eclipse.jface.resource.ImageRegistry; > import org.eclipse.papyrus.log.LogHelper; > import org.eclipse.ui.plugin.AbstractUIPlugin; > import org.osgi.framework.BundleContext; >@@ -58,6 +46,9 @@ > /** The log service */ > public static LogHelper log; > >+ /** image registry */ >+ private static ImageRegistry registry; >+ > /** Default constructor */ > public Activator() { > } >@@ -71,9 +62,11 @@ > * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext > * ) > */ >+ @Override > public void start(BundleContext context) throws Exception { > super.start(context); > plugin = this; >+ registry = getImageRegistry(); > log = new LogHelper(plugin); > EMFEditPlugin.getComposedAdapterFactoryDescriptorRegistry(); > >@@ -103,6 +96,7 @@ > * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext > * ) > */ >+ @Override > public void stop(BundleContext context) throws Exception { > plugin = null; > super.stop(context); >@@ -143,7 +137,6 @@ > customizationManager.registerCustomization(metamodelView); > } > customizationManager.loadCustomizations(); >- loadFacetsForCustomizations(registryDefaultCustomizations,customizationManager); > > } catch (Throwable e) { > Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Error initializing customizations", e)); //$NON-NLS-1$ >@@ -151,108 +144,7 @@ > } > > /** >- * load the facets > * >- * @param customizations >- * list of customization >- * @param customizationManager >- * the Customization Manager >- */ >- protected void loadFacetsForCustomizations( >- final List<MetamodelView> customizations, >- final CustomizationManager customizationManager) { >- final Set<Facet> referencedFacets = new HashSet<Facet>(); >- final Collection<FacetSet> facetSets = FacetSetCatalog.getSingleton() >- .getAllFacetSets(); >- >- for (MetamodelView customization : customizations) { >- String metamodelURI = customization.getMetamodelURI(); >- // find customized FacetSet >- FacetSet customizedFacetSet = null; >- if (metamodelURI != null) { >- for (FacetSet facetSet : facetSets) { >- if (metamodelURI.equals(facetSet.getNsURI())) { >- customizedFacetSet = facetSet; >- break; >- } >- } >- } >- if (customizedFacetSet == null) { >- continue; >- } >- >- // find customized Facets >- EList<TypeView> types = customization.getTypes(); >- for (TypeView typeView : types) { >- String metaclassName = typeView.getMetaclassName(); >- Facet facet = findFacetWithFullyQualifiedName(metaclassName, >- customizedFacetSet); >- if (facet != null) { >- referencedFacets.add(facet); >- } else { >- Activator.log.warn(NLS >- .bind( >- Messages.BrowserActionBarContributor_missingRequiredFacet, >- new Object[] { >- metaclassName, >- customizedFacetSet >- .getName(), >- customization.getName() })); >- } >- } >- >- for (Facet referencedFacet : referencedFacets) { >- customizationManager.loadFacet(referencedFacet); >- } >- } >- >- // >- // for modified facets >- // customizationManager.getInstancesForMetaclasses().buildDerivationTree(); >- // customizationManager.getAppearanceConfiguration().touch(); >- // customizationManager.refreshDelayed(true); >- } >- /** >- * fin a facet from >- * >- * @param metaclassName >- * @param customizedFacetSet >- * @return >- */ >- private Facet findFacetWithFullyQualifiedName(final String metaclassName, >- final FacetSet customizedFacetSet) { >- EList<Facet> facets = customizedFacetSet.getFacets(); >- for (Facet facet : facets) { >- String facetName = getMetaclassQualifiedName(facet); >- if (metaclassName.equals(facetName)) { >- return facet; >- } >- } >- return null; >- } >- >- /** @return the qualified name of the given metaclass */ >- public static String getMetaclassQualifiedName(final EClassifier eClass) { >- final ArrayList<String> qualifiedNameParts = new ArrayList<String>(); >- final StringBuilder builder = new StringBuilder(); >- >- EPackage ePackage = eClass.getEPackage(); >- while (ePackage != null) { >- qualifiedNameParts.add(ePackage.getName()); >- ePackage = ePackage.getESuperPackage(); >- } >- >- for (int i = qualifiedNameParts.size() - 1; i >= 0; i--) { >- builder.append(qualifiedNameParts.get(i) + "."); //$NON-NLS-1$ >- } >- >- builder.append(eClass.getName()); >- >- return builder.toString(); >- } >- >- /** >- * > * @see org.eclipse.ui.IStartup#earlyStartup() > * > */ >Index: src/org/eclipse/papyrus/modelexplorer/MoDiscoLabelProvider.java >=================================================================== >--- src/org/eclipse/papyrus/modelexplorer/MoDiscoLabelProvider.java (revision 4761) >+++ src/org/eclipse/papyrus/modelexplorer/MoDiscoLabelProvider.java (working copy) >@@ -10,117 +10,127 @@ > * Contributors: > * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation > * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >+ * Amine EL KOUHEN (CEA LIST/LIFL) - Added the decorator Factory > *****************************************************************************/ > package org.eclipse.papyrus.modelexplorer; > >-import org.eclipse.core.resources.IMarker; > import org.eclipse.core.runtime.IAdaptable; > import org.eclipse.emf.ecore.EObject; > import org.eclipse.emf.ecore.InternalEObject; > import org.eclipse.emf.facet.infra.browser.uicore.CustomizableModelLabelProvider; > import org.eclipse.gmf.runtime.notation.Diagram; > import org.eclipse.jface.resource.ImageDescriptor; >-import org.eclipse.jface.resource.ImageRegistry; >-import org.eclipse.jface.viewers.DecorationOverlayIcon; > import org.eclipse.osgi.util.NLS; > import org.eclipse.papyrus.core.editorsfactory.IPageIconsRegistry; > import org.eclipse.papyrus.core.editorsfactory.PageIconsRegistry; > import org.eclipse.papyrus.core.services.ServiceException; >+import org.eclipse.papyrus.core.ui.pagebookview.ModelExplorerDecorationAdapter; > import org.eclipse.papyrus.core.utils.EditorUtils; >-import org.eclipse.papyrus.validation.ValidationTool; >+import org.eclipse.papyrus.decoration.DecorationService; >+import org.eclipse.papyrus.decoration.util.Decoration.PreferedPosition; >+import org.eclipse.papyrus.decoration.util.IDecoration; > import org.eclipse.swt.graphics.Image; >-import org.eclipse.swt.graphics.Point; > import org.eclipse.ui.ISharedImages; > import org.eclipse.ui.PlatformUI; > >+// TODO: Auto-generated Javadoc > /** >- * the label provider that inherits of modisco label provider >- * >+ * the label provider that inherits of modisco label provider. > */ > public class MoDiscoLabelProvider extends CustomizableModelLabelProvider { >- >- /** icon registry */ >+ >+ /** icon registry. */ > private IPageIconsRegistry editorRegistry; > >- /** point corresponding to the size 16x16 */ >- private static final Point size16 = new Point (16, 16); >- >- /** image registry */ >- private static final ImageRegistry registry = new ImageRegistry (); >- >+ /** Decoration Service *. */ >+ private DecorationService decorationService; >+ > /** > * Creates a new MoDiscoLabelProvider. > */ > public MoDiscoLabelProvider() { > super(Activator.getDefault().getCustomizationManager()); >+ try { >+ decorationService = EditorUtils.getServiceRegistry().getService(DecorationService.class); >+ /* OR : decorationService = ServiceUtilsForActionHandlers.getInstance().getServiceRegistry().getService(DecorationService.class); */ >+ } catch (ServiceException e) { >+ // TODO Auto-generated catch block >+ e.printStackTrace(); >+ } >+ > } > > /** >- * Returns the message of the marker for the specified element >- * @param element the element for which the marker message should be found >+ * Returns the message of the marker for the specified element. >+ * >+ * @param element >+ * the element for which the marker message should be found > * @return the message of the marker for the specified element > */ > public String getMarkerMessage(Object element) { >- ValidationTool vt = new ValidationTool (element); >- return vt.getMarkerMessages(); >+ return decorationService.getDecoration(element, false).getMessage(); > } >- >+ > /** > * return the image of an element in the model browser > * evaluates error markers. >+ * >+ * @param element >+ * the element >+ * @return the image > */ > @Override > public Image getImage(Object element) { >- ValidationTool vt = new ValidationTool (element); >- vt.tryChildIfEmpty(); >- int severity = vt.getSeverity(); >- if(element instanceof Diagram) { >- return getDecoratedImage (getEditorRegistry().getEditorIcon(element), severity); >- } >- return getDecoratedImage (super.getImage(element), severity); >+ >+ // Get the Model Explorer Adapter >+ ModelExplorerDecorationAdapter adapter = new ModelExplorerDecorationAdapter(null); >+ >+ >+ //Set the decoration target >+ if(element instanceof Diagram) >+ adapter.setDecoratorTarget(getEditorRegistry().getEditorIcon(element)); >+ else >+ adapter.setDecoratorTarget(super.getImage(element)); >+ >+ //Set the decoration with default position >+ IDecoration decoration = decorationService.getDecoration(element, true); >+ decoration.setDecorationImage(getImageDescriptor(decoration.getSeverity())); >+ adapter.setDecoration(decoration.getDecorationImage(), PreferedPosition.DEFAULT); >+ >+ //return the target decorated >+ return adapter.getDecoratedImage(); >+ > } > > /** >- * Return a DecoratedImage, thanks to Torkild U. Resheim (Trondheim, Norway) >- * @param baseImage the base image to decorate >- * @param severity the severity of the error >- * @return the decorated image >+ * Gets the image descriptor from severity. >+ * >+ * @param severity >+ * the severity >+ * @return the image descriptor > */ >- private Image getDecoratedImage(Image baseImage, int severity) { >- ISharedImages sharedImages = PlatformUI.getWorkbench().getSharedImages(); >+ private ImageDescriptor getImageDescriptor(int severity) { >+ >+ ISharedImages sharedImages = PlatformUI.getWorkbench().getSharedImages(); > ImageDescriptor overlay = null; >- switch (severity) { >- case IMarker.SEVERITY_ERROR: >- overlay = sharedImages.getImageDescriptor(ISharedImages.IMG_DEC_FIELD_ERROR); >- break; >- case IMarker.SEVERITY_WARNING: >- overlay = sharedImages.getImageDescriptor(ISharedImages.IMG_DEC_FIELD_WARNING); >- break; >- default: >- return baseImage; >+ switch(severity) { >+ case 2://Error >+ overlay = sharedImages.getImageDescriptor(ISharedImages.IMG_DEC_FIELD_ERROR); >+ break; >+ case 1://Warning >+ overlay = sharedImages.getImageDescriptor(ISharedImages.IMG_DEC_FIELD_WARNING); >+ break; > } >- // Construct a new image identifier >- String decoratedImageId = baseImage.toString().concat(String.valueOf(severity)); >- // Return the stored image if we have one >- if (registry.get(decoratedImageId) == null) { >- // Otherwise create a new image and store it >- DecorationOverlayIcon decoratedImage = new DecorationOverlayIcon( >- baseImage, new ImageDescriptor[] { null, null, null, >- overlay, null }, size16) { >- }; >- registry.put(decoratedImageId, decoratedImage); >- } >- return registry.get(decoratedImageId); >+ >+ return overlay; > } >- >+ > /** > * Get the EditorRegistry used to create editor instances. This default > * implementation return the singleton eINSTANCE. This method can be > * subclassed to return another registry. > * > * @return the singleton eINSTANCE of editor registry >- * @throws ServiceException > */ > protected IPageIconsRegistry getEditorRegistry() { > if(editorRegistry == null) { >@@ -135,7 +145,6 @@ > * extension point namespace. > * > * @return the EditorRegistry for nested editor descriptors >- * @throws ServiceException > */ > protected IPageIconsRegistry createEditorRegistry() { > try { >@@ -160,8 +169,8 @@ > EObject obj = (EObject)((IAdaptable)element).getAdapter(EObject.class); > if(obj instanceof InternalEObject && obj.eIsProxy()) { > InternalEObject internal = (InternalEObject)obj; >- text = NLS.bind(Messages.MoDiscoLabelProvider_ProxyLabel, obj.getClass().getSimpleName(), internal.eProxyURI().trimFragment()); >- // Messages.MoDiscoLabelProvider_0 + + Messages.MoDiscoLabelProvider_1 + ;; >+ text = NLS.bind(Messages.MoDiscoLabelProvider_ProxyLabel, obj.getClass().getSimpleName(), internal.eProxyURI().trimFragment()); >+ // Messages.MoDiscoLabelProvider_0 + + Messages.MoDiscoLabelProvider_1 + ;; > } else { > text = super.getText(element); > } >@@ -169,5 +178,5 @@ > text = super.getText(element); > } > return text; >- } >+ } > } >Index: src/org/eclipse/papyrus/modelexplorer/ModelExplorerView.java >=================================================================== >--- src/org/eclipse/papyrus/modelexplorer/ModelExplorerView.java (revision 4761) >+++ src/org/eclipse/papyrus/modelexplorer/ModelExplorerView.java (working copy) >@@ -9,7 +9,7 @@ > * > * Contributors: > * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation >- * Vincent Lorenzo (CEA LIST) Vincent.lorenzo@cea.fr - 343950: [Model Explorer] [TableEditor] Function "Link with Editor" >+ * > *****************************************************************************/ > package org.eclipse.papyrus.modelexplorer; > >@@ -161,15 +161,12 @@ > Iterator<?> selectionIterator=((IStructuredSelection)selection).iterator(); > ArrayList<Object> semanticElementList= new ArrayList<Object>(); > while(selectionIterator.hasNext()) { >- Object currentSelection = selectionIterator.next(); >+ Object currentSelection = (Object)selectionIterator.next(); > if( currentSelection instanceof IAdaptable){ > Object semanticElement=((IAdaptable)currentSelection).getAdapter(EObject.class); > if( semanticElement!=null){ > semanticElementList.add(semanticElement); > } >- //when we are in a table, the selected element are EObject >- }else if(currentSelection instanceof EObject){ >- semanticElementList.add(currentSelection); > } > > } >Index: src/org/eclipse/papyrus/modelexplorer/actions/GenericTransformAction.java >=================================================================== >--- src/org/eclipse/papyrus/modelexplorer/actions/GenericTransformAction.java (revision 4761) >+++ src/org/eclipse/papyrus/modelexplorer/actions/GenericTransformAction.java (working copy) >@@ -25,9 +25,9 @@ > import org.eclipse.jface.dialogs.IDialogConstants; > import org.eclipse.jface.dialogs.MessageDialog; > import org.eclipse.jface.window.Window; >+import org.eclipse.papyrus.core.ui.InformationDialog; > import org.eclipse.papyrus.modelexplorer.Activator; > import org.eclipse.papyrus.modelexplorer.preferences.INavigatorPreferenceConstants; >-import org.eclipse.papyrus.ui.toolbox.dialog.InformationDialog; > import org.eclipse.swt.SWT; > import org.eclipse.swt.widgets.Display; > >Index: src/org/eclipse/papyrus/modelexplorer/dnd/CommonDropAdapterAssistant.java >=================================================================== >--- src/org/eclipse/papyrus/modelexplorer/dnd/CommonDropAdapterAssistant.java (revision 4761) >+++ src/org/eclipse/papyrus/modelexplorer/dnd/CommonDropAdapterAssistant.java (working copy) >@@ -105,26 +105,23 @@ > * @return a list that contains one command to move the diagram > */ > protected List<Command> getDropDiagramIntoCommand(TransactionalEditingDomain domain,EObject targetOwner, Diagram childElement){ >- // Diagram drag and drop is not supported. >- throw new UnsupportedOperationException(); >- >-// ArrayList<Command> commandList= new ArrayList<Command>(); >-// EReference eref= NotationPackage.eINSTANCE.getView_Element(); >-// if(eref!=null){ >-// SetRequest setRequest= new SetRequest(childElement, eref, targetOwner); >-// IElementEditService provider = ElementEditServiceUtils.getCommandProvider(childElement); >-// if(provider != null) { >-// // Retrieve delete command from the Element Edit service >-// ICommand command = provider.getEditCommand(setRequest); >-// >-// if(command != null) { >-// commandList.add( new GMFtoEMFCommandWrapper(command)); >-// } >-// } >-// } >-// >-// >-// return commandList; >+ ArrayList<Command> commandList= new ArrayList<Command>(); >+ EReference eref= NotationPackage.eINSTANCE.getView_Element(); >+ if(eref!=null){ >+ SetRequest setRequest= new SetRequest(childElement, eref, targetOwner); >+ IElementEditService provider = ElementEditServiceUtils.getCommandProvider(childElement); >+ if(provider != null) { >+ // Retrieve delete command from the Element Edit service >+ ICommand command = provider.getEditCommand(setRequest); >+ >+ if(command != null) { >+ commandList.add( new GMFtoEMFCommandWrapper(command)); >+ } >+ } >+ } >+ >+ >+ return commandList; > } > /** > * get the list of command to put an eobject before or after another EObject >@@ -333,8 +330,7 @@ > } > > if(eObjectchild instanceof Diagram){ >- // Do not allow diagram drag and drop, it is not supported yet. >- // result.addAll(getDropDiagramIntoCommand(getEditingDomain(), targetEObject,(Diagram) eObjectchild)); >+ result.addAll(getDropDiagramIntoCommand(getEditingDomain(), targetEObject,(Diagram) eObjectchild)); > } > //test if object is an eobject > else if(eObjectchild!=null){
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
rschnekenburger
:
iplog+
Actions:
View
|
Diff
Attachments on
bug 325610
:
196346
|
196347
|
196348
| 196349 |
196350
|
196351