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.semanticgov.ui.editor;
26
27 import org.eclipse.core.runtime.IPath;
28 import org.eclipse.core.runtime.Path;
29 import org.eclipse.jface.action.*;
30 import org.eclipse.jface.dialogs.MessageDialog;
31 import org.eclipse.jface.viewers.*;
32 import org.eclipse.swt.SWT;
33 import org.eclipse.swt.custom.SashForm;
34 import org.eclipse.swt.events.*;
35 import org.eclipse.swt.layout.GridData;
36 import org.eclipse.swt.layout.GridLayout;
37 import org.eclipse.swt.widgets.*;
38 import org.eclipse.ui.*;
39 import org.omwg.ontology.Ontology;
40 import org.semanticgov.ui.Activator;
41 import org.semanticgov.ui.Constants;
42 import org.semanticgov.ui.repository.RepositoryDialog;
43 import org.semanticgov.ui.wsdl.WSDLCache;
44 import org.semanticgov.ui.wsdl.WSDLElementChooser;
45 import org.wsmo.common.*;
46 import org.wsmo.common.exception.InvalidModelException;
47 import org.wsmo.service.WebService;
48 import org.wsmostudio.runtime.*;
49 import org.wsmostudio.runtime.cache.WSMOTopEntity;
50 import org.wsmostudio.ui.GUIHelper;
51 import org.wsmostudio.ui.Utils;
52 import org.wsmostudio.ui.editors.WSMOEditor;
53 import org.wsmostudio.ui.editors.WSMOEditorInput;
54 import org.wsmostudio.ui.editors.common.*;
55 import org.wsmostudio.ui.editors.model.ServiceDescriptionModel;
56 import org.wsmostudio.ui.views.navigator.WSMOContentProvider;
57
58 public class PAServiceEditor extends WSMOEditor {
59
60 public static final String EDITOR_ID = "org.semanticgov.ui.PAServiceEditor";
61
62 private Text idField,
63 descrField,
64 wsdlField;
65 private Table clientTypesTable,
66 providersTable,
67 processesTable,
68 inputsTable,
69 outputsTable,
70 precondsTable,
71 effectsTable;
72 private ComboViewer comboServiceTypes,
73 comboGovernedBy,
74 domainCombo,
75 subDomainCombo,
76 comboEffectTypes,
77 comboAdminLevel,
78 eLocationField,
79 phLocationField,
80 resultServiceInstanceField;
81
82 private ImportOntologyPanel importOntosPanel;
83
84 private PAServiceModel model;
85 private ActionHandler actionHandler;
86
87 @Override
88 protected void updateFromModel() {
89 updateFields();
90 }
91
92 @Override
93 public void createPartControl(Composite parent) {
94 if (this.model == null) {
95 return;
96 }
97 actionHandler = new ActionHandler(this.model);
98 GridLayout mainLayout = new GridLayout(1, false);
99 mainLayout.verticalSpacing = 0;
100 parent.setLayout(mainLayout);
101
102 initHeaderInfoPanel(parent);
103 initGeneralInfoPanel(parent);
104 initLocationPanel(parent);
105
106 SashForm splitter = new SashForm(parent, SWT.VERTICAL );
107 splitter.setLayoutData(new GridData(GridData.FILL_BOTH));
108
109 TabFolder importsOntologyFolder = new TabFolder(splitter, SWT.NONE);
110 importOntosPanel = new ImportOntologyPanel(importsOntologyFolder, this.model);
111
112 initClientTypesPanel(splitter);
113 initInputOutputPanel(splitter);
114 initPrecondEffectPanel(splitter);
115 updateFields();
116 registerSelectionHandlers();
117 }
118
119 public void init(final IEditorSite site, IEditorInput input) throws PartInitException {
120
121 super.init(site, input);
122 if (input instanceof IFileEditorInput) {
123 IPath inFile = ((IFileEditorInput)input).getFile().getLocation();
124 TopEntity[] topEntities = WSMORuntime.getIOManager().loadContent(inFile);
125 if (topEntities == null) {
126 closeEditorWithError(site, null);
127 return;
128 }
129 if (topEntities.length == 0
130 || false == topEntities[0] instanceof WebService) {
131 closeEditorWithError(site,
132 "No service found in file: '"
133 + inFile.toString() + "'");
134 return;
135 }
136 this.model = (PAServiceModel)new PAServiceModelFactory().createModel(topEntities[0], null);
137 super.setInput(new WSMOEditorInput(topEntities[0], this.model));
138 WSMORuntime.getRuntime().registerEntity(topEntities[0], inFile);
139 }
140 else if (input.getAdapter(ServiceDescriptionModel.class) != null) {
141 ServiceDescriptionModel uiModel = (ServiceDescriptionModel)
142 input.getAdapter(ServiceDescriptionModel.class);
143 if (uiModel instanceof PAServiceModel) {
144 this.model = (PAServiceModel)uiModel;
145 }
146 else {
147 this.model = (PAServiceModel)new PAServiceModelFactory().createModel(
148 uiModel.getServiceDescription(), null);
149 this.model.setMasterModel(uiModel.getMasterModel());
150 super.setInput(new WSMOEditorInput(uiModel.getServiceDescription(), this.model));
151 }
152 }
153 setPartName(getPartName());
154 this.model.addObserver(this);
155
156 try {
157 this.model.getInstanceOntology();
158 }
159 catch(RuntimeException error) {
160 if (false == MessageDialog.openConfirm(site.getShell(),
161 "No Instance Ontology",
162 error.getMessage()
163 + "\nPlease select one to proceed!")) {
164 closeEditorWithError(site, null);
165 return;
166 }
167 WSMOChooser chooser = new WSMOChooser(getSite().getShell(),
168 WSMORuntime.getRuntime(),
169 WSMOContentProvider.ONTOLOGY_MASK);
170 Ontology newOntology = (Ontology)chooser.open();
171 if (newOntology == null) {
172 closeEditorWithError(site, null);
173 return;
174 }
175 try {
176 this.model.getServiceDescription().addNFPValue(
177 Constants.NFP_INST_ONTOLOGY,
178 newOntology.getIdentifier());
179 newOntology.addNFPValue(Constants.NFP_SERVICE_REF,
180 this.model.getServiceDescription().getIdentifier());
181 this.model.setChanged();
182 }
183 catch(InvalidModelException ime) {
184
185 }
186 }
187
188 }
189
190 private void initHeaderInfoPanel(Composite parent) {
191 Group container = new Group(parent, SWT.NONE);
192 container.setText("PA Service Info");
193 container.setLayout(new GridLayout(5, false));
194 container.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
195
196 new Label(container, SWT.NONE).setText("Service Identifier : ");
197 idField = new Text(container, SWT.BORDER | SWT.SINGLE);
198 GridData gData = new GridData(GridData.FILL_HORIZONTAL);
199 gData.horizontalSpan = 2;
200 idField.setLayoutData(gData);
201 idField.setEditable(false);
202
203 Button nfpEditButton = new Button(container, SWT.PUSH | SWT.CENTER);
204 nfpEditButton.setText("PA Properties");
205 nfpEditButton.setImage(Activator.getPropertiesIcon());
206 nfpEditButton.addSelectionListener(new SelectionAdapter() {
207 public void widgetSelected(SelectionEvent se) {
208 openNFPEditor();
209 }
210 });
211 Button reloadDataButton = new Button(container, SWT.PUSH | SWT.CENTER);
212 reloadDataButton.setText("Reload Data");
213 reloadDataButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
214 reloadDataButton.setImage(Activator.getReloadIcon());
215 reloadDataButton.addSelectionListener(new SelectionAdapter() {
216 public void widgetSelected(SelectionEvent se) {
217 boolean dirty = model.isDirty();
218 model.reinitImportedOntologies();
219 if (false == dirty) {
220 model.clearDirty();
221 }
222 }
223 });
224
225 new Label(container, SWT.NONE).setText("Description : ");
226 descrField = new Text(container, SWT.SINGLE | SWT.BORDER);
227 descrField.setEditable(false);
228 gData = new GridData(GridData.FILL_HORIZONTAL);
229 gData.horizontalSpan = 4;
230 descrField.setLayoutData(gData);
231
232 new Label(container, SWT.NONE).setText("WSDL Service : ");
233 wsdlField = new Text(container, SWT.BORDER | SWT.SINGLE | SWT.READ_ONLY);
234 gData = new GridData(GridData.FILL_HORIZONTAL);
235 gData.horizontalSpan = 2;
236 wsdlField.setLayoutData(gData);
237
238 Button wsdlSelectButton = new Button(container, SWT.PUSH | SWT.CENTER);
239 wsdlSelectButton.setText("Select WSDL ");
240 wsdlSelectButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
241 wsdlSelectButton.setImage(Activator.getWSDLLogo());
242 wsdlSelectButton.addSelectionListener(new SelectionAdapter() {
243 public void widgetSelected(SelectionEvent event) {
244 WSDLElementChooser chooser = new WSDLElementChooser(getSite().getShell(),
245 WSDLCache.getCache());
246 Object res = chooser.open();
247 if (res != null) {
248 model.setWSDL(res.toString());
249 }
250 }
251 });
252 Button wsdlClearButton = new Button(container, SWT.PUSH | SWT.CENTER);
253 wsdlClearButton.setText("Clear WSDL ");
254 wsdlClearButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
255 wsdlClearButton.setImage(Activator.getClearIcon());
256 wsdlClearButton.addSelectionListener(new SelectionAdapter() {
257 public void widgetSelected(SelectionEvent event) {
258 model.setWSDL(null);
259 }
260 });
261
262 }
263
264 private void initGeneralInfoPanel(Composite parent) {
265 Group container = new Group(parent, SWT.NONE);
266 container.setText("General Info");
267 container.setLayout(new GridLayout(2, true));
268 container.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
269
270 Composite leftHalfPanel = new Composite(container, SWT.NONE);
271 leftHalfPanel.setLayout(new GridLayout(2, false));
272 leftHalfPanel.setLayoutData(new GridData(GridData.FILL_BOTH));
273
274 Composite rightHalfPanel = new Composite(container, SWT.NONE);
275 rightHalfPanel.setLayout(new GridLayout(2, false));
276 rightHalfPanel.setLayoutData(new GridData(GridData.FILL_BOTH));
277
278 new Label(leftHalfPanel, SWT.NONE).setText("Service Type : ");
279 comboServiceTypes = UIUtils.createInstancesCombo(leftHalfPanel);
280 comboServiceTypes.getCombo().setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
281
282 new Label(rightHalfPanel, SWT.NONE).setText("Governed by : ");
283 comboGovernedBy = UIUtils.createInstancesCombo(rightHalfPanel);
284 comboGovernedBy.getCombo().setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
285
286 new Label(leftHalfPanel, SWT.NONE).setText("Domain : ");
287 domainCombo = UIUtils.createInstancesCombo(leftHalfPanel);
288 domainCombo.getCombo().setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
289
290 new Label(rightHalfPanel, SWT.NONE).setText("Sub-domain : ");
291 subDomainCombo = UIUtils.createInstancesCombo(rightHalfPanel);
292 subDomainCombo.getCombo().setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
293
294 new Label(leftHalfPanel, SWT.NONE).setText("Effect Type : ");
295 comboEffectTypes = UIUtils.createInstancesCombo(leftHalfPanel);
296 comboEffectTypes.getCombo().setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
297
298 new Label(rightHalfPanel, SWT.NONE);
299 new Combo(rightHalfPanel, SWT.NONE).setVisible(false);
300
301 new Label(leftHalfPanel, SWT.NONE).setText("Result Service : ");
302 resultServiceInstanceField = UIUtils.createInstancesCombo(leftHalfPanel);
303 resultServiceInstanceField.getCombo().setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
304
305 new Label(rightHalfPanel, SWT.NONE).setText("Admin Level : ");
306 comboAdminLevel = UIUtils.createInstancesCombo(rightHalfPanel);
307 comboAdminLevel.getCombo().setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
308
309 }
310
311 private void initLocationPanel(Composite parent) {
312
313 SashForm splitter = new SashForm(parent, SWT.HORIZONTAL );
314 splitter.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
315
316 Group container = new Group(splitter, SWT.NONE);
317 container.setText("Location");
318 container.setLayout(new GridLayout(2, false));
319 container.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
320
321 new Label(container, SWT.NONE).setText("Electronic : ");
322 eLocationField = UIUtils.createInstancesCombo(container);
323 eLocationField.getCombo().setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
324
325 new Label(container, SWT.NONE).setText("Physical : ");
326 phLocationField = UIUtils.createInstancesCombo(container);
327 phLocationField.getCombo().setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
328
329 Group repositoryContainer = new Group(splitter, SWT.NONE);
330 repositoryContainer.setText("Repository");
331 repositoryContainer.setLayout(new GridLayout(2, false));
332 repositoryContainer.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
333
334 new Label(repositoryContainer, SWT.NONE).setText("Repository : ");
335 final Text repositoryField = new Text(repositoryContainer, SWT.BORDER | SWT.READ_ONLY);
336 repositoryField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
337 repositoryField.setText(
338 Activator.getDefault().getPreferenceStore()
339 .getString(RepositoryDialog.TARGET_REPOSITORY));
340 new Label(repositoryContainer, SWT.NONE);
341
342 Button publishButton = new Button(repositoryContainer, SWT.NONE);
343 publishButton.setText("Publish PA Service ...");
344 publishButton.setImage(Activator.getRepositoryIcon());
345 publishButton.addSelectionListener(new SelectionAdapter() {
346 public void widgetSelected(SelectionEvent se) {
347 new RepositoryDialog(getSite().getShell(), model, repositoryField).open();
348 }
349 });
350 splitter.setWeights(new int[] { 2, 1 });
351 }
352
353 private Table initActionTable(Composite parent, String[] actions) {
354
355 Table clientsTable = new Table(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
356 clientsTable.setLayoutData(new GridData(GridData.FILL_BOTH));
357 clientsTable.setLinesVisible(false);
358 createContextMenu(parent, clientsTable, actions);
359
360 return clientsTable;
361 }
362
363 private void initClientTypesPanel(Composite splitter) {
364 SashForm splitter3 = new SashForm(splitter, SWT.HORIZONTAL );
365 splitter.setLayoutData(new GridData(GridData.FILL_BOTH));
366
367 TabFolder tabFolder = new TabFolder(splitter3, SWT.NONE);
368 GridLayout gLayout = new GridLayout(1, false);
369 gLayout.marginTop = 5;
370 tabFolder.setLayout(gLayout);
371
372 TabItem mainItem = new TabItem(tabFolder, SWT.NONE);
373 tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
374 mainItem.setText("Client Type(s)");
375
376 this.clientTypesTable = initActionTable(tabFolder, new String[] {
377 ActionHandler.ADD_SOCIETAL_ENTITY,
378 null,
379 ActionHandler.REMOVE_CLIENT });
380
381 mainItem.setControl(this.clientTypesTable);
382
383 tabFolder = new TabFolder(splitter3, SWT.NONE);
384 tabFolder.setLayout(new GridLayout(1, false));
385
386 mainItem = new TabItem(tabFolder, SWT.NONE);
387 tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
388 mainItem.setText("Provider(s)");
389
390 this.providersTable = initActionTable(tabFolder, new String[] {
391 ActionHandler.ADD_SERVICE_PROVIDER,
392 null,
393 ActionHandler.REMOVE_SERVICE_PROVIDER });
394
395 mainItem.setControl(this.providersTable);
396
397 tabFolder = new TabFolder(splitter3, SWT.NONE);
398 tabFolder.setLayout(new GridLayout(1, false));
399
400 mainItem = new TabItem(tabFolder, SWT.NONE);
401 tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
402 mainItem.setText("Process(es)");
403
404 this.processesTable = initActionTable(tabFolder, new String[] {
405 ActionHandler.ADD_SERVICE_PROCESS,
406 null,
407 ActionHandler.REMOVE_SERVICE_PROCESS });
408
409 mainItem.setControl(this.processesTable);
410 }
411
412 private void initInputOutputPanel(Composite parent) {
413 SashForm splitter = new SashForm(parent, SWT.HORIZONTAL );
414 splitter.setLayoutData(new GridData(GridData.FILL_BOTH));
415
416 TabFolder tabFolder = new TabFolder(splitter, SWT.NONE);
417 tabFolder.setLayout(new GridLayout(1, false));
418
419 TabItem mainItem = new TabItem(tabFolder, SWT.NONE);
420 tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
421 mainItem.setText("Input(s)");
422
423 this.inputsTable = initActionTable(tabFolder, new String[] {
424 ActionHandler.ADD_INPUT,
425 null,
426 ActionHandler.REMOVE_INPUT });
427 mainItem.setControl(this.inputsTable);
428
429 tabFolder = new TabFolder(splitter, SWT.NONE);
430 tabFolder.setLayout(new GridLayout(1, false));
431
432 mainItem = new TabItem(tabFolder, SWT.NONE);
433 tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
434 mainItem.setText("Output(s)");
435
436 this.outputsTable = initActionTable(tabFolder, new String[] {
437 ActionHandler.ADD_OUTPUT,
438 null,
439 ActionHandler.REMOVE_OUTPUT });
440 mainItem.setControl(this.outputsTable);
441 }
442
443 private void initPrecondEffectPanel(Composite parent) {
444 SashForm splitter = new SashForm(parent, SWT.HORIZONTAL );
445 splitter.setLayoutData(new GridData(GridData.FILL_BOTH));
446
447 TabFolder tabFolder = new TabFolder(splitter, SWT.NONE);
448 tabFolder.setLayout(new GridLayout(1, false));
449
450 TabItem mainItem = new TabItem(tabFolder, SWT.NONE);
451 tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
452 mainItem.setText("Precondition(s)");
453
454 this.precondsTable = initActionTable(tabFolder, new String[] {
455 ActionHandler.ADD_PRECOND,
456 null,
457 ActionHandler.EDIT_PRECOND,
458 null,
459 ActionHandler.REMOVE_PRECOND });
460 this.precondsTable.addMouseListener(new MouseAdapter() {
461 public void mouseDoubleClick(MouseEvent e) {
462 if (e.button != 1) {
463 return;
464 }
465 actionHandler.doEditAxiom(precondsTable);
466 }
467 });
468
469 mainItem.setControl(this.precondsTable);
470
471 tabFolder = new TabFolder(splitter, SWT.NONE);
472 tabFolder.setLayout(new GridLayout(1, false));
473
474 mainItem = new TabItem(tabFolder, SWT.NONE);
475 tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
476 mainItem.setText("Effect(s)");
477
478 this.effectsTable = initActionTable(tabFolder, new String[] {
479 ActionHandler.ADD_EFFECT,
480 null,
481 ActionHandler.EDIT_EFFECT,
482 null,
483 ActionHandler.REMOVE_EFFECT });
484 this.effectsTable.addMouseListener(new MouseAdapter() {
485 public void mouseDoubleClick(MouseEvent e) {
486 if (e.button != 1) {
487 return;
488 }
489 actionHandler.doEditAxiom(effectsTable);
490 }
491 });
492
493 mainItem.setControl(this.effectsTable);
494 }
495
496
497
498 private void createContextMenu(Composite parentComp, final Table clientsTable, final String[] actions) {
499 final MenuManager menuMgr = new MenuManager();
500 menuMgr.setRemoveAllWhenShown(true);
501 menuMgr.addMenuListener(new IMenuListener() {
502 public void menuAboutToShow(IMenuManager mgr) {
503 if (false == GUIHelper.containsCursor(clientsTable)) {
504 return;
505 }
506 for(int i = 0; i < actions.length; i++) {
507 final String command = actions[i];
508 if (command == null) {
509 menuMgr.add(new Separator());
510 }
511 else {
512 menuMgr.add(new Action(command) {
513 public void run() {
514 actionHandler.performAction(command, clientsTable);
515 }
516 });
517 }
518 }
519 }
520 });
521 clientsTable.setMenu(menuMgr.createContextMenu(clientsTable));
522 }
523
524 private void closeEditorWithError(final IEditorSite site, String error) {
525 if (error != null) {
526 MessageDialog.openError(site.getShell(),
527 "Invalid Input", error);
528 }
529 if (!site.getShell().isDisposed()
530 && !site.getShell().getDisplay().isDisposed()){
531 site.getShell().getDisplay().asyncExec(new Runnable() {
532 public void run() {
533 site.getPage().closeEditor(PAServiceEditor.this, false);
534 }
535 });
536 }
537
538 }
539
540 private void openNFPEditor() {
541 new NFPEditor(Display.getCurrent().getActiveShell(), model).open();
542 }
543
544 public void dispose() {
545 idField.dispose();
546 descrField.dispose();
547
548 clientTypesTable.dispose();
549 inputsTable.dispose();
550 outputsTable.dispose();
551 precondsTable.dispose();
552 effectsTable.dispose();
553
554 super.dispose();
555 }
556
557 protected void doTryToSave() throws Exception {
558 WSMORuntime.getRuntime().doUpdateEntity(model.getServiceDescription());
559 String instOntoPath = WSMORuntime.getCache().getFileLocationForId(
560 (IRI)model.getInstanceOntology().getIdentifier(),
561 WSMOTopEntity.ONTOLOGY);
562 WSMORuntime.getIOManager().saveContent(
563 model.getInstanceOntology(), new Path(instOntoPath));
564 }
565
566 private void updateFields() {
567
568 importOntosPanel.reloadOntologies();
569
570 Entity entity = (Entity)model.getAdapter(Entity.class);
571 String idText = entity.getIdentifier().toString();
572 if (entity.listNFPValues(IRIUtils.titleNFP) != null
573 && entity.listNFPValues(IRIUtils.titleNFP).size() > 0) {
574 idText += " (" + entity.listNFPValues(IRIUtils.titleNFP).iterator().next() + ")";
575 }
576 idField.setText(idText);
577
578 if (entity.listNFPValues(IRIUtils.descrNFP) != null
579 && entity.listNFPValues(IRIUtils.descrNFP).size() > 0) {
580 Object value = entity.listNFPValues(IRIUtils.descrNFP).iterator().next();
581 descrField.setText(
582 (value instanceof Entity) ?
583 ((Entity)value).getIdentifier().toString()
584 : Utils.normalizeSpaces(value.toString()));
585 }
586 wsdlField.setText(model.getWSDL());
587
588 UIUtils.updateCombo(comboServiceTypes, model.listAvailableServiceTypes(), model.getServiceType());
589 UIUtils.updateCombo(comboGovernedBy, model.listAvailableLaws(), model.getGovernedBy());
590 UIUtils.updateCombo(domainCombo, model.listAvailableDomains(), model.getDomain());
591 UIUtils.updateCombo(subDomainCombo, model.listAvailableSubDomains(), model.getSubDomain());
592 UIUtils.updateCombo(comboEffectTypes, model.listAvailableEffectTypes(), model.getEffectType());
593 UIUtils.updateCombo(comboAdminLevel, model.listAvailableAdminLevels(), model.getAdminLevel());
594 UIUtils.updateCombo(resultServiceInstanceField, model.listAvailablePAServices(), model.getPAInstanceType());
595
596 UIUtils.updateCombo(eLocationField, model.listAvailableELocations(), model.getElectronicLocation());
597 UIUtils.updateCombo(phLocationField, model.listAvailablePhLocations(), model.getPhysicalLocation());
598
599 UIUtils.updateTable(inputsTable, model.listInputs());
600 UIUtils.updateTable(outputsTable, model.listOutputs());
601 UIUtils.updateTable(clientTypesTable, model.listClientTypes());
602
603 UIUtils.updateTable(providersTable, model.listServiceProviders());
604 UIUtils.updateTable(processesTable, model.listServiceProcesses());
605
606 UIUtils.updateAxiomsTable(precondsTable, model.listPreconditions());
607 UIUtils.updateAxiomsTable(effectsTable, model.listEffects());
608
609 }
610
611 private void registerSelectionHandlers() {
612 comboServiceTypes.addSelectionChangedListener(new ISelectionChangedListener() {
613 public void selectionChanged(SelectionChangedEvent event) {
614 Object selection = ((StructuredSelection)comboServiceTypes.getSelection()).getFirstElement();
615 model.setServiceType(
616 (selection != null && selection instanceof IRI) ?
617 (IRI)selection : null);
618 }
619 });
620
621 comboGovernedBy.addSelectionChangedListener(new ISelectionChangedListener() {
622 public void selectionChanged(SelectionChangedEvent event) {
623 Object selection = ((StructuredSelection)comboGovernedBy.getSelection()).getFirstElement();
624 model.setGovernedBy(
625 (selection != null && selection instanceof IRI) ?
626 (IRI)selection : null);
627 }
628 });
629
630 domainCombo.addSelectionChangedListener(new ISelectionChangedListener() {
631 public void selectionChanged(SelectionChangedEvent event) {
632 Object selection = ((StructuredSelection)domainCombo.getSelection()).getFirstElement();
633 model.setDomain(
634 (selection != null && selection instanceof IRI) ?
635 (IRI)selection : null);
636 }
637 });
638
639 subDomainCombo.addSelectionChangedListener(new ISelectionChangedListener() {
640 public void selectionChanged(SelectionChangedEvent event) {
641 Object selection = ((StructuredSelection)subDomainCombo.getSelection()).getFirstElement();
642 model.setSubDomain(
643 (selection != null && selection instanceof IRI) ?
644 (IRI)selection : null);
645 }
646 });
647
648 comboEffectTypes.addSelectionChangedListener(new ISelectionChangedListener() {
649 public void selectionChanged(SelectionChangedEvent event) {
650 Object selection = ((StructuredSelection)comboEffectTypes.getSelection()).getFirstElement();
651 model.setEffectType(
652 (selection != null && selection instanceof IRI) ?
653 (IRI)selection : null);
654 }
655 });
656
657 resultServiceInstanceField.addSelectionChangedListener(new ISelectionChangedListener() {
658 public void selectionChanged(SelectionChangedEvent event) {
659 Object selection = ((StructuredSelection)resultServiceInstanceField.getSelection()).getFirstElement();
660 model.setPAInstanceType(
661 (selection != null && selection instanceof IRI) ?
662 (IRI)selection : null);
663 }
664 });
665
666 comboAdminLevel.addSelectionChangedListener(new ISelectionChangedListener() {
667 public void selectionChanged(SelectionChangedEvent event) {
668 Object selection = ((StructuredSelection)comboAdminLevel.getSelection()).getFirstElement();
669 model.setAdminLevel(
670 (selection != null && selection instanceof IRI) ?
671 (IRI)selection : null);
672 }
673 });
674
675 eLocationField.addSelectionChangedListener(new ISelectionChangedListener() {
676 public void selectionChanged(SelectionChangedEvent event) {
677 Object selection = ((StructuredSelection)eLocationField.getSelection()).getFirstElement();
678 model.setElectronicLocation(
679 (selection != null && selection instanceof IRI) ?
680 (IRI)selection : null);
681 }
682 });
683
684 phLocationField.addSelectionChangedListener(new ISelectionChangedListener() {
685 public void selectionChanged(SelectionChangedEvent event) {
686 Object selection = ((StructuredSelection)phLocationField.getSelection()).getFirstElement();
687 model.setPhysicalLocation(
688 (selection != null && selection instanceof IRI) ?
689 (IRI)selection : null);
690 }
691 });
692 }
693
694
695 }
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720