switch (e.character){
case SWT.CR:
String text = input.getText();
if(input.getText().length() > 0){
//Make the category in Azureus
TorrentAttribute ta = Plugin.getPluginInterface().getTorrentManager().getAttribute(TorrentAttribute.TA_CATEGORY);
ta.addDefinedValue(text);
//Add it to our Properties
Plugin.getProperties().setProperty(text, "");
populateTable();
shell.dispose();
}
case SWT.ESC:
shell.dispose();
break;
}
}
});
Button cancel = new Button(shell, SWT.PUSH);
cancel.setText("Cancel");
cancel.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
shell.dispose();
}
});
Button accept = new Button(shell, SWT.PUSH);
accept.setText("Accept");
accept.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
String text = input.getText();
if(input.getText().length() > 0){
//Make the category in Azureus
TorrentAttribute ta = Plugin.getPluginInterface().getTorrentManager().getAttribute(TorrentAttribute.TA_CATEGORY);
ta.addDefinedValue(text);
//Add it to our Properties
Plugin.getProperties().setProperty(text, "");
populateTable();
shell.dispose();
}
}
});
//open shell
GraphicUtils.centerShellandOpen(shell);
}
});
//remove button on toolbar
remove = new ToolItem(toolBar1, SWT.PUSH);
remove.setImage(ImageRepository.getImage("cancel"));
remove.setEnabled(false);
remove.setToolTipText("Delete selected category");
//-- Listener for Remove
remove.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
TableItem[] toDie = table1.getSelection();
if(toDie.length == 1){
MessageBox messageBox = new MessageBox(toolBar1.getShell(), SWT.ICON_QUESTION | SWT.NO | SWT.YES);
messageBox.setText("Delete Confirmation");
messageBox.setMessage("Are you sure you want to remove the category " + toDie[0].getText(0) + "?");
int response = messageBox.open();
switch (response){
case SWT.YES:
String name = toDie[0].getText(0);
TorrentAttribute ta = Plugin.getPluginInterface().getTorrentManager().getAttribute(TorrentAttribute.TA_CATEGORY);
ta.removeDefinedValue(name);
Plugin.getProperties().remove(name);
Plugin.saveConfig();
populateTable();
remove.setEnabled(false);
break;