]> git.argeo.org Git - gpl/argeo-slc.git/blob - org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/DistWkspEditorInput.java
Adapt to changes in Argeo Commons.
[gpl/argeo-slc.git] / org.argeo.slc.client.ui.dist / src / org / argeo / slc / client / ui / dist / editors / DistWkspEditorInput.java
1 /*
2 * Copyright (C) 2007-2012 Argeo GmbH
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.argeo.slc.client.ui.dist.editors;
17
18 import org.argeo.slc.SlcException;
19 import org.argeo.slc.SlcNames;
20 import org.eclipse.jface.resource.ImageDescriptor;
21 import org.eclipse.ui.IEditorInput;
22 import org.eclipse.ui.IPersistableElement;
23
24 /** An editor input pointing to a distribution workspace */
25 public class DistWkspEditorInput implements IEditorInput, SlcNames {
26
27 // Injected
28 // private RepositoryFactory repositoryFactory;
29 // private Keyring keyring;
30 // private Node repoNode;
31 private String repoNodePath;
32 private String uri;
33
34 // Local variables
35 private String workspaceName;
36
37 // public WorkspaceEditorInput(RepositoryFactory repositoryFactory,
38 // Keyring keyring, Repository localRepository, Node repoNode,
39 // String uri) {
40 // // this.repositoryFactory = repositoryFactory;
41 // // this.keyring = keyring;
42 // this.localRepository = localRepository;
43 // // this.repoNode= repoNode;
44 // this.uri = uri;
45 //
46 // }
47
48 /** uri and workspace name cannot be null */
49 public DistWkspEditorInput(String repoNodePath, String uri,
50 String workspaceName) {
51 if (workspaceName == null)
52 throw new SlcException("Workspace name cannot be null");
53 if (uri == null)
54 throw new SlcException("URI for repository cannot be null");
55 this.repoNodePath = repoNodePath;
56 this.workspaceName = workspaceName;
57 this.uri = uri;
58 }
59
60 public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
61 return null;
62 }
63
64 public boolean exists() {
65 return true;
66 }
67
68 public ImageDescriptor getImageDescriptor() {
69 return null;
70 }
71
72 // Dummy compulsory methods
73 public String getToolTipText() {
74 return "Editor for workspace " + workspaceName
75 + " in repository of URI " + uri;
76 }
77
78 public String getName() {
79 return workspaceName + "@" + uri;
80 }
81
82 public IPersistableElement getPersistable() {
83 return null;
84 }
85
86 public boolean equals(Object obj) {
87 if (this == obj)
88 return true;
89 if (obj == null)
90 return false;
91 if (!(obj instanceof DistWkspEditorInput))
92 return false;
93
94 DistWkspEditorInput other = (DistWkspEditorInput) obj;
95
96 if (!workspaceName.equals(other.getWorkspaceName()))
97 return false;
98 if (!uri.equals(other.getUri()))
99 return false;
100
101 if (repoNodePath == null)
102 return other.getRepoNodePath() == null;
103 else
104 return repoNodePath.equals(other.getRepoNodePath());
105 }
106
107 public String getUri() {
108 return uri;
109 }
110
111 public String getWorkspaceName() {
112 return workspaceName;
113 }
114
115 public String getRepoNodePath() {
116 return repoNodePath;
117 }
118 }