Révision 2009

tmp/org.txm.core/src/java/org/txm/objects/Workspace.java (revision 2009)
36 36
import org.eclipse.core.resources.IWorkspaceRoot;
37 37
import org.eclipse.core.resources.ResourcesPlugin;
38 38
import org.eclipse.core.runtime.CoreException;
39
import org.eclipse.core.runtime.IPath;
39 40
import org.eclipse.core.runtime.Path;
40 41
import org.eclipse.osgi.util.NLS;
41 42
import org.txm.Toolbox;
......
309 310
			//FIXME: SJ: old version where there is a bug if the name or path are not in same case
310 311
			//Project project = new Project(this, parameters.name, false);
311 312
			//FIXME: SJ: new version that fix the bug but whe may want to not modify the case of the name? 
312
			Project project = new Project(this, parameters.name.toUpperCase(), false);
313
			Project project = new Project(this, binCorpusDir.getName(), false);
314
//			if (!parameters.name.equals(project.getRCPProject().getName())) {
315
//				IPath destination = new Path(project.getRCPProject().getParent().getLocation(), parameters.name);
316
//				project.getRCPProject().move(destination, true, project);
317
//			}
313 318

  
314 319
			project._load(parameters);
315 320

  
tmp/org.txm.core/src/java/org/txm/objects/EditionDefinition.java (revision 2009)
13 13
public class EditionDefinition {
14 14

  
15 15
	Preferences node;
16
	
17 16
	public EditionDefinition(Project project, String name) {
18 17
		this.node = project.getPreferencesScope().getNode(EditionDefinition.class.getSimpleName()).node(name);
19 18
		setName(name); //TODO use node.name() instead
20 19
		
21 20
	}
21
	
22
	public void delete() {
23
		try {
24
			node.removeNode();
25
		} catch (BackingStoreException e) {
26
			e.printStackTrace();
27
		}
28
	}
22 29

  
23 30
	public String getName() {
24 31
		return node.get(TBXPreferences.NAME, null);
tmp/org.txm.core/src/java/org/txm/objects/Project.java (revision 2009)
1144 1144
		return new EditionDefinition(this, name);
1145 1145
	}
1146 1146
	
1147
	public ArrayList<EditionDefinition> getEditionDefinitions() {
1148
		ArrayList<EditionDefinition> editions = new ArrayList<EditionDefinition>();
1149
		IEclipsePreferences editionNode = this.getPreferencesScope().getNode(EditionDefinition.class.getSimpleName());
1150
		try {
1151
			for (String editionName : editionNode.childrenNames()) {
1152
				if (this.hasEditionDefinition(editionName)) {
1153
					editions.add(getEditionDefinition(editionName));
1154
				}
1155
			}
1156
		} catch (BackingStoreException e) {
1157
			// TODO Auto-generated catch block
1158
			e.printStackTrace();
1159
		}
1160
		return editions;
1161
	}
1162
	
1147 1163
	public CorpusCommandPreferences getCommandPreferences(String name) {
1148 1164
		return new CorpusCommandPreferences(this, name);
1149 1165
	}
tmp/org.txm.groovy.core/src/java/org/txm/groovy/core/GSERunner.java (revision 2009)
148 148
//			}
149 149
//		});
150 150
		HashSet<String> defaultPlugins = new HashSet<String>();
151
		getDependancies("org.txm.rcp", defaultPlugins);
151
		//getDependancies("org.txm.rcp", defaultPlugins);
152 152
		
153 153
		for (Bundle b : bundles) {
154 154
			if (b == null) continue;
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xtz/XTZPager.groovy (revision 2009)
53 53

  
54 54
		if (!doDefaultEditionStep()) return;
55 55
		if (!doFacsEditionStep()) return;
56
		
57
		// remove extra XSL editions -> they will be recreated by the doPostEditionXSLStep call 
58
		for (EditionDefinition eDef : project.getEditionDefinitions()) {
59
			if (eDef.getName() != "facs" || eDef.getName() != "default") {
60
				eDef.delete();
61
			}
62
		}
56 63
		if (!doPostEditionXSLStep()) return;
57 64

  
58 65
		isSuccessFul = true;
......
115 122
				}
116 123
				edition.setName("default");
117 124
				edition.setIndex(outputDirectory.getAbsolutePath());
118

  
125
				
119 126
				for (i = 0 ; i < ed.getPageFiles().size();) {
120 127
					File f = ed.getPageFiles().get(i);
121 128
					String wordid = "w_0";
122
				if (i < ed.getIdx().size()) wordid = ed.getIdx().get(i);
129
					if (i < ed.getIdx().size()) wordid = ed.getIdx().get(i);
123 130
					edition.addPage(""+(++i), wordid);
124 131
				}
125 132
			} catch(Exception e) {
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xtz/XTZDefaultPagerStep.groovy (revision 2009)
300 300
				return false;
301 301
			}
