1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 /***
19 * <p>Title: WSMO Studio</p>
20 * <p>Description: Semantic Web Service Editor</p>
21 * <p>Copyright: Copyright (c) 2004-2007</p>
22 * <p>Company: Ontotext Lab. / SIRMA </p>
23 */
24
25 package org.wsmostudio.bpmo.ui.actions;
26
27
28 import java.util.List;
29
30 import org.eclipse.gef.editparts.AbstractEditPart;
31 import org.eclipse.gef.ui.actions.SelectionAction;
32 import org.wsmostudio.bpmo.model.WorkflowEntitiesContainer;
33 import org.wsmostudio.bpmo.ui.editor.BpmoEditor;
34 import org.wsmostudio.bpmo.ui.editor.layout.BPMOModelLayouter;
35
36 public class LayoutAction extends SelectionAction {
37
38 public static final String ID = "Reset Layout";
39
40 private BpmoEditor editor;
41
42 public LayoutAction(BpmoEditor editor) {
43 super(editor);
44 this.editor = editor;
45 }
46
47 public String getId() {
48 return ID;
49 }
50
51 public String getText() {
52 return ID;
53 }
54
55 protected boolean calculateEnabled() {
56 List<?> selection = getSelectedObjects();
57 if (selection.size() == 0) {
58 return true;
59 }
60 if (selection.size() == 1) {
61 return selection.get(0) instanceof AbstractEditPart
62 && ((AbstractEditPart)selection.get(0)).getModel() instanceof WorkflowEntitiesContainer;
63 }
64 return false;
65 }
66 public void run() {
67
68 if (getSelectedObjects().size() == 1) {
69 BPMOModelLayouter.doLayout((WorkflowEntitiesContainer)
70 ((AbstractEditPart)getSelectedObjects().get(0)).getModel());
71 }
72 else {
73 BPMOModelLayouter.doLayout(editor.getModel());
74 }
75 editor.getModel().notifyContentChanged();
76 }
77 }