1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.modeling.ui.view;
14 import java.util.ArrayList;
15 import java.util.Date;
16 import java.util.HashMap;
17 import java.util.HashSet;
18 import java.util.List;
22 import org.eclipse.core.runtime.Assert;
23 import org.eclipse.core.runtime.IProgressMonitor;
24 import org.eclipse.core.runtime.IStatus;
25 import org.eclipse.core.runtime.Status;
26 import org.eclipse.core.runtime.SubMonitor;
27 import org.eclipse.core.runtime.jobs.Job;
28 import org.eclipse.jface.action.IStatusLineManager;
29 import org.eclipse.jface.layout.GridDataFactory;
30 import org.eclipse.jface.resource.ColorDescriptor;
31 import org.eclipse.jface.resource.JFaceResources;
32 import org.eclipse.jface.resource.LocalResourceManager;
33 import org.eclipse.nebula.widgets.cdatetime.CDT;
34 import org.eclipse.nebula.widgets.cdatetime.CDateTime;
35 import org.eclipse.nebula.widgets.nattable.NatTable;
36 import org.eclipse.nebula.widgets.nattable.config.AbstractUiBindingConfiguration;
37 import org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration;
38 import org.eclipse.nebula.widgets.nattable.data.IDataProvider;
39 import org.eclipse.nebula.widgets.nattable.grid.GridRegion;
40 import org.eclipse.nebula.widgets.nattable.grid.data.DefaultBodyDataProvider;
41 import org.eclipse.nebula.widgets.nattable.grid.data.DefaultColumnHeaderDataProvider;
42 import org.eclipse.nebula.widgets.nattable.grid.data.DefaultCornerDataProvider;
43 import org.eclipse.nebula.widgets.nattable.grid.data.DefaultRowHeaderDataProvider;
44 import org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer;
45 import org.eclipse.nebula.widgets.nattable.grid.layer.CornerLayer;
46 import org.eclipse.nebula.widgets.nattable.grid.layer.DefaultColumnHeaderDataLayer;
47 import org.eclipse.nebula.widgets.nattable.grid.layer.DefaultRowHeaderDataLayer;
48 import org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer;
49 import org.eclipse.nebula.widgets.nattable.grid.layer.RowHeaderLayer;
50 import org.eclipse.nebula.widgets.nattable.layer.DataLayer;
51 import org.eclipse.nebula.widgets.nattable.layer.ILayer;
52 import org.eclipse.nebula.widgets.nattable.reorder.RowReorderLayer;
53 import org.eclipse.nebula.widgets.nattable.resize.action.AutoResizeColumnAction;
54 import org.eclipse.nebula.widgets.nattable.resize.action.ColumnResizeCursorAction;
55 import org.eclipse.nebula.widgets.nattable.resize.event.ColumnResizeEventMatcher;
56 import org.eclipse.nebula.widgets.nattable.resize.mode.ColumnResizeDragMode;
57 import org.eclipse.nebula.widgets.nattable.selection.SelectionLayer;
58 import org.eclipse.nebula.widgets.nattable.selection.config.DefaultSelectionStyleConfiguration;
59 import org.eclipse.nebula.widgets.nattable.sort.SortHeaderLayer;
60 import org.eclipse.nebula.widgets.nattable.sort.config.SingleClickSortConfiguration;
61 import org.eclipse.nebula.widgets.nattable.style.HorizontalAlignmentEnum;
62 import org.eclipse.nebula.widgets.nattable.ui.action.ClearCursorAction;
63 import org.eclipse.nebula.widgets.nattable.ui.action.NoOpMouseAction;
64 import org.eclipse.nebula.widgets.nattable.ui.binding.UiBindingRegistry;
65 import org.eclipse.nebula.widgets.nattable.ui.matcher.MouseEventMatcher;
66 import org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer;
67 import org.eclipse.swt.SWT;
68 import org.eclipse.swt.dnd.DND;
69 import org.eclipse.swt.dnd.DropTarget;
70 import org.eclipse.swt.dnd.DropTargetAdapter;
71 import org.eclipse.swt.dnd.DropTargetEvent;
72 import org.eclipse.swt.dnd.TextTransfer;
73 import org.eclipse.swt.dnd.Transfer;
74 import org.eclipse.swt.events.ModifyEvent;
75 import org.eclipse.swt.events.ModifyListener;
76 import org.eclipse.swt.events.SelectionEvent;
77 import org.eclipse.swt.events.SelectionListener;
78 import org.eclipse.swt.graphics.Color;
79 import org.eclipse.swt.graphics.RGB;
80 import org.eclipse.swt.layout.GridData;
81 import org.eclipse.swt.layout.GridLayout;
82 import org.eclipse.swt.widgets.Composite;
83 import org.eclipse.swt.widgets.Display;
84 import org.eclipse.swt.widgets.Group;
85 import org.eclipse.swt.widgets.Label;
86 import org.eclipse.swt.widgets.Text;
87 import org.eclipse.ui.IWorkbenchSite;
88 import org.simantics.DatabaseJob;
89 import org.simantics.databoard.util.URIStringUtils;
90 import org.simantics.db.ReadGraph;
91 import org.simantics.db.Resource;
92 import org.simantics.db.Session;
93 import org.simantics.db.common.ResourceArray;
94 import org.simantics.db.common.request.UniqueRead;
95 import org.simantics.db.common.utils.Logger;
96 import org.simantics.db.exception.DatabaseException;
97 import org.simantics.db.layer0.request.PossibleURI;
98 import org.simantics.db.service.SerialisationSupport;
99 import org.simantics.layer0.Layer0;
100 import org.simantics.modeling.ModelingResources;
101 import org.simantics.modeling.adapters.ChangeInformation;
102 import org.simantics.modeling.ui.Activator;
103 import org.simantics.ui.dnd.LocalObjectTransfer;
104 import org.simantics.ui.dnd.ResourceReferenceTransfer;
105 import org.simantics.ui.dnd.ResourceTransferUtils;
106 import org.simantics.ui.utils.ResourceAdaptionUtils;
107 import org.simantics.utils.ui.ErrorLogger;
108 import org.simantics.utils.ui.SWTUtils;
109 import org.simantics.utils.ui.dialogs.ShowMessage;
110 import org.simantics.utils.ui.workbench.WorkbenchUtils;
113 public class ChangeInformationComposite extends Composite {
115 private final LocalResourceManager resourceManager;
117 private final ColorDescriptor green = ColorDescriptor.createFrom(new RGB(0x57, 0xbc, 0x95));
120 * The Session used to access the graph. Received from outside of this
121 * class and therefore it is not disposed here, just used.
123 private final Session session;
125 private Resource resource;
127 private List<Bean> allContents = new ArrayList<Bean>();
129 private List<Bean> contents = new ArrayList<Bean>();
133 protected IWorkbenchSite site;
135 private NatTable table;
137 private IDataProvider bodyDataProvider;
139 private CDateTime createdBefore;
140 private CDateTime createdAfter;
141 private CDateTime modifiedBefore;
142 private CDateTime modifiedAfter;
144 private Label dropLabel;
146 private Text creatorText;
147 private Text modifierText;
148 private Text nameText;
149 private Text pathText;
150 private Text typesText;
152 private BeanSortModel sortModel;
158 * @param resource the initial resource to debug or <code>null</code> for
159 * initially blank UI.
161 public ChangeInformationComposite(Composite parent, int style, final Session session, Resource resource, IWorkbenchSite site) {
162 super(parent, style);
163 Assert.isNotNull(session, "session is null");
164 this.session = session;
165 this.resource = resource;
166 this.resourceManager = new LocalResourceManager(JFaceResources.getResources(), parent);
171 * When given to setStatus, indicates that the message shouldn't be touched
172 * since <code>null</code> has a different meaning.
174 private static final String DONT_TOUCH = "DONT_TOUCH";
176 protected void setStatus(String message, String error) {
177 IStatusLineManager status = WorkbenchUtils.getStatusLine(site);
178 if (status != null) {
179 if (message != DONT_TOUCH)
180 status.setMessage(message);
181 if (error != DONT_TOUCH)
182 status.setErrorMessage(error);
186 public void defaultInitializeUI() {
188 setLayout(new GridLayout(4, false));
189 setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
191 createDropLabel(this);
192 createContents(this);
196 public Label createDropLabel(Composite parent) {
197 dropLabel = new Label(parent, SWT.BORDER);
198 dropLabel.setAlignment(SWT.CENTER);
199 dropLabel.setText("Drag a resource here");
200 dropLabel.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY));
201 GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).hint(SWT.DEFAULT, 20).span(4, 1).grab(true, false).applyTo(dropLabel);
203 // Add resource id drop support to the drop-area.
204 DropTarget dropTarget = new DropTarget(dropLabel, DND.DROP_LINK | DND.DROP_COPY);
205 dropTarget.setTransfer(new Transfer[] { TextTransfer.getInstance(), ResourceReferenceTransfer.getInstance(), LocalObjectTransfer.getTransfer() });
206 dropTarget.addDropListener(new DropTargetAdapter() {
208 public void dragEnter(DropTargetEvent event) {
209 event.detail = DND.DROP_LINK;
210 dropLabel.setBackground((Color) resourceManager.get(green));
214 public void dragLeave(DropTargetEvent event) {
215 dropLabel.setBackground(null);
219 public void drop(DropTargetEvent event) {
220 dropLabel.setBackground(null);
221 ResourceArray[] data = parseEventData(event);
222 if (data == null || data.length != 1) {
223 event.detail = DND.DROP_NONE;
226 final ResourceArray array = data[0];
227 final Resource r = array.resources[array.resources.length - 1];
232 private ResourceArray[] parseEventData(DropTargetEvent event) {
233 //System.out.println("DATA: " + event.data);
234 if (event.data instanceof String) {
236 SerialisationSupport support = session.getService(SerialisationSupport.class);
237 return ResourceTransferUtils.readStringTransferable(support, (String) event.data).toResourceArrayArray();
238 } catch (IllegalArgumentException e) {
239 ErrorLogger.defaultLogError(e);
240 } catch (DatabaseException e) {
241 ErrorLogger.defaultLogError(e);
244 ResourceArray[] ret = ResourceAdaptionUtils.toResourceArrays(event.data);
254 public void createContents(Composite parent) {
256 Group fieldGroup = new Group(parent, SWT.NONE);
257 fieldGroup.setLayout(new GridLayout(2, false));
258 fieldGroup.setText("Filter modifications by text in columns");
259 GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).span(4, 1).grab(true, false).applyTo(fieldGroup);
263 final Label label = new Label(fieldGroup, SWT.NONE);
264 label.setAlignment(SWT.CENTER);
265 label.setText("Created By:");
266 GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).hint(SWT.DEFAULT, 20).span(1, 1).grab(false, false).applyTo(label);
268 creatorText = new Text(fieldGroup, SWT.BORDER);
269 GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).hint(SWT.DEFAULT, 20).span(1, 1).grab(true, false).applyTo(creatorText);
271 creatorText.addModifyListener(new ModifyListener() {
274 public void modifyText(ModifyEvent e) {
283 final Label label = new Label(fieldGroup, SWT.NONE);
284 label.setAlignment(SWT.CENTER);
285 label.setText("Modified By:");
286 GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).hint(SWT.DEFAULT, 20).span(1, 1).grab(false, false).applyTo(label);
288 modifierText = new Text(fieldGroup, SWT.BORDER);
289 GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).hint(SWT.DEFAULT, 20).span(1, 1).grab(true, false).applyTo(modifierText);
291 modifierText.addModifyListener(new ModifyListener() {
294 public void modifyText(ModifyEvent e) {
303 final Label label = new Label(fieldGroup, SWT.NONE);
304 label.setAlignment(SWT.CENTER);
305 label.setText("Name:");
306 GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).hint(SWT.DEFAULT, 20).span(1, 1).grab(false, false).applyTo(label);
308 nameText = new Text(fieldGroup, SWT.BORDER);
309 GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).hint(SWT.DEFAULT, 20).span(1, 1).grab(true, false).applyTo(nameText);
311 nameText.addModifyListener(new ModifyListener() {
314 public void modifyText(ModifyEvent e) {
323 final Label label = new Label(fieldGroup, SWT.NONE);
324 label.setAlignment(SWT.CENTER);
325 label.setText("Path:");
326 GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).hint(SWT.DEFAULT, 20).span(1, 1).grab(false, false).applyTo(label);
328 pathText = new Text(fieldGroup, SWT.BORDER);
329 GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).hint(SWT.DEFAULT, 20).span(1, 1).grab(true, false).applyTo(pathText);
331 pathText.addModifyListener(new ModifyListener() {
334 public void modifyText(ModifyEvent e) {
343 final Label label = new Label(fieldGroup, SWT.NONE);
344 label.setAlignment(SWT.CENTER);
345 label.setText("Types:");
346 GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).hint(SWT.DEFAULT, 20).span(1, 1).grab(false, false).applyTo(label);
348 typesText = new Text(fieldGroup, SWT.BORDER);
349 GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).hint(SWT.DEFAULT, 20).span(1, 1).grab(true, false).applyTo(typesText);
351 typesText.addModifyListener(new ModifyListener() {
354 public void modifyText(ModifyEvent e) {
362 SelectionListener selectionListener = new SelectionListener() {
365 public void widgetSelected(SelectionEvent e) {
366 widgetDefaultSelected(e);
370 public void widgetDefaultSelected(SelectionEvent e) {
375 Group timeGroup = new Group(parent, SWT.NONE);
376 timeGroup.setLayout(new GridLayout(2, false));
377 timeGroup.setText("Filter modifications by time");
378 GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).span(4, 1).grab(true, false).applyTo(timeGroup);
380 createdAfter = new CDateTime(timeGroup, CDT.BORDER | CDT.DROP_DOWN | CDT.CLOCK_12_HOUR);
381 createdAfter.setPattern("'Created after 'd.M.yyy '@' H:mm");
382 createdAfter.setNullText("<choose created after>");
383 createdAfter.addSelectionListener(selectionListener);
384 GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).hint(SWT.DEFAULT, 20).span(1, 1).grab(true, false).applyTo(createdAfter);
385 createdBefore = new CDateTime(timeGroup, CDT.BORDER | CDT.DROP_DOWN | CDT.CLOCK_12_HOUR);
386 createdBefore.setPattern("'Created before 'd.M.yyy '@' H:mm");
387 createdBefore.setNullText("<choose created before>");
388 createdBefore.addSelectionListener(selectionListener);
389 GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).hint(SWT.DEFAULT, 20).span(1, 1).grab(true, false).applyTo(createdBefore);
391 modifiedAfter = new CDateTime(timeGroup, CDT.BORDER | CDT.DROP_DOWN | CDT.CLOCK_12_HOUR);
392 modifiedAfter.setPattern("'Modified after 'd.M.yyy '@' H:mm");
393 modifiedAfter.setNullText("<choose modified after>");
394 modifiedAfter.addSelectionListener(selectionListener);
395 GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).hint(SWT.DEFAULT, 20).span(1, 1).grab(true, false).applyTo(modifiedAfter);
396 modifiedBefore = new CDateTime(timeGroup, CDT.BORDER | CDT.DROP_DOWN | CDT.CLOCK_12_HOUR);
397 modifiedBefore.setPattern("'Modified before 'd.M.yyy '@' H:mm");
398 modifiedBefore.setNullText("<choose modified before>");
399 modifiedBefore.addSelectionListener(selectionListener);
400 GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).hint(SWT.DEFAULT, 20).span(1, 1).grab(true, false).applyTo(modifiedBefore);
402 //property names of the Person class
403 String[] propertyNames = {"name", "path", "types", "createdBy", "createdAt", "modifiedBy", "modifiedAt"};
405 //mapping from property to label, needed for column header labels
406 Map<String, String> propertyToLabelMap = new HashMap<String, String>();
407 propertyToLabelMap.put("name", "Name");
408 propertyToLabelMap.put("path", "Path");
409 propertyToLabelMap.put("types", "Types");
410 propertyToLabelMap.put("createdBy", "Created By");
411 propertyToLabelMap.put("createdAt", "Created At");
412 propertyToLabelMap.put("modifiedBy", "Last Modified By");
413 propertyToLabelMap.put("modifiedAt", "Last Modified At");
415 //build the body layer stack
416 //Usually you would create a new layer stack by extending AbstractIndexLayerTransform and
417 //setting the ViewportLayer as underlying layer. But in this case using the ViewportLayer
418 //directly as body layer is also working.
419 bodyDataProvider = new DefaultBodyDataProvider<Bean>(contents, propertyNames);
420 final DataLayer bodyDataLayer = new DataLayer(bodyDataProvider);
421 bodyDataLayer.setColumnWidthByPosition(0, 145);
422 bodyDataLayer.setColumnWidthByPosition(1, 170);
423 bodyDataLayer.setColumnWidthByPosition(2, 120);
424 bodyDataLayer.setColumnWidthByPosition(3, 85);
425 bodyDataLayer.setColumnWidthByPosition(4, 85);
426 bodyDataLayer.setColumnWidthByPosition(5, 115);
427 bodyDataLayer.setColumnWidthByPosition(6, 115);
429 final RowReorderLayer rowReorderLayer = new RowReorderLayer(bodyDataLayer);
430 final SelectionLayer selectionLayer = new SelectionLayer(rowReorderLayer);
431 ViewportLayer viewportLayer = new ViewportLayer(selectionLayer);
433 //build the column header layer
434 IDataProvider columnHeaderDataProvider = new DefaultColumnHeaderDataProvider(propertyNames, propertyToLabelMap);
435 DataLayer columnHeaderDataLayer = new DefaultColumnHeaderDataLayer(columnHeaderDataProvider);
436 ColumnHeaderLayer columnHeaderLayer = new ColumnHeaderLayer(columnHeaderDataLayer, viewportLayer, selectionLayer);
438 sortModel = new BeanSortModel(allContents, contents);
440 SortHeaderLayer<Bean> sortHeaderLayer = new SortHeaderLayer<Bean>(
441 columnHeaderLayer, sortModel);
443 //build the row header layer
444 IDataProvider rowHeaderDataProvider = new DefaultRowHeaderDataProvider(bodyDataProvider);
445 DataLayer rowHeaderDataLayer = new DefaultRowHeaderDataLayer(rowHeaderDataProvider);
446 rowHeaderDataLayer.setColumnWidthByPosition(0, 90);
448 RowHeaderLayer rowHeaderLayer = new RowHeaderLayer(rowHeaderDataLayer, viewportLayer, selectionLayer);
450 //build the corner layer
451 IDataProvider cornerDataProvider = new DefaultCornerDataProvider(columnHeaderDataProvider, rowHeaderDataProvider);
452 DataLayer cornerDataLayer = new DataLayer(cornerDataProvider);
453 ILayer cornerLayer = new CornerLayer(cornerDataLayer, rowHeaderLayer, sortHeaderLayer);
455 //build the grid layer
456 GridLayer gridLayer = new GridLayer(viewportLayer, sortHeaderLayer, rowHeaderLayer, cornerLayer);
458 table = new NatTable(parent, gridLayer, false);
460 DefaultNatTableStyleConfiguration styleConfiguration = new DefaultNatTableStyleConfiguration();
461 styleConfiguration.hAlign = HorizontalAlignmentEnum.LEFT;
462 table.addConfiguration(styleConfiguration);
463 // Change the default sort key bindings. Note that 'auto configure' was turned off
464 table.addConfiguration(new SingleClickSortConfiguration());
465 table.addConfiguration(new DefaultSelectionStyleConfiguration());
468 table.addConfiguration(new AbstractUiBindingConfiguration() {
471 public void configureUiBindings(UiBindingRegistry uiBindingRegistry) {
472 // Mouse move - Show resize cursor
473 uiBindingRegistry.registerFirstMouseMoveBinding(new ColumnResizeEventMatcher(SWT.NONE,
474 GridRegion.ROW_HEADER, 0), new ColumnResizeCursorAction());
475 uiBindingRegistry.registerMouseMoveBinding(new MouseEventMatcher(), new ClearCursorAction());
478 uiBindingRegistry.registerFirstMouseDragMode(new ColumnResizeEventMatcher(SWT.NONE,
479 GridRegion.ROW_HEADER, 1), new ColumnResizeDragMode());
481 uiBindingRegistry.registerDoubleClickBinding(new ColumnResizeEventMatcher(SWT.NONE,
482 GridRegion.ROW_HEADER, 1), new AutoResizeColumnAction());
483 uiBindingRegistry.registerSingleClickBinding(new ColumnResizeEventMatcher(SWT.NONE,
484 GridRegion.ROW_HEADER, 1), new NoOpMouseAction());
490 GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).hint(SWT.DEFAULT, 20).span(4, 1).grab(true, true).applyTo(table);
494 public void changeLocation(Resource element) {
499 String uri = session.syncRequest(new PossibleURI(resource));
501 uri = uri.replace("http://Projects/Development%20Project/", "");
502 uri = URIStringUtils.unescape(uri);
503 dropLabel.setText("Drag a resource here - searching at " + uri);
505 } catch (DatabaseException e) {
506 Logger.defaultLogError(e);
513 public void refresh() {
519 public void updateData(boolean sort) {
523 if(sort) sortModel.sortCurrent();
527 setStatus(DONT_TOUCH, null);
531 private long getPossibleTime(CDateTime widget) {
532 Date d = widget.getSelection();
533 if(d == null) return 0;
534 else return d.getTime();
537 public void filter() {
539 long createdAfterTime = getPossibleTime(createdAfter);
540 long createdBeforeTime = getPossibleTime(createdBefore);
541 long modifiedAfterTime = getPossibleTime(modifiedAfter);
542 long modifiedBeforeTime = getPossibleTime(modifiedBefore);
544 String creatorFilter = creatorText.getText().toLowerCase();
545 if(creatorFilter.isEmpty()) creatorFilter = null;
546 String modifierFilter = modifierText.getText().toLowerCase();
547 if(modifierFilter.isEmpty()) modifierFilter = null;
548 String[] nameFilter = null;
549 if(!nameText.getText().isEmpty()) nameFilter = nameText.getText().toLowerCase().split(" ");
550 String[] pathFilter = null;
551 if(!pathText.getText().isEmpty()) pathFilter = pathText.getText().toLowerCase().split(" ");
552 String[] typesFilter = null;
553 if(!typesText.getText().isEmpty()) typesFilter = typesText.getText().toLowerCase().split(" ");
556 for(Bean b : allContents) {
558 if(createdAfterTime > 0 && b.createdAt < createdAfterTime) continue;
559 if(createdBeforeTime > 0 && b.createdAt > createdBeforeTime) continue;
560 if(modifiedAfterTime > 0 && b.modifiedAt < modifiedAfterTime) continue;
561 if(modifiedBeforeTime > 0 && b.modifiedAt > modifiedBeforeTime) continue;
563 if(creatorFilter != null && !b.getCreatedBy().toLowerCase().contains(creatorFilter)) continue;
564 if(modifierFilter != null && !b.getModifiedBy().toLowerCase().contains(modifierFilter)) continue;
565 if(nameFilter!= null) {
566 String name = b.getName().toLowerCase();
568 for(String t : nameFilter) {
569 if(name.contains(t)) {
576 if(pathFilter!= null) {
577 String name = b.getPath().toLowerCase();
579 for(String t : pathFilter) {
580 if(name.contains(t)) {
587 if(typesFilter != null) {
588 String types = b.getTypes().toLowerCase();
590 for(String t : typesFilter) {
591 if(types.contains(t)) {
603 public void searchAndUpdate() {
605 final Display display = WorkbenchUtils.getActiveWorkbenchWindowShell().getDisplay();
606 Job job = new DatabaseJob("Processing change information") {
608 protected IStatus run(final IProgressMonitor monitor) {
613 allContents.addAll(session.syncRequest(new UniqueRead<List<Bean>>() {
615 private void browse(ReadGraph graph, Layer0 L0, Resource r, Set<Resource> visited) throws DatabaseException {
617 if(!visited.add(r)) return;
619 for(Resource object : graph.getObjects(r, L0.DependsOn))
620 browse(graph, L0, object, visited);
625 public List<Bean> perform(ReadGraph graph) throws DatabaseException {
627 SubMonitor sub = SubMonitor.convert(monitor, "Readying change information", 100);
629 sub.setTaskName("Searching for change records");
631 ArrayList<Bean> result = new ArrayList<Bean>();
632 if(resource == null) return result;
634 HashSet<Resource> visited = new HashSet<Resource>();
636 Layer0 L0 = Layer0.getInstance(graph);
637 ModelingResources MOD = ModelingResources.getInstance(graph);
639 browse(graph, L0, resource, visited);
643 sub.setTaskName("Processing " + visited.size() + " change records");
644 sub.setWorkRemaining(visited.size());
646 String baseURI = graph.getPossibleURI(resource);
648 for(Resource r : visited) {
649 ChangeInformation ci = graph.getPossibleRelatedValue(r, MOD.changeInformation, ChangeInformation.BINDING);
650 if(ci != null) result.add(new Bean(graph, r, ci, baseURI));
659 return Status.OK_STATUS;
660 } catch (final DatabaseException e) {
661 showMessage(display, e.getMessage());
662 // WARNING, because we don't want the job system to pop up it's own error dialog
663 // which would happen if ERROR was used.
664 return new Status(IStatus.WARNING, Activator.PLUGIN_ID, "Errors while reading change information.", e);
668 SWTUtils.asyncExec(display, new Runnable() {
679 private void showMessage(Display display, final String message) {
680 SWTUtils.asyncExec(display, new Runnable() {
683 ShowMessage.showError("Problems while reading change information", message);