Example usage for javax.swing AbstractAction AbstractAction

List of usage examples for javax.swing AbstractAction AbstractAction

Introduction

In this page you can find the example usage for javax.swing AbstractAction AbstractAction.

Prototype

public AbstractAction() 

Source Link

Document

Creates an Action .

Usage

From source file:org.rdv.ui.ChannelListPanel.java

/**
 * Create the UI panel that contains the controls to filter the channel list.
 * //from   w w  w . ja  v a 2  s .  co  m
 * @return  the UI component dealing with filtering
 */
private JComponent createFilterPanel() {
    JPanel filterPanel = new JPanel();
    filterPanel.setLayout(new BorderLayout(5, 5));
    filterPanel.setBackground(Color.white);
    filterPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    JLabel filterIconLabel = new JLabel(DataViewer.getIcon("icons/filter.gif"));
    filterPanel.add(filterIconLabel, BorderLayout.WEST);

    filterTextField = new JTextField();
    filterTextField.setToolTipText("Enter text here to filter the channel list");
    filterTextField.getDocument().addDocumentListener(new DocumentListener() {
        public void changedUpdate(DocumentEvent e) {
            treeModel.setFilter(filterTextField.getText());
        }

        public void insertUpdate(DocumentEvent e) {
            changedUpdate(e);
        }

        public void removeUpdate(DocumentEvent e) {
            changedUpdate(e);
        }
    });
    filterPanel.add(filterTextField, BorderLayout.CENTER);

    Action focusFilterAction = new AbstractAction() {
        /** serialization version identifier */
        private static final long serialVersionUID = -2443410059209958411L;

        public void actionPerformed(ActionEvent e) {
            filterTextField.requestFocusInWindow();
            filterTextField.selectAll();
        }
    };

    int modifier = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
    filterTextField.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
            .put(KeyStroke.getKeyStroke(KeyEvent.VK_F, modifier), "focusFilter");
    filterTextField.getActionMap().put("focusFilter", focusFilterAction);

    Action cancelFilterAction = new AbstractAction(null, DataViewer.getIcon("icons/cancel.gif")) {
        /** serialization version identifier */
        private static final long serialVersionUID = 8913797349366699615L;

        public void actionPerformed(ActionEvent e) {
            treeModel.setFilter(null);
        }
    };
    cancelFilterAction.putValue(Action.SHORT_DESCRIPTION, "Cancel filter");

    filterTextField.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "cancelFilter");
    filterTextField.getActionMap().put("cancelFilter", cancelFilterAction);

    clearFilterButton = new JButton(cancelFilterAction);
    clearFilterButton.setBorderPainted(false);
    clearFilterButton.setVisible(false);
    filterPanel.add(clearFilterButton, BorderLayout.EAST);

    return filterPanel;
}

From source file:fxts.stations.util.preferences.EditAction.java

