Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvlorenzo2010-08-02 15:16:17 +0000
committervlorenzo2010-08-02 15:16:17 +0000
commita371735f0a4943b0b9bf2f7f30d98c2d503fc2a8 (patch)
treee831c49cf1499dce041736a57365c7d052190e96 /plugins
parent6518fb5dcb65ad67d4e627e62e0aeec791362d90 (diff)
downloadorg.eclipse.papyrus-a371735f0a4943b0b9bf2f7f30d98c2d503fc2a8.tar.gz
org.eclipse.papyrus-a371735f0a4943b0b9bf2f7f30d98c2d503fc2a8.tar.xz
org.eclipse.papyrus-a371735f0a4943b0b9bf2f7f30d98c2d503fc2a8.zip
NEW - bug 320367: [Usability] Change the visibility for the action Show/Hide Compartment
https://bugs.eclipse.org/bugs/show_bug.cgi?id=320367 I remove the actionSet for the Show/Hide actions, because they interfered with the toolbar menu : actions were always enable in the toolbar. This seems comes from the field enableFor in the extension point actionSet.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/uml/org.eclipse.papyrus.diagram.common/plugin.xml131
-rw-r--r--plugins/uml/org.eclipse.papyrus.diagram.common/src/org/eclipse/papyrus/diagram/common/actions/AbstractShowHideAction.java29
-rw-r--r--plugins/uml/org.eclipse.papyrus.diagram.common/src/org/eclipse/papyrus/diagram/common/actions/ShowHideCompartmentAction.java21
-rw-r--r--plugins/uml/org.eclipse.papyrus.diagram.common/src/org/eclipse/papyrus/diagram/common/actions/ShowHideContentsAction.java4
-rw-r--r--plugins/uml/org.eclipse.papyrus.diagram.common/src/org/eclipse/papyrus/diagram/common/actions/handlers/AbstractShowHideHandler.java122
-rw-r--r--plugins/uml/org.eclipse.papyrus.diagram.common/src/org/eclipse/papyrus/diagram/common/actions/handlers/ShowHideCompartmentHandler.java35
-rw-r--r--plugins/uml/org.eclipse.papyrus.diagram.common/src/org/eclipse/papyrus/diagram/common/actions/handlers/ShowHideContentsHandler.java38
-rw-r--r--plugins/uml/org.eclipse.papyrus.diagram.common/src/org/eclipse/papyrus/diagram/common/actions/handlers/ShowHideDropDownHandler.java104
8 files changed, 425 insertions, 59 deletions
diff --git a/plugins/uml/org.eclipse.papyrus.diagram.common/plugin.xml b/plugins/uml/org.eclipse.papyrus.diagram.common/plugin.xml
index e03b0a3c223..63ed8ec67d7 100644
--- a/plugins/uml/org.eclipse.papyrus.diagram.common/plugin.xml
+++ b/plugins/uml/org.eclipse.papyrus.diagram.common/plugin.xml
@@ -275,12 +275,14 @@
</command>
<command
categoryId="org.eclipse.papyrus.editor.category"
- description="Call the Show/Hide Compartment Action"
+ defaultHandler="org.eclipse.papyrus.diagram.common.actions.handlers.ShowHideCompartmentHandler"
+ description="Call the Show/Hide Compartments Action"
id="org.eclipse.papyrus.diagram.common.commands.ShowHideCompartmentCommand"
- name="Show/Hide Compartment Command">
+ name="Show/Hide Compartments Command">
</command>
<command
categoryId="org.eclipse.papyrus.editor.category"
+ defaultHandler="org.eclipse.papyrus.diagram.common.actions.handlers.ShowHideContentsHandler"
description="Call the Show/Hide Contents Action"
id="org.eclipse.papyrus.diagram.common.commands.ShowHideContentsCommand"
name="Show/Hide Contents Command">
@@ -416,6 +418,7 @@
</Priority>
</aspectToolProvider>
</extension>
+
<extension
point="org.eclipse.papyrus.diagram.common.aspectToolProvider">
<aspectToolProvider
@@ -975,16 +978,15 @@
</contributionItemProvider>
</extension>
<extension
- id="org.eclipse.papyrus.diagram.composite.compartmentviewer"
+ id="org.eclipse.papyrus.diagram.common.compartmentviewer"
point="org.eclipse.ui.popupMenus">
<objectContribution
adaptable="false"
- id="org.eclipse.papyrus.diagram.composite.compartmentviewer"
+ id="org.eclipse.papyrus.diagram.common.compartmentviewer"
objectClass="org.eclipse.papyrus.diagram.common.editparts.NamedElementEditPart">
<action
class="org.eclipse.papyrus.diagram.common.actions.ShowHideCompartmentAction"
definitionId="org.eclipse.papyrus.diagram.common.commands.ShowHideCompartmentCommand"
- enablesFor="+1"
icon="icons/fantomCompartment.gif"
id="org.eclipse.papyrus.diagram.composite.ShowHideCompartmentAction"
label="Show/Hide Compartments"
@@ -994,56 +996,91 @@
</objectContribution>
<objectContribution
adaptable="false"
- id="org.eclipse.papyrus.diagram.composite.contentsviewer"
+ id="org.eclipse.papyrus.diagram.common.contentsviewer"
objectClass="org.eclipse.papyrus.diagram.common.editparts.NamedElementEditPart">
<action
class="org.eclipse.papyrus.diagram.common.actions.ShowHideContentsAction"
definitionId="org.eclipse.papyrus.diagram.common.commands.ShowHideContentsCommand"
- enablesFor="1"
icon="icons/fantomContents.gif"
- id="org.eclipse.papyrus.diagram.composite.ShowHideInheritedContentsAction"
+ id="org.eclipse.papyrus.diagram.composite.ShowHideContentsAction"
label="Show/Hide Con&amp;tents"
menubarPath="filtersMenu/expandFilterGroup"
tooltip="Show/Hide Contents">
</action>
</objectContribution>
- </extension>
- <extension
- point="org.eclipse.ui.actionSets">
- <actionSet
- id="org.eclipse.papyrus.diagram.common.ShowHideCompartmentActionSet"
- label="Show/Hide Compartments"
- visible="true">
- <action
- class="org.eclipse.papyrus.diagram.common.actions.ShowHideCompartmentAction"
- definitionId="org.eclipse.papyrus.diagram.common.commands.ShowHideCompartmentCommand"
- icon="icons/fantomCompartment.gif"
- id="org.eclipse.papyrus.diagram.common.myShowHideCompartmentAction"
- label="Show/Hide &amp;Compartments"
- menubarPath="diagramMenu/filtersMenu/compartmentMenu"
- style="push"
- toolbarPath="compartmentMenu/allCompartmentsGroup"
- tooltip="Show/Hide Compartments">
- </action>
- </actionSet>
- <actionSet
- id="org.eclipse.papyrus.diagram.common.ShowHideContentsActionSet"
- label="Show/Hide Contents"
- visible="true">
- <action
- class="org.eclipse.papyrus.diagram.common.actions.ShowHideContentsAction"
- definitionId="org.eclipse.papyrus.diagram.common.commands.ShowHideContentsCommand"
- enablesFor="1"
- icon="icons/fantomContents.gif"
- id="org.eclipse.papyrus.diagram.common.myShowHideContentsAction"
- label="Show/Hide Con&amp;tents"
- menubarPath="diagramMenu/filtersMenu/compartmentMenu"
- style="push"
- toolbarPath="compartmentMenu/allCompartmentsGroup"
- tooltip="Show/Hide Contents">
- </action>
- </actionSet>
- </extension>
-
-
+ </extension>
+<extension point="org.eclipse.ui.commands">
+ <command
+ category="org.eclipse.papyrus.editor.category"
+ categoryId="org.eclipse.papyrus.editor.category"
+ defaultHandler="org.eclipse.papyrus.diagram.common.actions.handlers.ShowHideDropDownHandler"
+ id="org.eclipse.papyrus.diagram.common.show.hide.toolbar"
+ name="Show/Hide">
+ </command>
+ </extension>
+ <extension
+ id="showhideextension"
+ point="org.eclipse.ui.menus">
+ <menuContribution locationURI="toolbar:org.eclipse.ui.main.toolbar?before=org.eclipse.papyrus.diagram.ui.toolbar">
+ <toolbar id="org.eclipes.papyrus.common.show.hide.dropdown.toolbar">
+ <command
+ commandId="org.eclipse.papyrus.diagram.common.show.hide.toolbar"
+ icon="icons/fantom.gif"
+ id="org.eclipse.papyrus.common.showhide.toolbar.command"
+ style="pulldown"
+ tooltip="Show/Hide Actions">
+ <visibleWhen>
+ <and>
+ <with
+ variable="activeEditorId">
+ <equals
+ value="org.eclipse.papyrus.core.papyrusEditor">
+ </equals>
+ </with>
+ </and>
+ </visibleWhen>
+ </command>
+ </toolbar>
+ </menuContribution>
+ </extension>
+ <extension point="org.eclipse.ui.menus">
+ <menuContribution locationURI="menu:org.eclipse.papyrus.common.showhide.toolbar.command">
+ <command
+ commandId="org.eclipse.papyrus.diagram.common.commands.ShowHideCompartmentCommand"
+ icon="icons/fantomCompartment.gif"
+ label="Show/Hide Compartments"
+ mnemonic="&amp;p"
+ style="push"
+ tooltip="The Show/Hide Compartments Action">
+ <visibleWhen>
+ <and>
+ <with
+ variable="activeEditorId">
+ <equals
+ value="org.eclipse.papyrus.core.papyrusEditor">
+ </equals>
+ </with>
+ </and>
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.papyrus.diagram.common.commands.ShowHideContentsCommand"
+ icon="icons/fantomContents.gif"
+ label="Show/Hide Contents"
+ mnemonic="&amp;C"
+ style="push"
+ tooltip="The Show/Hide Contents Action">
+ <visibleWhen>
+ <and>
+ <with
+ variable="activeEditorId">
+ <equals
+ value="org.eclipse.papyrus.core.papyrusEditor">
+ </equals>
+ </with>
+ </and>
+ </visibleWhen>
+ </command>
+ </menuContribution>
+ </extension>
</plugin>
diff --git a/plugins/uml/org.eclipse.papyrus.diagram.common/src/org/eclipse/papyrus/diagram/common/actions/AbstractShowHideAction.java b/plugins/uml/org.eclipse.papyrus.diagram.common/src/org/eclipse/papyrus/diagram/common/actions/AbstractShowHideAction.java
index 03d42801ae4..f5edf22db79 100644
--- a/plugins/uml/org.eclipse.papyrus.diagram.common/src/org/eclipse/papyrus/diagram/common/actions/AbstractShowHideAction.java
+++ b/plugins/uml/org.eclipse.papyrus.diagram.common/src/org/eclipse/papyrus/diagram/common/actions/AbstractShowHideAction.java
@@ -168,7 +168,7 @@ public abstract class AbstractShowHideAction implements IActionDelegate, IWorkbe
* @return
* if the action can be run or not
*/
- protected boolean canRun() {
+ public boolean canRun() {
if(this.selectedElements.isEmpty()) {
return false;
@@ -215,7 +215,9 @@ public abstract class AbstractShowHideAction implements IActionDelegate, IWorkbe
}
}
- action.setEnabled(enabled);
+ if(action != null) {
+ action.setEnabled(enabled);
+ }
}
/**
@@ -301,6 +303,29 @@ public abstract class AbstractShowHideAction implements IActionDelegate, IWorkbe
}
/**
+ * Setter for {@link #selectedElements}.
+ * When this action is called by a popup menu, {@link #selectedElements} is filled by {@link #selectionChanged(IAction, ISelection)} When this
+ * action is called by a Handler, {@link #selectedElements} is filled with this method
+ *
+ * @param selection
+ * the current selection
+ */
+ public void setSelection(List<EditPart> selection) {
+ this.selectedElements = selection;
+ }
+
+ /**
+ * Getter for {@link AbstractShowHideAction#editPolicyKey}
+ *
+ * @return
+ *
+ * {@link AbstractShowHideAction#editPolicyKey}
+ */
+ public String getEditPolicyKey() {
+ return this.editPolicyKey;
+ }
+
+ /**
*
* This class provides some facilities to build the action.
*
diff --git a/plugins/uml/org.eclipse.papyrus.diagram.common/src/org/eclipse/papyrus/diagram/common/actions/ShowHideCompartmentAction.java b/plugins/uml/org.eclipse.papyrus.diagram.common/src/org/eclipse/papyrus/diagram/common/actions/ShowHideCompartmentAction.java
index 97c6cc0df8f..e3b3fc611a3 100644
--- a/plugins/uml/org.eclipse.papyrus.diagram.common/src/org/eclipse/papyrus/diagram/common/actions/ShowHideCompartmentAction.java
+++ b/plugins/uml/org.eclipse.papyrus.diagram.common/src/org/eclipse/papyrus/diagram/common/actions/ShowHideCompartmentAction.java
@@ -18,7 +18,6 @@ import java.util.Iterator;
import java.util.List;
import org.eclipse.draw2d.IFigure;
-import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.commands.Command;
@@ -143,6 +142,9 @@ public class ShowHideCompartmentAction extends AbstractShowHideAction {
@Override
protected void initAction() {
super.initAction();
+ if(this.selectedElements.size() < 1) {
+ return;
+ }
setContentProvider(new ContentProvider());
this.setEditorLabelProvider(new CustomEditorLabelProvider());
this.domain = ((IGraphicalEditPart)this.selectedElements.get(0)).getEditingDomain();
@@ -162,7 +164,7 @@ public class ShowHideCompartmentAction extends AbstractShowHideAction {
*/
@Override
protected List<Object> getInput() {
- Iterator it = this.representations.iterator();
+ Iterator<EditPartRepresentation> it = this.representations.iterator();
List<Object> input = new ArrayList<Object>();
while(it.hasNext()) {
input.add(it.next());
@@ -333,7 +335,7 @@ public class ShowHideCompartmentAction extends AbstractShowHideAction {
*/
public Object[] getElements(Object inputElement) {
if(inputElement instanceof List) {
- return ((List)inputElement).toArray();
+ return ((List<?>)inputElement).toArray();
}
return new Object[0];
}
@@ -404,7 +406,7 @@ public class ShowHideCompartmentAction extends AbstractShowHideAction {
protected List<String> initialCompartments = new ArrayList<String>();
/** the possible compartment */
- protected EList<View> possibleCompartments = null;
+ protected List<View> possibleCompartments = new ArrayList<View>();
/** the initial selection */
protected List<View> initialSelection = new ArrayList<View>();
@@ -430,7 +432,7 @@ public class ShowHideCompartmentAction extends AbstractShowHideAction {
* </ul>
*/
protected void init() {
- List localChildren = representedEditPart.getChildren();
+ List<?> localChildren = representedEditPart.getChildren();
//fill this.initialCompartments
for(Object current : localChildren) {
@@ -440,7 +442,14 @@ public class ShowHideCompartmentAction extends AbstractShowHideAction {
}
//fill this.possibleCompartments
- this.possibleCompartments = ((GraphicalEditPart)representedEditPart).getNotationView().getChildren();
+ List<?> graphicalChildren = ((GraphicalEditPart)representedEditPart).getNotationView().getChildren();
+ for(Object child : graphicalChildren) {
+ // Only add compartment
+ if(child instanceof BasicCompartment) {
+ this.possibleCompartments.add((View)child);
+ }
+ }
+
//fill this.initialSelection
if(this.possibleCompartments != null && !this.possibleCompartments.isEmpty()) {
diff --git a/plugins/uml/org.eclipse.papyrus.diagram.common/src/org/eclipse/papyrus/diagram/common/actions/ShowHideContentsAction.java b/plugins/uml/org.eclipse.papyrus.diagram.common/src/org/eclipse/papyrus/diagram/common/actions/ShowHideContentsAction.java
index 859be3c8f6e..4b532205de1 100644
--- a/plugins/uml/org.eclipse.papyrus.diagram.common/src/org/eclipse/papyrus/diagram/common/actions/ShowHideContentsAction.java
+++ b/plugins/uml/org.eclipse.papyrus.diagram.common/src/org/eclipse/papyrus/diagram/common/actions/ShowHideContentsAction.java
@@ -71,7 +71,6 @@ public class ShowHideContentsAction extends AbstractShowHideAction implements IA
*/
public ShowHideContentsAction() {
super(title, message, ShowHideClassifierContentsEditPolicy.SHOW_HIDE_CLASSIFIER_CONTENTS_POLICY);
-
}
@@ -680,7 +679,4 @@ public class ShowHideContentsAction extends AbstractShowHideAction implements IA
return this.representedClassifier;
}
}
-
-
-
}
diff --git a/plugins/uml/org.eclipse.papyrus.diagram.common/src/org/eclipse/papyrus/diagram/common/actions/handlers/AbstractShowHideHandler.java b/plugins/uml/org.eclipse.papyrus.diagram.common/src/org/eclipse/papyrus/diagram/common/actions/handlers/AbstractShowHideHandler.java
new file mode 100644
index 00000000000..7fe516c2757
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.diagram.common/src/org/eclipse/papyrus/diagram/common/actions/handlers/AbstractShowHideHandler.java
@@ -0,0 +1,122 @@
+/*****************************************************************************
+ * Copyright (c) 2010 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.diagram.common.actions.handlers;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.papyrus.diagram.common.actions.AbstractShowHideAction;
+import org.eclipse.ui.ISelectionService;
+import org.eclipse.ui.PlatformUI;
+
+
+/**
+ *
+ * Abstract Handler for the ShowHideActions
+ *
+ */
+
+abstract public class AbstractShowHideHandler extends AbstractHandler {
+
+ /** the current action */
+ private AbstractShowHideAction action = null;
+
+ /** the EditPolicy key for this action */
+ private String editpolicy;
+
+ /** the current selection */
+ private List<EditPart> selection = new ArrayList<EditPart>();
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param action
+ * to execute
+ * @param key
+ * the key representing the EditPolicy providing this action
+ */
+ public AbstractShowHideHandler(AbstractShowHideAction action, String key) {
+ this.action = action;
+ this.editpolicy = key;
+ }
+
+ /**
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ *
+ * @param event
+ * @return
+ * @throws ExecutionException
+ */
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ // buildSelection();
+ if(!selection.isEmpty()) {
+ this.action.setSelection(selection);
+ this.action.run(null);
+ }
+ setLastActionInToolBarMenu();
+ return null;
+ }
+
+ /**
+ * Initialize {@link ShowHideDropDownHandler#lastAction}.If the user clicks on the toolbar menu, this action will be done.
+ */
+ private void setLastActionInToolBarMenu() {
+ ShowHideDropDownHandler.lastAction = this.action;
+ }
+
+ /**
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
+ *
+ * @return
+ */
+ @Override
+ public boolean isEnabled() {
+ buildSelection();
+ return !this.selection.isEmpty();
+ }
+
+ /**
+ * Fill {@link #selection} with the EditPart owning the EditPolicy {@link #editpolicy}
+ */
+ protected void buildSelection() {
+ this.selection.clear();
+ ISelectionService selectionService = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService();
+ ISelection selectionTmp = selectionService.getSelection();
+ if((selectionTmp != null) && (!selectionTmp.isEmpty())) {
+ if(selectionTmp instanceof StructuredSelection) {
+ Iterator<?> it = ((StructuredSelection)selectionTmp).iterator();
+ while(it.hasNext()) {
+ Object current = it.next();
+ if(current instanceof EditPart) {
+ EditPolicy editpolicy = ((EditPart)current).getEditPolicy(this.editpolicy);
+ if(editpolicy != null) {
+ this.selection.add((EditPart)current);
+ }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/plugins/uml/org.eclipse.papyrus.diagram.common/src/org/eclipse/papyrus/diagram/common/actions/handlers/ShowHideCompartmentHandler.java b/plugins/uml/org.eclipse.papyrus.diagram.common/src/org/eclipse/papyrus/diagram/common/actions/handlers/ShowHideCompartmentHandler.java
new file mode 100644
index 00000000000..5993cc72ca5
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.diagram.common/src/org/eclipse/papyrus/diagram/common/actions/handlers/ShowHideCompartmentHandler.java
@@ -0,0 +1,35 @@
+/*****************************************************************************
+ * Copyright (c) 2010 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.diagram.common.actions.handlers;
+
+import org.eclipse.papyrus.diagram.common.actions.ShowHideCompartmentAction;
+import org.eclipse.papyrus.diagram.common.editpolicies.ShowHideCompartmentEditPolicy;
+
+/**
+ *
+ * Handler for the {@link ShowHideCompartmentAction}
+ *
+ */
+public class ShowHideCompartmentHandler extends AbstractShowHideHandler {
+
+ /**
+ *
+ * Constructor.
+ *
+ */
+ public ShowHideCompartmentHandler() {
+ super(new ShowHideCompartmentAction(), ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY);
+ }
+
+}
diff --git a/plugins/uml/org.eclipse.papyrus.diagram.common/src/org/eclipse/papyrus/diagram/common/actions/handlers/ShowHideContentsHandler.java b/plugins/uml/org.eclipse.papyrus.diagram.common/src/org/eclipse/papyrus/diagram/common/actions/handlers/ShowHideContentsHandler.java
new file mode 100644
index 00000000000..f60903d8237
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.diagram.common/src/org/eclipse/papyrus/diagram/common/actions/handlers/ShowHideContentsHandler.java
@@ -0,0 +1,38 @@
+/*****************************************************************************
+ * Copyright (c) 2010 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.diagram.common.actions.handlers;
+
+import org.eclipse.papyrus.diagram.common.actions.ShowHideContentsAction;
+import org.eclipse.papyrus.diagram.common.editpolicies.ShowHideClassifierContentsEditPolicy;
+
+/**
+ *
+ * Handler for the {@link ShowHideContentsAction}
+ *
+ */
+public class ShowHideContentsHandler extends AbstractShowHideHandler {
+
+
+ /**
+ *
+ * Constructor.
+ *
+ */
+ public ShowHideContentsHandler() {
+ super(new ShowHideContentsAction(), ShowHideClassifierContentsEditPolicy.SHOW_HIDE_CLASSIFIER_CONTENTS_POLICY);
+ }
+
+
+
+}
diff --git a/plugins/uml/org.eclipse.papyrus.diagram.common/src/org/eclipse/papyrus/diagram/common/actions/handlers/ShowHideDropDownHandler.java b/plugins/uml/org.eclipse.papyrus.diagram.common/src/org/eclipse/papyrus/diagram/common/actions/handlers/ShowHideDropDownHandler.java
new file mode 100644
index 00000000000..c3a6d78da70
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.diagram.common/src/org/eclipse/papyrus/diagram/common/actions/handlers/ShowHideDropDownHandler.java
@@ -0,0 +1,104 @@
+/*****************************************************************************
+ * Copyright (c) 2010 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.diagram.common.actions.handlers;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.papyrus.diagram.common.actions.AbstractShowHideAction;
+import org.eclipse.ui.ISelectionService;
+import org.eclipse.ui.PlatformUI;
+
+
+/**
+ *
+ * This handler can be used to do an action when the user clicks on the corresponding menu in the toolbar.
+ * This class is necessary to have a pulldown menu in the toolbar.
+ * Currently, nothing is done by this handler.
+ *
+ *
+ */
+
+public class ShowHideDropDownHandler extends AbstractHandler {
+
+ /** the last executed action */
+ public static AbstractShowHideAction lastAction = null;
+
+ /** selected EditParts */
+ private List<EditPart> selection = new ArrayList<EditPart>();
+
+ /**
+ *
+ * Constructor.
+ *
+ */
+ public ShowHideDropDownHandler() {
+ super();
+
+ }
+
+
+ /**
+ * Execute {@link #lastAction} if this action is not <code>null</code>
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ *
+ * @param event
+ * @return
+ * @throws ExecutionException
+ */
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+
+ if(lastAction != null) {
+ buildSelection();
+ if(!selection.isEmpty()) {
+ // lastAction.setSelection(selection);
+ // lastAction.run(null);
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Fill {@link #selection}
+ */
+ private void buildSelection() {
+ this.selection.clear();
+ ISelectionService selectionService = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService();
+ ISelection selectionTmp = selectionService.getSelection();
+ if((selectionTmp != null) && (!selectionTmp.isEmpty())) {
+ if(selectionTmp instanceof StructuredSelection) {
+ Iterator<?> it = ((StructuredSelection)selectionTmp).iterator();
+ while(it.hasNext()) {
+ Object current = it.next();
+ if(current instanceof EditPart) {
+ EditPolicy editpolicy = ((EditPart)current).getEditPolicy(lastAction.getEditPolicyKey());
+ if(editpolicy != null) {
+ this.selection.add((EditPart)current);
+ }
+ }
+ }
+ }
+ }
+ }
+
+}

Back to the top