Search in sources :

Example 1 with IDataFlavorHandler

use of org.freeplane.features.clipboard.mindmapmode.MClipboardController.IDataFlavorHandler in project freeplane by freeplane.

the class SelectedPasteAction method actionPerformed.

public void actionPerformed(final ActionEvent e) {
    final MClipboardController clipboardController = (MClipboardController) ClipboardController.getController();
    final Collection<IDataFlavorHandler> flavorHandlers = clipboardController.getFlavorHandlers();
    if (flavorHandlers.isEmpty()) {
        return;
    }
    final JPanel options = createPane(flavorHandlers);
    if (JOptionPane.CANCEL_OPTION == JOptionPane.showConfirmDialog((Component) e.getSource(), options, (String) getValue(Action.NAME), JOptionPane.OK_CANCEL_OPTION)) {
        return;
    }
    final NodeModel parent = Controller.getCurrentController().getSelection().getSelected();
    final Transferable clipboardContents = clipboardController.getClipboardContents();
    clipboardController.paste(clipboardContents, selectedHandler, parent, false, parent.isNewChildLeft());
    selectedHandler = null;
}
Also used : JPanel(javax.swing.JPanel) NodeModel(org.freeplane.features.map.NodeModel) Transferable(java.awt.datatransfer.Transferable) IDataFlavorHandler(org.freeplane.features.clipboard.mindmapmode.MClipboardController.IDataFlavorHandler) Component(java.awt.Component)

Example 2 with IDataFlavorHandler

use of org.freeplane.features.clipboard.mindmapmode.MClipboardController.IDataFlavorHandler in project freeplane by freeplane.

the class SelectedPasteAction method createPane.

private JPanel createPane(final Collection<IDataFlavorHandler> flavorHandlers) {
    final ButtonGroup group = new ButtonGroup();
    final JRadioButton[] buttons = new JRadioButton[flavorHandlers.size()];
    int i = 0;
    selectedHandler = null;
    for (final IDataFlavorHandler handler : flavorHandlers) {
        final JRadioButton radioButton = new JRadioButton(TextUtils.getText(handler.getClass().getSimpleName()));
        group.add(radioButton);
        if (selectedHandler == null) {
            selectedHandler = handler;
            radioButton.setSelected(true);
        }
        radioButton.addActionListener(new ActionListener() {

            public void actionPerformed(final ActionEvent e) {
                selectedHandler = handler;
            }
        });
        buttons[i++] = radioButton;
    }
    return createPane(buttons);
}
Also used : JRadioButton(javax.swing.JRadioButton) ActionListener(java.awt.event.ActionListener) ButtonGroup(javax.swing.ButtonGroup) ActionEvent(java.awt.event.ActionEvent) IDataFlavorHandler(org.freeplane.features.clipboard.mindmapmode.MClipboardController.IDataFlavorHandler)

Aggregations

IDataFlavorHandler (org.freeplane.features.clipboard.mindmapmode.MClipboardController.IDataFlavorHandler)2 Component (java.awt.Component)1 Transferable (java.awt.datatransfer.Transferable)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 ButtonGroup (javax.swing.ButtonGroup)1 JPanel (javax.swing.JPanel)1 JRadioButton (javax.swing.JRadioButton)1 NodeModel (org.freeplane.features.map.NodeModel)1