View Javadoc
1   /* 
2   
3    WSMO Studio - a Semantic Web Service Editor
4   
5    Copyright (c) 2004-2006, OntoText Lab. / SIRMA Group
6   
7    
8   
9    This library is free software; you can redistribute it and/or modify it under
10  
11   the terms of the GNU Lesser General Public License as published by the Free
12  
13   Software Foundation; either version 2.1 of the License, or (at your option)
14  
15   any later version.
16  
17   This library is distributed in the hope that it will be useful, but WITHOUT
18  
19   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20  
21   FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
22  
23   details.
24  
25   You should have received a copy of the GNU Lesser General Public License along
26  
27   with this library; if not, write to the Free Software Foundation, Inc.,
28  
29   59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30  
31   */
32  
33  
34  
35  /***
36  
37   * <p>Title: WSMO Studio</p>
38  
39   * <p>Description: Semantic Web Service Editor</p>
40  
41   * <p>Copyright:  Copyright (c) 2004-2006</p>
42  
43   * <p>Company: OntoText Lab. / SIRMA </p>
44  
45   */
46  
47  
48  
49  package org.wsmostudio.ui.editors;
50  
51  
52  
53  import org.eclipse.swt.SWT;
54  
55  import org.eclipse.swt.custom.SashForm;
56  
57  import org.eclipse.swt.layout.*;
58  
59  import org.eclipse.swt.widgets.*;
60  
61  import org.eclipse.ui.*;
62  
63  import org.wsmo.common.TopEntity;
64  
65  import org.wsmo.service.Interface;
66  
67  import org.wsmostudio.runtime.WSMORuntime;
68  
69  import org.wsmostudio.ui.Utils;
70  
71  import org.wsmostudio.ui.editors.common.*;
72  
73  import org.wsmostudio.ui.editors.model.InterfaceModel;
74  
75  
76  
77  /***
78  
79   * An editor component, subclass of WSMOEditor, capable to handle with WSMO-API 
80  
81   * Interface objects.
82  
83   * This editor appears as a part of the WSMO Studio workbench. It is the default
84  
85   * editor implementation for this kind of objects and it can be replaced by 
86  
87   * extending extension points <code>org.wsmostudio.ui.editors</code> and 
88  
89   * <code>org.eclipse.ui.editors</code>.
90  
91   *
92  
93   * @author not attributable
94  
95   * @version $Revision: 1.13 $ $Date: 2006/03/15 09:01:46 $
96  
97   */
98  
99  
100 
101 public class InterfaceEditor extends WSMOEditor {
102 
103 
104 
105     private NFPPanel nfpPanel;
106 
107     private NamespacesPanel nsPanel;
108 
109     private ImportOntologyPanel ontologiesPanel;
110 
111     private InterfaceModel model;
112 
113     
114 
115     private TabFolder ontosFolder;
116 
117     
118 
119     private Text choreographyField, orchestrationField;
120 
121     
122 
123     public void createPartControl(Composite parent) {
124 
125         GridLayout mainLayout = new GridLayout(1, false);
126 
127         mainLayout.verticalSpacing = 0;
128 
129         parent.setLayout(mainLayout);
130 
131         
132 
133         nfpPanel = new NFPPanel(parent, model);
134 
135         
136 
137         SashForm splitter = new SashForm(parent, SWT.VERTICAL );
138 
139         splitter.setLayoutData(new GridData(GridData.FILL_BOTH));
140 
141         nsPanel = new NamespacesPanel(splitter, model);
142 
143         ontosFolder = new TabFolder(splitter, SWT.NONE);
144 
145         ontologiesPanel = new ImportOntologyPanel(
146 
147                 ontosFolder, 
148 
149                 model);
150 
151 
152 
153         createInterfacePanel(parent);
154 
155     }
156 
157     
158 
159     public void init(IEditorSite site, IEditorInput input) throws PartInitException {
160 
161         super.init(site, input);
162 
163         this.model = (InterfaceModel)input.getAdapter(InterfaceModel.class);
164 
165     }
166 
167 
168 
169     public void dispose() {
170 
171         nfpPanel.dispose();
172 
173         super.dispose();
174 
175     }
176 
177 
178 
179     protected void doTryToSave() throws Exception {
180 
181         nsPanel.doUpdate();
182 
183         TopEntity topContainer = Utils.findTopContainer(model);
184 
185         WSMORuntime.getRuntime().doUpdateEntity(topContainer);
186 
187     }
188 
189     
190 
191     @SuppressWarnings("unchecked")
192 
193     protected void updateFromModel() {
194 
195 
196 
197         nsPanel.reloadNSInfo();
198 
199         ontologiesPanel.reloadOntologies();
200 
201         
202 
203         Interface targetIface = model.getInterface();
204 
205         orchestrationField.setText((targetIface.getOrchestration() != null) ?
206 
207                 targetIface.getOrchestration().getIdentifier().toString()
208 
209                 : "");
210 
211         choreographyField.setText((targetIface.getChoreography() != null) ?
212 
213                 targetIface.getChoreography().getIdentifier().toString()
214 
215                 : "");
216 
217     }
218 
219     
220 
221     private void createInterfacePanel(Composite parent) {
222 
223         Group mainPanel = new Group(parent, SWT.NONE);
224 
225         mainPanel.setLayout(new GridLayout(2, false));
226 
227         mainPanel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
228 
229         
230 
231         new Label(mainPanel, SWT.NONE).setText("Choreography : ");
232 
233         choreographyField = new Text(mainPanel, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY);
234 
235         
236 
237         if (model.getInterface().getChoreography() != null) {
238 
239             choreographyField.setText(model.getInterface()
240 
241                                           .getChoreography()
242 
243                                               .getIdentifier().toString());
244 
245         }
246 
247         choreographyField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
248 
249         new Label(mainPanel, SWT.NONE).setText("Orchestration :");
250 
251 
252 
253         orchestrationField = new Text(mainPanel, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY);
254 
255         
256 
257         if (model.getInterface().getOrchestration() != null) {
258 
259             orchestrationField.setText(model.getInterface()
260 
261                                           .getOrchestration()
262 
263                                               .getIdentifier().toString());
264 
265         }
266 
267         orchestrationField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
268 
269     }
270 
271 
272 
273 }
274 
275 
276 
277 /*
278 
279  * $Log: InterfaceEditor.java,v $
280  * Revision 1.13  2006/03/15 09:01:46  alex_simov
281  * bugfix[1420388]: Chor/Orch definitions are contained in Interfaces,
282  *  not referred by identifiers. Identifiers management removed from the UI.
283  *
284  * Revision 1.12  2006/01/23 14:35:54  alex_simov
285  * bugfix: choreography/orchestration references could not be modified.
286  * Incorrect UI models integration.
287  *
288  * Revision 1.11  2006/01/09 12:51:13  alex_simov
289  * Copyright message in header updated
290  *
291  * Revision 1.10  2005/11/09 16:17:39  alex_simov
292  * UIModels notification improved
293  *
294  * Revision 1.9  2005/11/02 14:50:57  alex_simov
295  * moving to MVC architecture cont'd
296  *
297  * Revision 1.8  2005/09/16 14:25:11  alex_simov
298  * Identifier.asString() removed, use Object.toString() instead
299  *
300  * Revision 1.7  2005/07/29 15:08:02  alex_simov
301  * added javadoc: class description, footer
302  *
303 
304  *
305 
306  */