Work on modular distributions - change lazy init policies, add observer on the catego...
authorBruno Sinou <bsinou@argeo.org>
Mon, 10 Mar 2014 18:53:05 +0000 (18:53 +0000)
committerBruno Sinou <bsinou@argeo.org>
Mon, 10 Mar 2014 18:53:05 +0000 (18:53 +0000)
git-svn-id: https://svn.argeo.org/slc/trunk@6890 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

14 files changed:
plugins/org.argeo.slc.client.ui.dist/icons/removeMark.gif [new file with mode: 0644]
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/DistConstants.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/commands/CopyWorkspace.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/commands/MarkAsRelevantCategory.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/commands/OpenModuleEditor.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/BundleDetailsPage.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/DistWkspSearchPage.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/DistWorkspaceEditor.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/WkspCategoryBaseListPage.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/model/ModularDistBaseElem.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/src/main/java/org/argeo/slc/client/ui/views/JcrResultListView.java

diff --git a/plugins/org.argeo.slc.client.ui.dist/icons/removeMark.gif b/plugins/org.argeo.slc.client.ui.dist/icons/removeMark.gif
new file mode 100644 (file)
index 0000000..d766177
Binary files /dev/null and b/plugins/org.argeo.slc.client.ui.dist/icons/removeMark.gif differ
index 52d41c96e8b34b3e81e9441af25f327664f9c65a..e7fbef20a0ccc227e6f0b9dbf7f133c81f765d02 100644 (file)
@@ -26,8 +26,11 @@ public interface DistConstants {
         */
        public final static String DATE_TIME_FORMAT = "MM/dd/yyyy, HH:mm";
        public final static String DATE_FORMAT = "MM/dd/yyyy";
-       // this should be directly retrieved from JCR APIs
+       // this should be directly retrieved from JCR APIs once we have solved the
+       // problem of the translation of name space to shortcut, typically
+       // {http://www.jcp.org/jcr/1.0} to jcr:
        public final static String JCR_IDENTIFIER = "jcr:uuid";
+       public final static String JCR_MIXIN_TYPES = "jcr:mixinTypes";
 
        // FIXME: should be defined in SlcNames
        public final static String SLC_BUNDLE_NAME = SlcNames.SLC_
@@ -38,4 +41,5 @@ public interface DistConstants {
                        + Constants.BUNDLE_VENDOR;
 
        public final String DEFAULT_PUBLIC_REPOSITORY_URI = "vm:///java";
+
 }
index 435410c46cf3d1a107e20bb77ac0df8354d2b313..e1398b7700901ecd842fa1d7af1fe0e42eb71b70 100644 (file)
@@ -23,19 +23,30 @@ import javax.jcr.RepositoryFactory;
 import javax.jcr.Session;
 import javax.jcr.security.Privilege;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.argeo.ArgeoException;
+import org.argeo.ArgeoMonitor;
+import org.argeo.eclipse.ui.EclipseArgeoMonitor;
 import org.argeo.jcr.JcrUtils;
 import org.argeo.slc.SlcConstants;
 import org.argeo.slc.client.ui.dist.DistPlugin;
+import org.argeo.slc.client.ui.dist.PrivilegedJob;
 import org.argeo.slc.client.ui.dist.utils.CommandHelpers;
 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;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.dialogs.ErrorDialog;
 import org.eclipse.jface.dialogs.InputDialog;
 import org.eclipse.jface.resource.ImageDescriptor;
 import org.eclipse.jface.window.Window;
+import org.eclipse.swt.widgets.Display;
 import org.eclipse.ui.handlers.HandlerUtil;
 
 /**
@@ -43,7 +54,8 @@ import org.eclipse.ui.handlers.HandlerUtil;
  */
 
 public class CopyWorkspace extends AbstractHandler {
-       // private static final Log log = LogFactory.getLog(CopyWorkspace.class);
+       private static final Log log = LogFactory.getLog(CopyWorkspace.class);
+
        public final static String ID = DistPlugin.ID + ".copyWorkspace";
        public final static String DEFAULT_LABEL = "Duplicate...";
        public final static String PARAM_SOURCE_WORKSPACE_NAME = "srcWkspName";
@@ -61,47 +73,158 @@ public class CopyWorkspace extends AbstractHandler {
                String targetRepoPath = event.getParameter(PARAM_TARGET_REPO_PATH);
                String wkspName = event.getParameter(PARAM_SOURCE_WORKSPACE_NAME);
 
-               Session nodeSession = null;
-               Session srcSession = null;
-               Session newSession = null;
-               try {
-                       nodeSession = nodeRepository.login();
-                       Node repoNode = nodeSession.getNode(targetRepoPath);
-                       Repository repository = RepoUtils.getRepository(repositoryFactory,
-                                       keyring, repoNode);
-                       Credentials credentials = RepoUtils.getRepositoryCredentials(
-                                       keyring, repoNode);
-
-                       InputDialog inputDialog = new InputDialog(HandlerUtil
-                                       .getActiveWorkbenchWindow(event).getShell(),
-                                       "New copy of workspace " + wkspName,
-                                       "Choose a name for the workspace to create", "", null);
-                       int result = inputDialog.open();
-                       if (result == Window.OK) {
-                               String newWorkspaceName = inputDialog.getValue();
-                               srcSession = repository.login(credentials, wkspName);
+               InputDialog inputDialog = new InputDialog(HandlerUtil
+                               .getActiveWorkbenchWindow(event).getShell(),
+                               "New copy of workspace " + wkspName,
+                               "Choose a name for the workspace to create", "", null);
+               int result = inputDialog.open();
+               if (result == Window.OK) {
+                       String newWorkspaceName = inputDialog.getValue();
+
+                       if (newWorkspaceName == null || newWorkspaceName.trim().equals("")
+                                       || newWorkspaceName.trim().equals(wkspName.trim())) {
+                               ErrorDialog
+                                               .openError(HandlerUtil.getActiveShell(event),
+                                                               "Non valid workspace name", newWorkspaceName
+                                                                               + " is not a valid workspace name.",
+                                                               new Status(IStatus.ERROR, "not valid", 0,
+                                                                               "Error", null));
+                               return null;
+                       }
+                       Job copyWkspJob = new CopyWkspJob(repositoryFactory, keyring,
+                                       nodeRepository, targetRepoPath, wkspName, newWorkspaceName,
+                                       HandlerUtil.getActiveWorkbenchWindow(event).getShell()
+                                                       .getDisplay());
+                       copyWkspJob.setUser(true);
+                       copyWkspJob.schedule();
+               }
+
+               // Session nodeSession = null;
+               // Session srcSession = null;
+               // Session newSession = null;
+               // try {
+               // nodeSession = nodeRepository.login();
+               // Node repoNode = nodeSession.getNode(targetRepoPath);
+               // Repository repository = RepoUtils.getRepository(repositoryFactory,
+               // keyring, repoNode);
+               // Credentials credentials = RepoUtils.getRepositoryCredentials(
+               // keyring, repoNode);
+               //
+               // InputDialog inputDialog = new InputDialog(HandlerUtil
+               // .getActiveWorkbenchWindow(event).getShell(),
+               // "New copy of workspace " + wkspName,
+               // "Choose a name for the workspace to create", "", null);
+               // int result = inputDialog.open();
+               // if (result == Window.OK) {
+               // String newWorkspaceName = inputDialog.getValue();
+               // srcSession = repository.login(credentials, wkspName);
+               //
+               // // Create the workspace
+               // srcSession.getWorkspace().createWorkspace(newWorkspaceName);
+               // Node srcRootNode = srcSession.getRootNode();
+               // // log in the newly created workspace
+               // newSession = repository.login(credentials, newWorkspaceName);
+               // Node newRootNode = newSession.getRootNode();
+               // RepoUtils.copy(srcRootNode, newRootNode);
+               // newSession.save();
+               // JcrUtils.addPrivilege(newSession, "/", SlcConstants.ROLE_SLC,
+               // Privilege.JCR_ALL);
+               // CommandHelpers.callCommand(RefreshDistributionsView.ID);
+               // }
+               // } catch (RepositoryException re) {
+               // throw new ArgeoException(
+               // "Unexpected error while creating the new workspace.", re);
+               // } finally {
+               // JcrUtils.logoutQuietly(newSession);
+               // JcrUtils.logoutQuietly(srcSession);
+               // JcrUtils.logoutQuietly(nodeSession);
+               // }
+               return null;
+       }
+
+       private static class CopyWkspJob extends PrivilegedJob {
+
+               private RepositoryFactory repositoryFactory;
+               private Keyring keyring;
+               private Repository localRepository;
+               private String targetRepoPath;
+               private String srcWkspName;
+               private String targetWkspName;
+               private Display display;
+
+               public CopyWkspJob(RepositoryFactory repositoryFactory,
+                               Keyring keyring, Repository localRepository,
+                               String targetRepoPath, String srcWkspName,
+                               String targetWkspName, Display display) {
+                       super("Duplicate workspace");
+                       this.repositoryFactory = repositoryFactory;
+                       this.keyring = keyring;
+                       this.localRepository = localRepository;
+                       this.targetRepoPath = targetRepoPath;
+                       this.srcWkspName = srcWkspName;
+                       this.targetWkspName = targetWkspName;
+                       this.display = display;
+               }
+               
+               @Override
+               protected IStatus doRun(IProgressMonitor progressMonitor) {
+                       long begin = System.currentTimeMillis();
+
+                       ArgeoMonitor monitor = new EclipseArgeoMonitor(progressMonitor);
+                       monitor.beginTask("Copy workspace", -1);
+                       monitor.subTask("Copying nodes");
+                       
+                       Session nodeSession = null;
+                       Session srcSession = null;
+                       Session newSession = null;
+                       try {
+                               nodeSession = localRepository.login();
+                               Node repoNode = nodeSession.getNode(targetRepoPath);
+                               Repository repository = RepoUtils.getRepository(
+                                               repositoryFactory, keyring, repoNode);
+                               Credentials credentials = RepoUtils.getRepositoryCredentials(
+                                               keyring, repoNode);
+
+                               srcSession = repository.login(credentials, srcWkspName);
 
                                // Create the workspace
-                               srcSession.getWorkspace().createWorkspace(newWorkspaceName);
+                               srcSession.getWorkspace().createWorkspace(targetWkspName);
                                Node srcRootNode = srcSession.getRootNode();
                                // log in the newly created workspace
-                               newSession = repository.login(credentials, newWorkspaceName);
+                               newSession = repository.login(credentials, targetWkspName);
                                Node newRootNode = newSession.getRootNode();
                                RepoUtils.copy(srcRootNode, newRootNode);
                                newSession.save();
                                JcrUtils.addPrivilege(newSession, "/", SlcConstants.ROLE_SLC,
                                                Privilege.JCR_ALL);
-                               CommandHelpers.callCommand(RefreshDistributionsView.ID);
+
+                               display.asyncExec(new Runnable() {
+                                       public void run() {
+                                               CommandHelpers.callCommand(RefreshDistributionsView.ID);
+                                       }
+                               });
+                               monitor.worked(1);
+
+                       } catch (RepositoryException re) {
+                               throw new ArgeoException(
+                                               "Unexpected error while creating the new workspace.",
+                                               re);
+                       } finally {
+                               JcrUtils.logoutQuietly(newSession);
+                               JcrUtils.logoutQuietly(srcSession);
+                               JcrUtils.logoutQuietly(nodeSession);
                        }
-               } catch (RepositoryException re) {
-                       throw new ArgeoException(
-                                       "Unexpected error while creating the new workspace.", re);
-               } finally {
-                       JcrUtils.logoutQuietly(newSession);
-                       JcrUtils.logoutQuietly(srcSession);
-                       JcrUtils.logoutQuietly(nodeSession);
+
+                       monitor.done();
+                       long duration = (System.currentTimeMillis() - begin) / 1000;// in
+                                                                                                                                               // s
+                       if (log.isDebugEnabled())
+                               log.debug("Created workspace " + targetWkspName + " in "
+                                               + (duration / 60) + "min " + (duration % 60) + "s");
+                       return Status.OK_STATUS;
                }
-               return null;
+
+               
        }
 
        /* DEPENDENCY INJECTION */
index 59b8e20e44139ac67a983a53756e0c49634a0468..ae617087f6e998955568bd40091f88dad194c448 100644 (file)
@@ -41,8 +41,11 @@ public class MarkAsRelevantCategory extends AbstractHandler {
 
        public final static String ID = DistPlugin.ID + ".markAsRelevantCategory";
        public final static String DEFAULT_LABEL = "Mark as relevant category base";
+       public final static String DEFAULT_REMOVE_LABEL = "Remove this category from relevant list";
        public final static ImageDescriptor DEFAULT_ICON = DistPlugin
                        .getImageDescriptor("icons/addItem.gif");
+       public final static ImageDescriptor DEFAULT_REMOVE_ICON = DistPlugin
+                       .getImageDescriptor("icons/removeMark.gif");
 
        public Object execute(ExecutionEvent event) throws ExecutionException {
                try {
@@ -57,16 +60,23 @@ public class MarkAsRelevantCategory extends AbstractHandler {
                                        Iterator<?> it = ((IStructuredSelection) selector)
                                                        .iterator();
 
-                                       String msg = "Your are about to mark this group as category base in the current workspace"
-                                                       + ".\n" + "Are you sure you want to proceed?";
-
-                                       boolean result = MessageDialog.openConfirm(DistPlugin
-                                                       .getDefault().getWorkbench().getDisplay()
-                                                       .getActiveShell(), "Confirm", msg);
+                                       Node node = (Node) it.next();
+                                       if (node.isNodeType(SlcTypes.SLC_RELEVANT_CATEGORY)) {
+                                               String msg = "Your are about to unlist this category from the relevant category list for current workspace"
+                                                               + ".\n" + "Are you sure you want to proceed?";
+                                               if (MessageDialog.openConfirm(DistPlugin.getDefault()
+                                                               .getWorkbench().getDisplay().getActiveShell(),
+                                                               "Confirm", msg)) {
+                                                       node.removeMixin(SlcTypes.SLC_RELEVANT_CATEGORY);
+                                                       node.getSession().save();
+                                               }
+                                       } else {
+                                               String msg = "Your are about to mark this group as category base in the current workspace"
+                                                               + ".\n" + "Are you sure you want to proceed?";
 
-                                       if (result) {
-                                               while (it.hasNext()) {
-                                                       Node node = (Node) it.next();
+                                               if (MessageDialog.openConfirm(DistPlugin.getDefault()
+                                                               .getWorkbench().getDisplay().getActiveShell(),
+                                                               "Confirm", msg)) {
                                                        node.addMixin(SlcTypes.SLC_RELEVANT_CATEGORY);
                                                        node.getSession().save();
                                                }
index b1b9619eb64ef69e8ea36c94e1e5de100d7c337a..85d047a95d5d18dd394042af1afaedf2606daf71 100644 (file)
@@ -82,8 +82,9 @@ public class OpenModuleEditor extends AbstractHandler {
                                businessSession = RepoUtils.getCorrespondingSession(
                                                repositoryFactory, keyring, repoNode, repoUri,
                                                workspaceName);
-                               repoUri = repoNode.getProperty(ArgeoNames.ARGEO_URI)
-                                               .getString();
+                               if (repoUri == null && repoNode != null)
+                                       repoUri = repoNode.getProperty(ArgeoNames.ARGEO_URI)
+                                                       .getString();
 
                        } catch (RepositoryException e) {
                                throw new SlcException("Cannot log to workspace "
index c272672707cb2e99fdeb10e0d3d4dc896de01a49..5136a9128afa4d6ba745e8575f31a03a841bf7e8 100644 (file)
@@ -40,33 +40,32 @@ public class DistTreeDoubleClickListener implements IDoubleClickListener {
                                treeViewer.refresh(obj);
                        }
                } else if (obj instanceof WorkspaceElem) {
-                       WorkspaceElem wn = (WorkspaceElem) obj;
-                       if (!wn.isConnected()) {
-                               wn.login();
-                               treeViewer.refresh(obj);
-                       } else {
-                               WorkspaceElem we = (WorkspaceElem) obj;
-                               Node repoNode = null;
-                               try {
-                                       RepoElem repoElem = we.getRepoElem();
-                                       Map<String, String> params = new HashMap<String, String>();
+                       //WorkspaceElem wn = (WorkspaceElem) obj;
+                       // if (!wn.isConnected()) {
+                       // wn.login();
+                       // treeViewer.refresh(obj);
+                       // } else {
+                       WorkspaceElem we = (WorkspaceElem) obj;
+                       Node repoNode = null;
+                       try {
+                               RepoElem repoElem = we.getRepoElem();
+                               Map<String, String> params = new HashMap<String, String>();
 
-                                       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 "
-                                                       + repoNode + " while "
-                                                       + "setting parameters of command "
-                                                       + "OpenWorkspaceEditor", re);
-                               }
+                               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 " + repoNode
+                                               + " while " + "setting parameters of command "
+                                               + "OpenWorkspaceEditor", re);
                        }
+                       // }
                } else if (obj instanceof ModularDistVersionElem) {
                        ModularDistVersionElem modDistElem = (ModularDistVersionElem) obj;
                        WorkspaceElem wkspElem = modDistElem.getWorkspaceElem();
index 3fc3aca081b1be2d4cd77fa40505ac7687ec12c7..37bff6bd717b1f0c55264c341b6755846847b41e 100644 (file)
@@ -34,10 +34,7 @@ public class DistTreeLabelProvider extends ColumnLabelProvider {
                        else
                                return JcrImages.REPOSITORY_DISCONNECTED;
                } else if (element instanceof WorkspaceElem) {
-                       if (((WorkspaceElem) element).isConnected())
-                               return JcrImages.WORKSPACE_CONNECTED;
-                       else
-                               return JcrImages.WORKSPACE_DISCONNECTED;
+                       return JcrImages.WORKSPACE_CONNECTED;
                } else if (element instanceof WkspGroupElem)
                        return DistImages.IMG_WKSP_GROUP;
                // else if (element instanceof GroupBaseElem)
index c33cca469f7581d9e4147f76874b77e1159b2382..d2d0773deb2e8b4a5d75732686f5cd4923535e9d 100644 (file)
@@ -33,6 +33,7 @@ import org.argeo.slc.jcr.SlcNames;
 import org.argeo.slc.jcr.SlcTypes;
 import org.argeo.slc.repo.RepoConstants;
 import org.argeo.slc.repo.RepoUtils;
+import org.eclipse.jface.dialogs.IMessageProvider;
 import org.eclipse.jface.viewers.ColumnLabelProvider;
 import org.eclipse.jface.viewers.IStructuredContentProvider;
 import org.eclipse.jface.viewers.ITreeContentProvider;
@@ -89,6 +90,7 @@ public class BundleDetailsPage extends FormPage implements SlcNames, SlcTypes {
                        form.setText(currBundle.hasProperty(DistConstants.SLC_BUNDLE_NAME) ? currBundle
                                        .getProperty(DistConstants.SLC_BUNDLE_NAME).getString()
                                        : "");
+                       form.setMessage(" test", IMessageProvider.NONE);
                        Composite body = form.getBody();
                        GridLayout layout = new GridLayout(1, false);
                        layout.marginWidth = 5;
index 7937eb6b7fceff48dbddd2938ef746f2716b6ebc..1228edfed051f18d8d8c02eda93cb67bf977dd0a 100644 (file)
@@ -39,6 +39,7 @@ import javax.jcr.query.qom.StaticOperand;
 
 import org.argeo.ArgeoMonitor;
 import org.argeo.eclipse.ui.EclipseArgeoMonitor;
+import org.argeo.eclipse.ui.EclipseUiUtils;
 import org.argeo.eclipse.ui.utils.CommandUtils;
 import org.argeo.jcr.JcrUtils;
 import org.argeo.slc.SlcException;
@@ -66,13 +67,12 @@ import org.eclipse.jface.viewers.TableViewer;
 import org.eclipse.jface.viewers.TableViewerColumn;
 import org.eclipse.jface.viewers.Viewer;
 import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ControlEvent;
-import org.eclipse.swt.events.ControlListener;
 import org.eclipse.swt.events.ModifyEvent;
 import org.eclipse.swt.events.ModifyListener;
 import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
 import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.FillLayout;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Button;
@@ -105,9 +105,9 @@ public class DistWkspSearchPage extends FormPage implements SlcNames {
        private NodeViewerComparator comparator;
        private TableViewer viewer;
 
-       private Composite header;
+       // private Composite header;
        private Text artifactTxt;
-       private final static String FILTER_HELP_MSG = "Enter filter criterion separated by a space";
+       private final static String FILTER_HELP_MSG = "Search bundles in the current workspace";
 
        public DistWkspSearchPage(DistWorkspaceEditor formEditor, String title,
                        Session session) {
@@ -166,22 +166,20 @@ public class DistWkspSearchPage extends FormPage implements SlcNames {
                Composite body = form.getBody();
                body.setLayout(layout);
 
-               // Add the filter section
-               createFilterPart(body);
-               // Add the table
-               createTableViewer(body);
-               // viewer.setInput(null);
-               // Add a listener to enable custom resize process
-               form.addControlListener(new ControlListener() {
-                       // form.addListener(SWT.RESIZE, new Listener() does not work
-                       public void controlResized(ControlEvent e) {
-                               refreshLayout();
-                       }
+               // Meta info about current workspace
+               Composite header = tk.createComposite(body);
+               header.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
+               createHeaderPart(form, header);
 
-                       public void controlMoved(ControlEvent e) {
-                       }
-               });
-               asynchronousRefresh();
+               // filter text
+               Composite filter = tk.createComposite(body);
+               filter.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
+               createFilterPart(filter);
+
+               // the table
+               Composite tableCmp = tk.createComposite(body);
+               tableCmp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+               createTableViewer(tableCmp);
        }
 
        /** Build repository request */
@@ -243,42 +241,62 @@ public class DistWkspSearchPage extends FormPage implements SlcNames {
 
        }
 
-       private void createFilterPart(Composite parent) {
-               header = tk.createComposite(parent);
-               GridLayout layout = new GridLayout(2, false);
+       private void createHeaderPart(ScrolledForm form, Composite parent) {
+               GridLayout layout = new GridLayout(4, false);
                layout.marginWidth = layout.marginHeight = layout.verticalSpacing = 0;
                layout.horizontalSpacing = 5;
-               header.setLayout(layout);
-               GridData gd = new GridData(SWT.FILL, SWT.FILL, false, false);
-               header.setLayoutData(gd);
+               parent.setLayout(layout);
+
+               String wkspName = ((DistWkspEditorInput) getEditorInput())
+                               .getWorkspaceName();
+               // wkspName = "Workspace " + wkspName;
+               form.setText(wkspName);
 
-               // Title: some meta information
-               // label = repoNode.isNodeType(NodeType.MIX_TITLE) ? repoNode
-               // .getProperty(Property.JCR_TITLE).getString() : repoNode
-               // .getName();
+               // form.setMessage("Choose in the below list "
+               // + "the categories that can be used as base for "
+               // + "modular distributions maintained via the current workspace",
+               // IMessageProvider.NONE);
 
-               String desc = null;
+               String repoAlias = "";
                Node repoNode = ((DistWorkspaceEditor) getEditor()).getRepoNode();
                if (repoNode != null)
                        try {
-                               desc = repoNode.isNodeType(NodeType.MIX_TITLE) ? repoNode
+                               repoAlias = 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 += " (" + ((DistWkspEditorInput) getEditorInput()).getUri() + ")";
-               Label lbl = tk.createLabel(header, desc, SWT.NONE);
+               else
+                       repoAlias = " - ";
 
-               gd = new GridData(SWT.FILL, SWT.FILL, false, false);
-               gd.horizontalSpan = 2;
-               lbl.setLayoutData(gd);
+               createLT(parent, "Repository alias", repoAlias);
+               createLT(parent, "URI",
+                               ((DistWkspEditorInput) getEditorInput()).getUri());
+       }
+
+       private Text createLT(Composite parent, String labelValue, String textValue) {
+               Label label = tk.createLabel(parent, labelValue, SWT.RIGHT);
+               label.setFont(EclipseUiUtils.getBoldFont(parent));
+               label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
+
+               // Add a trailing space to workaround a display glitch in RAP 1.3
+               Text text = tk.createText(parent, textValue + " ", SWT.LEFT);
+               text.setEditable(false);
+               return text;
+       }
+
+       private void createFilterPart(Composite parent) {
+               GridLayout layout = new GridLayout(2, false);
+               layout.marginWidth = layout.marginHeight = layout.verticalSpacing = 0;
+               layout.horizontalSpacing = 5;
+               parent.setLayout(layout);
 
                // Text Area to filter
-               artifactTxt = tk.createText(header, "", SWT.BORDER | SWT.SINGLE
+               artifactTxt = tk.createText(parent, "", SWT.BORDER | SWT.SINGLE
                                | SWT.SEARCH | SWT.CANCEL);
                artifactTxt.setMessage(FILTER_HELP_MSG);
-               gd = new GridData(SWT.FILL, SWT.FILL, false, false);
+               GridData gd = new GridData(SWT.FILL, SWT.FILL, false, false);
                gd.grabExcessHorizontalSpace = true;
                artifactTxt.setLayoutData(gd);
                artifactTxt.addModifyListener(new ModifyListener() {
@@ -290,7 +308,7 @@ public class DistWkspSearchPage extends FormPage implements SlcNames {
                        }
                });
 
-               Button resetBtn = tk.createButton(header, null, SWT.PUSH);
+               Button resetBtn = tk.createButton(parent, null, SWT.PUSH);
                resetBtn.setImage(DistImages.IMG_REPO_READONLY);
                resetBtn.addSelectionListener(new SelectionListener() {
 
@@ -301,7 +319,6 @@ public class DistWkspSearchPage extends FormPage implements SlcNames {
                        public void widgetDefaultSelected(SelectionEvent e) {
                        }
                });
-
        }
 
        private void resetFilter() {
@@ -321,6 +338,7 @@ public class DistWkspSearchPage extends FormPage implements SlcNames {
        }
 
        private void createTableViewer(Composite parent) {
+               parent.setLayout(new FillLayout());
                // helpers to enable sorting by column
                List<String> propertiesList = new ArrayList<String>();
                List<Integer> propertyTypesList = new ArrayList<Integer>();
@@ -497,21 +515,23 @@ public class DistWkspSearchPage extends FormPage implements SlcNames {
         * UI Trick to put scroll bar on the table rather than on the scrollform
         */
        private void refreshLayout() {
-               // Compute desired table size
-               int maxH = getManagedForm().getForm().getSize().y;
-               int maxW = getManagedForm().getForm().getParent().getSize().x;
-               maxH = maxH - header.getSize().y;
-               final Table table = viewer.getTable();
-               GridData gd = new GridData(SWT.LEFT, SWT.TOP, true, true);
-
-               // when table height is less than 200 px, we let the scroll bar on the
-               // scrollForm
-               // FIXME substract some spare space. There is room here for optimization
-               gd.heightHint = Math.max(maxH - 35, 200);
-               gd.widthHint = Math.max(maxW - 35, 200);
-
-               table.setLayoutData(gd);
-               getManagedForm().reflow(true);
+               // // Compute desired table size
+               // int maxH = getManagedForm().getForm().getSize().y;
+               // int maxW = getManagedForm().getForm().getParent().getSize().x;
+               // // maxH = maxH - header.getSize().y;
+               // final Table table = viewer.getTable();
+               // GridData gd = new GridData(SWT.LEFT, SWT.TOP, true, true);
+               //
+               // // when table height is less than 200 px, we let the scroll bar on
+               // the
+               // // scrollForm
+               // // FIXME substract some spare space. There is room here for
+               // optimization
+               // gd.heightHint = Math.max(maxH - 35, 200);
+               // gd.widthHint = Math.max(maxW - 35, 200);
+               //
+               // table.setLayoutData(gd);
+               // getManagedForm().reflow(true);
        }
 
        @Override
index 8f053bf3bf5cdaa006fc42de9455a30750cb31c0..0d3220aafc8a62d079301f1c417ad9eba427d2cd 100644 (file)
@@ -79,8 +79,8 @@ public class DistWorkspaceEditor extends FormEditor implements SlcNames {
        protected void addPages() {
                try {
                        addPage(new DistWkspSearchPage(this, "Details ", businessSession));
-                       addPage(new DistWkspBrowserPage(this, "Browser ", businessSession));
-                       addPage(new WkspCategoryBaseListPage(this, "Group base ",
+                       addPage(new DistWkspBrowserPage(this, "Maven ", businessSession));
+                       addPage(new WkspCategoryBaseListPage(this, "Groups ",
                                        businessSession));
                } catch (PartInitException e) {
                        throw new ArgeoException("Cannot add distribution editor pages", e);
index fa9f65f9689a16c6dad9c6e58597ddeedb47f0ed..7f67a73a36d0c9aae0258acc1745ad14cef98e83 100644 (file)
@@ -23,6 +23,8 @@ import javax.jcr.NodeIterator;
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
+import javax.jcr.observation.Event;
+import javax.jcr.observation.ObservationManager;
 import javax.jcr.query.QueryManager;
 import javax.jcr.query.QueryResult;
 import javax.jcr.query.qom.Constraint;
@@ -33,9 +35,11 @@ import javax.jcr.query.qom.Selector;
 import javax.jcr.query.qom.StaticOperand;
 
 import org.argeo.ArgeoException;
+import org.argeo.eclipse.ui.jcr.AsyncUiEventListener;
 import org.argeo.eclipse.ui.utils.CommandUtils;
 import org.argeo.jcr.JcrUtils;
 import org.argeo.slc.SlcException;
+import org.argeo.slc.client.ui.dist.DistConstants;
 import org.argeo.slc.client.ui.dist.DistImages;
 import org.argeo.slc.client.ui.dist.DistPlugin;
 import org.argeo.slc.client.ui.dist.commands.MarkAsRelevantCategory;
@@ -55,17 +59,16 @@ import org.eclipse.jface.viewers.TableViewer;
 import org.eclipse.jface.viewers.TableViewerColumn;
 import org.eclipse.jface.viewers.Viewer;
 import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ControlEvent;
-import org.eclipse.swt.events.ControlListener;
 import org.eclipse.swt.events.ModifyEvent;
 import org.eclipse.swt.events.ModifyListener;
 import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.FillLayout;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Menu;
 import org.eclipse.swt.widgets.Table;
 import org.eclipse.swt.widgets.Text;
@@ -93,10 +96,13 @@ public class WkspCategoryBaseListPage extends FormPage implements SlcNames {
        private NodeViewerComparator comparator;
        private TableViewer viewer;
        private FormToolkit tk;
-       private Composite header;
        private Text filterTxt;
        private final static String FILTER_HELP_MSG = "Enter filter criterion separated by a space";
 
+       // Observes changes
+       private final static String[] observedTypes = { SlcTypes.SLC_GROUP_BASE };
+       private CategoryObserver categoriesObserver;
+
        public WkspCategoryBaseListPage(FormEditor formEditor, String title,
                        Session session) {
                super(formEditor, PAGE_ID, title);
@@ -108,29 +114,40 @@ public class WkspCategoryBaseListPage extends FormPage implements SlcNames {
                ScrolledForm form = managedForm.getForm();
                tk = managedForm.getToolkit();
 
-               form.setText("Category base definition");
-               form.setMessage("Define relevant group base objects",
+               form.setText("Define Relevant Category");
+               form.setMessage("Choose in the below list "
+                               + "the categories that can be used as base for "
+                               + "modular distributions maintained via the current workspace",
                                IMessageProvider.NONE);
 
                // Main Layout
                GridLayout layout = new GridLayout(1, false);
                Composite body = form.getBody();
                body.setLayout(layout);
-               // Add the filter section
-               createFilterPart(body);
-               // Add the table
-               createTableViewer(body);
-
-               // Add a listener to enable custom resize process
-               form.addControlListener(new ControlListener() {
-                       // form.addListener(SWT.RESIZE, new Listener() does not work
-                       public void controlResized(ControlEvent e) {
-                               refreshLayout();
-                       }
 
-                       public void controlMoved(ControlEvent e) {
-                       }
-               });
+               // filter section
+               Composite header = tk.createComposite(body);
+               header.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
+               createFilterPart(header);
+
+               // the table
+               Composite tableCmp = tk.createComposite(body);
+               tableCmp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+               createTableViewer(tableCmp);
+
+               categoriesObserver = new CategoryObserver(viewer.getTable()
+                               .getDisplay());
+               try {
+                       ObservationManager observationManager = session.getWorkspace()
+                                       .getObservationManager();
+                       // FIXME Will not be notified if empty result is deleted
+                       observationManager.addEventListener(categoriesObserver,
+                                       Event.PROPERTY_CHANGED, "/", true, null, observedTypes,
+                                       false);
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot register listeners", e);
+               }
+
                refresh();
        }
 
@@ -192,39 +209,29 @@ public class WkspCategoryBaseListPage extends FormPage implements SlcNames {
        }
 
        private void createFilterPart(Composite parent) {
-               header = tk.createComposite(parent);
                GridLayout layout = new GridLayout(2, false);
                layout.marginWidth = layout.marginHeight = layout.verticalSpacing = 0;
                layout.horizontalSpacing = 5;
-               header.setLayout(layout);
-               GridData gd = new GridData(SWT.FILL, SWT.FILL, false, false);
-               header.setLayoutData(gd);
+               parent.setLayout(layout);
 
                // Text Area to filter
-               filterTxt = tk.createText(header, "", SWT.BORDER | SWT.SINGLE
+               filterTxt = tk.createText(parent, "", SWT.BORDER | SWT.SINGLE
                                | SWT.SEARCH | SWT.CANCEL);
                filterTxt.setMessage(FILTER_HELP_MSG);
-               gd = new GridData(SWT.FILL, SWT.FILL, false, false);
-               gd.grabExcessHorizontalSpace = true;
-               filterTxt.setLayoutData(gd);
+               filterTxt.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
                filterTxt.addModifyListener(new ModifyListener() {
                        public void modifyText(ModifyEvent event) {
                                refresh();
                        }
                });
 
-               Button resetBtn = tk.createButton(header, null, SWT.PUSH);
+               Button resetBtn = tk.createButton(parent, null, SWT.PUSH);
                resetBtn.setImage(DistImages.IMG_REPO_READONLY);
-               resetBtn.addSelectionListener(new SelectionListener() {
-
+               resetBtn.addSelectionListener(new SelectionAdapter() {
                        public void widgetSelected(SelectionEvent e) {
                                resetFilter();
                        }
-
-                       public void widgetDefaultSelected(SelectionEvent e) {
-                       }
                });
-
        }
 
        private void resetFilter() {
@@ -233,12 +240,13 @@ public class WkspCategoryBaseListPage extends FormPage implements SlcNames {
        }
 
        private void createTableViewer(Composite parent) {
+               parent.setLayout(new FillLayout());
                // helpers to enable sorting by column
                List<String> propertiesList = new ArrayList<String>();
                List<Integer> propertyTypesList = new ArrayList<Integer>();
 
                // Define the TableViewer
-               viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL
+               viewer = new TableViewer(parent, SWT.SINGLE | SWT.H_SCROLL
                                | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
 
                TableViewerColumn col;
@@ -267,20 +275,20 @@ public class WkspCategoryBaseListPage extends FormPage implements SlcNames {
                        }
                });
                col.getColumn().addSelectionListener(getSelectionAdapter(0));
-               propertiesList.add(SLC_NAME);
+               propertiesList.add(SLC_GROUP_BASE_ID);
                propertyTypesList.add(PropertyType.STRING);
 
                // Version
                col = new TableViewerColumn(viewer, SWT.NONE);
                col.getColumn().setWidth(80);
-               col.getColumn().setText("Is category");
+               col.getColumn().setText("Relevant");
                col.setLabelProvider(new ColumnLabelProvider() {
                        @Override
                        public String getText(Object element) {
                                try {
                                        return ((Node) element)
                                                        .isNodeType(SlcTypes.SLC_RELEVANT_CATEGORY) ? "Yes"
-                                                       : "-";
+                                                       : "No";
                                } catch (RepositoryException e) {
                                        throw new SlcException("unable to check type of node "
                                                        + element, e);
@@ -331,18 +339,31 @@ public class WkspCategoryBaseListPage extends FormPage implements SlcNames {
                // Mark as category base
                Object firstElement = ((IStructuredSelection) viewer.getSelection())
                                .getFirstElement();
-               boolean showMark = false;
+               Node currSelected = (Node) firstElement;
+
+               boolean isRelevant = false;
                try {
-                       showMark = !((Node) firstElement)
+                       isRelevant = currSelected
                                        .isNodeType(SlcTypes.SLC_RELEVANT_CATEGORY);
+                       boolean canEdit = currSelected
+                                       .canAddMixin(SlcTypes.SLC_RELEVANT_CATEGORY);
+
                } catch (RepositoryException e) {
                        throw new SlcException("unable to check type of node "
                                        + firstElement, e);
                }
-               CommandUtils.refreshCommand(menuManager, window,
-                               MarkAsRelevantCategory.ID,
-                               MarkAsRelevantCategory.DEFAULT_LABEL,
-                               MarkAsRelevantCategory.DEFAULT_ICON, showMark);
+               // Add
+               if (isRelevant) {// Remove
+                       CommandUtils.refreshCommand(menuManager, window,
+                                       MarkAsRelevantCategory.ID,
+                                       MarkAsRelevantCategory.DEFAULT_REMOVE_LABEL,
+                                       MarkAsRelevantCategory.DEFAULT_REMOVE_ICON, true);
+               } else {
+                       CommandUtils.refreshCommand(menuManager, window,
+                                       MarkAsRelevantCategory.ID,
+                                       MarkAsRelevantCategory.DEFAULT_LABEL,
+                                       MarkAsRelevantCategory.DEFAULT_ICON, true);
+               }
        }
 
        private SelectionAdapter getSelectionAdapter(final int index) {
@@ -413,32 +434,36 @@ public class WkspCategoryBaseListPage extends FormPage implements SlcNames {
                }
        }
 
-       /**
-        * UI Trick to put scroll bar on the table rather than on the scrollform
-        */
-       private void refreshLayout() {
-               // Compute desired table size
-               int maxH = getManagedForm().getForm().getSize().y;
-               int maxW = getManagedForm().getForm().getParent().getSize().x;
-               maxH = maxH - header.getSize().y;
-               final Table table = viewer.getTable();
-               GridData gd = new GridData(SWT.LEFT, SWT.TOP, true, true);
+       class CategoryObserver extends AsyncUiEventListener {
 
-               // when table height is less than 200 px, we let the scroll bar on the
-               // scrollForm
-               // FIXME substract some spare space. There is room here for optimization
-               gd.heightHint = Math.max(maxH - 35, 200);
-               gd.widthHint = Math.max(maxW - 35, 200);
+               public CategoryObserver(Display display) {
+                       super(display);
+               }
 
-               table.setLayoutData(gd);
-               getManagedForm().reflow(true);
+               @Override
+               protected Boolean willProcessInUiThread(List<Event> events)
+                               throws RepositoryException {
+                       for (Event event : events) {
+                               String path = event.getPath();
+                               if (JcrUtils.lastPathElement(path).equals(
+                                               DistConstants.JCR_MIXIN_TYPES))
+                                       return true;
+                       }
+                       return false;
+               }
+
+               protected void onEventInUiThread(List<Event> events)
+                               throws RepositoryException {
+                       if (getLog().isTraceEnabled())
+                               getLog().trace("Refresh table");
+                       viewer.refresh();
+               }
        }
 
        @Override
        public void setActive(boolean active) {
                super.setActive(active);
                if (active) {
-                       refreshLayout();
                }
        }
 }
\ No newline at end of file
index 08c7d6d3eaee8f9e5222883f2a27aa0dcbcb65c1..35e3f21dd40f01ad2bec30df308913719d180986 100644 (file)
@@ -21,6 +21,7 @@ import org.argeo.slc.jcr.SlcTypes;
  */
 public class ModularDistBaseElem extends DistParentElem {
 
+       final static public String AETHER_CATEGORY_BASE = "categoryBase";
        final static public String AETHER_BINARIES_TYPE = "binaries";
        final static public String AETHER_DEP_TYPE = "dep";
        private String type;
@@ -57,7 +58,7 @@ public class ModularDistBaseElem extends DistParentElem {
                        // initialize current object
                        try {
                                NodeIterator ni = getDistVersions();
-                               while (ni.hasNext()) {
+                               while (ni != null && ni.hasNext()) {
                                        Node curNode = ni.nextNode();
                                        addChild(new ModularDistVersionElem(this, curNode
                                                        .getProperty(SlcNames.SLC_ARTIFACT_VERSION)
@@ -74,6 +75,9 @@ public class ModularDistBaseElem extends DistParentElem {
 
        public NodeIterator getDistVersions() {
                try {
+                       if (AETHER_CATEGORY_BASE.equals(type))
+                               return null;
+
                        QueryManager queryManager = artifactBase.getSession()
                                        .getWorkspace().getQueryManager();
                        QueryObjectModelFactory factory = queryManager.getQOMFactory();
index 6f6a93a3a83b5d3b3cd96db6f50fbab284ff83d6..a163974072607d43659a534c250c200e7479c6d2 100644 (file)
@@ -49,7 +49,7 @@ public class WorkspaceElem extends DistParentElem {
                        if (isConnected())
                                return currSession.getRootNode().hasNodes();
                        else
-                               return false;
+                               return true;
                } catch (RepositoryException re) {
                        throw new ArgeoException(
                                        "Unexpected error while checking children node existence",
@@ -65,61 +65,60 @@ public class WorkspaceElem extends DistParentElem {
                } else {
                        // initialize current object
                        try {
+                               // Lazy connect the first time we retrieve children
                                if (currSession == null)
-                                       return null;
-                               else {
-                                       // Retrieve already existing distribution
-                                       Query groupQuery = currSession
-                                                       .getWorkspace()
-                                                       .getQueryManager()
-                                                       .createQuery(
-                                                                       "select * from ["
-                                                                                       + SlcTypes.SLC_MODULAR_DISTRIBUTION
-                                                                                       + "]", Query.JCR_SQL2);
-                                       NodeIterator distributions = groupQuery.execute()
-                                                       .getNodes();
-                                       distribs: while (distributions.hasNext()) {
-                                               Node currDist = distributions.nextNode();
-                                               Node distBase = currDist.getParent().getParent();
-                                               if (!distBase.isNodeType(SlcTypes.SLC_ARTIFACT_BASE))
-                                                       continue distribs;
-                                               String groupId = distBase.getProperty(
-                                                               SlcNames.SLC_GROUP_ID).getString();
-                                               String artifactId = distBase.getProperty(
-                                                               SlcNames.SLC_ARTIFACT_ID).getString();
+                                       login();
 
-                                               String name;
-                                               String type;
-                                               if (ModularDistBaseElem.AETHER_BINARIES_TYPE
-                                                               .equals(artifactId)) {
-                                                       name = groupId;
-                                                       type = ModularDistBaseElem.AETHER_BINARIES_TYPE;
-                                               } else {
-                                                       name = artifactId;
-                                                       type = ModularDistBaseElem.AETHER_DEP_TYPE;
-                                               }
-                                               if (getChildByName(name) == null)
-                                                       addChild(new ModularDistBaseElem(
-                                                                       WorkspaceElem.this, name, distBase, type));
-                                       }
-                                       // Add empty group base that have been marked as relevant
-                                       groupQuery = currSession
-                                                       .getWorkspace()
-                                                       .getQueryManager()
-                                                       .createQuery(
-                                                                       "select * from ["
-                                                                                       + SlcTypes.SLC_RELEVANT_CATEGORY
-                                                                                       + "]", Query.JCR_SQL2);
-                                       distributions = groupQuery.execute().getNodes();
-                                       while (distributions.hasNext()) {
-                                               Node distBase = distributions.nextNode();
-                                               String groupBaseId = distBase.getProperty(
-                                                               SlcNames.SLC_GROUP_BASE_ID).getString();
-                                               if (getChildByName(groupBaseId) == null)
-                                                       addChild(new ModularDistBaseElem(
-                                                                       WorkspaceElem.this, groupBaseId, distBase,
-                                                                       ModularDistBaseElem.AETHER_BINARIES_TYPE));
+                               // Retrieve already existing distribution
+                               Query groupQuery = currSession
+                                               .getWorkspace()
+                                               .getQueryManager()
+                                               .createQuery(
+                                                               "select * from ["
+                                                                               + SlcTypes.SLC_MODULAR_DISTRIBUTION
+                                                                               + "]", Query.JCR_SQL2);
+                               NodeIterator distributions = groupQuery.execute().getNodes();
+                               distribs: while (distributions.hasNext()) {
+                                       Node currDist = distributions.nextNode();
+                                       Node distBase = currDist.getParent().getParent();
+                                       if (!distBase.isNodeType(SlcTypes.SLC_ARTIFACT_BASE))
+                                               continue distribs;
+                                       String groupId = distBase
+                                                       .getProperty(SlcNames.SLC_GROUP_ID).getString();
+                                       String artifactId = distBase.getProperty(
+                                                       SlcNames.SLC_ARTIFACT_ID).getString();
+
+                                       String name;
+                                       String type;
+                                       if (ModularDistBaseElem.AETHER_BINARIES_TYPE
+                                                       .equals(artifactId)) {
+                                               name = groupId;
+                                               type = ModularDistBaseElem.AETHER_BINARIES_TYPE;
+                                       } else {
+                                               name = artifactId;
+                                               type = ModularDistBaseElem.AETHER_DEP_TYPE;
                                        }
+                                       if (getChildByName(name) == null)
+                                               addChild(new ModularDistBaseElem(WorkspaceElem.this,
+                                                               name, distBase, type));
+                               }
+                               // Add empty group base that have been marked as relevant
+                               groupQuery = currSession
+                                               .getWorkspace()
+                                               .getQueryManager()
+                                               .createQuery(
+                                                               "select * from ["
+                                                                               + SlcTypes.SLC_RELEVANT_CATEGORY + "]",
+                                                               Query.JCR_SQL2);
+                               distributions = groupQuery.execute().getNodes();
+                               while (distributions.hasNext()) {
+                                       Node distBase = distributions.nextNode();
+                                       String groupBaseId = distBase.getProperty(
+                                                       SlcNames.SLC_GROUP_BASE_ID).getString();
+                                       if (getChildByName(groupBaseId) == null)
+                                               addChild(new ModularDistBaseElem(WorkspaceElem.this,
+                                                               groupBaseId, distBase,
+                                                               ModularDistBaseElem.AETHER_CATEGORY_BASE));
                                }
                                return super.getChildren();
                        } catch (RepositoryException e) {
index b3faa178471bb7719b71d449e80e5f7c30631f43..0f25c7ce7867d8459a4459b275c438025ce902a0 100644 (file)
@@ -272,7 +272,6 @@ public class JcrResultListView extends ViewPart implements SlcNames {
                                getLog().trace("Refresh result list");
                        viewer.refresh();
                }
-
        }
 
        public void setSession(Session session) {