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-2006</p>
22 * <p>Company: OntoText Lab. / SIRMA </p>
23 */
24
25 package org.wsmostudio.choreography.navigator.actions;
26
27 import org.eclipse.jface.dialogs.*;
28 import org.eclipse.jface.viewers.IStructuredSelection;
29 import org.wsmo.common.Identifier;
30 import org.wsmo.factory.ChoreographyFactory;
31 import org.wsmo.service.Interface;
32 import org.wsmo.service.choreography.Choreography;
33 import org.wsmo.service.choreography.rule.ChoreographyRules;
34 import org.wsmostudio.choreography.ChoreographyPlugin;
35 import org.wsmostudio.runtime.WSMORuntime;
36 import org.wsmostudio.ui.*;
37 import org.wsmostudio.ui.editors.model.ObservableModel;
38 import org.wsmostudio.ui.views.navigator.actions.AbstractAction;
39
40 public class CreateChoreography extends AbstractAction {
41
42 public void run() {
43
44 Interface iface = (Interface)
45 ((IStructuredSelection)navigator.getTree().getSelection())
46 .getFirstElement();
47
48 if (iface.getChoreography() != null) {
49 MessageDialog.openWarning(navigator.getSite().getShell(),
50 "Incorrect Usage",
51 "The selected interface already has a choreography set!");
52 return;
53 }
54
55 ObservableModel uiModel =
56 (ObservableModel)navigator.getWsmoInput().getAdapter(ObservableModel.class);
57
58 IdentifierInputDialog iriInputDialog = new IdentifierInputDialog(
59 navigator.getSite().getShell(),
60 "New Choreography",
61 "New Choreography Identifier (leave blank for anonymous):",
62 Utils.findTopContainer(uiModel),
63 WSMORuntime.getRuntime().getWsmoFactory(),
64 true);
65 if (iriInputDialog.open() != Dialog.OK) {
66 return;
67 }
68 Identifier chorID = (Identifier)iriInputDialog.getIdentifier();
69 ChoreographyFactory fact = ChoreographyPlugin.getFactory();
70 Choreography chor = fact.containers.createChoreography(chorID);
71 ChoreographyRules rules = fact.containers.createRules(
72 WSMORuntime.getRuntime().getWsmoFactory().createAnonymousID());
73 chor.setRules(rules);
74 iface.setChoreography(chor);
75
76 uiModel.setChanged();
77 navigator.fireEntityChanged(iface);
78 navigator.getTree().refresh(iface);
79 navigator.getTree().setExpandedState(iface, true);
80 }
81 }
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110