Revision 736

tmp/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/preferences/RPreferences.java (revision 736)
101 101
		String saved = TXMPreferences.getString(RPreferences.VERSION, RPreferences.PREFERENCES_NODE);
102 102
		Version currentVersion = BundleUtils.getBundleVersion(RFRAGMENT); // the RFRAGMENT plugin contains the right version
103 103
		
104
		if (saved != null && saved.length() > 0) {
105
			Version savedVersion = new Version(saved);
106
			if (currentVersion.compareTo(savedVersion) <= 0) {
107
				Log.info("No post-installation of R plugin to do");
108
				return; // nothing to do
109
			}
110
		}
111
		Log.info("Updating R preferences for R plugin version="+currentVersion);
112
		
104
		//ensure plugin binary files rights are ok
113 105
		String os = "";
114 106
		String ext = "";
115 107
		String osname = System.getProperty("os.name").toLowerCase(); //$NON-NLS-1$
......
133 125
		File OSDir = new File(rpluginDir, os);
134 126
		File execFile = new File(OSDir, "bin/R"+ext);
135 127
		execFile.setExecutable(true);
136
		preferences.put(PATH_TO_EXECUTABLE, execFile.getAbsolutePath());
128
		
137 129
				
138 130
		if (!osname.contains("windows")) { 
139 131
			try {
......
156 148
			return;
157 149
		}
158 150
		
151
		preferences.put(PATH_TO_EXECUTABLE, execFile.getAbsolutePath());
159 152
		
153

  
154
		if (saved != null && saved.length() > 0) {
155
			Version savedVersion = new Version(saved);
156
			if (currentVersion.compareTo(savedVersion) <= 0) {
157
				Log.info("No post-installation of R plugin to do");
158
				return; // nothing to do
159
			}
160
		}
161
		Log.info("Updating R preferences for R plugin version="+currentVersion);
162
		
163
		
164
		
165
		
160 166
		Log.warning("SearchEngine preferences set with: "+OSDir.getAbsolutePath()+" and "+execFile.getAbsolutePath());
161 167
		TXMPreferences.put(RPreferences.PREFERENCES_NODE, RPreferences.VERSION, currentVersion.toString());
162
	
163 168
		
169
		TXMPreferences.put(RPreferences.PREFERENCES_NODE, PATH_TO_EXECUTABLE, execFile.getAbsolutePath());
170
		TXMPreferences.put(RPreferences.PREFERENCES_NODE, IS_MANDATORY, false);
171
		TXMPreferences.put(RPreferences.PREFERENCES_NODE, SERVER_ADDRESS, "127.0.0.1");
172
		TXMPreferences.put(RPreferences.PREFERENCES_NODE, REMOTE, false);
173
		TXMPreferences.put(RPreferences.PREFERENCES_NODE, DISABLE, false);
174
		TXMPreferences.put(RPreferences.PREFERENCES_NODE, DEBUG, false);
175
		TXMPreferences.put(RPreferences.PREFERENCES_NODE, PORT, "6311");
176
		TXMPreferences.put(RPreferences.PREFERENCES_NODE, USER, "");
177
		TXMPreferences.put(RPreferences.PREFERENCES_NODE, PASSWORD, "");
178
		TXMPreferences.put(RPreferences.PREFERENCES_NODE, RARGS, "");
179
		TXMPreferences.put(RPreferences.PREFERENCES_NODE, RSERVEARGS, "");
180
		TXMPreferences.put(RPreferences.PREFERENCES_NODE, FILE_TRANSFERT, false);
181
		TXMPreferences.put(RPreferences.PREFERENCES_NODE, SVG_DEVICE, "svg");
182
		TXMPreferences.put(RPreferences.PREFERENCES_NODE, SHOW_EVAL_LOGS, true);
164 183
	}
165 184
	
166 185
}
tmp/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/InstallRUserPart.java (revision 736)
16 16
		File scriptsDirectory = new File(workspace.getLocation(), "scripts");
17 17
		File samplesDirectory = new File(scriptsDirectory, "samples/R");
18 18
		samplesDirectory.mkdirs();
