}
}
private void onMouseDown(Event event) {
Point p = new Point(event.x, event.y);
TreeItem item = fCustomTree.getControl().getItem(p);
/* Problem - return */
if (item == null || item.isDisposed())
return;
/* Mouse-Up over Read-State-Column */
if (event.button == 1 && isInImageBounds(item, NewsColumn.TITLE, p)) {
Object data = item.getData();
/* Toggle State between Read / Unread */
if (data instanceof INews) {
INews news = (INews) data;
INews.State newState = (news.getState() == INews.State.READ) ? INews.State.UNREAD : INews.State.READ;
/* Set State */
fBlockNewsStateTracker.set(true);
try {
setNewsState(news, newState, false);
} finally {
fBlockNewsStateTracker.set(false);
}
fLastColumnActionInvokedMillies = System.currentTimeMillis();
/*
* This is a workaround: Immediately after the mouse-down-event has been
* issued, a selection-event is triggered. This event is resulting in the
* news-state-tracker to run and mark the selected news as read again. To
* avoid this, we disable the tracker for a short while and set it back to
* enabled again.
*/
JobRunner.runDelayedFlagInversion(200, fBlockNewsStateTracker);
}
}
/* Mouse-Up over Sticky-State-Column */
else if (event.button == 1 && isInImageBounds(item, NewsColumn.STICKY, p)) {
final Object data = item.getData();
/* Toggle State between Sticky / Not Sticky */
if (data instanceof INews) {
Runnable runnable = new Runnable() {
public void run() {
new MakeNewsStickyAction(new StructuredSelection(data)).run();
}
};
INews news = (INews) data;
if (news.getState() != INews.State.READ && isGroupingByStickyness()) //Workaround for Bug 1279
JobRunner.runInBackgroundThread(50, runnable);
else
runnable.run();
fLastColumnActionInvokedMillies = System.currentTimeMillis();
}
}
/* Mouse-Up over Attachments-Column */
else if (event.button == 1 && isInImageBounds(item, NewsColumn.ATTACHMENTS, p)) {
Object data = item.getData();
MenuManager contextMenu = new MenuManager();
ApplicationActionBarAdvisor.fillAttachmentsMenu(contextMenu, new StructuredSelection(data), fEditorSite, true);
if (fAttachmentsMenu != null)
fAttachmentsMenu.dispose();
fAttachmentsMenu = contextMenu.createContextMenu(fViewer.getControl());
Point cursorLocation = item.getDisplay().getCursorLocation();
cursorLocation.y = cursorLocation.y + 16;
fAttachmentsMenu.setLocation(cursorLocation);
fAttachmentsMenu.setVisible(true);
fLastColumnActionInvokedMillies = System.currentTimeMillis();