public void actionPerformed(ActionEvent aEvent) {
    JButton okButton = UIManager.getInst().createButton();
    JButton cancelButton = UIManager.getInst().createButton();
    final JDialog dialog = new JDialog(mEditorPanel.getParentDialog());
    dialog.setTitle(mEditorPanel.getTitle());
    JPanel editPanel = new JPanel();
    JPanel buttonPanel = new JPanel();
    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(UIFrontEnd.getInstance().getSideLayout());
    //mainPanel.setLayout(new SideLayout());

    //sets button panel
    buttonPanel.setLayout(UIFrontEnd.getInstance().getSideLayout());
    okButton.setText(mResMan.getString("IDS_OK_BUTTON"));
    //okButton.setPreferredSize(new Dimension(80, 27));
    GridBagConstraints sideConstraints = UIFrontEnd.getInstance().getSideConstraints();
    sideConstraints.insets = new Insets(10, 10, 10, 10);
    sideConstraints.gridx = 0;//from ww  w .  ja  v a  2s  .c o  m
    sideConstraints.gridy = 0;
    ResizeParameterWrapper resizeParameter = UIFrontEnd.getInstance().getResizeParameter();
    resizeParameter.init(0.5, 0.0, 0.5, 0.0);
    resizeParameter.setToConstraints(sideConstraints);
    buttonPanel.add(okButton, sideConstraints);
    cancelButton.setText(mResMan.getString("IDS_CANCEL_BUTTON"));
    //cancelButton.setPreferredSize(new Dimension(80, 27));
    sideConstraints = UIFrontEnd.getInstance().getSideConstraints();
    sideConstraints.insets = new Insets(10, 10, 10, 10);
    sideConstraints.gridx = 1;
    sideConstraints.gridy = 0;
    resizeParameter = UIFrontEnd.getInstance().getResizeParameter();
    resizeParameter.init(0.5, 0.0, 0.5, 0.0);
    resizeParameter.setToConstraints(sideConstraints);
    buttonPanel.add(cancelButton, sideConstraints);

    //adds button panel
    sideConstraints = UIFrontEnd.getInstance().getSideConstraints();
    sideConstraints.insets = new Insets(10, 10, 10, 10);
    sideConstraints.gridx = 0;
    sideConstraints.gridy = 1;
    resizeParameter = UIFrontEnd.getInstance().getResizeParameter();
    resizeParameter.init(0.0, 1.0, 1.0, 1.0);
    resizeParameter.setToConstraints(sideConstraints);
    mainPanel.add(buttonPanel, sideConstraints);

    //sets edit panel
    final IEditor editor = mType.getEditor();
    editor.setValue(mValue);
    editPanel.setLayout(UIFrontEnd.getInstance().getSideLayout());
    sideConstraints = UIFrontEnd.getInstance().getSideConstraints();
    resizeParameter = UIFrontEnd.getInstance().getResizeParameter();
    resizeParameter.init(0.0, 0.0, 1.0, 1.0);
    resizeParameter.setToConstraints(sideConstraints);
    Component editComp = editor.getComponent();

    //Mar 25 2004 - kav: added for right tab order at Font Chooser at java 1.4.
    if (editComp instanceof FontChooser) {
        FontChooser fc = (FontChooser) editComp;
        fc.setNextFocusedComp(okButton);
    }
    editPanel.add(editComp, sideConstraints);

    //adds editor panel
    sideConstraints = UIFrontEnd.getInstance().getSideConstraints();
    sideConstraints.gridx = 0;
    sideConstraints.gridy = 0;
    resizeParameter = UIFrontEnd.getInstance().getResizeParameter();
    resizeParameter.init(0.0, 0.0, 1.0, 1.0);
    resizeParameter.setToConstraints(sideConstraints);
    mainPanel.add(editPanel, sideConstraints);

    //adds main panel
    dialog.getContentPane().setLayout(UIFrontEnd.getInstance().getSideLayout());
    //dialog.getContentPane().setLayout(new SideLayout());
    sideConstraints = UIFrontEnd.getInstance().getSideConstraints();
    sideConstraints.fill = GridBagConstraints.BOTH;
    resizeParameter = UIFrontEnd.getInstance().getResizeParameter();
    resizeParameter.init(0.0, 0.0, 1.0, 1.0);
    resizeParameter.setToConstraints(sideConstraints);
    dialog.getContentPane().add(mainPanel, sideConstraints);

    //adds listeners to buttons
    okButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent aEvent) {
            if (editor.getValue().equals(mValue)) {
                //
            } else {
                mValue = editor.getValue();
                mEditorPanel.setValue(mValue);
                mEditorPanel.refreshControls();
                mEditorPanel.setValueChanged(true);
            }
            dialog.setVisible(false);
            dialog.dispose();
        }
    });
    okButton.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
            "ExitAction");
    okButton.getActionMap().put("ExitAction", new AbstractAction() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent aEvent) {
            editor.setValue(mValue);
            dialog.setVisible(false);
            dialog.dispose();
        }
    });
    okButton.requestFocus();
    cancelButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent aEvent) {
            editor.setValue(mValue);
            dialog.setVisible(false);
            dialog.dispose();
        }
    });
    //dialog.setResizable(false);
    dialog.setModal(true);
    dialog.pack();

    //sets minimal sizes for components
    Dimension dim = mainPanel.getSize();
    mainPanel.setMinimumSize(dim);
    mainPanel.setPreferredSize(dim);

    //sets size of buttons
    Dimension dimOkButton = okButton.getSize();
    Dimension dimCancelButton = cancelButton.getSize();
    int nMaxWidth = dimOkButton.getWidth() > dimCancelButton.getWidth() ? (int) dimOkButton.getWidth()
            : (int) dimCancelButton.getWidth();
    okButton.setPreferredSize(new Dimension(nMaxWidth, (int) dimOkButton.getHeight()));
    okButton.setSize(new Dimension(nMaxWidth, (int) dimOkButton.getHeight()));
    cancelButton.setPreferredSize(new Dimension(nMaxWidth, (int) dimCancelButton.getHeight()));
    cancelButton.setSize(new Dimension(nMaxWidth, (int) dimCancelButton.getHeight()));
    dialog.setLocationRelativeTo(dialog.getOwner());
    dialog.setVisible(true);
}

