1   /*
2    * OntologyEditor.java
3    *
4    * Copyright (c) 2002-2004, The University of Sheffield.
5    *
6    * This file is part of GATE (see http://gate.ac.uk/), and is free
7    * software, licenced under the GNU Library General Public License,
8    * Version 2, June1991.
9    *
10   * A copy of this licence is included in the distribution in the file
11   * licence.html, and is also available at http://gate.ac.uk/gate/licence.html.
12   *
13   * borislav popov 17/04/2002
14   *
15   * $Id: OntologyEditor.java,v 1.7 2005/12/14 14:28:58 julien_nioche Exp $
16   */
17  package gate.creole.ontology;
18  
19  import gate.VisualResource;
20  import gate.creole.ResourceInstantiationException;
21  import java.util.Set;
22  import java.util.Vector;
23  import com.ontotext.gate.vr.ClassNode;
24  
25  /**
26   * An interface defining the methods of an Ontology Editor.
27   */
28  public interface OntologyEditor extends VisualResource {
29    /**
30     * Creates a new ontology
31     * 
32     * @param name
33     *          the name of the ontology
34     * @param sourceURI
35     *          the URI of the ontology
36     * @param theURL
37     *          the URL of the ontology
38     * @param comment
39     *          ontology comment
40     */
41    public void createOntology(String name, String sourceURI, String theURL,
42            String comment) throws ResourceInstantiationException;
43  
44    /**
45     * Sets the ontology to be loaded in the editor
46     * 
47     * @param o
48     *          the ontology to be loaded
49     */
50    public void setOntology(Taxonomy o);
51  
52    /**
53     * Gets the loaded ontology
54     * 
55     * @return the current ontology in the editor
56     */
57    public Taxonomy getOntology();
58  
59    /**
60     * Sets the list of ontologies to be loaded in the editor
61     * 
62     * @param list
63     *          the list of ontologies
64     */
65    public void setOntologyList(Vector list);
66  
67    /**
68     * Gets the list of ontologies currently in the editor
69     * 
70     * @return the list of ontologies
71     */
72    public Vector getOntologyList();
73  
74    /** Visualizes the editor */
75    public void visualize();
76  
77    /**
78     * Invokes an add sub class dialog in position x,y
79     * 
80     * @param x
81     *          the x coordinate of the dialog
82     * @param y
83     *          the y coordinate of the dialog
84     */
85    public void addSubClass(int x, int y);
86  
87    /**
88     * Adds Sub Class given a ClassNode and the resulting info from the Add Sub
89     * Class dialog.
90     * 
91     * @param root
92     *          the node which is root to the sub class being added
93     * @param className
94     *          the name from the dialog
95     * @param classComment
96     *          the comment from the dialog
97     */
98    public void addSubClass(ClassNode root, String className, String classComment);
99  
100   /**
101    * Removes the node/class
102    * 
103    * @param node
104    *          the node to be removed
105    */
106   public void removeClass(ClassNode node);
107 
108   /**
109    * Renames a class
110    * 
111    * @param c
112    *          the class to be renamed
113    * @param n
114    *          the class node associated with the class
115    * @param x
116    *          coords
117    * @param y
118    *          coords
119    */
120   public void renameClass(TClass c, ClassNode n, int x, int y);
121 
122   /**
123    * Selects an ontology. Is called when an ontology has been selecte from the
124    * ontology list.
125    * 
126    * @param o
127    *          the selected ontology
128    */
129   public void ontologySelected(Taxonomy o);
130 
131   /**
132    * Saves a list of ontologies.
133    * 
134    * @param list
135    *          a list of ontologies to be saved
136    */
137   public void saveOntologies(Vector list);
138 
139   /**
140    * Closes list of ontologies
141    * 
142    * @param list
143    *          a list of ontologies to be saved
144    */
145   public void closeOntologies(Vector list)
146           throws ResourceInstantiationException;
147 
148   /**
149    * Gets all modified ontologies.
150    * 
151    * @return list of the modified ontologies
152    */
153   public Vector getModifiedOntologies();
154 
155   /*----------ontologies list popup menu item listeners------------
156    note: these methods could be invoked from within a listener or explicitly*/
157   /**
158    * Saves this ontology
159    * 
160    * @param o
161    *          the ontology to be saved
162    * @throws {@link ResourceInstantiationException}
163    */
164   public void saveOntology(Taxonomy o) throws ResourceInstantiationException;
165 
166   /**
167    * Invokes a Save As dialog for this ontology and saves it to the specified
168    * location.
169    * 
170    * @param o
171    *          the ontology to be saved
172    * @param x
173    *          the x coordinate of the save as dialog
174    * @param y
175    *          the y coordinate of the save as dialog
176    */
177   public void saveAsOntology(Taxonomy o, int x, int y)
178           throws ResourceInstantiationException;
179 
180   /**
181    * Renames an ontology
182    * 
183    * @param o
184    *          the ontology to be renamed
185    * @param x
186    *          the x coordinate of the rename dialog
187    * @param y
188    *          the y coordinate of the rename dialog
189    */
190   public void renameOntology(Taxonomy o, int x, int y);
191 
192   /**
193    * Deletes an ontology. Invokes AreYouSureDialog if the ontology has been
194    * changed.
195    * 
196    * @param o
197    *          the ontology to be deleted
198    * @param x
199    *          x coordinate of the option pane to be invoked
200    * @param y
201    *          y coordinate of the option pane to be invoked
202    */
203   public void deleteOntology(Taxonomy o, int x, int y)
204           throws ResourceInstantiationException;
205 
206   /**
207    * Edits the URI of an ontology.
208    * 
209    * @param o
210    *          the ontology to be edited
211    * @param x
212    *          coords of the dialog
213    * @param y
214    *          coords of the dialog
215    */
216   public void editURI(Taxonomy o, int x, int y);
217 
218   /**
219    * Edit the URI of an ontology class
220    * 
221    * @param c
222    *          class to be edited
223    * @param x
224    *          coords of the dialog
225    * @param y
226    *          coords of the dialog
227    */
228   public void editClassURI(TClass c, int x, int y);
229 
230   /**
231    * Gets all URIs that are present at the moment as ontology URIs.
232    * 
233    * @return all the uris that are available in the editor
234    */
235   public Set getAllURIs();
236 
237   /**
238    * Retrieve a set of all the class URIs in an ontology
239    * 
240    * @param o
241    *          the ontology
242    * @return set of all the URIs in the ontology
243    */
244   public Set getAllURIs(Taxonomy o);
245 
246   /**
247    * Closes an ontology. Invokes AreYouSureDialog if the ontology has been
248    * changed.
249    * 
250    * @param o
251    *          the ontology to be closed
252    * @param x
253    *          x coordinate of the option pane to be invoked
254    * @param y
255    *          y coordinate of the option pane to be invoked
256    */
257   public void closeOntology(Taxonomy o, int x, int y)
258           throws ResourceInstantiationException;
259 
260   /* End-------ontologies list popup menu item listeners------------ */
261   /**
262    * Wanna Save Dialog invocation.
263    * 
264    * @param o
265    *          the ontology to be saved or not
266    * @param x
267    *          x coordinate of the option pane to be invoked
268    * @param y
269    *          y coordinate of the option pane to be invoked
270    * @return the result of the option pane
271    */
272   public int AskWannaSave(Taxonomy o, int x, int y);
273 
274   /*------------- menu bar methods --------------*/
275   /**
276    * Acts on choosing Exit from the File menu.
277    */
278   public void fileExit();
279 
280   /**
281    * Acts on choosing Open from the File menu.
282    * 
283    * @param x
284    *          the x coordinate of the invocation
285    * @param y
286    *          the y coordinate of the invocation
287    * @throws ResourceInstantiationException
288    *           if something goes wrong with the loading.
289    */
290   public void fileOpen(int x, int y) throws ResourceInstantiationException;
291 
292   /**
293    * Invoke a mutiple selection save dialog with a list of ontologies to be
294    * saved.
295    * 
296    * @param x
297    *          coords of the dialog
298    * @param y
299    *          coords of the dialog
300    * @param ontologies
301    *          the list of ontologies to be optionally saved
302    */
303   public void fileSave(int x, int y, Vector ontologies);
304 
305   /**
306    * Invokes a mutiple selection close dialog with a list of ontologies to be
307    * closed.
308    * 
309    * @param x
310    *          coords of the dialog
311    * @param y
312    *          coords of the dialog
313    * @param ontologies
314    *          the list of ontologies to be optionally closed
315    */
316   public void fileClose(int x, int y, Vector ontologies);
317 
318   /**
319    * Inovkes a new ontology dialog.
320    * 
321    * @param x
322    *          coords of the dialog
323    * @param y
324    *          coords of the dialog
325    */
326   public void fileNew(int x, int y);
327 }// interface OntologyEditor
328