1 | /* |
2 | * Copyright 2007, SDQ, IPD, Uni Karlsruhe (TH) |
3 | */ |
4 | package de.uka.ipd.sdq.pcm.gmf.composite.part; |
5 | |
6 | import java.util.Iterator; |
7 | import java.util.List; |
8 | |
9 | import org.eclipse.core.commands.ExecutionEvent; |
10 | import org.eclipse.core.commands.ExecutionException; |
11 | import org.eclipse.core.commands.IHandler; |
12 | import org.eclipse.core.commands.IHandlerListener; |
13 | import org.eclipse.emf.ecore.EObject; |
14 | import org.eclipse.gef.EditPart; |
15 | import org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEditPolicy; |
16 | import org.eclipse.gmf.runtime.notation.View; |
17 | import org.eclipse.jface.viewers.ISelection; |
18 | import org.eclipse.jface.viewers.IStructuredSelection; |
19 | import org.eclipse.ui.PlatformUI; |
20 | |
21 | /** |
22 | * @generated |
23 | */ |
24 | public class PalladioComponentModelDiagramUpdateCommand implements IHandler { |
25 | |
26 | /** |
27 | * @generated |
28 | */ |
29 | public void addHandlerListener(IHandlerListener handlerListener) { |
30 | } |
31 | |
32 | /** |
33 | * @generated |
34 | */ |
35 | public void dispose() { |
36 | } |
37 | |
38 | /** |
39 | * @generated |
40 | */ |
41 | public Object execute(ExecutionEvent event) throws ExecutionException { |
42 | ISelection selection = PlatformUI.getWorkbench() |
43 | .getActiveWorkbenchWindow().getSelectionService() |
44 | .getSelection(); |
45 | if (selection instanceof IStructuredSelection) { |
46 | IStructuredSelection structuredSelection = (IStructuredSelection) selection; |
47 | if (structuredSelection.size() != 1) { |
48 | return null; |
49 | } |
50 | if (structuredSelection.getFirstElement() instanceof EditPart |
51 | && ((EditPart) structuredSelection.getFirstElement()) |
52 | .getModel() instanceof View) { |
53 | EObject modelElement = ((View) ((EditPart) structuredSelection |
54 | .getFirstElement()).getModel()).getElement(); |
55 | List editPolicies = CanonicalEditPolicy |
56 | .getRegisteredEditPolicies(modelElement); |
57 | for (Iterator it = editPolicies.iterator(); it.hasNext();) { |
58 | CanonicalEditPolicy nextEditPolicy = (CanonicalEditPolicy) it |
59 | .next(); |
60 | nextEditPolicy.refresh(); |
61 | } |
62 | |
63 | } |
64 | } |
65 | return null; |
66 | } |
67 | |
68 | /** |
69 | * @generated |
70 | */ |
71 | public boolean isEnabled() { |
72 | return true; |
73 | } |
74 | |
75 | /** |
76 | * @generated |
77 | */ |
78 | public boolean isHandled() { |
79 | return true; |
80 | } |
81 | |
82 | /** |
83 | * @generated |
84 | */ |
85 | public void removeHandlerListener(IHandlerListener handlerListener) { |
86 | } |
87 | |
88 | } |