+ Add a bundle details page
authorBruno Sinou <bsinou@argeo.org>
Thu, 7 Mar 2013 21:30:02 +0000 (21:30 +0000)
committerBruno Sinou <bsinou@argeo.org>
Thu, 7 Mar 2013 21:30:02 +0000 (21:30 +0000)
+ Enhance bundle overview filter
+ fix a few bugs

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

22 files changed:
plugins/org.argeo.slc.client.ui.dist/META-INF/spring/commands.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/DistConstants.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/commands/Fetch.java [new file with mode: 0644]
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/commands/RepoSyncCommand.java [deleted file]
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/ArtifactDetailsPage.java [deleted file]
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/ArtifactsBrowserPage.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/BundleDetailsPage.java [new file with mode: 0644]
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/BundleRawPage.java [new file with mode: 0644]
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/DistributionEditor.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/DistributionEditorInput.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/GenericArtifactEditor.java [deleted file]
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/GenericArtifactEditorInput.java [deleted file]
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/GenericBundleEditor.java [new file with mode: 0644]
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/GenericBundleEditorInput.java [new file with mode: 0644]
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/utils/AbstractHyperlinkListener.java [new file with mode: 0644]
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/utils/GenericDoubleClickListener.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/views/AbstractQueryArtifactsView.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/views/ArtifactsBrowser.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

index c5dce5e2fd25e680b958942ec077f3555425b502..da185e6dfcf44f827320649079518b2ab446fcd3 100644 (file)
@@ -26,7 +26,7 @@
                scope="prototype">
                <property name="repository" ref="javaRepository" />
        </bean>
-       <bean id="repoSyncCommand" class="org.argeo.slc.client.ui.dist.commands.RepoSyncCommand"
+       <bean id="fetch" class="org.argeo.slc.client.ui.dist.commands.Fetch"
                scope="prototype">
                <property name="repositoryFactory" ref="repositoryFactory" />
                <property name="nodeRepository" ref="nodeRepository" />
@@ -63,7 +63,8 @@
                scope="prototype">
        </bean>
 
-       <bean id="registerRepository" class="org.argeo.slc.client.ui.dist.commands.RegisterRepository">
+       <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" />
index 1d3935d5010bf9fef15d00863978cab9d0f077c5..f801a997d28a2858a982bdca13e79c3b345cd343 100644 (file)
@@ -56,9 +56,9 @@
    <extension
            point="org.eclipse.ui.editors">
             <editor
-                 class="org.argeo.slc.client.ui.dist.editors.GenericArtifactEditor"
-              id="org.argeo.slc.client.ui.dist.genericArtifactEditor"
-              name="Artifact 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>
        </command>
        
        <command
-            id="org.argeo.slc.client.ui.dist.repoSyncCommand"
+            id="org.argeo.slc.client.ui.dist.fetch"
             defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
             name="Fetch repository">
             <commandParameter
index d3c3e6828294920a5e588d2585cca8a69d6badd0..34edaaad07fd98869a4a644ec3666e4fdca556f9 100644 (file)
@@ -15,6 +15,9 @@
  */
 package org.argeo.slc.client.ui.dist;
 