From source file:de.tor.tribes.ui.views.DSWorkbenchSelectionFrame.java

/**
 * Creates new form DSWorkbenchSelectionFrame
 *///from w  w w . j  a  v  a2  s.  com
DSWorkbenchSelectionFrame() {
    initComponents();
    centerPanel = new GenericTestPanel(true);
    jSelectionPanel.add(centerPanel, BorderLayout.CENTER);
    centerPanel.setChildComponent(jSelectionTreePanel);
    buildMenu();
    capabilityInfoPanel1.addActionListener(this);
    treeData = new LinkedList<>();
    jSelectionTree.setCellRenderer(new NodeCellRenderer());

    KeyStroke copy = KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.CTRL_MASK, false);
    KeyStroke bbCopy = KeyStroke.getKeyStroke(KeyEvent.VK_B, ActionEvent.CTRL_MASK, false);
    KeyStroke paste = KeyStroke.getKeyStroke(KeyEvent.VK_V, ActionEvent.CTRL_MASK, false);
    KeyStroke delete = KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0, false);
    KeyStroke cut = KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK, false);
    jSelectionTree.registerKeyboardAction(DSWorkbenchSelectionFrame.this, "Copy", copy,
            JComponent.WHEN_FOCUSED);
    jSelectionTree.registerKeyboardAction(DSWorkbenchSelectionFrame.this, "BBCopy", bbCopy,
            JComponent.WHEN_FOCUSED);
    jSelectionTree.registerKeyboardAction(DSWorkbenchSelectionFrame.this, "Delete", delete,
            JComponent.WHEN_FOCUSED);
    jSelectionTree.registerKeyboardAction(DSWorkbenchSelectionFrame.this, "Paste", paste,
            JComponent.WHEN_FOCUSED);
    jSelectionTree.registerKeyboardAction(DSWorkbenchSelectionFrame.this, "Cut", cut, JComponent.WHEN_FOCUSED);
    jSelectionTree.getActionMap().put("find", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            //ignore find
        }
    });
    jSelectionTree.getSelectionModel().addTreeSelectionListener(DSWorkbenchSelectionFrame.this);

    buildTree();

    //<editor-fold defaultstate="collapsed" desc=" Init HelpSystem ">
    if (!Constants.DEBUG) {
        GlobalOptions.getHelpBroker().enableHelpKey(getRootPane(), "pages.selection_tool",
                GlobalOptions.getHelpBroker().getHelpSet());
    }
    //</editor-fold>
}

From source file:fi.smaa.jsmaa.gui.SMAATRIGUIFactory.java

private JMenuItem createAddCatMenuItem() {
    JMenuItem item = new JMenuItem("Add new");
    item.setMnemonic('n');
    item.setIcon(ImageFactory.IMAGELOADER.getIcon(FileNames.ICON_ADD));
    item.addActionListener(new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            addCategory();/*from   w  ww  . j a v  a2 s .  c o m*/
        }
    });
    return item;
}

From source file:de.codesourcery.eve.skills.ui.components.impl.planning.ShoppingListEditorComponent.java

