1
package net.launchpad.vide.flowchart.diagram.part;
3
import java.util.Iterator;
6
import org.eclipse.core.commands.ExecutionEvent;
7
import org.eclipse.core.commands.ExecutionException;
8
import org.eclipse.core.commands.IHandler;
9
import org.eclipse.core.commands.IHandlerListener;
10
import org.eclipse.emf.ecore.EObject;
11
import org.eclipse.gef.EditPart;
12
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEditPolicy;
13
import org.eclipse.gmf.runtime.notation.View;
14
import org.eclipse.jface.viewers.ISelection;
15
import org.eclipse.jface.viewers.IStructuredSelection;
16
import org.eclipse.ui.PlatformUI;
21
public class FlowchartDiagramUpdateCommand implements IHandler {
26
public void addHandlerListener(IHandlerListener handlerListener) {
32
public void dispose() {
38
public Object execute(ExecutionEvent event) throws ExecutionException {
39
ISelection selection = PlatformUI.getWorkbench()
40
.getActiveWorkbenchWindow().getSelectionService()
42
if (selection instanceof IStructuredSelection) {
43
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
44
if (structuredSelection.size() != 1) {
47
if (structuredSelection.getFirstElement() instanceof EditPart
48
&& ((EditPart) structuredSelection.getFirstElement())
49
.getModel() instanceof View) {
50
EObject modelElement = ((View) ((EditPart) structuredSelection
51
.getFirstElement()).getModel()).getElement();
52
List editPolicies = CanonicalEditPolicy
53
.getRegisteredEditPolicies(modelElement);
54
for (Iterator it = editPolicies.iterator(); it.hasNext();) {
55
CanonicalEditPolicy nextEditPolicy = (CanonicalEditPolicy) it
57
nextEditPolicy.refresh();
68
public boolean isEnabled() {
75
public boolean isHandled() {
82
public void removeHandlerListener(IHandlerListener handlerListener) {