+import org.argeo.slc.jcr.SlcNames;
+import org.osgi.framework.Constants;
+
 /** Constants used across the application. */
 public interface DistConstants {
        /*
@@ -25,6 +28,11 @@ public interface DistConstants {
        // this should be directly got in JCR
        public final static String JCR_IDENTIFIER = "jcr:uuid";
 
-       
-       
+       // FIXME: might be defined in SlcNames
+       public final static String SLC_BUNDLE_NAME = SlcNames.SLC_
+                       + Constants.BUNDLE_NAME;
+       public final static String SLC_BUNDLE_LICENCE = SlcNames.SLC_
+                       + "Bundle-License";
+       public final static String SLC_BUNDLE_VENDOR = SlcNames.SLC_
+                       + Constants.BUNDLE_VENDOR;
 }
diff --git a/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/commands/Fetch.java b/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/commands/Fetch.java
new file mode 100644 (file)
index 0000000..819e30d
--- /dev/null
@@ -0,0 +1,74 @@
+package org.argeo.slc.client.ui.dist.commands;
+
+import javax.jcr.Node;
+import javax.jcr.Repository;
+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.utils.CommandHelpers;
+import org.argeo.slc.client.ui.dist.wizards.FetchWizard;
+import org.argeo.slc.repo.RepoSync;
+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.jface.dialogs.Dialog;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/** Wraps a {@link RepoSync} as an Eclipse command. */
+public class Fetch extends AbstractHandler {
+       // private final static Log log = LogFactory.getLog(Fetch.class);
+
+       public final static String ID = DistPlugin.ID + ".fetch";
+       public final static String PARAM_TARGET_REPO = "targetRepoPath";
+       public final static String DEFAULT_LABEL = "Fetch...";
+       public final static String DEFAULT_ICON_PATH = "icons/fetchRepo.png";
+
+       // DEPENDENCY INJECTION
+       private Keyring keyring;
+       private RepositoryFactory repositoryFactory;
+       private Repository nodeRepository;
+
+       public Object execute(ExecutionEvent event) throws ExecutionException {
+               Session currSession = null;
+               try {
+                       // Target Repository
+                       String targetRepoPath = event.getParameter(PARAM_TARGET_REPO);
+                       currSession = nodeRepository.login();
+                       Node targetRepoNode = currSession.getNode(targetRepoPath);
+
+                       FetchWizard wizard = new FetchWizard(keyring, repositoryFactory,
+                                       nodeRepository);
+                       wizard.setTargetRepoNode(targetRepoNode);
+                       WizardDialog dialog = new WizardDialog(
+                                       HandlerUtil.getActiveShell(event), wizard);
+
+                       int result = dialog.open();
+                       if (result == Dialog.OK)
+                               CommandHelpers.callCommand(RefreshDistributionsView.ID);
+                       return null;
+               } catch (RepositoryException e) {
+                       throw new SlcException("Unexpected error while fetching data", e);
+               } finally {
+                       JcrUtils.logoutQuietly(currSession);
+               }
+       }
+
+       // DEPENDENCY INJECTION
+       public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
+               this.repositoryFactory = repositoryFactory;
+       }
+
+       public void setKeyring(Keyring keyring) {
+               this.keyring = keyring;
+       }
+
+       public void setNodeRepository(Repository repository) {
+               this.nodeRepository = repository;
+       }
+}
\ 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/RepoSyncCommand.java b/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/commands/RepoSyncCommand.java
deleted file mode 100644 (file)
index 5bbf4f4..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-package org.argeo.slc.client.ui.dist.commands;
-
-import javax.jcr.Node;
-import javax.jcr.Repository;
-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.utils.CommandHelpers;
-import org.argeo.slc.client.ui.dist.wizards.FetchWizard;
-import org.argeo.slc.repo.RepoSync;
-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.jface.dialogs.Dialog;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/** Wraps a {@link RepoSync} as an Eclipse command. */
-public class RepoSyncCommand extends AbstractHandler {
-       // private final static Log log = LogFactory.getLog(RepoSyncCommand.class);
-
-       public final static String ID = DistPlugin.ID + ".repoSyncCommand";
-       public final static String PARAM_TARGET_REPO = "targetRepoPath";
-       public final static String DEFAULT_LABEL = "Fetch...";
-       public final static String DEFAULT_ICON_PATH = "icons/fetchRepo.png";
-
-       // DEPENDENCY INJECTION
-       private Keyring keyring;
-       private RepositoryFactory repositoryFactory;
-       private Repository nodeRepository;
-
-
-       public Object execute(ExecutionEvent event) throws ExecutionException {
-               Session currSession = null;
-               try {
-                       // Target Repository
-                       String targetRepoPath = event.getParameter(PARAM_TARGET_REPO);
-                       currSession = nodeRepository.login();
-                       Node targetRepoNode = currSession.getNode(targetRepoPath);
-
-                       FetchWizard wizard = new FetchWizard(keyring, repositoryFactory,
-                                       nodeRepository);
-                       wizard.setTargetRepoNode(targetRepoNode);
-                       WizardDialog dialog = new WizardDialog(
-                                       HandlerUtil.getActiveShell(event), wizard);
-                       
-                       int result = dialog.open();
-                       if (result == Dialog.OK)
-                               CommandHelpers.callCommand(RefreshDistributionsView.ID);
-                       return null;
-               } catch (RepositoryException e) {
-                       throw new SlcException("Unexpected error while fetching data", e);
-               } finally {
-                       JcrUtils.logoutQuietly(currSession);
-               }
-       }
-
-       // DEPENDENCY INJECTION
-       public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
-               this.repositoryFactory = repositoryFactory;
-       }
-
-       public void setKeyring(Keyring keyring) {
-               this.keyring = keyring;
-       }
-
-       public void setNodeRepository(Repository repository) {
-               this.nodeRepository = repository;
-       }
-}
\ 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/ArtifactDetailsPage.java b/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/ArtifactDetailsPage.java
deleted file mode 100644 (file)
index f350a72..0000000
+++ /dev/null
@@ -1,369 +0,0 @@
-/*
- * 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 java.util.ArrayList;
-import java.util.List;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.Property;
-import javax.jcr.PropertyIterator;
-import javax.jcr.RepositoryException;
-import javax.jcr.Value;
-import javax.jcr.nodetype.NodeType;
-
-import org.argeo.ArgeoException;
-import org.argeo.slc.client.ui.dist.DistImages;
-import org.argeo.slc.client.ui.dist.utils.DistUiHelpers;
-import org.argeo.slc.client.ui.dist.utils.GenericDoubleClickListener;
-import org.argeo.slc.jcr.SlcNames;
-import org.argeo.slc.jcr.SlcTypes;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerCell;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeColumn;
-import org.eclipse.ui.forms.IManagedForm;
-import org.eclipse.ui.forms.editor.FormEditor;
-import org.eclipse.ui.forms.editor.FormPage;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-import org.eclipse.ui.forms.widgets.ScrolledForm;
-
-/**
- * Generic editor property page. Lists all properties of current node as a
- * complex tree. TODO: enable editing
- */
-
-public class ArtifactDetailsPage extends FormPage implements SlcNames, SlcTypes {
-       // private final static Log log =
-       // LogFactory.getLog(ArtifactDetailsPage.class);
-
-       // Main business Objects
-       private Node currentNode;
-
-       // This page widgets
-       private FormToolkit tk;
-       private TreeViewer complexTree;
-       private Text mavenSnippet;
-
-       public ArtifactDetailsPage(FormEditor editor, String title, Node currentNode) {
-               super(editor, "id", title);
-               this.currentNode = currentNode;
-       }
-
-       protected void createFormContent(IManagedForm managedForm) {
-               tk = managedForm.getToolkit();
-               ScrolledForm form = managedForm.getForm();
-               GridLayout layout = new GridLayout(1, false);
-               layout.marginWidth = 5;
-               form.getBody().setLayout(layout);
-
-               complexTree = createComplexTree(form.getBody());
-               createMavenSnipet(form.getBody());
-       }
-
-       private TreeViewer createComplexTree(Composite parent) {
-               int style = SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION;
-               Tree tree = new Tree(parent, style);
-               GridData gd = new GridData(GridData.FILL_BOTH);
-               gd.grabExcessHorizontalSpace = true;
-               gd.grabExcessVerticalSpace = true;
-               tree.setLayoutData(gd);
-               createColumn(tree, "Attribute", SWT.LEFT, 200);
-               createColumn(tree, "Value", SWT.LEFT, 200);
-               tree.setLinesVisible(true);
-               tree.setHeaderVisible(true);
-
-               TreeViewer result = new TreeViewer(tree);
-               result.setContentProvider(new TreeContentProvider());
-               result.setLabelProvider(new TreeLabelProvider());
-
-               result.setInput(currentNode);
-               result.expandToLevel(2);
-
-               result.addDoubleClickListener(new GenericDoubleClickListener(result));
-               // result.expandAll();
-               return result;
-       }
-
-       private void createMavenSnipet(Composite parent) {
-               mavenSnippet = new Text(parent, SWT.MULTI | SWT.WRAP | SWT.BORDER);
-               GridData gd = new GridData(GridData.FILL_HORIZONTAL);
-               gd.grabExcessHorizontalSpace = true;
-               gd.heightHint = 75;
-               mavenSnippet.setLayoutData(gd);
-               mavenSnippet.setText(generateXmlSnippet());
-       }
-
-       // Helpers
-       private String generateXmlSnippet() {
-               try {
-                       StringBuffer sb = new StringBuffer();
-                       sb.append("<dependency>\n");
-                       sb.append("\t<groupeId>");
-                       sb.append(currentNode.getProperty(SLC_GROUP_ID).getString());
-                       sb.append("</groupeId>\n");
-                       sb.append("\t<artifactId>");
-                       sb.append(currentNode.getProperty(SLC_ARTIFACT_ID).getString());
-                       sb.append("</artifactId>\n");
-                       sb.append("\t<version>");
-                       sb.append(currentNode.getProperty(SLC_ARTIFACT_VERSION).getString());
-                       sb.append("</version>\n");
-                       sb.append("</dependency>");
-                       return sb.toString();
-               } catch (RepositoryException re) {
-                       throw new ArgeoException(
-                                       "unexpected error while generating maven snippet");
-               }
-       }
-
-       private static TreeColumn createColumn(Tree parent, String name, int style,
-                       int width) {
-               TreeColumn result = new TreeColumn(parent, style);
-               result.setText(name);
-               result.setWidth(width);
-               result.setMoveable(true);
-               result.setResizable(true);
-               return result;
-       }
-
-       // View specific object
-       private class ViewSpecificItems {
-               private String key;
-               private Object value;
-               private boolean isFolder;
-               private Node curNode;
-
-               public ViewSpecificItems(String key, Object value, boolean isFolder) {
-                       this.key = key;
-                       this.value = value;
-                       this.isFolder = isFolder;
-               }
-
-               public String getKey() {
-                       return key;
-               }
-
-               public void setNode(Node node) {
-                       this.curNode = node;
-               }
-
-               public Node getNode() {
-                       return curNode;
-               }
-
-               public Object getValue() {
-                       return value;
-               }
-
-               public boolean isFolder() {
-                       return isFolder;
-               }
-
-       }
-
-       // providers
-       private class TreeLabelProvider extends ColumnLabelProvider implements
-                       SlcTypes, SlcNames {
-
-               public void update(ViewerCell cell) {
-                       try {
-
-                               int colIndex = cell.getColumnIndex();
-                               Object element = cell.getElement();
-                               if (element instanceof Property) {
-                                       Property prop = (Property) element;
-                                       if (colIndex == 0)
-                                               cell.setText(DistUiHelpers.getLabelJcrName(prop
-                                                               .getName()));
-                                       else if (colIndex == 1)
-                                               cell.setText(DistUiHelpers.formatValueAsString(prop
-                                                               .getValue()));
-
-                               } else if (element instanceof ViewSpecificItems) {
-                                       if (colIndex == 0)
-                                               cell.setText(((ViewSpecificItems) element).getKey());
-                                       else if (colIndex == 1)
-                                               cell.setText(DistUiHelpers
-                                                               .formatAsString(((ViewSpecificItems) element)
-                                                                               .getValue()));
-
-                               } else if (element instanceof Node) {
-                                       Node node = (Node) element;
-                                       if (colIndex == 0) {
-                                               if (node.isNodeType(NodeType.NT_FILE)) {
-                                                       cell.setImage(DistImages.IMG_FILE);
-                                                       cell.setText(node.getName());
-                                               } else if (node.isNodeType(SLC_IMPORTED_PACKAGE))
-                                                       cell.setText("Import package");
-                                               else if (node.isNodeType(SLC_EXPORTED_PACKAGE))
-                                                       cell.setText("Export package");
-
-                                       } else if (colIndex == 1) {
-                                               if (node.isNodeType(SLC_ARTIFACT)) {
-                                                       StringBuffer sb = new StringBuffer("");
-                                                       if (node.hasProperty(SLC_ARTIFACT_CLASSIFIER)) {
-                                                               sb.append(node.getProperty(
-                                                                               SLC_ARTIFACT_CLASSIFIER).getString());
-                                                               sb.append(" ");
-                                                       }
-                                                       if (node.hasProperty(SLC_ARTIFACT_EXTENSION))
-                                                               sb.append(node.getProperty(
-                                                                               SLC_ARTIFACT_EXTENSION).getString());
-                                                       cell.setText(sb.toString());
-                                               } else if (node.isNodeType(SLC_IMPORTED_PACKAGE)
-                                                               || node.isNodeType(SLC_EXPORTED_PACKAGE))
-                                                       cell.setText(node.getProperty(SLC_NAME).getString());
-                                       }
-                               }
-                       } catch (RepositoryException e) {
-                               throw new ArgeoException(
-                                               "unexpected error while getting artifact information",
-                                               e);
-                       }
-               }
-       }
-
-       private class TreeContentProvider implements ITreeContentProvider {
-               public Object[] getElements(Object parent) {
-                       List<Object> elements = new ArrayList<Object>();
-
-                       try {
-                               Node node = (Node) parent;
-                               elements = new ArrayList<Object>();
-
-                               // Maven coordinates
-                               elements.add(node.getProperty(SLC_GROUP_ID));
-                               elements.add(node.getProperty(SLC_ARTIFACT_ID));
-                               elements.add(node.getProperty(SLC_ARTIFACT_VERSION));
-
-                               // Meta information
-                               // boolean gotSource = false;
-                               // // TODO: implement this check
-                               // elements.add(new ViewSpecificItems("Sources available",
-                               // gotSource));
-
-                               // Jars
-                               NodeIterator ni = node.getNodes();
-                               while (ni.hasNext()) {
-                                       Node child = ni.nextNode();
-                                       if (child.isNodeType(SLC_ARTIFACT)) {
-                                               // we skip sha1 files for the time being.
-                                               elements.add(child);
-                                       }
-                               }
-                       } catch (RepositoryException e) {
-                               throw new ArgeoException(
-                                               "Unexpected exception while listing node properties", e);
-                       }
-                       return elements.toArray();
-               }
-
-               public Object getParent(Object child) {
-                       return null;
-               }
-
-               public Object[] getChildren(Object parent) {
-                       Object[] result = null;
-                       try {
-                               if (parent instanceof Property) {
-                                       Property prop = (Property) parent;
-                                       if (prop.isMultiple()) {
-                                               Value[] values = prop.getValues();
-                                               return values;
-                                       }
-                               } else if (parent instanceof Node) {
-                                       Node node = (Node) parent;
-                                       if (node.hasNodes()) {
-                                               List<Object> elements = new ArrayList<Object>();
-                                               PropertyIterator pi = node.getProperties();
-                                               while (pi.hasNext()) {
-                                                       Property curProp = pi.nextProperty();
-                                                       if (!curProp.getName().startsWith("jcr:")
-                                                                       && !curProp.isMultiple())
-                                                               elements.add(curProp);
-                                               }
-
-                                               NodeIterator ni = node.getNodes();
-                                               while (ni.hasNext()) {
-                                                       Node curNode = ni.nextNode();
-                                                       if (curNode.isNodeType(SLC_IMPORTED_PACKAGE)
-                                                                       || curNode.isNodeType(SLC_EXPORTED_PACKAGE)) {
-                                                               ViewSpecificItems vsi = new ViewSpecificItems(
-                                                                               "Bundle dependencies", "", true);
-                                                               vsi.setNode(node);
-                                                               elements.add(vsi);
-                                                               break;
-                                                       }
-                                               }
-                                               return elements.toArray();
-                                       }
-                               } else if (parent instanceof ViewSpecificItems
-                                               && ((ViewSpecificItems) parent).isFolder()) {
-                                       NodeIterator ni = ((ViewSpecificItems) parent).getNode()
-                                                       .getNodes();
-                                       List<Node> elements = new ArrayList<Node>();
-                                       while (ni.hasNext()) {
-                                               Node curNode = ni.nextNode();
-                                               if (curNode.isNodeType(SLC_IMPORTED_PACKAGE)
-                                                               || curNode.isNodeType(SLC_EXPORTED_PACKAGE)) {
-                                                       elements.add(curNode);
-                                               }
-                                       }
-                                       return elements.toArray();
-                               }
-                       } catch (RepositoryException e) {
-                               throw new ArgeoException(
-                                               "Unexpected error getting multiple values property.", e);
-                       }
-                       return result;
-               }
-
-               public boolean hasChildren(Object parent) {
-                       try {
-                               if (parent instanceof Property
-                                               && ((Property) parent).isMultiple()) {
-                                       return true;
-                               } else if (parent instanceof Node && ((Node) parent).hasNodes()
-                                               && ((Node) parent).isNodeType(SLC_BUNDLE_ARTIFACT)) {
-                                       return true;
-                               } else if (parent instanceof ViewSpecificItems
-                                               && ((ViewSpecificItems) parent).isFolder()) {
-                                       return true;
-                               }
-                       } catch (RepositoryException e) {
-                               throw new ArgeoException(
-                                               "Unexpected exception while checking if property is multiple",
-                                               e);
-                       }
-                       return false;
-               }
-
-               public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
-               }
-
-               public void dispose() {
-               }
-       }
-}
index 843a5fcb0277cd42bf37e7be6077b89e53ef5ad5..f8979dea8a4b10276e4dda971766ac2861f66460 100644 (file)
@@ -137,7 +137,7 @@ public class ArtifactsBrowserPage extends FormPage implements DistConstants,
                viewer.setContentProvider(new ArtifactsTreeContentProvider());
                viewer.setLabelProvider(new ArtifactLabelProvider());
                viewer.addSelectionChangedListener(new ArtifactTreeSelectionListener());
-               viewer.addDoubleClickListener(new GenericDoubleClickListener(viewer));
+               viewer.addDoubleClickListener(new GenericDoubleClickListener());
                viewer.setInput(rootNode);
 
                return viewer;