19
		BundleUtils.copyFiles("org.txm.statengine.r.core", "", "", "R", samplesDirectory);
19
		BundleUtils.copyFiles("org.txm.statsengine.r.core", "", "", "R", scriptsDirectory);
20 20
		
21 21
		return dir.exists() && samplesDirectory.exists();
22 22
	}
tmp/org.txm.rcp/src/main/java/org/txm/rcp/ApplicationWorkbenchAdvisor.java (revision 736)
416 416
	}
417 417
	
418 418
	public static boolean testTXMHOMEPreferenceAndDirectory() {
419
		if (TXMPreferences.getString(TBXPreferences.USER_TXM_HOME, TBXPreferences.PREFERENCES_NODE) == null || TXMPreferences.getString(TBXPreferences.USER_TXM_HOME, TBXPreferences.PREFERENCES_NODE).trim().equals("")) {
419
		String path = TXMPreferences.getString(TBXPreferences.USER_TXM_HOME, TBXPreferences.PREFERENCES_NODE);
420
		
421
		if (path == null || path.trim().equals("")) {
420 422
			Log.warning("TXM user directory is not set ('"+TBXPreferences.USER_TXM_HOME+"' preference is not set).");
421 423
			return true;
422 424
		}
......
466 468
	public void postShutdown() {
467 469
		callStopScript();
468 470
		Toolbox.shutdown();
471
		
469 472
	}
470 473

  
471 474
	/* (non-Javadoc)
tmp/org.txm.rcp/src/main/java/org/txm/rcp/preferences/TXMPreferencePage.java (revision 736)
45 45
 */
46 46
public abstract class TXMPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
47 47

  
48

  
49 48
	/**
50 49
	 * Creates a preferences page.
51 50
	 */
tmp/org.txm.rcp/src/main/java/org/txm/rcp/preferences/RCPPreferences.java (revision 736)
1 1
package org.txm.rcp.preferences;
2 2

  
3 3
import org.eclipse.core.runtime.preferences.DefaultScope;
4
import org.osgi.framework.FrameworkUtil;
4 5
import org.osgi.service.prefs.Preferences;
5 6
import org.txm.core.preferences.TBXPreferences;
6 7
import org.txm.core.preferences.TXMPreferences;
......
14 15
public class RCPPreferences extends TXMPreferences {
15 16

  
16 17
	
17
	public static final String PREFERENCES_NODE = RCPPreferences.class.getName();//FrameworkUtil.getBundle(RPreferences.class).getSymbolicName();
18
	public static final String PREFERENCES_NODE = FrameworkUtil.getBundle(RCPPreferences.class).getSymbolicName();
18 19

  
19 20

  
20
	
21

  
22 21
	/** The Constant UI_LOCALE. */
23 22
	public static final String UI_LOCALE = "ui_locale"; //$NON-NLS-1$
24 23

  
tmp/trunk/org.txm.setups/getSharedFiles.sh (revision 736)
1 1
TOOLBOXDIRECTORY="$HOME/workspace079/org.txm.toolbox"
2
SVNDIR="$HOME/SVN"
3
SVNDOCTRUNK="$SVNDIR/TXMSVN/trunk/doc"
2
SVNDIR="$HOME/SVN/TXMSVN/trunk"
3
SVNDOCTRUNK="$SVNDIR/doc"
4 4
SHARED="./shared"
5 5
SHAREDALL="$SHARED/all"
6
SCRIPTCOPYDIR="$SHAREDALL/scripts"
7 6

  
7

  
8
svn update "${SVNDIR}"
9

  
8 10
# copy TXM sample corpora files files
9
svn update "${SVNDIR}"
10 11
mkdir  "$SHAREDALL/samples"
11
cp -f "${SVNDIR}/corpora/tdm80j" "$SHAREDALL/samples/tdm80j"
12
cp -rf "${SVNDIR}/corpora/tdm80j" "$SHAREDALL/samples/tdm80j"
12 13
if [ $? != 0 ]; then
13
	echo "** TXM REFMAN copy failed"
14
	echo "** TXM sample corpora copy failed"
14 15
	exit 1;
15 16
fi
16 17

  
tmp/org.txm.libs.cqp/src/org/txm/libs/cqp/CQPLibPreferences.java (revision 736)
78 78
		String saved = TXMPreferences.getString(CQPLibPreferences.VERSION, CQPLibPreferences.PREFERENCES_NODE);
79 79
		Version currentVersion = BundleUtils.getBundleVersion(CQPFRAGMENT); // the CQPFRAGMENT plugin contains the right version
80 80
		
81
		if (saved != null && saved.length() > 0) {
82
			Version savedVersion = new Version(saved);
83
			if (currentVersion.compareTo(savedVersion) <= 0) {
84
				Log.info("No post-installation of CQP to do");
85
				return; // nothing to do
86
			}
87
		}
88
		Log.info("Updating CWB preferences for CQP version=" + currentVersion);
89 81
		
90 82
		String os = "win";
91 83
		String ext = "";
......
139 131
			return;
140 132
		}
141 133
		
142
		preferences.put(CQI_SERVER_PATH_TO_CQPLIB, OSDir.getAbsolutePath());
143
		preferences.put(CQI_SERVER_PATH_TO_INIT_FILE, initFile.getAbsolutePath());
144
		preferences.put(CQI_SERVER_PATH_TO_EXECUTABLE, execFile.getAbsolutePath());
145
		
146 134
		if (!osname.contains("windows")) { 
147 135
			try {
148 136
				Log.info("Setting execution file rights to: "+OSDir.getAbsolutePath());
......
153 141
				return;
154 142
			}
155 143
		}
144
		
145
		preferences.put(CQI_SERVER_PATH_TO_CQPLIB, OSDir.getAbsolutePath());
146
		preferences.put(CQI_SERVER_PATH_TO_INIT_FILE, initFile.getAbsolutePath());
147
		preferences.put(CQI_SERVER_PATH_TO_EXECUTABLE, execFile.getAbsolutePath());
148
		
149
		if (saved != null && saved.length() > 0) {
150
			Version savedVersion = new Version(saved);
151
			if (currentVersion.compareTo(savedVersion) <= 0) {
152
				Log.info("No post-installation of CQP to do");
153
				return; // nothing to do
154
			}
155
		}
156
		Log.info("Updating CWB preferences for CQP version=" + currentVersion);
156 157
	
157 158
		Log.warning("SearchEngine preferences set with: "+OSDir.getAbsolutePath()+ ", "+initFile.getAbsolutePath()+ " and "+execFile.getAbsolutePath());
158 159
		TXMPreferences.put(CQPLibPreferences.PREFERENCES_NODE, CQPLibPreferences.VERSION, currentVersion.toString());
159 160
	
161
		TXMPreferences.put(CQPLibPreferences.PREFERENCES_NODE, CQI_SERVER_PATH_TO_CQPLIB, OSDir.getAbsolutePath());
162
		TXMPreferences.put(CQPLibPreferences.PREFERENCES_NODE, CQI_SERVER_PATH_TO_INIT_FILE, initFile.getAbsolutePath());
163
		TXMPreferences.put(CQPLibPreferences.PREFERENCES_NODE, CQI_SERVER_PATH_TO_EXECUTABLE, execFile.getAbsolutePath());
164
		TXMPreferences.put(CQPLibPreferences.PREFERENCES_NODE, CQI_SERVER_ADDITIONAL_OPTIONS, "-b 1000000 -d OFF"); //$NON-NLS-1$
165
		TXMPreferences.put(CQPLibPreferences.PREFERENCES_NODE, CQI_SERVER_PORT, "4877"); //$NON-NLS-1$
166
		TXMPreferences.put(CQPLibPreferences.PREFERENCES_NODE, CQI_SERVER_HOST, "localhost"); //$NON-NLS-1$
167
		TXMPreferences.put(CQPLibPreferences.PREFERENCES_NODE, CQI_SERVER_LOGIN, "anonymous"); //$NON-NLS-1$
168
		TXMPreferences.put(CQPLibPreferences.PREFERENCES_NODE, CQI_SERVER_PASSWORD, ""); //$NON-NLS-1$
169
		TXMPreferences.put(CQPLibPreferences.PREFERENCES_NODE, CQI_SERVER_IS_REMOTE, "" + false); //$NON-NLS-1$
170
		TXMPreferences.put(CQPLibPreferences.PREFERENCES_NODE, CQI_NETWORK_MODE, false); //$NON-NLS-1$
171
		TXMPreferences.put(CQPLibPreferences.PREFERENCES_NODE, CQP_EMPTY_VALUE_CODE, ""); //$NON-NLS-1$
160 172
		
161
		
162 173
	}
163 174
}
tmp/org.txm.core/src/java/org/txm/Toolbox.java (revision 736)
45 45
import org.eclipse.core.runtime.ISafeRunnable;
46 46
import org.eclipse.core.runtime.Platform;
47 47
import org.eclipse.core.runtime.SafeRunner;
48
import org.eclipse.core.runtime.preferences.DefaultScope;
49
import org.eclipse.core.runtime.preferences.IPreferencesService;
48 50
import org.txm.core.messages.TXMCoreMessages;
49 51
import org.txm.core.preferences.TBXPreferences;
50 52
import org.txm.core.preferences.TXMPreferences;
......
196 198
			state = startWorkspace();
