X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=plugins%2Forg.argeo.slc.client.ui.dist%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fclient%2Fui%2Fdist%2Feditors%2FDistWkspSearchPage.java;h=ea1c20ef8bae350d9a2cdff73b6ceb4ef54d34e1;hb=39ceeb3083d5d9df0cf2f93bd26285e4c33234e3;hp=1228edfed051f18d8d8c02eda93cb67bf977dd0a;hpb=524221f25edad4b09aac22555450164e587b304a;p=gpl%2Fargeo-slc.git diff --git a/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/DistWkspSearchPage.java b/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/DistWkspSearchPage.java index 1228edfed..ea1c20ef8 100644 --- a/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/DistWkspSearchPage.java +++ b/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/DistWkspSearchPage.java @@ -39,17 +39,15 @@ 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; 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.PrivilegedJob; 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.NodeViewerComparator; +import org.argeo.slc.client.ui.dist.utils.DistNodeViewerComparator; import org.argeo.slc.jcr.SlcNames; import org.argeo.slc.jcr.SlcTypes; import org.eclipse.core.runtime.IProgressMonitor; @@ -71,11 +69,9 @@ import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; @@ -87,6 +83,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 { @@ -102,12 +99,12 @@ public class DistWkspSearchPage extends FormPage implements SlcNames { private DistWorkspaceEditor formEditor; private FormToolkit tk; - private NodeViewerComparator comparator; + private DistNodeViewerComparator comparator; private TableViewer viewer; // 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,15 +168,70 @@ 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()); + + // Filter Composite filter = tk.createComposite(body); filter.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); createFilterPart(filter); - // the table + // Table Composite tableCmp = tk.createComposite(body); tableCmp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); createTableViewer(tableCmp); + + section.setClient(body); } /** Build repository request */ @@ -241,53 +293,21 @@ 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; } private void createFilterPart(Composite parent) { - GridLayout layout = new GridLayout(2, false); + GridLayout layout = new GridLayout(); layout.marginWidth = layout.marginHeight = layout.verticalSpacing = 0; layout.horizontalSpacing = 5; parent.setLayout(layout); @@ -307,23 +327,6 @@ public class DistWkspSearchPage extends FormPage implements SlcNames { refreshFilteredList(); } }); - - Button resetBtn = tk.createButton(parent, null, SWT.PUSH); - resetBtn.setImage(DistImages.IMG_REPO_READONLY); - resetBtn.addSelectionListener(new SelectionListener() { - - public void widgetSelected(SelectionEvent e) { - resetFilter(); - } - - public void widgetDefaultSelected(SelectionEvent e) { - } - }); - } - - private void resetFilter() { - artifactTxt.setText(""); - artifactTxt.setMessage(FILTER_HELP_MSG); } private void refreshFilteredList() { @@ -388,7 +391,7 @@ public class DistWkspSearchPage extends FormPage implements SlcNames { }); col.getColumn().addSelectionListener(getSelectionAdapter(2)); propertiesList.add(SLC_BUNDLE_VERSION); - propertyTypesList.add(PropertyType.STRING); + propertyTypesList.add(DistNodeViewerComparator.VERSION_TYPE); final Table table = viewer.getTable(); table.setHeaderVisible(true); @@ -397,8 +400,8 @@ public class DistWkspSearchPage extends FormPage implements SlcNames { viewer.setContentProvider(new DistributionsContentProvider()); getSite().setSelectionProvider(viewer); - comparator = new NodeViewerComparator(2, - NodeViewerComparator.ASCENDING, propertiesList, + comparator = new DistNodeViewerComparator(2, + DistNodeViewerComparator.ASCENDING, propertiesList, propertyTypesList); viewer.setComparator(comparator); @@ -510,35 +513,4 @@ public class DistWkspSearchPage extends FormPage implements SlcNames { } } } - - /** - * UI Trick to put scroll bar on the table rather than on the scrollform - */ - private void refreshLayout() { - // // Compute desired table size - // int maxH = getManagedForm().getForm().getSize().y; - // int maxW = getManagedForm().getForm().getParent().getSize().x; - // // maxH = maxH - header.getSize().y; - // final Table table = viewer.getTable(); - // GridData gd = new GridData(SWT.LEFT, SWT.TOP, true, true); - // - // // when table height is less than 200 px, we let the scroll bar on - // the - // // scrollForm - // // FIXME substract some spare space. There is room here for - // optimization - // gd.heightHint = Math.max(maxH - 35, 200); - // gd.widthHint = Math.max(maxW - 35, 200); - // - // table.setLayoutData(gd); - // getManagedForm().reflow(true); - } - - @Override - public void setActive(boolean active) { - super.setActive(active); - if (active) { - refreshLayout(); - } - } } \ No newline at end of file