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;
}
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);
}
Aggregations