Révision 2980

tmp/org.txm.rcp/src/main/java/org/txm/rcp/utils/SWTUtils.java (revision 2980)
1
package org.txm.rcp.utils;
2

  
3
import org.eclipse.core.commands.ExecutionEvent;
4
import org.eclipse.swt.widgets.Shell;
5
import org.eclipse.swt.widgets.Widget;
6
import org.eclipse.ui.handlers.HandlerUtil;
7
import org.eclipse.ui.part.EditorPart;
8
import org.txm.rcp.Activator;
9

  
10
/**
11
 * Utils :
12
 * - getShell() from various SWT&Eclipse objects
13
 * 
14
 * @author mdecorde
15
 *
16
 */
17
public class SWTUtils {
18
	
19
	public static Shell getShell() {
20
		Shell shell = Activator.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell();
21
		if (shell == null) {
22
			return new Shell();
23
		}
24
		return shell;
25
	}
26
	
27
	public static Shell getShell(EditorPart editor) {
28
		if (editor == null) return getShell();
29
		return editor.getSite().getShell();
30
	}
31
	
32
	public static Shell getShell(ExecutionEvent event) {
33
		if (event == null) return getShell();
34
		return HandlerUtil.getActiveShell(event);
35
	}
36
	
37
	public static Shell getShell(Widget widget) {
38
		if (widget == null || widget.isDisposed()) return getShell();
39
		return widget.getDisplay().getActiveShell();
40
	}
41
}
0 42

  
tmp/org.txm.rcp/src/main/java/org/txm/rcp/p2/plugins/TXMUpdateHandler.java (revision 2980)
43 43
import org.eclipse.equinox.p2.ui.ProvisioningUI;
44 44
import org.eclipse.osgi.util.NLS;
45 45
import org.eclipse.swt.SWT;
46
import org.eclipse.swt.widgets.Display;
46 47
import org.eclipse.swt.widgets.MessageBox;
47 48
import org.eclipse.swt.widgets.Shell;
48 49
import org.eclipse.ui.handlers.HandlerUtil;
......
212 213
	@Override
213 214
	protected Shell getShell() {
214 215
		// System.out.println("MY GETSHELL: "+Display.getCurrent().getActiveShell());
216
		try {
217
			return Display.getCurrent().getActiveShell();
218
		}
219
		catch (Exception e) {
220
			Log.finer("Error: no active SWT shell available");
221
		}
215 222
		return new Shell();
216 223
	}
217 224
	
tmp/org.txm.rcp/src/main/java/org/txm/rcp/commands/editor/SetEncoding.java (revision 2980)
39 39
import org.txm.core.messages.TXMCoreMessages;
40 40
import org.txm.rcp.editors.TxtEditor;
41 41
import org.txm.rcp.messages.TXMUIMessages;
42
import org.txm.rcp.utils.SWTUtils;
42 43

  
43 44
/**
44 45
 * @author mdecorde
45
 * Change the encoding of the currently selected text editor
46
 *         Change the encoding of the currently selected text editor
46 47
 */
47 48
public class SetEncoding extends AbstractHandler {
48

  
49
	/* (non-Javadoc)
49
	
50
	/*
51
	 * (non-Javadoc)
50 52
	 * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
51 53
	 */
52 54
	@Override
......
57 59
			TxtEditor te = (TxtEditor) page;
58 60
			setEncoding(te);
59 61
		}
60

  
62
		
61 63
		return null;
62 64
	}
63

  
65
	
64 66
	public static void setEncoding(TxtEditor te) {
65 67
		try {
66
			IEncodingSupport encodingSupport = (IEncodingSupport) te.getAdapter(IEncodingSupport.class);		
68
			IEncodingSupport encodingSupport = te.getAdapter(IEncodingSupport.class);
67 69
			String currentEncoding = encodingSupport.getEncoding();
68 70
			String defaultEncoding = encodingSupport.getDefaultEncoding();
69 71
			if (currentEncoding == null) currentEncoding = defaultEncoding;
70
			Shell sh = new Shell();
72
			Shell sh = SWTUtils.getShell(te);
71 73
			InputDialog dlg = new InputDialog(sh,
72 74
					TXMUIMessages.changeCharactersEncoding,
73 75
					TXMCoreMessages.bind(TXMUIMessages.changeCharactersEncodingCurrentEncodingColon, currentEncoding, defaultEncoding),
......
78 80
					encodingSupport.setEncoding(newEncoding);
79 81
				}
80 82
			}
81
		} catch(Exception e) {
83
		}
84
		catch (Exception e) {
82 85
			org.txm.utils.logger.Log.printStackTrace(e);
83 86
		}
84 87
	}
85
}
88
}
tmp/org.txm.statsengine.r.rcp/src/org/txm/rcp/commands/R/ShowSvgHelp.java (revision 2980)
32 32
import org.eclipse.core.commands.ExecutionException;
33 33
import org.eclipse.jface.dialogs.MessageDialog;
34 34
import org.eclipse.swt.widgets.Shell;
35
import org.eclipse.ui.handlers.HandlerUtil;
35 36
import org.txm.rcp.messages.TXMUIMessages;
37

  
36 38
// TODO: Auto-generated Javadoc
37 39
/**
38 40
 * The Class ShowSvgHelp.
39 41
 */
40 42
public class ShowSvgHelp extends AbstractHandler {
41

  
42
	/* (non-Javadoc)
43
	
44
	/*
45
	 * (non-Javadoc)
43 46
	 * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
44 47
	 */
45 48
	@Override
46 49
	public Object execute(ExecutionEvent event) throws ExecutionException {
47 50
		
48
		MessageDialog.openInformation(new Shell(), TXMUIMessages.graphicsKeyboardShortcuts, 
51
		MessageDialog.openInformation(HandlerUtil.getActiveShell(event), TXMUIMessages.graphicsKeyboardShortcuts,
49 52
				TXMUIMessages.panColonRightMousePlusDrag +
50
				TXMUIMessages.zoomInAmpoutColonMouseWheelORShiftPlusRightMousePlusDrag +
51
				TXMUIMessages.zoomToSelectionColonCtrlPlusLeftMousePlusdrag +
52
				TXMUIMessages.EMPTY +
53
				TXMUIMessages.resetTheViewColonF5);
53
						TXMUIMessages.zoomInAmpoutColonMouseWheelORShiftPlusRightMousePlusDrag +
54
						TXMUIMessages.zoomToSelectionColonCtrlPlusLeftMousePlusdrag +
55
						TXMUIMessages.EMPTY +
56
						TXMUIMessages.resetTheViewColonF5);
54 57
		return event;
55 58
		
56 59
		/*
57 60
		 * <li>Faire glisser : Shif t+Left Mouse+drag</li>
58
<li>Zoom avant et arrière : Shif t+Right Mouse+drag</li>
59
<li>Zoom par sélection : Ctrl+Left Mouse+drag</li>
60
<li>Rotation : Ctrl+Right Mouse+drag</li>
61
<li>Retour à la vue initiale : F5</li>
61
		 * <li>Zoom avant et arrière : Shif t+Right Mouse+drag</li>
62
		 * <li>Zoom par sélection : Ctrl+Left Mouse+drag</li>
63
		 * <li>Rotation : Ctrl+Right Mouse+drag</li>
64
		 * <li>Retour à la vue initiale : F5</li>
62 65
		 */
63 66
	}
64

  
65
}
67
	
