Java Code Examples for javafx.scene.input.ClipboardContent#putHtml()

The following examples show how to use javafx.scene.input.ClipboardContent#putHtml() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PasteboardImpl.java    From oim-fx with MIT License 5 votes vote down vote up
@Override
public void writeSelection(boolean canSmartCopyOrDelete, String text, String html) {
	ClipboardContent content = new ClipboardContent();
	content.putString(text);
	content.putHtml(html);
	clipboard.setContent(content);
}
 
Example 2
Source File: PasteboardImpl.java    From oim-fx with MIT License 5 votes vote down vote up
@Override
public void writeUrl(String url, String markup) {
	ClipboardContent content = new ClipboardContent();
	content.putString(url);
	content.putHtml(markup);
	content.putUrl(url);
	clipboard.setContent(content);
}
 
Example 3
Source File: ClickableBitcoinAddress.java    From green_android with GNU General Public License v3.0 5 votes vote down vote up
@FXML
protected void copyAddress(ActionEvent event) {
    // User clicked icon or menu item.
    Clipboard clipboard = Clipboard.getSystemClipboard();
    ClipboardContent content = new ClipboardContent();
    content.putString(addressStr.get());
    content.putHtml(String.format("<a href='%s'>%s</a>", uri(), addressStr.get()));
    clipboard.setContent(content);
}
 
Example 4
Source File: ClickableBitcoinAddress.java    From GreenBits with GNU General Public License v3.0 5 votes vote down vote up
@FXML
protected void copyAddress(ActionEvent event) {
    // User clicked icon or menu item.
    Clipboard clipboard = Clipboard.getSystemClipboard();
    ClipboardContent content = new ClipboardContent();
    content.putString(addressStr.get());
    content.putHtml(String.format("<a href='%s'>%s</a>", uri(), addressStr.get()));
    clipboard.setContent(content);
}
 
Example 5
Source File: ClickableBitcoinAddress.java    From devcoretalk with GNU General Public License v2.0 5 votes vote down vote up
@FXML
protected void copyAddress(ActionEvent event) {
    // User clicked icon or menu item.
    Clipboard clipboard = Clipboard.getSystemClipboard();
    ClipboardContent content = new ClipboardContent();
    content.putString(addressStr.get());
    content.putHtml(String.format("<a href='%s'>%s</a>", uri(), addressStr.get()));
    clipboard.setContent(content);
}
 
Example 6
Source File: CObjectArray.java    From Open-Lowcode with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * copy all fields to the clipboard to paste into a spreadsheet
 * 
 * @param showhiddenfields if true, shows the hidden fields, if false, only
 *                         shows the visible fields
 */
public void copyTableToClipboard(boolean showhiddenfields) {
	try {
		ObservableList<ObjectTableRow> tabledata = thistable.getItems();
		StringBuilder clipboardstring = new StringBuilder();
		clipboardstring.append("<table cellspacing=\"0\" >");
		clipboardstring.append("<tr>");
		boolean[] showcolumns = new boolean[payloadlist.size()];
		for (int j = 0; j < payloadlist.size(); j++) {
			CBusinessField<?> thiscolumnheader = payloadlist.get(j);
			boolean show = false;
			if (!thiscolumnheader.isShowinbottomnotes())
				show = true;
			if (thiscolumnheader.isShowinbottomnotes())
				if (showhiddenfields)
					show = true;
			showcolumns[j] = show;
			if (show) {
				String columntitle = thiscolumnheader.getLabel();
				clipboardstring.append("<th>");
				clipboardstring.append(columntitle);
				clipboardstring.append("</th>");
			}
		}
		clipboardstring.append("</tr>\n");
		int line = 0;
		for (int i = 0; i < tabledata.size(); i++) {
			line++;
			ObjectTableRow thisrow = tabledata.get(i);
			ObjectDataElt objectdataelt = thisrow.getObject();
			clipboardstring.append("<tr>");
			for (int j = 0; j < payloadlist.size(); j++) {
				CBusinessField<?> thiscolumn = payloadlist.get(j);
				if (showcolumns[j]) {
					clipboardstring.append("<td>");
					SimpleDataElt thiselement = objectdataelt.lookupEltByName(thiscolumn.getFieldname());
					clipboardstring.append(printBusinessFieldToClipboard(actionmanager, thiscolumn, thiselement));
					clipboardstring.append("</td>");
				}
			}
			clipboardstring.append("</tr>\n");
		}
		clipboardstring.append("</table>");
		final ClipboardContent content = new ClipboardContent();
		content.putHtml(clipboardstring.toString());

		Clipboard.getSystemClipboard().setContent(content);
		actionmanager.getClientSession().getActiveClientDisplay().updateStatusBar("Copied table with " + line
				+ " line(s) to clipboard. You may paste it in a spreadsheet or word processor");
	} catch (Exception e) {
		logger.warning("Exception while copying to clipboard " + e.getMessage());
		for (int i = 0; i < e.getStackTrace().length; i++)
			logger.warning("   " + e.getStackTrace()[i]);
		actionmanager.getClientSession().getActiveClientDisplay()
				.updateStatusBar("Error while copying data :  " + e.getMessage(), true);
	}
}
 
