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.repository.ui;
26  
27  import org.eclipse.jface.resource.ImageDescriptor;
28  import org.eclipse.jface.resource.JFaceResources;
29  import org.eclipse.ui.IEditorInput;
30  import org.eclipse.ui.IPersistableElement;
31  import org.wsmo.datastore.WsmoRepository;
32  import org.wsmostudio.runtime.WsmoImageRegistry;
33  
34  /***
35   * RepositoryContent is an implementation of IEditorInput and serves as a descriptor
36   * of the Repository Editor input. It supplies information like repository name,
37   * image descriptor and the repository instance itself.
38   * The repository content is passed to the editor via the RepositoryEditor.init method.
39   * This implementation supplies access to the repository instance via IAdaptable.getAdapter
40   * method. 
41   *
42   * @author not attributable
43   * @version $Revision: 469 $ $Date: 2006-01-09 14:51:14 +0200 $
44   */
45  
46  
47  public class RepositoryContent implements IEditorInput {
48  
49     private WsmoRepository repository = null;
50     
51     public RepositoryContent(WsmoRepository proxy) {
52         repository = proxy;
53     }
54     
55     public ImageDescriptor getImageDescriptor() {
56         return JFaceResources.getImageRegistry()
57                                  .getDescriptor(
58                                          WsmoImageRegistry.REPOSITORY_ICON);
59     }
60  
61     public String getName() {
62         return repository.getDescription();
63     }
64  
65     public IPersistableElement getPersistable() {
66         return null;
67     }
68  
69     public String getToolTipText() {
70         return getName();
71     }
72  
73     public Object getAdapter(Class adapter) {
74         if (adapter.equals(WsmoRepository.class)) {
75                 return repository;
76         }
77         return null;
78     }
79  
80     public boolean equals(Object another) {
81         if (another == null 
82                 || false == another instanceof RepositoryContent) {
83             return false;
84         }
85         return repository.equals(((IEditorInput)another).getAdapter(WsmoRepository.class));
86     }
87     
88     public int hashCode() {
89         return repository.hashCode();
90     }
91  
92     public boolean exists() {
93         return false;
94     }
95  }
96  
97  /*
98   * $Log$
99   * Revision 1.6  2006/01/09 12:51:11  alex_simov
100  * Copyright message in header updated
101  *
102  * Revision 1.5  2005/09/30 12:11:19  alex_simov
103  * mistyping: hashcode() -> hashCode()
104  *
105  * Revision 1.4  2005/08/02 10:33:19  alex_simov
106  * minor code and/or javadoc fixes
107  *
108  * Revision 1.3  2005/07/21 11:46:32  alex_simov
109  * added javadoc: class description, footer
110  *
111  */