197 199

  
198 200
			Log.warning("Initializing logger");
199
			Log.setLevel(Level.parse(TXMPreferences.getString(TBXPreferences.LOG_LEVEL, TBXPreferences.PREFERENCES_NODE)));
201
			String level = TXMPreferences.getString(TBXPreferences.LOG_LEVEL, TBXPreferences.PREFERENCES_NODE);
202
			if (level == "") {
203
				level = "OFF";
204
			}
205
			Log.setLevel(Level.parse(level));
200 206
			Log.setPrintInConsole(Boolean.parseBoolean(TXMPreferences.getString(TBXPreferences.ADD_TECH_LOGS, TBXPreferences.PREFERENCES_NODE)));
201 207

  
202 208
			if (!TXMPreferences.getString(TBXPreferences.LOG_DIR, TBXPreferences.PREFERENCES_NODE).isEmpty()) {
......
416 422
			Toolbox.workspace.save();
417 423
		Toolbox.workspace = null;
418 424
		state = false;
425
		
426
		//save preferences
427
		IPreferencesService service = Platform.getPreferencesService();
428
		try {
429
		service.getRootNode().flush();
430
//		.childrenNames()) {
431
//			System.out.println("********************************************************************************************************"); //$NON-NLS-1$
432
//			System.out.println(" scope: " + children); //$NON-NLS-1$
433
//			String[] subchildren = service.getRootNode().node(children).childrenNames();
434
//			Arrays.sort(subchildren);
435
//			for (String children2 : subchildren) {
436
//				System.out.println("  node: "+ children2); //$NON-NLS-1$
437
//				service.getRootNode().node(children).node(children2).keys();
438
//				Arrays.sort(keys);
439
//				for (String key2 : keys) {
440
//					System.out.println("          " + key2 + " = " + service.getRootNode().node(children).node(children2).get(key2, null)); //$NON-NLS-1$ //$NON-NLS-2$
441
//				}
442
//			}
443
//		}
444
		} catch(Exception e) {
445
			System.out.println("Error while saving preferences: "+e.getLocalizedMessage());
446
		}
419 447
	}
