/** * Executes job using the given filtering progress monitor. A hook for * subclasses. * * @param monitor * progress monitor * @return result of the execution */ protected IStatus doRun(GranualProgressMonitor monitor) { try { internalRun(monitor); } catch (CoreException e) { cancel(); return new Status( IStatus.ERROR, PlatformUI.PLUGIN_ID, IStatus.ERROR, WorkbenchMessages.FilteredItemsSelectionDialog_jobError, e); } return Status.OK_STATUS; }
/** * Main method for the job. * * @param monitor * @throws CoreException */ private void internalRun(GranualProgressMonitor monitor) throws CoreException { try { if (monitor.isCanceled()) return; this.itemsFilter = filter; if (filter.getPattern().length() != 0) { filterContent(monitor); } if (monitor.isCanceled()) return; contentProvider.refresh(); } finally { monitor.done(); } }
/** * Applies the filter created by <code>createFilter()</code> method to the * items list. When new filter is different than previous one it will cause * refiltering. */ protected void applyFilter() { ItemsFilter newFilter = createFilter(); // don't apply filtering for patterns which mean the same, for example: // *a**b and ***a*b if (filter != null && filter.equalsFilter(newFilter)) { return; } filterHistoryJob.cancel(); filterJob.cancel(); this.filter = newFilter; if (this.filter != null) { filterHistoryJob.schedule(); } }
@Override public boolean close() { this.filterJob.cancel(); this.refreshCacheJob.cancel(); this.refreshProgressMessageJob.cancel(); if (showViewHandler != null) { IHandlerService service = PlatformUI .getWorkbench().getService(IHandlerService.class); service.deactivateHandler(showViewHandler); showViewHandler.getHandler().dispose(); showViewHandler = null; } if (menuManager != null) menuManager.dispose(); if (contextMenuManager != null) contextMenuManager.dispose(); storeDialog(getDialogSettings()); return super.close(); }
/** * Creates a new instance of the class. * * @param shell * shell to parent the dialog on * @param multi * indicates whether dialog allows to select more than one * position in its list of items */ public FilteredItemsSelectionDialog(Shell shell, boolean multi) { super(shell); this.multi = multi; filterHistoryJob = new FilterHistoryJob(); filterJob = new FilterJob(); contentProvider = new ContentProvider(); refreshCacheJob = new RefreshCacheJob(); itemsListSeparator = new ItemsListSeparator( WorkbenchMessages.FilteredItemsSelectionDialog_separatorLabel); selectionMode = NONE; }
@Override protected IStatus run(IProgressMonitor monitor) { this.itemsFilter = filter; contentProvider.reset(); refreshWithLastSelection = false; contentProvider.addHistoryItems(itemsFilter); if (!(lastCompletedFilter != null && lastCompletedFilter .isSubFilter(this.itemsFilter))) contentProvider.refresh(); filterJob.schedule(); return Status.OK_STATUS; }
/** * Schedules progress message refresh. */ public void scheduleProgressMessageRefresh() { if (filterJob.getState() != Job.RUNNING && refreshProgressMessageJob.getState() != Job.RUNNING) refreshProgressMessageJob.scheduleProgressRefresh(null); }
@Override protected final IStatus run(IProgressMonitor parent) { GranualProgressMonitor monitor = new GranualProgressMonitor(parent); return doRun(monitor); }
/** * Creates new instance of FilterJob */ public FilterJob() { super(WorkbenchMessages.FilteredItemsSelectionDialog_jobLabel); setSystem(true); }