@Override
protected JPanel createPanelHook() {

    final JPanel result = new JPanel();

    addItemsButton.addActionListener(new ActionListener() {

        @Override// ww  w.  ja  v  a2  s .c  o m
        public void actionPerformed(ActionEvent e) {
            final ItemChooserComponent comp = new ItemChooserComponent(
                    ItemChooserComponent.SelectionMode.MULTIPLE_SELECTION);

            comp.setModal(true);
            ComponentWrapper.wrapComponent("Add items", comp).setVisible(true);

            if (!comp.wasCancelled()) {
                for (ItemWithQuantity item : comp.getSelectedItemsWithQuantity()) {
                    tableModel.addItem(item);
                }
            }
        }
    });

    final PopupMenuBuilder menuBuilder = new PopupMenuBuilder();

    menuBuilder.addItem("Delete", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            deleteSelectedEntriesFromList();
        }

        @Override
        public boolean isEnabled() {
            return table.getSelectedRows().length > 0;
        }
    });

    menuBuilder.attach(table);

    table.setFillsViewportHeight(true);

    final JPanel top = new JPanel();

    new GridLayoutBuilder().add(new GridLayoutBuilder.VerticalGroup(
            new GridLayoutBuilder.HorizontalGroup(new GridLayoutBuilder.FixedCell(new JLabel("Title")),
                    new GridLayoutBuilder.FixedCell(title)),
            new GridLayoutBuilder.HorizontalGroup(new GridLayoutBuilder.FixedCell(new JLabel("Description")),
                    new GridLayoutBuilder.FixedCell(description)),
            new GridLayoutBuilder.HorizontalGroup(new GridLayoutBuilder.FixedCell(addItemsButton)))).addTo(top);

    new GridLayoutBuilder().add(new GridLayoutBuilder.VerticalGroup(new GridLayoutBuilder.FixedCell(top),
            new GridLayoutBuilder.Cell(new JScrollPane(table)))).addTo(result);

    this.title.setColumns(25);
    this.description.setLineWrap(true);
    this.description.setWrapStyleWord(true);

    return result;
}

From source file:captureplugin.CapturePlugin.java

public ActionMenu getContextMenuActions(final Program program) {

    final DeviceIf[] devices = mConfig.getDeviceArray();

    final Window parent = UiUtilities.getLastModalChildOf(getParentFrame());

    Action mainaction = new devplugin.ContextMenuAction();
    mainaction.putValue(Action.NAME, mLocalizer.msg("record", "record Program"));
    mainaction.putValue(Action.SMALL_ICON, createImageIcon("mimetypes", "video-x-generic", 16));

    ArrayList<ActionMenu> actionList = new ArrayList<ActionMenu>();

    for (final DeviceIf dev : devices) {
        Action action = new ContextMenuAction();
        action.putValue(Action.NAME, dev.getName());

        ArrayList<AbstractAction> commandList = new ArrayList<AbstractAction>();

        if (dev.isAbleToAddAndRemovePrograms()) {
            final Program test = dev.getProgramForProgramInList(program);

            if (test != null) {
                AbstractAction caction = new AbstractAction() {
                    public void actionPerformed(ActionEvent evt) {
                        dev.remove(parent, test);
                        updateMarkedPrograms();
                    }/*from  w w  w.j  a  va  2  s.c  o  m*/
                };
                caction.putValue(Action.NAME, Localizer.getLocalization(Localizer.I18N_DELETE));
                commandList.add(caction);
            } else {
                AbstractAction caction = new AbstractAction() {
                    public void actionPerformed(ActionEvent evt) {
                        if (dev.add(parent, program)) {
                            dev.sendProgramsToReceiveTargets(new Program[] { program });
                        }
                        updateMarkedPrograms();
                    }
                };
                caction.putValue(Action.NAME, mLocalizer.msg("record", "record"));
                commandList.add(caction);
            }

        }

        String[] commands = dev.getAdditionalCommands();

        if (commands != null) {
            for (int y = 0; y < commands.length; y++) {

                final int num = y;

                AbstractAction caction = new AbstractAction() {

                    public void actionPerformed(ActionEvent evt) {
                        dev.executeAdditionalCommand(parent, num, program);
                    }
                };
                caction.putValue(Action.NAME, commands[y]);
                commandList.add(caction);
            }
        }

        if (!commandList.isEmpty()) {
            actionList.add(new ActionMenu(action, commandList.toArray(new Action[commandList.size()])));
        }
    }

    if (actionList.size() == 1) {
        ActionMenu menu = actionList.get(0);

        if (menu.getSubItems().length == 0) {
            return null;
        }

        if (menu.getSubItems().length == 1) {
            Action action = menu.getSubItems()[0].getAction();
            action.putValue(Action.SMALL_ICON, createImageIcon("mimetypes", "video-x-generic", 16));
            return new ActionMenu(action);
        } else {
            mainaction.putValue(Action.NAME, menu.getTitle());
            return new ActionMenu(mainaction, menu.getSubItems());
        }

    }

    ActionMenu[] actions = new ActionMenu[actionList.size()];
    actionList.toArray(actions);

    if (actions.length == 0) {
        return null;
    }

    return new ActionMenu(mainaction, actions);
}