Example 7
Source File: CObjectTreeArray.java    From Open-Lowcode with Eclipse Public License 2.0 4 votes vote down vote up
public void copyTableToClipboard(boolean showhiddenfields) {
	try {
		TreeItem<ObjectDataElt> rootnode = thistreetable.getRoot();
		ArrayList<ObjectInStructure> treedata = new ArrayList<ObjectInStructure>();
		extractDataFromTree(treedata, rootnode, 1, "", 1);
		StringBuilder clipboardstring = new StringBuilder();
		clipboardstring.append("<table cellspacing=\"0\" >");
		clipboardstring.append("<tr>");
		boolean[] showcolumns = new boolean[payloadlist.size()];
		clipboardstring.append("<th>Level</th><th>Cascade</th>");
		for (int j = 0; j < payloadlist.size(); j++) {
			CBusinessField<?> thiscolumnheader = payloadlist.get(j);
			boolean show = false;
			if (!thiscolumnheader.isShowinbottomnotes())
				show = true;
			if (thiscolumnheader.isShowinbottomnotes())
				if (showhiddenfields)
					show = true;
			showcolumns[j] = show;
			if (show) {
				String columntitle = thiscolumnheader.getLabel();
				clipboardstring.append("<th>");
				clipboardstring.append(columntitle);
				clipboardstring.append("</th>");
			}
		}
		clipboardstring.append("</tr>\n");
		int line = 0;
		for (int i = 0; i < treedata.size(); i++) {
			line++;
			ObjectInStructure thisobject = treedata.get(i);
			ObjectDataElt thisrowdata = thisobject.payload;
			clipboardstring.append("<tr>");
			clipboardstring.append("<td>");
			clipboardstring.append(thisobject.level);
			clipboardstring.append("</td>");
			clipboardstring.append("<td>");
			clipboardstring.append(thisobject.cascade);
			clipboardstring.append("</td>");

			for (int j = 0; j < payloadlist.size(); j++) {
				CBusinessField<?> thiscolumn = payloadlist.get(j);
				if (showcolumns[j]) {
					clipboardstring.append("<td>");
					SimpleDataElt thiselement = thisrowdata.lookupEltByName(thiscolumn.getFieldname());
					clipboardstring.append(
							CObjectArray.printBusinessFieldToClipboard(actionmanager, thiscolumn, thiselement));
					clipboardstring.append("</td>");
				}
			}
			clipboardstring.append("</tr>\n");
		}
		clipboardstring.append("</table>");
		final ClipboardContent content = new ClipboardContent();
		content.putHtml(clipboardstring.toString());

		Clipboard.getSystemClipboard().setContent(content);
		actionmanager.getClientSession().getActiveClientDisplay().updateStatusBar("Copied table with " + line
				+ " line(s) to clipboard. You may paste it in a spreadsheet or word processor");
	} catch (Exception e) {
		logger.warning("Error while copying data to clipboard " + e.getMessage());
		for (int i = 0; i < e.getStackTrace().length; i++)
			logger.warning("   " + e.getStackTrace()[i]);
		actionmanager.getClientSession().getActiveClientDisplay()
				.updateStatusBar("Error while copying data to clipboard " + e.getMessage(), true);
	}
}