View Javadoc
1   /* 
2    WSMO Studio - a Semantic Web Service Editor
3    Copyright (c) 2004-2006, OntoText Lab. / SIRMA Group
4    
5    This library is free software; you can redistribute it and/or modify it under
6    the terms of the GNU Lesser General Public License as published by the Free
7    Software Foundation; either version 2.1 of the License, or (at your option)
8    any later version.
9    This library is distributed in the hope that it will be useful, but WITHOUT
10   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   details.
13   You should have received a copy of the GNU Lesser General Public License along
14   with this library; if not, write to the Free Software Foundation, Inc.,
15   59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
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.editors;
26  
27  import org.eclipse.swt.SWT;
28  import org.eclipse.swt.custom.SashForm;
29  import org.eclipse.swt.layout.*;
30  import org.eclipse.swt.widgets.*;
31  import org.eclipse.ui.*;
32  import org.wsmostudio.runtime.WSMORuntime;
33  import org.wsmostudio.ui.editors.common.*;
34  import org.wsmostudio.ui.editors.model.OntologyModel;
35  
36  /***
37   * An editor component, subclass of WSMOEditor, capable to handle with WSMO-API 
38   * Ontology objects.
39   * This editor appears as a part of the WSMO Studio workbench. It is the default
40   * editor implementation for this kind of objects and it can be replaced by 
41   * extending extension points <code>org.wsmostudio.ui.editors</code> and 
42   * <code>org.eclipse.ui.editors</code>.
43   *
44   * @author not attributable
45   * @version $Revision: 1.8 $ $Date: 2006/01/09 12:51:13 $
46   */
47  
48  public class OntologyEditor extends WSMOEditor {
49  
50      private NFPPanel nfpPanel;
51      private NamespacesPanel nsPanel;
52      private ImportOntologyPanel ontologiesPanel;
53      private UsedMediatorsPanel mediatorsPanel;
54      
55      private OntologyModel model;
56      
57      private TabFolder importOntosFolder, usedMedsFolder;
58      
59      public void createPartControl(Composite parent) {
60          GridLayout mainLayout = new GridLayout(1, false);
61          mainLayout.verticalSpacing = 0;
62          parent.setLayout(mainLayout);
63          
64          nfpPanel = new NFPPanel(parent, model);
65          
66          SashForm splitter = new SashForm(parent, SWT.VERTICAL );
67          splitter.setLayoutData(new GridData(GridData.FILL_BOTH));
68  
69          nsPanel = new NamespacesPanel(splitter, model);
70          
71          importOntosFolder = new TabFolder(splitter, SWT.NONE);
72          ontologiesPanel = new ImportOntologyPanel(
73                  importOntosFolder, 
74                  model);
75          
76          usedMedsFolder = new TabFolder(splitter, SWT.NONE);
77          mediatorsPanel = new UsedMediatorsPanel(usedMedsFolder, model);
78          
79      }
80      
81      public void init(IEditorSite site, IEditorInput input) throws PartInitException {
82          super.init(site, input);
83          this.model = (OntologyModel)input.getAdapter(OntologyModel.class);
84      }
85  
86      public void dispose() {
87          nsPanel.dispose();
88          nfpPanel.dispose();
89          super.dispose();
90      }
91      
92      protected void doTryToSave() throws Exception {
93  
94          nsPanel.doUpdate();
95          WSMORuntime.getRuntime().doUpdateEntity(model.getOntology());
96      }
97      
98      @SuppressWarnings("unchecked")
99      protected void updateFromModel() {
100         nsPanel.reloadNSInfo();
101         ontologiesPanel.reloadOntologies();
102         mediatorsPanel.reloadMediators();
103     }
104 }
105 
106 /*
107  * $Log: OntologyEditor.java,v $
108  * Revision 1.8  2006/01/09 12:51:13  alex_simov
109  * Copyright message in header updated
110  *
111  * Revision 1.7  2005/11/09 16:17:39  alex_simov
112  * UIModels notification improved
113  *
114  * Revision 1.6  2005/11/02 14:50:57  alex_simov
115  * moving to MVC architecture cont'd
116  *
117  * Revision 1.5  2005/07/29 15:08:02  alex_simov
118  * added javadoc: class description, footer
119  *
120  *
121  */