420 448

  
421 449
	/**
tmp/org.txm.core/src/java/org/txm/objects/Workspace.java (revision 736)
128 128
			}
129 129

  
130 130
			// the folders to copy from TXM install dir
131
			BundleUtils.copyFiles("org.txm.core", "res", "org/txm/xml", "xsl", new File(txmhomedir, "xsl"));
132
			BundleUtils.copyFiles("org.txm.core", "res", "org/txm/xml", "schema", new File(txmhomedir, "schema"));
133
			BundleUtils.copyFiles("org.txm.core", "res", "org/txm", "css", new File(txmhomedir, "css"));
131
			BundleUtils.copyFiles("org.txm.core", "res", "org/txm/xml", "xsl", txmhomedir);
132
			BundleUtils.copyFiles("org.txm.core", "res", "org/txm/xml", "schema", txmhomedir);
133
			BundleUtils.copyFiles("org.txm.core", "res", "org/txm", "css", txmhomedir);
134 134

  
135 135
			Workspace workspace = new Workspace(xmlfile);
136 136
			workspace.save();
......
140 140
			for (int i = 0; i < contributions.length; i++) {
141 141
				try {
142 142
					Log.info("Registering engine: "+contributions[i].getName());
143
					PostTXMHOMEInstallationStep engine = (PostTXMHOMEInstallationStep)contributions[i].createExecutableExtension("class"); //$NON-NLS-1$
144
					if (engine.install(workspace)) {
145
						System.out.println("Fail to install "+engine.getName()+" files in "+workspace.getLocation());
146
					} else {
147
						System.out.println(""+engine+" had no engine. Aborting its installation.");
143
					PostTXMHOMEInstallationStep extp = (PostTXMHOMEInstallationStep)contributions[i].createExecutableExtension("class"); //$NON-NLS-1$
144
					if (!extp.install(workspace)) {
145
						System.out.println("Fail to install "+extp.getName()+" files in "+workspace.getLocation());
148 146
					}
149 147
				} catch(CoreException e) {
150 148
					e.printStackTrace();
tmp/org.txm.oriflamms.rcp/src/org/txm/oriflamms/functions/TEI2Project.java (revision 736)
42 42
			return false;
43 43
		}
44 44

  
45
		File oriflammsMacroDirectory = new File(BundleUtils.getBundleFile("Oriflamms"), "res");
45
		File oriflammsMacroDirectory = new File(BundleUtils.getBundleFile("org.txm.oriflamms.rcp"), "res");
46 46
		System.out.println("Ressources files directory: "+oriflammsMacroDirectory);
47 47
		if (!oriflammsMacroDirectory.exists()) {
48 48
			System.out.println("Oriflamms macro directory not found: "+oriflammsMacroDirectory);
tmp/org.txm.oriflamms.rcp/src/org/txm/oriflamms/functions/Project2XTZ.java (revision 736)
25 25
	}
26 26

  
27 27
	public boolean process() throws IOException, TransformerException, ParserConfigurationException, SAXException, XMLStreamException {
28
		File oriflammsMacroDirectory = new File(BundleUtils.getBundleFile("Oriflamms"), "res");
28
		File oriflammsMacroDirectory = new File(BundleUtils.getBundleFile("org.txm.oriflamms.rcp"), "res");
29 29
		System.out.println("Ressources files directory: "+oriflammsMacroDirectory);
30 30
		if (!oriflammsMacroDirectory.exists()) {
31 31
			System.out.println("Oriflamms macro directory not found: "+oriflammsMacroDirectory+". Aborting");
tmp/org.txm.oriflamms.rcp/src/oriflamms/Activator.java (revision 736)
10 10
public class Activator extends AbstractUIPlugin {
11 11

  
12 12
	// The plug-in ID
13
	public static final String PLUGIN_ID = "Oriflamms"; //$NON-NLS-1$
13
	public static final String PLUGIN_ID = "org.txm.oriflamms.rcp"; //$NON-NLS-1$
14 14

  
15 15
	// The shared instance
16 16
	private static Activator plugin;
tmp/org.txm.oriflamms.rcp/META-INF/MANIFEST.MF (revision 736)
1 1
Manifest-Version: 1.0
2 2
Bundle-ManifestVersion: 2
3 3
Bundle-Name: Oriflamms
4
Bundle-SymbolicName: Oriflamms;singleton:=true
4
Bundle-SymbolicName: org.txm.oriflamms.rcp;singleton:=true
5 5
Bundle-Version: 1.0.0.qualifier
6 6
Bundle-Activator: oriflamms.Activator
7 7
Require-Bundle: org.txm.core;bundle-version="0.7.0",
tmp/org.txm.groovy.core/src/groovy/org/txm/groovy/core/InstallGroovyFiles.java (revision 736)
22 22
		}
23 23
		File scriptsDirectory = new File(txmhomedir, "scripts");
24 24
		File importDirectory = new File(scriptsDirectory, "import");
25
		File macroDirectory = new File(scriptsDirectory, "macro");
25
		File macroDirectory = new File(scriptsDirectory, "macro/org/txm");
26 26
		File samplesDirectory = new File(scriptsDirectory, "samples/groovy");
27 27
		
28 28
		HashMap<String, String> publishedImports = new HashMap<String, String>();
......
48 48
		}
49 49
		
50 50
		// copy published macros
51
		macroDirectory.mkdirs();
51 52
		BundleUtils.copyFiles(bundle_id, "src/groovy/", "org/txm", "macro", macroDirectory);
52 53
		
53 54
		// copy sample Groovy scripts
......
56 57
		BundleUtils.copyFiles(bundle_id, "src/groovy/", "org/txm", "importer", samplesDirectory);
57 58
		BundleUtils.copyFiles(bundle_id, "src/groovy/", "org/txm", "sw", samplesDirectory);
58 59
		BundleUtils.copyFiles(bundle_id, "src/groovy/", "org/txm", "tal", samplesDirectory);
59
		
60
		// remove some sample scripts
61
		new File(samplesDirectory, "ReleaseFunctionsValidation.groovy").delete();
62
		new File(samplesDirectory, "ReleaseLoadersValidation.groovy").delete();
63
		new File(samplesDirectory, "org/txm/AntTest.groovy").delete();
64
		new File(samplesDirectory, "org/txm/Build.java").delete();
65
		new File(samplesDirectory, "org/txm/Build2.java").delete();
66
		new File(samplesDirectory, "org/txm/Build3.groovy").delete();
67
		DeleteDir.deleteDirectory(new File(samplesDirectory, "org/txm/setup"));
68
		DeleteDir.deleteDirectory(new File(samplesDirectory, "org/txm/i18n"));
69
		DeleteDir.deleteDirectory(new File(samplesDirectory, "org/txm/svn"));
70
		
71
		return false;
60
			
61
		return scriptsDirectory.exists();
72 62
	}
73 63

  
74 64
	@Override
tmp/org.txm.groovy.core/src/groovy/org/txm/macro/r/Index2barplotMacro.groovy (revision 736)
1
package org.txm.macro.r;
2
// STANDARD DECLARATIONS
3

  
4
import org.kohsuke.args4j.*
5

  
6
import groovy.transform.Field
7

  
8
import org.txm.index.core.functions.Index
9
import org.txm.rcp.swt.widget.parameters.*
10
import org.txm.rcp.commands.*
11
import org.txm.Toolbox
12
import org.txm.statsengine.r.core.RWorkspace
13

  
14
def sel = corpusViewSelection
15

  
16
String symbol = null;
17
String prop = "none"
18
if (sel instanceof Index) {
19
	println "Sending Index data to R..."
20
	((Index)sel).asRMatrix()
21
	symbol = "t("+((Index)sel).getSymbol()+'$data)'
22
	prop = ((Index)sel).getProperties().toString()
23
}
24

  
25
if (symbol == null) {
26
	println "Selection is not an Index. Aborting."
27
	return
28
}
29

  
30
def r = RWorkspace.getRWorkspaceInstance()
31
def file = File.createTempFile("IndexHist", ".svg", new File(Toolbox.getTXMHOMEPATH(), "results"))
32

  
33
/// BEGIN SCRIPTS
34
def script ="""
35
par(las=2)
36
barplot($symbol, xlab="$prop", ylab="f")
37
"""
38
/// END SCRIPTS
39
r.plot(file, script)
40
println "Result saved in: "+file.getAbsolutePath()
41

  
42
//display the graphic
43
monitor.syncExec(new Runnable() {
44
	@Override
45
	public void run() {	OpenSVGGraph.OpenSVGFile(file.getAbsolutePath(), "Distribution") }
46
});
tmp/org.txm.progression.rcp/src/org/txm/progression/rcp/editors/ProgressionEditor.java (revision 736)
81 81
	private Button densityButton;
82 82

  
83 83

  
84
	
85
	
86
	
84

  
85

  
86

  
87 87
	/**
88 88
	 * Queries.
89 89
	 */
