Full refactoring of the UI distribution view:
authorBruno Sinou <bsinou@argeo.org>
Fri, 28 Feb 2014 20:28:45 +0000 (20:28 +0000)
committerBruno Sinou <bsinou@argeo.org>
Fri, 28 Feb 2014 20:28:45 +0000 (20:28 +0000)
+ introduce group base in the tree viewer
+ prepare the use of listener for refresh
+ remove hard links between the various UI parts
+ clean the UI object model

git-svn-id: https://svn.argeo.org/slc/trunk@6861 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

26 files changed:
plugins/org.argeo.slc.client.ui.dist/META-INF/spring/commands.xml
plugins/org.argeo.slc.client.ui.dist/META-INF/spring/editors.xml
plugins/org.argeo.slc.client.ui.dist/plugin.xml
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/DistImages.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/DistributionPerspective.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/commands/DisplayRepoInformation.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/commands/OpenWorkspaceEditor.java [new file with mode: 0644]
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/controllers/AnonymousDistTreeContentProvider.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/controllers/DistTreeComparator.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/controllers/DistTreeComparer.java [new file with mode: 0644]
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/controllers/DistTreeContentProvider.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/controllers/DistTreeDoubleClickListener.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/controllers/DistTreeLabelProvider.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/DistributionOverviewPage.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/DistributionWorkspaceEditor.java [new file with mode: 0644]
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/GroupBaseEditorInput.java [new file with mode: 0644]
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/WorkspaceEditorInput.java [new file with mode: 0644]
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/model/DistParentElem.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/model/GroupBaseElem.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/model/RepoElem.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/model/WkspGroupElem.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/model/WorkspaceElem.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/views/AnonymousDistributionsView.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/views/DistributionsView.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/wizards/RegisterRepoWizard.java
runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/RepoUtils.java

index 92a326ed27fa27bad7509c2209a3069c947bbd2d..858d11fbb92262639bcfc595d1606e15d6d782ae 100644 (file)
@@ -4,50 +4,63 @@
        xsi:schemaLocation="http://www.springframework.org/schema/beans
         http://www.springframework.org/schema/beans/spring-beans.xsd">
 
-       <bean id="org.argeo.slc.client.ui.dist.openGenericJcrQueryEditor"
-               class="org.argeo.eclipse.ui.jcr.commands.OpenGenericJcrQueryEditor"
-               scope="prototype">
-               <property name="editorId"
-                       value="org.argeo.slc.client.ui.dist.genericJcrQueryEditor" />
-       </bean>
-
-       <bean id="runInOSGi" class="org.argeo.slc.client.ui.dist.commands.RunInOsgi"
-               scope="prototype">
-               <property name="repository" ref="javaRepository" />
-               <property name="workspace" value="org.argeo.tp-1.3.1" />
+       <!-- DISTRIBUTIONS MANAGEMENT -->
+       <bean id="normalizeDistribution"
+               class="org.argeo.slc.client.ui.dist.commands.NormalizeDistribution">
+               <property name="repositoryFactory" ref="repositoryFactory" />
+               <property name="nodeRepository" ref="nodeRepository" />
+               <property name="keyring" ref="keyring" />
        </bean>
 
-       <bean id="fetch" class="org.argeo.slc.client.ui.dist.commands.Fetch"
-               scope="prototype">
+       <!-- REPOSITORY MANAGEMENT -->
+       <bean id="registerRepository"
+               class="org.argeo.slc.client.ui.dist.commands.RegisterRepository">
                <property name="repositoryFactory" ref="repositoryFactory" />
                <property name="nodeRepository" ref="nodeRepository" />
                <property name="keyring" ref="keyring" />
        </bean>
+
        <bean id="unregisterRemoteRepo"
                class="org.argeo.slc.client.ui.dist.commands.UnregisterRemoteRepo"
                scope="prototype">
                <property name="nodeRepository" ref="nodeRepository" />
        </bean>
 
-       <bean id="manageWorkspaceAuth"
-               class="org.argeo.slc.client.ui.dist.commands.ManageWorkspaceAuth"
+       <bean id="displayRepoInformation"
+               class="org.argeo.slc.client.ui.dist.commands.DisplayRepoInformation"
                scope="prototype">
-               <property name="repository" ref="javaRepository" />
+               <property name="repositoryFactory" ref="repositoryFactory" />
+               <property name="keyring" ref="keyring" />
        </bean>
-       <bean id="refreshDistributionsView"
-               class="org.argeo.slc.client.ui.dist.commands.RefreshDistributionsView"
+
+
+       <!-- WORKSPACE MANAGEMENT -->
+       <bean id="openWorkspaceEditor" class="org.argeo.slc.client.ui.dist.commands.OpenWorkspaceEditor"
                scope="prototype">
+               <property name="localRepository" ref="nodeRepository" />
        </bean>
-       <bean id="org.argeo.slc.client.ui.dist.deleteArtifacts" class="org.argeo.slc.client.ui.dist.commands.DeleteArtifacts"
+
+       <bean id="fetch" class="org.argeo.slc.client.ui.dist.commands.Fetch"
                scope="prototype">
+               <property name="repositoryFactory" ref="repositoryFactory" />
+               <property name="keyring" ref="keyring" />
+               <property name="nodeRepository" ref="nodeRepository" />
        </bean>
-       <bean id="refreshDistributionOverviewPage"
-               class="org.argeo.slc.client.ui.dist.commands.RefreshDistributionOverviewPage"
+
+       <bean id="manageWorkspaceAuth"
+               class="org.argeo.slc.client.ui.dist.commands.ManageWorkspaceAuth"
                scope="prototype">
+               <property name="repository" ref="javaRepository" />
        </bean>
 
-       <bean id="registerRepository"
-               class="org.argeo.slc.client.ui.dist.commands.RegisterRepository">
+       <bean id="publishWorkspace" class="org.argeo.slc.client.ui.dist.commands.PublishWorkspace">
+               <property name="repositoryFactory" ref="repositoryFactory" />
+               <property name="nodeRepository" ref="nodeRepository" />
+               <property name="keyring" ref="keyring" />
+       </bean>
+
+       <bean id="normalizeWorkspace"
+               class="org.argeo.slc.client.ui.dist.commands.NormalizeWorkspace">
                <property name="repositoryFactory" ref="repositoryFactory" />
                <property name="nodeRepository" ref="nodeRepository" />
                <property name="keyring" ref="keyring" />
                <property name="nodeRepository" ref="nodeRepository" />
                <property name="keyring" ref="keyring" />
        </bean>
+
        <bean id="copyWorkspace" class="org.argeo.slc.client.ui.dist.commands.CopyWorkspace">
                <property name="repositoryFactory" ref="repositoryFactory" />
                <property name="nodeRepository" ref="nodeRepository" />
                <property name="keyring" ref="keyring" />
        </bean>
+
        <bean id="mergeWorkspaces" class="org.argeo.slc.client.ui.dist.commands.MergeWorkspaces">
                <property name="repositoryFactory" ref="repositoryFactory" />
                <property name="nodeRepository" ref="nodeRepository" />
                <property name="keyring" ref="keyring" />
        </bean>
+
        <bean id="deleteWorkspace" class="org.argeo.slc.client.ui.dist.commands.DeleteWorkspace">
                <property name="repositoryFactory" ref="repositoryFactory" />
                <property name="nodeRepository" ref="nodeRepository" />
                <property name="keyring" ref="keyring" />
        </bean>
-       <bean id="publishWorkspace" class="org.argeo.slc.client.ui.dist.commands.PublishWorkspace">
-               <property name="repositoryFactory" ref="repositoryFactory" />
-               <property name="nodeRepository" ref="nodeRepository" />
-               <property name="keyring" ref="keyring" />
+
+       <!-- LEGACY -->
+       <bean id="org.argeo.slc.client.ui.dist.openGenericJcrQueryEditor"
+               class="org.argeo.eclipse.ui.jcr.commands.OpenGenericJcrQueryEditor"
+               scope="prototype">
+               <property name="editorId"
+                       value="org.argeo.slc.client.ui.dist.genericJcrQueryEditor" />
        </bean>
-       <bean id="normalizeDistribution"
-               class="org.argeo.slc.client.ui.dist.commands.NormalizeDistribution">
-               <property name="repositoryFactory" ref="repositoryFactory" />
-               <property name="nodeRepository" ref="nodeRepository" />
-               <property name="keyring" ref="keyring" />
+
+       <bean id="runInOSGi" class="org.argeo.slc.client.ui.dist.commands.RunInOsgi"
+               scope="prototype">
+               <property name="repository" ref="javaRepository" />
+               <property name="workspace" value="org.argeo.tp-1.3.1" />
        </bean>
-       <bean id="normalizeWorkspace"
-               class="org.argeo.slc.client.ui.dist.commands.NormalizeWorkspace">
-               <property name="repositoryFactory" ref="repositoryFactory" />
-               <property name="nodeRepository" ref="nodeRepository" />
-               <property name="keyring" ref="keyring" />
+
+       <bean id="refreshDistributionsView"
+               class="org.argeo.slc.client.ui.dist.commands.RefreshDistributionsView"
+               scope="prototype">
+       </bean>
+
+       <bean id="refreshDistributionOverviewPage"
+               class="org.argeo.slc.client.ui.dist.commands.RefreshDistributionOverviewPage"
+               scope="prototype">
        </bean>
+
+       <bean id="org.argeo.slc.client.ui.dist.deleteArtifacts" class="org.argeo.slc.client.ui.dist.commands.DeleteArtifacts"
+               scope="prototype">
+       </bean>
+
 </beans>
\ No newline at end of file
index 069bb1559b3e023874fdd655c9dca1c0a5d00430..36f95dcb967d95937fb933069d810931b5dcf666 100644 (file)
@@ -9,4 +9,12 @@
                class="org.argeo.eclipse.ui.jcr.editors.GenericJcrQueryEditor" scope="prototype">
                <property name="session" ref="slcSession" />
        </bean>
+
+       <bean id="distributionWorkspaceEditor"
+               class="org.argeo.slc.client.ui.dist.editors.DistributionWorkspaceEditor"
+               scope="prototype">
+               <property name="repositoryFactory" ref="repositoryFactory" />
+               <property name="keyring" ref="keyring" />
+               <property name="localRepository" ref="nodeRepository" />
+       </bean>
 </beans>
index 79c7950e06712f6e584fb3eaeff8734a0b6014de..21337e840555afe7f4bc7c53f38ad87388d65b25 100644 (file)
@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?eclipse version="3.4"?>
 <plugin>
-       <!-- Perspectives --> 
-   <extension
-         point="org.eclipse.ui.perspectives">
+       <!-- PERSPECTIVES --> 
+       <extension
+               point="org.eclipse.ui.perspectives">
                <perspective
             name="SLC Repo"
             class="org.argeo.slc.client.ui.dist.DistributionPerspective"
             icon="icons/repo.gif">
                </perspective>
    </extension>
-   <!-- Views -->
+   <!-- VIEWS -->
    <extension
-         point="org.eclipse.ui.views">
-      <view
+               point="org.eclipse.ui.views">
+               <view
             class="org.argeo.eclipse.spring.SpringExtensionFactory"
             id="org.argeo.slc.client.ui.dist.distributionsView"
             icon="icons/search.gif"
             name="Distributions">
