Search in sources :

Example 1 with AddPrefetchUndoableEdit

use of org.apache.cayenne.modeler.undo.AddPrefetchUndoableEdit in project cayenne by apache.

the class SelectQueryPrefetchTab method createToolbar.

protected JComponent createToolbar() {
    JButton add = new CayenneAction.CayenneToolbarButton(null, 1);
    add.setText("Add Prefetch");
    Icon addIcon = ModelerUtil.buildIcon("icon-plus.png");
    add.setIcon(addIcon);
    add.setDisabledIcon(FilteredIconFactory.createDisabledIcon(addIcon));
    add.addActionListener(e -> {
        String prefetch = getSelectedPath();
        if (prefetch == null) {
            return;
        }
        addPrefetch(prefetch);
        Application.getInstance().getUndoManager().addEdit(new AddPrefetchUndoableEdit(prefetch, SelectQueryPrefetchTab.this));
    });
    JButton remove = new CayenneAction.CayenneToolbarButton(null, 3);
    remove.setText("Remove Prefetch");
    Icon removeIcon = ModelerUtil.buildIcon("icon-trash.png");
    remove.setIcon(removeIcon);
    remove.setDisabledIcon(FilteredIconFactory.createDisabledIcon(removeIcon));
    remove.addActionListener(e -> {
        int selection = table.getSelectedRow();
        if (selection < 0) {
            return;
        }
        String prefetch = (String) table.getModel().getValueAt(selection, 0);
        removePrefetch(prefetch);
    });
    JToolBar toolBar = new JToolBar();
    toolBar.setBorder(BorderFactory.createEmptyBorder());
    toolBar.setFloatable(false);
    toolBar.add(add);
    toolBar.add(remove);
    return toolBar;
}
Also used : JButton(javax.swing.JButton) AddPrefetchUndoableEdit(org.apache.cayenne.modeler.undo.AddPrefetchUndoableEdit) Icon(javax.swing.Icon) JToolBar(javax.swing.JToolBar)

Aggregations

Icon (javax.swing.Icon)1 JButton (javax.swing.JButton)1 JToolBar (javax.swing.JToolBar)1 AddPrefetchUndoableEdit (org.apache.cayenne.modeler.undo.AddPrefetchUndoableEdit)1