......
95 95
	 */
96 96
	@Parameter(key=ProgressionPreferences.STRUCTURAL_UNIT)
97 97
	protected StructuralUnitsComboViewer structuralUnitsComboViewer;
98
	
98

  
99 99
	/**
100 100
	 * Structural unit property.
101 101
	 */
......
107 107
	 */
108 108
	@Parameter(key=ProgressionPreferences.PROPERTY_REGEX)
109 109
	protected Text propertyRegex;
110
	
110

  
111 111
	/**
112 112
	 * Mono style. Same lines styles.
113 113
	 */
......
121 121
	protected Button repeatSameValues;
122 122

  
123 123

  
124
	
125
	
126
	
124

  
125

  
126

  
127 127
	@Override
128 128
	public void __createPartControl(Composite parent) {
129 129

  
......
201 201
					bandeField.setEnabled(densityButton.getSelection());
202 202
					getResult().setDefaultChartType();
203 203
				}
204
				
204

  
205 205
				@Override
206 206
				public void widgetDefaultSelected(SelectionEvent e) { }
207 207
			});
......
211 211
			densityButton.setSelection(!cumulative);
212 212
			// listener
213 213
			densityButton.addSelectionListener(new SelectionListener() {
214
				
214

  
215 215
				@Override
216 216
				public void widgetSelected(SelectionEvent e) {
217 217
					bandeField.setEnabled(densityButton.getSelection());
218 218
					getResult().setChartType(Progression.DENSITY_CHART_TYPE);					
219 219
				}
220
				
220

  
221 221
				@Override
222 222
				public void widgetDefaultSelected(SelectionEvent e) { }
223 223
			});
