diff options
author | Vincent Lorenzo | 2014-04-23 11:54:17 +0000 |
---|---|---|
committer | Vincent Lorenzo | 2014-04-23 11:54:17 +0000 |
commit | fe58084dd3d1a5696e1c1cd0fe6821ba6559a152 (patch) | |
tree | 4d0a7fd4e2ce833f93ef4c6653a07f0ea9e2872f /plugins | |
parent | fad08ffd9d1ff0b86f39564136ec03380bb02a62 (diff) | |
parent | 13e8562985341ca6a15d64bd8cd877fa43831ddc (diff) | |
download | org.eclipse.papyrus-fe58084dd3d1a5696e1c1cd0fe6821ba6559a152.tar.gz org.eclipse.papyrus-fe58084dd3d1a5696e1c1cd0fe6821ba6559a152.tar.xz org.eclipse.papyrus-fe58084dd3d1a5696e1c1cd0fe6821ba6559a152.zip |
Merge branch 'master' of ssh://git.eclipse.org:29418/papyrus/org.eclipse.papyrus
Diffstat (limited to 'plugins')
7 files changed, 189 insertions, 177 deletions
diff --git a/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/editor/ViewFilter.java b/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/editor/ViewFilter.java index 4ef44922cc4..e5c8f0b42b1 100644 --- a/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/editor/ViewFilter.java +++ b/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/editor/ViewFilter.java @@ -1,6 +1,6 @@ /*****************************************************************************
* 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
@@ -11,10 +11,10 @@ *****************************************************************************/
package org.eclipse.papyrus.customization.properties.editor;
-import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
import org.eclipse.papyrus.views.properties.contexts.DataContextElement;
import org.eclipse.papyrus.views.properties.contexts.DataContextPackage;
import org.eclipse.papyrus.views.properties.contexts.View;
@@ -24,7 +24,7 @@ import org.eclipse.ui.internal.misc.StringMatcher; * A Filter for the UIEditor. The Filter can match Views and DataContextElements
* An object is matched if it directly matches the filter, or if one of its parents
* match it, or if one of his children (at any level) match it.
- *
+ *
* @author Camille Letavernier
*/
public class ViewFilter extends ViewerFilter {
@@ -33,7 +33,7 @@ public class ViewFilter extends ViewerFilter { /**
* Sets the pattern for this filter
- *
+ *
* @param pattern
*/
public void setPattern(String pattern) {
@@ -46,21 +46,20 @@ public class ViewFilter extends ViewerFilter { return true;
}
- if(element instanceof IAdaptable) {
- EObject eObject = (EObject)((IAdaptable)element).getAdapter(EObject.class);
- if(eObject != null) {
- if(eObject instanceof View) {
- String viewName = ((View)eObject).getName();
- if(viewName == null) {
- return true;
- }
- return matcher.match(viewName);
- } else if(eObject instanceof DataContextPackage) {
- //FIXME : The filter doesn't work correctly for displaying a DataContextElement in a Package
- return select((DataContextPackage)eObject);
- } else if(eObject instanceof DataContextElement) {
- return select((DataContextElement)eObject);
+ EObject semantic = EMFHelper.getEObject(element);
+
+ if(semantic != null) {
+ if(semantic instanceof View) {
+ String viewName = ((View)semantic).getName();
+ if(viewName == null) {
+ return true;
}
+ return matcher.match(viewName);
+ } else if(semantic instanceof DataContextPackage) {
+ //FIXME : The filter doesn't work correctly for displaying a DataContextElement in a Package
+ return select((DataContextPackage)semantic);
+ } else if(semantic instanceof DataContextElement) {
+ return select((DataContextElement)semantic);
}
}
@@ -70,7 +69,7 @@ public class ViewFilter extends ViewerFilter { /**
* An element is displayed if its name matches the filter, or if one of its
* children's or parent's name match it
- *
+ *
* @param dataContextPackage
* @return
*/
diff --git a/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/editor/preview/Preview.java b/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/editor/preview/Preview.java index 8e4b5d1ec8b..6fd1f1ddf98 100644 --- a/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/editor/preview/Preview.java +++ b/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/editor/preview/Preview.java @@ -1,6 +1,6 @@ /*****************************************************************************
* Copyright (c) 2010, 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
@@ -27,12 +27,9 @@ import java.util.List; import java.util.Map;
import java.util.Set;
-import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IPath;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
-import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.internal.treeproxy.EObjectTreeElement;
-import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.internal.treeproxy.EStructuralFeatureTreeElement;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
@@ -40,6 +37,9 @@ import org.eclipse.papyrus.customization.properties.Activator; import org.eclipse.papyrus.customization.properties.editor.UIEditor;
import org.eclipse.papyrus.customization.properties.messages.Messages;
import org.eclipse.papyrus.customization.properties.model.xwt.resource.XWTResource;
+import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.internal.treeproxy.EObjectTreeElement;
+import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.internal.treeproxy.EStructuralFeatureTreeElement;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
import org.eclipse.papyrus.views.properties.contexts.Section;
import org.eclipse.papyrus.views.properties.contexts.Tab;
import org.eclipse.papyrus.views.properties.contexts.View;
@@ -78,9 +78,9 @@ import org.eclipse.ui.part.ViewPart; * - The Enum and References fields are empty
* - Some buttons may be marked as disabled, but will be available at runtime (Or vice-versa)
* - The dynamic sections are always displayed
- *
+ *
* The preview can be disabled for performance issues
- *
+ *
* @author Camille Letavernier
*/
public class Preview extends ViewPart implements ISelectionChangedListener, IPartListener {
@@ -118,7 +118,7 @@ public class Preview extends ViewPart implements ISelectionChangedListener, IPar /**
* Constructor.
* Constructs a new Preview in an editor (Embedded preview)
- *
+ *
* @param editor
*/
public Preview(UIEditor editor) {
@@ -127,7 +127,7 @@ public class Preview extends ViewPart implements ISelectionChangedListener, IPar /**
* Creates the preview control in the given composite.
- *
+ *
* @param container
* The SWT Composite in which the preview should be displayed
*/
@@ -211,7 +211,7 @@ public class Preview extends ViewPart implements ISelectionChangedListener, IPar /**
* Sets the current Editor
- *
+ *
* @param editor
*/
public void setEditor(UIEditor editor) {
@@ -230,7 +230,7 @@ public class Preview extends ViewPart implements ISelectionChangedListener, IPar /**
* Saves the section's XWT Resource in a temporary file, which
* can then be interpreted by XWT. Returns the URL to this file.
- *
+ *
* @param section
* The section for which we want to persist the XWT Resource
* @return
@@ -257,15 +257,19 @@ public class Preview extends ViewPart implements ISelectionChangedListener, IPar }
OutputStream os = new FileOutputStream(xwtFile);
- Map<Object, Object> options = new HashMap<Object, Object>();
- //The outputstream cannot be formatted. If format is true, this is
- //the real file (and not the preview file) that will be formatted
- options.put(XWTResource.OPTION_FORMAT, false);
- if(section.getWidget() == null || section.getWidget().eResource() == null) {
- return null;
+ try {
+ Map<Object, Object> options = new HashMap<Object, Object>();
+ //The outputstream cannot be formatted. If format is true, this is
+ //the real file (and not the preview file) that will be formatted
+ options.put(XWTResource.OPTION_FORMAT, false);
+ if(section.getWidget() == null || section.getWidget().eResource() == null) {
+ return null;
+ }
+ section.getWidget().eResource().save(os, options);
+ return xwtFile.toURI().toURL();
+ } finally {
+ os.close();
}
- section.getWidget().eResource().save(os, options);
- return xwtFile.toURI().toURL();
} catch (IOException ex) {
Activator.log.error(ex);
}
@@ -275,7 +279,7 @@ public class Preview extends ViewPart implements ISelectionChangedListener, IPar /**
* Sets the view to display in the preview
- *
+ *
* @param view
* The view to display
*/
@@ -351,6 +355,7 @@ public class Preview extends ViewPart implements ISelectionChangedListener, IPar contents.addListener(SWT.Selection, new Listener() {
+ @Override
public void handleEvent(Event event) {
selectedTab = contents.getSelection().getText();
}
@@ -360,7 +365,7 @@ public class Preview extends ViewPart implements ISelectionChangedListener, IPar for(Section section : currentView.getSections()) {
Composite tabControl = tabs.get(section.getTab());
- if (tabControl == null){
+ if(tabControl == null) {
Activator.log.warn("The section doesn't have a tab"); //Bug in section deletion: it is still referenced by the views
continue;
}
@@ -388,6 +393,7 @@ public class Preview extends ViewPart implements ISelectionChangedListener, IPar Collections.sort(tabs, new Comparator<Tab>() {
+ @Override
public int compare(Tab tab1, Tab tab2) {
Tab afterTab1 = tab1.getAfterTab();
Tab afterTab2 = tab2.getAfterTab();
@@ -429,38 +435,36 @@ public class Preview extends ViewPart implements ISelectionChangedListener, IPar /**
* The preview listens on
- *
+ *
* @param event
* The SelectionChangedEvent
*/
+ @Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection)event.getSelection();
if(selection.size() == 1) {
EObjectTreeElement child = null;
- EObjectTreeElement element = (EObjectTreeElement)selection.getFirstElement();
+ EObjectTreeElement treeElement = (EObjectTreeElement)selection.getFirstElement();
do {
-
- if(element instanceof IAdaptable) {
- EObject adapter = (EObject)((IAdaptable)element).getAdapter(EObject.class);
- if(adapter instanceof View) {
- setView((View)adapter);
- return;
- }
+ EObject semantic = EMFHelper.getEObject(treeElement);
+ if(semantic instanceof View) {
+ setView((View)semantic);
+ return;
}
- child = element;
- EStructuralFeatureTreeElement elementFeature = element.getParent();
- if( elementFeature.getParent()!=null){
- element=elementFeature.getParent();
+ child = treeElement;
+ EStructuralFeatureTreeElement elementFeature = treeElement.getParent();
+ if(elementFeature != null && elementFeature.getParent() != null) {
+ treeElement = elementFeature.getParent();
}
- } while(child != element && element != null);
+ } while(child != treeElement && treeElement != null);
}
}
/**
* Activate or deactivate the preview
- *
+ *
* @param enabled
* If true, the preview will be activated. Otherwise, it will
* be disabled
@@ -474,24 +478,29 @@ public class Preview extends ViewPart implements ISelectionChangedListener, IPar parent.setFocus();
}
+ @Override
public void partActivated(IWorkbenchPart part) {
if(part instanceof UIEditor) {
setEditor((UIEditor)part);
}
}
+ @Override
public void partBroughtToTop(IWorkbenchPart part) {
//Nothing
}
+ @Override
public void partClosed(IWorkbenchPart part) {
//Nothing
}
+ @Override
public void partDeactivated(IWorkbenchPart part) {
//Nothing
}
+ @Override
public void partOpened(IWorkbenchPart part) {
//Nothing
}
diff --git a/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/util/ActionUtil.java b/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/util/ActionUtil.java index 1d3e003df7d..0f607c96240 100644 --- a/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/util/ActionUtil.java +++ b/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/util/ActionUtil.java @@ -16,7 +16,6 @@ import java.util.Iterator; import java.util.LinkedList;
import java.util.List;
-import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
@@ -46,12 +45,8 @@ public class ActionUtil { public static Collection<Object> getAdaptedSelection(Collection<? extends Object> selection) {
Collection<Object> newSelection = new LinkedList<Object>();
for(Object o : selection) {
- if(o instanceof IAdaptable) {
- EObject eObject = (EObject)((IAdaptable)o).getAdapter(EObject.class);
- newSelection.add(eObject);
- } else {
- newSelection.add(o);
- }
+ EObject semantic = EMFHelper.getEObject(o);
+ newSelection.add(semantic == null ? o : semantic);
}
return newSelection;
}
@@ -78,11 +73,7 @@ public class ActionUtil { while(it.hasNext()) {
Object object = it.next();
EObject eObject = EMFHelper.getEObject(object);
- if(eObject != null) {
- newSelection.add(eObject);
- } else {
- newSelection.add(object);
- }
+ newSelection.add(eObject == null ? object : eObject);
}
StructuredSelection selection = new StructuredSelection(newSelection);
diff --git a/plugins/doc/org.eclipse.papyrus.views.properties.doc/pom.xml b/plugins/doc/org.eclipse.papyrus.views.properties.doc/pom.xml new file mode 100644 index 00000000000..2091632ef8c --- /dev/null +++ b/plugins/doc/org.eclipse.papyrus.views.properties.doc/pom.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project> + <modelVersion>4.0.0</modelVersion> + <parent> + <artifactId>org.eclipse.papyrus</artifactId> + <groupId>org.eclipse.papyrus</groupId> + <version>1.0.0-SNAPSHOT</version> + <relativePath>../../../releng/top-pom-main.xml</relativePath> + </parent> + <artifactId>org.eclipse.papyrus.views.properties.doc</artifactId> + <groupId>org.eclipse.papyrus</groupId> + <version>1.0.0-SNAPSHOT</version> + <packaging>eclipse-plugin</packaging> +</project>
\ No newline at end of file diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/src/org/eclipse/papyrus/infra/gmfdiag/modelexplorer/queries/GetContainedDiagrams.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/src/org/eclipse/papyrus/infra/gmfdiag/modelexplorer/queries/GetContainedDiagrams.java index c9ebb4e79b6..967aeec9a60 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/src/org/eclipse/papyrus/infra/gmfdiag/modelexplorer/queries/GetContainedDiagrams.java +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/src/org/eclipse/papyrus/infra/gmfdiag/modelexplorer/queries/GetContainedDiagrams.java @@ -18,13 +18,12 @@ import java.util.Iterator; import java.util.List; import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.util.EcoreUtil; import org.eclipse.gmf.runtime.notation.Diagram; -import org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramUtils; 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.infra.gmfdiag.common.utils.DiagramUtils; import org.eclipse.papyrus.views.modelexplorer.NavigatorUtils; import org.eclipse.papyrus.views.modelexplorer.queries.AbstractEditorContainerQuery; @@ -42,8 +41,9 @@ public class GetContainedDiagrams extends AbstractEditorContainerQuery implement while(roots.hasNext()) { EObject root = roots.next(); if(root instanceof Diagram) { - if (EcoreUtil.equals(DiagramUtils.getOwner((Diagram) root), source)) { - result.add((Diagram)root); + Diagram diagram = (Diagram)root; + if (DiagramUtils.getOwner(diagram) == source) { + result.add(diagram); } } } diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/src/org/eclipse/papyrus/infra/gmfdiag/modelexplorer/queries/IsDiagramContainer.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/src/org/eclipse/papyrus/infra/gmfdiag/modelexplorer/queries/IsDiagramContainer.java index 8eab806acd3..223a6b56b82 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/src/org/eclipse/papyrus/infra/gmfdiag/modelexplorer/queries/IsDiagramContainer.java +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/src/org/eclipse/papyrus/infra/gmfdiag/modelexplorer/queries/IsDiagramContainer.java @@ -1,50 +1,47 @@ -/**
- * Copyright (c) 2011 Atos.
- *
- * 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:
- * Atos - Initial API and implementation
- *
- */
-package org.eclipse.papyrus.infra.gmfdiag.modelexplorer.queries;
-
-import java.util.Iterator;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.gmf.runtime.notation.Diagram;
-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.infra.gmfdiag.common.utils.DiagramUtils;
-import org.eclipse.papyrus.views.modelexplorer.NavigatorUtils;
-import org.eclipse.papyrus.views.modelexplorer.queries.AbstractEditorContainerQuery;
-
-public class IsDiagramContainer extends AbstractEditorContainerQuery implements IJavaQuery2<EObject, Boolean> {
-
- /**
- * Return true if the element is a Diagram Container
- */
- public Boolean evaluate(EObject source, IParameterValueList2 parameterValues, IFacetManager facetManager) throws DerivedTypedElementException {
- Iterator<EObject> roots = NavigatorUtils.getNotationRoots(source);
-
- if(roots != null) {
- while(roots.hasNext()) {
- EObject root = roots.next();
- if(root instanceof Diagram) {
- if(EcoreUtil.equals(DiagramUtils.getOwner((Diagram)root), source)) {
- return true;
- }
- }
- }
- }
-
- return false; //Return super...
- }
-
-}
+/** + * Copyright (c) 2011 Atos. + * + * 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: + * Atos - Initial API and implementation + * + */ +package org.eclipse.papyrus.infra.gmfdiag.modelexplorer.queries; + +import java.util.Iterator; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.gmf.runtime.notation.Diagram; +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.infra.gmfdiag.common.utils.DiagramUtils; +import org.eclipse.papyrus.views.modelexplorer.NavigatorUtils; +import org.eclipse.papyrus.views.modelexplorer.queries.AbstractEditorContainerQuery; + +public class IsDiagramContainer extends AbstractEditorContainerQuery implements IJavaQuery2<EObject, Boolean> { + + /** + * Return true if the element is a Diagram Container + */ + public Boolean evaluate(EObject source, IParameterValueList2 parameterValues, IFacetManager facetManager) throws DerivedTypedElementException { + Iterator<EObject> roots = NavigatorUtils.getNotationRoots(source); + + if(roots != null) { + while(roots.hasNext()) { + EObject root = roots.next(); + if(root instanceof Diagram) { + return DiagramUtils.getOwner((Diagram)root) == source; + } + } + } + + return false; //Return super... + } + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/InteractionOperandAppliedStereotypeLabelDisplayEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/InteractionOperandAppliedStereotypeLabelDisplayEditPolicy.java index d162c874a7f..e648ac49a61 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/InteractionOperandAppliedStereotypeLabelDisplayEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/InteractionOperandAppliedStereotypeLabelDisplayEditPolicy.java @@ -1,57 +1,59 @@ -/*****************************************************************************
- * Copyright (c) 2013 CEA
- *
- *
- * 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:
- * Soyatec - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.edit.policies;
-
-import org.eclipse.gef.EditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeNodeLabelDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.IPapyrusNodeNamedElementFigure;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.IPapyrusNodeUMLElementFigure;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CustomInteractionOperandEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.InteractionOperandGuardEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.InteractionOperandGuardEditPart.GuardFigure;
-import org.eclipse.swt.graphics.Image;
-
-
-/**
- * @author Jin Liu (jin.liu@soyatec.com)
- */
-public class InteractionOperandAppliedStereotypeLabelDisplayEditPolicy extends AppliedStereotypeNodeLabelDisplayEditPolicy {
-
- @Override
- protected void refreshStereotypeDisplay() {
- EditPart host = getHost();
- if(!(host instanceof CustomInteractionOperandEditPart)) {
- return;
- }
- IGraphicalEditPart guard = ((CustomInteractionOperandEditPart)host).getChildBySemanticHint(InteractionOperandGuardEditPart.GUARD_TYPE);
- if(!(guard instanceof InteractionOperandGuardEditPart)) {
- return;
- }
- GuardFigure figure = ((InteractionOperandGuardEditPart)guard).getPrimaryFigure();
- // calculate text and icon to display
- final String stereotypesToDisplay = stereotypesOnlyToDisplay();
- // computes the icon to be displayed
- final Image imageToDisplay = stereotypeIconToDisplay();
-
- // if the string is not empty, then, the figure has to display it.
- // Else, it displays
- // nothing
- // if (stereotypesToDisplay != "" || imageToDisplay != null) {
- if(figure instanceof IPapyrusNodeUMLElementFigure) {
- ((IPapyrusNodeUMLElementFigure)figure).setStereotypeDisplay(tag + (stereotypesOnlyToDisplay().equals("") ? stereotypesToDisplay : stereotypesToDisplay), imageToDisplay);
- refreshAppliedStereotypesProperties(((IPapyrusNodeNamedElementFigure) figure));
- }
- }
-}
+/***************************************************************************** + * Copyright (c) 2013 CEA + * + * + * 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: + * Soyatec - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.sequence.edit.policies; + +import org.eclipse.gef.EditPart; +import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; +import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeNodeLabelDisplayEditPolicy; +import org.eclipse.papyrus.uml.diagram.common.figure.node.IPapyrusNodeNamedElementFigure; +import org.eclipse.papyrus.uml.diagram.common.figure.node.IPapyrusNodeUMLElementFigure; +import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CustomInteractionOperandEditPart; +import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.InteractionOperandGuardEditPart; +import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.InteractionOperandGuardEditPart.GuardFigure; +import org.eclipse.swt.graphics.Image; + + +/** + * @author Jin Liu (jin.liu@soyatec.com) + */ +public class InteractionOperandAppliedStereotypeLabelDisplayEditPolicy extends AppliedStereotypeNodeLabelDisplayEditPolicy { + + @Override + protected void refreshStereotypeDisplay() { + EditPart host = getHost(); + if(!(host instanceof CustomInteractionOperandEditPart)) { + return; + } + IGraphicalEditPart guard = ((CustomInteractionOperandEditPart)host).getChildBySemanticHint(InteractionOperandGuardEditPart.GUARD_TYPE); + if(!(guard instanceof InteractionOperandGuardEditPart)) { + return; + } + GuardFigure figure = ((InteractionOperandGuardEditPart)guard).getPrimaryFigure(); + // calculate text and icon to display + final String stereotypesToDisplay = stereotypesOnlyToDisplay(); + // computes the icon to be displayed + final Image imageToDisplay = stereotypeIconToDisplay(); + + // if the string is not empty, then, the figure has to display it. + // Else, it displays + // nothing + // if (stereotypesToDisplay != "" || imageToDisplay != null) { + if(figure instanceof IPapyrusNodeUMLElementFigure) { + ((IPapyrusNodeUMLElementFigure)figure).setStereotypeDisplay(tag + ("".equals(stereotypesOnlyToDisplay()) ? stereotypesToDisplay : stereotypesToDisplay), imageToDisplay); + if (figure instanceof IPapyrusNodeNamedElementFigure){ + refreshAppliedStereotypesProperties((IPapyrusNodeNamedElementFigure) figure); + } + } + } +} |