if (event.eventType != TableRowMouseEvent.EVENT_MOUSEDOWN) {
return;
}
final Object dataSource = ((TableRowCore) event.row).getDataSource(true);
if (dataSource instanceof DiskManagerFileInfo) {
final DiskManagerFileInfo fileInfo = (DiskManagerFileInfo) dataSource;
Rectangle hilowBounds = (Rectangle) event.row.getData("hilowBounds");
if (event.button == 1 && hilowBounds != null
&& hilowBounds.contains(event.x, event.y)) {
if (fileInfo.getPriority() > 0) {
fileInfo.setPriority(0);
} else {
fileInfo.setPriority(1);
}
((TableRowCore) event.row).redraw();
}
Rectangle buttonBounds = (Rectangle) event.row.getData("buttonBounds");
if (buttonBounds != null && buttonBounds.contains(event.x, event.y)) {
Menu menu = new Menu(Display.getDefault().getActiveShell(), SWT.POP_UP);
MenuItem itemHigh = new MenuItem(menu, SWT.RADIO);
Messages.setLanguageText(itemHigh, "priority.high");
itemHigh.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
FilesViewMenuUtil.changePriority(FilesViewMenuUtil.PRIORITY_HIGH,
new Object[] {
dataSource
});
}
});
itemHigh.setSelection(fileInfo.getPriority() != 0);
MenuItem itemNormal = new MenuItem(menu, SWT.RADIO);
Messages.setLanguageText(itemNormal, "priority.normal");
itemNormal.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
FilesViewMenuUtil.changePriority(FilesViewMenuUtil.PRIORITY_NORMAL,
new Object[] {
dataSource
});
}
});
itemNormal.setSelection(fileInfo.getPriority() == 0);
new MenuItem(menu, SWT.SEPARATOR);
boolean canStart = fileInfo.isSkipped() || fileInfo.getDownloadManager().getState() == DownloadManager.STATE_STOPPED;
MenuItem itemStop = new MenuItem(menu, SWT.PUSH);
Messages.setLanguageText(itemStop, "v3.MainWindow.button.stop");
itemStop.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
FilesViewMenuUtil.changePriority(
FilesViewMenuUtil.PRIORITY_SKIPPED, new Object[] {
dataSource
});
}
});
itemStop.setEnabled(!canStart);
MenuItem itemStart = new MenuItem(menu, SWT.PUSH);
Messages.setLanguageText(itemStart, "v3.MainWindow.button.start");
itemStart.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
if (fileInfo.getDownloadManager().getState() == DownloadManager.STATE_STOPPED) {
TorrentUtil.queueDataSources(new Object[] { dataSource }, true);
}
FilesViewMenuUtil.changePriority(FilesViewMenuUtil.PRIORITY_NORMAL,
new Object[] {