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 @@ - - @@ -358,49 +352,6 @@ - - - - - - - - - - - - - - - @@ -433,49 +384,7 @@ name="Delete" description="Delete" categoryId="org.eclipse.papyrus.editor.category" defaultHandler="org.eclipse.papyrus.modelexplorer.handler.DeleteCommandHandler"> - - - - - - - - - - - - - + @@ -719,7 +628,6 @@ class="org.eclipse.papyrus.modelexplorer.handler.DuplicateDiagramHandler" commandId="org.eclipse.papyrus.modelexplorer.duplicate.command"> - @@ -735,15 +643,6 @@ - - - - - customizations, - final CustomizationManager customizationManager) { - final Set referencedFacets = new HashSet(); - final Collection 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 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 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 qualifiedNameParts = new ArrayList(); - 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 semanticElementList= new ArrayList(); 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 getDropDiagramIntoCommand(TransactionalEditingDomain domain,EObject targetOwner, Diagram childElement){ - // Diagram drag and drop is not supported. - throw new UnsupportedOperationException(); - -// ArrayList commandList= new ArrayList(); -// 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 commandList= new ArrayList(); + 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){