Clean both code and UI.
authorBruno Sinou <bsinou@argeo.org>
Fri, 21 Mar 2014 19:30:48 +0000 (19:30 +0000)
committerBruno Sinou <bsinou@argeo.org>
Fri, 21 Mar 2014 19:30:48 +0000 (19:30 +0000)
git-svn-id: https://svn.argeo.org/slc/trunk@6908 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

23 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/commands/DeleteArtifacts.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/commands/MarkAsRelevantCategory.java [deleted file]
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/commands/RefreshDistributionOverviewPage.java [deleted file]
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/ArtifactVersionEditor.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/BundleDependencyPage.java [new file with mode: 0644]
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/BundleDetailPage.java [new file with mode: 0644]
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/BundleDetailsPage.java [deleted file]
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/DistWkspBrowserPage.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/DistWkspSearchPage.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/DistributionEditor.java [deleted file]
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/DistributionEditorInput.java [deleted file]
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/GenericBundleEditor.java [deleted file]
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/GenericBundleEditorInput.java [deleted file]
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/GroupBaseEditorInput.java [deleted file]
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/ModularDistVersionDetailPage.java [new file with mode: 0644]
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/ModularDistVersionEditor.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/ModularDistVersionOverviewPage.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/WkspCategoryBaseListPage.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/utils/GenericDoubleClickListener.java [deleted file]
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

index bdf126d82225b27656a072778362085603202665..e2cd17458c32dd97fcf28fecf791bcd3ff4bc4eb 100644 (file)
                scope="prototype">
        </bean>
 
-       <bean id="refreshDistributionOverviewPage"
-               class="org.argeo.slc.client.ui.dist.commands.RefreshDistributionOverviewPage"
-               scope="prototype">
-       </bean>
-
        <bean id="org.argeo.slc.client.ui.dist.deleteArtifacts" class="org.argeo.slc.client.ui.dist.commands.DeleteArtifacts"
                scope="prototype">
        </bean>
-
 </beans>
\ No newline at end of file
index 97637957699dde5dd421260980c348ab8fac6f8b..19f5ddbb48dba8a3c47c98b07c34e0fe02b730be 100644 (file)
                                </class>
                        </state>
        </command>
-       <command
-            id="org.argeo.slc.client.ui.dist.refreshDistributionOverviewPage"
-            defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
-            name="Refresh distribution overview page">
-       </command>
        <command
             id="org.argeo.slc.client.ui.dist.deleteArtifacts"
             defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
index 893ca36bfd5bc5795fa62b663aef20fdc33bba96..b942ead9b3d77e3b14049458041babf9b9de922c 100644 (file)
@@ -22,7 +22,7 @@ import javax.jcr.RepositoryException;
 
 import org.argeo.ArgeoException;
 import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.client.ui.dist.utils.CommandHelpers;
+import org.argeo.slc.jcr.SlcTypes;
 import org.eclipse.core.commands.AbstractHandler;
 import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
