Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul D. Fernhout2014-11-25 17:22:13 +0000
committerPaul D. Fernhout2014-11-25 17:22:13 +0000
commit77cb989debe9a8970ab751a008cf8f30206e5b41 (patch)
tree90849dbc23eafad524636c8b7f3f276a752064b6
parent1b9ac0e7cd055bbe1eb7dee9f543548b375dfe21 (diff)
downloadorg.eclipse.ease.scripts-77cb989debe9a8970ab751a008cf8f30206e5b41.tar.gz
org.eclipse.ease.scripts-77cb989debe9a8970ab751a008cf8f30206e5b41.tar.xz
org.eclipse.ease.scripts-77cb989debe9a8970ab751a008cf8f30206e5b41.zip
add_console_log_statement_for_selection_into_clipboard.js and
put_hello_world_into_clipboard.js using new UI.setClipboard API call Change-Id: Ia791ab9672126a0f09096b933c0a01b4bd734fd3 Signed-off-by: Paul D. Fernhout <pdfernhout@kurtz-fernhout.com>
-rw-r--r--JavaScript Snippets/add_console_log_statement_for_selection_into_clipboard.js32
-rw-r--r--JavaScript Snippets/put_hello_world_into_clipboard.js19
2 files changed, 51 insertions, 0 deletions
diff --git a/JavaScript Snippets/add_console_log_statement_for_selection_into_clipboard.js b/JavaScript Snippets/add_console_log_statement_for_selection_into_clipboard.js
new file mode 100644
index 0000000..86a4bcc
--- /dev/null
+++ b/JavaScript Snippets/add_console_log_statement_for_selection_into_clipboard.js
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * name : Add console.log Statement For Selection Into Clipboard with EASE
+ * popup : enableFor(java.lang.Object)
+ *
+ * Copyright (c) 2014 Paul D. Fernhout
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributed by: Paul D. Fernhout
+ * Purpose: Puts a console.log statement into the clipboard derived from the currently selected text
+ * Installation: Put this script to a monitored location (see Preferences/Scripting/Script Location) and it will be available in any context menu.
+ * Usage: Select a variable you would like to log in your JavaScript code and then
+ * pick "Add console.log Statement For Selection Into Clipboard with EASE" from the context menu.
+ *******************************************************************************/
+
+// This defines getSelection and setClipboard
+loadModule('/System/UI');
+
+var selection = getSelection();
+// TODO: This next line is false for some reason with either TextSelection or ITextSelection, so using kludge as temporary work around
+// var isTextSelection = (selection instanceof org.eclipse.jface.text.TextSelection);
+var isTextSelection = "" + selection.getClass() === "class org.eclipse.jface.text.TextSelection";
+if (isTextSelection) {
+ selectedText = selection.getText();
+ var consoleLogStatement = 'console.log("' + selectedText + '", ' + selectedText + ');\n';
+ setClipboard(consoleLogStatement);
+ print("Set clipboard with: " + consoleLogStatement);
+} else {
+ print("Clipboard selection class was not of expected type; was: '" + selection.getClass() + "'");
+} \ No newline at end of file
diff --git a/JavaScript Snippets/put_hello_world_into_clipboard.js b/JavaScript Snippets/put_hello_world_into_clipboard.js
new file mode 100644
index 0000000..d38b214
--- /dev/null
+++ b/JavaScript Snippets/put_hello_world_into_clipboard.js
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * name : Put "Hello, world!" into Clipboard with EASE
+ * popup : enableFor(java.lang.Object)
+ *
+ * Copyright (c) 2014 Paul D. Fernhout
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributed by: Paul D. Fernhout
+ * Purpose: Puts "Hello, World!" into the clipboard
+ * Installation: Put this script to a monitored location (see Preferences/Scripting/Script Location) and it will be available in any context menu.
+ * Usage: Pick "Put "Hello, world!" into Clipboard with EASE" from the context menu and then paste the result somewhere in your document.
+ *******************************************************************************/
+
+loadModule('/System/UI');
+
+setClipboard("Hello, world!");

Back to the top