68
}
tmp/org.txm.statsengine.r.rcp/src/org/txm/statsengine/r/rcp/handlers/CheckRPackages.java (revision 2980)
10 10
import org.eclipse.core.commands.ExecutionException;
11 11
import org.eclipse.jface.dialogs.MessageDialog;
12 12
import org.eclipse.jface.util.Util;
13
import org.eclipse.swt.widgets.Display;
13 14
import org.eclipse.swt.widgets.Shell;
14 15
import org.rosuda.REngine.REXP;
15 16
import org.rosuda.REngine.REXPInteger;
......
19 20
import org.txm.core.engines.EngineType;
20 21
import org.txm.core.messages.TXMCoreMessages;
21 22
import org.txm.rcp.handlers.BaseAbstractHandler;
23
import org.txm.rcp.utils.SWTUtils;
22 24
import org.txm.statsengine.r.core.RWorkspace;
23 25
import org.txm.statsengine.r.core.exceptions.RWorkspaceException;
24 26
import org.txm.statsengine.r.rcp.messages.RUIMessages;
25 27
import org.txm.utils.logger.Log;
26 28

  
27 29
public class CheckRPackages extends BaseAbstractHandler {
28

  
30
	
29 31
	public static HashMap<String, String> packages;
32
	
30 33
	public static HashMap<String, String> errorMessages;
34
	
31 35
	public static HashMap<String, List<String>> depends;
32 36
	{
33
		packages = new HashMap<String,String>();
34
		errorMessages = new HashMap<String,String>();
35
		depends = new HashMap<String,List<String>>();
37
		packages = new HashMap<>();
38
		errorMessages = new HashMap<>();
39
		depends = new HashMap<>();
36 40
		
37 41
		packages.put("textometry", "0.1.4"); //$NON-NLS-1$ //$NON-NLS-2$
38 42
		packages.put("FactoMineR", "1.24"); //$NON-NLS-1$ //$NON-NLS-2$
......
50 54
		errorMessages.put("textometry", RUIMessages.tXMCouldNotLoadTheTextometryRPackageTheCooccurenceSpecificityAndProgressionCommandsWontBeAvailable); //$NON-NLS-1$
51 55
		errorMessages.put("FactoMineR", RUIMessages.tXMCouldNotLoadTheFactoMineRRPackageTheCorrespondanceAnalysisClassificationCommandsWontBeAvailable); //$NON-NLS-1$
52 56
	}
53

  
57
	
54 58
	@Override
55 59
	public Object execute(ExecutionEvent event) throws ExecutionException {
56 60
		
57
		if(!super.checkStatsEngine())	{
61
		if (!super.checkStatsEngine()) {
58 62
			return null;
59 63
		}
60 64
		
61
		Shell shell = new Shell();
65
		Shell shell = SWTUtils.getShell(event);
62 66
		if (check()) {
63 67
			MessageDialog.openInformation(shell, RUIMessages.rPackageDiagnostic, RUIMessages.necessaryPackagesAreReady);
64
		} else {
68
		}
69
		else {
65 70
			MessageDialog.openError(shell, RUIMessages.rPackageDiagnostic, RUIMessages.somePackagesAreMissingSeeConsoleForDetails);
66 71
		}
67 72
		return null;
68 73
	}
69

  
74
	
70 75
	public static String buildVersion(REXPInteger rExpInteger) throws REXPMismatchException {
71 76
		StringBuffer buff = new StringBuffer(""); //$NON-NLS-1$
72 77
		
73
		//RList list = rExpInteger.asList();
78
		// RList list = rExpInteger.asList();
74 79
		int[] ints = rExpInteger.asIntegers();
75
		for (int i = 0 ; i < rExpInteger.length() ;i++) {
76
			buff.append("."+ints[i]); //$NON-NLS-1$
80
		for (int i = 0; i < rExpInteger.length(); i++) {
81
			buff.append("." + ints[i]); //$NON-NLS-1$
77 82
		}
78 83
		if (buff.length() > 0)
79 84
			return buff.substring(1); // first "."
80

  
85
		
81 86
		return ""; //$NON-NLS-1$
82 87
	}
83

  
88
	
84 89
	public static boolean check() {
85 90
		System.out.print(RUIMessages.checkingRPackages);
86
		//Log.info("Checking R packages...");
91
		// Log.info("Checking R packages...");
87 92
		
88 93
		String method = "internal"; // default method is internal //$NON-NLS-1$
89 94
		if (Util.isMac()) method = "curl"; //$NON-NLS-1$
......
94 99
			RWorkspace rw = null;
95 100
			try {
96 101
				rw = RWorkspace.getRWorkspaceInstance();
97
			} catch (RWorkspaceException e) {
102
			}
103
			catch (RWorkspaceException e) {
104
				Log.warning(TXMCoreMessages.bind(RUIMessages.anErrorOccuredWhileGettingRWorkspaceInsanceColon, e));
98 105
				Log.printStackTrace(e);
99
				System.out.println(TXMCoreMessages.bind(RUIMessages.anErrorOccuredWhileGettingRWorkspaceInsanceColon, e));
100 106
				return false;
101 107
			}
108
			
102 109
			for (String p : packages.keySet()) {
103
				//String v = packages.get(p);
104
				//String error = errorMessages.get(p);
110
				// String v = packages.get(p);
111
				// String error = errorMessages.get(p);
105 112
				try {
106
					rw.eval("library(\""+p+"\")"); //$NON-NLS-1$ //$NON-NLS-2$
107
				} catch (Exception e) {
113
					rw.eval("installed.packages(\"" + p + "\")"); //$NON-NLS-1$ //$NON-NLS-2$
114
				}
115
				catch (Exception e) {
108 116
					Log.printStackTrace(e);
109 117
					Log.severe(TXMCoreMessages.bind("{0} package not installed. Error={1}.", p, e));
110 118
					ret = false;
111 119
				}
120
				
112 121
				if (ret) { // check the version and install if possible
113 122
					try {
114
						String currentVersion = getVersion(rw,p);
115
						ret = updateIfNecessary(rw, p, currentVersion);				
116
					} catch (Exception e) {
123
						String currentVersion = getVersion(rw, p);
124
						ret = updateIfNecessary(rw, p, currentVersion);
125
					}
126
					catch (Exception e) {
117 127
						Log.printStackTrace(e);
118
						System.out.println(TXMCoreMessages.bind("Error while testing package: {0}.", e));
128
						Log.warning(TXMCoreMessages.bind("Error while testing package: {0}.", e));
119 129
						ret = false;
120 130
					}
121
				} else { // package is not present, install it
131
				}
132
				else { // package is not present, try installing it
122 133
					try {
123 134
						Log.info(TXMCoreMessages.bind("The '{0}' package is not installed. Trying to install it now...", p));
124 135
						
125
						try {rw.eval("detach(\"package:"+p+"\", character.only = TRUE)");} catch(Exception tmpE){} // unload package to be able to reinstall it //$NON-NLS-1$ //$NON-NLS-2$
136
						try {
137
							rw.eval("detach(\"package:" + p + "\", character.only = TRUE)"); //$NON-NLS-1$ //$NON-NLS-2$
138
						}
139
						catch (Exception tmpE) {
140
						} // unload package to be able to reinstall it
126 141
						
127
						rw.eval("install.packages(\""+p+"\", dependencies=TRUE, method=\""+method+"\", repos=\"http://cran.rstudio.com\");"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
142
						// install depends if any
143
						if (depends.containsKey(p)) {
144
							for (String dep : depends.get(p)) {
145
								try {
146
									Log.info(TXMCoreMessages.bind("Trying to install the {0} dependency of {1} now...", dep, p));
147
									rw.eval("install.packages(\"" + dep + "\", dependencies=TRUE, method=\"" + method + "\", repos=\"http://cran.rstudio.com\");"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
148
								}
149
								catch (Exception e) {
150
									Log.warning(TXMCoreMessages.bind("Error while installing R dependency of {0} : {1} : {2}", p, dep, e));
151
									Log.printStackTrace(e);
152
									ret = false;
153
								}
154
							}
155
						}
128 156
						
129
						try {
130
							rw.eval("library(\""+p+"\")"); //$NON-NLS-1$ //$NON-NLS-2$
157
						// install the package itself
158
						rw.eval("install.packages(\"" + p + "\", dependencies=TRUE, method=\"" + method + "\", repos=\"http://cran.rstudio.com\");"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
159
						
160
						try { // now try loading the package
161
							rw.eval("library(\"" + p + "\")"); //$NON-NLS-1$ //$NON-NLS-2$
131 162
							Log.info(TXMCoreMessages.bind(RUIMessages.installedSuccessfully, p));
132
						} catch (Exception e) {
163
						}
164
						catch (Exception e) {
133 165
							Log.printStackTrace(e);
134
							System.out.println(TXMCoreMessages.bind("The '{0}' package was not installed. Please install it manually:\n * Run R\n * and execute 'install.packages(\"{1}\"')", p, p));
166
							Log.warning(TXMCoreMessages.bind("The '{0}' package was not installed correctly. Please install it manually:\n * Run R\n * and execute 'install.packages(\"{1}\"')", p, p));
135 167
							ret = false;
136 168
						}
137
					} catch (Exception e) {
169
					}
170
					catch (Exception e) {
138 171
						Log.printStackTrace(e);
139 172
						System.out.println(TXMCoreMessages.bind(RUIMessages.errorWhileInstallingPackageColon, e));
140 173
						ret = false;
141 174
					}
142 175
				}
143 176
			}
144
		} else {
177
		}
178
		else {
145 179
			System.out.println(RUIMessages.theRStatEngineIsNotRunningTryingToReinstallThePackagesRServeFactoMineRTextometry);
146 180
			try {
147 181
				installRPAckagesViaRscript();
148
			} catch(Exception e) {
182
			}
183
			catch (Exception e) {
149 184
				System.out.println(RUIMessages.tXMCouldNotReinstallRPackagesPleaseDoItManuallySeeManual);
150 185
			}
151 186
			ret = false;
......
160 195
		String cmd = ""; //$NON-NLS-1$
161 196
		String installPath = Toolbox.getInstallDirectory();
162 197
		if (Util.isMac() || Util.isLinux()) {
163
			cmd = "R --no-save < \""+installPath+"/R/rlibs.R\""; //$NON-NLS-1$ //$NON-NLS-2$
164
		} else if (Util.isWindows()) {
198
			cmd = "R --no-save < \"" + installPath + "/R/rlibs.R\""; //$NON-NLS-1$ //$NON-NLS-2$
199
		}
200
		else if (Util.isWindows()) {
165 201
			return false;
166
		} else {
202
		}
203
		else {
167 204
			return false;
168 205
		}
169 206
		Runtime.getRuntime().exec(cmd);
170 207
		return true;
171 208
	}
172

  
209
	
173 210
	private static String getVersion(RWorkspace rw, String p) throws REXPMismatchException, RWorkspaceException {
174
		REXP rRez = rw.eval("packageVersion(\""+p+"\")"); //$NON-NLS-1$ //$NON-NLS-2$
211
		REXP rRez = rw.eval("packageVersion(\"" + p + "\")"); //$NON-NLS-1$ //$NON-NLS-2$
175 212
		if (rRez.isList()) {
176 213
			RList rList = rRez.asList();
177 214
			if (rList.size() > 0) {
178 215
				Object elem = rList.get(0);
179 216
				if (elem instanceof REXPInteger) {
180
					REXPInteger rExpInt = (REXPInteger)elem;
217
					REXPInteger rExpInt = (REXPInteger) elem;
181 218
					return buildVersion(rExpInt);
182
				} else {
219
				}
220
				else {
183 221
					System.out.println(TXMCoreMessages.bind(RUIMessages.eRRORColonRlistFirstElementIsNotREXPIntegerColon, elem));
184 222
				}
185
			} else {
223
			}
224
			else {
186 225
				System.out.println(TXMCoreMessages.bind(RUIMessages.eRRORColonREvalListSizeIs0Colon, rList));
187 226
			}
188
		} else {
227
		}
228
		else {
189 229
			System.out.println(TXMCoreMessages.bind(RUIMessages.eRRORColonREvalIsNotAListColon, rRez));
190
		}	
230
		}
191 231
		return ""; //$NON-NLS-1$
192 232
	}
193

  
233
	
194 234
	/**
195 235
	 * 
196 236
	 * @param rw
......
202 242
	 * @throws REXPMismatchException
203 243
	 */
204 244
	private static boolean updateIfNecessary(RWorkspace rw, String p, String currentVersion) throws RWorkspaceException, REXPMismatchException {
205
		//System.out.println("Current version of "+p+" is "+v+" and need "+packages.get(p));
206
		//System.out.println("comp "+(packages.get(p))+" to "+(v));
207
		//System.out.println(packages.get(p).compareTo(v));
245
		// System.out.println("Current version of "+p+" is "+v+" and need "+packages.get(p));
246
		// System.out.println("comp "+(packages.get(p))+" to "+(v));
247
		// System.out.println(packages.get(p).compareTo(v));
208 248
		if (packages.get(p).compareTo(currentVersion) > 0) {
209 249
			System.out.println(TXMCoreMessages.bind("Updating the '{0}' ({1}) R package up to version {2}...", p, currentVersion, packages.get(p)));
210 250
			
211
			try {rw.eval("detach(\"package:"+p+"\", character.only = TRUE)");} catch(Exception tmpE){} // unload package to be able to reinstall it //$NON-NLS-1$ //$NON-NLS-2$
251
			try {
252
				rw.eval("detach(\"package:" + p + "\", character.only = TRUE)"); //$NON-NLS-1$ //$NON-NLS-2$
253
			}
254
			catch (Exception tmpE) {
255
			} // unload package to be able to reinstall it
212 256
			
213
			//update.packages don't work ?
214
			//rw.eval("update.packages(\""+p+"\", dependencies=TRUE, ask=FALSE, repos=\"http://cran.rstudio.com\");"); //$NON-NLS-1$ //$NON-NLS-2$
215
			rw.eval("install.packages(\""+p+"\", dependencies=TRUE, repos=\"http://cran.rstudio.com\");"); //$NON-NLS-1$ //$NON-NLS-2$
257
			// update.packages don't work ?
258
			// rw.eval("update.packages(\""+p+"\", dependencies=TRUE, ask=FALSE, repos=\"http://cran.rstudio.com\");"); //$NON-NLS-1$ //$NON-NLS-2$
259
			rw.eval("install.packages(\"" + p + "\", dependencies=TRUE, repos=\"http://cran.rstudio.com\");"); //$NON-NLS-1$ //$NON-NLS-2$
216 260
			
217
			try {rw.eval("library(\""+p+"\")");} catch(Exception tmpE){} // reload it //$NON-NLS-1$ //$NON-NLS-2$
261
			try {
262
				rw.eval("library(\"" + p + "\")"); //$NON-NLS-1$ //$NON-NLS-2$
263
			}
264
			catch (Exception tmpE) {
265
			} // reload it
218 266
			String newVersion = getVersion(rw, p);
219 267
			if (!newVersion.equals(packages.get(p))) {
220 268
				System.out.println(TXMCoreMessages.bind("Update of '{0}' failed (current version is still {1}). Warning: Windows users need to restart TXM.", p, newVersion));
......
223 271
		}
224 272
		return true;
225 273
	}
226
}
274
}
tmp/org.txm.backtomedia.rcp/src/org/txm/backtomedia/commands/function/BackToMedia.java (revision 2980)
369 369
			}
370 370
			
371 371
			AbstractCqiClient cqiClient = CorpusManager.getCorpusManager().getCqiClient();
372
			int[] struc = cqiClient.cpos2Struc(startProperty.getQualifiedName(),
373
					new int[] { keywordPosition, keywordEndPosition });
372
			int[] struc = cqiClient.cpos2Struc(startProperty.getQualifiedName(), new int[] { keywordPosition, keywordEndPosition });
374 373
			int[] struc2 = new int[] { struc[0], struc[1], struc[1] + 1 };
375 374
			String[] times = cqiClient.struc2Str(startProperty.getQualifiedName(), struc2);
376 375
			sStartTime = times[0];
tmp/org.txm.groovy.core/src/groovy/org/txm/macro/projects/antract/PrepareAFVOIXOFFCorpusMacro.groovy (revision 2980)
60 60
backtomedia/sync_mode=Structure
61 61
concordance/context_limits=text
62 62
concordance/context_limits_type=list
63
concordance/view_reference_pattern={"format"\\:"%s, %s, %s","properties"\\:["text_date-de-diffusion","u_time","div_identifiant-de-la-notice"]}
63
concordance/view_reference_pattern={"format"\\:"%s, %s, %s","properties"\\:["text_date-de-diffusion-tri","u_time","div_identifiant-de-la-notice"]}
64 64
concordance/sort_reference_pattern={"format"\\:"","properties"\\:["text_date-de-diffusion-tri","u_time","div_identifiant-de-la-notice"]}
65 65
concordance/name=concordance
66 66
eclipse.preferences.version=1"""
tmp/org.txm.edition.rcp/src/org/txm/edition/rcp/editors/SynopticEditionEditor.java (revision 2980)
27 27
//
28 28
package org.txm.edition.rcp.editors;
29 29

  
30
import java.io.IOException;
31 30
import java.util.ArrayList;
32
import java.util.Arrays;
33 31
import java.util.Collection;
34 32
import java.util.HashMap;
35 33
import java.util.HashSet;
......
74 72
import org.eclipse.ui.commands.ICommandService;
75 73
import org.eclipse.ui.handlers.IHandlerService;
76 74
import org.txm.core.messages.TXMCoreMessages;
77
import org.txm.core.results.TXMResult;
78 75
import org.txm.edition.rcp.messages.EditionUIMessages;
79 76
import org.txm.objects.Edition;
80 77
import org.txm.objects.Page;
81 78
import org.txm.objects.Text;
82 79
import org.txm.rcp.IImageKeys;
83 80
import org.txm.rcp.editors.IEditionEditor;
84
import org.txm.rcp.editors.ITXMResultEditor;
85 81
import org.txm.rcp.editors.TXMEditor;
86 82
import org.txm.rcp.swt.GLComposite;
87
import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
88 83
import org.txm.searchengine.cqp.corpus.CQPCorpus;
89 84
import org.txm.searchengine.cqp.corpus.MainCorpus;
90
import org.txm.searchengine.cqp.serverException.CqiServerError;
91 85
import org.txm.utils.logger.Log;
92 86

  
93 87
/**
......
97 91
 * 
98 92
 */
99 93
public class SynopticEditionEditor extends TXMEditor<Text> implements IEditionEditor {
100

  
94
	
101 95
	/** The Constant ID. */
102 96
	public final static String ID = SynopticEditionEditor.class.getName();
103

  
97
	
104 98
	LinkedHashMap<String, EditionPanel> editionPanels = new LinkedHashMap<>();
105

  
99
	
106 100
	/** The page_label: show current page name. */
107 101
	org.eclipse.swt.widgets.Text page_text;
108

  
102
	
109 103
	Label page_label;
110

  
104
	
111 105
	GLComposite editionsArea;
112

  
106
	
113 107
	private List<String> editionNames;
114

  
108
	
115 109
	private CQPCorpus corpus;
116

  
110
	
117 111
	private MainCorpus mainCorpus;
118

  
112
	
119 113
	private Text text;
120

  
114
	
121 115
	private Button editionsChooser;
122

  
116
	
123 117
	// private Label editionsLabel;
124 118
	private GLComposite controlsArea;
125

  
119
	
126 120
	// private GLComposite annotationWidgetsArea;
127 121
	// private TXMEditorToolBar supplementaryButtonToolbar;
128 122
	private ISelectionProvider selProvider;
129

  
123
	
130 124
	private org.eclipse.swt.widgets.Text text_text;
131

  
125
	
132 126
	// private Label text_label;
133 127
	private TXMAutoCompleteField identifiantComboAutoCompleteField;
134

  
128
	
135 129
	// TODO finish editor conversion
136 130
	@Override
137 131
	public Text getResult() {
......
140 134
		}
141 135
		return text;
142 136
	}
143

  
137
	
144 138
	/**
145 139
	 * Instantiates a new txm browser.
146 140
	 */
147 141
	public SynopticEditionEditor() {
148 142
		selProvider = new ISelectionProvider() {
149

  
143
			
150 144
			@Override
151 145
			public void setSelection(ISelection selection) {}
152

  
146
			
153 147
			@Override
154 148
			public void removeSelectionChangedListener(ISelectionChangedListener listener) {}
155

  
149
			
156 150
			@Override
157 151
			public ISelection getSelection() {
158 152
				ITextSelection sel = new ITextSelection() {
159

  
153
					
160 154
					@Override
161 155
					public boolean isEmpty() {
162 156
						for (EditionPanel panel : editionPanels.values()) {
......
165 159
						}
166 160
						return true;
167 161
					}
168

  
162
					
169 163
					@Override
170 164
					public String getText() {
171 165
						for (EditionPanel panel : editionPanels.values()) {
......
174 168
						}
175 169
						return EditionUIMessages.CommandLink_empty;
176 170
					}
177

  
171
					
178 172
					@Override
179 173
					public int getStartLine() {
180 174
						return 0;
181 175
					}
182

  
176
					
183 177
					@Override
184 178
					public int getOffset() {
185 179
						return 0;
186 180
					}
187

  
181
					
188 182
					@Override
189 183
					public int getLength() {
190 184
						return 0;
191 185
					}
192

  
186
					
193 187
					@Override
194 188
					public int getEndLine() {
195 189
						return 0;
......
197 191
				};
198 192
				return sel;
199 193
			}
200

  
194
			
201 195
			@Override
202 196
			public void addSelectionChangedListener(ISelectionChangedListener listener) {}
203 197
		};
204

  
198
		
205 199
	}
206

  
200
	
207 201
	public void setHighlightWordsById(RGBA color, HashSet<String> wordids) {
208 202
		for (EditionPanel panel : editionPanels.values()) {
209 203
			panel.setHighlightWordsById(color, wordids);
210 204
		}
211 205
	}
212

  
206
	
213 207
	public void addHighlightWordsById(RGBA color, String wordid) {
214 208
		for (EditionPanel panel : editionPanels.values()) {
215 209
			panel.addHighlightWordsById(color, wordid);
216 210
		}
217 211
	}
218

  
212
	
219 213
	public void addHighlightWordsById(RGBA color, Collection<String> wordids) {
220 214
		for (EditionPanel panel : editionPanels.values()) {
221 215
			panel.addHighlightWordsById(color, wordids);
222 216
		}
223 217
	}
224

  
218
	
225 219
	public void removeHighlightWordsById(RGBA color, Collection<String> wordids) {
226 220
		for (EditionPanel panel : editionPanels.values()) {
227 221
			if (!panel.isDisposed()) {
......
229 223
			}
230 224
		}
231 225
	}
232

  
226
	
233 227
	public void removeHighlightWordsById(RGBA color, String wordid) {
234 228
		for (EditionPanel panel : editionPanels.values()) {
235 229
			if (!panel.isDisposed()) {
......
237 231
			}
238 232
		}
239 233
	}
240

  
234
	
241 235
	// /**
242 236
	// *
243 237
	// * @param wordids2 all the words to highlight
......
259 253
	//
260 254
	//
261 255
	// }
262

  
256
	
263 257
	/**
264 258
	 * First page.
265 259
	 */
......
269 263
		}
270 264
		updatePageLabel();
271 265
	}
272

  
266
	
273 267
	/**
274 268
	 * Last page.
275 269
	 */
......
278 272
			panel.lastPage();
279 273
		updatePageLabel();
280 274
	}
281

  
275
	
282 276
	/**
283 277
	 * Previous page.
284 278
	 */
......
287 281
			panel.previousPage();
288 282
		updatePageLabel();
289 283
	}
290

  
284
	
291 285
	/**
292 286
	 * Next page.
293 287
	 */
......
296 290
			panel.nextPage();
297 291
		updatePageLabel();
298 292
	}
299

  
293
	
300 294
	/**
301 295
	 * Direct access to a page with a name.
302 296
	 */
......
305 299
			panel.goToPage(name);
306 300
		}
307 301
		updatePageLabel();
308

  
302
		
309 303
	}
310

  
304
	
311 305
	/**
312 306
	 * Direct access to a text with a name.
313 307
	 */
......
327 321
		catch (Exception e) {
328 322
			e.printStackTrace();
329 323
		}
330

  
324
		
331 325
		Log.info(NLS.bind("No {0} text found.", id));
332 326
	}
333

  
327
	
334 328
	/**
335 329
	 * Previous text.
336 330
	 */
......
340 334
		}
341 335
		updatePageLabel();
342 336
	}
343

  
337
	
344 338
	/**
345 339
	 * Next text.
346 340
	 */
......
350 344
		}
351 345
		updatePageLabel();
352 346
	}
353

  
347
	
354 348
	/**
355 349
	 * Previous text.
356 350
	 */
......
360 354
		}
361 355
		updatePageLabel();
362 356
	}
363

  
357
	
364 358
	/**
365 359
	 * Next text.
366 360
	 */
......
370 364
		}
371 365
		updatePageLabel();
372 366
	}
373

  
367
	
374 368
	public Composite getEditionArea() {
375 369
		return editionsArea;
376 370
	}
377

  
371
	
378 372
	// public Composite getUpperToolbarArea() {
379 373
	// return annotationWidgetsArea;
380 374
	// }
381

  
375
	
382 376
	public Composite getLowerToolbarArea() {
383 377
		return controlsArea;
384 378
	}
385

  
379
	
386 380
	@Override
387 381
	public void _createPartControl() {
388

  
382
		
389 383
		// remove the compute button
390 384
		this.removeComputeButton();
391

  
385
		
392 386
		editionsArea = getResultArea();
393

  
387
		
394 388
		controlsArea = getBottomToolbar().installGLComposite(EditionUIMessages.controls, 15, false);
395 389
		controlsArea.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
396 390
		// spacer
397 391
		new Label(controlsArea, SWT.NONE).setText("  "); //$NON-NLS-1$
398

  
392
		
399 393
		// annotationWidgetsArea = new GLComposite(getBetweenTopToolbarsAndResultComposite(), SWT.NONE, "Edition annotation area");
400 394
		// this.annotationWidgetsArea.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
401

  
395
		
402 396
		// supplementaryButtonToolbar = new TXMEditorToolBar(this, getTopToolbarContainer(), annotationWidgetsArea, SWT.NONE, "annotation urs");
403

  
397
		
404 398
		// Edition names label
405 399
		editionsChooser = new Button(controlsArea, SWT.PUSH);
406 400
		editionsChooser.setText(StringUtils.join(editionNames, " | ")); //$NON-NLS-1$
407

  
401
		
408 402
		if (mainCorpus.getProject().getBuiltEditionNames().size() > 1) {
409

  
403
			
410 404
			editionsChooser.addSelectionListener(new SelectionListener() {
411

  
405
				
412 406
				@Override
413 407
				public void widgetSelected(SelectionEvent e) {
414 408
					try {
415 409
						List<String> availableEditions = mainCorpus.getProject().getBuiltEditionNames();
416 410
						if (availableEditions.size() == 0) return;
417 411
						if (availableEditions.size() == 1) return;
418

  
419

  
412
						
413
						
420 414
						Shell shell = e.display.getActiveShell();
421 415
						EditionSelectorDialog d = new EditionSelectorDialog(shell, mainCorpus, editionNames);
422

  
416
						
423 417
						if (d.open() == Window.OK) {
424 418
							Object[] rez = d.getResult();
425 419
							editionNames = new ArrayList<>();
426 420
							for (int i = 0; i < rez.length; i++) {
427 421
								editionNames.add(rez[i].toString());
428 422
							}
429

  
423
							
430 424
							editionsChooser.setText(StringUtils.join(editionNames, " | ")); //$NON-NLS-1$
431 425
							openEditions(text, editionNames);
432 426
							firstPage();
......
437 431
						System.out.println(NLS.bind(EditionUIMessages.errorWhileGettingAvailableEditionsColonP0, e2));
438 432
					}
439 433
				}
440

  
434
				
441 435
				@Override
442 436
				public void widgetDefaultSelected(SelectionEvent e) {}
443 437
			});
......
445 439
		else {
446 440
			editionsChooser.setEnabled(false);
447 441
		}
448

  
442
		
449 443
		// Navigation buttons
450 444
		GLComposite pageNavigationComposite = new GLComposite(controlsArea, SWT.NONE, EditionUIMessages.pageButtons);
451 445
		pageNavigationComposite.getLayout().numColumns = 6;
......
457 451
		Button next = new Button(pageNavigationComposite, SWT.FLAT | SWT.PUSH);
458 452
		Button last = new Button(pageNavigationComposite, SWT.FLAT | SWT.PUSH);
459 453
		pageNavigationComposite.setLayoutData(new GridData(GridData.CENTER, GridData.FILL, true, false));
460

  
454
		
461 455
		GLComposite textNavigationComposite = new GLComposite(controlsArea, SWT.NONE, EditionUIMessages.textButtons);
462 456
		textNavigationComposite.getLayout().numColumns = 7;
463 457
		textNavigationComposite.getLayout().horizontalSpacing = 1;
......
497 491
		Button lastText = new Button(textNavigationComposite, SWT.FLAT | SWT.PUSH);
498 492
		textNavigationComposite.setLayoutData(new GridData(GridData.CENTER, GridData.FILL, false, false));
499 493
		// Layouts data
500

  
494
		
501 495
		editionsChooser.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false));
502

  
496
		
503 497
		// GridData buttonGridData = new GridData(GridData.END,GridData.CENTER, true, false);
504 498
		// buttonGridData.widthHint = 30;
505 499
		// buttonGridData.heightHint = 30;
......
513 507
		// centerButtonGridData.heightHint = 30;
514 508
		// first.setLayoutData(centerButtonGridData);
515 509
		// previous.setLayoutData(buttonGridData);
516

  
510
		
517 511
		// set sizes
518 512
		GridData gdata = new GridData(GridData.END, GridData.CENTER, false, false);
519 513
		gdata.minimumWidth = 25;
520 514
		gdata.widthHint = 25;
521

  
515
		
522 516
		page_text.setLayoutData(gdata);
523 517
		// page_label.setLayoutData(new GridData(GridData.BEGINNING,GridData.CENTER, false, false));
524 518
		//
......
529 523
		// last.setLayoutData(centerButtonGridData);
530 524
		// nextText.setLayoutData(buttonGridData);
531 525
		// lastText.setLayoutData(buttonGridData);
532

  
526
		
533 527
		// if (editionsChooser != null)
534 528
		// editionsChooser.setLayoutData(new GridData(GridData.BEGINNING,GridData.CENTER, false, true));
535 529
		// else spacer.setLayoutData(new GridData(GridData.END,GridData.CENTER, true, true));
536

  
530
		
537 531
		// set labels
538 532
		page_label.setText(""); //$NON-NLS-1$
539 533
		// text_label.setText(""); //$NON-NLS-1$
......
553 547
		nextText.setToolTipText(EditionUIMessages.nextText);
554 548
		lastText.setImage(IImageKeys.getImage(IImageKeys.CTRLFASTFORWARDEND));
555 549
		lastText.setToolTipText(EditionUIMessages.lastTextOfTheCorpus);
556

  
550
		
557 551
		page_text.addKeyListener(new KeyListener() {
558

  
552
			
559 553
			@Override
560 554
			public void keyReleased(KeyEvent e) {
561 555
				if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) {
562 556
					goToPage(page_text.getText());
563 557
				}
564 558
			}
565

  
559
			
566 560
			@Override
567 561
			public void keyPressed(KeyEvent e) {}
568 562
		});
569 563
		text_text.addKeyListener(new KeyListener() {
570

  
564
			
571 565
			@Override
572 566
			public void keyReleased(KeyEvent e) {
573 567
				if (identifiantComboAutoCompleteField.isOpen()) return;
574

  
568
				
575 569
				if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) {
576 570
					if (identifiantComboAutoCompleteField.isOpen()) {
577 571
						return; // ignore keys when content assist is opened
578 572
					}
579

  
573
					
580 574
					goToText(text_text.getText());
581 575
				}
582 576
				else if (e.keyCode == SWT.ARROW_DOWN) {
......
586 580
					previousText(false);
587 581
				}
588 582
			}
589

  
583
			
590 584
			@Override
591 585
			public void keyPressed(KeyEvent e) {}
592 586
		});
593 587
		text_text.addMouseWheelListener(new MouseWheelListener() {
594

  
588
			
595 589
			@Override
596 590
			public void mouseScrolled(MouseEvent e) {
597 591
				if (identifiantComboAutoCompleteField.isOpen()) {
598 592
					return;
599 593
				}
600

  
594
				
601 595
				if (e.count > 0) {
602 596
					previousText(false);
603 597
				}
......
609 603
		});
610 604
		// set listeners
611 605
		first.addSelectionListener(new SelectionListener() {
612

  
606
			
613 607
			@Override
614 608
			public void widgetDefaultSelected(SelectionEvent e) {
615 609
				firstPage();
616 610
			}
617

  
611
			
618 612
			@Override
619 613
			public void widgetSelected(SelectionEvent e) {
620 614
				firstPage();
621 615
			}
622 616
		});
623 617
		previous.addSelectionListener(new SelectionListener() {
624

  
618
			
625 619
			@Override
626 620
			public void widgetDefaultSelected(SelectionEvent e) {
627 621
				previousPage();
628 622
			}
629

  
623
			
630 624
			@Override
631 625
			public void widgetSelected(SelectionEvent e) {
632 626
				previousPage();
633 627
			}
634 628
		});
635 629
		next.addSelectionListener(new SelectionListener() {
636

  
630
			
637 631
			@Override
638 632
			public void widgetDefaultSelected(SelectionEvent e) {
639 633
				nextPage();
640 634
			}
641

  
635
			
642 636
			@Override
643 637
			public void widgetSelected(SelectionEvent e) {
644 638
				nextPage();
645 639
			}
646 640
		});
647 641
		last.addSelectionListener(new SelectionListener() {
648

  
642
			
649 643
			@Override
650 644
			public void widgetDefaultSelected(SelectionEvent e) {
651 645
				lastPage();
652 646
			}
653

  
647
			
654 648
			@Override
655 649
			public void widgetSelected(SelectionEvent e) {
656 650
				lastPage();
657 651
			}
658 652
		});
659 653
		nextText.addSelectionListener(new SelectionListener() {
660

  
654
			
661 655
			@Override
662 656
			public void widgetDefaultSelected(SelectionEvent e) {
663 657
				nextText();
664 658
			}
665

  
659
			
666 660
			@Override
667 661
			public void widgetSelected(SelectionEvent e) {
668 662
				nextText();
......
670 664
		});
671 665
		// set listeners
672 666
		previousText.addSelectionListener(new SelectionListener() {
673

  
667
			
674 668
			@Override
675 669
			public void widgetDefaultSelected(SelectionEvent e) {
676 670
				previousText(false);
677 671
			}
678

  
672
			
679 673
			@Override
680 674
			public void widgetSelected(SelectionEvent e) {
681 675
				previousText(false);
682 676
			}
683 677
		});
684 678
		lastText.addSelectionListener(new SelectionListener() {
685

  
679
			
686 680
			@Override
687 681
			public void widgetDefaultSelected(SelectionEvent e) {
688 682
				lastText();
689 683
			}
690

  
684
			
691 685
			@Override
692 686
			public void widgetSelected(SelectionEvent e) {
693 687
				lastText();
......
695 689
		});
696 690
		// set listeners
697 691
		firstText.addSelectionListener(new SelectionListener() {
698

  
692
			
699 693
			@Override
700 694
			public void widgetDefaultSelected(SelectionEvent e) {
701 695
				firstText();
702 696
			}
703

  
697
			
704 698
			@Override
705 699
			public void widgetSelected(SelectionEvent e) {
706 700
				firstText();
707 701
			}
708 702
		});
709

  
703
		
710 704
		try {
711 705
			// ensure all texts have build their page indexes
712 706
			for (Text t : mainCorpus.getProject().getTexts()) {
......
720 714
			e1.printStackTrace();
721 715
		}
722 716
	}
723

  
717
	
724 718
	// /**
725 719
	// * Opens the default corpus edition with the first Text
726 720
	// *
......
730 724
	// if (corpus == null) return false;
731 725
	// return openEditions(corpus, corpus.getProject().getFirstText(), corpus.getProject().getDefaultEdition());
732 726
	// }
733

  
727
	
734 728
	/**
735 729
	 * update editor title using the first panel only
736 730
	 */
......
745 739
				continue;
746 740
			}
747 741
			this.setPartName(e.getText().getName() + " - " + cpage.getName()); //$NON-NLS-1$
748

  
742
			
749 743
			if (page_text.isDisposed()) {
750 744
				continue;
751 745
			}
752 746
			page_text.setText(cpage.getName());
753 747
			page_label.setText(" / " + e.getNumPages()); //$NON-NLS-1$
754

  
748
			
755 749
			text_text.setText(p.getCurrentText().getName());
756 750
			// try {
757 751
			// text_label.setText(" / "+corpus.getCorpusTextIdsList().length);
......
759 753
			// // TODO Auto-generated catch block
760 754
			// e1.printStackTrace();
761 755
			// }
762

  
756
			
763 757
			controlsArea.layout();
764 758
			return;
765 759
		}
766 760
	}
767

  
761
	
768 762
	// public boolean openEditions(CQPCorpus corpus, String textID, String... editionNames) {
769 763
	// Text text = corpus.getProject().getText(textID);
770 764
	// if (text == null) return false;
771 765
	// return openEditions(corpus, text, editionNames);
772 766
	// }
773

  
767
	
774 768
	// /**
775 769
	// * Opens a list of edition corpus
776 770
	// * @param corpus
......
779 773
	// public boolean openEditions(CQPCorpus corpus, Text text, String... editionNames) {
780 774
	// return openEditions(corpus, text, Arrays.asList(editionNames));
781 775
	// }
782

  
776
	
783 777
	/**
784 778
	 * Opens a list of edition corpus
785 779
	 * 
......
787 781
	 * @param editionNames
788 782
	 */
789 783
	public boolean openEditions(Text text, List<String> editionNames) {
790

  
784
		
791 785
		try {
792 786
			text.compute();
793 787
		}
......
800 794
			panel.dispose();
801 795
		}
802 796
		editionPanels = new LinkedHashMap<>();
803

  
797
		
804 798
		editionsArea.getLayout().numColumns = editionNames.size();
805

  
799
		
806 800
		for (int i = 0; i < editionNames.size(); i++) {
807 801
			String editionName = editionNames.get(i);
808 802
			// System.out.println("EDITION NAME: "+editionName);
......
812 806
				try {
813 807
					EditionPanel panel = new EditionPanel(this, container, SWT.BORDER, edition);
814 808
					panel.initSelectionProvider();
815

  
809
					
816 810
					if (i == 0) { // TODO: how to manage multiple menumanager -> the text selection does not work only the first panel selection is used
817 811
						panel.initMenu();
818 812
						getSite().registerContextMenu(panel.getMenuManager(), panel.getSelectionProvider());
819 813
					}
820

  
814
					
821 815
					editionPanels.put(editionName, panel);
822
				} catch (SWTError e) {
823
					Log.severe("TXM could not open the internal browser: "+e);
816
				}
817
				catch (SWTError e) {
818
					Log.severe("TXM could not open the internal browser: " + e);
824 819
					Log.printStackTrace(e);
825 820
				}
826 821
			}
......
831 826
		editionsArea.layout();
832 827
		return true;
833 828
	}
834

  
829
	
835 830
	// /**
836 831
	// *
837 832
	// * //TODO: add getDefaultEditions to Corpus object
......
847 842
	// return new String[]{defaultEdition};
848 843
	// }
849 844
	// }
850

  
845
	
851 846
	@Override
852 847
	public void doSaveAs() {
853 848
		return;
854 849
	}
855

  
850
	
856 851
	@Override
857 852
	public void init(IEditorSite site, IEditorInput input) throws PartInitException {
858

  
853
		
859 854
		corpus = ((SynopticEditorInput) input).getCorpus(); // corpus focused when opening the editions
860 855
		try {
861 856
			corpus.compute(false);
......
867 862
		mainCorpus = corpus.getMainCorpus(); // get the main corpus of the corpus
868 863
		text = ((SynopticEditorInput) input).getText();
869 864
		editionNames = ((SynopticEditorInput) input).getEditions();
870

  
865
		
871 866
		super.init(site, input);
872 867
	}
873

  
868
	
874 869
	public boolean isDisposed() {
875 870
		return editionsArea.isDisposed();
876 871
	}
877

  
872
	
878 873
	@Override
879 874
	public boolean isSaveAsAllowed() {
880 875
		return false;
881 876
	}
882

  
877
	
883 878
	@Override
884 879
	public void _setFocus() {
885 880
		this.getEditionPanel(0).setFocus();
886 881
	}
887

  
882
	
888 883
	public void backToText(Text text, String line_wordid) {
889 884
		try {
890 885
			text.compute();
......
899 894
			e.printStackTrace();
900 895
		}
901 896
	}
902

  
897
	
903 898
	public void reloadPage() {
904 899
		for (EditionPanel p : editionPanels.values()) {
905 900
			p.reloadPage();
906 901
		}
907 902
	}
908

  
903
	
909 904
	@Override
910 905
	public String getTextSelection() {
911 906
		String sel = null;
......
917 912
		}
918 913
		return EditionUIMessages.CommandLink_empty;
919 914
	}
920

  
915
	
921 916
	@Override
922 917
	public CQPCorpus getCorpus() {
923 918
		return corpus;
924 919
	}
925

  
920
	
926 921
	public CQPCorpus getMainCorpus() {
927 922
		return mainCorpus;
928 923
	}
929

  
924
	
930 925
	public EditionPanel getEditionPanel(int i) {
931 926
		int n = 0;
932 927
		for (EditionPanel p : editionPanels.values()) {
......
936 931
		}
937 932
		return null;
938 933
	}
939

  
934
	
940 935
	/**
941 936
	 * 
942 937
	 * @return the first and last word ID covered by the text selection of the first EditionPanel
......
947 942
		}
948 943
		return null;
949 944
	}
950

  
945
	
951 946
	/**
952 947
	 * 
953 948
	 * @param text2 the Text to set
......
959 954
		}
960 955
		updatePageLabel();
961 956
	}
962

  
957
	
963 958
	public void setFocusedWordID(String focusid) {
964 959
		for (EditionPanel p : editionPanels.values()) {
965 960
			p.setFocusedWordID(focusid);
966 961
		}
967 962
		updatePageLabel();
968 963
	}
969

  
964
	
970 965
	/**
971 966
	 * TODO finish implementation in EditionPanel
972 967
	 * 
......
977 972
			p.setHighlightedArea(positions);
978 973
		}
979 974
	}
980

  
975
	
981 976
	public void updateWordStyles() {
982 977
		for (EditionPanel p : editionPanels.values()) {
983 978
			p.updateWordStyles();
984 979
		}
985 980
	}
986

  
981
	
987 982
	public void addFontWeightWordsById(String weight, List<String> previousSelectedUnitIDS) {
988 983
		for (EditionPanel p : editionPanels.values()) {
989 984
			p.addFontWeightWordsById(weight, previousSelectedUnitIDS);
990 985
		}
991 986
	}
992

  
987
	
993 988
	public void removeFontWeightWordsById(List<String> previousSelectedUnitIDS) {
994 989
		for (EditionPanel p : editionPanels.values()) {
995 990
			p.removeFontWeightWordsById(previousSelectedUnitIDS);
996 991
		}
997 992
	}
998

  
993
	
999 994
	public void fireIsDirty() {
1000 995
		this.firePropertyChange(IEditorPart.PROP_DIRTY);
1001 996
	}
1002

  
997
	
1003 998
	/**
1004 999
	 * Clears all highlighted words.
1005 1000
	 */
......
1008 1003
			p.removeHighlightWords();
1009 1004
		}
1010 1005
	}
1011

  
1006
	
1012 1007
	@Override
1013 1008
	public void updateResultFromEditor() {
1014 1009
		// TODO Auto-generated method stub
1015 1010
	}
1016

  
1011
	
1017 1012
	@Override
1018 1013
	public void updateEditorFromResult(boolean update) throws Exception {
1019 1014
		this.firstPage();
1020 1015
	}
1021

  
1016
	
1022 1017
	/**
1023 1018
	 * Browser command that opens an edition
1024 1019
	 * 
......
1029 1024
		IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
1030 1025
		ICommandService cmdService = window.getService(ICommandService.class);
1031 1026
		Command cmd = cmdService.getCommand(id);
1032

  
1027
		
1033 1028
		// get the parameter
1034 1029
		ArrayList<Parameterization> parameters = new ArrayList<>();
1035 1030
		ArrayList<String> failedParameters = new ArrayList<>();
......
1040 1035
				parameters.add(p);
1041 1036
			}
1042 1037
			catch (NotDefinedException e) {
1043
				//Log.warning(NLS.bind(EditionUIMessages.warningColonUnknownedParameterIdEqualsP0, k));
1038
				// Log.warning(NLS.bind(EditionUIMessages.warningColonUnknownedParameterIdEqualsP0, k));
1044 1039
				failedParameters.add(k);
1045 1040
			}
1046 1041
		}
1047

  
1042
		
1048 1043
		// build the parameterized command
1049 1044
		ParameterizedCommand pc = new ParameterizedCommand(cmd, parameters.toArray(new Parameterization[parameters.size()]));
1050

  
1045
		
1051 1046
		// execute the command
1052 1047
		IHandlerService handlerService = window.getService(IHandlerService.class);
1053 1048
		try {
......
1059 1054
		}
1060 1055
		return null;
1061 1056
	}
1062

  
1057
	
1063 1058
	/**
1064 1059
	 * 
1065 1060
	 * @param editor may be null, will be used by the command to display its result
......
1076 1071
		for (int i = 0; i + 1 < arguments.length; i += 2) {
1077 1072
			params.put(arguments[i].toString(), arguments[i + 1].toString());
1078 1073
		}
1079

  
1074
		
1080 1075
		String id = params.get("id"); //$NON-NLS-1$
1081 1076
		if (id != null) {
1082 1077
			params.remove("id"); //$NON-NLS-1$

Formats disponibles : Unified diff