+
+ private class RepositoryNode extends TreeParent {
+ private final String name;
+ private final Repository repository;
+ private Session defaultSession = null;
+
+ public RepositoryNode(String name, Repository repository) {
+ super(name);
+ this.name = name;
+ this.repository = repository;
+ }
+
+ public Repository getRepository() {
+ return repository;
+ }
+
+ public Session getDefaultSession() {
+ return defaultSession;
+ }
+
+ public void login() {
+ try {
+ defaultSession = repository.login();
+ String[] wkpNames = defaultSession.getWorkspace()
+ .getAccessibleWorkspaceNames();
+ for (String wkpName : wkpNames) {
+ if (wkpName.equals(defaultSession.getWorkspace().getName()))
+ addChild(new WorkspaceNode(repository, wkpName,
+ defaultSession));
+ else
+ addChild(new WorkspaceNode(repository, wkpName));
+ }
+ nodesViewer.refresh(this);
+ } catch (RepositoryException e) {
+ throw new ArgeoException(
+ "Cannot connect to repository " + name, e);
+ }
+ }
+ }
+
+ private class WorkspaceNode extends TreeParent {
+ private final String name;
+ private final Repository repository;
+ private Session session = null;
+
+ public WorkspaceNode(Repository repository, String name) {
+ this(repository, name, null);
+ }
+
+ public WorkspaceNode(Repository repository, String name, Session session) {
+ super(name);
+ this.name = name;
+ this.repository = repository;
+ this.session = session;
+ }
+
+ public Session getSession() {
+ return session;
+ }
+
+ public void login() {
+ try {
+ if (session != null)
+ session.logout();
+
+ session = repository.login(name);
+ nodesViewer.refresh(this);
+ } catch (RepositoryException e) {
+ throw new ArgeoException(
+ "Cannot connect to repository " + name, e);
+ }
+ }
+
+ }