Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Pontesegger2014-11-25 14:25:16 +0000
committerChristian Pontesegger2014-11-25 14:25:16 +0000
commite9c589aa9d0c50bdbe611888b2d13dbdf02265ba (patch)
tree17b2117e8f54af0c338ceb74431f95e3b34eafc0
parentb038bfb3618e74ede7a6e3be32251e813409cb92 (diff)
downloadorg.eclipse.ease.scripts-e9c589aa9d0c50bdbe611888b2d13dbdf02265ba.tar.gz
org.eclipse.ease.scripts-e9c589aa9d0c50bdbe611888b2d13dbdf02265ba.tar.xz
org.eclipse.ease.scripts-e9c589aa9d0c50bdbe611888b2d13dbdf02265ba.zip
script to add folders to monitored script locations
hooks into context menu of IContainer objects to register them for script files. Change-Id: I24b55e9912d25729b54da3bb09a76089391c65b5
-rw-r--r--JavaScript Snippets/Script helpers/Add to script locations.js38
1 files changed, 38 insertions, 0 deletions
diff --git a/JavaScript Snippets/Script helpers/Add to script locations.js b/JavaScript Snippets/Script helpers/Add to script locations.js
new file mode 100644
index 0000000..4f7224e
--- /dev/null
+++ b/JavaScript Snippets/Script helpers/Add to script locations.js
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Christian Pontesegger and others. 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
+ *
+ * Contributors: Christian Pontesegger - initial API and implementation
+ *
+ * name : Add script location
+ * popup : enableFor(org.eclipse.core.resources.IContainer)
+ * description : Adds the selected folder to monitored script locations
+ ******************************************************************************/
+
+loadModule('/System/UI');
+var selection = getSelection();
+if (selection instanceof org.eclipse.jface.viewers.IStructuredSelection) {
+ // get location, due to context menu binding we know this is an IContainer
+ var container = selection.getFirstElement();
+ var location = "workspace:/" + container.getFullPath();
+ var node = location.replace(/\//g, "|");
+
+ loadModule('/System/Platform');
+ // verify that location is not already registered
+ var storedLocation = readPreferences("org.eclipse.ease.ui/" + node, "location");
+ if (storedLocation == "") {
+ // add location preferences
+ writePreferences("org.eclipse.ease.ui/" + node, "location", location);
+ writePreferences("org.eclipse.ease.ui/" + node, "default", false);
+ writePreferences("org.eclipse.ease.ui/" + node, "recursive", true);
+
+ // trigger update
+ var repositoryService = getService(org.eclipse.ease.ui.scripts.repository.IRepositoryService);
+ repositoryService.updateLocations();
+
+ } else
+ // location already registered
+ showInfoDialog("Location is already registered");
+} \ No newline at end of file

Back to the top