]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/commands/DisplayRepoInformation.java
+ clean repo model
[gpl/argeo-slc.git] / plugins / org.argeo.slc.client.ui.dist / src / main / java / org / argeo / slc / client / ui / dist / commands / DisplayRepoInformation.java
index e439491c9cb0aa0f717391231e9e6df436f349d6..3325092de8b7c584218b048b4bff1fa8b493a391 100644 (file)
  */
 package org.argeo.slc.client.ui.dist.commands;
 
-import javax.jcr.RepositoryException;
+import javax.jcr.Repository;
 import javax.jcr.Session;
 
 import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
 import org.argeo.slc.client.ui.dist.DistPlugin;
+import org.argeo.slc.client.ui.dist.RepoService;
 import org.argeo.slc.client.ui.dist.model.RepoElem;
 import org.eclipse.core.commands.AbstractHandler;
 import org.eclipse.core.commands.ExecutionEvent;
@@ -42,7 +42,7 @@ import org.eclipse.swt.widgets.Text;
 import org.eclipse.ui.handlers.HandlerUtil;
 
 /**
- * Opens a popup that displays various information on the current reppository.
+ * Open a dialog that displays various information on the current repository.
  */
 public class DisplayRepoInformation extends AbstractHandler {
        public final static String ID = DistPlugin.ID + ".displayRepoInformation";
@@ -50,28 +50,37 @@ public class DisplayRepoInformation extends AbstractHandler {
        public final static ImageDescriptor DEFAULT_ICON = DistPlugin
                        .getImageDescriptor("icons/help.gif");
 
+       /* DEPENDENCY INJECTION */
+       private RepoService repoService;
+       private Repository nodeRepository;
+
        public Object execute(ExecutionEvent event) throws ExecutionException {
                IStructuredSelection iss = (IStructuredSelection) HandlerUtil
                                .getActiveSite(event).getSelectionProvider().getSelection();
                if (iss.getFirstElement() instanceof RepoElem) {
                        RepoElem re = (RepoElem) iss.getFirstElement();
-                       InformationDialog inputDialog = new InformationDialog(HandlerUtil
-                                       .getActiveSite(event).getShell());
-                       inputDialog.create();
-                       Session session = null;
+
+                       Session defaultSession = null;
                        try {
-                               session = re.getRepository().login(re.getCredentials());
-                               inputDialog.loginTxt.setText(session.getUserID());
+                               defaultSession = repoService.getRemoteSession(re.getRepoNodePath(),
+                                               re.getUri(), null);
+
+                               InformationDialog inputDialog = new InformationDialog(
+                                               HandlerUtil.getActiveSite(event).getShell());
+                               inputDialog.create();
+                               // TODO add more information.
+                               inputDialog.loginTxt.setText(defaultSession.getUserID());
                                inputDialog.nameTxt.setText(re.getLabel());
                                inputDialog.uriTxt.setText(re.getUri());
                                inputDialog.readOnlyBtn.setSelection(re.isReadOnly());
-                       } catch (RepositoryException e) {
-                               throw new SlcException("Unexpected error while "
-                                               + "getting repository information.", e);
+
+                               inputDialog.open();
+                               // } catch (RepositoryException e) {
+                               // throw new SlcException("Unexpected error while "
+                               // + "getting repository information.", e);
                        } finally {
-                               JcrUtils.logoutQuietly(session);
+                               JcrUtils.logoutQuietly(defaultSession);
                        }
-                       inputDialog.open();
                }
                return null;
        }
@@ -117,7 +126,7 @@ public class DisplayRepoInformation extends AbstractHandler {
 
                /** Creates label and text. */
                protected Text createLT(Composite parent, String label) {
-                       new Label(parent, SWT.NONE).setText(label);
+                       new Label(parent, SWT.RIGHT).setText(label);
                        Text text = new Text(parent, SWT.SINGLE | SWT.LEAD | SWT.NONE);
                        text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
                        text.setEditable(false);
@@ -126,7 +135,7 @@ public class DisplayRepoInformation extends AbstractHandler {
 
                /** Creates label and check. */
                protected Button createLC(Composite parent, String label) {
-                       new Label(parent, SWT.NONE).setText(label);
+                       new Label(parent, SWT.RIGHT).setText(label);
                        Button check = new Button(parent, SWT.CHECK);
                        check.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
                        check.setEnabled(false);
@@ -138,4 +147,14 @@ public class DisplayRepoInformation extends AbstractHandler {
                        shell.setText("Repository information");
                }
        }
+
+       /* DEPENDENCY INJECTION */
+       public void setRepoService(RepoService repoService) {
+               this.repoService = repoService;
+       }
+
+       public void setNodeRepository(Repository nodeRepository) {
+               this.nodeRepository = nodeRepository;
+       }
+
 }
\ No newline at end of file