Révision 3477

trunk/org.txm.texts.core/src/org/txm/texts/core/TextsSelection.java (revision 3477)
1
package org.txm.texts.core;
2

  
3
import org.txm.searchengine.cqp.corpus.CQPCorpus;
4
import org.txm.searchengine.cqp.corpus.Subcorpus;
5

  
6
public class TextsSelection extends Subcorpus {
7

  
8
	public TextsSelection(CQPCorpus corpus) {
9
		
10
		super(corpus);
11
	}
12
	
13
	/**
14
	 * 
15
	 * @param parametersNodePath
16
	 */
17
	public TextsSelection(String parametersNodePath) {
18
		super(parametersNodePath);
19
	}
20
	
21
	
22
}
0 23

  
TXM/trunk/org.txm.utils/src/org/txm/utils/DeleteDir.java (revision 3477)
55 55
		deleteDirectory(new File(args[0]));
56 56
	}
57 57

  
58
	static public boolean deleteDirectory(File path) {
59
		return deleteDirectory(path, false);
60
	}
61
	
58 62
	/**
59 63
	 * Delete directory.
60 64
	 *
61
	 * @param path
62
	 *            the path
65
	 * @param path the path to the directory to delete
66
	 * @param definitive definitivelly delete the directory or move it to trash FIXME NOT IMPLEMENTED YET
63 67
	 * @return true, if successful
64 68
	 */
