diff options
4 files changed, 79 insertions, 3 deletions
diff --git a/plugins/sysml/modelexplorer/org.eclipse.papyrus.sysml.modelexplorer/plugin.xml b/plugins/sysml/modelexplorer/org.eclipse.papyrus.sysml.modelexplorer/plugin.xml index 17f7cf34f50..0164774e1dd 100644 --- a/plugins/sysml/modelexplorer/org.eclipse.papyrus.sysml.modelexplorer/plugin.xml +++ b/plugins/sysml/modelexplorer/org.eclipse.papyrus.sysml.modelexplorer/plugin.xml @@ -2,9 +2,9 @@ <?eclipse version="3.4"?> <plugin> -<extension point="org.eclipse.papyrus.emf.facet.util.emf.core.modeldeclaration"> +<!--extension point="org.eclipse.papyrus.emf.facet.util.emf.core.modeldeclaration"> <modeldeclaration file="resources/SimpleSysML.custom"/> -</extension> +</extension--> --> <!-- This declaration is added in order command (CommandHandler) status to be verified (isVisible and isEnabled) before any attempt to execute the command, diff --git a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/META-INF/MANIFEST.MF b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/META-INF/MANIFEST.MF index d90e41436d9..a588bdced42 100644 --- a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/META-INF/MANIFEST.MF +++ b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/META-INF/MANIFEST.MF @@ -35,7 +35,9 @@ Require-Bundle: org.eclipse.ui, org.eclipse.emf.ecore,
org.eclipse.papyrus.emf.facet.efacet.core;bundle-version="1.0.0",
org.eclipse.papyrus.infra.gmfdiag.common;bundle-version="1.0.0",
- org.eclipse.papyrus.infra.viewpoints.policy;bundle-version="1.0.0"
+ org.eclipse.papyrus.infra.viewpoints.policy;bundle-version="1.0.0",
+ org.eclipse.papyrus.emf.facet.custom.ui,
+ org.eclipse.papyrus.uml.tools.utils
Bundle-Vendor: %providerName
Bundle-Version: 1.0.0.qualifier
Bundle-ManifestVersion: 2
diff --git a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/resource/SimpleUML.custom b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/resource/SimpleUML.custom index 9f5c435da9e..1c575d13891 100644 --- a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/resource/SimpleUML.custom +++ b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/resource/SimpleUML.custom @@ -10,6 +10,14 @@ <query xsi:type="javaQuery:JavaQuery" implementationClassName="org.eclipse.papyrus.uml.modelexplorer.queries.DisplayUMLStructuralFeature"/>
<override xsi:type="efacet:FacetOperation" href="../../../plugin/org.eclipse.papyrus.emf.facet.custom.ui/resources/customproperties.efacet#//CustomizedEObject/isVisible"/>
</facetOperations>
+ <facetOperations name="GetElementIcon">
+ <eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/papyrus/emf/facet/custom/0.2.incubation/custom_primitive_types#//Image"/>
+ <eParameters name="eStructuralElement">
+ <eType xsi:type="ecore:EClass" href="http://www.eclipse.org/emf/2002/Ecore#//EStructuralFeature"/>
+ </eParameters>
+ <query xsi:type="javaQuery:JavaQuery" implementationClassName="org.eclipse.papyrus.uml.modelexplorer.queries.GetImageQuery"/>
+ <override xsi:type="efacet:FacetOperation" href="../../../plugin/org.eclipse.papyrus.emf.facet.custom.ui/resources/customproperties.efacet#//CustomizedEObject/image"/>
+ </facetOperations>
<facetOperations name="CollapseContaimentRef">
<eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EBoolean"/>
<eParameters name="eStructuralFeature">
diff --git a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/queries/GetImageQuery.java b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/queries/GetImageQuery.java new file mode 100644 index 00000000000..8293016477b --- /dev/null +++ b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/queries/GetImageQuery.java @@ -0,0 +1,66 @@ +/***************************************************************************** + * 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.uml.modelexplorer.queries; + +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.edit.provider.ComposedAdapterFactory; +import org.eclipse.emf.edit.provider.IItemLabelProvider; +import org.eclipse.papyrus.emf.facet.custom.metamodel.custompt.IImage; +import org.eclipse.papyrus.emf.facet.custom.ui.ImageUtils; +import org.eclipse.papyrus.emf.facet.custom.ui.internal.custompt.ImageWrapper; +import org.eclipse.papyrus.emf.facet.custom.ui.internal.query.ImageQuery; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; +import org.eclipse.papyrus.emf.facet.query.java.core.IJavaQuery2; +import org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2; +import org.eclipse.papyrus.uml.tools.utils.ElementUtil; +import org.eclipse.swt.graphics.Image; +import org.eclipse.uml2.uml.Element; +import org.eclipse.uml2.uml.Stereotype; + +/** Create a basic label based on element name */ +public class GetImageQuery implements IJavaQuery2<Element, IImage> { + + //public static final String sysml_plugin_path = "platform:/plugin/org.eclipse.papyrus.sysml/"; + + + //@Override + public IImage evaluate(Element source, IParameterValueList2 parameterValues, IFacetManager facetManager) throws DerivedTypedElementException { + String iconPath = ""; + if(!source.getAppliedStereotypes().isEmpty()) { + Stereotype first_stereotype = source.getAppliedStereotypes().get(0); + + if(!first_stereotype.getIcons().isEmpty()) { + org.eclipse.uml2.uml.Image icon = ElementUtil.getStereotypeImage(source, first_stereotype, "icon"); + if(icon != null) { + iconPath = icon.getLocation(); + } + } + } + + String imagePath = ""; + + if(iconPath != null && !"".equals(iconPath)) { + URI iconURI = URI.createURI(iconPath); +// if(iconURI.isRelative()) { +// imagePath = sysml_plugin_path + iconPath; +// } else { + imagePath = iconURI.toString(); + // } + } + if("".equals(imagePath)){ + return ImageQuery.getEObjectImage(source); + } + return ImageUtils.wrap(imagePath); + } +} |