302 302

  
303
			println "DEBUG: start parsing"
303 304
			for (int event = parser.next(); event != XMLStreamConstants.END_DOCUMENT; event = parser.next()) {
304 305
				rend = "";
305 306
				switch (event) {
tmp/org.txm.rcp/src/main/java/org/txm/rcp/commands/workspace/LoadBinaryCorpus.java (revision 2009)
31 31
import java.net.MalformedURLException;
32 32
import java.net.URL;
33 33

  
34
import org.apache.commons.io.FileUtils;
34 35
import org.eclipse.core.commands.AbstractHandler;
35 36
import org.eclipse.core.commands.ExecutionEvent;
36 37
import org.eclipse.core.commands.ExecutionException;
......
58 59
import org.txm.searchengine.core.SearchEnginesManager;
59 60
import org.txm.searchengine.cqp.corpus.MainCorpus;
60 61
import org.txm.utils.DeleteDir;
62
import org.txm.utils.Download;
61 63
import org.txm.utils.io.FileCopy;
62 64
import org.txm.utils.logger.Log;
63 65
import org.txm.utils.zip.Zip;
......
94 96
					URL u = new URL(url);
95 97
					File f = new File(url);
96 98
					File corpora = Toolbox.workspace.getLocation();
97
					if (DownloadFile.download(u, corpora)) {
98
						zipFile = new File(corpora, f.getName());
99
					} else {
100
						System.out.println("** Error: could not download corpus at "+url);
101
					}
102
				} catch (MalformedURLException e) {
99
					zipFile = new File(corpora, f.getName());
100
					System.out.println("BEF ? "+zipFile.exists());
101
					zipFile.delete();
102
					System.out.println("DEL ? "+zipFile.exists());
103
					FileUtils.copyURLToFile(u, zipFile);
104
					System.out.println(zipFile.getAbsolutePath());
105
					System.out.println("OK ? "+zipFile.exists());
106
				} catch (Exception e) {
103 107
					// TODO Auto-generated catch block
104 108
					e.printStackTrace();
109
					return null;
105 110
				}
106 111
			}
107 112
		} else {
tmp/org.txm.rcp/src/main/java/org/txm/rcp/commands/workspace/DownloadCorpus.java (revision 2009)
1
package org.txm.rcp.commands.workspace;
2

  
3
import java.io.File;
4
import java.io.IOException;
5
import java.net.MalformedURLException;
6
import java.net.URL;
7

  
8
import org.eclipse.core.commands.AbstractHandler;
9
import org.eclipse.core.commands.ExecutionEvent;
10
import org.eclipse.core.commands.ExecutionException;
11
import org.txm.Toolbox;
12
import org.txm.objects.Project;
13
import org.txm.rcp.utils.JobHandler;
14
import org.txm.utils.Download;
15

  
16
public class DownloadCorpus extends AbstractHandler {
17

  
18
	@Override
19
	public Object execute(ExecutionEvent event) throws ExecutionException {
20
		String key = event
21
				.getParameter("org.txm.rcp.commands.commandParameter3"); //$NON-NLS-1$
22
		if (key != null && key.trim().length() > 0) {
23
			try {
24
				return downloadAndLoad(key);
25
			} catch (Exception e) {
26
				// TODO Auto-generated catch block
27
				e.printStackTrace();
28
			}
29
		}
30
		return null;
31
	}
32

  
33
	public static Project downloadAndLoad(String urlString) throws InterruptedException, ExecutionException, IOException {
34
		URL url = new URL(urlString);
35
		File binFile = new File(Toolbox.getTxmHomePath(), "results/"+new File(url.getFile()).getName());
36
		if (!binFile.getName().endsWith(".txm")) {
37
			System.out.println("The downloaded file is not a TXM corpus.");
38
			return null;
39
		}
40
		Download.download(url, binFile);
41
		JobHandler job = LoadBinaryCorpus.loadBinaryCorpusArchive(binFile);
42
		job.join();
43
		Object r = job.getResultObject();
44
		if (r != null && r instanceof Project) {
45
			return (Project)r;
46
		}
47
		
48
		return null;
49
	}
50
}
0 51

  
tmp/org.txm.rcp/src/main/java/org/txm/rcp/corpuswizard/ImportWizard.java (revision 2009)
65 65
						project = p;
66 66
					}
