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.ui.views.navigator.actions;
26
27
28
29 import org.eclipse.jface.dialogs.MessageDialog;
30 import org.eclipse.jface.viewers.IStructuredSelection;
31 import org.eclipse.ui.*;
32 import org.wsmo.common.Entity;
33 import org.wsmostudio.runtime.LogManager;
34 import org.wsmostudio.ui.*;
35 import org.wsmostudio.ui.editors.WSMOEditorInput;
36 import org.wsmostudio.ui.editors.model.ObservableModel;
37 import org.wsmostudio.ui.views.navigator.WSMONavigator;
38
39 /***
40 * An action belonging to the context menu of the <i>WSMO Navigator</i> view.
41 * This action opens the selected object with a suitable editor. It relies on
42 * the <code>org.wsmostudio.ui.editors.extension.ExtensionManager</code> to
43 * determine the most appropriate editor to use.
44 *
45 * @author not attributable
46 * @version $Revision: 1.11 $ $Date: 2006/01/09 12:51:14 $
47 */
48
49 public class EditAction extends AbstractAction {
50
51 public EditAction() {
52 super();
53 }
54
55 public EditAction(WSMONavigator navi) {
56 super();
57 navigator = navi;
58 }
59
60 public void run() {
61 Object target =
62 ((IStructuredSelection)navigator.getTree().getSelection()).getFirstElement();
63
64 if (target instanceof Entity
65 && Utils.isAProxy(target)) {
66 MessageDialog.openError(navigator.getSite().getShell(),
67 "External Object",
68 "The selected object has no local definition and cannot be shown!");
69 return;
70 }
71
72 String targetEditorID = WsmoUIPlugin.getDefault()
73 .getExtensionManager()
74 .locateEditorForEntity((Entity)target);
75
76 if (targetEditorID != null) {
77 try {
78 ObservableModel model = Utils.createEditorModel(target,
79 (ObservableModel)navigator.getWsmoInput().getAdapter(ObservableModel.class),
80 targetEditorID);
81 IEditorInput input = new WSMOEditorInput(target, model);
82 PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
83 .openEditor(input, targetEditorID);
84 }
85 catch(PartInitException pie) {
86 LogManager.logError("Error opening editor \n"+pie.getMessage(), pie);
87 }
88 }
89 }
90 }
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117