Index: tmp/org.txm.rcp/src/main/java/org/txm/rcp/handlers/scripts/ExecuteGroovyMacro.java
===================================================================
--- tmp/org.txm.rcp/src/main/java/org/txm/rcp/handlers/scripts/ExecuteGroovyMacro.java	(revision 2070)
+++ tmp/org.txm.rcp/src/main/java/org/txm/rcp/handlers/scripts/ExecuteGroovyMacro.java	(revision 2071)
@@ -80,6 +80,13 @@
 			result = f.getAbsolutePath();
 		} else if (filenameParameter != null) {
 			result = filenameParameter;
+			File f = new File(filenameParameter);
+			if (!f.exists()) { // file not found, try locating it in Groovy scripts
+				f = new File(Toolbox.getTxmHomePath() + "/scripts/groovy/user", filenameParameter);
+				if (f.exists()) { // found !
+					result = f.getAbsolutePath();
+				}
+			}
 		} else if (selection != null
 				& selection instanceof IStructuredSelection) {
 			File file = null;
Index: tmp/org.txm.rcp/src/main/java/org/txm/rcp/handlers/scripts/ExecuteGroovyScript.java
===================================================================
--- tmp/org.txm.rcp/src/main/java/org/txm/rcp/handlers/scripts/ExecuteGroovyScript.java	(revision 2070)
+++ tmp/org.txm.rcp/src/main/java/org/txm/rcp/handlers/scripts/ExecuteGroovyScript.java	(revision 2071)
@@ -103,6 +103,13 @@
 			result = f.getAbsolutePath();
 		} else if (filenameParameter != null) {
 			result = filenameParameter;
+			File f = new File(filenameParameter);
+			if (!f.exists()) { // file not found, try locating it in Groovy scripts
+				f = new File(Toolbox.getTxmHomePath() + "/scripts/groovy/user", filenameParameter);
+				if (f.exists()) { // found !
+					result = f.getAbsolutePath();
+				}
+			}
 		} else if (sel != null
 				& sel instanceof IStructuredSelection) {
 			File file = null;
Index: tmp/org.txm.setups/shared/mac/Applications/TXM.app/Contents/MacOS/TXM
===================================================================
--- tmp/org.txm.setups/shared/mac/Applications/TXM.app/Contents/MacOS/TXM	(revision 2070)
+++ tmp/org.txm.setups/shared/mac/Applications/TXM.app/Contents/MacOS/TXM	(revision 2071)
@@ -7,7 +7,7 @@
 VERSION=0.8.0
 exec 3>$HOME/TXMPostInstallOutputLogs.txt
 exec 4>$HOME/TXMPostInstallErrorLogs.txt
-(
+
 echo "$HOME is '$HOME'"
 
 if [ ! -d "$HOME" ]; then
@@ -28,7 +28,7 @@
 	echo "TXM: Impossible to access '$DIR' directory. Aborting$LOGFILESMSG"
 	exit 1
 fi
-
+(
 echo "DOTTXMHOME='$DOTTXMHOME'"
 if [ ! -d "$DOTTXMHOME" ]; then
 	mkdir "$DOTTXMHOME"
@@ -152,4 +152,5 @@
 echo "TXM: Running TXM for Mac OS X $OSVERSION with the JAR launcher..."
 ) 1>&3 2>&4
 
+echo "Starting TXM with --launcher.ini '$DOTTXMHOME/TXM.ini' -configuration '$DOTTXMHOME/configuration' -user '$DOTTXMHOME/user' -install '/Applications/TXM-TXMVERSION.app/Contents/TXM'" 
 /Applications/TXM-TXMVERSION.app/Contents/TXM/jre/Contents/Home/bin/java -Djava.library.path="$(echo  /Applications/TXM-TXMVERSION.app/Contents/TXM/plugins/org.eclipse.equinox.launcher.cocoa.macosx.x86_64_*/eclipse_*.so)" -XX:MaxPermSize=256m -XstartOnFirstThread $TXMINIARGSVM -jar "$(echo /Applications/TXM-TXMVERSION.app/Contents/TXM/plugins/org.eclipse.equinox.launcher_*.jar)" -os macosx -ws cocoa -arch x86_64 -showsplash -run --launcher.ini "$DOTTXMHOME/TXM.ini" -configuration "$DOTTXMHOME/configuration" -user "$DOTTXMHOME/user" -install "/Applications/TXM-TXMVERSION.app/Contents/TXM"
Index: tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/commands/URSToolsMenuContribution.java
===================================================================
--- tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/commands/URSToolsMenuContribution.java	(revision 0)
+++ tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/commands/URSToolsMenuContribution.java	(revision 2071)
@@ -0,0 +1,167 @@
+package org.txm.annotation.urs.commands;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.Comparator;
+
+import org.eclipse.jface.action.ContributionItem;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.MenuEvent;
+import org.eclipse.swt.events.MenuListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.txm.Toolbox;
+import org.txm.rcp.TXMWindows;
+import org.txm.rcp.handlers.scripts.ExecuteGroovyMacro;
+import org.txm.rcp.views.corpora.CorporaView;
+import org.txm.utils.logger.Log;
+
+public class URSToolsMenuContribution extends ContributionItem {
+
+	Menu menu;
+	int index;
+	public URSToolsMenuContribution() {
+		super();
+	}
+	public URSToolsMenuContribution(String id) {
+		super(id);
+	}
+
+	@Override
+	public void fill(Menu menu, int index) {
+		this.menu = menu;
+		this.index = index;
+
+
+		menu.addMenuListener(new MenuListener() {
+
+			@Override
+			public void menuShown(MenuEvent e) {
+				onOpen(URSToolsMenuContribution.this.menu, URSToolsMenuContribution.this.index);
+			}
+
+			@Override
+			public void menuHidden(MenuEvent e) { }
+		});
+	}
+
+	public File getMacroDirectory() {
+		//create the menu item
+		String w = Toolbox.getTxmHomePath();
+		if (w == null || w.length() == 0) return null;
+
+		return new File(w, "scripts/groovy/user/org/txm/macro/urs");
+	}
+
+	public void onOpen(Menu menu, int index) {
+
+		File macroDirectory = getMacroDirectory();
+		if (macroDirectory == null) return;
+
+		File subDirectory = new File(macroDirectory, this.getId());
+		
+		File[] files = subDirectory.listFiles();
+		if (files == null || files.length == 0) {
+
+			MenuItem[] menuItems = menu.getItems();
+			for (int i = 0; i < menuItems.length; i++) {
+				menuItems[i].dispose();
+			}
+
+//			MenuItem menuItem = new MenuItem(menu, SWT.CHECK, index);
+//			menuItem.setText("<no macro>");
+//			menuItem.addSelectionListener(new SelectionAdapter() {
+//				public void widgetSelected(SelectionEvent e) {
+//					Log.info("To populate this menu, you must create macros in the 'ui/menu/main' macro directory.");
+//				}
+//			});
+			return;
+		}
+
+		populate(menu, subDirectory, index);
+	}
+
+	public static void populate(Menu menu, File directory, int index) {
+
+		// First empty
+		MenuItem[] menuItems = menu.getItems();
+		for (int i = 0; i < menuItems.length; i++) {
+			menuItems[i].dispose();
+		}
+
+		// Find files
+		File[] files = directory.listFiles();
+
+		// first are directories
+		Arrays.sort(files, new Comparator<File>() {
+			@Override
+			public int compare(File arg0, File arg1) {
+				if (arg0.isDirectory()) {
+					if (arg1.isDirectory()) {
+						return arg0.getName().compareTo(arg1.getName());
+					} else {
+						return -1;
+					}
+				} else if (arg1.isFile()) {
+					return arg0.getName().compareTo(arg1.getName());
+				} else {
+					return 1;
+				}
+			}
+
+		});
+		for (File f : files) {
+			if (f.getName().endsWith("Macro.groovy")) {
+				MenuItem menuItem = new MenuItem(menu, SWT.PUSH);
+				menuItem.setText(f.getName().substring(0, f.getName().length()-12).replaceAll("([A-Z])[^A-Z]", " $1"));
+				menuItem.addSelectionListener(new MacroSelectionAdapter(f));
+			} else if (f.isDirectory()) {
+				MenuItem subMenuItem = new MenuItem(menu, SWT.CASCADE);
+				subMenuItem.setText(f.getName());
+				Menu submenu = new Menu(menu);
+				subMenuItem.setMenu(submenu);
+				populate(submenu, f, 0);
+			}
+		}
+	}
+
+	public static class MacroSelectionAdapter extends SelectionAdapter {
+		File macro;
+		public MacroSelectionAdapter(File macro) {
+			this.macro = macro;
+		}
+
+		public void widgetSelected(SelectionEvent e) {
+			IWorkbenchWindow acWindow = TXMWindows.getActiveWindow();
+			IWorkbenchPart page = acWindow.getActivePage().getActivePart();
+			ExecuteGroovyMacro.execute(macro.getAbsolutePath(), page, CorporaView.getInstance().getTreeViewer().getSelection(), "");
+		}
+	}
+
+	public static class MacroDirectoryMenu extends Menu {
+
+		File directory;
+		int index;
+
+		public MacroDirectoryMenu(Menu parentMenu, File dir, int i) {
+			super(parentMenu);
+			this.directory = dir;
+			this.index = i;
+			this.addMenuListener(new MenuListener() {
+
+				@Override
+				public void menuShown(MenuEvent e) {
+					populate(MacroDirectoryMenu.this, directory, index);
+				}
+
+				@Override
+				public void menuHidden(MenuEvent e) { }
+			});
+		}
+	}
+}

Property changes on: tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/commands/URSToolsMenuContribution.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.analec.rcp/plugin.xml
===================================================================
--- tmp/org.txm.analec.rcp/plugin.xml	(revision 2070)
+++ tmp/org.txm.analec.rcp/plugin.xml	(revision 2071)
@@ -10,7 +10,7 @@
                label="%menu.label"
                mnemonic="%menu.mnemonic">
             <command
-                  commandId="org.txm.annotation.urs.commands.LoadStructureFromGlozz"
+                  commandId="org.txm.annotation.urs.commands.SaveCorpus"
                   style="push">
                <visibleWhen
                      checkEnabled="false">
@@ -19,6 +19,159 @@
                   </reference>
                </visibleWhen>
             </command>
+            <menu
+                  id="menu.urs.tools"
+                  label="Tools">
+               <visibleWhen
+                     checkEnabled="false">
+                  <reference
+                        definitionId="OneCorpusSelected">
+                  </reference>
+               </visibleWhen>
+               <menu
+                     label="Annotation">
+                  <command
+                        commandId="org.txm.rcp.commands.ExecuteMacro"
+                        label="Annotate concordance"
+                        style="push">
+                     <parameter
+                           name="org.txm.rcp.command.parameter.file"
+                           value="org/txm/macro/urs/edit/ConcordanceToUnitMacro.groovy">
+                     </parameter>
+                  </command>
+                  <command
+                        commandId="org.txm.rcp.commands.ExecuteMacro"
+                        label="Reset annotation"
+                        style="push">
+                     <parameter
+                           name="org.txm.rcp.command.parameter.file"
+                           value="org/txm/macro/urs/edit/ResetAnnotationsMacro.groovy">
+                     </parameter>
+                  </command>
+                  <command
+                        commandId="org.txm.rcp.commands.ExecuteMacro"
+                        label="SI to Singleton"
+                        style="push">
+                     <parameter
+                           name="org.txm.rcp.command.parameter.file"
+                           value="org/txm/macro/urs/edit/Si2SingletonMacro.groovy">
+                     </parameter>
+                  </command>
+                  <command
+                        commandId="org.txm.rcp.commands.ExecuteMacro"
+                        label="Annotate selection of units"
+                        style="push">
+                     <parameter
+                           name="org.txm.rcp.command.parameter.file"
+                           value="org/txm/macro/urs/edit/UnitsAnnotateMacro.groovy">
+                     </parameter>
+                  </command>
+               </menu>
+               <menu
+                     label="Verification">
+                  <command
+                        commandId="org.txm.rcp.commands.ExecuteMacro"
+                        label="Check duplicated units in schema"
+                        style="push">
+                     <parameter
+                           name="org.txm.rcp.command.parameter.file"
+                           value="org/txm/macro/urs/edit/CheckDuplicatesInSchemasMacro.groovy">
+                     </parameter>
+                  </command>
+                  <command
+                        commandId="org.txm.rcp.commands.ExecuteMacro"
+                        label="Check annotation structure values"
+                        style="push">
+                     <parameter
+                           name="org.txm.rcp.command.parameter.file"
+                           value="org/txm/macro/urs/edit/CheckAnnotationStructureValuesMacro.groovy">
+                     </parameter>
+                  </command>
+               </menu>
+               <menu
+                     label="Exploitation">
+                  <command
+                        commandId="org.txm.rcp.commands.ExecuteMacro"
+                        label="Units summary"
+                        style="push">
+                     <parameter
+                           name="org.txm.rcp.command.parameter.file"
+                           value="org/txm/macro/urs/exploit/UnitsSummaryMacro.groovy">
+                     </parameter>
+                  </command>
+                  <command
+                        commandId="org.txm.rcp.commands.ExecuteMacro"
+                        label="Units list"
+                        style="push">
+                     <parameter
+                           name="org.txm.rcp.command.parameter.file"
+                           value="org/txm/macro/urs/exploit/UnitsListMacro.groovy">
+                     </parameter>
+                  </command>
+                  <command
+                        commandId="org.txm.rcp.commands.ExecuteMacro"
+                        label="Units index"
+                        style="push">
+                     <parameter
+                           name="org.txm.rcp.command.parameter.file"
+                           value="org/txm/macro/urs/exploit/UnitsIndexMacro.groovy">
+                     </parameter>
+                  </command>
+                  <command
+                        commandId="org.txm.rcp.commands.ExecuteMacro"
+                        label="Schemas progression"
+                        style="push">
+                     <parameter
+                           name="org.txm.rcp.command.parameter.file"
+                           value="org/txm/macro/urs/exploit/SchemasProgressionMacro.groovy">
+                     </parameter>
+                  </command>
+                  <command
+                        commandId="org.txm.rcp.commands.ExecuteMacro"
+                        label="Schemas summary"
+                        style="push">
+                     <parameter
+                           name="org.txm.rcp.command.parameter.file"
+                           value="org/txm/macro/urs/exploit/SchemasSummaryMacro.groovy">
+                     </parameter>
+                  </command>
+               </menu>
+               <menu
+                     label="Export">
+                  <command
+                        commandId="org.txm.rcp.commands.ExecuteMacro"
+                        label="Export to Glozz"
+                        style="push">
+                     <parameter
+                           name="org.txm.rcp.command.parameter.file"
+                           value="org/txm/macro/urs/export/ExportToGlozzMacro.groovy">
+                     </parameter>
+                  </command>
+                  <command
+                        commandId="org.txm.rcp.commands.ExecuteMacro"
+                        label="Export as..."
+                        style="push">
+                     <parameter
+                           name="org.txm.rcp.command.parameter.file"
+                           value="org/txm/macro/urs/export/ExportAsMacro.groovy">
+                     </parameter>
+                  </command>
+               </menu>
+               <menu
+                     label="Exploitation2">
+                  <dynamic
+                        class="org.txm.annotation.urs.commands.URSToolsMenuContribution"
+                        id="exploit">
+                  </dynamic>
+               </menu>
+               <menu
+                     label="Annotation2">
+                  <dynamic
+                        class="org.txm.annotation.urs.commands.URSToolsMenuContribution"
+                        id="edit">
+                  </dynamic>
+               </menu>
+            </menu>
             <command
                   commandId="org.txm.annotation.urs.commands.EditAnnotationStructure"
                   style="push">
@@ -39,8 +192,12 @@
                   </reference>
                </visibleWhen>
             </command>
+            <separator
+                  name="URSRCP.separator1"
+                  visible="true">
+            </separator>
             <command
-                  commandId="org.txm.annotation.urs.commands.SaveCorpus"
+                  commandId="org.txm.annotation.urs.commands.LoadStructureFromGlozz"
                   style="push">
                <visibleWhen
                      checkEnabled="false">
@@ -49,10 +206,6 @@
                   </reference>
                </visibleWhen>
             </command>
-            <separator
-                  name="URSRCP.separator1"
-                  visible="true">
-            </separator>
             <command
                   commandId="org.txm.annotation.urs.commands.ImportTEIAnnotations"
                   style="push">