From source file:fi.smaa.jsmaa.gui.SMAA2GUIFactory.java

private JMenuItem createAddOrdinalCriterionItem() {
    JMenuItem ordCrit = new JMenuItem("Ordinal");
    ordCrit.setIcon(ImageFactory.IMAGELOADER.getIcon(FileNames.ICON_ORDINALCRITERION));

    ordCrit.addActionListener(new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            addCriterionAndStartRename(new OrdinalCriterion(generateNextCriterionName()));
        }//from  w  w  w  .  ja  v  a  2 s .co  m
    });
    return ordCrit;
}

From source file:fr.duminy.components.swing.listpanel.SimpleItemManagerTest.java

private ItemManager<Bean> createItemManagerAndUpdateItemAction(ContainerType containerType, NameType nameType) {
    return createItemManager(containerType, new AbstractAction() {
        @Override/*from  ww  w  .  j a  v a2  s .c  om*/
        public void actionPerformed(ActionEvent e) {
            addCallback(manager.updateItem(getBean()), "update");
        }

        @Override
        public String toString() {
            return "AbstractAction('update')";
        }
    }, nameType);
}

From source file:net.sf.jabref.gui.openoffice.StyleSelectDialog.java

private void init() {
    setupPopupMenu();//ww w  .j  a v  a2 s . c  o m

    addButton.addActionListener(actionEvent -> {
        AddFileDialog addDialog = new AddFileDialog();
        addDialog.setDirectoryPath(preferences.getCurrentStyle());
        addDialog.setVisible(true);
        addDialog.getFileName().ifPresent(fileName -> {
            if (loader.addStyleIfValid(fileName)) {
                preferences.setCurrentStyle(fileName);
            }
        });
        updateStyles();

    });
    addButton.setToolTipText(Localization.lang("Add style file"));

    removeButton.addActionListener(removeAction);
    removeButton.setToolTipText(Localization.lang("Remove style"));

    // Create a preview panel for previewing styles
    // Must be done before creating the table to avoid NPEs
    preview = new PreviewPanel(null, null, "");
    // Use the test entry from the Preview settings tab in Preferences:
    preview.setEntry(prevEntry);

    setupTable();
    updateStyles();

    // Build dialog
    diag = new JDialog(frame, Localization.lang("Select style"), true);

    FormBuilder builder = FormBuilder.create();
    builder.layout(new FormLayout("fill:pref:grow, 4dlu, left:pref, 4dlu, left:pref",
            "pref, 4dlu, 100dlu:grow, 4dlu, pref, 4dlu, fill:100dlu"));
    builder.add(Localization.lang("Select one of the available styles or add a style file from disk.")).xyw(1,
            1, 5);
    builder.add(new JScrollPane(table)).xyw(1, 3, 5);
    builder.add(addButton).xy(3, 5);
    builder.add(removeButton).xy(5, 5);
    builder.add(preview).xyw(1, 7, 5);
    builder.padding("5dlu, 5dlu, 5dlu, 5dlu");

    diag.add(builder.getPanel(), BorderLayout.CENTER);

    AbstractAction okListener = new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent event) {
            if ((table.getRowCount() == 0) || (table.getSelectedRowCount() == 0)) {
                JOptionPane.showMessageDialog(diag, Localization.lang("You must select a valid style file."),
                        Localization.lang("Style selection"), JOptionPane.ERROR_MESSAGE);
                return;
            }
            okPressed = true;
            storeSettings();
            diag.dispose();
        }
    };
    ok.addActionListener(okListener);

    Action cancelListener = new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent event) {
            diag.dispose();
        }
    };
    cancel.addActionListener(cancelListener);

    ButtonBarBuilder bb = new ButtonBarBuilder();
    bb.addGlue();
    bb.addButton(ok);
    bb.addButton(cancel);
    bb.addGlue();
    bb.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    diag.add(bb.getPanel(), BorderLayout.SOUTH);

    ActionMap am = bb.getPanel().getActionMap();
    InputMap im = bb.getPanel().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    im.put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_DIALOG), "close");
    am.put("close", cancelListener);
    im.put(KeyStroke.getKeyStroke("ENTER"), "enterOk");
    am.put("enterOk", okListener);

    diag.pack();

    PositionWindow pw = new PositionWindow(diag, JabRefPreferences.STYLES_POS_X, JabRefPreferences.STYLES_POS_Y,
            JabRefPreferences.STYLES_SIZE_X, JabRefPreferences.STYLES_SIZE_Y);
    pw.setWindowPosition();
}

