putValue(SHORT_DESCRIPTION, tr("Add filter."));
putValue(SMALL_ICON, ImageProvider.get("dialogs","add"));
}
@Override
public void actionPerformed(ActionEvent e) {
Filter filter = (Filter)SearchAction.showSearchDialog(new Filter());
if(filter != null){
filterModel.addFilter(filter);
}
}});
SideButton editButton = new SideButton(new AbstractAction() {
{
putValue(NAME, tr("Edit"));
putValue(SHORT_DESCRIPTION, tr("Edit filter."));
putValue(SMALL_ICON, ImageProvider.get("dialogs", "edit"));
}
@Override
public void actionPerformed(ActionEvent e) {
int index = userTable.getSelectionModel().getMinSelectionIndex();
if(index < 0) return;
Filter f = filterModel.getFilter(index);
Filter filter = (Filter)SearchAction.showSearchDialog(f);
if(filter != null){
filterModel.setFilter(index, filter);
}
}
});
SideButton deleteButton = new SideButton(new AbstractAction() {
{
putValue(NAME, tr("Delete"));
putValue(SHORT_DESCRIPTION, tr("Delete filter."));
putValue(SMALL_ICON, ImageProvider.get("dialogs", "delete"));
}
@Override
public void actionPerformed(ActionEvent e) {
int index = userTable.getSelectionModel().getMinSelectionIndex();
if(index < 0) return;
filterModel.removeFilter(index);
}
});
SideButton upButton = new SideButton(new AbstractAction() {
{
putValue(NAME, tr("Up"));
putValue(SHORT_DESCRIPTION, tr("Move filter up."));
putValue(SMALL_ICON, ImageProvider.get("dialogs", "up"));
}
@Override
public void actionPerformed(ActionEvent e) {
int index = userTable.getSelectionModel().getMinSelectionIndex();
if(index < 0) return;
filterModel.moveUpFilter(index);
userTable.getSelectionModel().setSelectionInterval(index-1, index-1);
}
});
SideButton downButton = new SideButton(new AbstractAction() {
{
putValue(NAME, tr("Down"));
putValue(SHORT_DESCRIPTION, tr("Move filter down."));
putValue(SMALL_ICON, ImageProvider.get("dialogs", "down"));
}
@Override
public void actionPerformed(ActionEvent e) {
int index = userTable.getSelectionModel().getMinSelectionIndex();
if(index < 0) return;
filterModel.moveDownFilter(index);
userTable.getSelectionModel().setSelectionInterval(index+1, index+1);
}
});
// Toggle filter "enabled" on Enter
InputMapUtils.addEnterAction(userTable, new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
int index = userTable.getSelectedRow();
if (index<0) return;
Filter filter = filterModel.getFilter(index);
filterModel.setValueAt(!filter.enable, index, FilterTableModel.COL_ENABLED);
}
});
// Toggle filter "hiding" on Spacebar
InputMapUtils.addSpacebarAction(userTable, new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
int index = userTable.getSelectedRow();
if (index<0) return;
Filter filter = filterModel.getFilter(index);
filterModel.setValueAt(!filter.hiding, index, FilterTableModel.COL_HIDING);
}
});
createLayout(userTable, true, Arrays.asList(new SideButton[] {