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.choreography.Choreography;
32 import org.wsmo.service.choreography.rule.ChoreographyRules;
33 import org.wsmostudio.choreography.ChoreographyPlugin;
34 import org.wsmostudio.runtime.WSMORuntime;
35 import org.wsmostudio.ui.*;
36 import org.wsmostudio.ui.editors.model.ObservableModel;
37 import org.wsmostudio.ui.views.navigator.actions.AbstractAction;
38
39 public class CreateRulesAction extends AbstractAction {
40
41 public void run() {
42
43 Choreography chor = (Choreography)
44 ((IStructuredSelection)navigator.getTree().getSelection())
45 .getFirstElement();
46
47 if (chor.getRules() != null) {
48 MessageDialog.openWarning(navigator.getSite().getShell(),
49 "Incorrect Usage",
50 "The selected choreography already has a rules contaioner set!");
51 return;
52 }
53
54 ObservableModel uiModel =
55 (ObservableModel)navigator.getWsmoInput().getAdapter(ObservableModel.class);
56
57 IdentifierInputDialog iriInputDialog = new IdentifierInputDialog(
58 navigator.getSite().getShell(),
59 "New Rules Container",
60 "New Rules Container Identifier :",
61 Utils.findTopContainer(uiModel),
62 WSMORuntime.getRuntime().getWsmoFactory(),
63 true);
64 if (iriInputDialog.open() != Dialog.OK) {
65 return;
66 }
67 Identifier rulesID = iriInputDialog.getIdentifier();
68 ChoreographyFactory fact = ChoreographyPlugin.getFactory();
69 ChoreographyRules rules = fact.containers.createRules(rulesID);
70
71 chor.setRules(rules);
72
73 uiModel.setChanged();
74 navigator.fireEntityChanged(chor);
75 navigator.getTree().refresh(chor);
76 navigator.getTree().setExpandedState(chor, true);
77 }
78 }
79
80
81
82
83
84
85
86
87
88
89
90