use of java.awt.datatransfer.Clipboard in project Terasology by MovingBlocks.
the class BehaviorEditorScreen method onCopyPressed.
private void onCopyPressed() {
Clipboard systemClipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
String data = behaviorEditor.save();
StringSelection contents = new StringSelection(data);
systemClipboard.setContents(contents, contents);
}
use of java.awt.datatransfer.Clipboard in project BoofCV by lessthanoptimal.
the class ApplicationLauncherApp method handleContextMenu.
/**
* Displays a context menu for a class leaf node
* Allows copying of the name and the path to the source
*/
private void handleContextMenu(JTree tree, int x, int y) {
TreePath path = tree.getPathForLocation(x, y);
tree.setSelectionPath(path);
DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
if (node == null)
return;
if (!node.isLeaf()) {
tree.setSelectionPath(null);
return;
}
final AppInfo info = (AppInfo) node.getUserObject();
JMenuItem copyname = new JMenuItem("Copy Name");
copyname.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(new StringSelection(info.app.getSimpleName()), null);
}
});
JMenuItem copypath = new JMenuItem("Copy Path");
copypath.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String path = UtilIO.getSourcePath(info.app.getPackage().getName(), info.app.getSimpleName());
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(new StringSelection(path), null);
}
});
JMenuItem github = new JMenuItem("Go to Github");
github.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
openInGitHub(info);
}
});
JPopupMenu submenu = new JPopupMenu();
submenu.add(copyname);
submenu.add(copypath);
submenu.add(github);
submenu.show(tree, x, y);
}
use of java.awt.datatransfer.Clipboard in project JWildfire by thargor6.
the class IFlamesController method baseFlameToClipboardButton_clicked.
public void baseFlameToClipboardButton_clicked() {
try {
String xml = getIFlamesFunc().getFlameParams(getCurrFlameIndex()).getFlameXML();
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
StringSelection data = new StringSelection(xml);
clipboard.setContents(data, data);
messageHelper.showStatusMessage(getFlame(), "flame saved to clipboard");
} catch (Throwable ex) {
errorHandler.handleError(ex);
}
}
use of java.awt.datatransfer.Clipboard in project JWildfire by thargor6.
the class IFlamesController method saveIFlameToClipboardButton_clicked.
public void saveIFlameToClipboardButton_clicked() {
try {
if (getFlame() != null) {
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
String xml = new FlameWriter().getFlameXML(getFlame());
StringSelection data = new StringSelection(xml);
clipboard.setContents(data, data);
messageHelper.showStatusMessage(getFlame(), "flame saved to clipboard");
}
} catch (Throwable ex) {
errorHandler.handleError(ex);
}
}
use of java.awt.datatransfer.Clipboard in project JWildfire by thargor6.
the class DancingFractalsController method loadFlameFromClipboardButton_clicked.
public void loadFlameFromClipboardButton_clicked() {
List<Flame> newFlames = null;
try {
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
Transferable clipData = clipboard.getContents(clipboard);
if (clipData != null) {
if (clipData.isDataFlavorSupported(DataFlavor.stringFlavor)) {
String xml = (String) (clipData.getTransferData(DataFlavor.stringFlavor));
newFlames = new FlameReader(prefs).readFlamesfromXML(xml);
}
}
if (newFlames == null || newFlames.size() < 1) {
throw new Exception("There is currently no valid flame in the clipboard");
} else {
for (Flame newFlame : newFlames) {
project.getFlames().add(validateDancingFlame(newFlame));
}
refreshProjectFlames();
enableControls();
}
} catch (Throwable ex) {
errorHandler.handleError(ex);
}
}
Aggregations