1 18 package org.visualcontent.ui.nodetree; 19 20 import javax.jcr.RepositoryException; 21 import javax.jcr.query.Query; 22 import javax.jcr.query.QueryResult; 23 24 import org.eclipse.core.runtime.IProgressMonitor; 25 import org.eclipse.core.runtime.IStatus; 26 import org.eclipse.core.runtime.Status; 27 import org.eclipse.core.runtime.jobs.Job; 28 import org.eclipse.swt.widgets.Display; 29 import org.visualcontent.ui.UiPlugin; 30 31 35 public class SearchJob extends Job { 36 37 private Query query; 38 private NodeTreeViewPart nodeTreeView; 39 40 public SearchJob(String name, Query aQuery, NodeTreeViewPart theNodeTreeView) { 41 super(name); 42 this.query = aQuery; 43 this.nodeTreeView = theNodeTreeView; 44 } 45 46 49 protected IStatus run(IProgressMonitor monitor) { 50 monitor.beginTask("Search in the repository",IProgressMonitor.UNKNOWN); 51 Display display = nodeTreeView.getSite().getShell().getDisplay(); 52 try { 53 final QueryResult result = query.execute(); 54 display.syncExec( 56 new Runnable () { 57 public void run(){ 58 nodeTreeView.setInput(result); 59 } 60 }); 61 monitor.done(); 62 } 63 catch (final RepositoryException e) { 64 display.syncExec( 65 new Runnable () { 66 public void run(){ 67 UiPlugin.getDefault().showError("Could not execute the query.",e); 68 } 69 }); 70 } 71 return Status.OK_STATUS; 72 } 73 } 74 | Popular Tags |