Class Graph2DClipboard
provides our
application with convenient clipboard support.
Namely, this means support for Cut, Copy, and Paste actions for graph elements.
The code in Example 1.1, “Setting up clipboard support” presents the general setup that we will need in an application to make use of the services of Graph2DClipboard. You can observe this code also in the Clipboard1 application.
Example 1.1. Setting up clipboard support
public Graph2DClipboard getClipboardSupport() {
if (clipboard == null) {
clipboard = new Graph2DClipboard(view);
}
return clipboard;
}
Example 1.2, “Adding clipboard actions to a tool bar” shows how we can add the default clipboard actions for Cut, Copy, and Paste provided by class Graph2DClipboard to the toolbar of an application.
Example 1.2. Adding clipboard actions to a tool bar
// Adding clipboard actions (Cut, Copy, Paste) to the tool bar. toolbar.add(getClipboardSupport().getCutAction()); toolbar.add(getClipboardSupport().getCopyAction()); toolbar.add(getClipboardSupport().getPasteAction());
Clipboard1 builds upon the AdditionalDataEditor application, which allows to associate additional data with the nodes of the graph. However, if we have entered a custom text for a node using the text field, copies of that node created via the clipboard actions show only null values for the additional data.
Read on to learn how we can fix this...
|
Copyright ©2008-2009, yWorks GmbH. All rights reserved. |