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.widgets.Composite;
28  import org.eclipse.ui.*;
29  import org.wsmo.common.TopEntity;
30  import org.wsmostudio.runtime.WSMORuntime;
31  import org.wsmostudio.ui.editors.model.*;
32  
33  /***
34   * An editor component, subclass of WSMOEditor, capable to handle with WSMO-API 
35   * Axiom objects.
36   * This editor appears as a part of the WSMO Studio workbench. It is the default
37   * editor implementation for this kind of objects and it can be replaced by 
38   * extending extension points <code>org.wsmostudio.ui.editors</code> and 
39   * <code>org.eclipse.ui.editors</code>.
40   *
41   * @author not attributable
42   * @version $Revision: 1.9 $ $Date: 2006/01/09 12:51:13 $
43   */
44  
45  public class AxiomEditor extends WSMOEditor {
46      
47      private AxiomEditorPanel mainEditor;
48      private AxiomModel axiomModel;
49  
50      
51      public void createPartControl(Composite parent) {
52          
53          mainEditor = new AxiomEditorPanel(parent, axiomModel);
54      }
55      
56      public void init(IEditorSite site, IEditorInput input) throws PartInitException {
57          super.init(site, input);
58          axiomModel = (AxiomModel)input.getAdapter(AxiomModel.class);
59      }
60  
61      protected void updateFromModel() {
62          mainEditor.reloadDefinitionsInTable();
63      }
64  
65      public void dispose() {
66          mainEditor.dispose();
67          axiomModel = null;
68          super.dispose();
69      }
70  
71      public void setFocus() {
72          super.setFocus();
73          mainEditor.setFocus();
74      }
75      
76      protected void doTryToSave() throws Exception {
77          mainEditor.doUpdate();
78          ObservableModel topModel = (ObservableModel)axiomModel;
79          while (topModel.getMasterModel() != null) {
80              topModel = topModel.getMasterModel();
81          }
82          WSMORuntime.getRuntime().doUpdateEntity(
83                  (TopEntity)topModel.getAdapter(TopEntity.class));
84      }
85  
86  }
87  
88  /*
89   * $Log: AxiomEditor.java,v $
90   * Revision 1.9  2006/01/09 12:51:13  alex_simov
91   * Copyright message in header updated
92   *
93   * Revision 1.8  2005/11/24 16:47:13  alex_simov
94   * doTryToSave() updated - TopEntity container retrieved via UI models
95   *
96   * Revision 1.7  2005/11/09 16:17:39  alex_simov
97   * UIModels notification improved
98   *
99   * Revision 1.6  2005/11/02 08:57:02  alex_simov
100  * moving to a better Model-View-Contoller architecture
101  *
102  * Revision 1.5  2005/07/29 15:08:02  alex_simov
103  * added javadoc: class description, footer
104  *
105  *
106  */