// It may be the categories array just contains "uncategorised".
allow_category_selection = user_category_found;
}
if (allow_category_selection) {
final Category catUncat = CategoryManager.getCategory(Category.TYPE_UNCATEGORIZED);
if (catUncat != null) {
final MenuItem itemCategory = new MenuItem(menuCategory, SWT.PUSH);
Messages.setLanguageText(itemCategory, catUncat.getName());
itemCategory.addListener(SWT.Selection, new DMTask(dms) {
public void run(DownloadManager dm) {
dm.getDownloadState().setCategory(catUncat);
}
});
new MenuItem(menuCategory, SWT.SEPARATOR);
}
for (i = 0; i < categories.length; i++) {
final Category category = categories[i];
if (category.getType() == Category.TYPE_USER) {
final MenuItem itemCategory = new MenuItem(menuCategory, SWT.PUSH);
itemCategory.setText(category.getName());
itemCategory.addListener(SWT.Selection, new DMTask(dms) {
public void run(DownloadManager dm) {
dm.getDownloadState().setCategory(category);
}
});
}
}
new MenuItem(menuCategory, SWT.SEPARATOR);
}
final MenuItem itemAddCategory = new MenuItem(menuCategory, SWT.PUSH);
Messages.setLanguageText(itemAddCategory, "MyTorrentsView.menu.setCategory.add");
itemAddCategory.addListener(SWT.Selection, new DMTask(dms) {
public void run(DownloadManager[] dms) {
CategoryAdderWindow adderWindow = new CategoryAdderWindow(composite.getDisplay());
Category newCategory = adderWindow.getNewCategory();
if (newCategory != null) assignToCategory(dms, newCategory);
}
});
}