]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/DistributionOverviewPage.java
Work in progress - work on modular distributions.
[gpl/argeo-slc.git] / plugins / org.argeo.slc.client.ui.dist / src / main / java / org / argeo / slc / client / ui / dist / editors / DistributionOverviewPage.java
index 4401f7da9b2574442e296eeeb28d07c61e9eabdc..edd848fe98f0a99594e5cfce1598763f901d880f 100644 (file)
@@ -20,9 +20,11 @@ import java.util.List;
 
 import javax.jcr.Node;
 import javax.jcr.NodeIterator;
+import javax.jcr.Property;
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
+import javax.jcr.nodetype.NodeType;
 import javax.jcr.query.QueryManager;
 import javax.jcr.query.QueryResult;
 import javax.jcr.query.qom.Constraint;
@@ -36,6 +38,7 @@ import javax.jcr.query.qom.StaticOperand;
 import org.argeo.ArgeoException;
 import org.argeo.ArgeoMonitor;
 import org.argeo.eclipse.ui.EclipseArgeoMonitor;
+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;
@@ -43,7 +46,6 @@ import org.argeo.slc.client.ui.dist.DistImages;
 import org.argeo.slc.client.ui.dist.DistPlugin;
 import org.argeo.slc.client.ui.dist.PrivilegedJob;
 import org.argeo.slc.client.ui.dist.commands.DeleteArtifacts;
-import org.argeo.slc.client.ui.dist.utils.CommandHelpers;
 import org.argeo.slc.client.ui.dist.utils.NodeViewerComparator;
 import org.argeo.slc.jcr.SlcNames;
 import org.argeo.slc.jcr.SlcTypes;
@@ -86,12 +88,13 @@ import org.eclipse.ui.forms.editor.FormPage;
 import org.eclipse.ui.forms.widgets.FormToolkit;
 import org.eclipse.ui.forms.widgets.ScrolledForm;
 
-/** Table giving an overview of an OSGi distribution with corresponding filters */
+/** Show all bundles contained in a given workspace as filter-able table */
 public class DistributionOverviewPage extends FormPage implements SlcNames {
-       final static String PAGE_ID = "distributionOverviewPage";
        // final private static Log log = LogFactory
        // .getLog(DistributionOverviewPage.class);
 
+       final static String PAGE_ID = "distributionOverviewPage";
+
        // Business Objects
        private Session session;
 
@@ -163,7 +166,7 @@ public class DistributionOverviewPage extends FormPage implements SlcNames {
                createFilterPart(body);
                // Add the table
                createTableViewer(body);
-               viewer.setInput(null);
+               // viewer.setInput(null);
                // Add a listener to enable custom resize process
                form.addControlListener(new ControlListener() {
                        // form.addListener(SWT.RESIZE, new Listener() does not work
@@ -239,13 +242,29 @@ public class DistributionOverviewPage extends FormPage implements SlcNames {
        private void createFilterPart(Composite parent) {
                header = tk.createComposite(parent);
                GridLayout layout = new GridLayout(2, false);
+               layout.marginWidth = layout.marginHeight = layout.verticalSpacing = 0;
+               layout.horizontalSpacing = 5;
                header.setLayout(layout);
                GridData gd = new GridData(SWT.FILL, SWT.FILL, false, false);
                header.setLayoutData(gd);
 
                // Title: some meta information
-               String desc = ((DistributionEditorInput) getEditorInput())
-                               .getRepositoryDescription();
+               // label = repoNode.isNodeType(NodeType.MIX_TITLE) ? repoNode
+               // .getProperty(Property.JCR_TITLE).getString() : repoNode
+               // .getName();
+
+               String desc = null;
+               Node repoNode = ((DistributionWorkspaceEditor) getEditor())
+                               .getRepoNode();
+               if (repoNode != null)
+                       try {
+                               desc = repoNode.isNodeType(NodeType.MIX_TITLE) ? repoNode
+                                               .getProperty(Property.JCR_TITLE).getString() : repoNode
+                                               .getName();
+                       } catch (RepositoryException e1) {
+                               throw new SlcException("Unable to get repository alias ", e1);
+                       }
+               desc += " (" + ((WorkspaceEditorInput) getEditorInput()).getUri() + ")";
                Label lbl = tk.createLabel(header, desc, SWT.NONE);
 
                gd = new GridData(SWT.FILL, SWT.FILL, false, false);
@@ -253,7 +272,8 @@ public class DistributionOverviewPage extends FormPage implements SlcNames {
                lbl.setLayoutData(gd);
 
                // Text Area to filter
-               artifactTxt = tk.createText(header, "", SWT.BORDER | SWT.SINGLE);
+               artifactTxt = tk.createText(header, "", SWT.BORDER | SWT.SINGLE
+                               | SWT.SEARCH | SWT.CANCEL);
                artifactTxt.setMessage(FILTER_HELP_MSG);
                gd = new GridData(SWT.FILL, SWT.FILL, false, false);
                gd.grabExcessHorizontalSpace = true;
@@ -324,7 +344,7 @@ public class DistributionOverviewPage extends FormPage implements SlcNames {
                // Symbolic name
                col = new TableViewerColumn(viewer, SWT.V_SCROLL);
                col.getColumn().setWidth(300);
-               col.getColumn().setText("Symbolic name");
+               col.getColumn().setText("Symbolic Name");
                col.setLabelProvider(new ColumnLabelProvider() {
                        @Override
                        public String getText(Object element) {
@@ -392,9 +412,9 @@ public class DistributionOverviewPage extends FormPage implements SlcNames {
                                .getActiveWorkbenchWindow();
                // Build conditions
                // Delete selected artifacts
-               CommandHelpers.refreshCommand(menuManager, window, DeleteArtifacts.ID,
-                               DeleteArtifacts.DEFAULT_LABEL,
-                               DeleteArtifacts.DEFAULT_ICON_PATH, true);
+               CommandUtils.refreshCommand(menuManager, window, DeleteArtifacts.ID,
+                               DeleteArtifacts.DEFAULT_LABEL, DeleteArtifacts.DEFAULT_ICON,
+                               true);
        }
 
        private SelectionAdapter getSelectionAdapter(final int index) {
@@ -478,7 +498,7 @@ public class DistributionOverviewPage extends FormPage implements SlcNames {
 
                // when table height is less than 200 px, we let the scroll bar on the
                // scrollForm
-               // FIXME substract some spare space. Here is room for optimization
+               // 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);