67 67
				}
68
				boolean newProject = project == null;
68
				boolean newProject = (project == null);
69 69
				if (newProject) { // it's a new project configuration
70 70
					project = Toolbox.workspace.getProject(name);
71 71
					if (project == null) {
......
103 103
					Log.info(NLS.bind(TXMUIMessages.theP1P0CorpusWillBeReplaced, project, date));
104 104
				}
105 105
				
106
				if (!project.hasEditionDefinition("default")) {
107
					EditionDefinition def = project.getEditionDefinition("default");
108
					def.setBuildEdition(true);
109
					def.setWordsPerPage(500);
110
					def.setPageBreakTag("pb");
111
				}
106
//				if (!project.hasEditionDefinition("default")) {
107
//					EditionDefinition def = project.getEditionDefinition("default");
108
//					def.setBuildEdition(true);
109
//					def.setWordsPerPage(500);
110
//					def.setPageBreakTag("pb");
111
//				}
112 112
				
113 113
				project.setDoUpdate(false);
114 114
				project.saveParameters();
tmp/org.txm.rcp/src/main/java/org/txm/rcp/handlers/results/ComputeTXMResult.java (revision 2009)
3 3
import org.eclipse.core.commands.AbstractHandler;
4 4
import org.eclipse.core.commands.ExecutionEvent;
5 5
import org.eclipse.core.commands.ExecutionException;
6
import org.eclipse.ui.IEditorPart;
6 7
import org.eclipse.ui.IWorkbenchPart;
7 8
import org.eclipse.ui.handlers.HandlerUtil;
8 9
import org.txm.rcp.editors.TXMEditor;
......
20 21
	@Override
21 22
	public Object execute(ExecutionEvent event) throws ExecutionException {
22 23
		IWorkbenchPart part = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getActivePart();
23
		
24
		IEditorPart activeEditor = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getActiveEditor();
25
		System.out.println("A part="+part);
26
		System.out.println("A editor="+activeEditor);
24 27
		// gets the main editor if the active editor is a multipages editor
25 28
		if(part instanceof TXMMultiPageEditor)	{
26 29
			part = (IWorkbenchPart) ((TXMMultiPageEditor)part).getEditors().get(0);
tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/imports/sections/EditionSection.java (revision 2009)
37 37
	Button buildFacsEditionCheckButton;
38 38
	Text imageDirectoryText;
39 39

  
40
	private Text defaultEditions;
41

  
40 42
	/**
41 43
	 * 
42 44
	 * @param toolkit2
......
146 148
				});
147 149
			}
148 150
		}
151
		
152
		if (scriptName.startsWith("xtz")) {
153
			
154
			tmpLabel = toolkit.createLabel(sectionClient, "Default edition: ");
155
			tmpLabel.setLayoutData(getLabelGridData());
156
			
157
			defaultEditions = toolkit.createText(sectionClient, "", SWT.BORDER);
158
			TableWrapData gdata = getTextGridData();
159
			gdata.colspan = 2;
160
			defaultEditions.setLayoutData(gdata);
161
		}
149 162

  
150 163
		//// First draft of interface to add editions to a corpus
151 164
		//		Button addButton = toolkit.createButton(sectionClient, Messages.CorpusPage_1, SWT.PUSH);
......
217 230
		if (this.section.isDisposed()) return;
218 231
		if (project == null) return;
219 232

  
220
		EditionDefinition edition_params = project.getEditionDefinition("default");
221
		if (edition_params != null) {
233
		buildEditionCheckButton.setSelection(!project.hasEditionDefinition("default"));
234
		
235
		if (project.hasEditionDefinition("default")) {
236

  
237
			EditionDefinition edition_params = project.getEditionDefinition("default");
222 238
			boolean be = edition_params.getBuildEdition();
223 239
			buildEditionCheckButton.setSelection(be);
224 240

  
......
230 246
				pageBreakText.setText(pbt);	
231 247
		}
232 248

  
233
		edition_params = project.getEditionDefinition("facs");
249
		EditionDefinition edition_params = project.getEditionDefinition("facs");
234 250
		boolean bfe = edition_params.getBuildEdition();
235 251
		if (buildFacsEditionCheckButton != null && edition_params != null) {
236 252
			buildFacsEditionCheckButton.setSelection(bfe);
......
240 256
			if (imageDirectoryText != null && imageDirectory != null)
241 257
				imageDirectoryText.setText(imageDirectory);
242 258
		}
259
		
260
		String defaults = project.getDefaultEditionName();
261
		if (defaults != null && defaults.length() > 0 && defaultEditions != null) {
262
			defaultEditions.setText(defaults);
263
		}
243 264
	}
244 265

  
245 266
	@Override
......
275 296
				edition_params2.setBuildEdition(build);
276 297
				edition_params2.setImagesDirectory(images_directory);
277 298
			}
299
			
300
			if (defaultEditions != null) {
301
				String defaults = defaultEditions.getText();
302
				if (defaults != null && defaults.length() > 0) {
303
					project.setDefaultEditionName(defaults);
304
				}
305
			}
278 306
		}
279 307
		return true;
280 308
	}
tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMEditor.java (revision 2009)
61 61
import org.txm.core.preferences.TBXPreferences;
62 62
import org.txm.core.results.Parameter;
63 63
import org.txm.core.results.TXMResult;
64
import org.txm.rcp.IImageKeys;
64 65
import org.txm.rcp.JobsTimer;
65 66
import org.txm.rcp.StatusLine;
66 67
import org.txm.rcp.TXMWindows;
67 68
import org.txm.rcp.editors.listeners.BaseAbstractComputeListener;
69
import org.txm.rcp.editors.listeners.ComputeSelectionListener;
68 70
import org.txm.rcp.handlers.BaseAbstractHandler;
69 71
import org.txm.rcp.messages.TXMUIMessages;
70 72
import org.txm.rcp.preferences.RCPPreferences;
......
390 392
			this.topToolBar = new TXMEditorToolBar(this, this.firstLineComposite, this.extendedParametersComposite, SWT.FLAT | SWT.RIGHT, TOP_TOOLBAR_ID);
391 393

  
392 394
			// store the Compute button to access if later, especially from subclasses
393
			this.computeButton = this.topToolBar.getItemByContributionId(TOP_TOOLBAR_COMPUTE_BUTTON_ID);
394

  
395
			this.computeButton = new ToolItem(topToolBar, SWT.PUSH);//.topToolBar.getItemByContributionId(TOP_TOOLBAR_COMPUTE_BUTTON_ID);
396
			this.computeButton.setImage(IImageKeys.getImage(IImageKeys.START));
397
			this.computeButton.addSelectionListener(new ComputeSelectionListener(this, true));
398
			
395 399
			// computing parameters components
396 400
			boolean showExtendedParameters = false;
397 401
			// only show the area if the result can not compute and is dirty
......
422 426
				this.bottomSubWidgetsComposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
423 427
			}
424 428

  
425

  
426 429
			this.bottomToolBar = new TXMEditorToolBar(this, this.bottomToolBarContainer, this.bottomSubWidgetsComposite, SWT.FLAT, "bottom"); //$NON-NLS-1$
427 430

  
428

  
429 431
			this.notifyExtensions("notifyStartOfCreatePartControl"); //$NON-NLS-1$
430 432
			this._createPartControl(); // child editor creates its parameters and displays widgets
431 433
			this.notifyExtensions("notifyEndOfCreatePartControl"); //$NON-NLS-1$
tmp/org.txm.rcp/plugin.xml (revision 2009)
1209 1209
               </parameter>
1210 1210
            </command>
1211 1211
            <command
1212
                  commandId="org.txm.rcp.commands.workspace.LoadBinaryCorpus"
1213
                  label="VOEUX"
1214
                  style="push"
1215
                  tooltip="Download and load the VOEUX corpus">
1216
               <parameter
1217
                     name="url"
1218
                     value="http://textometrie.ens-lyon.fr/files/corpora/voeux/voeux-bin.txm">
1219
               </parameter>
1220
            </command>
1221
            <command
1212 1222
                  commandId="org.txm.rcp.commands.OpenLocalizedWebPage"
1213 1223
                  label="%command.label.70"
1214 1224
                  style="push">
......
2279 2289
      <menuContribution
2280 2290
            allPopups="true"
2281 2291
            locationURI="toolbar:TXMEditorTopToolBar">
2282
         <command
2283
               commandId="org.txm.rcp.handlers.ComputeTXMResult"
2284
               icon="icons/functions/run.png"
2285
               id="compute"
2286
               label="%command.label.36"
2287
               style="push">
2288
         </command>
2289 2292
      </menuContribution>
2290 2293
      <menuContribution
2291 2294
            allPopups="false"
tmp/org.txm.utils/src/org/txm/utils/io/IOUtils.java (revision 2009)
228 228
	 * @throws MalformedURLException
229 229
	 * @throws IOException
230 230
	 */
231
	public static InputStream getInput(File manifest) throws MalformedURLException, IOException {
232
		return manifest.toURI().toURL().openStream();
231
	public static InputStream getInput(File file) throws MalformedURLException, IOException {
232
		return file.toURI().toURL().openStream();
233 233
	}
234 234

  
235 235
	public static OutputStream getOutputStream(File file) throws FileNotFoundException {
tmp/org.txm.utils/src/org/txm/utils/Download.java (revision 2009)
1
package org.txm.utils;
2

  
3
import java.io.File;
4
import java.io.FileOutputStream;
5
import java.io.IOException;
6
import java.net.URL;
7
import java.nio.channels.Channels;
8
import java.nio.channels.ReadableByteChannel;
9

  
10
public class Download {
11
	public static long download(URL source, File output) throws IOException {
12
		ReadableByteChannel rbc = Channels.newChannel(source.openStream());
13
		FileOutputStream fos = new FileOutputStream(output);
14
		return fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
15
	}
16
}
0 17

  
tmp/TXMReleasePlugins.site/site.xml (revision 2009)
3 3
   <description name="TXM Extensions - RELEASE" url="http://txm.textometrie.org/updates/plugins">
4 4
      This update site contains the Release plugins for TXM
5 5
   </description>
6
   <feature url="features/org.txm.backtomedia.feature_1.0.0.1906.jar" id="org.txm.backtomedia.feature" version="1.0.0.1906">
6
   <feature url="features/org.txm.backtomedia.feature_1.0.0.1978.jar" id="org.txm.backtomedia.feature" version="1.0.0.1978">
7 7
      <category name="Commands"/>
8 8
   </feature>
9
   <feature url="features/org.txm.wordcloud.feature_1.0.0.1906.jar" id="org.txm.wordcloud.feature" version="1.0.0.1906">
9
   <feature url="features/org.txm.wordcloud.feature_1.0.0.1978.jar" id="org.txm.wordcloud.feature" version="1.0.0.1978">
10 10
      <category name="Commands"/>
11 11
   </feature>
12
   <feature url="features/org.txm.treetagger.binaries.feature_1.0.0.1906.jar" id="org.txm.treetagger.binaries.feature" version="1.0.0.1906" os="" ws="">
12
   <feature url="features/org.txm.treetagger.binaries.feature_1.0.0.1978.jar" id="org.txm.treetagger.binaries.feature" version="1.0.0.1978" os="" ws="">
13 13
      <category name="Annotation"/>
14 14
   </feature>
15
   <feature url="features/org.txm.treetagger.models.feature_1.0.0.1906.jar" id="org.txm.treetagger.models.feature" version="1.0.0.1906">
15
   <feature url="features/org.txm.treetagger.models.feature_1.0.0.1978.jar" id="org.txm.treetagger.models.feature" version="1.0.0.1978">
16 16
      <category name="Annotation"/>
17 17
   </feature>
18
   <feature url="features/org.txm.annotation.urs.feature_1.0.0.1906.jar" id="org.txm.annotation.urs.feature" version="1.0.0.1906">
18
   <feature url="features/org.txm.annotation.urs.feature_1.0.0.1978.jar" id="org.txm.annotation.urs.feature" version="1.0.0.1978">
19 19
      <category name="Annotation"/>
20 20
   </feature>
21
   <feature url="features/org.txm.tigersearch.feature_1.0.0.1906.jar" id="org.txm.tigersearch.feature" version="1.0.0.1906">
21
   <feature url="features/org.txm.tigersearch.feature_1.0.0.1978.jar" id="org.txm.tigersearch.feature" version="1.0.0.1978">
22 22
      <category name="Annotation"/>
23 23
   </feature>
24 24
   <category-def name="Commands" label="Commands">

Formats disponibles : Unified diff