Lines 860-875
Link Here
|
860 |
} |
860 |
} |
861 |
} |
861 |
} |
862 |
|
862 |
|
863 |
updateProgressLabel(); |
863 |
scheduleProgressMessageRefresh(); |
864 |
} |
864 |
} |
865 |
|
865 |
|
866 |
/** |
866 |
/** |
867 |
* Updates the progress label - should be called in UI thread. |
867 |
* Updates the progress label. |
|
|
868 |
* |
869 |
* @deprecated |
868 |
*/ |
870 |
*/ |
869 |
public void updateProgressLabel() { |
871 |
public void updateProgressLabel() { |
870 |
if (!progressLabel.isDisposed()) { |
872 |
scheduleProgressMessageRefresh(); |
871 |
progressLabel.setText(contentProvider.getProgressMessage()); |
|
|
872 |
} |
873 |
} |
873 |
} |
874 |
|
874 |
|
875 |
/** |
875 |
/** |
Lines 906-913
Link Here
|
906 |
* Schedules progress message refresh. |
906 |
* Schedules progress message refresh. |
907 |
*/ |
907 |
*/ |
908 |
public void scheduleProgressMessageRefresh() { |
908 |
public void scheduleProgressMessageRefresh() { |
909 |
if (refreshProgressMessageJob.cancel()) |
909 |
if (filterJob.getState() != Job.RUNNING && refreshProgressMessageJob.getState() != Job.RUNNING) |
910 |
refreshProgressMessageJob.schedule(); |
910 |
refreshProgressMessageJob.scheduleProgressRefresh(null); |
911 |
} |
911 |
} |
912 |
|
912 |
|
913 |
/* |
913 |
/* |
Lines 1288-1302
Link Here
|
1288 |
} |
1288 |
} |
1289 |
|
1289 |
|
1290 |
/** |
1290 |
/** |
1291 |
* Refreshes the progress message. |
1291 |
* Refreshes the progress message cyclically with 500 milliseconds delay. |
1292 |
* |
1292 |
* <code>RefreshProgressMessageJob</code> is strictly connected with |
|
|
1293 |
* <code>GranualProgressMonitor</code> and use it to to get progress |
1294 |
* message and to decide about break of cyclical refresh. |
1293 |
*/ |
1295 |
*/ |
1294 |
private class RefreshProgressMessageJob extends UIJob { |
1296 |
private class RefreshProgressMessageJob extends UIJob { |
1295 |
|
1297 |
|
1296 |
private boolean cancelling = false; |
1298 |
private GranualProgressMonitor progressMonitor; |
1297 |
|
1299 |
|
1298 |
/** |
1300 |
/** |
1299 |
* Creates a new instance of the class |
1301 |
* Creates a new instance of the class. |
1300 |
*/ |
1302 |
*/ |
1301 |
public RefreshProgressMessageJob() { |
1303 |
public RefreshProgressMessageJob() { |
1302 |
super( |
1304 |
super( |
Lines 1306-1335
Link Here
|
1306 |
setSystem(true); |
1308 |
setSystem(true); |
1307 |
} |
1309 |
} |
1308 |
|
1310 |
|
|
|
1311 |
/* (non-Javadoc) |
1312 |
* @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor) |
1313 |
*/ |
1309 |
public IStatus runInUIThread(IProgressMonitor monitor) { |
1314 |
public IStatus runInUIThread(IProgressMonitor monitor) { |
1310 |
|
1315 |
|
1311 |
cancelling = false; |
1316 |
if (!progressLabel.isDisposed()) |
1312 |
|
1317 |
progressLabel.setText(progressMonitor != null ? progressMonitor |
1313 |
if (FilteredItemsSelectionDialog.this != null) { |
1318 |
.getMessage() : EMPTY_STRING); |
1314 |
FilteredItemsSelectionDialog.this.updateProgressLabel(); |
1319 |
|
1315 |
} |
1320 |
if (progressMonitor == null || progressMonitor.isDone()) { |
|
|
1321 |
return new Status(IStatus.CANCEL, PlatformUI.PLUGIN_ID, |
1322 |
IStatus.CANCEL, EMPTY_STRING, null); } |
1316 |
|
1323 |
|
1317 |
if (cancelling) |
1324 |
// schedule cyclical with 500 milliseconds delay |
1318 |
refreshProgressMessageJob.schedule(); |
1325 |
schedule(500); |
1319 |
|
1326 |
|
1320 |
return new Status(IStatus.OK, PlatformUI.PLUGIN_ID, IStatus.OK, |
1327 |
return new Status(IStatus.OK, PlatformUI.PLUGIN_ID, IStatus.OK, |
1321 |
EMPTY_STRING, null); |
1328 |
EMPTY_STRING, null); |
1322 |
} |
1329 |
} |
1323 |
|
1330 |
|
1324 |
/* |
1331 |
/** |
1325 |
* (non-Javadoc) |
1332 |
* Schedule progress refresh job. |
1326 |
* |
1333 |
* |
1327 |
* @see org.eclipse.core.runtime.jobs.Job#canceling() |
1334 |
* @param progressMonitor |
|
|
1335 |
* used during refresh progress label |
1328 |
*/ |
1336 |
*/ |
1329 |
protected void canceling() { |
1337 |
public void scheduleProgressRefresh( |
1330 |
super.canceling(); |
1338 |
GranualProgressMonitor progressMonitor) { |
1331 |
this.cancelling = true; |
1339 |
this.progressMonitor = progressMonitor; |
|
|
1340 |
schedule(200); |
1332 |
} |
1341 |
} |
|
|
1342 |
|
1333 |
} |
1343 |
} |
1334 |
|
1344 |
|
1335 |
/** |
1345 |
/** |
Lines 1373-1379
Link Here
|
1373 |
|
1383 |
|
1374 |
if (FilteredItemsSelectionDialog.this != null) { |
1384 |
if (FilteredItemsSelectionDialog.this != null) { |
1375 |
GranualProgressMonitor wrappedMonitor = new GranualProgressMonitor( |
1385 |
GranualProgressMonitor wrappedMonitor = new GranualProgressMonitor( |
1376 |
monitor, contentProvider, true); |
1386 |
monitor); |
1377 |
FilteredItemsSelectionDialog.this.reloadCache(true, |
1387 |
FilteredItemsSelectionDialog.this.reloadCache(true, |
1378 |
wrappedMonitor); |
1388 |
wrappedMonitor); |
1379 |
} |
1389 |
} |
Lines 1704-1723
Link Here
|
1704 |
|
1714 |
|
1705 |
/** |
1715 |
/** |
1706 |
* GranualProgressMonitor is used for monitoring progress of filtering |
1716 |
* GranualProgressMonitor is used for monitoring progress of filtering |
1707 |
* process. It updates progress message and refreshes dialog after concrete |
1717 |
* process. It is used by <code>RefreshProgressMessageJob</code> to |
1708 |
* part of work. State of this monitor illustrates state of filtering or |
1718 |
* refresh progress message. State of this monitor illustrates state of |
1709 |
* cache refreshing process. |
1719 |
* filtering or cache refreshing process. |
1710 |
* |
|
|
1711 |
* The <code>GranualProgressMonitor</code> progress monitor changes amount |
1712 |
* of work to be done before next update is to be scheduled (increases |
1713 |
* granuality). For 0-10% updates are scheduled for all whole numbers {1, 2, |
1714 |
* 3, . . ., 10 } surpassed. For 10-100% updates are done every 10%. |
1715 |
* |
1720 |
* |
1716 |
* @see GranualProgressMonitor#internalWorked(double) |
1721 |
* @see GranualProgressMonitor#internalWorked(double) |
1717 |
*/ |
1722 |
*/ |
1718 |
private static class GranualProgressMonitor extends ProgressMonitorWrapper { |
1723 |
private class GranualProgressMonitor extends ProgressMonitorWrapper { |
1719 |
|
|
|
1720 |
private ContentProvider contentProvider; |
1721 |
|
1724 |
|
1722 |
private String name; |
1725 |
private String name; |
1723 |
|
1726 |
|
Lines 1729-1754
Link Here
|
1729 |
|
1732 |
|
1730 |
private boolean done; |
1733 |
private boolean done; |
1731 |
|
1734 |
|
1732 |
private boolean isFiltering; |
|
|
1733 |
|
1734 |
/** |
1735 |
/** |
1735 |
* Creates instance of <code>GranualProgressMonitor</code>. |
1736 |
* Creates instance of <code>GranualProgressMonitor</code>. |
1736 |
* |
1737 |
* |
1737 |
* @param monitor |
1738 |
* @param monitor |
1738 |
* progress to be wrapped |
1739 |
* progress to be wrapped |
1739 |
* @param contentProvider |
|
|
1740 |
* @param isFiltering |
1741 |
* if this progress monitor is attached to a filtering job. |
1742 |
* If <code>false</code> the job ought to be a cache/UI |
1743 |
* refresh job. Filtering jobs have higher priority - if |
1744 |
* there's a running filtering job progress updates triggered |
1745 |
* from a non-filtering job will not be displayed on UI. |
1746 |
*/ |
1740 |
*/ |
1747 |
public GranualProgressMonitor(IProgressMonitor monitor, |
1741 |
public GranualProgressMonitor(IProgressMonitor monitor) { |
1748 |
ContentProvider contentProvider, boolean isFiltering) { |
|
|
1749 |
super(monitor); |
1742 |
super(monitor); |
1750 |
this.contentProvider = contentProvider; |
1743 |
} |
1751 |
this.isFiltering = isFiltering; |
1744 |
|
|
|
1745 |
/** |
1746 |
* Checks if filtering has been done |
1747 |
* |
1748 |
* @return true if filtering work has been done false in other way |
1749 |
*/ |
1750 |
public boolean isDone() { |
1751 |
return done; |
1752 |
} |
1752 |
} |
1753 |
|
1753 |
|
1754 |
/* |
1754 |
/* |
Lines 1760-1766
Link Here
|
1760 |
super.setTaskName(name); |
1760 |
super.setTaskName(name); |
1761 |
this.name = name; |
1761 |
this.name = name; |
1762 |
this.subName = null; |
1762 |
this.subName = null; |
1763 |
updateProgressMessage(); |
|
|
1764 |
} |
1763 |
} |
1765 |
|
1764 |
|
1766 |
/* |
1765 |
/* |
Lines 1771-1777
Link Here
|
1771 |
public void subTask(String name) { |
1770 |
public void subTask(String name) { |
1772 |
super.subTask(name); |
1771 |
super.subTask(name); |
1773 |
this.subName = name; |
1772 |
this.subName = name; |
1774 |
updateProgressMessage(); |
|
|
1775 |
} |
1773 |
} |
1776 |
|
1774 |
|
1777 |
/* |
1775 |
/* |
Lines 1785-1791
Link Here
|
1785 |
if (this.name == null) |
1783 |
if (this.name == null) |
1786 |
this.name = name; |
1784 |
this.name = name; |
1787 |
this.totalWork = totalWork; |
1785 |
this.totalWork = totalWork; |
1788 |
updateProgressMessage(); |
1786 |
refreshProgressMessageJob.scheduleProgressRefresh(this); |
1789 |
} |
1787 |
} |
1790 |
|
1788 |
|
1791 |
/* |
1789 |
/* |
Lines 1805-1811
Link Here
|
1805 |
*/ |
1803 |
*/ |
1806 |
public void done() { |
1804 |
public void done() { |
1807 |
done = true; |
1805 |
done = true; |
1808 |
contentProvider.setProgressMessage("", isFiltering); //$NON-NLS-1$ |
|
|
1809 |
super.done(); |
1806 |
super.done(); |
1810 |
} |
1807 |
} |
1811 |
|
1808 |
|
Lines 1815-1821
Link Here
|
1815 |
* @see org.eclipse.core.runtime.ProgressMonitorWrapper#setCanceled(boolean) |
1812 |
* @see org.eclipse.core.runtime.ProgressMonitorWrapper#setCanceled(boolean) |
1816 |
*/ |
1813 |
*/ |
1817 |
public void setCanceled(boolean b) { |
1814 |
public void setCanceled(boolean b) { |
1818 |
done = true; |
1815 |
done = b; |
1819 |
super.setCanceled(b); |
1816 |
super.setCanceled(b); |
1820 |
} |
1817 |
} |
1821 |
|
1818 |
|
Lines 1826-1839
Link Here
|
1826 |
*/ |
1823 |
*/ |
1827 |
public void internalWorked(double work) { |
1824 |
public void internalWorked(double work) { |
1828 |
worked = worked + work; |
1825 |
worked = worked + work; |
1829 |
if ((((int) (((worked - work) * 10) / totalWork)) < ((int) ((worked * 10) / totalWork))) |
|
|
1830 |
|| (((int) ((worked * 10) / totalWork)) == 0)) |
1831 |
if (!isCanceled()) |
1832 |
updateProgressMessage(); |
1833 |
} |
1834 |
|
1835 |
private void updateProgressMessage() { |
1836 |
contentProvider.setProgressMessage(getMessage(), isFiltering); |
1837 |
} |
1826 |
} |
1838 |
|
1827 |
|
1839 |
private String getMessage() { |
1828 |
private String getMessage() { |
Lines 1868-1874
Link Here
|
1868 |
|
1857 |
|
1869 |
/** |
1858 |
/** |
1870 |
* Filters items history and schedule filter job. |
1859 |
* Filters items history and schedule filter job. |
1871 |
* |
|
|
1872 |
*/ |
1860 |
*/ |
1873 |
private class FilterHistoryJob extends Job { |
1861 |
private class FilterHistoryJob extends Job { |
1874 |
|
1862 |
|
Lines 1878-1891
Link Here
|
1878 |
private ItemsFilter itemsFilter; |
1866 |
private ItemsFilter itemsFilter; |
1879 |
|
1867 |
|
1880 |
/** |
1868 |
/** |
1881 |
* Create a new instance of the receiver. |
1869 |
* Creates new instance of reciever. |
1882 |
*/ |
1870 |
*/ |
1883 |
public FilterHistoryJob() { |
1871 |
public FilterHistoryJob() { |
1884 |
super(WorkbenchMessages.FilteredItemsSelectionDialog_jobLabel); |
1872 |
super(WorkbenchMessages.FilteredItemsSelectionDialog_jobLabel); |
1885 |
setSystem(true); |
1873 |
setSystem(true); |
1886 |
} |
1874 |
} |
1887 |
|
1875 |
|
1888 |
/* (non-Javadoc) |
1876 |
/* |
|
|
1877 |
* (non-Javadoc) |
1878 |
* |
1889 |
* @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor) |
1879 |
* @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor) |
1890 |
*/ |
1880 |
*/ |
1891 |
protected IStatus run(IProgressMonitor monitor) { |
1881 |
protected IStatus run(IProgressMonitor monitor) { |
Lines 1926-1932
Link Here
|
1926 |
|
1916 |
|
1927 |
/** |
1917 |
/** |
1928 |
* Creates new instance of FilterJob |
1918 |
* Creates new instance of FilterJob |
1929 |
* |
|
|
1930 |
*/ |
1919 |
*/ |
1931 |
public FilterJob() { |
1920 |
public FilterJob() { |
1932 |
super(WorkbenchMessages.FilteredItemsSelectionDialog_jobLabel); |
1921 |
super(WorkbenchMessages.FilteredItemsSelectionDialog_jobLabel); |
Lines 1939-1946
Link Here
|
1939 |
* @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor) |
1928 |
* @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor) |
1940 |
*/ |
1929 |
*/ |
1941 |
protected final IStatus run(IProgressMonitor parent) { |
1930 |
protected final IStatus run(IProgressMonitor parent) { |
1942 |
GranualProgressMonitor monitor = new GranualProgressMonitor(parent, |
1931 |
GranualProgressMonitor monitor = new GranualProgressMonitor(parent); |
1943 |
contentProvider, true); |
|
|
1944 |
return doRun(monitor); |
1932 |
return doRun(monitor); |
1945 |
} |
1933 |
} |
1946 |
|
1934 |
|
Lines 2005-2011
Link Here
|
2005 |
throws CoreException { |
1993 |
throws CoreException { |
2006 |
|
1994 |
|
2007 |
if (lastCompletedFilter != null |
1995 |
if (lastCompletedFilter != null |
2008 |
&& lastCompletedFilter.isSubFilter(filter)) { |
1996 |
&& lastCompletedFilter.isSubFilter(this.itemsFilter)) { |
2009 |
|
1997 |
|
2010 |
int length = lastCompletedResult.size() / 500; |
1998 |
int length = lastCompletedResult.size() / 500; |
2011 |
monitor |
1999 |
monitor |
Lines 2035-2051
Link Here
|
2035 |
monitor |
2023 |
monitor |
2036 |
.beginTask( |
2024 |
.beginTask( |
2037 |
WorkbenchMessages.FilteredItemsSelectionDialog_searchJob_taskName, |
2025 |
WorkbenchMessages.FilteredItemsSelectionDialog_searchJob_taskName, |
2038 |
1000); |
2026 |
100); |
2039 |
subMonitor = new SubProgressMonitor(monitor, 500); |
2027 |
subMonitor = new SubProgressMonitor(monitor, 95); |
2040 |
|
2028 |
|
2041 |
} |
2029 |
} |
2042 |
|
2030 |
|
2043 |
fillContentProvider(contentProvider, itemsFilter, subMonitor); |
2031 |
fillContentProvider(contentProvider, itemsFilter, subMonitor); |
2044 |
|
2032 |
|
2045 |
if (monitor != null && !monitor.isCanceled()) { |
2033 |
if (monitor != null && !monitor.isCanceled()) { |
2046 |
monitor.worked(100); |
2034 |
monitor.worked(2); |
2047 |
contentProvider.rememberResult(itemsFilter); |
2035 |
contentProvider.rememberResult(itemsFilter); |
2048 |
monitor.worked(400); |
2036 |
monitor.worked(3); |
2049 |
} |
2037 |
} |
2050 |
} |
2038 |
} |
2051 |
|
2039 |
|
Lines 2445-2453
Link Here
|
2445 |
* Items that are duplicates. |
2433 |
* Items that are duplicates. |
2446 |
*/ |
2434 |
*/ |
2447 |
private Set duplicates; |
2435 |
private Set duplicates; |
2448 |
|
2436 |
|
2449 |
private String progressMessage = ""; //$NON-NLS-1$ |
|
|
2450 |
|
2451 |
/** |
2437 |
/** |
2452 |
* List of <code>ViewerFilter</code>s to be used during filtering |
2438 |
* List of <code>ViewerFilter</code>s to be used during filtering |
2453 |
*/ |
2439 |
*/ |
Lines 2526-2532
Link Here
|
2526 |
this.items.clear(); |
2512 |
this.items.clear(); |
2527 |
this.duplicates.clear(); |
2513 |
this.duplicates.clear(); |
2528 |
this.lastSortedItems.clear(); |
2514 |
this.lastSortedItems.clear(); |
2529 |
this.progressMessage = ""; //$NON-NLS-1$ |
|
|
2530 |
} |
2515 |
} |
2531 |
|
2516 |
|
2532 |
/** |
2517 |
/** |
Lines 2587-2619
Link Here
|
2587 |
} |
2572 |
} |
2588 |
|
2573 |
|
2589 |
/** |
2574 |
/** |
2590 |
* Sets progress message. |
|
|
2591 |
* |
2592 |
* @param progressMessage |
2593 |
* @param isFiltering |
2594 |
* if this progress update was triggered by a filtering job |
2595 |
* or a refresh job; if it was triggered by a refresh job and |
2596 |
* a filtering job is running, the progress won't be |
2597 |
* displayed |
2598 |
*/ |
2599 |
public void setProgressMessage(String progressMessage, |
2600 |
boolean isFiltering) { |
2601 |
if (!isFiltering && filterJob.getState() == Job.RUNNING) |
2602 |
return; |
2603 |
this.progressMessage = progressMessage; |
2604 |
scheduleProgressMessageRefresh(); |
2605 |
} |
2606 |
|
2607 |
/** |
2608 |
* Gets progress message. |
2609 |
* |
2610 |
* @return progress message |
2611 |
*/ |
2612 |
public String getProgressMessage() { |
2613 |
return progressMessage; |
2614 |
} |
2615 |
|
2616 |
/** |
2617 |
* Removes items from history and refreshes the view. |
2575 |
* Removes items from history and refreshes the view. |
2618 |
* |
2576 |
* |
2619 |
* @param item |
2577 |
* @param item |
Lines 2740-2755
Link Here
|
2740 |
* @param itemsFilter |
2698 |
* @param itemsFilter |
2741 |
*/ |
2699 |
*/ |
2742 |
public void rememberResult(ItemsFilter itemsFilter) { |
2700 |
public void rememberResult(ItemsFilter itemsFilter) { |
2743 |
if (itemsFilter == filter && lastCompletedFilter == null) { |
2701 |
List itemsList = Collections.synchronizedList(Arrays |
2744 |
lastCompletedResult = Collections.synchronizedList(Arrays |
2702 |
.asList(getItems(false))); |
2745 |
.asList(getItems(false))); |
2703 |
// synchronization |
2746 |
// synchronization |
2704 |
if (itemsFilter == filter) { |
2747 |
if (lastCompletedResult.size() == 0 && itemsFilter != filter) { |
2705 |
lastCompletedFilter = itemsFilter; |
2748 |
lastCompletedFilter = null; |
2706 |
lastCompletedResult = itemsList; |
2749 |
lastCompletedResult = null; |
|
|
2750 |
} else { |
2751 |
lastCompletedFilter = itemsFilter; |
2752 |
} |
2753 |
} |
2707 |
} |
2754 |
|
2708 |
|
2755 |
} |
2709 |
} |
Lines 2823-2831
Link Here
|
2823 |
|
2777 |
|
2824 |
// the TableViewer's root (the input) is treated as parent |
2778 |
// the TableViewer's root (the input) is treated as parent |
2825 |
|
2779 |
|
2826 |
lastFilteredItems = Arrays.asList(getFilteredItems(list |
2780 |
lastFilteredItems = Arrays.asList(getFilteredItems(list.getInput(), |
2827 |
.getInput(), monitor != null ? new SubProgressMonitor( |
2781 |
monitor != null ? new SubProgressMonitor(monitor, 100) |
2828 |
monitor, 100) : null)); |
2782 |
: null)); |
2829 |
|
2783 |
|
2830 |
if (reset || (monitor != null && monitor.isCanceled())) { |
2784 |
if (reset || (monitor != null && monitor.isCanceled())) { |
2831 |
if (monitor != null) |
2785 |
if (monitor != null) |
Lines 2920-2926
Link Here
|
2920 |
} |
2874 |
} |
2921 |
} |
2875 |
} |
2922 |
|
2876 |
|
2923 |
if (filteredElements == null) { |
2877 |
if (filteredElements == null || monitor.isCanceled()) { |
2924 |
if (monitor != null) |
2878 |
if (monitor != null) |
2925 |
monitor.done(); |
2879 |
monitor.done(); |
2926 |
return new Object[0]; |
2880 |
return new Object[0]; |