From source file:de.codesourcery.eve.skills.ui.components.impl.planning.CalendarComponent.java

@Override
protected JPanel createPanel() {

    addEntryButton.setEnabled(false);//w  ww.j  ava2  s  .co m
    addEntryButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            addNewCalendarEntry();
        }

    });

    calendarWidget.addSelectionListener(new ISelectionListener<Date>() {

        @Override
        public void selectionChanged(Date selected) {
            addEntryButton.setEnabled(selected != null);
            tableModel.refresh();
        }
    });

    table.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() != 2 || e.isPopupTrigger()) {
                return;
            }

            final int viewRow = table.rowAtPoint(e.getPoint());
            if (viewRow != -1) {
                editCalendarEntry(tableModel.getRow(table.convertRowIndexToModel(viewRow)));
            }
        }
    });

    table.setFillsViewportHeight(true);
    table.setRowSorter(tableModel.getRowSorter());
    table.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);

    final PopupMenuBuilder menuBuilder = new PopupMenuBuilder();

    menuBuilder.addItem("Remove", new AbstractAction() {

        @Override
        public boolean isEnabled() {
            return !ArrayUtils.isEmpty(table.getSelectedRows());
        }

        @Override
        public void actionPerformed(ActionEvent e) {
            final int[] viewRows = table.getSelectedRows();
            if (ArrayUtils.isEmpty(viewRows)) {
                return;
            }

            final int[] modelRows = new int[viewRows.length];
            int i = 0;
            for (int viewRow : viewRows) {
                modelRows[i++] = table.convertRowIndexToModel(viewRow);
            }

            final List<ICalendarEntry> removedEntries = new ArrayList<ICalendarEntry>();

            for (int modelRow : modelRows) {
                removedEntries.add(tableModel.getRow(modelRow));
            }

            for (ICalendarEntry toBeRemoved : removedEntries) {
                calendarManager.getCalendar().deleteEntry(toBeRemoved);
            }
        }
    });

    menuBuilder.addItem("Edit...", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            final int modelRow = table.convertRowIndexToModel(table.getSelectedRows()[0]);
            editCalendarEntry(tableModel.getRow(modelRow));
        }

        @Override
        public boolean isEnabled() {
            return !ArrayUtils.isEmpty(table.getSelectedRows());
        }
    });

    menuBuilder.attach(table);

    // controls panel
    final JPanel controlsPanel = new JPanel();

    controlsPanel.setLayout(new GridBagLayout());
    controlsPanel.add(addEntryButton, constraints(0, 0).noResizing().end());

    // combine panels
    final JPanel subPanel = new JPanel();

    subPanel.setLayout(new GridBagLayout());

    subPanel.add(controlsPanel, constraints(0, 0).useRelativeWidth().weightY(0).end());
    subPanel.add(new JScrollPane(table), constraints(0, 1).useRelativeWidth().useRemainingHeight().end());

    final ImprovedSplitPane splitPane = new ImprovedSplitPane(JSplitPane.HORIZONTAL_SPLIT, calendarWidget,
            subPanel);

    splitPane.setDividerLocation(0.7);

    final JPanel result = new JPanel();
    result.setLayout(new GridBagLayout());

    result.add(splitPane, constraints(0, 0).resizeBoth().end());

    return result;
}