Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErich Gamma2004-04-07 10:16:42 +0000
committerErich Gamma2004-04-07 10:16:42 +0000
commit9436f79d714008a75fdb021f5e4974c7f4fa3974 (patch)
treedaab6e6a1382d786f5dfa252608181507ef3aeef
parenta8a1eed389ee575215eda89b5d00ef6c12b744ce (diff)
downloadeclipse.platform.text-9436f79d714008a75fdb021f5e4974c7f4fa3974.tar.gz
eclipse.platform.text-9436f79d714008a75fdb021f5e4974c7f4fa3974.tar.xz
eclipse.platform.text-9436f79d714008a75fdb021f5e4974c7f4fa3974.zip
updated to use IWorbenchSiteProgress service to schedule a job
-rw-r--r--org.eclipse.search/new search/org/eclipse/search2/internal/ui/InternalSearchUI.java43
-rw-r--r--org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchView.java16
2 files changed, 56 insertions, 3 deletions
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/InternalSearchUI.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/InternalSearchUI.java
index 4703a9a2e..beaa12257 100644
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/InternalSearchUI.java
+++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/InternalSearchUI.java
@@ -1,13 +1,17 @@
package org.eclipse.search2.internal.ui;
import java.lang.reflect.InvocationTargetException;
+import java.net.MalformedURLException;
+import java.net.URL;
import java.util.HashMap;
import java.util.Iterator;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.action.Action;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.operation.IRunnableContext;
import org.eclipse.jface.operation.IRunnableWithProgress;
@@ -18,6 +22,7 @@ import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.WorkbenchException;
+import org.eclipse.ui.progress.IWorkbenchSiteProgressService;
import org.eclipse.search.ui.IQueryListener;
import org.eclipse.search.ui.ISearchQuery;
@@ -40,6 +45,8 @@ public class InternalSearchUI {
public static final String SEARCH_VIEW_ID= "org.eclipse.search.ui.views.SearchView"; //$NON-NLS-1$
+ public static final Object FAMILY_SEARCH = new Object();
+
private class SearchJobRecord {
public ISearchQuery fQuery;
public Job fJob;
@@ -72,7 +79,9 @@ public class InternalSearchUI {
fSearchJobRecord.fJob= null;
return status;
}
-
+ public boolean belongsTo(Object family) {
+ return family == InternalSearchUI.FAMILY_SEARCH;
+ }
}
@@ -139,9 +148,37 @@ public class InternalSearchUI {
private void doRunSearchInBackground(SearchJobRecord jobRecord) {
if (jobRecord.fJob == null) {
jobRecord.fJob= new InternalSearchJob(jobRecord);
- jobRecord.fJob.setPriority(Job.BUILD);
+ jobRecord.fJob.setPriority(Job.BUILD);
+ }
+ // TODO temporary to experiment with new jobs view
+ configureJob(jobRecord.fJob);
+ getProgressService().schedule(jobRecord.fJob, 0, true);
+ }
+
+ private void configureJob(Job job) {
+ job.setProperty(new QualifiedName("org.eclipse.ui.workbench.progress", "keep"), Boolean.TRUE);
+ job.setProperty(new QualifiedName("org.eclipse.ui.workbench.progress", "goto"), new Action() {
+ public void run() {
+ activateSearchView();
+ }
+ });
+ try {
+ URL install= SearchPlugin.getDefault().getDescriptor().getInstallURL();
+ URL icon;
+ icon= new URL(install, "icons/full/cview16/searchres.gif");
+ job.setProperty(new QualifiedName("org.eclipse.ui.workbench.progress", "icon"), icon);
+ } catch (MalformedURLException e) {
+ // don't set any icon
}
- jobRecord.fJob.schedule();
+ }
+
+ public IWorkbenchSiteProgressService getProgressService() {
+ IWorkbenchSiteProgressService service = null;
+ Object siteService =
+ getSearchView().getSite().getAdapter(IWorkbenchSiteProgressService.class);
+ if(siteService != null)
+ service = (IWorkbenchSiteProgressService) siteService;
+ return service;
}
public boolean runAgain(ISearchQuery job) {
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchView.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchView.java
index ee4e8d64e..91f1b78ba 100644
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchView.java
+++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchView.java
@@ -28,6 +28,7 @@ import org.eclipse.ui.part.IPageSite;
import org.eclipse.ui.part.Page;
import org.eclipse.ui.part.PageBook;
import org.eclipse.ui.part.PageBookView;
+import org.eclipse.ui.progress.IWorkbenchSiteProgressService;
import org.eclipse.search.ui.IContextMenuConstants;
import org.eclipse.search.ui.IQueryListener;
@@ -377,6 +378,7 @@ public class SearchView extends PageBookView implements ISearchResultViewPart, I
public void init(IViewSite site, IMemento memento) throws PartInitException {
super.init(site, memento);
fPageState= memento;
+ getProgressService().showBusyForFamily(InternalSearchUI.FAMILY_SEARCH);
}
/**
@@ -416,4 +418,18 @@ public class SearchView extends PageBookView implements ISearchResultViewPart, I
return (ISearchResultPage) page;
return null;
}
+
+ public IWorkbenchSiteProgressService getProgressService() {
+ IWorkbenchSiteProgressService service = null;
+ Object siteService =
+ getSite().getAdapter(IWorkbenchSiteProgressService.class);
+ if(siteService != null)
+ service = (IWorkbenchSiteProgressService) siteService;
+ return service;
+ }
+
+ public void showBusy(boolean busy) {
+ super.showBusy(busy);
+ getProgressService().warnOfContentChange();
+ }
}

Back to the top