Révision 2071

tmp/org.txm.rcp/src/main/java/org/txm/rcp/handlers/scripts/ExecuteGroovyScript.java (revision 2071)
103 103
			result = f.getAbsolutePath();
104 104
		} else if (filenameParameter != null) {
105 105
			result = filenameParameter;
106
			File f = new File(filenameParameter);
107
			if (!f.exists()) { // file not found, try locating it in Groovy scripts
108
				f = new File(Toolbox.getTxmHomePath() + "/scripts/groovy/user", filenameParameter);
109
				if (f.exists()) { // found !
110
					result = f.getAbsolutePath();
111
				}
112
			}
106 113
		} else if (sel != null
107 114
				& sel instanceof IStructuredSelection) {
108 115
			File file = null;
tmp/org.txm.rcp/src/main/java/org/txm/rcp/handlers/scripts/ExecuteGroovyMacro.java (revision 2071)
80 80
			result = f.getAbsolutePath();
81 81
		} else if (filenameParameter != null) {
82 82
			result = filenameParameter;
83
			File f = new File(filenameParameter);
84
			if (!f.exists()) { // file not found, try locating it in Groovy scripts
85
				f = new File(Toolbox.getTxmHomePath() + "/scripts/groovy/user", filenameParameter);
86
				if (f.exists()) { // found !
87
					result = f.getAbsolutePath();
88
				}
89
			}
83 90
		} else if (selection != null
84 91
				& selection instanceof IStructuredSelection) {
85 92
			File file = null;
tmp/org.txm.analec.rcp/plugin.xml (revision 2071)
10 10
               label="%menu.label"
11 11
               mnemonic="%menu.mnemonic">
12 12
            <command
13
                  commandId="org.txm.annotation.urs.commands.LoadStructureFromGlozz"
13
                  commandId="org.txm.annotation.urs.commands.SaveCorpus"
14 14
                  style="push">
15 15
               <visibleWhen
16 16
                     checkEnabled="false">
......
19 19
                  </reference>
20 20
               </visibleWhen>
21 21
            </command>
22
            <menu
23
                  id="menu.urs.tools"
24
                  label="Tools">
25
               <visibleWhen
26
                     checkEnabled="false">
27
                  <reference
28
                        definitionId="OneCorpusSelected">
29
                  </reference>
30
               </visibleWhen>
31
               <menu
32
                     label="Annotation">
33
                  <command
34
                        commandId="org.txm.rcp.commands.ExecuteMacro"
35
                        label="Annotate concordance"
36
                        style="push">
37
                     <parameter
38
                           name="org.txm.rcp.command.parameter.file"
39
                           value="org/txm/macro/urs/edit/ConcordanceToUnitMacro.groovy">
40
                     </parameter>
41
                  </command>
42
                  <command
43
                        commandId="org.txm.rcp.commands.ExecuteMacro"
44
                        label="Reset annotation"
45
                        style="push">
46
                     <parameter
47
                           name="org.txm.rcp.command.parameter.file"
48
                           value="org/txm/macro/urs/edit/ResetAnnotationsMacro.groovy">
49
                     </parameter>
50
                  </command>
51
                  <command
52
                        commandId="org.txm.rcp.commands.ExecuteMacro"
53
                        label="SI to Singleton"
54
                        style="push">
55
                     <parameter
56
                           name="org.txm.rcp.command.parameter.file"
57
                           value="org/txm/macro/urs/edit/Si2SingletonMacro.groovy">
58
                     </parameter>
59
                  </command>
60
                  <command
61
                        commandId="org.txm.rcp.commands.ExecuteMacro"
62
                        label="Annotate selection of units"
63
                        style="push">
64
                     <parameter
65
                           name="org.txm.rcp.command.parameter.file"
66
                           value="org/txm/macro/urs/edit/UnitsAnnotateMacro.groovy">
67
                     </parameter>
68
                  </command>
69
               </menu>
70
               <menu
71
                     label="Verification">
72
                  <command
73
                        commandId="org.txm.rcp.commands.ExecuteMacro"
74
                        label="Check duplicated units in schema"
75
                        style="push">
76
                     <parameter
77
                           name="org.txm.rcp.command.parameter.file"
78
                           value="org/txm/macro/urs/edit/CheckDuplicatesInSchemasMacro.groovy">
79
                     </parameter>
80
                  </command>
81
                  <command
82
                        commandId="org.txm.rcp.commands.ExecuteMacro"
83
                        label="Check annotation structure values"
84
                        style="push">
85
                     <parameter
86
                           name="org.txm.rcp.command.parameter.file"
87
                           value="org/txm/macro/urs/edit/CheckAnnotationStructureValuesMacro.groovy">
88
                     </parameter>
89
                  </command>
90
               </menu>
91
               <menu
92
                     label="Exploitation">
93
                  <command
94
                        commandId="org.txm.rcp.commands.ExecuteMacro"
95
                        label="Units summary"
96
                        style="push">
97
                     <parameter
98
                           name="org.txm.rcp.command.parameter.file"
99
                           value="org/txm/macro/urs/exploit/UnitsSummaryMacro.groovy">
100
                     </parameter>
101
                  </command>
102
                  <command
103
                        commandId="org.txm.rcp.commands.ExecuteMacro"
104
                        label="Units list"
105
                        style="push">
106
                     <parameter
107
                           name="org.txm.rcp.command.parameter.file"
108
                           value="org/txm/macro/urs/exploit/UnitsListMacro.groovy">
109
                     </parameter>
110
                  </command>
111
                  <command
112
                        commandId="org.txm.rcp.commands.ExecuteMacro"
113
                        label="Units index"
114
                        style="push">
115
                     <parameter
116
                           name="org.txm.rcp.command.parameter.file"
117
                           value="org/txm/macro/urs/exploit/UnitsIndexMacro.groovy">
118
                     </parameter>
119
                  </command>
120
                  <command
121
                        commandId="org.txm.rcp.commands.ExecuteMacro"
122
                        label="Schemas progression"
123
                        style="push">
124
                     <parameter
125
                           name="org.txm.rcp.command.parameter.file"
126
                           value="org/txm/macro/urs/exploit/SchemasProgressionMacro.groovy">
127
                     </parameter>
128
                  </command>
129
                  <command
130
                        commandId="org.txm.rcp.commands.ExecuteMacro"
131
                        label="Schemas summary"
132
                        style="push">
133
                     <parameter
134
                           name="org.txm.rcp.command.parameter.file"
135
                           value="org/txm/macro/urs/exploit/SchemasSummaryMacro.groovy">
136
                     </parameter>
137
                  </command>
138
               </menu>
139
               <menu
140
                     label="Export">
141
                  <command
142
                        commandId="org.txm.rcp.commands.ExecuteMacro"
143
                        label="Export to Glozz"
144
                        style="push">
145
                     <parameter
146
                           name="org.txm.rcp.command.parameter.file"
147
                           value="org/txm/macro/urs/export/ExportToGlozzMacro.groovy">
148
                     </parameter>
149
                  </command>
150
                  <command
151
                        commandId="org.txm.rcp.commands.ExecuteMacro"
152
                        label="Export as..."
153
                        style="push">
154
                     <parameter
155
                           name="org.txm.rcp.command.parameter.file"
156
                           value="org/txm/macro/urs/export/ExportAsMacro.groovy">
157
                     </parameter>
158
                  </command>
159
               </menu>
160
               <menu
161
                     label="Exploitation2">
162
                  <dynamic
163
                        class="org.txm.annotation.urs.commands.URSToolsMenuContribution"
164
                        id="exploit">
165
                  </dynamic>
166
               </menu>
167
               <menu
168
                     label="Annotation2">
169
                  <dynamic
170
                        class="org.txm.annotation.urs.commands.URSToolsMenuContribution"
171
                        id="edit">
172
                  </dynamic>
173
               </menu>
174
            </menu>
22 175
            <command
23 176
                  commandId="org.txm.annotation.urs.commands.EditAnnotationStructure"
24 177
                  style="push">
......
39 192
                  </reference>
40 193
               </visibleWhen>
41 194
            </command>
195
            <separator
196
                  name="URSRCP.separator1"
197
                  visible="true">
198
            </separator>
42 199
            <command
43
                  commandId="org.txm.annotation.urs.commands.SaveCorpus"
200
                  commandId="org.txm.annotation.urs.commands.LoadStructureFromGlozz"
44 201
                  style="push">
45 202
               <visibleWhen
46 203
                     checkEnabled="false">
......
49 206
                  </reference>
50 207
               </visibleWhen>
51 208
            </command>
52
            <separator
53
                  name="URSRCP.separator1"
54
                  visible="true">
55
            </separator>
56 209
            <command
57 210
                  commandId="org.txm.annotation.urs.commands.ImportTEIAnnotations"
58 211
                  style="push">
tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/commands/URSToolsMenuContribution.java (revision 2071)
1
package org.txm.annotation.urs.commands;
2

  
3
import java.io.File;
4
import java.util.Arrays;
5
import java.util.Comparator;
6

  
7
import org.eclipse.jface.action.ContributionItem;
8
import org.eclipse.osgi.util.NLS;
9
import org.eclipse.swt.SWT;
10
import org.eclipse.swt.events.MenuEvent;
11
import org.eclipse.swt.events.MenuListener;
12
import org.eclipse.swt.events.SelectionAdapter;
13
import org.eclipse.swt.events.SelectionEvent;
14
import org.eclipse.swt.widgets.Menu;
15
import org.eclipse.swt.widgets.MenuItem;
16
import org.eclipse.ui.IWorkbenchPart;
17
import org.eclipse.ui.IWorkbenchWindow;
18
import org.txm.Toolbox;
19
import org.txm.rcp.TXMWindows;
20
import org.txm.rcp.handlers.scripts.ExecuteGroovyMacro;
21
import org.txm.rcp.views.corpora.CorporaView;
22
import org.txm.utils.logger.Log;
23

  
24
public class URSToolsMenuContribution extends ContributionItem {
25

  
26
	Menu menu;
27
	int index;
28
	public URSToolsMenuContribution() {
29
		super();
30
	}
31
	public URSToolsMenuContribution(String id) {
32
		super(id);
33
	}
34

  
35
	@Override
36
	public void fill(Menu menu, int index) {
37
		this.menu = menu;
38
		this.index = index;
39

  
40

  
41
		menu.addMenuListener(new MenuListener() {
42

  
43
			@Override
44
			public void menuShown(MenuEvent e) {
45
				onOpen(URSToolsMenuContribution.this.menu, URSToolsMenuContribution.this.index);
46
			}
47

  
48
			@Override
49
			public void menuHidden(MenuEvent e) { }
50
		});
51
	}
52

  
53
	public File getMacroDirectory() {
54
		//create the menu item
55
		String w = Toolbox.getTxmHomePath();
56
		if (w == null || w.length() == 0) return null;
57

  
58
		return new File(w, "scripts/groovy/user/org/txm/macro/urs");
59
	}
60

  
61
	public void onOpen(Menu menu, int index) {
62

  
63
		File macroDirectory = getMacroDirectory();
64
		if (macroDirectory == null) return;
65

  
66
		File subDirectory = new File(macroDirectory, this.getId());
67
		
68
		File[] files = subDirectory.listFiles();
69
		if (files == null || files.length == 0) {
70

  
71
			MenuItem[] menuItems = menu.getItems();
72
			for (int i = 0; i < menuItems.length; i++) {
73
				menuItems[i].dispose();
74
			}
75

  
76
//			MenuItem menuItem = new MenuItem(menu, SWT.CHECK, index);
77
//			menuItem.setText("<no macro>");
78
//			menuItem.addSelectionListener(new SelectionAdapter() {
79
//				public void widgetSelected(SelectionEvent e) {
80
//					Log.info("To populate this menu, you must create macros in the 'ui/menu/main' macro directory.");
81
//				}
82
//			});
83
			return;
84
		}
85

  
86
		populate(menu, subDirectory, index);
87
	}
88

  
89
	public static void populate(Menu menu, File directory, int index) {
90

  
91
		// First empty
92
		MenuItem[] menuItems = menu.getItems();
93
		for (int i = 0; i < menuItems.length; i++) {
94
			menuItems[i].dispose();
95
		}
96

  
97
		// Find files
98
		File[] files = directory.listFiles();
99

  
100
		// first are directories
101
		Arrays.sort(files, new Comparator<File>() {
102
			@Override
103
			public int compare(File arg0, File arg1) {
104
				if (arg0.isDirectory()) {
105
					if (arg1.isDirectory()) {
106
						return arg0.getName().compareTo(arg1.getName());
107
					} else {
108
						return -1;
109
					}
110
				} else if (arg1.isFile()) {
111
					return arg0.getName().compareTo(arg1.getName());
112
				} else {
113
					return 1;
114
				}
115
			}
116

  
117
		});
118
		for (File f : files) {
119
			if (f.getName().endsWith("Macro.groovy")) {
120
				MenuItem menuItem = new MenuItem(menu, SWT.PUSH);
121
				menuItem.setText(f.getName().substring(0, f.getName().length()-12).replaceAll("([A-Z])[^A-Z]", " $1"));
122
				menuItem.addSelectionListener(new MacroSelectionAdapter(f));
123
			} else if (f.isDirectory()) {
124
				MenuItem subMenuItem = new MenuItem(menu, SWT.CASCADE);
125
				subMenuItem.setText(f.getName());
126
				Menu submenu = new Menu(menu);
127
				subMenuItem.setMenu(submenu);
128
				populate(submenu, f, 0);
129
			}
130
		}
131
	}
132

  
133
	public static class MacroSelectionAdapter extends SelectionAdapter {
134
		File macro;
135
		public MacroSelectionAdapter(File macro) {
136
			this.macro = macro;
137
		}
138

  
139
		public void widgetSelected(SelectionEvent e) {
140
			IWorkbenchWindow acWindow = TXMWindows.getActiveWindow();
141
			IWorkbenchPart page = acWindow.getActivePage().getActivePart();
142
			ExecuteGroovyMacro.execute(macro.getAbsolutePath(), page, CorporaView.getInstance().getTreeViewer().getSelection(), "");
143
		}
144
	}
145

  
146
	public static class MacroDirectoryMenu extends Menu {
147

  
148
		File directory;
149
		int index;
150

  
151
		public MacroDirectoryMenu(Menu parentMenu, File dir, int i) {
152
			super(parentMenu);
153
			this.directory = dir;
154
			this.index = i;
155
			this.addMenuListener(new MenuListener() {
156

  
157
				@Override
158
				public void menuShown(MenuEvent e) {
159
					populate(MacroDirectoryMenu.this, directory, index);
160
				}
161

  
162
				@Override
163
				public void menuHidden(MenuEvent e) { }
164
			});
165
		}
166
	}
167
}
0 168

  
tmp/org.txm.setups/shared/mac/Applications/TXM.app/Contents/MacOS/TXM (revision 2071)
7 7
VERSION=0.8.0
8 8
exec 3>$HOME/TXMPostInstallOutputLogs.txt
9 9
exec 4>$HOME/TXMPostInstallErrorLogs.txt
10
(
10

  
11 11
echo "$HOME is '$HOME'"
12 12

  
13 13
if [ ! -d "$HOME" ]; then
......
28 28
	echo "TXM: Impossible to access '$DIR' directory. Aborting$LOGFILESMSG"
29 29
	exit 1
30 30
fi
31

  
31
(
32 32
echo "DOTTXMHOME='$DOTTXMHOME'"
33 33
if [ ! -d "$DOTTXMHOME" ]; then
34 34
	mkdir "$DOTTXMHOME"
......
152 152
echo "TXM: Running TXM for Mac OS X $OSVERSION with the JAR launcher..."
153 153
) 1>&3 2>&4
154 154

  
155
echo "Starting TXM with --launcher.ini '$DOTTXMHOME/TXM.ini' -configuration '$DOTTXMHOME/configuration' -user '$DOTTXMHOME/user' -install '/Applications/TXM-TXMVERSION.app/Contents/TXM'" 
155 156
/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"

Formats disponibles : Unified diff