]> git.argeo.org Git - lgpl/argeo-commons.git/blob - ArgeoUserEditorInput.java
51aeeef80f314f1937b0d0717b46012ad43f6a5d
[lgpl/argeo-commons.git] / ArgeoUserEditorInput.java
1 package org.argeo.security.ui.admin.editors;
2
3 import javax.jcr.Node;
4 import javax.jcr.PathNotFoundException;
5 import javax.jcr.RepositoryException;
6 import javax.jcr.ValueFormatException;
7
8 import org.argeo.ArgeoException;
9 import org.argeo.jcr.ArgeoNames;
10 import org.eclipse.jface.resource.ImageDescriptor;
11 import org.eclipse.ui.IEditorInput;
12 import org.eclipse.ui.IPersistableElement;
13
14 /** Editor input for an Argeo user. */
15 public class ArgeoUserEditorInput implements IEditorInput {
16 private final String username;
17 private final Node userHome;
18
19 @Deprecated
20 public ArgeoUserEditorInput(String username) {
21 this.username = username;
22 this.userHome = null;
23 }
24
25 public ArgeoUserEditorInput(Node userHome) {
26 try {
27 this.username = userHome.getProperty(ArgeoNames.ARGEO_USER_ID)
28 .getString();
29 this.userHome = userHome;
30 } catch (RepositoryException e) {
31 throw new ArgeoException("Cannot initialize editor input for "
32 + userHome, e);
33 }
34 }
35
36 public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
37 return null;
38 }
39
40 public boolean exists() {
41 return username != null;
42 }
43
44 public ImageDescriptor getImageDescriptor() {
45 return null;
46 }
47
48 public String getName() {
49 return username != null ? username : "<new user>";
50 }
51
52 public IPersistableElement getPersistable() {
53 return null;
54 }
55
56 public String getToolTipText() {
57 return username != null ? username : "<new user>";
58 }
59
60 public boolean equals(Object obj) {
61 if (!(obj instanceof ArgeoUserEditorInput))
62 return false;
63 if (((ArgeoUserEditorInput) obj).getUsername() == null)
64 return false;
65 return ((ArgeoUserEditorInput) obj).getUsername().equals(username);
66 }
67
68 public String getUsername() {
69 return username;
70 }
71
72 public Node getUserHome() {
73 return userHome;
74 }
75
76 }