......
236 236
			StructuralUnitsCombosGroup structuration = new StructuralUnitsCombosGroup(paramPanel, this, this.getResult().getStructuralUnit(), this.getResult().getStructuralUnitProperty());
237 237
			GridData gdata = new GridData(GridData.BEGINNING, GridData.BEGINNING, true, false, 3, 1);
238 238
			structuration.setLayoutData(gdata); // the group must use the full line
239
			
239

  
240 240
			// Structural Unit
241 241
			structuralUnitsComboViewer = structuration.getStructuralUnitsComboViewer();
242
			
242

  
243 243
			// Structural Unit Property
244 244
			structuralUnitPropertiesComboViewer = structuration.getStructuralUnitPropertiesComboViewer();
245
			
246 245

  
246

  
247 247
			// property REGEX
248 248
			Label regexLabel = new Label(structuration, SWT.NONE);
249 249
			regexLabel.setText(ProgressionUIMessages.ProgressionDialog_7);
......
254 254
			//propertyRegex.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true, 2, 1));
255 255
			propertyRegex.addKeyListener(new ComputeKeyListener(this));
256 256

  
257
			
257

  
258 258
			// Repeat same values in part markers
259
			repeatSameValues = new Button(structuration, SWT.CHECK);
259
			repeatSameValues = new Button(paramPanel, SWT.CHECK);