65
	static public boolean deleteDirectory(File path) {
66
		if (path == null)
69
	static public boolean deleteDirectory(File path, boolean definitive) {
70
		if (path == null) {
67 71
			return false;
68
		if (!path.exists())
72
		}
73
		if (!path.exists()) {
69 74
			return false;
70

  
71
		try { // try using system for faster reply
72
				// prefer OS-dependent directory removal tool
75
		}
76
		try { // try using system for faster reply and prefer OS-dependent directory removal tool
73 77
			if (SystemUtils.IS_OS_WINDOWS) {
74 78
				Runtime.getRuntime().exec(new String[] { "%ComSpec%", "/C", "RD /S /Q \"" + path + '"' }).waitFor(); // FIXME: SJ: "%ComSpec%" is not defined, at least on my Win7
75 79
			} else if (SystemUtils.IS_OS_UNIX) {
76
				Runtime.getRuntime().exec(new String[] { "/bin/rm", "-rf", path.toString() }).waitFor();
80
				if (definitive) {
81
					Runtime.getRuntime().exec(new String[] { "/bin/rm", "-rf", path.toString() }).waitFor();
82
				} else {
83
					Runtime.getRuntime().exec(new String[] { "gio", "trash", path.toString() }).waitFor();
84
				}
77 85
			}
78 86
			
79 87
			if (!path.exists()) { // it worked
......
89 97
			if (files != null)
90 98
				for (int i = 0; i < files.length; i++) {
91 99
					if (files[i].isDirectory()) {
92
						deleteDirectory(files[i]);
100
						deleteDirectory(files[i], definitive);
93 101
					} else {
94 102
						files[i].delete();
95 103
					}
TXM/trunk/org.txm.searchengine.cqp.core/src/org/txm/importer/cwb/CompressCQPIndexes.java (revision 3477)
186 186
		try {
187 187
			String userdir = System.getProperty("user.home");
188 188
			File tools = new File(userdir, "SVN/txm-sf/CWB/cwb-lib/src/builds/linux-64"); //$NON-NLS-1$
189
			File registry = new File(userdir, "runtime-rcpapplication.product/corpora/NOV13-P1/registry/nov13-p1"); //$NON-NLS-1$
190
			File data = new File(userdir, "runtime-rcpapplication.product/corpora/NOV13-P1/data/NOV13-P1"); //$NON-NLS-1$
191
			CompressCQPIndexes.compressAll(tools, registry, "NOV13-P1", data, true);
189
			File registry = new File(userdir, "runtime-rcpapplication.product/corpora/NOV13-P1-2022-06-15-V1/registry/nov13-p1-2022-06-15-v1"); //$NON-NLS-1$
190
			File data = new File(userdir, "runtime-rcpapplication.product/corpora/NOV13-P1-2022-06-15-V1/data/NOV13-P1-2022-06-15-V1"); //$NON-NLS-1$
191
			CompressCQPIndexes.compressAll(tools, registry, "NOV13-P1-2022-06-15-V1", data, true);
192 192
			
193 193
		} catch (Exception e) {
194 194
			e.printStackTrace();
TXM/trunk/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/CQPEdition.java (revision 3477)
1
package org.txm.searchengine.cqp.corpus;
2

  
3
import org.txm.objects.Edition;
4
import org.txm.objects.Page;
5
import org.txm.objects.Text;
6
import org.txm.utils.TXMProgressMonitor;
7

  
8
/**
9
 * Build onthefly HTML pages from the CQP indexes (words + structures)
10
 * 
11
 * @author mdecorde
12
 *
13
 */
14
public class CQPEdition extends Edition {
15

  
16
	public CQPEdition(Text text) {
17
		
18
		super(text);
19
	}
20
	
21
	public CQPEdition(String id) {
22
		
23
		super(id);
24
	}
25
	
26
	@Override
27
	protected boolean _compute(TXMProgressMonitor monitor) throws Exception {
28
		// pPageNames.cl
29
		// pPageFirstWordIds
30
		return true;
31
	}
32
	
33
	/**
34
	 * Gets the page.
35
	 *
36
	 * @param no the no
37
	 * @return the page
38
	 */
39
	public Page getPage(int n) {
40
		
41
		if (n >= 0 && pPageNames.size() > n) {
42
			String wId = "w_0"; // default word id
43
			if (pPageFirstWordIds.size() > n) {
44
				wId = pPageFirstWordIds.get(n);
45
			}
46
			return new Page(this, pPageNames.get(n), wId, n);
47
		}
48
		else {
49
			return null;
50
		}
51
	}
52
}
0 53

  
TXM/trunk/org.txm.lexicaltable.core/src/org/txm/lexicaltable/core/functions/LexicalTable.java (revision 3477)
562 562
		else if (this.getPartition() != null) {
563 563
			return NLS.bind(LexicalTableCoreMessages.info_creatingLexicalTableWithTheP0PartitionCommaPropertiesP1, this.getPartition().getName(), this.property.asString());
564 564
		}
565
		else if (this.parent instanceof Subcorpus) {
566
			return NLS.bind(LexicalTableCoreMessages.info_creatingLexicalTableWithTheP0PartitionCommaPropertiesP1, this.getPartition().getName(), this.property.asString());
565
		else if (this.parent instanceof Subcorpus) { // from subcorpus
566
			return NLS.bind(LexicalTableCoreMessages.info_creatingLexicalTableWithTheP0CorpusAndTheP1Subcorpus, this.parent.getParent().getName(), this.parent.getName());
567 567
		}
568
		// from main corpus and subcorpus
568
		// from main corpus 
569 569
		else {
570 570
			return NLS.bind("Computing Lexical table on {0}", this.parent.getName());
571 571
		}
TXM/trunk/org.txm.rcp/plugin.xml (revision 3477)
1966 1966
            </visibleWhen>
1967 1967
         </command>
1968 1968
         <command
1969
               commandId="org.txm.rcp.commands.DeleteFile"
1970
               style="push"
1971
               tooltip="%command.tooltip.15">
1972
            <visibleWhen
1973
                  checkEnabled="false">
1974
               <reference
1975
                     definitionId="OneFileSelected">
1976
               </reference>
1977
            </visibleWhen>
1978
         </command>
1979
         <command
1980 1969
               commandId="org.txm.rcp.commands.CopyFile"
1981 1970
               style="push"
1982 1971
               tooltip="%command.tooltip.16">
TXM/trunk/org.txm.rcp/src/main/java/org/txm/rcp/handlers/files/DeleteFile.java (revision 3477)
28 28
package org.txm.rcp.handlers.files;
29 29

  
30 30
import java.io.File;
31
import java.util.Arrays;
31 32
import java.util.List;
32 33

  
33 34
import org.eclipse.core.commands.AbstractHandler;
......
66 67
			
67 68
			if (o instanceof File) {
68 69
				File file = (File) o;
69
				delete(file);
70
				boolean definitive = true; // (event.stateMask & SWT.SHIFT) != 0;
71
				delete(file, definitive);
70 72
			}
71 73
		}
72 74
		return null;
......
77 79
	 * 
78 80
	 * @param file the file or directory to delete
79 81
	 */
80
	public static void delete(File file) {
81
		// ask new file name
82
	public static void delete(File file, boolean definitive) {
82 83
		
83
		Shell shell = new Shell();
84
		MessageBox dialog = new MessageBox(shell, SWT.YES | SWT.NO);
85
		dialog.setMessage(TXMUIMessages.bind(TXMUIMessages.areYouSureYouWantToDeleteP0Colon, file));
86
		
87
		int buttonID = dialog.open();
88
		switch (buttonID) {
89
			case SWT.YES:
90
				File parentFile = file.getParentFile();
91
				if (file.isFile()) {
92
					if (!file.delete()) System.out.println(NLS.bind(TXMUIMessages.failedToDeleteFileP0, file));
93
				}
94
				else if (file.isDirectory()) {
95
					if (!DeleteDir.deleteDirectory(file)) System.out.println(NLS.bind(TXMUIMessages.failedToDeleteFileP0, file));
96
				}
97
				Explorer.refresh(parentFile);
98
				MacroExplorer.refresh(parentFile);
99
			case SWT.NO:
100
				// exits here ...
101
				break;
102
			case SWT.CANCEL:
103
				// does nothing ...
104
		}
84
		delete(Arrays.asList(file), definitive);
105 85
	}
106 86
	
107 87
	/**
108 88
	 * open a dialog box to confirm and update views
109 89
	 * 
110 90
	 * @param files the files or directories to delete
91
	 * @param definitive definitivelly delete the files FIXME NOT IMPLEMENTED YET
111 92
	 */
112
	public static void delete(List files) {
93
	public static void delete(List<?> files, boolean definitive) {
94
		
113 95
		Shell shell = new Shell();
114 96
		MessageBox dialog = new MessageBox(shell, SWT.YES | SWT.NO);
115 97
		dialog.setMessage(TXMUIMessages.bind(TXMUIMessages.areYouSureYouWantToDeleteP0Colon, files));
......
122 104
						File file = (File) o;
123 105
						if (file.exists()) {
124 106
							if (file.isFile()) {
125
								if (!file.delete()) {
126
									System.out.println(NLS.bind(TXMUIMessages.failedToDeleteFileP0, file));
107
								if (definitive) {
108
									if (!file.delete()) {
109
										System.out.println(NLS.bind(TXMUIMessages.failedToDeleteFileP0, file));
110
									}
111
								} else {
112
									File dest = new File(System.getProperty("java.io.tmpdir"), file.getName());
113
									dest.delete();
114
									if (!file.renameTo(dest)) {
115
										System.out.println(NLS.bind("Fail to move file to the tmp directory: {0}", file));
116
									}
127 117
								}
128 118
							}
129 119
							else if (file.isDirectory()) {
130
								if (!DeleteDir.deleteDirectory(file)) {
120
								if (!DeleteDir.deleteDirectory(file, definitive)) {
131 121
									System.out.println(NLS.bind(TXMUIMessages.failedToDeleteFileP0, file));
132 122
								}
133 123
							}
TXM/trunk/org.txm.rcp/src/main/java/org/txm/rcp/messages/TXMUIMessages.java (revision 3477)
1480 1480
	public static String YouNeedToSetAsManyPercentSPrintfMarksAsSelectedProperties;
1481 1481

  
1482 1482
	public static String YouReGoingToLostThoseModificationsIfNotAlreadyExportedContinue;
1483

  
1484
	public static String defaultReferences;
1483 1485
	
1484 1486
	static {
1485 1487
		// initialize resource bundle
TXM/trunk/org.txm.rcp/src/main/java/org/txm/rcp/views/fileexplorer/Explorer.java (revision 3477)
300 300
			public void keyPressed(KeyEvent e) {
301 301
				ISelection sel = tv.getSelection();
302 302
				if (sel instanceof IStructuredSelection) {
303
					List objects = ((IStructuredSelection) sel).toList();
303
					List<Object> objects = ((IStructuredSelection) sel).toList();
304 304
					if (e.keyCode == SWT.DEL) {
305
						DeleteFile.delete(objects);
305
						boolean definitive = true; // (e.stateMask & SWT.SHIFT) != 0;
306
						DeleteFile.delete(objects, definitive);
306 307
					}
307 308
					else if (e.keyCode == SWT.F5) {
308 309
						Explorer.refresh();
......
313 314
							if (o instanceof File) {
314 315
								File file = (File) o;
315 316
								if (e.keyCode == SWT.DEL) {
316
									DeleteFile.delete(file);
317
									boolean definitive = true; // (e.stateMask & SWT.SHIFT) != 0;
318
									//DeleteFile.delete(file, definitive);
317 319
								}
318 320
								else if ((char) e.keyCode == 'c' & ((e.stateMask & SWT.CTRL) != 0)) {
319 321
									CopyFile.copy(file);
TXM/trunk/org.txm.rcp/src/main/java/org/txm/rcp/views/fileexplorer/MacroExplorer.java (revision 3477)
300 300
				if (sel instanceof IStructuredSelection) {
301 301
					List<?> objects = ((IStructuredSelection) sel).toList();
302 302
					if (e.keyCode == SWT.DEL) {
303
						DeleteFile.delete(objects);
303
						boolean definitive = (e.stateMask & SWT.SHIFT) != 0;
304
						DeleteFile.delete(objects, definitive);
304 305
					}
305 306
					else if (e.keyCode == SWT.F5) {
306 307
						MacroExplorer.refresh();
......
311 312
							if (o instanceof File) {
312 313
								File file = (File) o;
313 314
								if (e.keyCode == SWT.DEL) {
314
									DeleteFile.delete(file);
315
									boolean definitive = true; // (e.stateMask & SWT.SHIFT) != 0;
316
									DeleteFile.delete(file, definitive);
315 317
								}
316 318
								else if ((char) e.keyCode == 'c' & ((e.stateMask & SWT.CTRL) != 0)) {
317 319
									CopyFile.copy(file);
TXM/trunk/org.txm.core/src/java/org/txm/objects/Edition.java (revision 3477)
52 52
	
53 53
	/** The index page path. */
54 54
	@Parameter(key = TBXPreferences.INDEX)
55
	String pIndex;
55
	protected String pIndex;
56 56
	
57 57
	@Parameter(key = TBXPreferences.NAMES)
58
	ArrayList<String> pPageNames;
58
	protected ArrayList<String> pPageNames;
59 59
	
60 60
	@Parameter(key = "pages_wordids")
61
	ArrayList<String> pPageFirstWordIds;
61
	protected ArrayList<String> pPageFirstWordIds;
62 62
	
63
	private File defaultHtmlDir;
63
	protected File defaultHtmlDir;
64 64
	
65 65
	/**
66 66
	 * Instantiates a new edition.
TXM/trunk/org.txm.groovy.core/src/groovy/org/txm/macro/transcription/Vocapia2Transcriber.groovy (revision 3477)
81 81
								break;
82 82
							case "Speaker": // <Speaker ch="1" dur="531.38" gender="X" spkid="Enquêtrice" lang="fre" lconf="1.00" nw="1586" tconf="0.95"/> -> <Speaker id="spk1" name="enq4" check="no" dialect="native" accent="" scope="local"/>
83 83
							
84
								String spkid = parser.getAttributeValue(null, "spkid").trim().replaceAll("[\\s()]", "")
85
								
84 86
								writer.writeStartElement("Speaker")
85
								writer.writeAttribute("id", parser.getAttributeValue(null, "spkid").trim())
86
								writer.writeAttribute("name", parser.getAttributeValue(null, "spkid").trim())
87
								writer.writeAttribute("id", spkid)
88
								writer.writeAttribute("name", spkid)
87 89
								writer.writeAttribute("check", "")
88 90
								writer.writeAttribute("dialect", parser.getAttributeValue(null, "lang"))
89 91
								writer.writeAttribute("accent", parser.getAttributeValue(null, "gender"))
......
94 96
								/**
95 97
								 * remove the additional speaker if already written
96 98
								 */
97
								if (additionalSpeakers.containsKey(parser.getAttributeValue(null, "spkid").trim())) {
98
									additionalSpeakers.remove(parser.getAttributeValue(null, "spkid").trim())
99
								if (additionalSpeakers.containsKey(spkid)) {
100
									additionalSpeakers.remove(spkid)
99 101
								}
100 102
								break;
101 103
								
......
124 126
									else if (name == "etime") name = "endTime"
125 127
									else if (name == "spkid") {
126 128
										name = "speaker"
127
										value = value.trim()
129
										value = value.trim().replaceAll("[\\s()]", "")
128 130
									}
129 131
									writer.writeAttribute(name, value)
130 132
								}
TXM/trunk/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/transcriber/importer.groovy (revision 3477)
198 198
			cpb.done()
199 199
		} else {
200 200
			
201
			println "Tokenizing "+files.length+" files from $txmDir"
201
			println "Tokenizing "+files.length+" files"
202 202
			cpb = new ConsoleProgressBar(files.length)
203 203
			for (File pfile : files) {
204 204
				cpb.tick()

Formats disponibles : Unified diff