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 Group</p>
23 */
24
25 package org.wsmostudio.choreography.editors;
26
27 import java.util.Iterator;
28 import java.util.Set;
29
30 import org.eclipse.swt.SWT;
31 import org.eclipse.swt.custom.SashForm;
32 import org.eclipse.swt.layout.GridData;
33 import org.eclipse.swt.layout.GridLayout;
34 import org.eclipse.swt.widgets.Composite;
35 import org.eclipse.ui.IEditorInput;
36 import org.eclipse.ui.IEditorSite;
37 import org.eclipse.ui.PartInitException;
38 import org.wsmo.service.*;
39 import org.wsmostudio.choreography.editors.model.ChoreographyModel;
40 import org.wsmostudio.ui.editors.WSMOEditor;
41 import org.wsmostudio.ui.editors.common.NFPPanel;
42
43 /***
44 * An editor component, subclass of WSMOEditor, capable to handle with WSMO-API
45 * extensions for Choreography.
46 * This editor appears as a part of the WSMO Studio workbench. It is the default
47 * editor implementation for this kind of objects and it can be replaced by
48 * extending extension points <code>org.wsmostudio.ui.editors</code> and
49 * <code>org.eclipse.ui.editors</code>.
50 *
51 * @author not attributable
52 * @version $Revision: 1042 $ $Date: 2007-02-13 17:46:57 +0200 $
53 */
54
55 public class ChoreographyEditor extends WSMOEditor {
56
57 public static final String id = "org.wsmostudio.ui.editors.choreographyEditor";
58
59 private NFPPanel nfpPanel;
60 private ChoreographyModel uiModel;
61
62 private StateSignatureEditor sSigPanel;
63 private RulesManagementPanel rulesPanel;
64
65 public void createPartControl(Composite parent) {
66 GridLayout mainLayout = new GridLayout(1, false);
67 mainLayout.verticalSpacing = 0;
68 parent.setLayout(mainLayout);
69
70 nfpPanel = new NFPPanel(parent, uiModel);
71
72 SashForm splitter = new SashForm(parent, SWT.VERTICAL );
73 splitter.setLayoutData(new GridData(GridData.FILL_BOTH));
74
75 sSigPanel = new StateSignatureEditor(uiModel, splitter);
76 rulesPanel = new RulesManagementPanel(splitter, uiModel);
77 splitter.setWeights(new int[] {3, 5});
78 }
79
80 public void init(IEditorSite site, IEditorInput input) throws PartInitException {
81 super.init(site, input);
82 this.uiModel = (ChoreographyModel)input.getAdapter(ChoreographyModel.class);
83 }
84
85 public void dispose() {
86 nfpPanel.dispose();
87 sSigPanel.dispose();
88 super.dispose();
89 }
90
91 /***
92 * The method is invoked just before SAVE operation.
93 * The internal state of the editor is merged with the wsmo4j model.
94 */
95 public void modelAboutToSave() throws Exception {
96 rulesPanel.updateEditedRule();
97 }
98
99 protected void updateFromModel() {
100 nfpPanel.update();
101 sSigPanel.reloadContent();
102 rulesPanel.reloadRules();
103 }
104
105 public boolean isInputEntityDead() {
106
107 if (uiModel.getMasterModel().getAdapter(Interface.class) != null) {
108
109 Interface iface = (Interface)
110 uiModel.getMasterModel().getAdapter(Interface.class);
111 ServiceDescription service = (ServiceDescription)
112 uiModel.getMasterModel().getMasterModel().getAdapter(
113 ServiceDescription.class);
114 if (false == service.listInterfaces().contains(iface)) {
115 return true;
116 }
117 return (iface.getChoreography() != uiModel.getChoreography()
118 && false == uiModel.getChoreography().equals(iface.getChoreography()));
119 }
120 if (uiModel.getMasterModel().getAdapter(ServiceDescription.class) != null) {
121
122 ServiceDescription service = (ServiceDescription)
123 uiModel.getMasterModel().getAdapter(ServiceDescription.class);
124 Set ifaces = service.listInterfaces();
125 for(Iterator it = ifaces.iterator(); it.hasNext();) {
126 Interface testIface = (Interface)it.next();
127 if (testIface.getChoreography() == uiModel.getChoreography()
128 || uiModel.getChoreography().equals(testIface.getChoreography())) {
129 return false;
130 }
131 }
132 return true;
133 }
134 return super.isInputEntityDead();
135 }
136
137 }
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198