-      </view>
-      <view
+               </view>
+               <view
             class="org.argeo.eclipse.spring.SpringExtensionFactory"
             id="org.argeo.slc.client.ui.dist.anonymousDistributionsView"
             icon="icons/search.gif"
             name="Public Repository">
-      </view>
-      <view
+               </view>
+               <view
             class="org.argeo.slc.client.ui.dist.views.HelpView"
             id="org.argeo.slc.client.ui.dist.helpView"
             icon="icons/help.gif"
             name="About">
-      </view>
-      <view
+               </view>
+               <view
             class="org.argeo.eclipse.spring.SpringExtensionFactory"
             id="org.argeo.slc.client.ui.dist.artifactsBrowser"
             icon="icons/packageBrowser.gif"
             name="Artifacts browser">
-      </view>
-      <view
+               </view>
+               <view
             class="org.argeo.eclipse.spring.SpringExtensionFactory"
             id="org.argeo.slc.client.ui.dist.queryArtifactsForm"
             icon="icons/searchForm.gif"
             name="Artifacts Form">
-      </view>
-      <view
+               </view>
+               <view
             class="org.argeo.eclipse.spring.SpringExtensionFactory"
             id="org.argeo.slc.client.ui.dist.queryBundlesForm"
             icon="icons/searchForm.gif"
-            name="Bundles Form">
-      </view>
-      <view
+                       name="Bundles Form">
+               </view>
+               <view
             class="org.argeo.eclipse.spring.SpringExtensionFactory"
             id="org.argeo.slc.client.ui.dist.queryArtifactsText"
             icon="icons/search.gif"
             name="Query builder">
-      </view>
-       <view
+               </view>
+               <view
                 name="Progress View"
                 icon="icons/pview.gif"
                 category="org.eclipse.ui"
                 class="org.eclipse.ui.ExtensionFactory:progressView"
                 id="org.eclipse.ui.views.ProgressView">
-          </view>
-   </extension>
-   <!-- Editors -->
-   <extension
-           point="org.eclipse.ui.editors">
-            <editor
-                 class="org.argeo.slc.client.ui.dist.editors.GenericBundleEditor"
-              id="org.argeo.slc.client.ui.dist.genericBundleEditor"
-              name="Bundle editor"
-              icon="icons/artifactVersionBase.gif"
-              default="false">
-        </editor>
-            <editor
-                 class="org.argeo.slc.client.ui.dist.editors.DistributionEditor"
-              id="org.argeo.slc.client.ui.dist.distributionEditor"
-              name="Distribution editor"
-              icon="icons/distribution_perspective.gif"
-              default="false">
-        </editor>
-    </extension>
-    <!-- Commands --> 
+               </view>
+       </extension>
+       <!-- EDITORS -->
+       <extension
+               point="org.eclipse.ui.editors">
+               <editor
+                       class="org.argeo.slc.client.ui.dist.editors.GenericBundleEditor"
+                       id="org.argeo.slc.client.ui.dist.genericBundleEditor"
+                       name="Bundle editor"
+                       icon="icons/artifactVersionBase.gif"
+                       default="false">
+               </editor>
+               <editor
+                       class="org.argeo.slc.client.ui.dist.editors.DistributionEditor"
+                       id="org.argeo.slc.client.ui.dist.distributionEditor"
+                       name="Distribution editor"
+                       icon="icons/distribution_perspective.gif"
+                       default="false">
+               </editor>
+               <editor
+                       class="org.argeo.eclipse.spring.SpringExtensionFactory"
+                       id="org.argeo.slc.client.ui.dist.distributionWorkspaceEditor"
+                       name="Distribution workspace editor"
+                       icon="icons/distribution_perspective.gif"
+                       default="false">
+               </editor>
+       </extension>
+
+    <!-- COMMANDS  --> 
        <extension
          point="org.eclipse.ui.commands">
-               <!-- Commands that do not need dependency injection -->
+               
+               <!-- Distribution Managemnt -->
                <command
-            defaultHandler="org.argeo.slc.client.ui.dist.commands.RefreshArtifactBrowser"
-            id="org.argeo.slc.client.ui.dist.refreshArtifactBrowser"
-            name="Refresh Artifact Browser">
+            id="org.argeo.slc.client.ui.dist.normalizeDistribution"
+            defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
+            name="Normalize Distribution">
+                       <commandParameter
+                               id="workspaceName"
+                               name="Workspace name">
+                       </commandParameter>
+                       <commandParameter
+                               id="targetRepoPath"
+                               name="Target repo node path">
+                       </commandParameter>
        </command>
+       
+       <!-- Repository Management --> 
        <command
-            defaultHandler="org.argeo.slc.client.ui.dist.commands.DisplayRepoInformation"
-            id="org.argeo.slc.client.ui.dist.displayRepoInformation"
-            name="Display repo info">
-       </command>
-               <command
-            defaultHandler="org.argeo.slc.client.ui.dist.commands.ShowSizeColumn"
-            id="org.argeo.slc.client.ui.dist.showSizeColumn"
-            name="Show size column">
-            <state 
-                               id="org.argeo.slc.client.ui.dist.showSizeColumn.toggleState">
-                               <class class="org.eclipse.jface.commands.ToggleState"> 
-                                       <parameter
-                                               name="default"
-                                       value="true" />
-                               </class>
-                       </state>
+            id="org.argeo.slc.client.ui.dist.registerRepository"
+            defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
+            name="Add Repository">
        </command>
-
-               <!-- Command with Spring dependency injection -->
-               <command
+       <command
             defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
             id="org.argeo.slc.client.ui.dist.unregisterRemoteRepo"
             name="Unregister remote repository">
                        </commandParameter>
        </command>
                <command
-            id="org.argeo.slc.client.ui.dist.runInOSGi"
             defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
-            name="Run in OSGi">
-            <commandParameter
-                       id="workspace"
-                       name="Workspace Name">
-                       </commandParameter>
+            id="org.argeo.slc.client.ui.dist.displayRepoInformation"
+            name="Display repository information">
        </command>
+       
+       <!-- Workspace Management -->
                <command
-            id="org.argeo.slc.client.ui.dist.registerRepository"
+            id="org.argeo.slc.client.ui.dist.openWorkspaceEditor"
             defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
-            name="Add Repository">
+            name="Open Workspace Editor">
+                       <commandParameter
+                               id="param.repoNodePath"
+                               name="Repo node path">
+                       </commandParameter>
+                       <commandParameter
+                               id="param.repoUri"
+                               name="Repo URI">
+                       </commandParameter>
+                       <commandParameter
+                               id="param.workspaceName"
+                               name="Workspace name">
+                       </commandParameter>
        </command>
-       
        <command
             id="org.argeo.slc.client.ui.dist.fetch"
             defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
                        name="Target repo uri">
                        </commandParameter>
        </command>
-       
-               <!-- TO MANIPULATE WORKSPACES -->
-               <!-- Workspaces CRUD --> 
-               <command
-            id="org.argeo.slc.client.ui.dist.createWorkspace"
+       <command
+            id="org.argeo.slc.client.ui.dist.normalizeWorkspace"
             defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
-            name="Create Workspace">
-            <commandParameter
-                       id="workspacePrefix"
-                       name="Workspace prefix">
-                       </commandParameter>
-            <commandParameter
-                       id="targetRepoPath"
-                       name="Target repo node path">
-                       </commandParameter>
-       </command>
-               <command
-                       id="org.argeo.slc.client.ui.dist.deleteWorkspace"
-                       defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
-                       name="Delete chosen Workspace">
+            name="Normalize Workspace">
                        <commandParameter
                                id="workspaceName"
                                name="Workspace name">
                        </commandParameter>
        </command>
        <command
-            id="org.argeo.slc.client.ui.dist.publishWorkspace"
+            id="org.argeo.slc.client.ui.dist.manageWorkspaceAuth"
             defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
-            name="Publish selected workspace">
-                       <commandParameter
-                               id="workspaceName"
-                               name="Workspace name">
-                       </commandParameter>
-                       <commandParameter
-                               id="targetRepoPath"
-                               name="Target repo node path">
-                       </commandParameter>
+            name="Manage workspace authorizations">
+            <commandParameter
+                       id="org.argeo.slc.client.ui.dist.workspaceName"
+                       name="Workspace Name">
+                       </commandParameter>
        </command>
+
        <command
-            id="org.argeo.slc.client.ui.dist.normalizeDistribution"
+            id="org.argeo.slc.client.ui.dist.publishWorkspace"
             defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
-            name="Normalize Distribution">
+            name="Publish selected workspace">
                        <commandParameter
                                id="workspaceName"
                                name="Workspace name">
                        </commandParameter>
        </command>
        
-       <command
-            id="org.argeo.slc.client.ui.dist.normalizeWorkspace"
+       <!-- Workspaces CRUD --> 
+               <command
+            id="org.argeo.slc.client.ui.dist.createWorkspace"
             defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
-            name="Normalize Workspace">
+            name="Create Workspace">
+            <commandParameter
+                       id="workspacePrefix"
+                       name="Workspace prefix">
+                       </commandParameter>
+            <commandParameter
+                       id="targetRepoPath"
+                       name="Target repo node path">
+                       </commandParameter>
+       </command>
+               <command
+                       id="org.argeo.slc.client.ui.dist.deleteWorkspace"
+                       defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
+                       name="Delete chosen Workspace">
                        <commandParameter
                                id="workspaceName"
                                name="Workspace name">
                        name="Target repo node path">
                        </commandParameter>
        </command>
+       
        <command
             id="org.argeo.slc.client.ui.dist.mergeWorkspaces"
             defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
                        name="Target repo node path">
                        </commandParameter>
        </command>
+       
+               <!-- Legacy -->
+               <command
+            defaultHandler="org.argeo.slc.client.ui.dist.commands.RefreshArtifactBrowser"
+            id="org.argeo.slc.client.ui.dist.refreshArtifactBrowser"
+            name="Refresh Artifact Browser">
+       </command>
        <command
-            id="org.argeo.slc.client.ui.dist.manageWorkspaceAuth"
+            defaultHandler="org.argeo.slc.client.ui.dist.commands.ShowSizeColumn"
+            id="org.argeo.slc.client.ui.dist.showSizeColumn"
+            name="Show size column">
+            <state 
+                               id="org.argeo.slc.client.ui.dist.showSizeColumn.toggleState">
+                               <class class="org.eclipse.jface.commands.ToggleState"> 
+                                       <parameter
+                                               name="default"
+                                       value="true" />
+                               </class>
+                       </state>
+       </command>
+
+               <command
+            id="org.argeo.slc.client.ui.dist.runInOSGi"
             defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
-            name="Manage workspace authorizations">
+            name="Run in OSGi">
             <commandParameter
-                       id="org.argeo.slc.client.ui.dist.workspaceName"
+                       id="workspace"
                        name="Workspace Name">
                        </commandParameter>
        </command>
+               
        <command
             id="org.argeo.slc.client.ui.dist.refreshDistributionsView"
             defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
             name="Refresh Distributions View">
        </command>
+
        <command
             id="org.argeo.slc.client.ui.dist.refreshDistributionOverviewPage"
             defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
             name="Refresh distribution overview page">
        </command>
