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.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
99
100
101
102
103
104
105
106
107
108
109
110
111