summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenoit Maggi2014-04-09 04:57:58 (EDT)
committerBenoit Maggi2014-04-09 04:57:58 (EDT)
commit6bcbe2ba1ef2b71c983b46ef9103aaedbdbb73cc (patch)
treef825c17957104da1920485b06bd729d17a12ff5c
parent6c775487550fe7379997aff0b0cf9d4205b99012 (diff)
downloadorg.eclipse.papyrus-6bcbe2ba1ef2b71c983b46ef9103aaedbdbb73cc.zip
org.eclipse.papyrus-6bcbe2ba1ef2b71c983b46ef9103aaedbdbb73cc.tar.gz
org.eclipse.papyrus-6bcbe2ba1ef2b71c983b46ef9103aaedbdbb73cc.tar.bz2
[Usability] Papyrus shall provide a copy/paste/cut featurerefs/changes/90/24690/1
Add property tester to remove text copy from diagram copy/paster handler Signed-off-by: Benoit Maggi <benoit.maggi@cea.fr> Change-Id: I665470e8e9e2b0c87f37d1e84a677519e413ce16
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/plugin.xml565
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/utils/DiagramPropertyTester.java186
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/plugin.xml16
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/src/org/eclipse/papyrus/infra/gmfdiag/menu/handlers/CopyInDiagramHandler.java42
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/src/org/eclipse/papyrus/infra/gmfdiag/menu/handlers/PasteInDiagramHandler.java62
5 files changed, 494 insertions, 377 deletions
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/plugin.xml b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/plugin.xml
index f034500..e9de87c 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/plugin.xml
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/plugin.xml
@@ -1,285 +1,292 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.0"?>
-
-<plugin>
- <extension-point id="nestedEditor" name="NestedEditor" schema="schema/nestedEditor.exsd"/>
- <extension-point id="initializeView" name="initializeView" schema="schema/initializeView.exsd"/>
- <extension-point id="shapeProvider" name="ShapeProvider" schema="schema/shapeProvider.exsd"/>
- <extension-point id="notationTypesMapping" name="notationTypesMapping" schema="schema/notationTypesMapping.exsd"/>
- <extension-point id="svgPostProcessors" name="svgPostProcessors" schema="schema/svgPostProcessors.exsd"/>
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
+
+<plugin>
+ <extension-point id="nestedEditor" name="NestedEditor" schema="schema/nestedEditor.exsd"/>
+ <extension-point id="initializeView" name="initializeView" schema="schema/initializeView.exsd"/>
+ <extension-point id="shapeProvider" name="ShapeProvider" schema="schema/shapeProvider.exsd"/>
+ <extension-point id="notationTypesMapping" name="notationTypesMapping" schema="schema/notationTypesMapping.exsd"/>
+ <extension-point id="svgPostProcessors" name="svgPostProcessors" schema="schema/svgPostProcessors.exsd"/>
<extension-point id="pasteCommandProvider" name="pasteCommandProvider" schema="schema/pasteCommandProvider.exsd"/>
<extension-point id="pasteStrategy" name="pasteStrategy" schema="schema/pasteStrategy.exsd"/>
<extension-point id="copyStrategy" name="copyStrategy" schema="schema/copyStrategy.exsd"/>
-
-<extension
- point="org.eclipse.ui.handlers">
- <handler
- class="org.eclipse.papyrus.infra.gmfdiag.common.handler.RefreshHandler"
- commandId="org.eclipse.ui.file.refresh">
- <activeWhen>
- <with
- variable="activePartId">
- <equals
- value="org.eclipse.papyrus.infra.core.papyrusEditor">
- </equals>
- </with>
- </activeWhen>
- </handler>
-</extension>
-<extension
- point="org.eclipse.ui.menus">
- <menuContribution
- allPopups="false"
- locationURI="toolbar:org.eclipes.papyrus.menu.toolbar">
- <command
- commandId="org.eclipse.ui.file.refresh"
- icon="icons/refresh.gif"
- label="Refresh"
- style="push"
- tooltip="Refresh the current diagram">
- <visibleWhen
- checkEnabled="false">
- <with
- variable="activeEditorId">
- <equals
- value="org.eclipse.papyrus.infra.core.papyrusEditor">
- </equals>
- </with>
- </visibleWhen>
- </command>
- </menuContribution>
-</extension>
-<extension
- point="org.eclipse.ui.preferencePages">
- <page
- category="org.eclipse.papyrus.infra.core.sasheditor.preferences.generalcategory"
- class="org.eclipse.papyrus.infra.gmfdiag.common.preferences.ConnectionToolPreferencePage"
- id="org.eclipse.papyrus.infra.gmfdiag.common.connectionTools"
- name="Connection Tools">
- </page>
+
+<extension
+ point="org.eclipse.ui.handlers">
+ <handler
+ class="org.eclipse.papyrus.infra.gmfdiag.common.handler.RefreshHandler"
+ commandId="org.eclipse.ui.file.refresh">
+ <activeWhen>
+ <with
+ variable="activePartId">
+ <equals
+ value="org.eclipse.papyrus.infra.core.papyrusEditor">
+ </equals>
+ </with>
+ </activeWhen>
+ </handler>
+</extension>
+<extension
+ point="org.eclipse.ui.menus">
+ <menuContribution
+ allPopups="false"
+ locationURI="toolbar:org.eclipes.papyrus.menu.toolbar">
+ <command
+ commandId="org.eclipse.ui.file.refresh"
+ icon="icons/refresh.gif"
+ label="Refresh"
+ style="push"
+ tooltip="Refresh the current diagram">
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="activeEditorId">
+ <equals
+ value="org.eclipse.papyrus.infra.core.papyrusEditor">
+ </equals>
+ </with>
+ </visibleWhen>
+ </command>
+ </menuContribution>
+</extension>
+<extension
+ point="org.eclipse.ui.preferencePages">
+ <page
+ category="org.eclipse.papyrus.infra.core.sasheditor.preferences.generalcategory"
+ class="org.eclipse.papyrus.infra.gmfdiag.common.preferences.ConnectionToolPreferencePage"
+ id="org.eclipse.papyrus.infra.gmfdiag.common.connectionTools"
+ name="Connection Tools">
+ </page>
<page
category="org.eclipse.papyrus.infra.core.sasheditor.preferences.generalcategory"
class="org.eclipse.papyrus.infra.gmfdiag.common.preferences.PastePreferencesPage"
id="org.eclipse.papyrus.infra.gmfdiag.paste.preferences"
name="Paste">
</page>
-</extension>
-<extension
- point="org.eclipse.core.runtime.preferences">
- <initializer
- class="org.eclipse.papyrus.infra.gmfdiag.common.preferences.ConnectionToolPreferenceInitializer">
- </initializer>
-</extension>
- <extension
- point="org.eclipse.papyrus.infra.core.model">
- <model
- classname="org.eclipse.papyrus.infra.gmfdiag.common.model.NotationModel"
- description="Model for notation"
- fileExtension="notation">
- </model>
- </extension>
-
-
- <extension
- point="org.eclipse.emf.ecore.extension_parser">
- <parser
- class="org.eclipse.gmf.runtime.emf.core.resources.GMFResourceFactory"
- type="notation">
- </parser>
- </extension>
-<extension
- point="org.eclipse.papyrus.infra.core.service">
- <serviceFactory
- classname="org.eclipse.papyrus.infra.gmfdiag.common.undocontext.UndoContextServiceFactory"
- description="The shared IUndoContext used to tag command in the CommandStack"
- id="org.eclipse.core.commands.operations.IUndoContext"
- priority="1"
- startKind="lazy">
- <dependsOn
- serviceKeyRef="org.eclipse.emf.transaction.TransactionalEditingDomain">
- </dependsOn>
- </serviceFactory>
- <service
- classname="org.eclipse.papyrus.infra.gmfdiag.common.DefaultGraphicalEditorSupport"
- description="The default diagram editor support implementation."
- id="org.eclipse.papyrus.infra.gmfdiag.common.IGraphicalEditorSupport"
- priority="1"
- startKind="lazy">
- </service>
- </extension>
-<extension
- point="org.eclipse.papyrus.infra.services.labelprovider.labelProvider">
- <labelProvider
- priority="40"
- provider="org.eclipse.papyrus.infra.gmfdiag.common.providers.NotationFilteredLabelProvider">
- </labelProvider>
-</extension>
-<extension
- point="org.eclipse.gmf.runtime.diagram.ui.decoratorProviders">
- <decoratorProvider
- class="org.eclipse.papyrus.infra.gmfdiag.common.providers.ShapeDecoratorProvider">
- <Priority
- name="Lowest">
- </Priority>
- </decoratorProvider>
-</extension>
-<extension
- point="org.eclipse.core.runtime.adapters">
- <factory
- adaptableType="org.eclipse.gmf.runtime.notation.Diagram"
- class="org.eclipse.papyrus.infra.gmfdiag.common.adapter.DiagramAdapterFactory">
- <adapter
- type="org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.IOpenable">
- </adapter>
- </factory>
-</extension>
-
-<!-- ElementType bindings for diagram duplication with paste command -->
- <extension
- point="org.eclipse.gmf.runtime.emf.type.core.elementTypes">
- <metamodel
- nsURI="http://www.eclipse.org/emf/2002/Ecore">
- <adviceBinding
- class="org.eclipse.papyrus.infra.gmfdiag.common.advice.GMFDiagramDuplicateEditHelperAdvice"
- id="org.eclipse.papyrus.infra.gmfdiag.common.advice.GMFDiagramDuplicateEditHelperAdvice"
- inheritance="none"
- typeId="*">
- </adviceBinding>
- </metamodel>
- </extension>
-
-<extension point="org.eclipse.gmf.runtime.emf.type.core.elementTypeBindings">
-
- <!-- Bindings declaration -->
- <binding context="org.eclipse.papyrus.infra.services.edit.TypeContext">
- <advice ref="org.eclipse.papyrus.infra.gmfdiag.common.advice.GMFDiagramDuplicateEditHelperAdvice" />
- </binding>
-</extension>
-<extension
- point="org.eclipse.gmf.runtime.emf.type.core.elementTypes">
- <metamodel
- nsURI="http://www.eclipse.org/gmf/runtime/1.0.2/notation">
- <metamodelType
- eclass="Diagram"
- edithelper="org.eclipse.papyrus.infra.gmfdiag.common.helper.DiagramEditHelper"
- id="org.eclipse.papyrus.infra.gmfdiag.common.DiagramElementType"
- name="Diagram">
- </metamodelType>
- </metamodel>
-</extension>
-<extension
- point="org.eclipse.gmf.runtime.emf.type.core.elementTypeBindings">
- <binding
- context="org.eclipse.papyrus.infra.services.edit.TypeContext">
- <elementType
- ref="org.eclipse.papyrus.infra.gmfdiag.common.DiagramElementType">
- </elementType>
- </binding>
-</extension>
-<extension
- point="org.eclipse.core.expressions.propertyTesters">
- <propertyTester
- class="org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramPropertyTester"
- id="org.eclipse.papyrus.infra.gmfdiag.common.diagram.tester"
- namespace="org.eclipse.papyrus.infra.gmfdiag.common.diagram.tester"
- properties="isDiagramEditor"
- type="org.eclipse.jface.viewers.IStructuredSelection">
- </propertyTester>
- <propertyTester
- class="org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramPropertyTester"
- id="org.eclipse.papyrus.infra.gmfdiag.common.diagram.context.tester"
- namespace="org.eclipse.papyrus.infra.gmfdiag.common.diagram.context.tester"
- properties="isGmfDiagramContextActive"
- type="java.util.Collection">
+</extension>
+<extension
+ point="org.eclipse.core.runtime.preferences">
+ <initializer
+ class="org.eclipse.papyrus.infra.gmfdiag.common.preferences.ConnectionToolPreferenceInitializer">
+ </initializer>
+</extension>
+ <extension
+ point="org.eclipse.papyrus.infra.core.model">
+ <model
+ classname="org.eclipse.papyrus.infra.gmfdiag.common.model.NotationModel"
+ description="Model for notation"
+ fileExtension="notation">
+ </model>
+ </extension>
+
+
+ <extension
+ point="org.eclipse.emf.ecore.extension_parser">
+ <parser
+ class="org.eclipse.gmf.runtime.emf.core.resources.GMFResourceFactory"
+ type="notation">
+ </parser>
+ </extension>
+<extension
+ point="org.eclipse.papyrus.infra.core.service">
+ <serviceFactory
+ classname="org.eclipse.papyrus.infra.gmfdiag.common.undocontext.UndoContextServiceFactory"
+ description="The shared IUndoContext used to tag command in the CommandStack"
+ id="org.eclipse.core.commands.operations.IUndoContext"
+ priority="1"
+ startKind="lazy">
+ <dependsOn
+ serviceKeyRef="org.eclipse.emf.transaction.TransactionalEditingDomain">
+ </dependsOn>
+ </serviceFactory>
+ <service
+ classname="org.eclipse.papyrus.infra.gmfdiag.common.DefaultGraphicalEditorSupport"
+ description="The default diagram editor support implementation."
+ id="org.eclipse.papyrus.infra.gmfdiag.common.IGraphicalEditorSupport"
+ priority="1"
+ startKind="lazy">
+ </service>
+ </extension>
+<extension
+ point="org.eclipse.papyrus.infra.services.labelprovider.labelProvider">
+ <labelProvider
+ priority="40"
+ provider="org.eclipse.papyrus.infra.gmfdiag.common.providers.NotationFilteredLabelProvider">
+ </labelProvider>
+</extension>
+<extension
+ point="org.eclipse.gmf.runtime.diagram.ui.decoratorProviders">
+ <decoratorProvider
+ class="org.eclipse.papyrus.infra.gmfdiag.common.providers.ShapeDecoratorProvider">
+ <Priority
+ name="Lowest">
+ </Priority>
+ </decoratorProvider>
+</extension>
+<extension
+ point="org.eclipse.core.runtime.adapters">
+ <factory
+ adaptableType="org.eclipse.gmf.runtime.notation.Diagram"
+ class="org.eclipse.papyrus.infra.gmfdiag.common.adapter.DiagramAdapterFactory">
+ <adapter
+ type="org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.IOpenable">
+ </adapter>
+ </factory>
+</extension>
+
+<!-- ElementType bindings for diagram duplication with paste command -->
+ <extension
+ point="org.eclipse.gmf.runtime.emf.type.core.elementTypes">
+ <metamodel
+ nsURI="http://www.eclipse.org/emf/2002/Ecore">
+ <adviceBinding
+ class="org.eclipse.papyrus.infra.gmfdiag.common.advice.GMFDiagramDuplicateEditHelperAdvice"
+ id="org.eclipse.papyrus.infra.gmfdiag.common.advice.GMFDiagramDuplicateEditHelperAdvice"
+ inheritance="none"
+ typeId="*">
+ </adviceBinding>
+ </metamodel>
+ </extension>
+
+<extension point="org.eclipse.gmf.runtime.emf.type.core.elementTypeBindings">
+
+ <!-- Bindings declaration -->
+ <binding context="org.eclipse.papyrus.infra.services.edit.TypeContext">
+ <advice ref="org.eclipse.papyrus.infra.gmfdiag.common.advice.GMFDiagramDuplicateEditHelperAdvice" />
+ </binding>
+</extension>
+<extension
+ point="org.eclipse.gmf.runtime.emf.type.core.elementTypes">
+ <metamodel
+ nsURI="http://www.eclipse.org/gmf/runtime/1.0.2/notation">
+ <metamodelType
+ eclass="Diagram"
+ edithelper="org.eclipse.papyrus.infra.gmfdiag.common.helper.DiagramEditHelper"
+ id="org.eclipse.papyrus.infra.gmfdiag.common.DiagramElementType"
+ name="Diagram">
+ </metamodelType>
+ </metamodel>
+</extension>
+<extension
+ point="org.eclipse.gmf.runtime.emf.type.core.elementTypeBindings">
+ <binding
+ context="org.eclipse.papyrus.infra.services.edit.TypeContext">
+ <elementType
+ ref="org.eclipse.papyrus.infra.gmfdiag.common.DiagramElementType">
+ </elementType>
+ </binding>
+</extension>
+<extension
+ point="org.eclipse.core.expressions.propertyTesters">
+ <propertyTester
+ class="org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramPropertyTester"
+ id="org.eclipse.papyrus.infra.gmfdiag.common.diagram.tester"
+ namespace="org.eclipse.papyrus.infra.gmfdiag.common.diagram.tester"
+ properties="isDiagramEditor"
+ type="org.eclipse.jface.viewers.IStructuredSelection">
+ </propertyTester>
+ <propertyTester
+ class="org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramPropertyTester"
+ id="org.eclipse.papyrus.infra.gmfdiag.common.diagram.context.tester"
+ namespace="org.eclipse.papyrus.infra.gmfdiag.common.diagram.context.tester"
+ properties="isGmfDiagramContextActive"
+ type="java.util.Collection">
</propertyTester>
+ <propertyTester
+ class="org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramPropertyTester"
+ id="org.eclipse.papyrus.infra.gmfdiag.common.diagram.text.tester"
+ namespace="org.eclipse.papyrus.infra.gmfdiag.common.diagram.text.tester"
+ properties="isTextZone"
+ type="org.eclipse.swt.widgets.Shell">
+ </propertyTester>
+</extension>
+<extension
+ point="org.eclipse.ui.menus">
+ <menuContribution
+ locationURI="popup:org.eclipse.papyrus.views.modelexplorer.popupmenu.creatediagram">
+ <dynamic
+ class="org.eclipse.papyrus.infra.gmfdiag.common.handler.DynamicDiagramsMenuContribution"
+ id="org.eclipse.papyrus.infra.gmfdiag.common.handler.DynamicDiagramsMenuContribution">
+ </dynamic>
+ </menuContribution>
+ <menuContribution
+ allPopups="false"
+ locationURI="menu:org.eclipse.papyrus.ui.menu">
+ <menu
+ icon="platform:/plugin/org.eclipse.papyrus.infra.viewpoints.policy/icons/NewDiagram.gif"
+ id="org.eclipse.papyrus.uml.diagram.ui.menu.diagrams"
+ label="New Diagram">
+ <dynamic
+ class="org.eclipse.papyrus.infra.gmfdiag.common.handler.DynamicDiagramsMenuContribution"
+ id="org.eclipse.papyrus.infra.gmfdiag.common.handler.DynamicDiagramsMenuContribution">
+ </dynamic>
+ </menu>
+ </menuContribution>
+ <menuContribution
+ allPopups="false"
+ locationURI="toolbar:org.eclipse.ui.main.toolbar">
+ <toolbar
+ id="org.eclipse.papyrus.infra.viewpoints.policy.toolbar">
+ <command
+ commandId="org.eclipse.papyrus.infra.viewpoints.policy.toolbar.diagrams.command"
+ icon="platform:/plugin/org.eclipse.papyrus.infra.viewpoints.policy/icons/NewDiagram.gif"
+ id="org.eclipse.papyrus.infra.viewpoints.policy.toolbar.diagrams"
+ label="Create a new diagram ..."
+ style="pulldown"
+ tooltip="Create a new diagram ...">
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="activeEditorId">
+ <equals
+ value="org.eclipse.papyrus.infra.core.papyrusEditor">
+ </equals>
+ </with>
+ </visibleWhen>
+ </command>
+ </toolbar>
+ </menuContribution>
+ <menuContribution
+ allPopups="false"
+ locationURI="menu:org.eclipse.papyrus.infra.viewpoints.policy.toolbar.diagrams">
+ <dynamic
+ class="org.eclipse.papyrus.infra.gmfdiag.common.handler.DynamicDiagramsMenuContribution"
+ id="org.eclipse.papyrus.infra.gmfdiag.common.handler.DynamicDiagramsMenuContribution">
+ </dynamic>
+ </menuContribution>
+</extension>
+<extension
+ point="org.eclipse.ui.commands">
+ <command
+ categoryId="org.eclipse.papyrus.infra.viewpoints.policy.commands"
+ defaultHandler="org.eclipse.papyrus.infra.viewpoints.policy.DynamicCommandHandler"
+ id="org.eclipse.papyrus.infra.viewpoints.policy.toolbar.diagrams.command"
+ name="Create Dynamic Diagram Command">
+ </command>
+</extension>
+<extension
+ point="org.eclipse.papyrus.infra.viewpoints.policy.viewType">
+ <helper
+ class="org.eclipse.papyrus.infra.gmfdiag.common.helper.GMFDiagramViewTypeHelper">
+ </helper>
+</extension>
+<extension
+ point="org.eclipse.papyrus.infra.gmfdiag.common.shapeProvider">
+ <shapeProvider
+ class="org.eclipse.papyrus.infra.gmfdiag.common.providers.StyleBasedShapeProvider"
+ description="Provides shapes based on the applied styles."
+ id="org.eclipse.papyrus.infra.gmfdiag.common.providers.StyleBasedShapeProvider"
+ name="StyleBasedShapeProvider">
+ <Priority
+ name="Low"></Priority>
+ </shapeProvider>
</extension>
-<extension
- point="org.eclipse.ui.menus">
- <menuContribution
- locationURI="popup:org.eclipse.papyrus.views.modelexplorer.popupmenu.creatediagram">
- <dynamic
- class="org.eclipse.papyrus.infra.gmfdiag.common.handler.DynamicDiagramsMenuContribution"
- id="org.eclipse.papyrus.infra.gmfdiag.common.handler.DynamicDiagramsMenuContribution">
- </dynamic>
- </menuContribution>
- <menuContribution
- allPopups="false"
- locationURI="menu:org.eclipse.papyrus.ui.menu">
- <menu
- icon="platform:/plugin/org.eclipse.papyrus.infra.viewpoints.policy/icons/NewDiagram.gif"
- id="org.eclipse.papyrus.uml.diagram.ui.menu.diagrams"
- label="New Diagram">
- <dynamic
- class="org.eclipse.papyrus.infra.gmfdiag.common.handler.DynamicDiagramsMenuContribution"
- id="org.eclipse.papyrus.infra.gmfdiag.common.handler.DynamicDiagramsMenuContribution">
- </dynamic>
- </menu>
- </menuContribution>
- <menuContribution
- allPopups="false"
- locationURI="toolbar:org.eclipse.ui.main.toolbar">
- <toolbar
- id="org.eclipse.papyrus.infra.viewpoints.policy.toolbar">
- <command
- commandId="org.eclipse.papyrus.infra.viewpoints.policy.toolbar.diagrams.command"
- icon="platform:/plugin/org.eclipse.papyrus.infra.viewpoints.policy/icons/NewDiagram.gif"
- id="org.eclipse.papyrus.infra.viewpoints.policy.toolbar.diagrams"
- label="Create a new diagram ..."
- style="pulldown"
- tooltip="Create a new diagram ...">
- <visibleWhen
- checkEnabled="false">
- <with
- variable="activeEditorId">
- <equals
- value="org.eclipse.papyrus.infra.core.papyrusEditor">
- </equals>
- </with>
- </visibleWhen>
- </command>
- </toolbar>
- </menuContribution>
- <menuContribution
- allPopups="false"
- locationURI="menu:org.eclipse.papyrus.infra.viewpoints.policy.toolbar.diagrams">
- <dynamic
- class="org.eclipse.papyrus.infra.gmfdiag.common.handler.DynamicDiagramsMenuContribution"
- id="org.eclipse.papyrus.infra.gmfdiag.common.handler.DynamicDiagramsMenuContribution">
- </dynamic>
- </menuContribution>
-</extension>
-<extension
- point="org.eclipse.ui.commands">
- <command
- categoryId="org.eclipse.papyrus.infra.viewpoints.policy.commands"
- defaultHandler="org.eclipse.papyrus.infra.viewpoints.policy.DynamicCommandHandler"
- id="org.eclipse.papyrus.infra.viewpoints.policy.toolbar.diagrams.command"
- name="Create Dynamic Diagram Command">
- </command>
-</extension>
-<extension
- point="org.eclipse.papyrus.infra.viewpoints.policy.viewType">
- <helper
- class="org.eclipse.papyrus.infra.gmfdiag.common.helper.GMFDiagramViewTypeHelper">
- </helper>
-</extension>
-<extension
- point="org.eclipse.papyrus.infra.gmfdiag.common.shapeProvider">
- <shapeProvider
- class="org.eclipse.papyrus.infra.gmfdiag.common.providers.StyleBasedShapeProvider"
- description="Provides shapes based on the applied styles."
- id="org.eclipse.papyrus.infra.gmfdiag.common.providers.StyleBasedShapeProvider"
- name="StyleBasedShapeProvider">
- <Priority
- name="Low"></Priority>
- </shapeProvider>
-</extension>
-<extension
- point="org.eclipse.papyrus.infra.gmfdiag.common.notationTypesMapping">
- <mapping
- humanReadableType="symbol"
- type="compartment_shape_display">
- </mapping>
+<extension
+ point="org.eclipse.papyrus.infra.gmfdiag.common.notationTypesMapping">
+ <mapping
+ humanReadableType="symbol"
+ type="compartment_shape_display">
+ </mapping>
</extension>
<extension
point="org.eclipse.papyrus.infra.services.decoration.decorationSpecificFunctions">
@@ -296,11 +303,11 @@
name="Lowest">
</Priority>
</editpolicyProvider>
-</extension>
-<extension
- point="org.eclipse.papyrus.infra.gmfdiag.commands.historyListeners">
- <historyListener
- class="org.eclipse.papyrus.infra.gmfdiag.common.listener.RollbackNotificationHistoryListener">
- </historyListener>
-</extension>
-</plugin>
+</extension>
+<extension
+ point="org.eclipse.papyrus.infra.gmfdiag.commands.historyListeners">
+ <historyListener
+ class="org.eclipse.papyrus.infra.gmfdiag.common.listener.RollbackNotificationHistoryListener">
+ </historyListener>
+</extension>
+</plugin>
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/utils/DiagramPropertyTester.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/utils/DiagramPropertyTester.java
index 238a66b..cf82db0 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/utils/DiagramPropertyTester.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/utils/DiagramPropertyTester.java
@@ -1,80 +1,106 @@
-/*****************************************************************************
- * 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:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.gmfdiag.common.utils;
-
-import java.util.Collection;
-
-import org.eclipse.core.expressions.PropertyTester;
-import org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.papyrus.infra.tools.util.WorkbenchPartHelper;
-import org.eclipse.papyrus.infra.tools.util.EditorHelper;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.PlatformUI;
-
-
-public class DiagramPropertyTester extends PropertyTester {
-
- /** property to test if the selected element are open in the editor */
- public static final String IS_DIAGRAM_EDITOR = "isDiagramEditor"; //$NON-NLS-1$
-
- /**
- * property to test if the GMF Diagram context is active
- */
- public static final String IS_GMF_DIAGRAM_CONTEXT_ACTIVE = "isGmfDiagramContextActive"; //$NON-NLS-1$
-
- /**
- *
- * {@inheritDoc}
- */
- public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
- if(IS_DIAGRAM_EDITOR.equals(property) && receiver instanceof IStructuredSelection) {
- //FIXME : we should be able to replace the calls to this test in the plugin.xml by :
- // activeWhen -> with -> activeEditor -> adapt -> IDiagramWorkbenchPart. unfortunately, this method doesn't work, the adapt test is correct, but the Eclipse handler system
- //find often several handlers actived in the same time and choose one of them (and never the Papyrus handler...)
- boolean answer = isDiagramEditor((IStructuredSelection)receiver);
- return new Boolean(answer).equals(expectedValue);
- } else if(IS_GMF_DIAGRAM_CONTEXT_ACTIVE.equals(property) && receiver instanceof Collection<?>) {
- boolean answer = isDiagramContextActive((Collection<?>)receiver);
- return new Boolean(answer).equals(expectedValue);
- }
- return false;
- }
-
- /**
- *
- * @param selection
- * @return
- * <code>true</code> if the current active part is a Papyrus Diagram
- */
- private boolean isDiagramEditor(IStructuredSelection selection) {
- final IWorkbenchPart part = WorkbenchPartHelper.getCurrentActiveWorkbenchPart();
- if(part != null) {
- final IDiagramWorkbenchPart diagramPart = (IDiagramWorkbenchPart)part.getAdapter(IDiagramWorkbenchPart.class);
- return diagramPart != null;
- }
- return false;
- }
-
- /**
- *
- * @param context
- *
- * @return
- */
- private boolean isDiagramContextActive(final Collection<?> activeContextIds) {
- return activeContextIds.contains("org.eclipse.gmf.runtime.diagram.ui.diagramContext"); //$NON-NLS-1$
- }
-}
+/*****************************************************************************
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.gmfdiag.common.utils;
+
+import java.util.Collection;
+
+import org.eclipse.core.expressions.PropertyTester;
+import org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.papyrus.infra.tools.util.WorkbenchPartHelper;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IWorkbenchPart;
+
+
+public class DiagramPropertyTester extends PropertyTester {
+
+ /** property to test if the selected element are open in the editor */
+ public static final String IS_DIAGRAM_EDITOR = "isDiagramEditor"; //$NON-NLS-1$
+
+ /**
+ * property to test if the GMF Diagram context is active
+ */
+ public static final String IS_GMF_DIAGRAM_CONTEXT_ACTIVE = "isGmfDiagramContextActive"; //$NON-NLS-1$
+
+ /**
+ * property to test if the focus is on a text zone or an internal xtext editor
+ */
+ public static final String IS_TEXT_ZONE = "isTextZone"; //$NON-NLS-1$
+
+
+ /**
+ *
+ * {@inheritDoc}
+ */
+ public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
+ if(IS_DIAGRAM_EDITOR.equals(property) && receiver instanceof IStructuredSelection) {
+ //FIXME : we should be able to replace the calls to this test in the plugin.xml by :
+ // activeWhen -> with -> activeEditor -> adapt -> IDiagramWorkbenchPart. unfortunately, this method doesn't work, the adapt test is correct, but the Eclipse handler system
+ //find often several handlers actived in the same time and choose one of them (and never the Papyrus handler...)
+ boolean answer = isDiagramEditor((IStructuredSelection)receiver);
+ return new Boolean(answer).equals(expectedValue);
+ } else if(IS_GMF_DIAGRAM_CONTEXT_ACTIVE.equals(property) && receiver instanceof Collection<?>) {
+ boolean answer = isDiagramContextActive((Collection<?>)receiver);
+ return new Boolean(answer).equals(expectedValue);
+ } else if (IS_TEXT_ZONE.equals(property) && receiver instanceof Shell){
+ boolean answer = isTextZone((Shell)receiver);
+ return new Boolean(answer).equals(expectedValue);
+ }
+ return false;
+ }
+
+ /**
+ * @param shell
+ * @return <code>true</code> if the focus is on a text zone or an internal xtext editor
+ */
+ private boolean isTextZone(Shell shell) {
+ Display display = shell.getDisplay();
+ if (display != null){
+ Control focusControl = display.getFocusControl();
+ if (focusControl instanceof StyledText || focusControl instanceof Text){
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ *
+ * @param selection
+ * @return
+ * <code>true</code> if the current active part is a Papyrus Diagram
+ */
+ private boolean isDiagramEditor(IStructuredSelection selection) {
+ final IWorkbenchPart part = WorkbenchPartHelper.getCurrentActiveWorkbenchPart();
+ if(part != null) {
+ final IDiagramWorkbenchPart diagramPart = (IDiagramWorkbenchPart)part.getAdapter(IDiagramWorkbenchPart.class);
+ return diagramPart != null;
+ }
+ return false;
+ }
+
+ /**
+ *
+ * @param context
+ *
+ * @return
+ */
+ private boolean isDiagramContextActive(final Collection<?> activeContextIds) {
+ return activeContextIds.contains("org.eclipse.gmf.runtime.diagram.ui.diagramContext"); //$NON-NLS-1$
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/plugin.xml b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/plugin.xml
index 472622a..20bd41e 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/plugin.xml
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/plugin.xml
@@ -139,6 +139,14 @@
value="true">
</test>
</with>
+ <with
+ variable="activeShell">
+ <test
+ forcePluginActivation="true"
+ property="org.eclipse.papyrus.infra.gmfdiag.common.diagram.tester.isTextZone"
+ value="false">
+ </test>
+ </with>
</and>
</activeWhen>
</handler>
@@ -162,6 +170,14 @@
value="true">
</test>
</with>
+ <with
+ variable="activeShell">
+ <test
+ forcePluginActivation="true"
+ property="org.eclipse.papyrus.infra.gmfdiag.common.diagram.tester.isTextZone"
+ value="false">
+ </test>
+ </with>
</and>
</activeWhen>
</handler>
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/src/org/eclipse/papyrus/infra/gmfdiag/menu/handlers/CopyInDiagramHandler.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/src/org/eclipse/papyrus/infra/gmfdiag/menu/handlers/CopyInDiagramHandler.java
index 507ee4e..5786fcc 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/src/org/eclipse/papyrus/infra/gmfdiag/menu/handlers/CopyInDiagramHandler.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/src/org/eclipse/papyrus/infra/gmfdiag/menu/handlers/CopyInDiagramHandler.java
@@ -17,6 +17,7 @@ package org.eclipse.papyrus.infra.gmfdiag.menu.handlers;
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.core.expressions.IEvaluationContext;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gef.commands.Command;
import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart;
@@ -35,6 +36,11 @@ import org.eclipse.papyrus.infra.gmfdiag.common.strategy.IStrategy;
import org.eclipse.papyrus.infra.gmfdiag.common.strategy.paste.IPasteStrategy;
import org.eclipse.papyrus.infra.gmfdiag.common.strategy.paste.PasteStrategyManager;
import org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramEditPartsUtil;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
/**
* Handler for the Copy Action in Diagram
@@ -82,11 +88,43 @@ public class CopyInDiagramHandler extends AbstractGraphicalCommandHandler {
return result;
}
-
+
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.infra.gmfdiag.menu.handlers.AbstractGraphicalCommandHandler#setEnabled(java.lang.Object)
+ */
+ @Override
+ public void setEnabled(Object evaluationContext) {
+ if(evaluationContext instanceof IEvaluationContext) {
+ IEvaluationContext iEvaluationContext = (IEvaluationContext)evaluationContext;
+ Object activeFocusControl = iEvaluationContext.getVariable("activeFocusControl"); //$NON-NLS-1$
+ Object activeShell = iEvaluationContext.getVariable("activeShell"); //$NON-NLS-1$
+ Control focusControl = null;
+ if(activeShell instanceof Shell) {
+ Shell shell = (Shell)activeShell;
+ Display display = shell.getDisplay();
+ if(display != null) {
+ focusControl = display.getFocusControl();
+ }
+ }
+ if(activeFocusControl instanceof StyledText || focusControl instanceof Text) { // true if the focus is on an internal xtext editor or a text edit
+ setBaseEnabled(false);
+ } else {
+ super.setEnabled(evaluationContext);
+ }
+ }
+ }
+
+
+
+
//
// Nested classes
//
-
+
@SuppressWarnings("restriction")
private static class MyCopyImageCommand extends org.eclipse.gmf.runtime.diagram.ui.render.internal.commands.CopyImageCommand implements INonDirtying {
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/src/org/eclipse/papyrus/infra/gmfdiag/menu/handlers/PasteInDiagramHandler.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/src/org/eclipse/papyrus/infra/gmfdiag/menu/handlers/PasteInDiagramHandler.java
index 14c5fb0..3edbcca 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/src/org/eclipse/papyrus/infra/gmfdiag/menu/handlers/PasteInDiagramHandler.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.menu/src/org/eclipse/papyrus/infra/gmfdiag/menu/handlers/PasteInDiagramHandler.java
@@ -15,6 +15,7 @@ package org.eclipse.papyrus.infra.gmfdiag.menu.handlers;
import java.util.List;
+import org.eclipse.core.expressions.IEvaluationContext;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.commands.UnexecutableCommand;
import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
@@ -23,10 +24,15 @@ import org.eclipse.papyrus.infra.core.clipboard.PapyrusClipboard;
import org.eclipse.papyrus.infra.gmfdiag.common.strategy.IStrategy;
import org.eclipse.papyrus.infra.gmfdiag.common.strategy.paste.IPasteStrategy;
import org.eclipse.papyrus.infra.gmfdiag.common.strategy.paste.PasteStrategyManager;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
/**
- * The handler for the paste with model in Diagram
+ * The handler for the paste with model in Diagram
*
*/
public class PasteInDiagramHandler extends AbstractGraphicalCommandHandler {
@@ -39,30 +45,54 @@ public class PasteInDiagramHandler extends AbstractGraphicalCommandHandler {
*/
@Override
protected Command getCommand() {
-
PapyrusClipboard.getInstance().resetTarget();
-
List<IGraphicalEditPart> selectedElements = getSelectedElements();
- if (selectedElements.size() == 1){ // Paste is only enabled on a simple selection
- //if (PapyrusClipboard.getInstance().size() > 0) { // TODO : Paste is only enabled if there is something inside the clipboard
- GraphicalEditPart targetOwnerEditPart = (GraphicalEditPart) selectedElements.get(0);
+ if(selectedElements.size() == 1) { // Paste is only enabled on a simple selection
+ GraphicalEditPart targetOwnerEditPart = (GraphicalEditPart)selectedElements.get(0);
org.eclipse.gef.commands.CompoundCommand compoundCommand = new org.eclipse.gef.commands.CompoundCommand("Paste all elements"); //$NON-NLS-1$
-
- List<IStrategy> allStrategies = PasteStrategyManager.getInstance()
- .getAllActiveStrategies();
- for (IStrategy iStrategy : allStrategies) {
- IPasteStrategy iPasteStrategy = (IPasteStrategy) iStrategy;
+
+ List<IStrategy> allStrategies = PasteStrategyManager.getInstance().getAllActiveStrategies();
+ for(IStrategy iStrategy : allStrategies) {
+ IPasteStrategy iPasteStrategy = (IPasteStrategy)iStrategy;
Command graphicalCommand = iPasteStrategy.getGraphicalCommand(getEditingDomain(), targetOwnerEditPart, PapyrusClipboard.getInstance());
- if (graphicalCommand!=null) {
+ if(graphicalCommand != null) {
compoundCommand.add(graphicalCommand);
}
}
- return compoundCommand;
- // }
+ return compoundCommand;
}
return UnexecutableCommand.INSTANCE;
}
- // TODO : setEnable if selection.size == 1 and Papyrus Clipboard or other is not empty
-
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.infra.gmfdiag.menu.handlers.AbstractGraphicalCommandHandler#setEnabled(java.lang.Object)
+ */
+ @Override
+ public void setEnabled(Object evaluationContext) {
+ if(!PapyrusClipboard.getInstance().isEmpty()) {
+ if(evaluationContext instanceof IEvaluationContext) {
+ IEvaluationContext iEvaluationContext = (IEvaluationContext)evaluationContext;
+ Object activeFocusControl = iEvaluationContext.getVariable("activeFocusControl"); //$NON-NLS-1$
+ Object activeShell = iEvaluationContext.getVariable("activeShell"); //$NON-NLS-1$
+ Control focusControl = null;
+ if(activeShell instanceof Shell) {
+ Shell shell = (Shell)activeShell;
+ Display display = shell.getDisplay();
+ if(display != null) {
+ focusControl = display.getFocusControl();
+ }
+ }
+ if(activeFocusControl instanceof StyledText || focusControl instanceof Text) { // true if the focus is on an internal xtext editor or a text edit
+ setBaseEnabled(false);
+ } else {
+ super.setEnabled(evaluationContext);
+ }
+ }
+ } else {
+ setBaseEnabled(false);
+ }
+ }
}