use of org.apache.cayenne.modeler.undo.PasteCompoundUndoableEdit in project cayenne by apache.
the class PasteAction method performAction.
/**
* Performs pasting items from the system buffer
*/
@Override
public void performAction(ActionEvent e) {
try {
Object content = Toolkit.getDefaultToolkit().getSystemClipboard().getData(CayenneTransferable.CAYENNE_FLAVOR);
Object currentObject = getProjectController().getCurrentObject();
if (content != null && currentObject != null) {
DataChannelDescriptor domain = (DataChannelDescriptor) getProjectController().getProject().getRootNode();
DataMap map = getProjectController().getCurrentDataMap();
UndoableEdit undoableEdit;
if (content instanceof List) {
undoableEdit = new PasteCompoundUndoableEdit();
for (Object o : (List) content) {
paste(currentObject, o);
undoableEdit.addEdit(new PasteUndoableEdit(domain, map, currentObject, o));
}
} else {
paste(currentObject, content);
undoableEdit = new PasteUndoableEdit(domain, map, currentObject, content);
}
application.getUndoManager().addEdit(undoableEdit);
}
} catch (UnsupportedFlavorException ufe) {
// do nothing
} catch (Exception ex) {
ErrorDebugDialog.guiException(ex);
}
}
Aggregations