260 260
			repeatSameValues.setText(ProgressionUIMessages.ProgressionDialog_15);
261 261
			repeatSameValues.addSelectionListener(new ComputeSelectionListener(this));
262
			
263
			
262

  
263

  
264 264
			// Lines styles
265 265
			multipleLineStrokes = new Button(paramPanel, SWT.CHECK);
266 266
			multipleLineStrokes.setText(ProgressionUIMessages.ProgressionDialog_14);
267 267
			multipleLineStrokes.addSelectionListener(new ComputeSelectionListener(this));
268
			
269 268

  
269

  
270 270
			// Queries
271 271
			sc1 = new ScrolledComposite(mainPanel, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
272 272
			glayout = new GridLayout(1, true);
......
285 285

  
286 286
			// queries parameters
287 287
			// FIXME: useless?
288
//			Label focusLabel = new Label(queriesFocusComposite, SWT.NONE);
289
//			focusLabel.setText(ProgressionUIMessages.ProgressionDialog_8);
290
//			focusLabel.setAlignment(SWT.CENTER);
288
			//			Label focusLabel = new Label(queriesFocusComposite, SWT.NONE);
289
			//			focusLabel.setText(ProgressionUIMessages.ProgressionDialog_8);
290
			//			focusLabel.setAlignment(SWT.CENTER);
291 291

  
292 292
			// add query button
293 293
			Button plusButton = new Button(queriesFocusComposite, SWT.NONE);
......
315 315

  
316 316
	}
