- /*
- * PROPERTIES
- */
- private class PropertiesContentProvider implements
- IStructuredContentProvider {
-
- public void dispose() {
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
-
- public Object[] getElements(Object inputElement) {
- try {
- if (inputElement instanceof Node) {
- Set<Property> props = new TreeSet<Property>(itemComparator);
- PropertyIterator pit = ((Node) inputElement)
- .getProperties();
- while (pit.hasNext())
- props.add(pit.nextProperty());
- return props.toArray();
- }
- return new Object[] {};
- } catch (RepositoryException e) {
- throw new ArgeoException("Cannot get element for "
- + inputElement, e);
- }
- }
-
- }
-
- 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);
- }
- }
-