+
        <command
             id="org.argeo.slc.client.ui.dist.deleteArtifacts"
             defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
index 3bdd056ec9c920d768bfab518ac56dbc0690b5eb..ebc4d42403d2272e384d4bf2ce9882d18b613f6b 100644 (file)
@@ -55,6 +55,9 @@ public class DistImages {
        public final static Image IMG_DISTGRP_READONLY = DistPlugin
                        .getImageDescriptor("icons/distGrpReadOnly.gif").createImage();
 
+       public final static Image IMG_GROUP_BASE = DistPlugin.getImageDescriptor(
+                       "icons/packages.gif").createImage();
+
        /* CHECK BOXES */
        public final static Image CHECKED = DistPlugin.getImageDescriptor(
                        "icons/checked.gif").createImage();
index 7538e6f37b1078f017e431b5415fe2f7e6880d15..918b4b44cbf54e98443b41f0a650ba9851211b8a 100644 (file)
@@ -35,6 +35,8 @@ public class DistributionPerspective implements IPerspectiveFactory {
                IFolderLayout main = layout.createFolder("main", IPageLayout.LEFT,
                                0.3f, editorArea);
                main.addView(DistributionsView.ID);
-               main.addView("org.eclipse.ui.views.ProgressView");
+               IFolderLayout bottom = layout.createFolder("bottom",
+                               IPageLayout.BOTTOM, 0.75f, editorArea);
+               bottom.addView("org.eclipse.ui.views.ProgressView");
        }
 }
index e439491c9cb0aa0f717391231e9e6df436f349d6..6ccd8d8eb3e196c6bb302a39108bc1b46cf853d5 100644 (file)
  */
 package org.argeo.slc.client.ui.dist.commands;
 
-import javax.jcr.RepositoryException;
+import javax.jcr.RepositoryFactory;
 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.model.RepoElem;
+import org.argeo.slc.repo.RepoUtils;
+import org.argeo.util.security.Keyring;
 import org.eclipse.core.commands.AbstractHandler;
 import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
@@ -42,36 +43,44 @@ 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";
        public final static String DEFAULT_LABEL = "Information";
        public final static ImageDescriptor DEFAULT_ICON = DistPlugin
                        .getImageDescriptor("icons/help.gif");
-
+       
+       /* DEPENDENCY INJECTION */
+       private RepositoryFactory repositoryFactory;
+       private Keyring keyring;
+       
        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();