diff --git a/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/BundleDetailsPage.java b/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/BundleDetailsPage.java
new file mode 100644 (file)
index 0000000..b0f2fa6
--- /dev/null
@@ -0,0 +1,468 @@
+/*
+ * 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 java.net.URL;
+import java.util.List;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.RepositoryException;
+import javax.jcr.query.QueryManager;
+import javax.jcr.query.QueryResult;
+import javax.jcr.query.qom.Constraint;
+import javax.jcr.query.qom.Ordering;
+import javax.jcr.query.qom.QueryObjectModel;
+import javax.jcr.query.qom.QueryObjectModelFactory;
+import javax.jcr.query.qom.Selector;
+
+import org.argeo.ArgeoException;
+import org.argeo.eclipse.ui.ErrorFeedback;
+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.utils.AbstractHyperlinkListener;
+import org.argeo.slc.jcr.SlcNames;
+import org.argeo.slc.jcr.SlcTypes;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.TableLayout;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.TreeViewerColumn;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.browser.IWebBrowser;
+import org.eclipse.ui.browser.IWorkbenchBrowserSupport;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.editor.FormEditor;
+import org.eclipse.ui.forms.editor.FormPage;
+import org.eclipse.ui.forms.events.HyperlinkEvent;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.Hyperlink;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+import org.eclipse.ui.forms.widgets.Section;
+
+/**
+ * Presents main information of a given OSGI bundle
+ */
+
+public class BundleDetailsPage extends FormPage implements SlcNames, SlcTypes {
+       // private final static Log log =
+       // LogFactory.getLog(ArtifactDetailsPage.class);
+
+       // Main business Objects
+       private Node currBundle;
+
+       // This page widgets
+       private Text mavenSnippet;
+       private FormToolkit toolkit;
+
+       public BundleDetailsPage(FormEditor editor, String title, Node currentNode) {
+               super(editor, "id", title);
+               this.currBundle = currentNode;
+       }
+
+       protected void createFormContent(IManagedForm managedForm) {
+               ScrolledForm form = managedForm.getForm();
+               toolkit = managedForm.getToolkit();
+               try {
+                       form.setText(currBundle.hasProperty(DistConstants.SLC_BUNDLE_NAME) ? currBundle
+                                       .getProperty(DistConstants.SLC_BUNDLE_NAME).getString()
+                                       : "");
+                       Composite body = form.getBody();
+                       GridLayout layout = new GridLayout(1, false);
+                       layout.marginWidth = 5;
+                       layout.verticalSpacing = 15;
+
+                       body.setLayout(layout);
+                       createdetailsPart(body);
+
+                       createExportPackageSection(body);
+                       createImportPackageSection(body);
+                       createReqBundleSection(body);
+                       createMavenSnipet(body);
+
+               } catch (RepositoryException e) {
+                       throw new SlcException("unexpected error "
+                                       + "while creating bundle details page");
+               }
+       }
+
+       /** Add useful info for the current bundle */
+       private void createdetailsPart(Composite parent) throws RepositoryException {
+               Composite details = toolkit.createComposite(parent);
+               GridLayout layout = new GridLayout(2, false);
+               layout.horizontalSpacing = 20;
+               details.setLayout(layout);
+
+               createField(details, "Symbolic name", SlcNames.SLC_SYMBOLIC_NAME);
+               createField(details, "Version", SlcNames.SLC_BUNDLE_VERSION);
+               createField(details, "Group Id", SlcNames.SLC_GROUP_ID);
+               createHyperlink(details, "Licence", DistConstants.SLC_BUNDLE_LICENCE);
+               createField(details, "Vendor", DistConstants.SLC_BUNDLE_VENDOR);
+
+       }
+
+       /** Import Package Section */
+       private void createExportPackageSection(Composite parent)
+                       throws RepositoryException {
+
+               // Define the TableViewer
+               Section headerSection = addSection(parent, "Export packages");
+               // TreeViewer viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL
+               // | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
+               TreeViewer viewer = new TreeViewer(headerSection, SWT.MULTI
+                               | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
+
+               final Tree tree = viewer.getTree();
+               tree.setHeaderVisible(false);
+               tree.setLinesVisible(true);
+               GridData gd = new GridData(SWT.LEFT, SWT.TOP, true, true);
+               gd.heightHint = 300;
+               tree.setLayoutData(gd);
+
+               TreeViewerColumn col = new TreeViewerColumn(viewer, SWT.FILL);
+               col.getColumn().setWidth(200);
+
+               col.setLabelProvider(new ColumnLabelProvider() {
+                       @Override
+                       public String getText(Object element) {
+                               return JcrUtils.get((Node) element, SlcNames.SLC_NAME);
+                       }
+
+                       @Override
+                       public Image getImage(Object element) {
+                               return null;
+                       }
+               });
+
+               viewer.setContentProvider(new ITreeContentProvider() {
+
+                       public void dispose() {
+                       }
+
+                       public void inputChanged(Viewer viewer, Object oldInput,
+                                       Object newInput) {
+                       }
+
+                       public Object[] getElements(Object inputElement) {
+                               try {
+                                       List<Node> nodes = JcrUtils.nodeIteratorToList(listNodes(
+                                                       currBundle, SlcTypes.SLC_EXPORTED_PACKAGE,
+                                                       SlcNames.SLC_NAME));
+                                       return nodes.toArray();
+                               } catch (RepositoryException e) {
+                                       throw new SlcException("Cannot list children Nodes", e);
+                               }
+                       }
+
+                       public Object[] getChildren(Object parentElement) {
+                               // Only 2 levels for the time being
+                               try {
+                                       Node pNode = (Node) parentElement;
+                                       if (pNode.isNodeType(SlcTypes.SLC_EXPORTED_PACKAGE)) {
+                                               List<Node> nodes = JcrUtils
+                                                               .nodeIteratorToList(listNodes(pNode,
+                                                                               SlcTypes.SLC_JAVA_PACKAGE,
+                                                                               SlcNames.SLC_NAME));
+                                               return nodes.toArray();
+                                       } else
+                                               return null;
+                               } catch (RepositoryException e) {
+                                       throw new SlcException("Cannot list children Nodes", e);
+                               }
+                       }
+
+                       public Object getParent(Object element) {
+                               // useless
+                               return null;
+                       }
+
+                       public boolean hasChildren(Object element) {
+                               try {
+                                       Node pNode = (Node) element;
+                                       if (pNode.isNodeType(SlcTypes.SLC_EXPORTED_PACKAGE)) {
+                                               // might return true even if there is no "valid" child
+                                               return pNode.hasNodes();
+                                       } else
+                                               return false;
+                               } catch (RepositoryException e) {
+                                       throw new SlcException("Cannot check children Nodes", e);
+                               }
+                       }
+               });
+
+               headerSection.setClient(tree);
+               viewer.setInput("Initialize");
+       }
+
+       /** Import Package Section */
+       private void createImportPackageSection(Composite parent)
+                       throws RepositoryException {
+
+               // Define the TableViewer
+               Section headerSection = addSection(parent, "Import packages");
+               TableViewer viewer = new TableViewer(headerSection, SWT.MULTI
+                               | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
+
+               // Name
+               TableViewerColumn col = new TableViewerColumn(viewer, SWT.NONE);
+               col.getColumn().setWidth(300);
+               col.getColumn().setText("Name");
+               col.setLabelProvider(new ColumnLabelProvider() {
+                       @Override
+                       public String getText(Object element) {
+                               return JcrUtils.get((Node) element, SLC_NAME);
+                       }
+               });
+
+               // Version
+               col = new TableViewerColumn(viewer, SWT.NONE);
+               col.getColumn().setWidth(100);
+               col.getColumn().setText("Version");
+               col.setLabelProvider(new ColumnLabelProvider() {
+                       @Override
+                       public String getText(Object element) {
+                               return JcrUtils.get((Node) element, SLC_VERSION);
+                       }
+               });
+
+               // Optional
+               col = new TableViewerColumn(viewer, SWT.NONE);
+               col.getColumn().setWidth(100);
+               col.getColumn().setText("Optional");
+               col.setLabelProvider(new ColumnLabelProvider() {
+                       @Override
+                       public String getText(Object element) {
+                               return JcrUtils.get((Node) element, SLC_OPTIONAL);
+                       }
+               });
+
+               final Table table = viewer.getTable();
+               table.setHeaderVisible(true);
+               table.setLinesVisible(true);
+               GridData gd = new GridData(SWT.LEFT, SWT.TOP, true, true);
+               gd.heightHint = 300;
+               table.setLayoutData(gd);
+
+               viewer.setContentProvider(new TableContentProvider(
+                               SLC_IMPORTED_PACKAGE, SLC_NAME));
+               headerSection.setClient(viewer.getTable());
+
+               viewer.setInput("Initialize");
+       }
+
+       /** Required Bundle Section */
+       private void createReqBundleSection(Composite parent)
+                       throws RepositoryException {
+
+               // Define the TableViewer
+               Section headerSection = addSection(parent, "Required bundles");
+               TableViewer viewer = new TableViewer(headerSection, SWT.MULTI
+                               | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
+
+               // Name
+               TableViewerColumn col = new TableViewerColumn(viewer, SWT.NONE);
+               col.getColumn().setWidth(300);
+               col.getColumn().setText("Name");
+               col.setLabelProvider(new ColumnLabelProvider() {
+                       @Override
+                       public String getText(Object element) {
+                               return JcrUtils.get((Node) element, SLC_SYMBOLIC_NAME);
+                       }
+               });
+
+               // Version
+               col = new TableViewerColumn(viewer, SWT.NONE);
+               col.getColumn().setWidth(100);
+               col.getColumn().setText("Version");
+               col.setLabelProvider(new ColumnLabelProvider() {
+                       @Override
+                       public String getText(Object element) {
+                               return JcrUtils.get((Node) element, SLC_BUNDLE_VERSION);
+                       }
+               });
+
+               // Version
+               col = new TableViewerColumn(viewer, SWT.NONE);
+               col.getColumn().setWidth(100);
+               col.getColumn().setText("Optional");
+               col.setLabelProvider(new ColumnLabelProvider() {
+                       @Override
+                       public String getText(Object element) {
+                               return JcrUtils.get((Node) element, SLC_OPTIONAL);
+                       }
+               });
+
+               final Table table = viewer.getTable();
+               table.setHeaderVisible(true);
+               table.setLinesVisible(true);
+
+               viewer.setContentProvider(new TableContentProvider(SLC_REQUIRED_BUNDLE,
+                               SLC_SYMBOLIC_NAME));
+               headerSection.setClient(viewer.getTable());
+
+               viewer.setInput("Initialize");
+       }
+
+       /** Build repository request */
+       private NodeIterator listNodes(Node parent, String nodeType, String orderBy)
+                       throws RepositoryException {
+               QueryManager queryManager = currBundle.getSession().getWorkspace()
+                               .getQueryManager();
+               QueryObjectModelFactory factory = queryManager.getQOMFactory();
+
+               final String nodeSelector = "nodes";
+               Selector source = factory.selector(nodeType, nodeSelector);
+
+               Constraint childOf = factory.childNode(nodeSelector, parent.getPath());
+
+               Ordering order = factory.ascending(factory.propertyValue(nodeSelector,
+                               orderBy));
+               Ordering[] orderings = { order };
+
+               QueryObjectModel query = factory.createQuery(source, childOf,
+                               orderings, null);
+
+               QueryResult result = query.execute();
+               return result.getNodes();
+
+       }
+
+       private class TableContentProvider implements IStructuredContentProvider {
+               private String nodeType;
+               private String orderBy;
+
+               TableContentProvider(String nodeType, String orderBy) {
+                       this.nodeType = nodeType;
+                       this.orderBy = orderBy;
+               }
+
+               public void dispose() {
+               }
+
+               public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+               }
+
+               public Object[] getElements(Object arg0) {
+                       try {
+                               List<Node> nodes = JcrUtils.nodeIteratorToList(listNodes(
+                                               currBundle, nodeType, orderBy));
+                               return nodes.toArray();
+                       } catch (RepositoryException e) {
+                               ErrorFeedback.show("Cannot list children Nodes", e);
+                               return null;
+                       }
+               }
+       }
+
+       /* HELPERS */
+       private void createField(Composite parent, String label, String jcrPropName)
+                       throws RepositoryException {
+               toolkit.createLabel(parent, label, SWT.NONE);
+               Text txt = toolkit.createText(parent, "", SWT.SINGLE);
+               txt.setText(currBundle.hasProperty(jcrPropName) ? currBundle
+                               .getProperty(jcrPropName).getString() : "");
+               txt.setEditable(false);
+               GridData gd = new GridData(SWT.FILL, SWT.TOP, true, false);
+               txt.setLayoutData(gd);
+       }
+
+       private Section addSection(Composite parent, String title) {
+               Section section = toolkit.createSection(parent, Section.TWISTIE);
+               section.setText(title);
+               section.setExpanded(false);
+               GridData gd = new GridData(SWT.FILL, SWT.FILL, false, false);
+               section.setLayoutData(gd);
+               Composite body = new Composite(section, SWT.FILL);
+               section.setClient(body);
+               // Layout
+               body.setLayout(new TableLayout());
+               return section;
+       }
+
+       private void createHyperlink(Composite parent, String label,
+                       String jcrPropName) throws RepositoryException {
+               toolkit.createLabel(parent, label, SWT.NONE);
+               if (currBundle.hasProperty(jcrPropName)) {
+                       final Hyperlink link = toolkit.createHyperlink(parent, currBundle
+                                       .getProperty(jcrPropName).getString(), SWT.NONE);
+                       link.addHyperlinkListener(new AbstractHyperlinkListener() {
+                               @Override
+                               public void linkActivated(HyperlinkEvent e) {
+                                       try {
+                                               IWorkbenchBrowserSupport browserSupport = PlatformUI
+                                                               .getWorkbench().getBrowserSupport();
+                                               IWebBrowser browser = browserSupport
+                                                               .createBrowser(
+                                                                               IWorkbenchBrowserSupport.LOCATION_BAR
+                                                                                               | IWorkbenchBrowserSupport.NAVIGATION_BAR,
+                                                                               "SLC Distribution browser",
+                                                                               "SLC Distribution browser",
+                                                                               "A tool tip");
+                                               browser.openURL(new URL(link.getText()));
+                                       } catch (Exception ex) {
+                                               throw new SlcException("error opening browser", ex); //$NON-NLS-1$
+                                       }
+                               }
+                       });
+               } else
+                       toolkit.createLabel(parent, "", SWT.NONE);
+       }
+
+       /** Creates a text area with corresponding maven snippet */
+       private void createMavenSnipet(Composite parent) {
+               mavenSnippet = new Text(parent, SWT.MULTI | SWT.WRAP | SWT.BORDER);
+               GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+               gd.grabExcessHorizontalSpace = true;
+               gd.heightHint = 100;
+               mavenSnippet.setLayoutData(gd);
+               mavenSnippet.setText(generateXmlSnippet());
+       }
+
+       // Helpers
+       private String generateXmlSnippet() {
+               try {
+                       StringBuffer sb = new StringBuffer();
+                       sb.append("<dependency>\n");
+                       sb.append("\t<groupeId>");
+                       sb.append(currBundle.getProperty(SLC_GROUP_ID).getString());
+                       sb.append("</groupeId>\n");
+                       sb.append("\t<artifactId>");
+                       sb.append(currBundle.getProperty(SLC_ARTIFACT_ID).getString());
+                       sb.append("</artifactId>\n");
+                       sb.append("\t<version>");
+                       sb.append(currBundle.getProperty(SLC_ARTIFACT_VERSION).getString());
+                       sb.append("</version>\n");
+                       sb.append("</dependency>");
+                       return sb.toString();
+               } catch (RepositoryException re) {
+                       throw new ArgeoException(
+                                       "unexpected error while generating maven snippet");
+               }
+       }
+}
\ 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/BundleRawPage.java b/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/BundleRawPage.java
new file mode 100644 (file)
index 0000000..329adc8
--- /dev/null
@@ -0,0 +1,337 @@
+/*
+ * 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 java.util.ArrayList;
+import java.util.List;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.Property;
+import javax.jcr.PropertyIterator;
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+import javax.jcr.nodetype.NodeType;
+
+import org.argeo.ArgeoException;
+import org.argeo.slc.client.ui.dist.DistImages;
+import org.argeo.slc.client.ui.dist.utils.DistUiHelpers;
+import org.argeo.slc.client.ui.dist.utils.GenericDoubleClickListener;
+import org.argeo.slc.jcr.SlcNames;
+import org.argeo.slc.jcr.SlcTypes;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerCell;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeColumn;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.editor.FormEditor;
+import org.eclipse.ui.forms.editor.FormPage;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+
+/**
+ * Lists all properties of current bundle as a tree
+ */
+
+public class BundleRawPage extends FormPage implements SlcNames, SlcTypes {
+       // private final static Log log =
+       // LogFactory.getLog(ArtifactDetailsPage.class);
+
+       // Main business Objects
+       private Node currBundle;
+
+       // This page widgets
+       private TreeViewer complexTree;
+       private Text mavenSnippet;
+
+       public BundleRawPage(FormEditor editor, String title, Node currentNode) {
+               super(editor, "id", title);
+               this.currBundle = currentNode;
+       }
+
+       protected void createFormContent(IManagedForm managedForm) {
+               ScrolledForm form = managedForm.getForm();
+               GridLayout layout = new GridLayout(1, false);
+               layout.marginWidth = 5;
+               form.getBody().setLayout(layout);
+
+               createViewer(form.getBody());
+       }
+
+       private void createViewer(Composite parent) {
+               
+               // Create the viewer
+               int style = SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION;
+               Tree tree = new Tree(parent, style);
+               GridData gd = new GridData(GridData.FILL_BOTH);
+               gd.grabExcessHorizontalSpace = true;
+               gd.grabExcessVerticalSpace = true;
+               tree.setLayoutData(gd);
+               createColumn(tree, "Attribute", SWT.LEFT, 200);
+               createColumn(tree, "Value", SWT.LEFT, 200);
+               tree.setLinesVisible(true);
+               tree.setHeaderVisible(true);
+
+               // Configure
+               complexTree.addDoubleClickListener(new GenericDoubleClickListener());
+               complexTree = new TreeViewer(tree);
+               complexTree.setContentProvider(new TreeContentProvider());
+               complexTree.setLabelProvider(new TreeLabelProvider());
+
+               // Initialize
+               complexTree.setInput(currBundle);
+               // result.expandAll();
+               complexTree.expandToLevel(2);
+
+       }
+
+       
+       private static TreeColumn createColumn(Tree parent, String name, int style,
+                       int width) {
+               TreeColumn result = new TreeColumn(parent, style);
+               result.setText(name);
+               result.setWidth(width);
+               result.setMoveable(true);
+               result.setResizable(true);
+               return result;
+       }
+
+       // View specific object
+       private class ViewSpecificItems {
+               private String key;
+               private Object value;
+               private boolean isFolder;
+               private Node curNode;
+
+               public ViewSpecificItems(String key, Object value, boolean isFolder) {
+                       this.key = key;
+                       this.value = value;
+                       this.isFolder = isFolder;
+               }
+
+               public String getKey() {
+                       return key;
+               }
+
+               public void setNode(Node node) {
+                       this.curNode = node;
+               }
+
+               public Node getNode() {
+                       return curNode;
+               }
+
+               public Object getValue() {
+                       return value;
+               }
+
+               public boolean isFolder() {
+                       return isFolder;
+               }
+
+       }
+
+       // providers
+       private class TreeLabelProvider extends ColumnLabelProvider implements
+                       SlcTypes, SlcNames {
+
+               public void update(ViewerCell cell) {
+                       try {
+
+                               int colIndex = cell.getColumnIndex();
+                               Object element = cell.getElement();
+                               if (element instanceof Property) {
+                                       Property prop = (Property) element;
+                                       if (colIndex == 0)
+                                               cell.setText(DistUiHelpers.getLabelJcrName(prop
+                                                               .getName()));
+                                       else if (colIndex == 1)
+                                               cell.setText(DistUiHelpers.formatValueAsString(prop
+                                                               .getValue()));
+
+                               } else if (element instanceof ViewSpecificItems) {
+                                       if (colIndex == 0)
+                                               cell.setText(((ViewSpecificItems) element).getKey());
+                                       else if (colIndex == 1)
+                                               cell.setText(DistUiHelpers
+                                                               .formatAsString(((ViewSpecificItems) element)
+                                                                               .getValue()));
+
+                               } else if (element instanceof Node) {
+                                       Node node = (Node) element;
+                                       if (colIndex == 0) {
+                                               if (node.isNodeType(NodeType.NT_FILE)) {
+                                                       cell.setImage(DistImages.IMG_FILE);
+                                                       cell.setText(node.getName());
+                                               } else if (node.isNodeType(SLC_IMPORTED_PACKAGE))
+                                                       cell.setText("Import package");
+                                               else if (node.isNodeType(SLC_EXPORTED_PACKAGE))
+                                                       cell.setText("Export package");
+
+                                       } else if (colIndex == 1) {
+                                               if (node.isNodeType(SLC_ARTIFACT)) {
+                                                       StringBuffer sb = new StringBuffer("");
+                                                       if (node.hasProperty(SLC_ARTIFACT_CLASSIFIER)) {
+                                                               sb.append(node.getProperty(
+                                                                               SLC_ARTIFACT_CLASSIFIER).getString());
+                                                               sb.append(" ");
+                                                       }
+                                                       if (node.hasProperty(SLC_ARTIFACT_EXTENSION))
+                                                               sb.append(node.getProperty(
+                                                                               SLC_ARTIFACT_EXTENSION).getString());
+                                                       cell.setText(sb.toString());
+                                               } else if (node.isNodeType(SLC_IMPORTED_PACKAGE)
+                                                               || node.isNodeType(SLC_EXPORTED_PACKAGE))
+                                                       cell.setText(node.getProperty(SLC_NAME).getString());
+                                       }
+                               }
+                       } catch (RepositoryException e) {
+                               throw new ArgeoException(
+                                               "unexpected error while getting artifact information",
+                                               e);
+                       }
+               }
+       }
+
+       private class TreeContentProvider implements ITreeContentProvider {
+               public Object[] getElements(Object parent) {
+                       List<Object> elements = new ArrayList<Object>();
+
+                       try {
+                               Node node = (Node) parent;
+                               elements = new ArrayList<Object>();
+
+                               // Maven coordinates
+                               elements.add(node.getProperty(SLC_GROUP_ID));
+                               elements.add(node.getProperty(SLC_ARTIFACT_ID));
+                               elements.add(node.getProperty(SLC_ARTIFACT_VERSION));
+
+                               // Meta information
+                               // boolean gotSource = false;
+                               // // TODO: implement this check
+                               // elements.add(new ViewSpecificItems("Sources available",
+                               // gotSource));
+
+                               // Jars
+                               NodeIterator ni = node.getNodes();
+                               while (ni.hasNext()) {
+                                       Node child = ni.nextNode();
+                                       if (child.isNodeType(SLC_ARTIFACT)) {
+                                               // we skip sha1 files for the time being.
+                                               elements.add(child);
+                                       }
+                               }
+                       } catch (RepositoryException e) {
+                               throw new ArgeoException(
+                                               "Unexpected exception while listing node properties", e);
+                       }
+                       return elements.toArray();
+               }
+
+               public Object getParent(Object child) {
+                       return null;
+               }
+
+               public Object[] getChildren(Object parent) {
+                       Object[] result = null;
+                       try {
+                               if (parent instanceof Property) {
+                                       Property prop = (Property) parent;
+                                       if (prop.isMultiple()) {
+                                               Value[] values = prop.getValues();
+                                               return values;
+                                       }
+                               } else if (parent instanceof Node) {
+                                       Node node = (Node) parent;
+                                       if (node.hasNodes()) {
+                                               List<Object> elements = new ArrayList<Object>();
+                                               PropertyIterator pi = node.getProperties();
+                                               while (pi.hasNext()) {
+                                                       Property curProp = pi.nextProperty();
+                                                       if (!curProp.getName().startsWith("jcr:")
+                                                                       && !curProp.isMultiple())
+                                                               elements.add(curProp);
+                                               }
+
+                                               NodeIterator ni = node.getNodes();
+                                               while (ni.hasNext()) {
+                                                       Node curNode = ni.nextNode();
+                                                       if (curNode.isNodeType(SLC_IMPORTED_PACKAGE)
+                                                                       || curNode.isNodeType(SLC_EXPORTED_PACKAGE)) {
+                                                               ViewSpecificItems vsi = new ViewSpecificItems(
+                                                                               "Bundle dependencies", "", true);
+                                                               vsi.setNode(node);
+                                                               elements.add(vsi);
+                                                               break;
+                                                       }
+                                               }
+                                               return elements.toArray();
+                                       }
+                               } else if (parent instanceof ViewSpecificItems
+                                               && ((ViewSpecificItems) parent).isFolder()) {
+                                       NodeIterator ni = ((ViewSpecificItems) parent).getNode()
+                                                       .getNodes();
+                                       List<Node> elements = new ArrayList<Node>();
+                                       while (ni.hasNext()) {
+                                               Node curNode = ni.nextNode();
+                                               if (curNode.isNodeType(SLC_IMPORTED_PACKAGE)
+                                                               || curNode.isNodeType(SLC_EXPORTED_PACKAGE)) {
+                                                       elements.add(curNode);
+                                               }
+                                       }
+                                       return elements.toArray();
+                               }
+                       } catch (RepositoryException e) {
+                               throw new ArgeoException(
+                                               "Unexpected error getting multiple values property.", e);
+                       }
+                       return result;
+               }
+
+               public boolean hasChildren(Object parent) {
+                       try {
+                               if (parent instanceof Property
+                                               && ((Property) parent).isMultiple()) {
+                                       return true;
+                               } else if (parent instanceof Node && ((Node) parent).hasNodes()
+                                               && ((Node) parent).isNodeType(SLC_BUNDLE_ARTIFACT)) {
+                                       return true;
+                               } else if (parent instanceof ViewSpecificItems
+                                               && ((ViewSpecificItems) parent).isFolder()) {
+                                       return true;
+                               }
+                       } catch (RepositoryException e) {
+                               throw new ArgeoException(
+                                               "Unexpected exception while checking if property is multiple",
+                                               e);
+                       }
+                       return false;
+               }
+
+               public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+               }
+
+               public void dispose() {
+               }
+       }
+}
index ba3796786164ed605e3fbd613dd61022b325d8a5..bdbaf6831559b4117118f2205bee90e1fa3302c2 100644 (file)
@@ -15,8 +15,6 @@
  */
 package org.argeo.slc.client.ui.dist.editors;
 
-import javax.jcr.Credentials;
-import javax.jcr.GuestCredentials;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 
@@ -58,8 +56,8 @@ public class DistributionEditor extends FormEditor implements SlcNames {
        @Override
        protected void addPages() {
                try {
-                       addPage(new ArtifactsBrowserPage(this, "Browser", session));
                        addPage(new DistributionOverviewPage(this, "Overview", session));
+                       addPage(new ArtifactsBrowserPage(this, "Browser", session));
                } catch (PartInitException e) {
                        throw new ArgeoException("Cannot add distribution editor pages", e);
                }
index dd0a8be05d38778fecfadbbcbead5b3d57cdcc13..3663827e3113669198e49f703596ae53362c0a1e 100644 (file)
@@ -109,5 +109,4 @@ public class DistributionEditorInput implements IEditorInput, SlcNames {
        public Credentials getCredentials() {
                return credentials;
        }
-
-}
+}
\ No newline at end of file
index c2af792367150ab510c8ddd1ee0fa65fe81635e0..4468cc9194f8e2cbbedee13f9818a44e8ce38a7c 100644 (file)
@@ -23,7 +23,6 @@ import javax.jcr.NodeIterator;
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
-import javax.jcr.query.Query;
 import javax.jcr.query.QueryManager;
 import javax.jcr.query.QueryResult;
 import javax.jcr.query.qom.Constraint;
@@ -34,10 +33,11 @@ import javax.jcr.query.qom.QueryObjectModelFactory;
 import javax.jcr.query.qom.Selector;
 import javax.jcr.query.qom.StaticOperand;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.argeo.ArgeoException;
+import org.argeo.eclipse.ui.ErrorFeedback;
 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.DeleteArtifacts;
 import org.argeo.slc.client.ui.dist.utils.CommandHelpers;
@@ -48,7 +48,10 @@ import org.eclipse.jface.action.IMenuListener;
 import org.eclipse.jface.action.IMenuManager;
 import org.eclipse.jface.action.MenuManager;
 import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
 import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.viewers.TableViewer;
 import org.eclipse.jface.viewers.TableViewerColumn;
 import org.eclipse.jface.viewers.Viewer;
@@ -59,26 +62,28 @@ 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.GridData;
 import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Menu;
 import org.eclipse.swt.widgets.Table;
 import org.eclipse.swt.widgets.Text;
 import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
 import org.eclipse.ui.forms.IManagedForm;
 import org.eclipse.ui.forms.editor.FormEditor;
 import org.eclipse.ui.forms.editor.FormPage;
 import org.eclipse.ui.forms.widgets.FormToolkit;
 import org.eclipse.ui.forms.widgets.ScrolledForm;
-import org.eclipse.ui.forms.widgets.Section;
-import org.osgi.framework.Constants;
 
 /** Table giving an overview of an OSGi distribution with corresponding filters */
 public class DistributionOverviewPage extends FormPage implements SlcNames {
        final static String PAGE_ID = "distributionOverviewPage";
-       final private static Log log = LogFactory
-                       .getLog(DistributionOverviewPage.class);
+       // final private static Log log = LogFactory
+       // .getLog(DistributionOverviewPage.class);
 
        // Business Objects
        private Session session;
@@ -89,7 +94,8 @@ public class DistributionOverviewPage extends FormPage implements SlcNames {
        private Text artifactTxt;
        private FormToolkit tk;
        private Composite header;
-       private Section headerSection;
+
+       // private Section headerSection;
 
        public DistributionOverviewPage(FormEditor formEditor, String title,
                        Session session) {
@@ -112,6 +118,9 @@ public class DistributionOverviewPage extends FormPage implements SlcNames {
                // Add the table
                createTableViewer(body);
 
+               viewer.setInput(session);
+               resetFilter();
+
                // Add a listener to enable custom resize process
                form.addControlListener(new ControlListener() {
                        public void controlResized(ControlEvent e) {
@@ -133,6 +142,66 @@ public class DistributionOverviewPage extends FormPage implements SlcNames {
 
        }
 
+       /** Build repository request */
+       private NodeIterator listBundleArtifacts(Session session)
+                       throws RepositoryException {
+               QueryManager queryManager = session.getWorkspace().getQueryManager();
+               QueryObjectModelFactory factory = queryManager.getQOMFactory();
+
+               final String bundleArtifactsSelector = "bundleArtifacts";
+               Selector source = factory.selector(SlcTypes.SLC_BUNDLE_ARTIFACT,
+                               bundleArtifactsSelector);
+
+               // Create a dynamic operand for each property on which we want to filter
+               DynamicOperand symbNameDO = factory.propertyValue(
+                               source.getSelectorName(), SlcNames.SLC_SYMBOLIC_NAME);
+               DynamicOperand versionDO = factory.propertyValue(
+                               source.getSelectorName(), SlcNames.SLC_BUNDLE_VERSION);
+               DynamicOperand nameDO = factory.propertyValue(source.getSelectorName(),
+                               DistConstants.SLC_BUNDLE_NAME);
+
+               // Default Constraint: no source artifacts
+               Constraint defaultC = factory.not(factory.comparison(
+                               symbNameDO,
+                               QueryObjectModelFactory.JCR_OPERATOR_LIKE,
+                               factory.literal(session.getValueFactory().createValue(
+                                               "%.source"))));
+
+               // Build constraints based the textArea content
+               String artifactTxtVal = artifactTxt.getText();
+               if (!"".equals(artifactTxtVal.trim())) {
+                       // Parse the String
+                       String[] strs = artifactTxtVal.trim().split(" ");
+                       for (String token : strs) {
+                               token = token.replace('*', '%');
+                               StaticOperand so = factory.literal(session.getValueFactory()
+                                               .createValue("%" + token + "%"));
+
+                               Constraint currC = factory.comparison(symbNameDO,
+                                               QueryObjectModelFactory.JCR_OPERATOR_LIKE, so);
+                               currC = factory.or(currC, factory.comparison(versionDO,
+                                               QueryObjectModelFactory.JCR_OPERATOR_LIKE, so));
+                               currC = factory.or(currC, factory.comparison(nameDO,
+                                               QueryObjectModelFactory.JCR_OPERATOR_LIKE, so));
+
+                               defaultC = factory.and(defaultC, currC);
+                       }
+               }
+
+               Ordering order = factory.descending(factory.propertyValue(
+                               bundleArtifactsSelector, SlcNames.SLC_BUNDLE_VERSION));
+               Ordering order2 = factory.ascending(factory.propertyValue(
+                               bundleArtifactsSelector, SlcNames.SLC_SYMBOLIC_NAME));
+               Ordering[] orderings = { order, order2 };
+
+               QueryObjectModel query = factory.createQuery(source, defaultC,
+                               orderings, null);
+
+               QueryResult result = query.execute();
+               return result.getNodes();
+
+       }
+
        private void createFilterPart(Composite parent) {
                header = tk.createComposite(parent);
                GridLayout layout = new GridLayout(2, false);
@@ -140,8 +209,15 @@ public class DistributionOverviewPage extends FormPage implements SlcNames {
                GridData gd = new GridData(SWT.FILL, SWT.FILL, false, false);
                header.setLayoutData(gd);
 
-               // Artifact Name
-               tk.createLabel(header, "Artifact name: ", SWT.NONE);
+               // TODO display real repository information
+               // Title: some meta information
+               Label lbl = tk.createLabel(header, "Current repository: ", SWT.NONE);
+
+               gd = new GridData(SWT.FILL, SWT.FILL, false, false);
+               gd.horizontalSpan = 2;
+               lbl.setLayoutData(gd);
+
+               // Text Area to filter
                artifactTxt = tk.createText(header, "", SWT.BORDER | SWT.SINGLE);
                gd = new GridData(SWT.FILL, SWT.FILL, false, false);
                gd.grabExcessHorizontalSpace = true;
@@ -153,33 +229,24 @@ public class DistributionOverviewPage extends FormPage implements SlcNames {
                        }
                });
 
-               headerSection = tk.createSection(header, Section.TWISTIE);
-               headerSection.setText("Advanced filters");
-               headerSection.setExpanded(false);
-               gd = new GridData(SWT.FILL, SWT.FILL, false, false);
-               gd.horizontalSpan = 2;
-               headerSection.setLayoutData(gd);
+               Button resetBtn = tk.createButton(header, null, SWT.PUSH);
+               resetBtn.setImage(DistImages.IMG_REPO_READONLY);
+               resetBtn.addSelectionListener(new SelectionListener() {
 
-               Composite body = new Composite(headerSection, SWT.FILL);
-               headerSection.setClient(body);
+                       public void widgetSelected(SelectionEvent e) {
+                               resetFilter();
+                       }
 
-               // Layout
-               layout = new GridLayout(2, false);
-               body.setLayout(layout);
+                       public void widgetDefaultSelected(SelectionEvent e) {
+                       }
+               });
 
-               // Artifact Name
-               tk.createLabel(body, "Add some more filters here ", SWT.NONE);
-               // lbl = tk.createLabel(body, "Artifact name: ", SWT.NONE);
-               // artifactTxt = tk.createText(body, "", SWT.BORDER | SWT.SINGLE);
-               // gd = new GridData(SWT.FILL, SWT.FILL, false, false);
-               // gd.grabExcessHorizontalSpace = true;
-               // artifactTxt.setLayoutData(gd);
-               // artifactTxt.addModifyListener(new ModifyListener() {
-               //
-               // public void modifyText(ModifyEvent event) {
-               // refreshFilteredList();
-               // }
-               // });
+       }
+
+       private void resetFilter() {
+               artifactTxt.setText("");
+               artifactTxt.setMessage("Enter filter criterion separated by a space");
+               viewer.refresh();
        }
 
        private void refreshFilteredList() {
@@ -187,7 +254,6 @@ public class DistributionOverviewPage extends FormPage implements SlcNames {
        }
 
        private void createTableViewer(Composite parent) {
-
                // helpers to enable sorting by column
                List<String> propertiesList = new ArrayList<String>();
                List<Integer> propertyTypesList = new ArrayList<Integer>();
@@ -196,75 +262,62 @@ public class DistributionOverviewPage extends FormPage implements SlcNames {
                viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL
                                | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
 
-               TableViewerColumn col = new TableViewerColumn(viewer, SWT.V_SCROLL);
+               // Name
+               TableViewerColumn col = new TableViewerColumn(viewer, SWT.NONE);
                col.getColumn().setWidth(300);
-               col.getColumn().setText("Symbolic name");
+               col.getColumn().setText("Name");
                col.setLabelProvider(new ColumnLabelProvider() {
                        @Override
                        public String getText(Object element) {
-                               return JcrUtils.get((Node) element, SLC_SYMBOLIC_NAME);
+                               return JcrUtils.get((Node) element,
+                                               DistConstants.SLC_BUNDLE_NAME);
                        }
                });
                col.getColumn().addSelectionListener(getSelectionAdapter(0));
-               propertiesList.add(SLC_SYMBOLIC_NAME);
+               propertiesList.add(DistConstants.SLC_BUNDLE_NAME);
                propertyTypesList.add(PropertyType.STRING);
 
-               col = new TableViewerColumn(viewer, SWT.NONE);
-               col.getColumn().setWidth(100);
-               col.getColumn().setText("Version");
+               // Symbolic name
+               col = new TableViewerColumn(viewer, SWT.V_SCROLL);
+               col.getColumn().setWidth(300);
+               col.getColumn().setText("Symbolic name");
                col.setLabelProvider(new ColumnLabelProvider() {
                        @Override
                        public String getText(Object element) {
-                               return JcrUtils.get((Node) element, SLC_BUNDLE_VERSION);
+                               return JcrUtils.get((Node) element, SLC_SYMBOLIC_NAME);
                        }
                });
                col.getColumn().addSelectionListener(getSelectionAdapter(1));
-               propertiesList.add(SLC_BUNDLE_VERSION);
+               propertiesList.add(SLC_SYMBOLIC_NAME);
                propertyTypesList.add(PropertyType.STRING);
 
+               // Version
                col = new TableViewerColumn(viewer, SWT.NONE);
-               col.getColumn().setWidth(150);
-               col.getColumn().setText("Group ID");
+               col.getColumn().setWidth(100);
+               col.getColumn().setText("Version");
                col.setLabelProvider(new ColumnLabelProvider() {
                        @Override
                        public String getText(Object element) {
-                               return JcrUtils.get((Node) element, SLC_GROUP_ID);
+                               return JcrUtils.get((Node) element, SLC_BUNDLE_VERSION);
                        }
                });
                col.getColumn().addSelectionListener(getSelectionAdapter(2));
-               propertiesList.add(SLC_GROUP_ID);
-               propertyTypesList.add(PropertyType.STRING);
-
-               col = new TableViewerColumn(viewer, SWT.NONE);
-               col.getColumn().setWidth(300);
-               col.getColumn().setText("Name");
-               col.setLabelProvider(new ColumnLabelProvider() {
-                       @Override
-                       public String getText(Object element) {
-                               return JcrUtils.get((Node) element, SLC_
-                                               + Constants.BUNDLE_NAME);
-                       }
-               });
-               col.getColumn().addSelectionListener(getSelectionAdapter(3));
-               propertiesList.add(SLC_ + Constants.BUNDLE_NAME);
+               propertiesList.add(SLC_BUNDLE_VERSION);
                propertyTypesList.add(PropertyType.STRING);
 
                final Table table = viewer.getTable();
                table.setHeaderVisible(true);
                table.setLinesVisible(true);
-               GridData gd = new GridData(SWT.FILL, SWT.TOP, true, true);
-               gd.heightHint = 300;
-               table.setLayoutData(gd);
 
                viewer.setContentProvider(new DistributionsContentProvider());
                getSite().setSelectionProvider(viewer);
 
-               viewer.setInput(session);
-               comparator = new NodeViewerComparator(1,
-                               NodeViewerComparator.DESCENDING, propertiesList,
+               comparator = new NodeViewerComparator(2,
+                               NodeViewerComparator.ASCENDING, propertiesList,
                                propertyTypesList);
                viewer.setComparator(comparator);
 
+               // Context Menu
                MenuManager menuManager = new MenuManager();
                Menu menu = menuManager.createContextMenu(viewer.getTable());
                menuManager.addMenuListener(new IMenuListener() {
@@ -275,6 +328,8 @@ public class DistributionOverviewPage extends FormPage implements SlcNames {
                viewer.getTable().setMenu(menu);
                getSite().registerContextMenu(menuManager, viewer);
 
+               // Double click
+               viewer.addDoubleClickListener(new DoubleClickListener());
        }
 
        @Override
@@ -287,47 +342,12 @@ public class DistributionOverviewPage extends FormPage implements SlcNames {
                viewer.refresh();
        }
 
-       /**
-        * 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;
-               // int maxW = getManagedForm().getForm().getSize().x;
-               maxH = maxH - header.getSize().y;
-
-               // maxH = maxH - headerSection.getSize().y
-               // - headerSection.getClient().getSize().y;
-
-               // Set
-               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. Here is room for optimization
-               gd.heightHint = Math.max(maxH - 70, 200);
-               gd.widthHint = Math.max(maxW - 40, 200);
-
-               table.setLayoutData(gd);
-               getManagedForm().reflow(true);
-       }
-
-       @Override
-       public void setActive(boolean active) {
-               super.setActive(active);
-               if (active) {
-                       refreshLayout();
-               }
-       }
-
-       /** Programatically configure the context menu */
+       /** Programmatically configure the context menu */
        protected void contextMenuAboutToShow(IMenuManager menuManager) {
                IWorkbenchWindow window = DistPlugin.getDefault().getWorkbench()
                                .getActiveWorkbenchWindow();
 
-               // Build conditions depending on element type (repo or workspace)
+               // Build conditions
 
                // Delete selected artifacts
                CommandHelpers.refreshCommand(menuManager, window, DeleteArtifacts.ID,
@@ -336,70 +356,6 @@ public class DistributionOverviewPage extends FormPage implements SlcNames {
 
        }
 
-       NodeIterator listBundleArtifacts(Session session)
-                       throws RepositoryException {
-               QueryManager queryManager = session.getWorkspace().getQueryManager();
-               QueryObjectModelFactory factory = queryManager.getQOMFactory();
-
-               final String bundleArtifactsSelector = "bundleArtifacts";
-               Selector source = factory.selector(SlcTypes.SLC_BUNDLE_ARTIFACT,
-                               bundleArtifactsSelector);
-
-               String artifactTxtVal = artifactTxt.getText();
-
-               DynamicOperand propName = factory.propertyValue(
-                               source.getSelectorName(), SlcNames.SLC_SYMBOLIC_NAME);
-               StaticOperand propValue = factory.bindVariable("'%" + artifactTxtVal
-                               + "%'");
-               Constraint constraint = factory.comparison(propName,
-                               QueryObjectModelFactory.JCR_OPERATOR_LIKE, propValue);
-
-               Ordering order = factory.ascending(factory.propertyValue(
-                               bundleArtifactsSelector, SlcNames.SLC_SYMBOLIC_NAME));
-               Ordering[] orderings = { order };
-
-               QueryObjectModel query = factory.createQuery(source, constraint,
-                               orderings, null);
-
-               QueryResult result = query.execute();
-               return result.getNodes();
-       }
-
-       private NodeIterator getArtifactsWithWhereClause(String whereClause) {
-               StringBuffer strBuf = new StringBuffer();
-               strBuf.append("Select * FROM [" + SlcTypes.SLC_BUNDLE_ARTIFACT
-                               + "] AS bundleArtifacts");
-               if (whereClause != null && !"".equals(whereClause.trim())) {
-                       strBuf.append(" WHERE ");
-                       strBuf.append(whereClause);
-               }
-               strBuf.append(" ORDER BY ");
-               strBuf.append("bundleArtifacts.[" + SlcNames.SLC_SYMBOLIC_NAME + "] ");
-               strBuf.append("ASC");
-               try {
-                       if (log.isTraceEnabled())
-                               log.trace("Get artifacts query : " + strBuf.toString());
-                       Query query = session.getWorkspace().getQueryManager()
-                                       .createQuery(strBuf.toString(), Query.JCR_SQL2);
-                       return query.execute().getNodes();
-               } catch (RepositoryException e) {
-                       throw new SlcException(
-                                       "Unexpected error while retrieving list of artifacts", e);
-               }
-       }
-
-       private String buildWhereClause() {
-               StringBuffer whereClause = new StringBuffer();
-
-               String artifactTxtVal = artifactTxt.getText();
-               if (!"".equals(artifactTxtVal)) {
-                       whereClause.append("bundleArtifacts.[" + SlcNames.SLC_SYMBOLIC_NAME
-                                       + "] like ");
-                       whereClause.append("'%" + artifactTxtVal + "%'");
-               }
-               return whereClause.toString();
-       }
-
        private SelectionAdapter getSelectionAdapter(final int index) {
                SelectionAdapter selectionAdapter = new SelectionAdapter() {
                        @Override
@@ -420,6 +376,7 @@ public class DistributionOverviewPage extends FormPage implements SlcNames {
                return selectionAdapter;
        }
 
+       /* LOCAL CLASSES */
        private class DistributionsContentProvider implements
                        IStructuredContentProvider {
                // private Session session;
@@ -432,86 +389,71 @@ public class DistributionOverviewPage extends FormPage implements SlcNames {
                }
 
                public Object[] getElements(Object arg0) {
-                       // try {
-                       // List<Node> nodes = JcrUtils
-                       // .nodeIteratorToList(listBundleArtifacts(session));
-                       // return nodes.toArray();
-                       // } catch (RepositoryException e) {
-                       // ErrorFeedback.show("Cannot list bundles", e);
-                       // return null;
-                       // }
-
-                       List<Node> nodes = JcrUtils
-                                       .nodeIteratorToList(getArtifactsWithWhereClause(buildWhereClause()));
-                       return nodes.toArray();
+                       try {
+                               List<Node> nodes = JcrUtils
+                                               .nodeIteratorToList(listBundleArtifacts(session));
+                               return nodes.toArray();
+                       } catch (RepositoryException e) {
+                               ErrorFeedback.show("Cannot list bundles", e);
+                               return null;
+                       }
+               }
+       }
+
+       private class DoubleClickListener implements IDoubleClickListener {
+
+               public void doubleClick(DoubleClickEvent event) {
+                       Object obj = ((IStructuredSelection) event.getSelection())
+                                       .getFirstElement();
+                       try {
+                               if (obj instanceof Node) {
+                                       Node node = (Node) obj;
+                                       if (node.isNodeType(SlcTypes.SLC_BUNDLE_ARTIFACT)) {
+                                               GenericBundleEditorInput gaei = new GenericBundleEditorInput(
+                                                               node);
+                                               DistPlugin.getDefault().getWorkbench()
+                                                               .getActiveWorkbenchWindow().getActivePage()
+                                                               .openEditor(gaei, GenericBundleEditor.ID);
+                                       }
+                               }
+                       } catch (RepositoryException re) {
+                               throw new ArgeoException(
+                                               "Repository error while getting node info", re);
+                       } catch (PartInitException pie) {
+                               throw new ArgeoException(
+                                               "Unexepected exception while opening artifact editor",
+                                               pie);
+                       }
+               }
+       }
+
+       /**
+        * 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. Here is room for optimization
+               gd.heightHint = Math.max(maxH - 35, 200);
+               gd.widthHint = Math.max(maxW - 35, 200);
+
+               table.setLayoutData(gd);
+               getManagedForm().reflow(true);
+       }
+
+       @Override
+       public void setActive(boolean active) {
+               super.setActive(active);
+               if (active) {
+                       refreshLayout();
                }
        }
-       //
-       // private class BoundedLayout extends Layout {
-       // protected Layout delegateLayout;
-       //
-       // protected Method computeSizeMethod;
-       // protected Method layoutMethod;
-       //
-       // protected boolean widthBound;
-       //
-       // public BoundedLayout(Layout delegateLayout, boolean widthBound) {
-       // setDelegateLayout(delegateLayout);
-       // this.widthBound = widthBound;
-       // }
-       //
-       // public Layout getDelegateLayout() {
-       // return delegateLayout;
-       // }
-       //
-       // public void setDelegateLayout(Layout delegateLayout) {
-       // this.delegateLayout = delegateLayout;
-       //
-       // try {
-       // computeSizeMethod = delegateLayout.getClass()
-       // .getDeclaredMethod("computeSize", Composite.class,
-       // int.class, int.class, boolean.class);
-       // computeSizeMethod.setAccessible(true);
-       //
-       // layoutMethod = delegateLayout.getClass().getDeclaredMethod(
-       // "layout", Composite.class, boolean.class);
-       // layoutMethod.setAccessible(true);
-       // } catch (Exception e) {
-       // throw new RuntimeException(e);
-       // }
-       // }
-       //
-       // @Override
-       // protected Point computeSize(Composite composite, int wHint, int hHint,
-       // boolean flushCache) {
-       // // get comp size to make sure we don't let any children exceed it
-       // Point compSize = composite.getSize();
-       //
-       // try {
-       // Point layoutComputedSize = (Point) computeSizeMethod.invoke(
-       // delegateLayout, composite, wHint, hHint, flushCache);
-       //
-       // if (widthBound) {
-       // layoutComputedSize.x = Math.min(compSize.x,
-       // layoutComputedSize.x);
-       // } else {
-       // layoutComputedSize.y = Math.min(compSize.y,
-       // layoutComputedSize.y);
-       // }
-       //
-       // return layoutComputedSize;
-       // } catch (Exception e) {
-       // throw new RuntimeException(e);
-       // }
-       // }
-       //
-       // @Override
-       // protected void layout(Composite composite, boolean flushCache) {
-       // try {
-       // layoutMethod.invoke(delegateLayout, composite, flushCache);
-       // } catch (Exception e) {
-       // throw new RuntimeException(e);
-       // }
-       // }
-       // }
+
 }
\ 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/GenericArtifactEditor.java b/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/GenericArtifactEditor.java
deleted file mode 100644 (file)
index 0e9f174..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * 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 org.argeo.ArgeoException;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-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;
-
-/**
- * 
- * Container for the node editor page. At creation time, it takes a JCR Node
- * that cannot be changed afterwards.
- * 
- */
-public class GenericArtifactEditor extends FormEditor {
-
-       // private final static Log log =
-       // LogFactory.getLog(GenericNodeEditor.class);
-       public final static String ID = DistPlugin.ID + ".genericArtifactEditor";
-
-       // business objects
-       private Node artifactNode;
-
-       // This Editor widgets
-       private ArtifactDetailsPage artifactDetailsPage;
-
-       public void init(IEditorSite site, IEditorInput input)
-                       throws PartInitException {
-               super.init(site, input);
-               GenericArtifactEditorInput gaei = (GenericArtifactEditorInput) getEditorInput();
-               artifactNode = gaei.getArtifactNode();
-               this.setPartName(gaei.getArtifactId());
-       }
-
-       @Override
-       protected void addPages() {
-               try {
-
-                       artifactDetailsPage = new ArtifactDetailsPage(this, "Main",
-                                       artifactNode);
-                       addPage(artifactDetailsPage);
-               } catch (PartInitException e) {
-                       throw new ArgeoException("Not able to add an empty page ", e);
-               }
-       }
-
-       @Override
-       public void doSaveAs() {
-               // unused compulsory method
-       }
-
-       @Override
-       public void doSave(IProgressMonitor monitor) {
-               try {
-                       // Automatically commit all pages of the editor
-                       commitPages(true);
-                       firePropertyChange(PROP_DIRTY);
-               } catch (Exception e) {
-                       throw new ArgeoException("Error while saving node", e);
-               }
-
-       }
-
-       @Override
-       public boolean isSaveAsAllowed() {
-               return true;
-       }
-
-       Node getArtifactNode() {
-               return artifactNode;
-       }
-}
diff --git a/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/GenericArtifactEditorInput.java b/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/GenericArtifactEditorInput.java
deleted file mode 100644 (file)
index f58b0eb..0000000
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * 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.RepositoryException;
-
-import org.argeo.ArgeoException;
-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 based the JCR node object.
- * */
-
-public class GenericArtifactEditorInput implements IEditorInput, SlcNames {
-
-       private final Node artifactNode;
-       // cache key properties at creation time to avoid Exception at recoring time
-       // when the session has been closed
-       private String artifactId;
-       private String groupId;
-       private String version;
-
-       public GenericArtifactEditorInput(Node artifactNode) {
-               this.artifactNode = artifactNode;
-               try {
-                       artifactId = artifactNode.getProperty(SLC_ARTIFACT_ID).getString();
-                       groupId = artifactNode.getProperty(SLC_GROUP_ID).getString();
-                       version = artifactNode.getProperty(SLC_ARTIFACT_VERSION)
-                                       .getString();
-               } catch (RepositoryException re) {
-                       throw new ArgeoException(
-                                       "unexpected error while getting node key values at creation time",
-                                       re);
-               }
-       }
-
-       public Node getArtifactNode() {
-               return artifactNode;
-       }
-
-       public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
-               return null;
-       }
-
-       public boolean exists() {
-               return true;
-       }
-
-       public ImageDescriptor getImageDescriptor() {
-               return null;
-       }
-
-       public String getArtifactId() {
-               return artifactId;
-       }
-
-       public String getGroupId() {
-               return groupId;
-       }
-
-       public String getVersion() {
-               return version;
-       }
-
-       // Dummy compulsory methods
-       public String getToolTipText() {
-               return artifactId + ":" + groupId + ":" + version;
-       }
-
-       public String getName() {
-               return artifactId + ":" + groupId + ":" + version;
-       }
-
-       public IPersistableElement getPersistable() {
-               return null;
-       }
-
-       /**
-        * equals method based on coordinates
-        */
-       public boolean equals(Object obj) {
-               if (this == obj)
-                       return true;
-               if (obj == null)
-                       return false;
-               if (getClass() != obj.getClass())
-                       return false;
-
-               GenericArtifactEditorInput other = (GenericArtifactEditorInput) obj;
-               if (!getGroupId().equals(other.getGroupId()))
-                       return false;
-               if (!getArtifactId().equals(other.getArtifactId()))
-                       return false;
-               if (!getVersion().equals(other.getVersion()))
-                       return false;
-               return true;
-       }
-}
diff --git a/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/GenericBundleEditor.java b/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/GenericBundleEditor.java
new file mode 100644 (file)
index 0000000..17e546a
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ * 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 org.argeo.ArgeoException;
+import org.argeo.slc.client.ui.dist.DistPlugin;
+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;
+
+/**
+ * 
+ * Exposes a bundle and enable its management
+ * 
+ */
+public class GenericBundleEditor extends FormEditor {
+
+       // private final static Log log =
+       // LogFactory.getLog(GenericNodeEditor.class);
+       public final static String ID = DistPlugin.ID + ".genericBundleEditor";
+
+       // business objects
+       private Node bundleNode;
+
+       // This Editor widgets
+       private BundleRawPage bundleRawPage;
+       private BundleDetailsPage bundleDetailsPage;
+
+       public void init(IEditorSite site, IEditorInput input)
+                       throws PartInitException {
+               super.init(site, input);
+               GenericBundleEditorInput gaei = (GenericBundleEditorInput) getEditorInput();
+               bundleNode = gaei.getArtifactNode();
+               this.setPartName(gaei.getArtifactId());
+       }
+
+       @Override
+       protected void addPages() {
+               try {
+                       bundleDetailsPage = new BundleDetailsPage(this, "Main", bundleNode);
+                       addPage(bundleDetailsPage);
+                       bundleRawPage = new BundleRawPage(this, "Main", bundleNode);
+                       addPage(bundleRawPage);
+               } catch (PartInitException e) {
+                       throw new ArgeoException("Not able to add an empty page ", e);
+               }
+       }
+
+       @Override
+       public void doSaveAs() {
+               // unused compulsory method
+       }
+
+       @Override
+       public void doSave(IProgressMonitor monitor) {
+               try {
+                       // Automatically commit all pages of the editor
+                       commitPages(true);
+                       firePropertyChange(PROP_DIRTY);
+               } catch (Exception e) {
+                       throw new ArgeoException("Error while saving node", e);
+               }
+
+       }
+
+       @Override
+       public boolean isSaveAsAllowed() {
+               return true;
+       }
+}
diff --git a/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/GenericBundleEditorInput.java b/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/GenericBundleEditorInput.java
new file mode 100644 (file)
index 0000000..e0d24c3
--- /dev/null
@@ -0,0 +1,116 @@
+/*
+ * 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.RepositoryException;
+
+import org.argeo.ArgeoException;
+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 based the JCR node object.
+ * */
+
+public class GenericBundleEditorInput implements IEditorInput, SlcNames {
+
+       private final Node artifactNode;
+       // cache key properties at creation time to avoid Exception at recovering time
+       // when the session has been closed
+       private String artifactId;
+       private String groupId;
+       private String version;
+
+       public GenericBundleEditorInput(Node artifactNode) {
+               this.artifactNode = artifactNode;
+               try {
+                       artifactId = artifactNode.getProperty(SLC_ARTIFACT_ID).getString();
+                       groupId = artifactNode.getProperty(SLC_GROUP_ID).getString();
+                       version = artifactNode.getProperty(SLC_ARTIFACT_VERSION)
+                                       .getString();
+               } catch (RepositoryException re) {
+                       throw new ArgeoException(
+                                       "unexpected error while getting node key values at creation time",
+                                       re);
+               }
+       }
+
+       public Node getArtifactNode() {
+               return artifactNode;
+       }
+
+       public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
+               return null;
+       }
+
+       public boolean exists() {
+               return true;
+       }
+
+       public ImageDescriptor getImageDescriptor() {
+               return null;
+       }
+
+       public String getArtifactId() {
+               return artifactId;
+       }
+
+       public String getGroupId() {
+               return groupId;
+       }
+
+       public String getVersion() {
+               return version;
+       }
+
+       // Dummy compulsory methods
+       public String getToolTipText() {
+               return artifactId + ":" + groupId + ":" + version;
+       }
+
+       public String getName() {
+               // return artifactId + ":" + groupId + ":" + version;
+               return groupId;
+       }
+
+       public IPersistableElement getPersistable() {
+               return null;
+       }
+
+       /**
+        * equals method based on coordinates
+        */
+       public boolean equals(Object obj) {
+               if (this == obj)
+                       return true;
+               if (obj == null)
+                       return false;
+               if (getClass() != obj.getClass())
+                       return false;
+
+               GenericBundleEditorInput other = (GenericBundleEditorInput) obj;
+               if (!getGroupId().equals(other.getGroupId()))
+                       return false;
+               if (!getArtifactId().equals(other.getArtifactId()))
+                       return false;
+               if (!getVersion().equals(other.getVersion()))
+                       return false;
+               return true;
+       }
+}
\ 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/utils/AbstractHyperlinkListener.java b/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/utils/AbstractHyperlinkListener.java
new file mode 100644 (file)
index 0000000..3c95ac4
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Argeo Connect - Data management and communications
+ * Copyright (C) 2012 Argeo GmbH
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>
+ *
+ * Additional permission under GNU GPL version 3 section 7
+ *
+ * If you modify this Program, or any covered work, by linking or combining it
+ * with software covered by the terms of the Eclipse Public License, the
+ * licensors of this Program grant you additional permission to convey the
+ * resulting work. Corresponding Source for a non-source form of such a
+ * combination shall include the source code for the parts of such software
+ * which are used as well as that of the covered work.
+ */
+package org.argeo.slc.client.ui.dist.utils;
+
+import org.eclipse.ui.forms.events.HyperlinkEvent;
+import org.eclipse.ui.forms.events.IHyperlinkListener;
+
+public abstract class AbstractHyperlinkListener implements IHyperlinkListener {
+
+       public void linkEntered(HyperlinkEvent e) {
+       }
+
+       public void linkExited(HyperlinkEvent e) {
+       }
+
+       /** Must be overriden **/
+       public abstract void linkActivated(HyperlinkEvent e);
+}
\ No newline at end of file
index 52fd904ca50cb75e7650ac9a1ac161e2c2fcbc26..209bb4dd7b0c6b1aec763029561903a531de59c3 100644 (file)
@@ -25,19 +25,19 @@ import org.argeo.eclipse.ui.jcr.utils.JcrFileProvider;
 import org.argeo.eclipse.ui.specific.FileHandler;
 import org.argeo.slc.client.ui.dist.DistConstants;
 import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.client.ui.dist.editors.GenericArtifactEditor;
-import org.argeo.slc.client.ui.dist.editors.GenericArtifactEditorInput;
+import org.argeo.slc.client.ui.dist.editors.GenericBundleEditor;
+import org.argeo.slc.client.ui.dist.editors.GenericBundleEditorInput;
 import org.argeo.slc.jcr.SlcNames;
 import org.argeo.slc.jcr.SlcTypes;
 import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.jface.viewers.DoubleClickEvent;
 import org.eclipse.jface.viewers.IDoubleClickListener;
 import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.TreeViewer;
 import org.eclipse.ui.PartInitException;
 
 /**
- * Centralizes the management of double click on an ArtifactTreeViewer
+ * Centralizes the management of double click on an viewer that displays
+ * artifacts.
  */
 public class GenericDoubleClickListener implements IDoubleClickListener,
                SlcTypes, SlcNames, DistConstants {
@@ -45,13 +45,10 @@ public class GenericDoubleClickListener implements IDoubleClickListener,
        // private final static Log log = LogFactory
        // .getLog(GenericDoubleClickListener.class);
 
-       //private TreeViewer viewer;
-
        private JcrFileProvider jfp;
        private FileHandler fileHandler;
 
-       public GenericDoubleClickListener(TreeViewer viewer) {
-               // this.viewer = viewer;
+       public GenericDoubleClickListener() {
                jfp = new JcrFileProvider();
                fileHandler = new FileHandler(jfp);
        }
@@ -65,11 +62,11 @@ public class GenericDoubleClickListener implements IDoubleClickListener,
                        if (obj instanceof Node) {
                                Node node = (Node) obj;
                                if (node.isNodeType(SLC_ARTIFACT_VERSION_BASE)) {
-                                       GenericArtifactEditorInput gaei = new GenericArtifactEditorInput(
+                                       GenericBundleEditorInput gaei = new GenericBundleEditorInput(
                                                        node);
                                        DistPlugin.getDefault().getWorkbench()
                                                        .getActiveWorkbenchWindow().getActivePage()
-                                                       .openEditor(gaei, GenericArtifactEditor.ID);
+                                                       .openEditor(gaei, GenericBundleEditor.ID);
                                } else if (node.isNodeType(NodeType.NT_FILE)) {
                                        String name = node.getName();
                                        String id = node.getIdentifier();
@@ -107,11 +104,11 @@ public class GenericDoubleClickListener implements IDoubleClickListener,
                                                                        + SLC_ARTIFACT_VERSION_BASE + " node "
                                                                        + " in order to open the artifact editor");
                                else {
-                                       GenericArtifactEditorInput gaei = new GenericArtifactEditorInput(
+                                       GenericBundleEditorInput gaei = new GenericBundleEditorInput(
                                                        node);
                                        DistPlugin.getDefault().getWorkbench()
                                                        .getActiveWorkbenchWindow().getActivePage()
-                                                       .openEditor(gaei, GenericArtifactEditor.ID);
+                                                       .openEditor(gaei, GenericBundleEditor.ID);
                                }
                        }
                } catch (RepositoryException re) {
index 33fd14981162d8c2f3145caba1d5f9378ea9cdc0..3fcb1db10b2ea5491639f9919bd8e1e287a3feb9 100644 (file)
@@ -87,7 +87,7 @@ public abstract class AbstractQueryArtifactsView extends ViewPart implements
 
                viewer.setLabelProvider(new ViewLabelProvider());
                viewer.setContentProvider(new ViewContentProvider());
-               viewer.addDoubleClickListener(new GenericDoubleClickListener(null));
+               viewer.addDoubleClickListener(new GenericDoubleClickListener());
 
                tableConfigurer = new ArtifactsTableConfigurer(viewer, 1,
                                GenericTableComparator.DESCENDING);
index 0a696af7ed0e308269f38ad951f1589bec9e6c29..10a38454c7d34efe20d228059e9259ff528f3e81 100644 (file)
@@ -122,7 +122,7 @@ public class ArtifactsBrowser extends ViewPart implements DistConstants,
                viewer.setContentProvider(new ArtifactsTreeContentProvider());
                viewer.setLabelProvider(new ArtifactLabelProvider());
                viewer.addSelectionChangedListener(new ArtifactTreeSelectionListener());
-               viewer.addDoubleClickListener(new GenericDoubleClickListener(viewer));
+               viewer.addDoubleClickListener(new GenericDoubleClickListener());
                viewer.setInput(rootNode);
 
                return viewer;
index 3ca2ce9ab6eb98ee629ca8a22201ad37ded70dca..26e38f1bbbebfdbefd0cc38a4fd945bc809e294f 100644 (file)
@@ -50,10 +50,10 @@ import org.argeo.slc.client.ui.dist.DistPlugin;
 import org.argeo.slc.client.ui.dist.commands.CopyWorkspace;
 import org.argeo.slc.client.ui.dist.commands.CreateWorkspace;
 import org.argeo.slc.client.ui.dist.commands.DeleteWorkspace;
+import org.argeo.slc.client.ui.dist.commands.Fetch;
 import org.argeo.slc.client.ui.dist.commands.ManageWorkspaceAuth;
 import org.argeo.slc.client.ui.dist.commands.NormalizeDistribution;
 import org.argeo.slc.client.ui.dist.commands.RegisterRepository;
-import org.argeo.slc.client.ui.dist.commands.RepoSyncCommand;
 import org.argeo.slc.client.ui.dist.commands.UnregisterRemoteRepo;
 import org.argeo.slc.client.ui.dist.editors.DistributionEditor;
 import org.argeo.slc.client.ui.dist.editors.DistributionEditorInput;
@@ -136,14 +136,13 @@ public class DistributionsView extends ViewPart implements SlcNames, ArgeoNames
                        }
                });
 
-               final Tree table = viewer.getTree();
-               table.setHeaderVisible(false);
-               table.setLinesVisible(false);
+               final Tree tree = viewer.getTree();
+               tree.setHeaderVisible(false);
+               tree.setLinesVisible(false);
 
                viewer.setContentProvider(new DistributionsContentProvider());
                viewer.addDoubleClickListener(new DistributionsDCL());
                viewer.setComparator(new ArtifactNamesComparator());
-               log.debug("Comparator set ");
 
                // Enable selection retrieving from outside the view
                getSite().setSelectionProvider(viewer);
@@ -255,11 +254,10 @@ public class DistributionsView extends ViewPart implements SlcNames, ArgeoNames
 
                                // Fetch repository
                                params = new HashMap<String, String>();
-                               params.put(RepoSyncCommand.PARAM_TARGET_REPO, targetRepoPath);
+                               params.put(Fetch.PARAM_TARGET_REPO, targetRepoPath);
                                CommandHelpers.refreshParameterizedCommand(menuManager, window,
-                                               RepoSyncCommand.ID, RepoSyncCommand.DEFAULT_LABEL,
-                                               RepoSyncCommand.DEFAULT_ICON_PATH, !isDistribElem
-                                                               && singleElement, params);
+                                               Fetch.ID, Fetch.DEFAULT_LABEL, Fetch.DEFAULT_ICON_PATH,
+                                               !isDistribElem && singleElement, params);
 
                                // Normalize workspace
                                params = new HashMap<String, String>();
index c38f42fb70fbb68504bff554804b4290e0b9a2f0..a4369afec8268b00fc64a2dad906144d476e779e 100644 (file)
@@ -76,7 +76,7 @@ public class RegisterRepoWizard extends Wizard {
 
        // Default values
        private final static String DEFAULT_NAME = "Argeo public Repository";
-       private final static String DEFAULT_URI = "https://repo.argeo.org/data/pub/java";
+       private final static String DEFAULT_URI = "http://repo.argeo.org/data/pub/java";
        private final static String DEFAULT_USER_NAME = "anonymous";
        private final static boolean DEFAULT_ANONYMOUS = true;
 
@@ -189,7 +189,12 @@ public class RegisterRepoWizard extends Wizard {
                                password.setEnabled(false);
                        }
 
-                       Button test = createButton(parent, "Test");
+                       Button test = createButton(composite, "Test");
+                       GridData gd = new GridData(SWT.CENTER, SWT.CENTER, false, false, 2,
+                                       1);
+                       gd.widthHint = 140;
+                       test.setLayoutData(gd);
+
                        test.addSelectionListener(new SelectionAdapter() {
                                public void widgetSelected(SelectionEvent arg0) {
                                        testConnection();