@@ -32,6 +32,7 @@ import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.ui.IEditorPart;
 import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.handlers.HandlerUtil;
 
 /**
  * Delete chosen artifacts from the current workspace.
@@ -46,8 +47,7 @@ public class DeleteArtifacts extends AbstractHandler {
 
        public Object execute(ExecutionEvent event) throws ExecutionException {
                try {
-                       IWorkbenchPart activePart = DistPlugin.getDefault().getWorkbench()
-                                       .getActiveWorkbenchWindow().getActivePage().getActivePart();
+                       IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
 
                        if (activePart instanceof IEditorPart) {
                                ISelection selector = ((IEditorPart) activePart)
@@ -69,14 +69,16 @@ public class DeleteArtifacts extends AbstractHandler {
                                        if (result) {
                                                while (it.hasNext()) {
                                                        Node node = (Node) it.next();
-                                                       // we remove the artifactVersion, that is the parent
-                                                       node.getParent().remove();
-                                                       node.getSession().save();
+                                                       if (node.isNodeType(SlcTypes.SLC_ARTIFACT)) {
+                                                               // we remove the artifactVersion, that is the parent
+                                                               node.getParent().remove();
+                                                               node.getSession().save();
+                                                       }
                                                }
                                        }
                                }
                        }
-                       CommandHelpers.callCommand(RefreshDistributionOverviewPage.ID);
+                       // CommandHelpers.callCommand(RefreshDistributionOverviewPage.ID);
                } catch (RepositoryException re) {
                        throw new ArgeoException(
                                        "Unexpected error while deleting artifacts.", re);
diff --git a/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/commands/MarkAsRelevantCategory.java b/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/commands/MarkAsRelevantCategory.java
deleted file mode 100644 (file)
index e58aa1a..0000000
+++ /dev/null
@@ -1,79 +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.commands;
-
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.resource.ImageDescriptor;
-
-/**
- * Add the {@code SlcNames.SLC_RELEVANT_CATEGORY} mixin to the selected node
- */
-public class MarkAsRelevantCategory extends AbstractHandler {
-       // private static final Log log = LogFactory.getLog(DeleteWorkspace.class);
-
-       public final static String ID = DistPlugin.ID + ".markAsRelevantCategory";
-       public final static String DEFAULT_LABEL = "Mark as relevant category base";
-       public final static ImageDescriptor DEFAULT_ICON = DistPlugin
-                       .getImageDescriptor("icons/addItem.gif");
-       
-       public Object execute(ExecutionEvent event) throws ExecutionException {
-               // try {
-               // IWorkbenchPart activePart = DistPlugin.getDefault().getWorkbench()
-               // .getActiveWorkbenchWindow().getActivePage().getActivePart();
-               //
-               // if (activePart instanceof IEditorPart) {
-               // ISelection selector = ((IEditorPart) activePart)
-               // .getEditorSite().getSelectionProvider().getSelection();
-               // if (selector != null
-               // && selector instanceof IStructuredSelection) {
-               // Iterator<?> it = ((IStructuredSelection) selector)
-               // .iterator();
-               //
-               // Node node = (Node) it.next();
-               // if (node.isNodeType(SlcTypes.SLC_CATEGORY)) {
-               // String msg =
-               // "Your are about to unlist this category from the relevant category list for current workspace"
-               // + ".\n" + "Are you sure you want to proceed?";
-               // if (MessageDialog.openConfirm(DistPlugin.getDefault()
-               // .getWorkbench().getDisplay().getActiveShell(),
-               // "Confirm", msg)) {
-               // node.removeMixin(SlcTypes.SLC_CATEGORY);
-               // node.getSession().save();
-               // }
-               // } else {
-               // String msg =
-               // "Your are about to mark this group as category base in the current workspace"
-               // + ".\n" + "Are you sure you want to proceed?";
-               //
-               // if (MessageDialog.openConfirm(DistPlugin.getDefault()
-               // .getWorkbench().getDisplay().getActiveShell(),
-               // "Confirm", msg)) {
-               // node.addMixin(SlcTypes.SLC_CATEGORY);
-               // node.getSession().save();
-               // }
-               // }
-               // }
-               // }
-               // } catch (RepositoryException re) {
-               // throw new ArgeoException(
-               // "Unexpected error while deleting artifacts.", re);
-               // }
-               return null;
-       }
-}
\ 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/RefreshDistributionOverviewPage.java b/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/commands/RefreshDistributionOverviewPage.java
deleted file mode 100644 (file)
index 4230150..0000000
+++ /dev/null
@@ -1,52 +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.commands;
-
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.client.ui.dist.editors.DistributionEditor;
-import org.argeo.slc.client.ui.dist.editors.DistWkspSearchPage;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.forms.editor.IFormPage;
-
-/**
- * Force refresh of the Distribution overview page of the corresponding editor
- */
-public class RefreshDistributionOverviewPage extends AbstractHandler {
-       // private static final Log log = LogFactory
-       // .getLog(RefreshDistributionOverviewPage.class);
-
-       public final static String ID = DistPlugin.ID
-                       + ".refreshDistributionOverviewPage";
-       public final static String DEFAULT_LABEL = "Refresh the distribution overview";
-       public final static ImageDescriptor DEFAULT_ICON = DistPlugin
-                       .getImageDescriptor("icons/refresh.png");
-
-       public Object execute(ExecutionEvent event) throws ExecutionException {
-               IWorkbenchPart activePart = DistPlugin.getDefault().getWorkbench()
-                               .getActiveWorkbenchWindow().getActivePage().getActivePart();
-               if (activePart instanceof DistributionEditor) {
-                       IFormPage ifp = ((DistributionEditor) activePart)
-                                       .getActivePageInstance();
-                       if (ifp instanceof DistWkspSearchPage)
-                               ((DistWkspSearchPage) ifp).refresh();
-               }
-               return null;
-       }
-}
\ No newline at end of file
index ad9a33b756382dc3c14a778a195ea59953e1719c..9c01be72c81d99d3412a496049e2677cef878e77 100644 (file)
@@ -91,7 +91,8 @@ public class ArtifactVersionEditor extends FormEditor implements SlcNames {
                setPartName(getFormattedName());
 
                try {
-                       addPage(new BundleDetailsPage(this, "Details ", artifact));
+                       addPage(new BundleDetailPage(this, "Details ", artifact));
+                       addPage(new BundleDependencyPage(this, "Dependencies ", artifact));
                        addPage(new BundleRawPage(this, "Raw Meta-Data ", artifact));
                } catch (PartInitException e) {
                        throw new ArgeoException("Cannot add distribution editor pages", e);
diff --git a/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/BundleDependencyPage.java b/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/BundleDependencyPage.java
new file mode 100644 (file)
index 0000000..321ec80
--- /dev/null
@@ -0,0 +1,458 @@
+/*
+ * 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.List;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.RepositoryException;
+
+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.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.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.Tree;
+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;
+
+/**
+ * Present main information of a given OSGI bundle
+ */
+public class BundleDependencyPage extends FormPage implements SlcNames {
+       // private final static Log log =
+       // LogFactory.getLog(ArtifactDetailsPage.class);
+
+       // Main business Objects
+       private Node currBundle;
+
+       // This page widgets
+       private FormToolkit toolkit;
+
+       public BundleDependencyPage(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 {
+                       if (currBundle.hasProperty(DistConstants.SLC_BUNDLE_NAME))
+                               form.setText(currBundle.getProperty(
+                                               DistConstants.SLC_BUNDLE_NAME).getString());
+                       Composite body = form.getBody();
+                       GridLayout layout = new GridLayout(1, false);
+                       layout.horizontalSpacing = layout.marginWidth = 0;
+                       layout.verticalSpacing = layout.marginHeight = 0;
+                       body.setLayout(layout);
+
+                       Composite part = toolkit.createComposite(body);
+                       createExportPackageSection(part);
+                       GridData gd = new GridData(SWT.FILL, SWT.TOP, true, false);
+                       gd.heightHint = 180;
+                       part.setLayoutData(gd);
+
+                       part = toolkit.createComposite(body);
+                       createImportPackageSection(part);
+                       gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+                       // gd.heightHint = 200;
+                       part.setLayoutData(gd);
+
+                       part = toolkit.createComposite(body);
+                       createReqBundleSection(part);
+                       gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+                       // /gd.heightHint = 200;
+                       part.setLayoutData(gd);
+
+                       managedForm.reflow(true);
+
+               } catch (RepositoryException e) {
+                       throw new SlcException("unexpected error "
+                                       + "while creating bundle details page");
+               }
+       }
+
+       // Workaround to add an artificial level to the export package browser
+       private class LevelElem {
+               private String label;
+               private Object parent;
+
+               public LevelElem(String label, Object parent) {
+                       this.label = label;
+                       this.parent = parent;
+               }
+
+               public String toString() {
+                       return label;
+               }
+
+               public Object getParent() {
+                       return parent;
+               }
+       }
+
+       /** Export Package Section */
+       private void createExportPackageSection(Composite parent)
+                       throws RepositoryException {
+               parent.setLayout(new GridLayout());
+
+               // Define the TableViewer
+
+               Section section = addSection(parent, "Export packages");
+               section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+               TreeViewer viewer = new TreeViewer(section, SWT.H_SCROLL | SWT.V_SCROLL
+                               | SWT.BORDER);
+               final Tree tree = viewer.getTree();
+               tree.setHeaderVisible(false);
+               tree.setLinesVisible(true);
+               tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+               TreeViewerColumn col = new TreeViewerColumn(viewer, SWT.FILL);
+               col.getColumn().setWidth(400);
+
+               col.setLabelProvider(new ColumnLabelProvider() {
+                       @Override
+                       public String getText(Object element) {
+                               if (element instanceof Node)
+                                       return JcrUtils.get((Node) element, SlcNames.SLC_NAME);
+                               else
+                                       return element.toString();
+                       }
+
+                       @Override
+                       public Image getImage(Object element) {
+                               if (element instanceof Node) {
+                                       try {
+                                               Node node = (Node) element;
+                                               if (node.isNodeType(SlcTypes.SLC_EXPORTED_PACKAGE))
+                                                       return DistImages.IMG_PACKAGE;
+                                       } catch (RepositoryException e) {
+                                               throw new SlcException("Error retriving "
+                                                               + "image for the labelProvider", e);
+                                       }
+                               }
+                               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 {
+                                       if (parentElement instanceof LevelElem) {
+                                               Node node = (Node) ((LevelElem) parentElement)
+                                                               .getParent();
+                                               List<Node> nodes = JcrUtils
+                                                               .nodeIteratorToList(listNodes(node,
+                                                                               SlcTypes.SLC_JAVA_PACKAGE,
+                                                                               SlcNames.SLC_NAME));
+                                               return nodes.toArray();
+                                       } else if (parentElement instanceof Node) {
+                                               Node pNode = (Node) parentElement;
+                                               if (pNode.isNodeType(SlcTypes.SLC_EXPORTED_PACKAGE)) {
+                                                       if (listNodes(pNode, SlcTypes.SLC_JAVA_PACKAGE,
+                                                                       SlcNames.SLC_NAME).getSize() > 0) {
+                                                               Object[] result = { new LevelElem("uses", pNode) };
+                                                               return result;
+                                                       }
+                                               }
+                                       }
+                                       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 {
+                                       if (element instanceof LevelElem)
+                                               return true;
+                                       else {
+                                               Node pNode = (Node) element;
+                                               if (pNode.isNodeType(SlcTypes.SLC_EXPORTED_PACKAGE)) {
+                                                       return listNodes(pNode, SlcTypes.SLC_JAVA_PACKAGE,
+                                                                       SlcNames.SLC_NAME).getSize() > 0;
+                                               }
+                                       }
+                                       return false;
+                               } catch (RepositoryException e) {
+                                       throw new SlcException("Cannot check children Nodes", e);
+                               }
+                       }
+               });
+
+               section.setClient(tree);
+               viewer.setInput("Initialize");
+               // work around a display problem : the tree table has only a few lines
+               // when the tree is not expended
+               // viewer.expandToLevel(2);
+       }
+
+       /** Import Package Section */
+       private void createImportPackageSection(Composite parent)
+                       throws RepositoryException {
+               parent.setLayout(new GridLayout());
+
+               // Define the TableViewer
+               // toolkit.createLabel(parent, "Import packages", SWT.NONE).setFont(
+               // EclipseUiUtils.getBoldFont(parent));
+
+               Section section = addSection(parent, "Import packages");
+               section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+               TableViewer viewer = new TableViewer(section, SWT.H_SCROLL
+                               | SWT.V_SCROLL | SWT.BORDER);
+
+               final Table table = viewer.getTable();
+               table.setHeaderVisible(true);
+               table.setLinesVisible(true);
+               table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+               // Name
+               TableViewerColumn col = new TableViewerColumn(viewer, SWT.NONE);
+               col.getColumn().setWidth(350);
+               col.getColumn().setText("Name");
+               col.setLabelProvider(new ColumnLabelProvider() {
+                       @Override
+                       public String getText(Object element) {
+                               return JcrUtils.get((Node) element, SLC_NAME);
+                       }
+
+                       public Image getImage(Object element) {
+                               return DistImages.IMG_PACKAGE;
+                       }
+
+               });
+
+               // 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);
+                       }
+               });
+
+               viewer.setContentProvider(new TableContentProvider(
+                               SlcTypes.SLC_IMPORTED_PACKAGE, SLC_NAME));
+               section.setClient(table);
+               viewer.setInput("Initialize");
+       }
+
+       /** Required Bundle Section */
+       private void createReqBundleSection(Composite parent)
+                       throws RepositoryException {
+               parent.setLayout(new GridLayout());
+
+               // Define the TableViewer
+               Section section = addSection(parent, "Required bundles");
+               section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+               // toolkit.createLabel(parent, "Required bundles", SWT.NONE).setFont(
+               // EclipseUiUtils.getBoldFont(parent));
+               TableViewer viewer = new TableViewer(section, SWT.H_SCROLL
+                               | SWT.V_SCROLL | SWT.BORDER);
+
+               final Table table = viewer.getTable();
+               table.setHeaderVisible(true);
+               table.setLinesVisible(true);
+               table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+               // 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);
+                       }
+
+                       @Override
+                       public Image getImage(Object element) {
+                               return DistImages.IMG_BUNDLE;
+                       }
+               });
+
+               // Version
+               col = new TableViewerColumn(viewer, SWT.NONE);
+               col.getColumn().setWidth(140);
+               col.getColumn().setText("Version");
+               col.setLabelProvider(new ColumnLabelProvider() {
+                       @Override
+                       public String getText(Object element) {
+                               return JcrUtils.get((Node) element, SLC_BUNDLE_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);
+                       }
+               });
+
+               viewer.setContentProvider(new TableContentProvider(
+                               SlcTypes.SLC_REQUIRED_BUNDLE, SLC_SYMBOLIC_NAME));
+               section.setClient(table);
+               viewer.setInput("Initialize");
+       }
+
+       /**
+        * Build repository request
+        * 
+        * FIXME Workaround for remote repository, the path to bundleartifact (for
+        * instance
+        * .../org/argeo/slc/org.argeo.slc.client.ui.dist/1.1.12/org.argeo.slc
+        * .client.ui.dist-1.1.12/ ) is not valid for method factory.childNode(); it
+        * fails parsing the "1.1.12" part, trying to cast it as a BigDecimal
+        * 
+        * */
+       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();
+
+               String pattern = null;
+               if (SlcTypes.SLC_EXPORTED_PACKAGE.equals(nodeType))
+                       pattern = "slc:Export-Package*";
+               else if (SlcTypes.SLC_JAVA_PACKAGE.equals(nodeType))
+                       pattern = "slc:uses*";
+               else if (SlcTypes.SLC_IMPORTED_PACKAGE.equals(nodeType))
+                       pattern = "slc:Import-Package*";
+               else if (SlcTypes.SLC_REQUIRED_BUNDLE.equals(nodeType))
+                       pattern = "slc:Require-Bundle*";
+
+               return parent.getNodes(pattern);
+       }
+
+       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 Section addSection(Composite parent, String title) {
+               Section section = toolkit.createSection(parent, Section.TITLE_BAR);
+               section.setText(title);
+               section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+               return section;
+       }
+
+}
\ 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/BundleDetailPage.java b/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/BundleDetailPage.java
new file mode 100644 (file)
index 0000000..43f3dda
--- /dev/null
@@ -0,0 +1,268 @@
+/*
+ * 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 javax.jcr.Node;
+import javax.jcr.RepositoryException;
+
+import org.argeo.ArgeoException;
+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.repo.RepoConstants;
+import org.argeo.slc.repo.RepoUtils;
+import org.eclipse.jface.dialogs.IMessageProvider;
+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.Label;
+import org.eclipse.swt.widgets.Text;
+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;
+
+/**
+ * Show the details for a given bundle.
+ */
+public class BundleDetailPage extends FormPage implements SlcNames {
+
+       final static String PAGE_ID = "BundleDetailPage";
+
+       // Business Objects
+       private Node bundle;
+
+       // This page widgets
+       private FormToolkit tk;
+
+       public BundleDetailPage(FormEditor formEditor, String title, Node bundle) {
+               super(formEditor, PAGE_ID, title);
+               this.bundle = bundle;
+       }
+
+       @Override
+       protected void createFormContent(IManagedForm managedForm) {
+               // General settings for this page
+               ScrolledForm form = managedForm.getForm();
+               tk = managedForm.getToolkit();
+               Composite body = form.getBody();
+
+               GridLayout layout = new GridLayout(1, false);
+               layout.marginWidth = 5;
+               layout.marginRight = 15;
+               layout.verticalSpacing = 0;
+               body.setLayout(layout);
+               try {
+                       form.setText(bundle.hasProperty(SlcNames.SLC_SYMBOLIC_NAME) ? bundle
+                                       .getProperty(SlcNames.SLC_SYMBOLIC_NAME).getString() : "");
+                       form.setMessage(bundle
+                                       .hasProperty(DistConstants.SLC_BUNDLE_DESCRIPTION) ? bundle
+                                       .getProperty(DistConstants.SLC_BUNDLE_DESCRIPTION)
+                                       .getString() : "", IMessageProvider.NONE);
+               } catch (RepositoryException re) {
+                       throw new SlcException("Unable to get bundle name for node "
+                                       + bundle, re);
+               }
+
+               // Main layout
+               Composite header = tk.createComposite(body);
+               header.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
+               populateHeaderPart(header);
+
+               Composite mavenSnipet = tk.createComposite(body);
+               mavenSnipet.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+               populateMavenSnippetPart(mavenSnipet);
+       }
+
+       private void populateHeaderPart(Composite parent) {
+               GridLayout layout = new GridLayout(6, false);
+               // layout.marginWidth = layout.horizontalSpacing = layout.marginHeight =
+               // 0;
+               layout.horizontalSpacing = 10;
+               parent.setLayout(layout);
+               try {
+                       // 1st Line: Category, name version
+                       createLT(parent, "Category",
+                                       bundle.hasProperty(SlcNames.SLC_GROUP_ID) ? bundle
+                                                       .getProperty(SlcNames.SLC_GROUP_ID).getString()
+                                                       : "");
+                       createLT(parent, "Name",
+                                       bundle.hasProperty(SlcNames.SLC_ARTIFACT_ID) ? bundle
+                                                       .getProperty(SlcNames.SLC_ARTIFACT_ID).getString()
+                                                       : "");
+                       createLT(parent, "Version",
+                                       bundle.hasProperty(SlcNames.SLC_ARTIFACT_VERSION) ? bundle
+                                                       .getProperty(SlcNames.SLC_ARTIFACT_VERSION)
+                                                       .getString() : "");
+
+                       // 2nd Line: Vendor, licence, sources
+                       createLT(
+                                       parent,
+                                       "Vendor",
+                                       bundle.hasProperty(DistConstants.SLC_BUNDLE_VENDOR) ? bundle
+                                                       .getProperty(DistConstants.SLC_BUNDLE_VENDOR)
+                                                       .getString() : "N/A");
+
+                       createHyperlink(parent, "Licence", DistConstants.SLC_BUNDLE_LICENCE);
+                       addSourceSourcesLink(parent);
+               } catch (RepositoryException re) {
+                       throw new SlcException("Unable to get bundle name for node "
+                                       + bundle, re);
+               }
+
+       }
+
+       private void populateMavenSnippetPart(Composite parent) {
+               GridLayout layout = new GridLayout(1, false);
+               layout.marginWidth = layout.horizontalSpacing = layout.horizontalSpacing = layout.marginHeight = 0;
+               parent.setLayout(layout);
+
+               Section section = tk.createSection(parent, Section.TITLE_BAR
+                               | Section.DESCRIPTION);
+               section.setText("Maven");
+               section.setDescription("Copy Paste the below snippet "
+                               + "to use it in your code.");
+               section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+               Text snippetTxt = createMavenSnippet(section);
+               section.setClient(snippetTxt);
+       }
+
+       // /////////////////////
+       // HELPERS
+
+       private Text createLT(Composite parent, String labelValue, String textValue) {
+               Label label = tk.createLabel(parent, labelValue, SWT.RIGHT);
+               // label.setFont(EclipseUiUtils.getBoldFont(parent));
+               label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
+               // Add a trailing space to workaround a display glitch in RAP 1.3
+               Text text = new Text(parent, SWT.LEFT);
+               text.setText(textValue + " ");
+               text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+               text.setEditable(false);
+               return text;
+       }
+
+       private void createHyperlink(Composite parent, String label,
+                       String jcrPropName) throws RepositoryException {
+               tk.createLabel(parent, label, SWT.NONE);
+               if (bundle.hasProperty(jcrPropName)) {
+                       final Hyperlink link = tk.createHyperlink(parent, bundle
+                                       .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
+                       tk.createLabel(parent, "N/A", SWT.NONE);
+       }
+
+       // helper to check if sources are available
+       private void addSourceSourcesLink(Composite parent) {
+               try {
+                       String srcPath = RepoUtils.relatedPdeSourcePath(
+                                       RepoConstants.DEFAULT_ARTIFACTS_BASE_PATH, bundle);
+                       if (!bundle.getSession().nodeExists(srcPath)) {
+                               createLT(parent, "Sources", "N/A");
+                       } else {
+                               Node sourcesNode = bundle.getSession().getNode(srcPath);
+
+                               String srcName = null;
+                               if (sourcesNode.hasProperty(SlcNames.SLC_SYMBOLIC_NAME))
+                                       srcName = sourcesNode.getProperty(
+                                                       SlcNames.SLC_SYMBOLIC_NAME).getString();
+                               else
+                                       srcName = sourcesNode.getName();
+                               Label label = tk.createLabel(parent, "Sources", SWT.RIGHT);
+                               label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false,
+                                               false));
+                               final Hyperlink link = tk.createHyperlink(parent, srcName,
+                                               SWT.NONE);
+                               link.addHyperlinkListener(new AbstractHyperlinkListener() {
+                                       @Override
+                                       public void linkActivated(HyperlinkEvent e) {
+                                               try {
+                                                       System.out.println("CLICK on Sources link");
+                                               } catch (Exception ex) {
+                                                       throw new SlcException("error opening browser", ex); //$NON-NLS-1$
+                                               }
+                                       }
+                               });
+
+                       }
+               } catch (RepositoryException e) {
+                       throw new SlcException("Unable to configure sources link for "
+                                       + bundle, e);
+               }
+       }
+
+       /** Creates a text area with corresponding maven snippet */
+       private Text createMavenSnippet(Composite parent) {
+               Text mavenSnippet = new Text(parent, SWT.MULTI | SWT.WRAP);
+               GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+               gd.grabExcessHorizontalSpace = true;
+               gd.heightHint = 100;
+               mavenSnippet.setLayoutData(gd);
+               mavenSnippet.setText(generateXmlSnippet());
+               return mavenSnippet;
+       }
+
+       private String generateXmlSnippet() {
+               try {
+                       StringBuffer sb = new StringBuffer();
+                       sb.append("<dependency>\n");
+                       sb.append("\t<groupId>");
+                       sb.append(bundle.getProperty(SLC_GROUP_ID).getString());
+                       sb.append("</groupId>\n");
+                       sb.append("\t<artifactId>");
+                       sb.append(bundle.getProperty(SLC_ARTIFACT_ID).getString());
+                       sb.append("</artifactId>\n");
+                       sb.append("\t<version>");
+                       sb.append(bundle.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/BundleDetailsPage.java b/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/BundleDetailsPage.java
deleted file mode 100644 (file)
index e34c2db..0000000
+++ /dev/null
@@ -1,562 +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.net.URL;
-import java.util.List;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.RepositoryException;
-
-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.utils.AbstractHyperlinkListener;
-import org.argeo.slc.jcr.SlcNames;
-import org.argeo.slc.jcr.SlcTypes;
-import org.argeo.slc.repo.RepoConstants;
-import org.argeo.slc.repo.RepoUtils;
-import org.eclipse.jface.dialogs.IMessageProvider;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-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.Button;
-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;
-
-/**
- * Present 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()
-                                       : "");
-                       form.setMessage(" ", IMessageProvider.NONE);
-                       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);
-                       createMavenSnippet(body);
-
-               } catch (RepositoryException e) {
-                       throw new SlcException("unexpected error "
-                                       + "while creating bundle details page");
-               }
-       }
-
-       /** Displays 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);
-               addSourceAvailableLabel(details);
-       }
-
-       // helper to check if sources are available
-       private void addSourceAvailableLabel(Composite parent) {
-               Button srcChk = toolkit.createButton(parent, "Sources available",
-                               SWT.CHECK);
-               srcChk.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1));
-
-               try {
-                       String srcPath = RepoUtils.relatedPdeSourcePath(
-                                       RepoConstants.DEFAULT_ARTIFACTS_BASE_PATH, currBundle);
-                       srcChk.setSelection(currBundle.getSession().nodeExists(srcPath));
-               } catch (RepositoryException e) {
-                       throw new SlcException("Unable to check sources", e);
-               }
-               srcChk.setEnabled(false);
-       }
-
-       // Workaround to add an artificial level to the export package browser
-       private class LevelElem {
-               private String label;
-               private Object parent;
-
-               public LevelElem(String label, Object parent) {
-                       this.label = label;
-                       this.parent = parent;
-               }
-
-               public String toString() {
-                       return label;
-               }
-
-               public Object getParent() {
-                       return parent;
-               }
-       }
-
-       /** Export 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(400);
-
-               col.setLabelProvider(new ColumnLabelProvider() {
-                       @Override
-                       public String getText(Object element) {
-                               if (element instanceof Node)
-                                       return JcrUtils.get((Node) element, SlcNames.SLC_NAME);
-                               else
-                                       return element.toString();
-                       }
-
-                       @Override
-                       public Image getImage(Object element) {
-                               if (element instanceof Node) {
-                                       try {
-                                               Node node = (Node) element;
-                                               if (node.isNodeType(SlcTypes.SLC_EXPORTED_PACKAGE))
-                                                       return DistImages.IMG_PACKAGE;
-                                       } catch (RepositoryException e) {
-                                               throw new SlcException("Error retriving "
-                                                               + "image for the labelProvider", e);
-                                       }
-                               }
-                               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 {
-                                       if (parentElement instanceof LevelElem) {
-                                               Node node = (Node) ((LevelElem) parentElement)
-                                                               .getParent();
-                                               List<Node> nodes = JcrUtils
-                                                               .nodeIteratorToList(listNodes(node,
-                                                                               SlcTypes.SLC_JAVA_PACKAGE,
-                                                                               SlcNames.SLC_NAME));
-                                               return nodes.toArray();
-                                       } else if (parentElement instanceof Node) {
-                                               Node pNode = (Node) parentElement;
-                                               if (pNode.isNodeType(SlcTypes.SLC_EXPORTED_PACKAGE)) {
-                                                       if (listNodes(pNode, SlcTypes.SLC_JAVA_PACKAGE,
-                                                                       SlcNames.SLC_NAME).getSize() > 0) {
-                                                               Object[] result = { new LevelElem("uses", pNode) };
-                                                               return result;
-                                                       }
-                                               }
-                                       }
-                                       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 {
-                                       if (element instanceof LevelElem)
-                                               return true;
-                                       else {
-                                               Node pNode = (Node) element;
-                                               if (pNode.isNodeType(SlcTypes.SLC_EXPORTED_PACKAGE)) {
-                                                       return listNodes(pNode, SlcTypes.SLC_JAVA_PACKAGE,
-                                                                       SlcNames.SLC_NAME).getSize() > 0;
-                                               }
-                                       }
-                                       return false;
-                               } catch (RepositoryException e) {
-                                       throw new SlcException("Cannot check children Nodes", e);
-                               }
-                       }
-               });
-
-               headerSection.setClient(tree);
-               viewer.setInput("Initialize");
-               // work around a display problem : the tree table has only a few lines
-               // when the tree is not expended
-               viewer.expandToLevel(3);
-       }
-
-       /** 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(350);
-               col.getColumn().setText("Name");
-               col.setLabelProvider(new ColumnLabelProvider() {
-                       @Override
-                       public String getText(Object element) {
-                               return JcrUtils.get((Node) element, SLC_NAME);
-                       }
-
-                       public Image getImage(Object element) {
-                               return DistImages.IMG_PACKAGE;
-                       }
-
-               });
-
-               // 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);
-                       }
-
-                       @Override
-                       public Image getImage(Object element) {
-                               return DistImages.IMG_BUNDLE;
-                       }
-               });
-
-               // Version
-               col = new TableViewerColumn(viewer, SWT.NONE);
-               col.getColumn().setWidth(140);
-               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
-        * 
-        * FIXME Workaround for remote repository, the path to bundleartifact (for
-        * instance
-        * .../org/argeo/slc/org.argeo.slc.client.ui.dist/1.1.12/org.argeo.slc
-        * .client.ui.dist-1.1.12/ ) is not valid for method factory.childNode(); it
-        * fails parsing the "1.1.12" part, trying to cast it as a BigDecimal
-        * 
-        * */
-       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();
-
-               String pattern = null;
-               if (SlcTypes.SLC_EXPORTED_PACKAGE.equals(nodeType))
-                       pattern = "slc:Export-Package*";
-               else if (SlcTypes.SLC_JAVA_PACKAGE.equals(nodeType))
-                       pattern = "slc:uses*";
-               else if (SlcTypes.SLC_IMPORTED_PACKAGE.equals(nodeType))
-                       pattern = "slc:Import-Package*";
-               else if (SlcTypes.SLC_REQUIRED_BUNDLE.equals(nodeType))
-                       pattern = "slc:Require-Bundle*";
-
-               return parent.getNodes(pattern);
-       }
-
-       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 createMavenSnippet(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<groupId>");
-                       sb.append(currBundle.getProperty(SLC_GROUP_ID).getString());
-                       sb.append("</groupId>\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
index 1c3a9fd5c28acf1043f22a3c555f1565444e50ff..3656019fd03b77cd43a3fed83817e53076a1fa01 100644 (file)
@@ -16,7 +16,9 @@
 package org.argeo.slc.client.ui.dist.editors;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import javax.jcr.Node;
 import javax.jcr.NodeIterator;
@@ -29,12 +31,12 @@ 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.utils.CommandUtils;
 import org.argeo.jcr.JcrUtils;
 import org.argeo.slc.SlcException;
 import org.argeo.slc.client.ui.dist.DistConstants;
 import org.argeo.slc.client.ui.dist.DistImages;
-import org.argeo.slc.client.ui.dist.DistPlugin;
+import org.argeo.slc.client.ui.dist.commands.OpenModuleEditor;
 import org.argeo.slc.jcr.SlcNames;
 import org.argeo.slc.jcr.SlcTypes;
 import org.argeo.slc.repo.RepoConstants;
@@ -51,7 +53,6 @@ import org.eclipse.swt.layout.FillLayout;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Tree;
 import org.eclipse.swt.widgets.TreeColumn;
-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;
@@ -119,7 +120,7 @@ public class DistWkspBrowserPage extends FormPage implements DistConstants,
                int style = SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL
                                | SWT.FULL_SELECTION | SWT.BORDER;
                Tree tree = new Tree(parent, style);
-               createColumn(tree, "Artifacts", SWT.LEFT, 300);
+               createColumn(tree, "Artifacts", SWT.LEFT, 450);
                tree.setLinesVisible(true);
                tree.setHeaderVisible(true);
 
@@ -242,35 +243,39 @@ public class DistWkspBrowserPage extends FormPage implements DistConstants,
                public void doubleClick(DoubleClickEvent event) {
                        Object obj = ((IStructuredSelection) event.getSelection())
                                        .getFirstElement();
-                       try {
-                               if (obj instanceof Node) {
-                                       Node node = (Node) obj;
+                       if (obj instanceof Node) {
+                               Node node = (Node) obj;
+                               try {
                                        if (node.isNodeType(SlcTypes.SLC_ARTIFACT_VERSION_BASE)) {
-                                               // TODO fix using QOM after jcr upgrade
-                                               NodeIterator ni = node.getNodes();
-                                               while (ni.hasNext()) {
-                                                       Node curr = ni.nextNode();
-                                                       if (curr.isNodeType(SlcTypes.SLC_BUNDLE_ARTIFACT)) {
-                                                               GenericBundleEditorInput gaei = new GenericBundleEditorInput(
-                                                                               curr);
-                                                               DistPlugin
-                                                                               .getDefault()
-                                                                               .getWorkbench()
-                                                                               .getActiveWorkbenchWindow()
-                                                                               .getActivePage()
-                                                                               .openEditor(gaei,
-                                                                                               GenericBundleEditor.ID);
+                                               NodeIterator nit = node.getNodes();
+                                               while (nit.hasNext()) {
+                                                       Node curr = nit.nextNode();
+                                                       if (curr.isNodeType(SlcTypes.SLC_ARTIFACT)) {
+                                                               node = curr;
+                                                               break;
                                                        }
                                                }
                                        }
+
+                                       if (node.isNodeType(SlcTypes.SLC_ARTIFACT)) {
+                                               DistWkspEditorInput dwip = (DistWkspEditorInput) getEditorInput();
+                                               Map<String, String> params = new HashMap<String, String>();
+                                               params.put(OpenModuleEditor.PARAM_REPO_NODE_PATH,
+                                                               dwip.getRepoNodePath());
+                                               params.put(OpenModuleEditor.PARAM_REPO_URI,
+                                                               dwip.getUri());
+                                               params.put(OpenModuleEditor.PARAM_WORKSPACE_NAME,
+                                                               dwip.getWorkspaceName());
+                                               String path = node.getPath();
+                                               params.put(OpenModuleEditor.PARAM_MODULE_PATH, path);
+                                               CommandUtils.callCommand(OpenModuleEditor.ID, params);
+                                       }
+                               } catch (RepositoryException re) {
+                                       throw new SlcException("Cannot get path for node " + node
+                                                       + " while setting parameters for "
+                                                       + "command OpenModuleEditor", re);
                                }
-                       } 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);
+
                        }
                }
        }
index 1228edfed051f18d8d8c02eda93cb67bf977dd0a..8ce3fe12dd330b01b38f16f04290a85d204088dc 100644 (file)
@@ -39,7 +39,6 @@ import javax.jcr.query.qom.StaticOperand;
 
 import org.argeo.ArgeoMonitor;
 import org.argeo.eclipse.ui.EclipseArgeoMonitor;
-import org.argeo.eclipse.ui.EclipseUiUtils;
 import org.argeo.eclipse.ui.utils.CommandUtils;
 import org.argeo.jcr.JcrUtils;
 import org.argeo.slc.SlcException;
@@ -87,6 +86,7 @@ import org.eclipse.ui.forms.IManagedForm;
 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;
 
 /** Show all bundles contained in a given workspace as filter-able table */
 public class DistWkspSearchPage extends FormPage implements SlcNames {
@@ -107,7 +107,7 @@ public class DistWkspSearchPage extends FormPage implements SlcNames {
 
        // private Composite header;
        private Text artifactTxt;
-       private final static String FILTER_HELP_MSG = "Search bundles in the current workspace";
+       private final static String FILTER_HELP_MSG = "Filter criterion, separated by a space";
 
        public DistWkspSearchPage(DistWorkspaceEditor formEditor, String title,
                        Session session) {
@@ -171,7 +171,59 @@ public class DistWkspSearchPage extends FormPage implements SlcNames {
                header.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
                createHeaderPart(form, header);
 
-               // filter text
+               Composite modules = tk.createComposite(body);
+               modules.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+               populateModuleSection(modules);
+       }
+
+       private void createHeaderPart(ScrolledForm form, Composite parent) {
+               GridLayout layout = new GridLayout(4, false);
+               // layout.marginWidth = layout.marginHeight = layout.verticalSpacing =
+               // 0;
+               // layout.horizontalSpacing = 2;
+               parent.setLayout(layout);
+
+               String wkspName = ((DistWkspEditorInput) getEditorInput())
+                               .getWorkspaceName();
+               wkspName = wkspName.replaceAll("-", " ");
+               form.setText(wkspName);
+
+               String repoAlias = "";
+               Node repoNode = ((DistWorkspaceEditor) getEditor()).getRepoNode();
+               if (repoNode != null)
+                       try {
+                               repoAlias = repoNode.isNodeType(NodeType.MIX_TITLE) ? repoNode
+                                               .getProperty(Property.JCR_TITLE).getString() : repoNode
+                                               .getName();
+                       } catch (RepositoryException e1) {
+                               throw new SlcException("Unable to get repository alias ", e1);
+                       }
+               else
+                       repoAlias = " - ";
+
+               createLT(parent, "Repository alias", repoAlias);
+               createLT(parent, "URI",
+                               ((DistWkspEditorInput) getEditorInput()).getUri());
+       }
+
+       private void populateModuleSection(Composite parent) {
+               GridLayout layout = new GridLayout(1, false);
+               layout.marginWidth = layout.horizontalSpacing = layout.horizontalSpacing = layout.marginHeight = 0;
+               parent.setLayout(layout);
+
+               Section section = tk.createSection(parent, Section.TITLE_BAR
+                               | Section.DESCRIPTION);
+               section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+               section.setText("Artifacts");
+               section.setDescription("Search among all artifacts that are referenced in the current workspace");
+               section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+               Composite body = tk.createComposite(section);
+               layout = new GridLayout(1, false);
+               layout.marginWidth = layout.horizontalSpacing = layout.horizontalSpacing = layout.marginHeight = 0;
+               body.setLayout(new GridLayout());
+
                Composite filter = tk.createComposite(body);
                filter.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
                createFilterPart(filter);
@@ -180,6 +232,8 @@ public class DistWkspSearchPage extends FormPage implements SlcNames {
                Composite tableCmp = tk.createComposite(body);
                tableCmp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
                createTableViewer(tableCmp);
+
+               section.setClient(body);
        }
 
        /** Build repository request */
@@ -241,47 +295,15 @@ public class DistWkspSearchPage extends FormPage implements SlcNames {
 
        }
 
-       private void createHeaderPart(ScrolledForm form, Composite parent) {
-               GridLayout layout = new GridLayout(4, false);
-               layout.marginWidth = layout.marginHeight = layout.verticalSpacing = 0;
-               layout.horizontalSpacing = 5;
-               parent.setLayout(layout);
-
-               String wkspName = ((DistWkspEditorInput) getEditorInput())
-                               .getWorkspaceName();
-               // wkspName = "Workspace " + wkspName;
-               form.setText(wkspName);
-
-               // form.setMessage("Choose in the below list "
-               // + "the categories that can be used as base for "
-               // + "modular distributions maintained via the current workspace",
-               // IMessageProvider.NONE);
-
-               String repoAlias = "";
-               Node repoNode = ((DistWorkspaceEditor) getEditor()).getRepoNode();
-               if (repoNode != null)
-                       try {
-                               repoAlias = repoNode.isNodeType(NodeType.MIX_TITLE) ? repoNode
-                                               .getProperty(Property.JCR_TITLE).getString() : repoNode
-                                               .getName();
-                       } catch (RepositoryException e1) {
-                               throw new SlcException("Unable to get repository alias ", e1);
-                       }
-               else
-                       repoAlias = " - ";
-
-               createLT(parent, "Repository alias", repoAlias);
-               createLT(parent, "URI",
-                               ((DistWkspEditorInput) getEditorInput()).getUri());
-       }
-
        private Text createLT(Composite parent, String labelValue, String textValue) {
-               Label label = tk.createLabel(parent, labelValue, SWT.RIGHT);
-               label.setFont(EclipseUiUtils.getBoldFont(parent));
+               Label label = new Label(parent, SWT.RIGHT);
+               label.setText(labelValue);
+               // label.setFont(EclipseUiUtils.getBoldFont(parent));
                label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
 
                // Add a trailing space to workaround a display glitch in RAP 1.3
-               Text text = tk.createText(parent, textValue + " ", SWT.LEFT);
+               Text text = new Text(parent, SWT.LEFT); // | SWT.BORDER
+               text.setText(textValue + " ");
                text.setEditable(false);
                return text;
        }
diff --git a/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/DistributionEditor.java b/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/DistributionEditor.java
deleted file mode 100644 (file)
index 1e3be13..0000000
+++ /dev/null
@@ -1,83 +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.RepositoryException;
-import javax.jcr.Session;
-
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.jcr.SlcNames;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorSite;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.forms.editor.FormEditor;
-
-/**
- * Browse, analyse and modify an OSGi distribution
- */
-public class DistributionEditor extends FormEditor implements SlcNames {
-       // private final static Log log =
-       // LogFactory.getLog(DistributionEditor.class);
-       public final static String ID = DistPlugin.ID + ".distributionEditor";
-
-       private Session session;
-
-       @Override
-       public void init(IEditorSite site, IEditorInput input)
-                       throws PartInitException {
-               DistributionEditorInput dei = (DistributionEditorInput) input;
-               try {
-                       session = dei.getRepository().login(dei.getCredentials(),
-                                       dei.getWorkspaceName());
-               } catch (RepositoryException e) {
-                       throw new PartInitException("Cannot log to workspace "
-                                       + dei.getWorkspaceName(), e);
-               }
-               setPartName(dei.getWorkspaceName());
-               super.init(site, input);
-       }
-
-       @Override
-       protected void addPages() {
-               // try {
-               // addPage(new DistWkspSearchPage(this, "Overview", session));
-               // addPage(new DistWkspBrowserPage(this, "Browser", session));
-               // } catch (PartInitException e) {
-               // throw new ArgeoException("Cannot add distribution editor pages", e);
-               // }
-       }
-
-       @Override
-       public void doSave(IProgressMonitor arg0) {
-       }
-
-       @Override
-       public void dispose() {
-               JcrUtils.logoutQuietly(session);
-               super.dispose();
-       }
-
-       @Override
-       public void doSaveAs() {
-       }
-
-       @Override
-       public boolean isSaveAsAllowed() {
-               return false;
-       }
-}
\ 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/DistributionEditorInput.java b/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/DistributionEditorInput.java
deleted file mode 100644 (file)
index 323e9ee..0000000
+++ /dev/null
@@ -1,121 +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.Credentials;
-import javax.jcr.Repository;
-
-import org.argeo.slc.jcr.SlcNames;
-import org.argeo.slc.repo.RepoConstants;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IPersistableElement;
-
-/**
- * An editor input pointing to a distribution
- * */
-public class DistributionEditorInput implements IEditorInput, SlcNames {
-
-       private Repository repository;
-       private Credentials credentials;
-       private String repositoryName;
-       private String repositoryDescription;
-       private String workspaceName;
-
-       private String artifactsBase;
-
-       public DistributionEditorInput(Repository repository,
-                       Credentials credentials, String repositoryName,
-                       String repositoryDescription, String workspaceName,
-                       String artifactsBase) {
-               super();
-               this.repository = repository;
-               this.repositoryName = repositoryName;
-               this.repositoryDescription = repositoryDescription;
-               this.workspaceName = workspaceName;
-               this.artifactsBase = artifactsBase;
-               this.credentials = credentials;
-       }
-
-       public DistributionEditorInput(Repository repository,
-                       Credentials credentials, String repositoryName,
-                       String repositoryDescription, String workspaceName) {
-               this(repository, credentials, repositoryName, repositoryDescription,
-                               workspaceName, RepoConstants.DEFAULT_ARTIFACTS_BASE_PATH);
-       }
-
-       public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
-               return null;
-       }
-
-       public boolean exists() {
-               return true;
-       }
-
-       public ImageDescriptor getImageDescriptor() {
-               return null;
-       }
-
-       // Dummy compulsory methods
-       public String getToolTipText() {
-               return workspaceName;
-       }
-
-       public String getName() {
-               return workspaceName;
-       }
-
-       public IPersistableElement getPersistable() {
-               return null;
-       }
-
-       public boolean equals(Object obj) {
-               if (this == obj)
-                       return true;
-               if (obj == null)
-                       return false;
-               if (!(obj instanceof DistributionEditorInput))
-                       return false;
-
-               DistributionEditorInput other = (DistributionEditorInput) obj;
-               return getRepository().equals(other.getRepository())
-                               && getWorkspaceName().equals(other.getWorkspaceName());
-       }
-
-       public Repository getRepository() {
-               return repository;
-       }
-
-       public String getWorkspaceName() {
-               return workspaceName;
-       }
-
-       public String getArtifactsBase() {
-               return artifactsBase;
-       }
-
-       public String getRepositoryName() {
-               return repositoryName;
-       }
-
-       public String getRepositoryDescription() {
-               return repositoryDescription;
-       }
-
-       public Credentials getCredentials() {
-               return credentials;
-       }
-}
\ 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/GenericBundleEditor.java b/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/GenericBundleEditor.java
deleted file mode 100644 (file)
index 7429ed0..0000000
+++ /dev/null
@@ -1,86 +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;
-
-/**
- * Expose 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, "Raw info", bundleNode);
-                       addPage(bundleRawPage);
-               } catch (PartInitException e) {
-                       throw new ArgeoException("Not able to add an empty page ", e);
-               }
-       }
-
-       @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);
-               }
-
-       }
-
-       // unused compulsory methods
-       @Override
-       public boolean isSaveAsAllowed() {
-               return false;
-       }
-
-       @Override
-       public void doSaveAs() {
-       }
-
-}
\ 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/GenericBundleEditorInput.java b/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/GenericBundleEditorInput.java
deleted file mode 100644 (file)
index fb9412e..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 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/editors/GroupBaseEditorInput.java b/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/GroupBaseEditorInput.java
deleted file mode 100644 (file)
index f319a1c..0000000
+++ /dev/null
@@ -1,65 +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 org.argeo.slc.SlcException;
-
-/**
- * An editor input pointing to a given group base in a distribution workspace
- */
-public class GroupBaseEditorInput extends DistWkspEditorInput {
-
-       private final String groupBaseId;
-
-       /** uri, workspace name and group base Id cannot be null */
-       public GroupBaseEditorInput(String repoNodePath, String uri,
-                       String workspaceName, String groupBaseId) {
-               super(repoNodePath, uri, workspaceName);
-               if (groupBaseId == null)
-                       throw new SlcException("Group base ID cannot be null");
-               this.groupBaseId = groupBaseId;
-       }
-
-       public String getToolTipText() {
-               return "Editor for group base of ID " + groupBaseId + " in workspace "
-                               + getWorkspaceName() + " in " + getUri();
-       }
-
-       public String getName() {
-               return groupBaseId;
-       }
-
-       public boolean equals(Object obj) {
-               if (this == obj)
-                       return true;
-               if (obj == null)
-                       return false;
-               if (!(obj instanceof GroupBaseEditorInput))
-                       return false;
-
-               GroupBaseEditorInput other = (GroupBaseEditorInput) obj;
-
-               if (groupBaseId.equals(other.getGroupBaseId()))
-                       return super.equals(obj);
-               else
-                       return false;
-       }
-
-       public String getGroupBaseId() {
-               return groupBaseId;
-       }
-
-}
\ No newline at end of file
diff --git a/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/ModularDistVersionDetailPage.java b/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/ModularDistVersionDetailPage.java
new file mode 100644 (file)
index 0000000..4326da4
--- /dev/null
@@ -0,0 +1,134 @@
+/*
+ * 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.SlcException;
+import org.argeo.slc.jcr.SlcNames;
+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.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;
+
+/**
+ * Show the details for a given bundle.
+ */
+public class ModularDistVersionDetailPage extends FormPage implements SlcNames {
+
+       final static String PAGE_ID = "ModularDistVersionDetailPage";
+
+       // Business Objects
+       private Node modularDistVersion;
+
+       // This page widgets
+       private FormToolkit tk;
+
+       public ModularDistVersionDetailPage(FormEditor formEditor, String title,
+                       Node modularDistVersion) {
+               super(formEditor, PAGE_ID, title);
+               this.modularDistVersion = modularDistVersion;
+       }
+
+       @Override
+       protected void createFormContent(IManagedForm managedForm) {
+               // General settings for this page
+               ScrolledForm form = managedForm.getForm();
+               tk = managedForm.getToolkit();
+               Composite body = form.getBody();
+
+               GridLayout layout = new GridLayout(1, false);
+               layout.marginWidth = 5;
+               layout.marginRight = 15;
+               layout.verticalSpacing = 0;
+               body.setLayout(layout);
+               try {
+                       form.setText(modularDistVersion.hasProperty(SLC_NAME) ? modularDistVersion
+                                       .getProperty(SLC_NAME).getString() : "");
+               } catch (RepositoryException re) {
+                       throw new SlcException("Unable to get slc:name for node "
+                                       + modularDistVersion, re);
+               }
+
+               // Main layout
+               Composite mavenSnipet = tk.createComposite(body);
+               mavenSnipet.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+               populateMavenSnippetPart(mavenSnipet);
+       }
+
+       private void populateMavenSnippetPart(Composite parent) {
+               GridLayout layout = new GridLayout(1, false);
+               layout.marginWidth = layout.horizontalSpacing = layout.horizontalSpacing = layout.marginHeight = 0;
+               parent.setLayout(layout);
+
+               Section section = tk.createSection(parent, Section.TITLE_BAR
+                               | Section.DESCRIPTION);
+               section.setText("Maven");
+               section.setDescription("In order to rely on the versions defined by this distribution, "
+                               + "add the below tag to the dependency management of your parent pom.");
+               section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+               Text snippetTxt = createMavenSnippet(section);
+               section.setClient(snippetTxt);
+       }
+
+       // /////////////////////
+       // HELPERS
+       /** Creates a text area with corresponding maven snippet */
+       private Text createMavenSnippet(Composite parent) {
+               Text mavenSnippet = new Text(parent, SWT.MULTI | SWT.WRAP);
+               GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+               gd.grabExcessHorizontalSpace = true;
+               gd.heightHint = 100;
+               mavenSnippet.setLayoutData(gd);
+               mavenSnippet.setText(generateXmlSnippet());
+               mavenSnippet.setEditable(false);
+               return mavenSnippet;
+       }
+
+       private String generateXmlSnippet() {
+               try {
+                       StringBuffer sb = new StringBuffer();
+                       sb.append("<dependency>\n");
+                       sb.append("\t<groupId>");
+                       sb.append(modularDistVersion.getProperty(SLC_GROUP_ID).getString());
+                       sb.append("</groupId>\n");
+                       sb.append("\t<artifactId>");
+                       sb.append(modularDistVersion.getProperty(SLC_ARTIFACT_ID)
+                                       .getString());
+                       sb.append("</artifactId>\n");
+                       sb.append("\t<version>");
+                       sb.append(modularDistVersion.getProperty(SLC_ARTIFACT_VERSION)
+                                       .getString());
+                       sb.append("</version>\n");
+                       sb.append("\t<type>pom</type>\n");
+                       sb.append("\t<scope>import</scope>\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
index 284347bc370e407668c839a72159582a3f9e432a..6f25f2a84fb8c772157ec4ab208125bb0ba943bd 100644 (file)
@@ -40,15 +40,15 @@ public class ModularDistVersionEditor extends ArtifactVersionEditor {
 
        @Override
        protected void addPages() {
+               setPartName(getFormattedName());
                try {
                        addPage(new ModularDistVersionOverviewPage(this, "Modules ",
                                        getArtifact()));
                        addPage(new RunInOsgiPage(this, "Run as OSGi ", getArtifact()));
-                       super.addPages();
+                       addPage(new ModularDistVersionDetailPage(this, "Details",
+                                       getArtifact()));
                } catch (PartInitException e) {
                        throw new SlcException("Cannot add distribution editor pages", e);
-                       // } catch (RepositoryException e) {
-                       // throw new SlcException("Cannot get artifact session", e);
                }
        }
 
index fb8229672aa1becae714bef38bc74245df3c1a1a..da537380af6ee52c4d9ea273efb57eb5c327a396 100644 (file)
@@ -17,7 +17,9 @@ package org.argeo.slc.client.ui.dist.editors;
 
 import java.net.URL;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import javax.jcr.Node;
 import javax.jcr.NodeIterator;
@@ -33,24 +35,19 @@ import javax.jcr.query.qom.QueryObjectModelFactory;
 import javax.jcr.query.qom.Selector;
 import javax.jcr.query.qom.StaticOperand;
 
-import org.argeo.ArgeoException;
 import org.argeo.eclipse.ui.EclipseUiUtils;
 import org.argeo.eclipse.ui.utils.CommandUtils;
 import org.argeo.jcr.JcrUtils;
 import org.argeo.slc.SlcException;
 import org.argeo.slc.client.ui.dist.DistConstants;
 import org.argeo.slc.client.ui.dist.DistImages;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.client.ui.dist.commands.DeleteArtifacts;
+import org.argeo.slc.client.ui.dist.commands.OpenModuleEditor;
 import org.argeo.slc.client.ui.dist.utils.AbstractHyperlinkListener;
 import org.argeo.slc.client.ui.dist.utils.NodeViewerComparator;
 import org.argeo.slc.jcr.SlcNames;
 import org.argeo.slc.jcr.SlcTypes;
 import org.argeo.slc.repo.RepoConstants;
 import org.argeo.slc.repo.RepoUtils;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
 import org.eclipse.jface.dialogs.IMessageProvider;
 import org.eclipse.jface.viewers.ColumnLabelProvider;
 import org.eclipse.jface.viewers.DoubleClickEvent;
@@ -71,11 +68,8 @@ 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.PlatformUI;
 import org.eclipse.ui.browser.IWebBrowser;
 import org.eclipse.ui.browser.IWorkbenchBrowserSupport;
@@ -151,8 +145,6 @@ public class ModularDistVersionOverviewPage extends FormPage implements
 
        private void populateHeaderPart(Composite parent) {
                GridLayout layout = new GridLayout(6, false);
-               // layout.marginWidth = layout.horizontalSpacing = layout.marginHeight =
-               // 0;
                layout.horizontalSpacing = 10;
                parent.setLayout(layout);
                try {
@@ -198,9 +190,9 @@ public class ModularDistVersionOverviewPage extends FormPage implements
                label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
 
                // Add a trailing space to workaround a display glitch in RAP 1.3
-               Text text = tk.createText(parent, textValue + " ", SWT.LEFT);
+               Text text = new Text(parent, SWT.LEFT);
+               text.setText(textValue + " ");
                text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-
                text.setEditable(false);
                return text;
        }
@@ -298,7 +290,6 @@ public class ModularDistVersionOverviewPage extends FormPage implements
                createTableViewer(tablePart);
                // populate it on first pass.
                refresh();
-
        }
 
        private void createFilterPart(Composite parent) {
@@ -392,16 +383,16 @@ public class ModularDistVersionOverviewPage extends FormPage implements
                                propertyTypesList);
                viewer.setComparator(comparator);
 
-               // Context Menu
-               MenuManager menuManager = new MenuManager();
-               Menu menu = menuManager.createContextMenu(viewer.getTable());
-               menuManager.addMenuListener(new IMenuListener() {
-                       public void menuAboutToShow(IMenuManager manager) {
-                               contextMenuAboutToShow(manager);
-                       }
-               });
-               viewer.getTable().setMenu(menu);
-               getSite().registerContextMenu(menuManager, viewer);
+//             // Context Menu
+//             MenuManager menuManager = new MenuManager();
+//             Menu menu = menuManager.createContextMenu(viewer.getTable());
+//             menuManager.addMenuListener(new IMenuListener() {
+//                     public void menuAboutToShow(IMenuManager manager) {
+//                             contextMenuAboutToShow(manager);
+//                     }
+//             });
+//             viewer.getTable().setMenu(menu);
+//             getSite().registerContextMenu(menuManager, viewer);
 
                // Double click
                viewer.addDoubleClickListener(new DoubleClickListener());
@@ -477,16 +468,16 @@ public class ModularDistVersionOverviewPage extends FormPage implements
                viewer.getTable().setFocus();
        }
 
-       /** Programmatically configure the context menu */
-       protected void contextMenuAboutToShow(IMenuManager menuManager) {
-               IWorkbenchWindow window = DistPlugin.getDefault().getWorkbench()
-                               .getActiveWorkbenchWindow();
-               // Build conditions
-               // Delete selected artifacts
-               CommandUtils.refreshCommand(menuManager, window, DeleteArtifacts.ID,
-                               DeleteArtifacts.DEFAULT_LABEL, DeleteArtifacts.DEFAULT_ICON,
-                               true);
-       }
+       // /** Programmatically configure the context menu */
+       // protected void contextMenuAboutToShow(IMenuManager menuManager) {
+       // IWorkbenchWindow window = DistPlugin.getDefault().getWorkbench()
+       // .getActiveWorkbenchWindow();
+       // // Build conditions
+       // // Delete selected artifacts
+       // // CommandUtils.refreshCommand(menuManager, window, DeleteArtifacts.ID,
+       // // DeleteArtifacts.DEFAULT_LABEL, DeleteArtifacts.DEFAULT_ICON,
+       // // true);
+       // }
 
        private SelectionAdapter getSelectionAdapter(final int index) {
                SelectionAdapter selectionAdapter = new SelectionAdapter() {
@@ -534,54 +525,29 @@ public class ModularDistVersionOverviewPage extends FormPage implements
                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);
+                       if (obj instanceof Node) {
+                               Node node = (Node) obj;
+                               try {
+                                       if (node.isNodeType(SlcTypes.SLC_ARTIFACT)) {
+                                               ModuleEditorInput dwip = (ModuleEditorInput) getEditorInput();
+                                               Map<String, String> params = new HashMap<String, String>();
+                                               params.put(OpenModuleEditor.PARAM_REPO_NODE_PATH,
+                                                               dwip.getRepoNodePath());
+                                               params.put(OpenModuleEditor.PARAM_REPO_URI,
+                                                               dwip.getUri());
+                                               params.put(OpenModuleEditor.PARAM_WORKSPACE_NAME,
+                                                               dwip.getWorkspaceName());
+                                               String path = node.getPath();
+                                               params.put(OpenModuleEditor.PARAM_MODULE_PATH, path);
+                                               CommandUtils.callCommand(OpenModuleEditor.ID, params);
                                        }
+                               } catch (RepositoryException re) {
+                                       throw new SlcException("Cannot get path for node " + node
+                                                       + " while setting parameters for "
+                                                       + "command OpenModuleEditor", re);
                                }
-                       } 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. There is room here for optimization
-       // gd.heightHint = Math.max(maxH - 35, 200);
-       // gd.widthHint = Math.max(maxW - 35, 200);
-       //
-       // table.setLayoutData(gd);
-       // getManagedForm().reflow(true);
-       // }
 
-       @Override
-       public void setActive(boolean active) {
-               super.setActive(active);
-               if (active) {
-                       // refreshLayout();
+                       }
                }
        }
 }
\ No newline at end of file
index c82312e8b9e1bdd0058908c9ef97a8f0de80a9e9..751d26cdc17e733236377654f361c1b08540e911 100644 (file)
@@ -35,7 +35,6 @@ import javax.jcr.query.qom.QueryObjectModelFactory;
 import javax.jcr.query.qom.Selector;
 import javax.jcr.query.qom.StaticOperand;
 
-import org.argeo.ArgeoException;
 import org.argeo.eclipse.ui.jcr.AsyncUiEventListener;
 import org.argeo.eclipse.ui.utils.CommandUtils;
 import org.argeo.jcr.JcrUtils;
@@ -44,6 +43,7 @@ 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.OpenGenerateBinariesWizard;
+import org.argeo.slc.client.ui.dist.commands.OpenModuleEditor;
 import org.argeo.slc.client.ui.dist.utils.NodeViewerComparator;
 import org.argeo.slc.jcr.SlcNames;
 import org.argeo.slc.jcr.SlcTypes;
@@ -75,7 +75,6 @@ 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;
@@ -433,24 +432,28 @@ public class WkspCategoryBaseListPage extends FormPage implements SlcNames {
                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);
+                       if (obj instanceof Node) {
+                               Node node = (Node) obj;
+                               try {
+                                       if (node.isNodeType(SlcTypes.SLC_ARTIFACT)) {
+                                               DistWkspEditorInput dwip = (DistWkspEditorInput) getEditorInput();
+                                               Map<String, String> params = new HashMap<String, String>();
+                                               params.put(OpenModuleEditor.PARAM_REPO_NODE_PATH,
+                                                               dwip.getRepoNodePath());
+                                               params.put(OpenModuleEditor.PARAM_REPO_URI,
+                                                               dwip.getUri());
+                                               params.put(OpenModuleEditor.PARAM_WORKSPACE_NAME,
+                                                               dwip.getWorkspaceName());
+                                               String path = node.getPath();
+                                               params.put(OpenModuleEditor.PARAM_MODULE_PATH, path);
+                                               CommandUtils.callCommand(OpenModuleEditor.ID, params);
                                        }
+                               } catch (RepositoryException re) {
+                                       throw new SlcException("Cannot get path for node " + node
+                                                       + " while setting parameters for "
+                                                       + "command OpenModuleEditor", re);
                                }
-                       } 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);
+
                        }
                }
        }
diff --git a/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/utils/GenericDoubleClickListener.java b/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/utils/GenericDoubleClickListener.java
deleted file mode 100644 (file)
index 209bb4d..0000000
+++ /dev/null
@@ -1,122 +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.utils;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-import javax.jcr.nodetype.NodeType;
-import javax.jcr.query.Row;
-
-import org.argeo.ArgeoException;
-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.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.ui.PartInitException;
-
-/**
- * Centralizes the management of double click on an viewer that displays
- * artifacts.
- */
-public class GenericDoubleClickListener implements IDoubleClickListener,
-               SlcTypes, SlcNames, DistConstants {
-
-       // private final static Log log = LogFactory
-       // .getLog(GenericDoubleClickListener.class);
-
-       private JcrFileProvider jfp;
-       private FileHandler fileHandler;
-
-       public GenericDoubleClickListener() {
-               jfp = new JcrFileProvider();
-               fileHandler = new FileHandler(jfp);
-       }
-
-       public void doubleClick(DoubleClickEvent event) {
-               if (event.getSelection() == null || event.getSelection().isEmpty())
-                       return;
-               Object obj = ((IStructuredSelection) event.getSelection())
-                               .getFirstElement();
-               try {
-                       if (obj instanceof Node) {
-                               Node node = (Node) obj;
-                               if (node.isNodeType(SLC_ARTIFACT_VERSION_BASE)) {
-                                       GenericBundleEditorInput gaei = new GenericBundleEditorInput(
-                                                       node);
-                                       DistPlugin.getDefault().getWorkbench()
-                                                       .getActiveWorkbenchWindow().getActivePage()
-                                                       .openEditor(gaei, GenericBundleEditor.ID);
-                               } else if (node.isNodeType(NodeType.NT_FILE)) {
-                                       String name = node.getName();
-                                       String id = node.getIdentifier();
-                                       jfp.setReferenceNode(node);
-                                       fileHandler.openFile(name, id);
-                               }
-
-                       } else if (obj instanceof Row) {
-                               Row row = (Row) obj;
-                               // String uuid;
-                               // try {
-                               // uuid = row.getValue(
-                               // SLC_ARTIFACT_VERSION_BASE + "." + JCR_IDENTIFIER)
-                               // .getString();
-                               // } catch (ItemNotFoundException infe) {
-                               // MessageDialog.openError(DistPlugin.getDefault()
-                               // .getWorkbench().getActiveWorkbenchWindow()
-                               // .getShell(), "Invalid request",
-                               // "The request must return a value for "
-                               // + SLC_ARTIFACT_VERSION_BASE + "."
-                               // + JCR_IDENTIFIER
-                               // + " in order to open the artifact editor");
-                               // return;
-                               // }
-                               // Node node =
-                               // row.getNode(SLC_ARTIFACT_VERSION_BASE).getSession()
-                               // .getNodeByIdentifier(uuid);
-
-                               Node node = row.getNode(SLC_ARTIFACT_VERSION_BASE);
-                               if (node == null)
-                                       MessageDialog.openError(DistPlugin.getDefault()
-                                                       .getWorkbench().getActiveWorkbenchWindow()
-                                                       .getShell(), "Invalid request",
-                                                       "The request must return a "
-                                                                       + SLC_ARTIFACT_VERSION_BASE + " node "
-                                                                       + " in order to open the artifact editor");
-                               else {
-                                       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);
-               }
-       }
-}
index 3fcb1db10b2ea5491639f9919bd8e1e287a3feb9..45c0d0f2eb5b328c7711fd55ada4b39b0c92657d 100644 (file)
@@ -33,7 +33,6 @@ import org.apache.commons.logging.LogFactory;
 import org.argeo.ArgeoException;
 import org.argeo.eclipse.ui.GenericTableComparator;
 import org.argeo.slc.client.ui.dist.utils.ArtifactsTableConfigurer;
-import org.argeo.slc.client.ui.dist.utils.GenericDoubleClickListener;
 import org.argeo.slc.jcr.SlcTypes;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Status;
@@ -87,7 +86,7 @@ public abstract class AbstractQueryArtifactsView extends ViewPart implements
 
                viewer.setLabelProvider(new ViewLabelProvider());
                viewer.setContentProvider(new ViewContentProvider());
-               viewer.addDoubleClickListener(new GenericDoubleClickListener());
+               // viewer.addDoubleClickListener(new GenericDoubleClickListener());
 
                tableConfigurer = new ArtifactsTableConfigurer(viewer, 1,
                                GenericTableComparator.DESCENDING);
index 31cf7eb03515f536714e2507876a8b559563d011..1f1104bb98f7c5fc8a5433d0808e975d32859cf2 100644 (file)
@@ -29,7 +29,6 @@ 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.controllers.ArtifactsTreeContentProvider;
-import org.argeo.slc.client.ui.dist.utils.GenericDoubleClickListener;
 import org.argeo.slc.jcr.SlcTypes;
 import org.argeo.slc.repo.RepoConstants;
 import org.eclipse.jface.viewers.ColumnLabelProvider;
@@ -118,7 +117,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.addDoubleClickListener(new GenericDoubleClickListener());
                viewer.setInput(rootNode);
 
                return viewer;