+               
+                       Session defaultSession =  null;
+                       try{
+                               defaultSession = RepoUtils.getCorrespondingSession(repositoryFactory, keyring, re.getRepoNode(), re.getUri(), null);
+                       
+                       
                        InformationDialog inputDialog = new InformationDialog(HandlerUtil
                                        .getActiveSite(event).getShell());
                        inputDialog.create();
-                       Session session = null;
-                       try {
-                               session = re.getRepository().login(re.getCredentials());
-                               inputDialog.loginTxt.setText(session.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.loginTxt.setText(defaultSession.getUserID());
+                       inputDialog.nameTxt.setText(re.getLabel());
+                       inputDialog.uriTxt.setText(re.getUri());
+                       inputDialog.readOnlyBtn.setSelection(re.isReadOnly());
+               
+                       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 setRepositoryFactory(RepositoryFactory repositoryFactory) {
+               this.repositoryFactory = repositoryFactory;
+       }
+
+       public void setKeyring(Keyring keyring) {
+               this.keyring = keyring;
+       }
+       
 }
\ No newline at end of file
diff --git a/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/commands/OpenWorkspaceEditor.java b/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/commands/OpenWorkspaceEditor.java
new file mode 100644 (file)
index 0000000..db7155e
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.slc.client.ui.dist.commands;
+
+import javax.jcr.Node;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.argeo.jcr.ArgeoNames;
+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.editors.DistributionWorkspaceEditor;
+import org.argeo.slc.client.ui.dist.editors.WorkspaceEditorInput;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/**
+ * Open a distribution workspace editor for a given workspace in a repository
+ */
+public class OpenWorkspaceEditor extends AbstractHandler {
+       public final static String ID = DistPlugin.ID + ".openWorkspaceEditor";
+       public final static String DEFAULT_LABEL = "Open editor";
+       public final static ImageDescriptor DEFAULT_ICON = DistPlugin
+                       .getImageDescriptor("icons/distribution_perspective.gif");
+
+       // use local node repo and repository factory to retrieve and log to
+       // relevant repository
+       public final static String PARAM_REPO_NODE_PATH = "param.repoNodePath";
+       // use URI and repository factory to retrieve and ANONYMOUSLY log in
+       // relevant repository
+       public final static String PARAM_REPO_URI = "param.repoUri";
+       public final static String PARAM_WORKSPACE_NAME = "param.workspaceName";
+
+       /* DEPENDENCY INJECTION */
+       private Repository localRepository;
+       
+       public Object execute(ExecutionEvent event) throws ExecutionException {
+               String repoNodePath = event.getParameter(PARAM_REPO_NODE_PATH);
+               String repoUri = event.getParameter(PARAM_REPO_URI);
+               String workspaceName = event.getParameter(PARAM_WORKSPACE_NAME);
+
+               Session defaultSession = null;
+               if (repoNodePath != null && repoUri == null) {
+                       try {
+
+                               defaultSession = localRepository.login();
+                               if (defaultSession.nodeExists(repoNodePath)) {
+                                       Node repoNode = defaultSession.getNode(repoNodePath);
+                                       repoUri = repoNode.getProperty(ArgeoNames.ARGEO_URI)
+                                                       .getString();
+                               }
+                       } catch (RepositoryException e) {
+                               throw new SlcException("Unexpected error while "
+                                               + "getting repoNode info for repoNode at path "
+                                               + repoNodePath, e);
+                       } finally {
+                               JcrUtils.logoutQuietly(defaultSession);
+                       }
+
+               }
+
+               WorkspaceEditorInput wei = new WorkspaceEditorInput(repoNodePath,
+                               repoUri, workspaceName);
+               try {
+                       HandlerUtil.getActiveWorkbenchWindow(event).getActivePage()
+                                       .openEditor(wei, DistributionWorkspaceEditor.ID);
+               } catch (PartInitException e) {
+                       throw new SlcException("Unexpected error while "
+                                       + "opening editor for workspace " + workspaceName
+                                       + " with URI " + repoUri + " and repoNode at path "
+                                       + repoNodePath, e);
+               }
+               return null;
+       }
+
+       /* DEPENDENCY INJECTION */
+       public void setLocalRepository(Repository localRepository) {
+               this.localRepository = localRepository;
+       }
+}
\ No newline at end of file
index e736e1f9f6ace4b20173ce75eecea05529eead5a..74bd34d854ce6176bfa7f5a599de4298761406a8 100644 (file)
@@ -2,9 +2,8 @@ package org.argeo.slc.client.ui.dist.controllers;
 
 import javax.jcr.RepositoryFactory;
 
-import org.argeo.slc.client.ui.dist.model.DistParentElem;
+import org.argeo.eclipse.ui.TreeParent;
 import org.argeo.slc.client.ui.dist.model.RepoElem;
-import org.argeo.slc.client.ui.dist.model.WorkspaceElem;
 import org.eclipse.jface.viewers.ITreeContentProvider;
 import org.eclipse.jface.viewers.Viewer;
 
@@ -29,28 +28,33 @@ public class AnonymousDistTreeContentProvider implements ITreeContentProvider {
                String uri = (String) input;
                publicRepo = new RepoElem(repositoryFactory, uri,
                                "Argeo Public Repository");
+               // force connection and creation of the children UI object
+               publicRepo.login();
                return publicRepo.getChildren();
        }
 
        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
        }
 
+       // @Override
        public Object[] getChildren(Object parentElement) {
-               if (parentElement instanceof DistParentElem) {
-                       return ((DistParentElem) parentElement).getChildren();
-               else
+               if (parentElement instanceof TreeParent)
+                       return ((TreeParent) parentElement).getChildren();
+               else
                        return null;
        }
 
+       // @Override
        public Object getParent(Object element) {
+               if (element instanceof TreeParent)
+                       return ((TreeParent) element).getParent();
                return null;
        }
 
+       // @Override
        public boolean hasChildren(Object element) {
-               if (element instanceof WorkspaceElem)
-                       return false;
-               else if (element instanceof DistParentElem)
-                       return true;
+               if (element instanceof TreeParent)
+                       return ((TreeParent) element).hasChildren();
                else
                        return false;
        }
index 26065428b58c3d18c98b5eab02755b82b21f77e8..d0c7066d1fd82f0118024f68bbb98c4b8377e8a1 100644 (file)
@@ -1,8 +1,8 @@
 package org.argeo.slc.client.ui.dist.controllers;
 
 import org.argeo.slc.client.ui.dist.model.DistParentElem;
-import org.argeo.slc.client.ui.dist.model.WkspGroupElem;
 import org.argeo.slc.client.ui.dist.model.RepoElem;
+import org.argeo.slc.client.ui.dist.model.WkspGroupElem;
 import org.argeo.slc.client.ui.dist.model.WorkspaceElem;
 import org.eclipse.jface.viewers.Viewer;
 import org.eclipse.jface.viewers.ViewerComparator;
@@ -36,8 +36,8 @@ public class DistTreeComparator extends ViewerComparator {
                String s1, s2;
 
                if (e1 instanceof DistParentElem) {
-                       s1 = ((DistParentElem) e1).getLabel();
-                       s2 = ((DistParentElem) e2).getLabel();
+                       s1 = ((DistParentElem) e1).getName();
+                       s2 = ((DistParentElem) e2).getName();
                } else {
                        s1 = e1.toString();
                        s2 = e2.toString();
diff --git a/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/controllers/DistTreeComparer.java b/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/controllers/DistTreeComparer.java
new file mode 100644 (file)
index 0000000..5c6b9de
--- /dev/null
@@ -0,0 +1,28 @@
+package org.argeo.slc.client.ui.dist.controllers;
+
+import org.argeo.eclipse.ui.TreeParent;
+import org.eclipse.jface.viewers.IElementComparer;
+
+/** Compares two elements of the Distribution tree */
+public class DistTreeComparer implements IElementComparer {
+
+       public int hashCode(Object element) {
+               if (element instanceof TreeParent)
+                       return ((TreeParent) element).hashCode();
+               else
+
+                       return element.getClass().toString().hashCode();
+       }
+
+       public boolean equals(Object elementA, Object elementB) {
+               if (!(elementA instanceof TreeParent)
+                               || !(elementB instanceof TreeParent)) {
+                       return elementA == null ? elementB == null : elementA
+                                       .equals(elementB);
+               } else {
+                       TreeParent tpA = ((TreeParent) elementA);
+                       TreeParent tpB = ((TreeParent) elementB);
+                       return tpA.compareTo(tpB) == 0;
+               }
+       }
+}
\ No newline at end of file
index a62e01dcdbd01a542416b6bfad5f04e16f9db1b5..b2c816be171ffce155c10e36494bb93c363690b6 100644 (file)
@@ -12,28 +12,28 @@ import javax.jcr.RepositoryFactory;
 import javax.jcr.Session;
 import javax.jcr.nodetype.NodeType;
 
+import org.argeo.eclipse.ui.TreeParent;
 import org.argeo.jcr.ArgeoJcrUtils;
 import org.argeo.jcr.ArgeoNames;
 import org.argeo.jcr.ArgeoTypes;
 import org.argeo.jcr.JcrUtils;
 import org.argeo.jcr.UserJcrUtils;
 import org.argeo.slc.SlcException;
-import org.argeo.slc.client.ui.dist.model.DistParentElem;
 import org.argeo.slc.client.ui.dist.model.RepoElem;
-import org.argeo.slc.client.ui.dist.model.WorkspaceElem;
 import org.argeo.slc.repo.RepoConstants;
 import org.argeo.util.security.Keyring;
 import org.eclipse.jface.viewers.ITreeContentProvider;
 import org.eclipse.jface.viewers.Viewer;
 
 /**
- * Enables browsing in local and remote SLC software repositories. Keyring
- * and repository factory must be injected
+ * Enables browsing in local and remote SLC software repositories. Keyring and
+ * repository factory must be injected
  */
 public class DistTreeContentProvider implements ITreeContentProvider {
        private Session nodeSession;
        List<RepoElem> repositories = new ArrayList<RepoElem>();
 
+       /* DEPENDENCY INJECTION */
        private RepositoryFactory repositoryFactory;
        private Keyring keyring;
 
@@ -53,9 +53,13 @@ public class DistTreeContentProvider implements ITreeContentProvider {
                        NodeIterator repos = nodeSession.getNode(reposPath).getNodes();
                        while (repos.hasNext()) {
                                Node repoNode = repos.nextNode();
-                               if (repoNode.isNodeType(ArgeoTypes.ARGEO_REMOTE_REPOSITORY))
-                                       repositories.add(new RepoElem(repoNode, repositoryFactory,
-                                                       keyring));
+                               if (repoNode.isNodeType(ArgeoTypes.ARGEO_REMOTE_REPOSITORY)) {
+                                       String label = repoNode.isNodeType(NodeType.MIX_TITLE) ? repoNode
+                                                       .getProperty(Property.JCR_TITLE).getString()
+                                                       : repoNode.getName();
+                                       repositories.add(new RepoElem(repositoryFactory, keyring,
+                                                       repoNode, label));
+                               }
                        }
                } catch (RepositoryException e) {
                        throw new SlcException("Cannot get base elements", e);
@@ -66,25 +70,25 @@ public class DistTreeContentProvider implements ITreeContentProvider {
        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
        }
 
+       // @Override
        public Object[] getChildren(Object parentElement) {
-               if (parentElement instanceof DistParentElem) {
-                       return ((DistParentElem) parentElement).getChildren();
-               } else if (parentElement instanceof WorkspaceElem) {
-                       return ((WorkspaceElem) parentElement).getChildren();
-               }
-               return null;
+               if (parentElement instanceof TreeParent)
+                       return ((TreeParent) parentElement).getChildren();
+               else
+                       return null;
        }
 
+       // @Override
        public Object getParent(Object element) {
-               // TODO register repo elem in distribution elem?
+               if (element instanceof TreeParent)
+                       return ((TreeParent) element).getParent();
                return null;
        }
 
+       // @Override
        public boolean hasChildren(Object element) {
-               if (element instanceof WorkspaceElem)
-                       return false;
-               else if (element instanceof DistParentElem)
-                       return true;
+               if (element instanceof TreeParent)
+                       return ((TreeParent) element).hasChildren();
                else
                        return false;
        }
@@ -128,9 +132,7 @@ public class DistTreeContentProvider implements ITreeContentProvider {
                }
        }
 
-       /*
-        * DEPENDENCY INJECTION
-        */
+       /* DEPENDENCY INJECTION */
        public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
                this.repositoryFactory = repositoryFactory;
        }
index bfa97665856a8785cc41e82a8e26d2be53b74a0c..6e8d53734ce0b3ec64a58b47b3df83e805bad441 100644 (file)
@@ -1,37 +1,70 @@
 package org.argeo.slc.client.ui.dist.controllers;
 
-import org.argeo.eclipse.ui.ErrorFeedback;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.client.ui.dist.editors.DistributionEditor;
-import org.argeo.slc.client.ui.dist.editors.DistributionEditorInput;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+
+import org.argeo.eclipse.ui.utils.CommandUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.client.ui.dist.commands.OpenWorkspaceEditor;
+import org.argeo.slc.client.ui.dist.model.RepoElem;
 import org.argeo.slc.client.ui.dist.model.WorkspaceElem;
 import org.eclipse.jface.viewers.DoubleClickEvent;
 import org.eclipse.jface.viewers.IDoubleClickListener;
 import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.PartInitException;
+import org.eclipse.jface.viewers.TreeViewer;
 
 /** Listen to double-clicks on the distributions view tree. */
 public class DistTreeDoubleClickListener implements IDoubleClickListener {
 
+       private TreeViewer treeViewer;
+
+       public DistTreeDoubleClickListener(TreeViewer treeViewer) {
+               this.treeViewer = treeViewer;
+       }
+
        public void doubleClick(DoubleClickEvent event) {
                if (event.getSelection() == null || event.getSelection().isEmpty())
                        return;
                Object obj = ((IStructuredSelection) event.getSelection())
                                .getFirstElement();
-               if (obj instanceof WorkspaceElem) {
-                       WorkspaceElem we = (WorkspaceElem) obj;
-                       DistributionEditorInput dei = new DistributionEditorInput(we
-                                       .getRepoElem().getRepository(), we.getRepoElem()
-                                       .getCredentials(), we.getRepoElem().getLabel(), we
-                                       .getRepoElem().getDescription(), we.getWorkspaceName());
-                       try {
-                               DistPlugin.getDefault().getWorkbench()
-                                               .getActiveWorkbenchWindow().getActivePage()
-                                               .openEditor(dei, DistributionEditor.ID);
-                       } catch (PartInitException e) {
-                               ErrorFeedback.show(
-                                               "Cannot open editor for " + we.getWorkspaceName(), e);
+
+               if (obj instanceof RepoElem) {
+                       RepoElem rpNode = (RepoElem) obj;
+                       if (!rpNode.isConnected()) {
+                               rpNode.login();
+                               treeViewer.refresh(obj);
+                       }
+               } else if (obj instanceof WorkspaceElem) {
+                       WorkspaceElem wn = (WorkspaceElem) obj;
+                       if (!wn.isConnected())
+                               wn.login();
+                       else {
+                               WorkspaceElem we = (WorkspaceElem) obj;
+
+                               try {
+                                       RepoElem repoElem = we.getRepoElem();
+                                       Map<String, String> params = new HashMap<String, String>();
+
+                                       Node repoNode = repoElem.getRepoNode();
+                                       if (repoNode != null)
+                                               params.put(OpenWorkspaceEditor.PARAM_REPO_NODE_PATH,
+                                                               repoNode.getPath());
+                                       params.put(OpenWorkspaceEditor.PARAM_REPO_URI,
+                                                       repoElem.getUri());
+                                       params.put(OpenWorkspaceEditor.PARAM_WORKSPACE_NAME,
+                                                       we.getWorkspaceName());
+                                       CommandUtils.callCommand(OpenWorkspaceEditor.ID, params);
+                               } catch (RepositoryException re) {
+                                       throw new SlcException(
+                                                       "Cannot get path for node while "
+                                                                       + "setting parameters of command OpenWorkspaceEditor",
+                                                       re);
+                               }
                        }
+                       treeViewer.refresh(obj);
                }
        }
 }
\ No newline at end of file
index b504ae6f3bb022ecee61370b056ee9432e1c842f..b2ca9f2907d68389dad658dba45e339554afc46c 100644 (file)
@@ -1,44 +1,46 @@
 package org.argeo.slc.client.ui.dist.controllers;
 
+import org.argeo.eclipse.ui.jcr.JcrImages;
 import org.argeo.slc.client.ui.dist.DistImages;
 import org.argeo.slc.client.ui.dist.model.DistParentElem;
-import org.argeo.slc.client.ui.dist.model.WkspGroupElem;
+import org.argeo.slc.client.ui.dist.model.GroupBaseElem;
 import org.argeo.slc.client.ui.dist.model.RepoElem;
+import org.argeo.slc.client.ui.dist.model.WkspGroupElem;
 import org.argeo.slc.client.ui.dist.model.WorkspaceElem;
 import org.eclipse.jface.viewers.ColumnLabelProvider;
 import org.eclipse.swt.graphics.Image;
 
 /**
- * Manages icons and labels for the distributions browser
+ * Manages icons and labels for the Distributions tree browser
  */
 public class DistTreeLabelProvider extends ColumnLabelProvider {
        @Override
        public String getText(Object element) {
                if (element instanceof DistParentElem)
-                       return ((DistParentElem) element).getLabel();
+                       return ((DistParentElem) element).getName();
                else
                        return element.toString();
        }
 
        @Override
        public Image getImage(Object element) {
-               if (element instanceof DistParentElem) {
-                       DistParentElem bElement = (DistParentElem) element;
-                       if (bElement instanceof RepoElem)
-                               if (bElement.inHome())
-                                       return DistImages.IMG_HOME_REPO;
-                               else if (bElement.isReadOnly())
-                                       return DistImages.IMG_REPO_READONLY;
-                               else
-                                       return DistImages.IMG_REPO;
-                       else if (bElement instanceof WkspGroupElem)
-                               return DistImages.IMG_WKSP;
-                       else if (element instanceof WorkspaceElem)
-                               if (((WorkspaceElem) element).isReadOnly())
-                                       return DistImages.IMG_DISTGRP_READONLY;
-                               else
-                                       return DistImages.IMG_DISTGRP;
-               }
-               return null;
+               if (element instanceof RepoElem) {
+                       RepoElem re = ((RepoElem) element);
+                       if (re.inHome())
+                               return DistImages.IMG_HOME_REPO;
+                       else if (re.isConnected())
+                               return JcrImages.REPOSITORY_CONNECTED;
+                       else
+                               return JcrImages.REPOSITORY_DISCONNECTED;
+               } else if (element instanceof WorkspaceElem) {
+                       if (((WorkspaceElem) element).isConnected())
+                               return JcrImages.WORKSPACE_CONNECTED;
+                       else
+                               return JcrImages.WORKSPACE_DISCONNECTED;
+               } else if (element instanceof WkspGroupElem)
+                       return JcrImages.WORKSPACE_CONNECTED;
+               else if (element instanceof GroupBaseElem)
+                       return DistImages.IMG_GROUP_BASE;
+               return super.getImage(element);
        }
 }
\ No newline at end of file
index 1499bd5b75143925c1289f650bfc189446e6b7d3..edd848fe98f0a99594e5cfce1598763f901d880f 100644 (file)
@@ -20,9 +20,11 @@ import java.util.List;
 
 import javax.jcr.Node;
 import javax.jcr.NodeIterator;
+import javax.jcr.Property;
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
+import javax.jcr.nodetype.NodeType;
 import javax.jcr.query.QueryManager;
 import javax.jcr.query.QueryResult;
 import javax.jcr.query.qom.Constraint;
@@ -247,8 +249,22 @@ public class DistributionOverviewPage extends FormPage implements SlcNames {
                header.setLayoutData(gd);
 
                // Title: some meta information
-               String desc = ((DistributionEditorInput) getEditorInput())
-                               .getRepositoryDescription();
+               // label = repoNode.isNodeType(NodeType.MIX_TITLE) ? repoNode
+               // .getProperty(Property.JCR_TITLE).getString() : repoNode
+               // .getName();
+
+               String desc = null;
+               Node repoNode = ((DistributionWorkspaceEditor) getEditor())
+                               .getRepoNode();
+               if (repoNode != null)
+                       try {
+                               desc = repoNode.isNodeType(NodeType.MIX_TITLE) ? repoNode
+                                               .getProperty(Property.JCR_TITLE).getString() : repoNode
+                                               .getName();
+                       } catch (RepositoryException e1) {
+                               throw new SlcException("Unable to get repository alias ", e1);
+                       }
+               desc += " (" + ((WorkspaceEditorInput) getEditorInput()).getUri() + ")";
                Label lbl = tk.createLabel(header, desc, SWT.NONE);
 
                gd = new GridData(SWT.FILL, SWT.FILL, false, false);
diff --git a/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/DistributionWorkspaceEditor.java b/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/DistributionWorkspaceEditor.java
new file mode 100644 (file)
index 0000000..723bb4d
--- /dev/null
@@ -0,0 +1,127 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.slc.client.ui.dist.editors;
+
+import javax.jcr.Node;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.RepositoryFactory;
+import javax.jcr.Session;
+
+import org.argeo.ArgeoException;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.client.ui.dist.DistPlugin;
+import org.argeo.slc.jcr.SlcNames;
+import org.argeo.slc.repo.RepoUtils;
+import org.argeo.util.security.Keyring;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.forms.editor.FormEditor;
+
+/**
+ * Browse, analyse and modify a workspace containing software distributions
+ */
+public class DistributionWorkspaceEditor extends FormEditor implements SlcNames {
+       // private final static Log log =
+       // LogFactory.getLog(DistributionEditor.class);
+       public final static String ID = DistPlugin.ID
+                       + ".distributionWorkspaceEditor";
+
+       /* DEPENDENCY INJECTION */
+       private RepositoryFactory repositoryFactory;
+       private Repository localRepository;
+       private Keyring keyring;
+
+       // Business objects
+       private Node repoNode;
+       // Session that provides the node in the home of the local repository
+       private Session localSession = null;
+       // The business Session on optionally remote repository
+       private Session businessSession;
+       private WorkspaceEditorInput editorInput;
+
+       @Override
+       public void init(IEditorSite site, IEditorInput input)
+                       throws PartInitException {
+               editorInput = (WorkspaceEditorInput) input;
+
+               try {
+                       localSession = localRepository.login();
+                       if (editorInput.getRepoNodePath() != null
+                                       && localSession.nodeExists(editorInput.getRepoNodePath()))
+                               repoNode = localSession.getNode(editorInput.getRepoNodePath());
+
+                       businessSession = RepoUtils.getCorrespondingSession(
+                                       repositoryFactory, keyring, repoNode, editorInput.getUri(),
+                                       editorInput.getWorkspaceName());
+               } catch (RepositoryException e) {
+                       throw new PartInitException("Cannot log to workspace "
+                                       + editorInput.getName(), e);
+               }
+               setPartName(editorInput.getWorkspaceName());
+               super.init(site, input);
+       }
+
+       @Override
+       protected void addPages() {
+               try {
+                       addPage(new DistributionOverviewPage(this, "Overview",
+                                       businessSession));
+                       addPage(new ArtifactsBrowserPage(this, "Browser", businessSession));
+               } catch (PartInitException e) {
+                       throw new ArgeoException("Cannot add distribution editor pages", e);
+               }
+       }
+
+       @Override
+       public void doSave(IProgressMonitor arg0) {
+       }
+
+       @Override
+       public void dispose() {
+               JcrUtils.logoutQuietly(businessSession);
+               JcrUtils.logoutQuietly(localSession);
+               super.dispose();
+       }
+
+       @Override
+       public void doSaveAs() {
+       }
+
+       @Override
+       public boolean isSaveAsAllowed() {
+               return false;
+       }
+
+       protected Node getRepoNode() {
+               return repoNode;
+       }
+
+       /* DEPENDENCY INJECTION */
+       public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
+               this.repositoryFactory = repositoryFactory;
+       }
+
+       public void setKeyring(Keyring keyring) {
+               this.keyring = keyring;
+       }
+
+       public void setLocalRepository(Repository localRepository) {
+               this.localRepository = localRepository;
+       }
+}
\ No newline at end of file
diff --git a/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/GroupBaseEditorInput.java b/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/GroupBaseEditorInput.java
new file mode 100644 (file)
index 0000000..bd9c788
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.slc.client.ui.dist.editors;
+
+import org.argeo.slc.SlcException;
+
+/**
+ * An editor input pointing to a given group base in a distribution workspace
+ */
+public class GroupBaseEditorInput extends WorkspaceEditorInput {
+
+       private final String groupBaseId;
+
+       /** uri, workspace name and group base Id cannot be null */
+       public GroupBaseEditorInput(String repoNodePath, String uri,
+                       String workspaceName, String groupBaseId) {
+               super(repoNodePath, uri, workspaceName);
+               if (groupBaseId == null)
+                       throw new SlcException("Group base ID cannot be null");
+               this.groupBaseId = groupBaseId;
+       }
+
+       public String getToolTipText() {
+               return "Editor for group base of ID " + groupBaseId + " in workspace "
+                               + getWorkspaceName() + " in " + getUri();
+       }
+
+       public String getName() {
+               return groupBaseId;
+       }
+
+       public boolean equals(Object obj) {
+               if (this == obj)
+                       return true;
+               if (obj == null)
+                       return false;
+               if (!(obj instanceof GroupBaseEditorInput))
+                       return false;
+
+               GroupBaseEditorInput other = (GroupBaseEditorInput) obj;
+
+               if (groupBaseId.equals(other.getGroupBaseId()))
+                       return super.equals(obj);
+               else
+                       return false;
+       }
+
+       public String getGroupBaseId() {
+               return groupBaseId;
+       }
+
+}
\ No newline at end of file
diff --git a/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/WorkspaceEditorInput.java b/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/WorkspaceEditorInput.java
new file mode 100644 (file)
index 0000000..a440cbc
--- /dev/null
@@ -0,0 +1,120 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.slc.client.ui.dist.editors;
+
+import org.argeo.slc.SlcException;
+import org.argeo.slc.jcr.SlcNames;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IPersistableElement;
+
+/**
+ * An editor input pointing to a distribution workspace
+ */
+public class WorkspaceEditorInput implements IEditorInput, SlcNames {
+
+       // Injected
+       // private RepositoryFactory repositoryFactory;
+       // private Keyring keyring;
+       // private Node repoNode;
+       private String repoNodePath;
+       private String uri;
+
+       // Local variables
+       private String workspaceName;
+
+       // public WorkspaceEditorInput(RepositoryFactory repositoryFactory,
+       // Keyring keyring, Repository localRepository, Node repoNode,
+       // String uri) {
+       // // this.repositoryFactory = repositoryFactory;
+       // // this.keyring = keyring;
+       // this.localRepository = localRepository;
+       // // this.repoNode= repoNode;
+       // this.uri = uri;
+       //
+       // }
+
+       /** uri and workspace name cannot be null */
+       public WorkspaceEditorInput(String repoNodePath, String uri,
+                       String workspaceName) {
+               if (workspaceName == null)
+                       throw new SlcException("Workspace name cannot be null");
+               if (uri == null)
+                       throw new SlcException("URI for repository cannot be null");
+               this.repoNodePath = repoNodePath;
+               this.workspaceName = workspaceName;
+               this.uri = uri;
+       }
+
+       public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
+               return null;
+       }
+
+       public boolean exists() {
+               return true;
+       }
+
+       public ImageDescriptor getImageDescriptor() {
+               return null;
+       }
+
+       // Dummy compulsory methods
+       public String getToolTipText() {
+               return "Editor for workspace " + workspaceName
+                               + " in repository of URI " + uri;
+       }
+
+       public String getName() {
+               return workspaceName + "@" + uri;
+       }
+
+       public IPersistableElement getPersistable() {
+               return null;
+       }
+
+       public boolean equals(Object obj) {
+               if (this == obj)
+                       return true;
+               if (obj == null)
+                       return false;
+               if (!(obj instanceof WorkspaceEditorInput))
+                       return false;
+
+               WorkspaceEditorInput other = (WorkspaceEditorInput) obj;
+
+               if (!workspaceName.equals(other.getWorkspaceName()))
+                       return false;
+               if (!uri.equals(other.getUri()))
+                       return false;
+
+               if (repoNodePath == null)
+                       return other.getRepoNodePath() == null;
+               else
+                       return repoNodePath.equals(other.getRepoNodePath());
+       }
+
+       public String getUri() {
+               return uri;
+       }
+
+       public String getWorkspaceName() {
+               return workspaceName;
+       }
+
+       public String getRepoNodePath() {
+               return repoNodePath;
+       }
+}
\ No newline at end of file
index 09dede9e820049ddc5a2df9dae85cb91636319cd..fe960b43f31d19da86d0f937b4a4788c2172605e 100644 (file)
@@ -1,30 +1,48 @@
 package org.argeo.slc.client.ui.dist.model;
 
-/** Common super class for all tree elements of the Distributions View*/
-public abstract class DistParentElem {
-       public final static Character VERSION_SEP = '-';
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.argeo.eclipse.ui.TreeParent;
+
+/** Common super class for all tree elements of the Distributions View */
+public abstract class DistParentElem extends TreeParent {
+       protected final static Character VERSION_SEP = '-';
+
+       protected static final List<String> ARGEO_SYSTEM_WKSP;
+       static {
+               List<String> tmpList = new ArrayList<String>();
+               tmpList.add("main");
+               tmpList.add("proxy");
+               tmpList.add("security");
+               tmpList.add("localrepo");
+               ARGEO_SYSTEM_WKSP = Collections.unmodifiableList(tmpList);
+       }
 
        private boolean inHome = false;
        private boolean isReadOnly = false;
 
-       public DistParentElem(boolean inHome, boolean isReadOnly) {
+       public DistParentElem(String name, boolean inHome, boolean isReadOnly) {
+               super(name);
                this.inHome = inHome;
                this.isReadOnly = isReadOnly;
        }
 
-       public DistParentElem() {
+       public DistParentElem(String name) {
+               super(name);
        }
 
-       public abstract String getLabel();
-
-       public abstract Object[] getChildren();
-
-       public boolean hasChildren() {
-               return true;
-       }
-
-       public void dispose() {
-       }
+       // public abstract String getLabel();
+       //
+       // public abstract Object[] getChildren();
+       //
+       // public boolean hasChildren() {
+       // return true;
+       // }
+       //
+       // public void dispose() {
+       // }
 
        public void setInHome(boolean inHome) {
                this.inHome = inHome;
index 9b6b3ff7729821ab7886d6c2018e0479733938be..2b9a8fe12cfec0e2c97d6edd3954aa88d9867bf1 100644 (file)
@@ -5,12 +5,14 @@ package org.argeo.slc.client.ui.dist.model;
  * have the same group ID
  */
 public class GroupBaseElem extends DistParentElem {
-       private WorkspaceElem wkspElem;
+       // private WorkspaceElem wkspElem;
        private String groupId;
 
        public GroupBaseElem(WorkspaceElem wkspElem, String groupId) {
-               super(wkspElem.inHome(), wkspElem.isReadOnly());
-               this.wkspElem = wkspElem;
+               super(groupId, wkspElem.inHome(), wkspElem.isReadOnly());
+
+               setParent(wkspElem);
+               // this.wkspElem = wkspElem;
                this.groupId = groupId;
        }
 
@@ -22,14 +24,18 @@ public class GroupBaseElem extends DistParentElem {
                return groupId;
        }
 
-       public String toString() {
-               return getLabel();
-       }
+       // public String toString() {
+       // return getLabel();
+       // }
 
-       public void dispose() {
-       }
+       // public void dispose() {
+       // }
 
        public WorkspaceElem getWorkspaceElem() {
-               return wkspElem;
+               return (WorkspaceElem) getParent();
+       }
+
+       public String getGroupId() {
+               return getName();
        }
 }
\ No newline at end of file
index 60916bec59d13d6601ca1a48e6124cc4f23662e3..3dc56ed2bb1c844a4cd52a13490a7dadb4360a1a 100644 (file)
@@ -1,20 +1,14 @@
 package org.argeo.slc.client.ui.dist.model;
 
 import java.security.AccessControlException;
-import java.util.HashMap;
-import java.util.Map;
 
 import javax.jcr.Credentials;
 import javax.jcr.Node;
-import javax.jcr.Property;
 import javax.jcr.Repository;
 import javax.jcr.RepositoryException;
 import javax.jcr.RepositoryFactory;
 import javax.jcr.Session;
-import javax.jcr.nodetype.NodeType;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 import org.argeo.jcr.ArgeoJcrUtils;
 import org.argeo.jcr.ArgeoNames;
 import org.argeo.jcr.JcrUtils;
@@ -24,152 +18,205 @@ import org.argeo.slc.repo.RepoUtils;
 import org.argeo.util.security.Keyring;
 
 /**
- * Abstract a repository. It might be persisted by a node in the current user home
- * Node or just an URI and a label if user is anonymous
+ * Abstract a repository. It might be persisted by a node in the current user
+ * home Node or just an URI and a label if user is anonymous
  */
 public class RepoElem extends DistParentElem {
-       private final static Log log = LogFactory.getLog(RepoElem.class);
+       // private final static Log log = LogFactory.getLog(RepoElem.class);
 
-       private Repository repository;
-       private Credentials credentials;
        private RepositoryFactory repositoryFactory;
        private Keyring keyring;
+       private Credentials credentials;
+       private Session defaultSession = null;
 
        // Defines current repo
        private Node repoNode = null;
        private String label;
        private String uri;
 
+       private Repository repository;
+
        /**
-        * Creates a RepoElement for an authenticated user. repofactory and keyring
-        * are used to enable lazy init
+        * Creates a RepoElement for anonymous user. The {@code RepositoryFactory}
+        * is used to enable lazy initialisation
+        */
+       public RepoElem(RepositoryFactory repoFactory, String uri, String label) {
+               super(label);
+               this.repositoryFactory = repoFactory;
+               this.uri = uri;
+               this.label = label;
+       }
+
+       /**
+        * Creates a RepoElement for an authenticated user. The
+        * {@code RepositoryFactory} and {@code Keyring} are used to enable lazy
+        * initialisation
         * 
         */
-       public RepoElem(Node repoNode, RepositoryFactory repoFactory,
-                       Keyring keyring) {
+       public RepoElem(RepositoryFactory repoFactory, Keyring keyring,
+                       Node repoNode, String alias) {
+               super(alias);
+               this.label = alias;
+               // label = repoNode.isNodeType(NodeType.MIX_TITLE) ? repoNode
+               // .getProperty(Property.JCR_TITLE).getString() : repoNode
+               // .getName();
                this.repoNode = repoNode;
                this.repositoryFactory = repoFactory;
                this.keyring = keyring;
                try {
-                       // initialize this repo informations
+                       // Initialize this repo information
                        setInHome(RepoConstants.DEFAULT_JAVA_REPOSITORY_ALIAS
                                        .equals(repoNode.getName()));
-                       if (!inHome())
+                       if (inHome())
+                               // Directly log and retrieve children for local repository
+                               login();
+                       else
                                setReadOnly(!repoNode.hasNode(ArgeoNames.ARGEO_PASSWORD));
                        uri = JcrUtils.get(repoNode, ArgeoNames.ARGEO_URI);
-                       label = repoNode.isNodeType(NodeType.MIX_TITLE) ? repoNode
-                                       .getProperty(Property.JCR_TITLE).getString() : repoNode
-                                       .getName();
                } catch (RepositoryException e) {
                        throw new SlcException("Unable to " + "initialize repo element", e);
                }
        }
 
-       /**
-        * Creates a RepoElement for anonymous user. repofactory is used to enable
-        * lazy init
-        * 
-        */
-       public RepoElem(RepositoryFactory repoFactory, String uri, String label) {
-               this.repositoryFactory = repoFactory;
-               this.uri = uri;
-               this.label = label;
+       /** Effective login. Does nothing if the session is already there. */
+       public void login() {
+               if (isConnected())
+                       return;
+
+               if (repository == null)
+                       if (repoNode == null)
+                               // Anonymous
+                               repository = ArgeoJcrUtils.getRepositoryByUri(
+                                               repositoryFactory, uri);
+                       else {
+                               repository = RepoUtils.getRepository(repositoryFactory,
+                                               keyring, repoNode);
+                               credentials = RepoUtils.getRepositoryCredentials(keyring,
+                                               repoNode);
+                       }
+
+               try {
+                       defaultSession = repository.login(credentials);
+                       refreshChildren();
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot login repository " + label
+                                       + " with credential " + credentials, e);
+               }
        }
 
-       /** Lazily connects to repository */
-       protected void connect() {
-               if (repository != null)
-                       return;
-               if (repoNode == null)
-                       // Anonymous
-                       repository = ArgeoJcrUtils.getRepositoryByUri(repositoryFactory,
-                                       uri);
-               else {
-                       repository = RepoUtils.getRepository(repositoryFactory, keyring,
-                                       repoNode);
-                       credentials = RepoUtils.getRepositoryCredentials(keyring, repoNode);
+       protected void refreshChildren() {
+               try {
+                       // TODO also remove deleted children (only adds for the time being
+                       String[] workspaceNames = defaultSession.getWorkspace()
+                                       .getAccessibleWorkspaceNames();
+                       buildWksp: for (String workspaceName : workspaceNames) {
+                               if (!isWorkspaceVisible(workspaceName))
+                                       continue buildWksp;
+
+                               String prefix = getPrefix(workspaceName);
+                               if (getChildByName(prefix) == null) {
+                                       WkspGroupElem wkspGpElem = new WkspGroupElem(RepoElem.this,
+                                                       prefix);
+                                       addChild(wkspGpElem);
+                               }
+                       }
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot list workspaces for " + repoNode, e);
                }
        }
 
-       public String getLabel() {
-               return label;
+       @Override
+       public synchronized void dispose() {
+               JcrUtils.logoutQuietly(defaultSession);
+               super.dispose();
        }
 
-       public String getUri() {
-               return uri;
+       private String getPrefix(String workspaceName) {
+               // Here is the tricks - we rely on a "hard coded" convention
+               // Workspace name should be like: name-major.minor
+               if (workspaceName.lastIndexOf(VERSION_SEP) > 0)
+                       return workspaceName.substring(0,
+                                       workspaceName.lastIndexOf(VERSION_SEP));
+               else
+                       return workspaceName;
        }
 
-       public String toString() {
-               return repoNode != null ? repoNode.toString() : label;
+       /* Exposes this to the children workspace group */
+       protected boolean isWorkspaceVisible(String wkspName) {
+               Boolean result = true;
+               if (ARGEO_SYSTEM_WKSP.contains(wkspName))
+                       return false;
+               // Add a supplementary check to hide workspace that are not
+               // public to anonymous user
+               if (repoNode == null) {
+                       Session tmpSession = null;
+                       try {
+                               tmpSession = repository.login(wkspName);
+                               try {
+                                       tmpSession.checkPermission("/", "read");
+                               } catch (AccessControlException e) {
+                                       result = false;
+                               }
+                       } catch (RepositoryException e) {
+                               throw new SlcException(
+                                               "Cannot list workspaces for anonymous user", e);
+                       } finally {
+                               JcrUtils.logoutQuietly(tmpSession);
+                       }
+               }
+               return result;
        }
 
-       public Object[] getChildren() {
+       /**
+        * Actual call to the
+        * {@link Repository#login(javax.jcr.Credentials, String)} method. To be
+        * overridden.
+        * 
+        * Creates a new session with correct credentials using the information
+        * contained in the corresponding repo node. It provides all UI children
+        * elements an unique entry point to retrieve a new Session. Caller must
+        * close the session when it is not in use anymore.
+        * 
+        */
+       protected Session repositoryLogin(String workspaceName) {
                try {
-                       connect();
-               } catch (Exception e) {
-                       log.error("Cannot connect to " + uri + " return no children.", e);
-                       return new Object[0];
+                       return repository.login(credentials, workspaceName);
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot login repository " + label
+                                       + " with credential " + credentials, e);
                }
+       }
 
-               Session session = null;
-               try {
-                       session = repository.login(credentials);
-                       String[] workspaceNames = session.getWorkspace()
-                                       .getAccessibleWorkspaceNames();
-                       Map<String, WkspGroupElem> children = new HashMap<String, WkspGroupElem>();
+       public Boolean isConnected() {
+               if (defaultSession != null && defaultSession.isLive())
+                       return true;
+               else
+                       return false;
+       }
 
-                       buildWksp: for (String workspaceName : workspaceNames) {
-                               // Add a supplementary check to hide workspace that are not
-                               // public to anonymous user
-
-                               if (repoNode == null) {
-                                       Session tmpSession = null;
-                                       try {
-                                               tmpSession = repository.login(workspaceName);
-                                               Boolean res = true;
-                                               try {
-                                                       tmpSession.checkPermission("/", "read");
-                                               } catch (AccessControlException e) {
-                                                       res = false;
-                                               }
-                                               if (!res)
-                                                       continue buildWksp;
-                                       } catch (RepositoryException e) {
-                                               throw new SlcException(
-                                                               "Cannot list workspaces for anonymous user", e);
-                                       } finally {
-                                               JcrUtils.logoutQuietly(tmpSession);
-                                       }
-                               }
+       /** Exposes URI to the current repository */
+       public String getUri() {
+               return uri;
+       }
 
-                               // filter technical workspaces
-                               // FIXME: rely on a more robust rule than just wksp name
-                               if (workspaceName.lastIndexOf(VERSION_SEP) > 0) {
-                                       String prefix = workspaceName.substring(0,
-                                                       workspaceName.lastIndexOf(VERSION_SEP));
-                                       if (!children.containsKey(prefix)) {
-                                               children.put(prefix, new WkspGroupElem(RepoElem.this,
-                                                               prefix));
-                                       }
-                               }
-                       }
-                       return children.values().toArray();
-               } catch (RepositoryException e) {
-                       throw new SlcException("Cannot list workspaces for " + repoNode, e);
-               } finally {
-                       JcrUtils.logoutQuietly(session);
-               }
+       /**
+        * Exposes the local repoNode that completely define a connection to a
+        * repository (including a set of credentials). Might return null in case of
+        * an anonymous user
+        */
+       public Node getRepoNode() {
+               return repoNode;
        }
 
        public Repository getRepository() {
-               connect();
                return repository;
        }
-
+       
        public Credentials getCredentials() {
                return credentials;
        }
 
+       // META INFO
        public String getDescription() {
                String desc = label;
                if (repoNode != null)
@@ -177,8 +224,11 @@ public class RepoElem extends DistParentElem {
                return desc;
        }
 
-       /** Might return null in case of an anonymous user */
-       public Node getRepoNode() {
-               return repoNode;
+       public String getLabel() {
+               return label;
+       }
+
+       public String toString() {
+               return repoNode != null ? repoNode.toString() : label;
        }
 }
\ No newline at end of file
index 685a8e053c27cb81f405e8ec5ec8b0746e5edc52..95d28ebb351fd27cf3d8a1ba7cdd4c88e3432f21 100644 (file)
 package org.argeo.slc.client.ui.dist.model;
 
-import java.security.AccessControlException;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.jcr.Repository;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 
+import org.argeo.ArgeoException;
 import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
 
 /**
  * Abstract set of similar workspaces, that is a bunch of workspaces with same
  * prefix.
  */
 public class WkspGroupElem extends DistParentElem {
-       private RepoElem repoElem;
-       private String name;
 
-       public WkspGroupElem(RepoElem repoElem, String prefix) {
-               super(repoElem.inHome(), repoElem.isReadOnly());
-               this.repoElem = repoElem;
-               this.name = prefix;
-       }
+       private Session defaultSession;
 
-       public Object[] getChildren() {
-               Session session = null;
+       /**
+        */
+       public WkspGroupElem(RepoElem repoElem, String prefix) {
+               super(prefix, repoElem.inHome(), repoElem.isReadOnly());
+               setParent(repoElem);
+               // Directly adds children upon creation
                try {
-                       Repository repository = repoElem.getRepository();
-                       session = repository.login(repoElem.getCredentials());
-
-                       String[] workspaceNames = session.getWorkspace()
+                       defaultSession = repoElem.repositoryLogin(null);
+                       String[] wkpNames = defaultSession.getWorkspace()
                                        .getAccessibleWorkspaceNames();
-                       List<WorkspaceElem> distributionElems = new ArrayList<WorkspaceElem>();
-                       buildWksp: for (String workspaceName : workspaceNames) {
-
-                               // Filter non-public workspaces for user anonymous.
-                               if (repoElem.getRepoNode() == null) {
-                                       Session tmpSession = null;
-                                       try {
-                                               tmpSession = repository.login(workspaceName);
-                                               Boolean res = true;
-                                               try {
-                                                       tmpSession.checkPermission("/", "read");
-                                               } catch (AccessControlException e) {
-                                                       res = false;
-                                               }
-                                               if (!res)
-                                                       continue buildWksp;
-                                       } catch (RepositoryException e) {
-                                               throw new SlcException(
-                                                               "Cannot list workspaces for anonymous user", e);
-                                       } finally {
-                                               JcrUtils.logoutQuietly(tmpSession);
-                                       }
-                               }
-
-                               // filter technical workspaces
-                               if (workspaceName.startsWith(name)
-                                               && workspaceName.substring(0,
-                                                               workspaceName.lastIndexOf(VERSION_SEP)).equals(
-                                                               name)) {
-                                       distributionElems.add(new WorkspaceElem(repoElem,
-                                                       workspaceName));
-                               }
+                       for (String wkpName : wkpNames) {
+                               if (wkpName.startsWith(prefix)
+                                               && repoElem.isWorkspaceVisible(wkpName))
+                                       addChild(new WorkspaceElem(WkspGroupElem.this, repoElem,
+                                                       wkpName));
                        }
-                       return distributionElems.toArray();
                } catch (RepositoryException e) {
-                       throw new SlcException("Cannot list workspaces for prefix " + name,
-                                       e);
-               } finally {
-                       JcrUtils.logoutQuietly(session);
+                       throw new ArgeoException("Cannot retrieve workspace names", e);
                }
        }
 
-       public String getLabel() {
-               return name;
-       }
+       //
+       // public Object[] getChildren() {
+       // Session session = null;
+       // try {
+       // Repository repository = repoElem.getRepository();
+       // session = repository.login(repoElem.getCredentials());
+       //
+       // String[] workspaceNames = session.getWorkspace()
+       // .getAccessibleWorkspaceNames();
+       // List<WorkspaceElem> distributionElems = new ArrayList<WorkspaceElem>();
+       // buildWksp: for (String workspaceName : workspaceNames) {
+       //
+       // // Filter non-public workspaces for user anonymous.
+       // if (repoElem.getRepoNode() == null) {
+       // Session tmpSession = null;
+       // try {
+       // tmpSession = repository.login(workspaceName);
+       // Boolean res = true;
+       // try {
+       // tmpSession.checkPermission("/", "read");
+       // } catch (AccessControlException e) {
+       // res = false;
+       // }
+       // if (!res)
+       // continue buildWksp;
+       // } catch (RepositoryException e) {
+       // throw new SlcException(
+       // "Cannot list workspaces for anonymous user", e);
+       // } finally {
+       // JcrUtils.logoutQuietly(tmpSession);
+       // }
+       // }
+       //
+       // // filter technical workspaces
+       // if (workspaceName.startsWith(name)
+       // && workspaceName.substring(0,
+       // workspaceName.lastIndexOf(VERSION_SEP)).equals(
+       // name)) {
+       // distributionElems.add(new WorkspaceElem(repoElem,
+       // workspaceName));
+       // }
+       // }
+       // return distributionElems.toArray();
+       // } catch (RepositoryException e) {
+       // throw new SlcException("Cannot list workspaces for prefix " + name,
+       // e);
+       // } finally {
+       // JcrUtils.logoutQuietly(session);
+       // }
+       // }
 
-       public String toString() {
-               return getLabel();
-       }
+       // public String getLabel() {
+       // return name;
+       // }
+       //
+       // public String toString() {
+       // return getLabel();
+       // }
 
        public void dispose() {
+               JcrUtils.logoutQuietly(defaultSession);
+               super.dispose();
        }
 
-       public RepoElem getRepoElem() {
-               return repoElem;
-       }
+       // public RepoElem getRepoElem() {
+       // return repoElem;
+       // }
 }
\ No newline at end of file
index 9cf295c5f78e0839ae1f7aceadcaec1fec75e400..52acdac7d7e0ba1e85c33c3734baca3673e29c27 100644 (file)
@@ -1,26 +1,26 @@
 package org.argeo.slc.client.ui.dist.model;
 
-/** Abstracts a workspace that contains a given distribution */
+import javax.jcr.NodeIterator;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.query.Query;
+
+import org.argeo.ArgeoException;
+import org.argeo.slc.jcr.SlcNames;
+import org.argeo.slc.jcr.SlcTypes;
+
+/** Abstract a workspace that contains a software distribution */
 public class WorkspaceElem extends DistParentElem {
        private final RepoElem repoElem;
        private String workspaceName;
-       private String label;
-
-       // /**
-       // * Helper to display only version when the workspace name is well
-       // formatted
-       // */
-       // private static String formatName(String name) {
-       // if (name != null && name.lastIndexOf(VERSION_SEP) > 0)
-       // return name.substring(name.lastIndexOf(VERSION_SEP) + 1);
-       // else
-       // return name;
-       // }
-
-       public WorkspaceElem(RepoElem repoElem, String workspaceName) {
+       private Session defaultSession;
+
+       public WorkspaceElem(WkspGroupElem parent, RepoElem repoElem,
+                       String workspaceName) {
+               super(workspaceName, repoElem.inHome(), repoElem.isReadOnly());
                this.repoElem = repoElem;
                this.workspaceName = workspaceName;
-               this.label = workspaceName; // formatName(workspaceName);
+               setParent(parent);
        }
 
        public String getWorkspaceName() {
@@ -31,20 +31,63 @@ public class WorkspaceElem extends DistParentElem {
                return repoElem;
        }
 
-       public boolean isReadOnly() {
-               return repoElem.isReadOnly();
+       public Boolean isConnected() {
+               if (defaultSession != null && defaultSession.isLive())
+                       return true;
+               else
+                       return false;
        }
 
-       public boolean hasChildren() {
-               return false;
+       public void login() {
+               defaultSession = repoElem.repositoryLogin(getName());
        }
 
-       public Object[] getChildren() {
-               return null;
+       public boolean hasChildren() {
+               try {
+                       if (isConnected())
+                               return defaultSession.getRootNode().hasNodes();
+                       else
+                               return false;
+               } catch (RepositoryException re) {
+                       throw new ArgeoException(
+                                       "Unexpected error while checking children node existence",
+                                       re);
+               }
        }
 
+       /** Override normal behaviour to initialize display of the workspace */
        @Override
-       public String getLabel() {
-               return label;
+       public synchronized Object[] getChildren() {
+               if (isLoaded()) {
+                       return super.getChildren();
+               } else {
+                       // initialize current object
+                       try {
+                               if (defaultSession == null)
+                                       return null;
+                               else {
+                                       Query groupQuery = defaultSession
+                                                       .getWorkspace()
+                                                       .getQueryManager()
+                                                       .createQuery(
+                                                                       "select * from [" + SlcTypes.SLC_GROUP_BASE
+                                                                                       + "] as group order by group.["
+                                                                                       + SlcNames.SLC_GROUP_BASE_ID + "]",
+                                                                       Query.JCR_SQL2);
+                                       NodeIterator groups = groupQuery.execute().getNodes();
+                                       while (groups.hasNext()) {
+                                               addChild(new GroupBaseElem(WorkspaceElem.this, groups
+                                                               .nextNode()
+                                                               .getProperty(SlcNames.SLC_GROUP_BASE_ID)
+                                                               .getString()));
+                                       }
+                               }
+                               return super.getChildren();
+                       } catch (RepositoryException e) {
+                               throw new ArgeoException(
+                                               "Cannot initialize WorkspaceNode UI object."
+                                                               + getName(), e);
+                       }
+               }
        }
 }
index ed57feccdd6d122eb784bca74e89b4211dc1d709..21e8f37b0ae5d3727fdf1f8c8511bc062488247c 100644 (file)
@@ -63,7 +63,7 @@ public class AnonymousDistributionsView extends ViewPart implements SlcNames,
 
                // viewer.setContentProvider(new DistTreeContentProvider());
                viewer.setContentProvider(treeContentProvider);
-               viewer.addDoubleClickListener(new DistTreeDoubleClickListener());
+               viewer.addDoubleClickListener(new DistTreeDoubleClickListener(viewer));
                viewer.setComparator(new DistTreeComparator());
 
                // Initialize
index 29797590da0df61441370c91130e32961c9fd615..09119524f5dea4aa817c6c6ef0f73d2929b56428 100644 (file)
@@ -39,12 +39,13 @@ import org.argeo.slc.client.ui.dist.commands.RefreshDistributionsView;
 import org.argeo.slc.client.ui.dist.commands.RegisterRepository;
 import org.argeo.slc.client.ui.dist.commands.UnregisterRemoteRepo;
 import org.argeo.slc.client.ui.dist.controllers.DistTreeComparator;
+import org.argeo.slc.client.ui.dist.controllers.DistTreeComparer;
 import org.argeo.slc.client.ui.dist.controllers.DistTreeContentProvider;
 import org.argeo.slc.client.ui.dist.controllers.DistTreeDoubleClickListener;
 import org.argeo.slc.client.ui.dist.controllers.DistTreeLabelProvider;
 import org.argeo.slc.client.ui.dist.model.DistParentElem;
-import org.argeo.slc.client.ui.dist.model.WkspGroupElem;
 import org.argeo.slc.client.ui.dist.model.RepoElem;
+import org.argeo.slc.client.ui.dist.model.WkspGroupElem;
 import org.argeo.slc.client.ui.dist.model.WorkspaceElem;
 import org.argeo.slc.client.ui.dist.utils.CommandHelpers;
 import org.argeo.slc.jcr.SlcNames;
@@ -57,6 +58,7 @@ import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.viewers.TreeViewer;
 import org.eclipse.jface.viewers.TreeViewerColumn;
 import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerComparator;
 import org.eclipse.jface.viewers.ViewerDropAdapter;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.dnd.DND;
@@ -103,9 +105,14 @@ public class DistributionsView extends ViewPart implements SlcNames, ArgeoNames
 
                // viewer.setContentProvider(new DistTreeContentProvider());
                viewer.setContentProvider(treeContentProvider);
-               viewer.addDoubleClickListener(new DistTreeDoubleClickListener());
+               viewer.addDoubleClickListener(new DistTreeDoubleClickListener(viewer));
+               viewer.setComparer(new DistTreeComparer());
+
                viewer.setComparator(new DistTreeComparator());
 
+               @SuppressWarnings("unused")
+               ViewerComparator vc = viewer.getComparator();
+
                // Enable retrieving current tree selected items from outside the view
                getSite().setSelectionProvider(viewer);
 
@@ -156,7 +163,7 @@ public class DistributionsView extends ViewPart implements SlcNames, ArgeoNames
 
                                if (firstElement instanceof WorkspaceElem) {
                                        WorkspaceElem de = (WorkspaceElem) firstElement;
-                                       re = de.getRepoElem();
+                                       re = (RepoElem) de.getParent().getParent();
                                        isDistribElem = true;
                                        isReadOnly = de.isReadOnly();
                                        workspaceName = de.getWorkspaceName();
@@ -166,13 +173,15 @@ public class DistributionsView extends ViewPart implements SlcNames, ArgeoNames
                                        isHomeRepo = re.inHome();
                                        isReadOnly = re.isReadOnly();
                                } else if (firstElement instanceof WkspGroupElem) {
-                                       WkspGroupElem dge = (WkspGroupElem) firstElement;
-                                       isReadOnly = dge.isReadOnly();
+                                       WkspGroupElem wge = (WkspGroupElem) firstElement;
+                                       isReadOnly = wge.isReadOnly();
                                        isDistribGroupElem = true;
-                                       re = dge.getRepoElem();
-                                       workspacePrefix = dge.getLabel();
+                                       re = (RepoElem) wge.getParent();
+                                       workspacePrefix = wge.getName();
                                }
 
+                               // TODO add case for goups
+
                                if (re != null) {
                                        // targetRepoUri = re.getUri();
                                        targetRepoPath = re.getRepoNode().getPath();
@@ -270,7 +279,7 @@ public class DistributionsView extends ViewPart implements SlcNames, ArgeoNames
                                                PublishWorkspace.ID, PublishWorkspace.DEFAULT_LABEL,
                                                PublishWorkspace.DEFAULT_ICON, isDistribElem
                                                                && singleElement && !isReadOnly, params);
-                               
+
                                // Normalize distribution (Legacy)
                                params = new HashMap<String, String>();
                                params.put(NormalizeDistribution.PARAM_TARGET_REPO_PATH,
@@ -283,8 +292,6 @@ public class DistributionsView extends ViewPart implements SlcNames, ArgeoNames
                                                NormalizeDistribution.DEFAULT_ICON, isDistribElem
                                                                && singleElement && !isReadOnly, params);
 
-                       
-
                                if (submenu.getSize() > 0)
                                        menuManager.add(submenu);
 
@@ -324,8 +331,8 @@ public class DistributionsView extends ViewPart implements SlcNames, ArgeoNames
                        if (selection.getFirstElement() instanceof WorkspaceElem) {
                                WorkspaceElem de = (WorkspaceElem) selection.getFirstElement();
                                if (TextTransfer.getInstance().isSupportedType(event.dataType)) {
-                                       event.data = de.getRepoElem().getUri() + "/"
-                                                       + de.getWorkspaceName();
+                                       event.data = ((RepoElem) de.getParent().getParent())
+                                                       .getUri() + "/" + de.getWorkspaceName();
                                }
                        }
                }
@@ -340,14 +347,18 @@ public class DistributionsView extends ViewPart implements SlcNames, ArgeoNames
 
                @Override
                public boolean performDrop(Object data) {
-                       WorkspaceElem sourceDist = (WorkspaceElem) getSelectedObject();
+                       WorkspaceElem sourceWksp = (WorkspaceElem) getSelectedObject();
                        RepoElem targetRepo = (RepoElem) getCurrentTarget();
 
-                       Boolean ok = MessageDialog.openConfirm(getSite().getShell(),
-                                       "Confirm distribution merge", "Do you want to merge "
-                                                       + sourceDist.getWorkspaceName() + " (from repo "
-                                                       + sourceDist.getRepoElem().getLabel()
-                                                       + ") to repo " + targetRepo.getLabel() + "?");
+                       Boolean ok = MessageDialog.openConfirm(
+                                       getSite().getShell(),
+                                       "Confirm distribution merge",
+                                       "Do you want to merge "
+                                                       + sourceWksp.getWorkspaceName()
+                                                       + " (from repo "
+                                                       + ((RepoElem) sourceWksp.getParent().getParent())
+                                                                       .getLabel() + ") to repo "
+                                                       + targetRepo.getLabel() + "?");
                        if (!ok)
                                return false;
 
@@ -355,14 +366,15 @@ public class DistributionsView extends ViewPart implements SlcNames, ArgeoNames
                                Map<String, String> params = new HashMap<String, String>();
                                params.put(MergeWorkspaces.PARAM_TARGET_REPO_PATH, targetRepo
                                                .getRepoNode().getPath());
-                               params.put(MergeWorkspaces.PARAM_SOURCE_REPO_PATH, sourceDist
-                                               .getRepoElem().getRepoNode().getPath());
+                               params.put(MergeWorkspaces.PARAM_SOURCE_REPO_PATH,
+                                               ((RepoElem) sourceWksp.getParent().getParent())
+                                                               .getRepoNode().getPath());
                                params.put(MergeWorkspaces.PARAM_SOURCE_WORKSPACE_NAME,
-                                               sourceDist.getWorkspaceName());
+                                               sourceWksp.getWorkspaceName());
                                CommandHelpers.callCommand(RefreshDistributionsView.ID, params);
                                return true;
                        } catch (RepositoryException e) {
-                               throw new SlcException("Cannot process drop from " + sourceDist
+                               throw new SlcException("Cannot process drop from " + sourceWksp
                                                + " to " + targetRepo, e);
                        }
                }
@@ -373,8 +385,8 @@ public class DistributionsView extends ViewPart implements SlcNames, ArgeoNames
                        if (target instanceof RepoElem) {
                                if (getSelectedObject() instanceof WorkspaceElem) {
                                        // check if not same repository
-                                       String srcRepoUri = ((WorkspaceElem) getSelectedObject())
-                                                       .getRepoElem().getUri();
+                                       String srcRepoUri = ((RepoElem) ((WorkspaceElem) getSelectedObject())
+                                                       .getParent().getParent()).getUri();
                                        String targetRepoUri = ((RepoElem) target).getUri();
                                        return !targetRepoUri.equals(srcRepoUri);
                                }
index 76df0627411671420af322b6930c134e4bd87c10..3f7f30c6588b7ebd5484c115be5007daa2b1f8f0 100644 (file)
@@ -224,7 +224,7 @@ public class RegisterRepoWizard extends Wizard {
 
                /** Creates label and text. */
                protected Text createLT(Composite parent, String label, String initial) {
-                       new Label(parent, SWT.NONE).setText(label);
+                       new Label(parent, SWT.RIGHT).setText(label);
                        Text text = new Text(parent, SWT.SINGLE | SWT.LEAD | SWT.BORDER);
                        text.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true));
                        text.setText(initial);
@@ -234,7 +234,7 @@ public class RegisterRepoWizard extends Wizard {
                /** Creates label and check. */
                protected Button createLC(Composite parent, String label,
                                Boolean initial) {
-                       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.setSelection(initial);
index 7b901af43b8d658f1f44b9bf489a7942bb3a8ecc..591da8e47a0b92b009c7c5a4134583f52755eb41 100644 (file)
@@ -388,7 +388,7 @@ public class RepoUtils implements ArgeoNames, SlcNames {
        }
 
        /**
-        * Reads credentials from node, using keyring if there is a password. Cann
+        * Reads credentials from node, using keyring if there is a password. Can
         * return null if no credentials needed (local repo) at all, but returns
         * {@link GuestCredentials} if user id is 'anonymous' .
         */
@@ -416,6 +416,42 @@ public class RepoUtils implements ArgeoNames, SlcNames {
                }
        }
 
+       /**
+        * Shortcut to retrieve a session given variable information: Handle the
+        * case where we only have an URI of the repository, that we want to connect
+        * as anonymous or the case of a identified connexion to a local or remote
+        * repository.
+        * 
+        * Callers must close the session once it has been used
+        */
+       public static Session getCorrespondingSession(
+                       RepositoryFactory repositoryFactory, Keyring keyring,
+                       Node repoNode, String uri, String workspaceName) {
+               try {
+                       if (repoNode == null && uri == null)
+                               throw new SlcException(
+                                               "At least one of repoNode and uri must be defined");
+                       Repository currRepo = null;
+                       Credentials credentials = null;
+                       // Anonymous URI only workspace
+                       if (repoNode == null)
+                               // Anonymous
+                               currRepo = ArgeoJcrUtils.getRepositoryByUri(repositoryFactory,
+                                               uri);
+                       else {
+                               currRepo = RepoUtils.getRepository(repositoryFactory, keyring,
+                                               repoNode);
+                               credentials = RepoUtils.getRepositoryCredentials(keyring,
+                                               repoNode);
+                       }
+                       return currRepo.login(credentials, workspaceName);
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot connect to workspace "
+                                       + workspaceName + " of repository " + repoNode
+                                       + " with URI " + uri, e);
+               }
+       }
+
        /**
         * Write group indexes: 'binaries' lists all bundles and their versions,
         * 'sources' list theire sources, and 'sdk' aggregates both.