+ Composite body = form.getBody();
+ body.setLayout(layout);
+
+ // Add the filter section
+ createFilterPart(body);
+ // Add the table
+ createTableViewer(body);
+ viewer.setInput(null);
+ // Add a listener to enable custom resize process
+ form.addControlListener(new ControlListener() {
+ // form.addListener(SWT.RESIZE, new Listener() does not work
+ public void controlResized(ControlEvent e) {
+ refreshLayout();
+ }
+
+ public void controlMoved(ControlEvent e) {
+ }
+ });
+ asynchronousRefresh();
+ }
+
+ /** Build repository request */
+ private NodeIterator listBundleArtifacts(Session session, String filter)
+ throws RepositoryException {
+ QueryManager queryManager = session.getWorkspace().getQueryManager();
+ QueryObjectModelFactory factory = queryManager.getQOMFactory();
+
+ final String bundleArtifactsSelector = "bundleArtifacts";
+ Selector source = factory.selector(SlcTypes.SLC_BUNDLE_ARTIFACT,
+ bundleArtifactsSelector);
+
+ // Create a dynamic operand for each property on which we want to filter
+ DynamicOperand symbNameDO = factory.propertyValue(
+ source.getSelectorName(), SlcNames.SLC_SYMBOLIC_NAME);
+ DynamicOperand versionDO = factory.propertyValue(
+ source.getSelectorName(), SlcNames.SLC_BUNDLE_VERSION);
+ DynamicOperand nameDO = factory.propertyValue(source.getSelectorName(),
+ DistConstants.SLC_BUNDLE_NAME);
+
+ // Default Constraint: no source artifacts
+ Constraint defaultC = factory.not(factory.comparison(
+ symbNameDO,
+ QueryObjectModelFactory.JCR_OPERATOR_LIKE,
+ factory.literal(session.getValueFactory().createValue(
+ "%.source"))));
+
+ // Build constraints based the textArea content
+ if (filter != null && !"".equals(filter.trim())) {
+ // Parse the String
+ String[] strs = filter.trim().split(" ");
+ for (String token : strs) {
+ token = token.replace('*', '%');
+ StaticOperand so = factory.literal(session.getValueFactory()
+ .createValue("%" + token + "%"));
+
+ Constraint currC = factory.comparison(symbNameDO,
+ QueryObjectModelFactory.JCR_OPERATOR_LIKE, so);
+ currC = factory.or(currC, factory.comparison(versionDO,
+ QueryObjectModelFactory.JCR_OPERATOR_LIKE, so));
+ currC = factory.or(currC, factory.comparison(nameDO,
+ QueryObjectModelFactory.JCR_OPERATOR_LIKE, so));
+
+ defaultC = factory.and(defaultC, currC);
+ }
+ }
+
+ Ordering order = factory.descending(factory.propertyValue(
+ bundleArtifactsSelector, SlcNames.SLC_BUNDLE_VERSION));
+ Ordering order2 = factory.ascending(factory.propertyValue(
+ bundleArtifactsSelector, SlcNames.SLC_SYMBOLIC_NAME));
+ Ordering[] orderings = { order, order2 };
+
+ QueryObjectModel query = factory.createQuery(source, defaultC,
+ orderings, null);
+
+ QueryResult result = query.execute();
+ return result.getNodes();
+
+ }
+
+ private void createFilterPart(Composite parent) {
+ header = tk.createComposite(parent);
+ GridLayout layout = new GridLayout(2, false);
+ 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 lbl = tk.createLabel(header, desc, SWT.NONE);
+
+ gd = new GridData(SWT.FILL, SWT.FILL, false, false);
+ gd.horizontalSpan = 2;
+ lbl.setLayoutData(gd);
+
+ // Text Area to filter
+ artifactTxt = tk.createText(header, "", SWT.BORDER | SWT.SINGLE);
+ artifactTxt.setMessage(FILTER_HELP_MSG);
+ gd = new GridData(SWT.FILL, SWT.FILL, false, false);
+ gd.grabExcessHorizontalSpace = true;
+ artifactTxt.setLayoutData(gd);
+ artifactTxt.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent event) {
+ if ("".equals(artifactTxt.getText().trim()))
+ asynchronousRefresh();
+ else
+ refreshFilteredList();
+ }
+ });
+
+ Button resetBtn = tk.createButton(header, null, SWT.PUSH);
+ resetBtn.setImage(DistImages.IMG_REPO_READONLY);
+ resetBtn.addSelectionListener(new SelectionListener() {