317 317

  
318
	
319
	
320
	
318

  
319

  
320

  
321 321
	/**
322 322
	 * 
323 323
	 * @author mdecorde
......
326 326
	public class QueryField extends Composite {
327 327

  
328 328
		protected AssistedQueryWidget focusTextBox;
329
		
329

  
330 330
		protected TXMEditor editor;
331
		
331

  
332 332
		/**
333 333
		 * 
334 334
		 * @param parent
......
336 336
		 */
337 337
		public QueryField(Composite parent, int style) {
338 338
			super(parent, style);
339
			
339

  
340 340
			GridLayout glayout = new GridLayout(2, false);
341 341
			glayout.marginBottom = glayout.marginTop = glayout.marginHeight = glayout.verticalSpacing = 0;
342
			
342

  
343 343
			this.setLayout(glayout);
344
			
344

  
345 345
			queryWidgets.add(this);
346
			
346

  
347 347
			focusTextBox = new AssistedQueryWidget(this, SWT.BORDER, getResult().getCorpus());
348 348
			focusTextBox.setFocus();
349 349
			focusTextBox.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
......
375 375
		public void setQuery(String query) {
376 376
			focusTextBox.setText(query);
377 377
		}
378
		
378

  
379 379
		public Query getQuery() {
380 380
			return focusTextBox.getQuery();
381 381
		}
......
390 390
	 *
391 391
	 * @return the assisted query widget
392 392
	 */
393
	private QueryField addFocusQueryField(String text) {
394
		
393
	private QueryField addFocusQueryField(String initialQuery) {
394

  
395 395
		// do not add same query twice
396
		for (int i = 0; i < queryWidgets.size(); i++) {
397
			
398
			if(queryWidgets.get(i).getQuery().getQueryString().equals(text)
399
					|| (queryWidgets.get(i).getQuery().getQueryString().equals("\"\"") && text.isEmpty()))	{
400
				return null;
396
		if (initialQuery != null && initialQuery.length() > 0) { // test only if the initial query is set
397
			for (int i = 0; i < queryWidgets.size(); i++) {
398

  
399
				if (queryWidgets.get(i).getQuery().getQueryString().equals(initialQuery))	{
400
					System.out.println("The query already exists: "+initialQuery);
401
					return null;
402
				}
401 403
			}
402 404
		}
403
		
405

  
404 406
		QueryField queryField = new QueryField(this.queriesFocusComposite, SWT.NONE);
405
		queryField.setQuery(text);
407
		if (initialQuery != null) { // avoid null pointer exception
408
			queryField.setQuery(initialQuery);
409
		}
406 410
		GridData gridData = new GridData(GridData.FILL, GridData.FILL, true, false);
407 411
		queryField.setLayoutData(gridData);
408 412

  
......
422 426

  
423 427
	@Override
424 428
	public void updateEditorFromChart(boolean update) {
425
		
429

  
426 430
		// create the queries fields
427 431
		if (queries == null) {
428 432
			addFocusQueryField();
......
433 437
			}
434 438
		}
435 439
	}
436
	
437 440

  
441

  
438 442
	@Override
439 443
	public void updateResultFromEditor() {
440 444

  
tmp/org.txm.analec.rcp/src/org/txm/macro/analec/exploit/SchemasProgressionMacro.groovy (revision 736)
187 187

  
188 188
def corpus = parent
189 189
try {
190
	def struct = corpus.getStructuralUnit(struct_name)
191
	def struct_p = struct.getProperty(struct_prop)
192

  
190
	def struct = corpus.getStructuralUnit(struct_name);
191
	def struct_p = null;
192
	if (struct != null) {
193
		struct_p = struct.getProperty(struct_prop)
194
	}
195
	
193 196
	Progression progression = new Progression(corpus, queries,
194 197
			struct, struct_p,	".*",
195 198
			cummulative, false, false,

Also available in: Unified diff