private CategoryExplorerWidget explorer;
private Constants constants = ((Constants) GWT.create(Constants.class));
public CategoryManager() {
PrettyFormLayout form = new PrettyFormLayout();
form.addHeader("images/edit_category.gif", new HTML(constants.EditCategories())); //NON-NLS
form.startSection(constants.CategoriesPurposeTip());
explorer = new CategoryExplorerWidget(new CategorySelectHandler() {
public void selected(String sel) {
//don't need this here as we don't do anything on select in this spot
}
});
SimplePanel editable = new SimplePanel();
editable.add( explorer );
form.addAttribute(constants.CurrentCategories(), editable );
HorizontalPanel actions = new HorizontalPanel();
form.addAttribute("", actions);
Button newCat = new Button(constants.NewCategory());
newCat.setTitle(constants.CreateANewCategory());
newCat.addClickListener( new ClickListener() {
public void onClick(Widget w) {
CategoryEditor newCat = new CategoryEditor( explorer.getSelectedPath(), new Command() {
public void execute() {
explorer.refresh();
}
});
newCat.show();
}
} );
actions.add(newCat);
Button rename = new Button(constants.RenameSelected());
rename.addClickListener(new ClickListener() {
public void onClick(Widget w) {
if (!explorer.isSelected()) {
Window.alert(constants.PleaseSelectACategoryToRename());
return;
}
renameSelected();
}
});
actions.add(rename);
Button delete = new Button(constants.DeleteSelected());
delete.addClickListener( new ClickListener() {
public void onClick(Widget w) {
if (!explorer.isSelected()) {
Window.alert(constants.PleaseSelectACategoryToDelete());
return;
}
deleteSelected();
}
} );
delete.setTitle(constants.DeleteSelectedCat());
actions.add(delete);
form.endSection();
initWidget( form );
}