|
Lines 14-23
Link Here
|
| 14 |
import java.util.HashSet; |
14 |
import java.util.HashSet; |
| 15 |
import java.util.Iterator; |
15 |
import java.util.Iterator; |
| 16 |
import java.util.LinkedHashMap; |
16 |
import java.util.LinkedHashMap; |
|
|
17 |
import java.util.LinkedHashSet; |
| 17 |
import java.util.List; |
18 |
import java.util.List; |
| 18 |
import java.util.Map; |
19 |
import java.util.Map; |
| 19 |
import java.util.Set; |
20 |
import java.util.Set; |
| 20 |
|
21 |
|
|
|
22 |
import org.eclipse.core.runtime.IProgressMonitor; |
| 23 |
import org.eclipse.core.runtime.IStatus; |
| 24 |
import org.eclipse.core.runtime.Status; |
| 21 |
import org.eclipse.jface.action.Action; |
25 |
import org.eclipse.jface.action.Action; |
| 22 |
import org.eclipse.jface.action.IMenuListener; |
26 |
import org.eclipse.jface.action.IMenuListener; |
| 23 |
import org.eclipse.jface.action.IMenuManager; |
27 |
import org.eclipse.jface.action.IMenuManager; |
|
Lines 151-156
Link Here
|
| 151 |
import org.eclipse.ui.PlatformUI; |
155 |
import org.eclipse.ui.PlatformUI; |
| 152 |
import org.eclipse.ui.part.DrillDownAdapter; |
156 |
import org.eclipse.ui.part.DrillDownAdapter; |
| 153 |
import org.eclipse.ui.part.ViewPart; |
157 |
import org.eclipse.ui.part.ViewPart; |
|
|
158 |
import org.eclipse.ui.progress.WorkbenchJob; |
| 154 |
import org.eclipse.ui.themes.IThemeManager; |
159 |
import org.eclipse.ui.themes.IThemeManager; |
| 155 |
|
160 |
|
| 156 |
/** |
161 |
/** |
|
Lines 179-185
Link Here
|
| 179 |
private static final String ID_SEPARATOR_NEW = "new"; |
184 |
private static final String ID_SEPARATOR_NEW = "new"; |
| 180 |
|
185 |
|
| 181 |
private static final String ID_SEPARATOR_OPERATIONS = "operations"; |
186 |
private static final String ID_SEPARATOR_OPERATIONS = "operations"; |
| 182 |
|
187 |
|
| 183 |
private static final String ID_SEPARATOR_CONTEXT = "context"; |
188 |
private static final String ID_SEPARATOR_CONTEXT = "context"; |
| 184 |
|
189 |
|
| 185 |
public static final String ID_SEPARATOR_TASKS = "tasks"; |
190 |
public static final String ID_SEPARATOR_TASKS = "tasks"; |
|
Lines 203-208
Link Here
|
| 203 |
PriorityLevel.P2.getDescription(), PriorityLevel.P3.getDescription(), PriorityLevel.P4.getDescription(), |
208 |
PriorityLevel.P2.getDescription(), PriorityLevel.P3.getDescription(), PriorityLevel.P4.getDescription(), |
| 204 |
PriorityLevel.P5.getDescription() }; |
209 |
PriorityLevel.P5.getDescription() }; |
| 205 |
|
210 |
|
|
|
211 |
private static final long REFRESH_DELAY_DEFAULT = 200; |
| 212 |
|
| 213 |
private static final long REFRESH_DELAY_MAX = 500; |
| 214 |
|
| 206 |
private static List<AbstractTaskListPresentation> presentationsPrimary = new ArrayList<AbstractTaskListPresentation>(); |
215 |
private static List<AbstractTaskListPresentation> presentationsPrimary = new ArrayList<AbstractTaskListPresentation>(); |
| 207 |
|
216 |
|
| 208 |
private static List<AbstractTaskListPresentation> presentationsSecondary = new ArrayList<AbstractTaskListPresentation>(); |
217 |
private static List<AbstractTaskListPresentation> presentationsSecondary = new ArrayList<AbstractTaskListPresentation>(); |
|
Lines 304-317
Link Here
|
| 304 |
|
313 |
|
| 305 |
public void pageClosed(IWorkbenchPage page) { |
314 |
public void pageClosed(IWorkbenchPage page) { |
| 306 |
// ignore |
315 |
// ignore |
| 307 |
|
316 |
|
| 308 |
} |
317 |
} |
| 309 |
|
318 |
|
| 310 |
public void pageOpened(IWorkbenchPage page) { |
319 |
public void pageOpened(IWorkbenchPage page) { |
| 311 |
// ignore |
320 |
// ignore |
| 312 |
} |
321 |
} |
| 313 |
}; |
322 |
}; |
| 314 |
|
323 |
|
| 315 |
private LinkedHashMap<String, IStructuredSelection> lastSelectionByTaskHandle = new LinkedHashMap<String, IStructuredSelection>( |
324 |
private LinkedHashMap<String, IStructuredSelection> lastSelectionByTaskHandle = new LinkedHashMap<String, IStructuredSelection>( |
| 316 |
SIZE_MAX_SELECTION_HISTORY); |
325 |
SIZE_MAX_SELECTION_HISTORY); |
| 317 |
|
326 |
|
|
Lines 574-580
Link Here
|
| 574 |
if (PlatformUI.getWorkbench().getActiveWorkbenchWindow() != null) { |
583 |
if (PlatformUI.getWorkbench().getActiveWorkbenchWindow() != null) { |
| 575 |
PlatformUI.getWorkbench().getActiveWorkbenchWindow().removePageListener(PAGE_LISTENER); |
584 |
PlatformUI.getWorkbench().getActiveWorkbenchWindow().removePageListener(PAGE_LISTENER); |
| 576 |
} |
585 |
} |
| 577 |
|
586 |
|
| 578 |
final IThemeManager themeManager = getSite().getWorkbenchWindow().getWorkbench().getThemeManager(); |
587 |
final IThemeManager themeManager = getSite().getWorkbenchWindow().getWorkbench().getThemeManager(); |
| 579 |
if (themeManager != null) { |
588 |
if (themeManager != null) { |
| 580 |
themeManager.removePropertyChangeListener(THEME_CHANGE_LISTENER); |
589 |
themeManager.removePropertyChangeListener(THEME_CHANGE_LISTENER); |
|
Lines 1134-1140
Link Here
|
| 1134 |
} |
1143 |
} |
| 1135 |
manager.add(new Separator(ID_SEPARATOR_CONTEXT)); |
1144 |
manager.add(new Separator(ID_SEPARATOR_CONTEXT)); |
| 1136 |
manager.add(new Separator(ID_SEPARATOR_OPERATIONS)); |
1145 |
manager.add(new Separator(ID_SEPARATOR_OPERATIONS)); |
| 1137 |
|
1146 |
|
| 1138 |
if (element instanceof AbstractTask) { |
1147 |
if (element instanceof AbstractTask) { |
| 1139 |
for (String menuPath : dynamicMenuMap.keySet()) { |
1148 |
for (String menuPath : dynamicMenuMap.keySet()) { |
| 1140 |
if (ID_SEPARATOR_CONTEXT.equals(menuPath)) { |
1149 |
if (ID_SEPARATOR_CONTEXT.equals(menuPath)) { |
|
Lines 1148-1154
Link Here
|
| 1148 |
} |
1157 |
} |
| 1149 |
} |
1158 |
} |
| 1150 |
manager.add(new Separator(ID_SEPARATOR_REPOSITORY)); |
1159 |
manager.add(new Separator(ID_SEPARATOR_REPOSITORY)); |
| 1151 |
|
1160 |
|
| 1152 |
if (element instanceof AbstractRepositoryQuery || element instanceof TaskCategory) { |
1161 |
if (element instanceof AbstractRepositoryQuery || element instanceof TaskCategory) { |
| 1153 |
manager.add(new Separator()); |
1162 |
manager.add(new Separator()); |
| 1154 |
addAction(propertiesAction, manager, element); |
1163 |
addAction(propertiesAction, manager, element); |
|
Lines 1362-1367
Link Here
|
| 1362 |
|
1371 |
|
| 1363 |
boolean isInRenameAction = false; |
1372 |
boolean isInRenameAction = false; |
| 1364 |
|
1373 |
|
|
|
1374 |
private DelayedRefreshJob refreshJob = new DelayedRefreshJob("TaskList Refresh"); |
| 1375 |
|
| 1365 |
public void setInRenameAction(boolean b) { |
1376 |
public void setInRenameAction(boolean b) { |
| 1366 |
isInRenameAction = b; |
1377 |
isInRenameAction = b; |
| 1367 |
} |
1378 |
} |
|
Lines 1483-1508
Link Here
|
| 1483 |
* Encapsulates refresh policy. |
1494 |
* Encapsulates refresh policy. |
| 1484 |
*/ |
1495 |
*/ |
| 1485 |
private void refresh(final AbstractTaskContainer element) { |
1496 |
private void refresh(final AbstractTaskContainer element) { |
| 1486 |
if (getViewer().getControl() != null && !getViewer().getControl().isDisposed()) { |
1497 |
refreshJob.refreshTask(element); |
| 1487 |
if (element == null) { |
|
|
| 1488 |
getViewer().refresh(true); |
| 1489 |
} else { |
| 1490 |
try { |
| 1491 |
if (element instanceof AbstractTask) { |
| 1492 |
AbstractTask task = (AbstractTask) element; |
| 1493 |
getViewer().refresh(task, true); |
| 1494 |
} else { |
| 1495 |
getViewer().refresh(element, true); |
| 1496 |
} |
| 1497 |
// TODO: consider moving expansion logic into viewer manager |
| 1498 |
if (isFocusedMode()) { |
| 1499 |
getViewer().expandToLevel(element, 3); |
| 1500 |
} |
| 1501 |
} catch (SWTException e) { |
| 1502 |
StatusHandler.log(e, "Failed to refresh Task List"); |
| 1503 |
} |
| 1504 |
} |
| 1505 |
} |
| 1506 |
} |
1498 |
} |
| 1507 |
|
1499 |
|
| 1508 |
public Image[] getPirorityImages() { |
1500 |
public Image[] getPirorityImages() { |
|
Lines 1684-1687
Link Here
|
| 1684 |
presentationsSecondary.add(presentation); |
1676 |
presentationsSecondary.add(presentation); |
| 1685 |
} |
1677 |
} |
| 1686 |
} |
1678 |
} |
|
|
1679 |
|
| 1680 |
private final class DelayedRefreshJob extends WorkbenchJob { |
| 1681 |
|
| 1682 |
private static final int NOT_SCHEDULED = -1; |
| 1683 |
|
| 1684 |
private LinkedHashSet<AbstractTaskContainer> queue = new LinkedHashSet<AbstractTaskContainer>(); |
| 1685 |
|
| 1686 |
private long scheduleTime = NOT_SCHEDULED; |
| 1687 |
|
| 1688 |
private DelayedRefreshJob(String name) { |
| 1689 |
super(name); |
| 1690 |
|
| 1691 |
setSystem(true); |
| 1692 |
} |
| 1693 |
|
| 1694 |
public synchronized void refreshTask(AbstractTaskContainer element) { |
| 1695 |
queue.add(element); |
| 1696 |
|
| 1697 |
if (scheduleTime == NOT_SCHEDULED) { |
| 1698 |
scheduleTime = System.currentTimeMillis(); |
| 1699 |
schedule(REFRESH_DELAY_DEFAULT); |
| 1700 |
} else if (System.currentTimeMillis() - scheduleTime < REFRESH_DELAY_MAX - REFRESH_DELAY_DEFAULT) { |
| 1701 |
// reschedule to aggregate more refreshes |
| 1702 |
cancel(); |
| 1703 |
schedule(REFRESH_DELAY_DEFAULT); |
| 1704 |
} |
| 1705 |
} |
| 1706 |
|
| 1707 |
public IStatus runInUIThread(IProgressMonitor monitor) { |
| 1708 |
if (getViewer().getControl() == null || getViewer().getControl().isDisposed()) { |
| 1709 |
return Status.CANCEL_STATUS; |
| 1710 |
} |
| 1711 |
|
| 1712 |
final AbstractTaskContainer[] items; |
| 1713 |
synchronized (this) { |
| 1714 |
if (queue.contains(null)) { |
| 1715 |
items = null; |
| 1716 |
} else { |
| 1717 |
items = queue.toArray(new AbstractTaskContainer[0]); |
| 1718 |
} |
| 1719 |
queue.clear(); |
| 1720 |
|
| 1721 |
scheduleTime = NOT_SCHEDULED; |
| 1722 |
} |
| 1723 |
|
| 1724 |
if (items == null) { |
| 1725 |
getViewer().refresh(true); |
| 1726 |
} else if (items.length > 0) { |
| 1727 |
try { |
| 1728 |
for (AbstractTaskContainer item : items) { |
| 1729 |
if (item instanceof AbstractTask) { |
| 1730 |
AbstractTask task = (AbstractTask) item; |
| 1731 |
getViewer().refresh(task, true); |
| 1732 |
} else { |
| 1733 |
getViewer().refresh(item, true); |
| 1734 |
} |
| 1735 |
// TODO: consider moving expansion logic into viewer manager |
| 1736 |
if (isFocusedMode()) { |
| 1737 |
getViewer().expandToLevel(item, 3); |
| 1738 |
} |
| 1739 |
} |
| 1740 |
} catch (SWTException e) { |
| 1741 |
StatusHandler.log(e, "Failed to refresh Task List"); |
| 1742 |
} |
| 1743 |
} |
| 1744 |
|
| 1745 |
return Status.OK_STATUS; |
| 1746 |
} |
| 1747 |
} |
| 1748 |
|
| 1687 |
} |
1749 |
} |