Révision 1616
tmp/org.txm.setups/index.html (revision 1616) | ||
---|---|---|
3 | 3 |
<meta http-equiv="content-type" content="text/html; charset=UTF-8"> |
4 | 4 |
<meta name="generator" content="ReText 4.1.2"> |
5 | 5 |
<link rel="stylesheet" type="text/css" href="index_files/sf.css"> |
6 |
<title>Téléchargement de TXM 0.8.0 α2</title>
|
|
6 |
<title>Téléchargements | TXM 0.8.0 beta | Downloads</title>
|
|
7 | 7 |
</head> |
8 | 8 |
<body> |
9 | 9 |
<hr/> |
10 | 10 |
|
11 |
<h1 align="center">Téléchargement de <span class="big"> TXM 0.8.0 </span> α<br>
|
|
11 |
<h1 align="center">Téléchargements <span class="big"> TXM 0.8.0 beta </span> Downloads<br>
|
|
12 | 12 |
<!--<img src="index_files/txm-icon.jpg"><br>--> |
13 | 13 |
<!-- <small><a href="#fr">(instructions d'installation en français ci-dessous - FR FR FR)</a></small> --> |
14 | 14 |
</h1> |
15 | 15 |
<div style="background-image:url('index_files/TXM-background.jpg');background-repeat: no-repeat;background-position: right;"> |
16 | 16 |
|
17 |
<p>Version 1</p> |
|
18 |
|
|
17 | 19 |
<table > |
18 |
<td><center><a href="TXM_0.8.0a3_Win64_installer.exe"><img width="125" src="index_files/windows-icon.png"/><br>Windows 7 et plus (64 bit)</a></center></td>
|
|
19 |
<td><center ><a href="TXM_0.8.0a3_Linux64_installer.deb"><img width="125" src="index_files/ubuntu-icon.png"/><br>Ubuntu 16.04 et plus</a><br></center></li><td>
|
|
20 |
<td><center ><a href="TXM_0.8.0a3_MacOSX_installer.pkg"><img width="125" src="index_files/macosx-icon.png"/><br>Mac OS X 10.10 et plus</a><br></center></li><td>
|
|
20 |
<td><center><a href="TXM_0.8.0b1_Win64_installer.exe"><img width="125" src="index_files/windows-icon.png"/><br>Windows 7 et plus (64 bit)</a></center></td>
|
|
21 |
<td><center ><a href="TXM_0.8.0b1_Linux64_installer.deb"><img width="125" src="index_files/ubuntu-icon.png"/><br>Ubuntu 16.04 et plus</a><br></center></li><td>
|
|
22 |
<td><center ><a href="TXM_0.8.0b1_MacOSX_installer.pkg"><img width="125" src="index_files/macosx-icon.png"/><br>Mac OS X 10.10 et plus</a><br></center></li><td>
|
|
21 | 23 |
</table> |
22 | 24 |
|
25 |
<!-- |
|
26 |
<p><b>versions antérieures</b><br/> |
|
27 |
|
|
28 |
b4 <a href="TXM_0.8.0b4_Win64_installer.exe">Windows</a> <a href="TXM_0.8.0b4_Linux64_installer.deb">Ubuntu</a> <a href="TXM_0.8.0b4_MacOSX_installer.pkg">Mac OS X</a><br/> |
|
29 |
b3 <a href="TXM_0.8.0b3_Win64_installer.exe">Windows</a> <a href="TXM_0.8.0b3_Linux64_installer.deb">Ubuntu</a> <a href="TXM_0.8.0b3_MacOSX_installer.pkg">Mac OS X</a><br/> |
|
30 |
b2 <a href="TXM_0.8.0b2_Win64_installer.exe">Windows</a> <a href="TXM_0.8.0b2_Linux64_installer.deb">Ubuntu</a> <a href="TXM_0.8.0b2_MacOSX_installer.pkg">Mac OS X</a><br/> |
|
31 |
b1 <a href="TXM_0.8.0b1_Win64_installer.exe">Windows</a> <a href="TXM_0.8.0b1_Linux64_installer.deb">Ubuntu</a> <a href="TXM_0.8.0b1_MacOSX_installer.pkg">Mac OS X</a><br/> |
|
32 |
</p>--> |
|
33 |
|
|
23 | 34 |
<h2>Recettes</h2> |
24 | 35 |
<ul> |
25 | 36 |
<li><a href="https://groupes.renater.fr/wiki/txm-info/public/roadmap_0.8#recette_0_-_installation_multiple">Recette 0 </a>: installation</li> |
tmp/org.txm.rcp/src/main/java/org/txm/rcp/commands/workspace/LoadBinaryCorporaDirectory.java (revision 1616) | ||
---|---|---|
28 | 28 |
package org.txm.rcp.commands.workspace; |
29 | 29 |
|
30 | 30 |
import java.io.File; |
31 |
import java.io.FileFilter; |
|
31 | 32 |
import java.util.ArrayList; |
33 |
import java.util.Arrays; |
|
34 |
import java.util.Comparator; |
|
35 |
import java.util.List; |
|
32 | 36 |
|
33 | 37 |
import org.eclipse.core.commands.AbstractHandler; |
34 | 38 |
import org.eclipse.core.commands.ExecutionEvent; |
... | ... | |
36 | 40 |
import org.eclipse.core.runtime.IProgressMonitor; |
37 | 41 |
import org.eclipse.core.runtime.IStatus; |
38 | 42 |
import org.eclipse.core.runtime.Status; |
43 |
import org.eclipse.jface.viewers.ArrayContentProvider; |
|
44 |
import org.eclipse.jface.viewers.LabelProvider; |
|
39 | 45 |
import org.eclipse.osgi.util.NLS; |
40 | 46 |
import org.eclipse.swt.SWT; |
41 | 47 |
import org.eclipse.swt.widgets.DirectoryDialog; |
48 |
import org.eclipse.swt.widgets.Display; |
|
42 | 49 |
import org.eclipse.swt.widgets.Shell; |
50 |
import org.eclipse.ui.dialogs.ListSelectionDialog; |
|
43 | 51 |
import org.eclipse.ui.handlers.HandlerUtil; |
44 | 52 |
import org.txm.Toolbox; |
45 | 53 |
import org.txm.core.engines.EngineType; |
... | ... | |
49 | 57 |
import org.txm.rcp.messages.TXMUIMessages; |
50 | 58 |
import org.txm.rcp.swt.dialog.LastOpened; |
51 | 59 |
import org.txm.rcp.utils.JobHandler; |
60 |
import org.txm.rcp.views.corpora.CorporaView; |
|
52 | 61 |
import org.txm.searchengine.core.SearchEngine; |
53 | 62 |
import org.txm.searchengine.core.SearchEnginesManager; |
54 | 63 |
import org.txm.utils.io.IOUtils; |
55 | 64 |
import org.txm.utils.logger.Log; |
65 |
import org.txm.utils.zip.Zip; |
|
56 | 66 |
|
57 | 67 |
/** |
58 | 68 |
* Create projects from one binary corpus directory |
... | ... | |
84 | 94 |
|
85 | 95 |
if (directory.exists()) { |
86 | 96 |
LastOpened.set(ID, directory); |
87 |
return loadBinaryCorpusFromCorporaDirectory(directory); |
|
97 |
return loadBinaryCorpusFromCorporaDirectory(directory, true, true);
|
|
88 | 98 |
} |
89 | 99 |
} |
90 | 100 |
return null; |
91 | 101 |
} |
92 | 102 |
|
93 | 103 |
/** |
94 |
* stop engines, load binary corpora from a directory, restart engines and refresh views
|
|
104 |
* stop engines, try loading binary corpora from a directory, restart engines and refresh views
|
|
95 | 105 |
* |
96 | 106 |
* @param directory |
97 | 107 |
* @return |
98 | 108 |
*/ |
99 |
public static JobHandler loadBinaryCorpusFromCorporaDirectory(final File directory) { |
|
109 |
public static JobHandler loadBinaryCorpusFromCorporaDirectory(final File directory, final boolean askSelection, final boolean replace) {
|
|
100 | 110 |
|
101 |
JobHandler jobhandler = new JobHandler("Scanning "+directory+"...", true) { |
|
111 |
JobHandler jobhandler = new JobHandler("Loading corpora from "+directory+"...", true) { |
|
112 |
|
|
113 |
JobHandler self = this; |
|
102 | 114 |
@Override |
103 |
protected IStatus run(IProgressMonitor monitor) { |
|
115 |
protected IStatus run(final IProgressMonitor monitor) {
|
|
104 | 116 |
this.runInit(monitor); |
105 | 117 |
|
106 | 118 |
try { |
... | ... | |
112 | 124 |
|
113 | 125 |
File corporaDirectory = new File(Toolbox.getTxmHomePath(), "corpora"); |
114 | 126 |
if (!corporaDirectory.exists()) { |
115 |
System.out.println("Corpora directory not found. Aborting.");
|
|
127 |
Log.severe("Corpora directory not found. Aborting.");
|
|
116 | 128 |
try { |
117 | 129 |
SearchEnginesManager.getCQPSearchEngine().start(null); |
118 | 130 |
} catch (Exception e) { |
... | ... | |
122 | 134 |
return Status.CANCEL_STATUS; |
123 | 135 |
} |
124 | 136 |
|
125 |
final ArrayList<Project> newProjects = loadBinaryCorpusFromCorporaDirectory(directory, this, monitor); |
|
137 |
|
|
138 |
final ArrayList<Project> newProjects = new ArrayList<Project>(); |
|
139 |
if (askSelection) { |
|
140 |
|
|
141 |
this.syncExec(new Runnable() { |
|
142 |
@Override |
|
143 |
public void run() { |
|
144 |
List<File> files = getBinaryCorpusSelection(directory); |
|
145 |
ArrayList<Project> tmp = loadBinaryCorpusFromCorporaDirectory(files, self, monitor, replace); |
|
146 |
if (tmp != null) { |
|
147 |
newProjects.addAll(tmp); |
|
148 |
} |
|
149 |
} |
|
150 |
}); |
|
151 |
|
|
152 |
} else { // try loading corpora and dont replace existing corpus |
|
153 |
ArrayList<Project> tmp = loadBinaryCorpusFromCorporaDirectory(directory, this, monitor, replace); |
|
154 |
if (tmp != null) { |
|
155 |
newProjects.addAll(tmp); |
|
156 |
} |
|
157 |
} |
|
126 | 158 |
|
127 | 159 |
this.acquireSemaphore(); |
128 | 160 |
try { |
... | ... | |
139 | 171 |
e.printStackTrace(); |
140 | 172 |
} |
141 | 173 |
} |
142 |
System.out.println(NLS.bind(TXMUIMessages.P0CorpusLoaded, newProjects.size())); |
|
174 |
if (newProjects.size() > 0) { |
|
175 |
System.out.println(NLS.bind(TXMUIMessages.P0CorpusLoaded, newProjects.size())); |
|
176 |
} |
|
143 | 177 |
|
144 | 178 |
this.syncExec(new Runnable() { |
145 | 179 |
@Override |
... | ... | |
157 | 191 |
jobhandler.schedule(); |
158 | 192 |
return jobhandler; |
159 | 193 |
} |
194 |
|
|
195 |
protected static List<File> getBinaryCorpusSelection(File directory) { |
|
196 |
ArrayList<File> selectedFiles = new ArrayList<File>();; |
|
197 |
if (!directory.isDirectory()) return selectedFiles; |
|
198 |
if (!directory.exists()) return selectedFiles; |
|
199 |
|
|
200 |
Shell shell = null; |
|
201 |
|
|
202 |
if (Display.getCurrent() != null) { |
|
203 |
shell = Display.getCurrent().getActiveShell(); |
|
204 |
} else if (Display.getDefault() == null) { |
|
205 |
shell = Display.getDefault().getActiveShell(); |
|
206 |
} else if (Display.findDisplay(Thread.currentThread()) != null) { |
|
207 |
shell = Display.findDisplay(Thread.currentThread()).getActiveShell(); |
|
208 |
} else { |
|
209 |
return selectedFiles; |
|
210 |
} |
|
211 |
File[] files = directory.listFiles(new FileFilter() { |
|
212 |
|
|
213 |
@Override |
|
214 |
public boolean accept(File arg0) { |
|
215 |
return IOUtils.HIDDENFILE_FILTER.accept(arg0) && arg0.getName().endsWith(".txm"); |
|
216 |
} |
|
217 |
}); |
|
218 |
Arrays.sort(files, new Comparator<File>() { |
|
219 |
@Override |
|
220 |
public int compare(File o1, File o2) { |
|
221 |
int i = o1.getName().compareTo(o2.getName()); |
|
222 |
if (i == 0) { |
|
223 |
return (int) (o1.lastModified() - o2.lastModified()); |
|
224 |
} |
|
225 |
return i; |
|
226 |
} |
|
227 |
}); |
|
228 |
|
|
229 |
ListSelectionDialog lsd = new ListSelectionDialog(shell, files, new ArrayContentProvider(), new LabelProvider() { |
|
160 | 230 |
|
231 |
@Override |
|
232 |
public String getText(Object element) { |
|
233 |
if (element == null) return "error"; |
|
234 |
|
|
235 |
if (!(element instanceof File)) return "not a file ("+element+")"; |
|
236 |
|
|
237 |
File f = (File) element; |
|
238 |
if (f.isDirectory()) { |
|
239 |
if (new File(f, ".settings").exists()) { |
|
240 |
return f.getName().toUpperCase()+" ("+f+")"; |
|
241 |
} else if (new File(f, "import.xml").exists()) { |
|
242 |
return f.getName().toUpperCase()+" ("+f+")"; |
|
243 |
} |
|
244 |
} else if (f.getName().endsWith(".txm")) { |
|
245 |
return Zip.getRoot(f).toUpperCase()+" ("+f+")"; |
|
246 |
} |
|
247 |
|
|
248 |
return "not a txm corpus ("+f+")"; |
|
249 |
} |
|
250 |
}, "Select the '.txm' corpus to load."); |
|
251 |
lsd.setInitialSelections(files); |
|
252 |
lsd.setTitle("Corpus load"); |
|
253 |
if (lsd.open() == ListSelectionDialog.OK) { |
|
254 |
System.out.println(lsd.getResult()); |
|
255 |
for (Object o : lsd.getResult()) { |
|
256 |
selectedFiles.add(new File(o.toString())); |
|
257 |
} |
|
258 |
} |
|
259 |
|
|
260 |
return selectedFiles; |
|
261 |
} |
|
262 |
|
|
161 | 263 |
/** |
162 | 264 |
* dont manage SearchEngine state |
163 | 265 |
* |
266 |
* @param files2 |
|
267 |
* @param job |
|
268 |
* @param monitor |
|
269 |
* @return the loaded projects |
|
270 |
*/ |
|
271 |
protected static ArrayList<Project> loadBinaryCorpusFromCorporaDirectory(File directory, JobHandler job, IProgressMonitor monitor, boolean replace) { |
|
272 |
File[] files = directory.listFiles(IOUtils.HIDDENFILE_FILTER); |
|
273 |
return loadBinaryCorpusFromCorporaDirectory(Arrays.asList(files), job, monitor, replace); |
|
274 |
} |
|
275 |
|
|
276 |
/** |
|
277 |
* dont manage SearchEngine state |
|
278 |
* |
|
164 | 279 |
* @param corporaDirectory |
165 | 280 |
* @param job |
166 | 281 |
* @param monitor |
167 |
* @return |
|
282 |
* @param replace if true replace existing corpus |
|
283 |
* @return the loaded projects |
|
168 | 284 |
*/ |
169 |
protected static ArrayList<Project> loadBinaryCorpusFromCorporaDirectory(File corporaDirectory, JobHandler job, IProgressMonitor monitor) {
|
|
285 |
protected static ArrayList<Project> loadBinaryCorpusFromCorporaDirectory(List<File> corporaFiles, JobHandler job, IProgressMonitor monitor, boolean replace) {
|
|
170 | 286 |
|
171 | 287 |
ArrayList<Project> projects = new ArrayList<Project>(); |
172 | 288 |
|
... | ... | |
183 | 299 |
job.releaseSemaphore(); |
184 | 300 |
|
185 | 301 |
monitor.subTask(TXMUIMessages.loadingTheCorpusInThePlatform); |
186 |
for (File corpusDirectory : corporaDirectory.listFiles(IOUtils.HIDDENFILE_FILTER)) {
|
|
302 |
for (File corpusDirectory : corporaFiles) {
|
|
187 | 303 |
if (corpusDirectory.isHidden()) { |
188 | 304 |
continue; |
189 | 305 |
} |
190 | 306 |
|
191 | 307 |
Project project = Toolbox.workspace.getProject(corpusDirectory.getName().toUpperCase()); |
192 | 308 |
if (project != null) { |
193 |
System.out.println("A corpus named "+corpusDirectory.getName().toUpperCase()+" is already loaded. Aborting the loading of "+corpusDirectory);
|
|
309 |
Log.warning("A corpus named "+corpusDirectory.getName().toUpperCase()+" is already loaded. Aborting the loading of "+corpusDirectory);
|
|
194 | 310 |
continue; |
195 | 311 |
} |
196 | 312 |
|
197 | 313 |
if (corpusDirectory.isDirectory()) { |
198 |
project = LoadBinaryCorpus.loadBinaryCorpusAsDirectory(corpusDirectory, monitor); |
|
314 |
// project = LoadBinaryCorpus.loadBinaryCorpusAsDirectory(corpusDirectory, monitor, replace); |
|
315 |
continue; |
|
199 | 316 |
} else if (corpusDirectory.getName().endsWith(".txm")) { |
200 |
project = LoadBinaryCorpus.loadBinaryCorpusArchive(corpusDirectory, job, monitor); |
|
317 |
project = LoadBinaryCorpus.loadBinaryCorpusArchive(corpusDirectory, job, monitor, replace);
|
|
201 | 318 |
} else { |
202 | 319 |
continue; // not a corpus |
203 | 320 |
} |
204 | 321 |
|
205 | 322 |
// Project base = LoadBinaryCorpus.loadBinaryCorpusAsDirectory(corpusDirectory); |
206 | 323 |
if (project == null) { |
207 |
Log.severe("Error: fail to load binary corpus: "+corpusDirectory);
|
|
324 |
Log.warning("Failed to load binary corpus: "+corpusDirectory);
|
|
208 | 325 |
} else { |
209 | 326 |
projects.add(project); |
210 | 327 |
} |
tmp/org.txm.rcp/src/main/java/org/txm/rcp/commands/workspace/Load079BinaryCorpus.java (revision 1616) | ||
---|---|---|
36 | 36 |
import org.txm.objects.Project; |
37 | 37 |
import org.txm.rcp.messages.TXMUIMessages; |
38 | 38 |
import org.txm.searchengine.cqp.corpus.MainCorpus; |
39 |
import org.txm.utils.DeleteDir; |
|
39 | 40 |
import org.txm.utils.logger.Log; |
40 | 41 |
import org.txm.utils.zip.Zip; |
41 | 42 |
|
... | ... | |
60 | 61 |
* 3- unzip the archive |
61 | 62 |
* 4- load the binary corpus directory |
62 | 63 |
* 5- restart TXM engines |
64 |
* @param replace |
|
63 | 65 |
* @throws Exception |
64 | 66 |
*/ |
65 |
public static Project loadBinaryCorpusArchive(final File zipFile, IProgressMonitor monitor) throws Exception { |
|
67 |
public static Project loadBinaryCorpusArchive(final File zipFile, IProgressMonitor monitor, boolean replace) throws Exception {
|
|
66 | 68 |
|
67 | 69 |
final File corporaDir = Toolbox.workspace.getLocation(); //$NON-NLS-1$ |
68 | 70 |
corporaDir.mkdir(); |
71 |
|
|
72 |
if (!canLoad(zipFile)) { |
|
73 |
System.out.println(TXMUIMessages.binaryCorpusIsNotATXM079CorpusNoImportXmlFile); |
|
74 |
return null; |
|
75 |
} |
|
69 | 76 |
|
70 | 77 |
String basedirname = Zip.getRoot(zipFile); |
71 | 78 |
|
72 | 79 |
Project p = Toolbox.workspace.getProject(basedirname.toUpperCase()); |
73 | 80 |
if (p != null) { |
74 |
System.out.println(NLS.bind(TXMUIMessages.abortingLoadingOfPOACorpusWithTheSameNameAlreadyExists, zipFile)); |
|
75 |
return null; |
|
81 |
if (replace) { |
|
82 |
p.delete(); |
|
83 |
} else { |
|
84 |
System.out.println(NLS.bind(TXMUIMessages.abortingLoadingOfPOACorpusWithTheSameNameAlreadyExists, zipFile)); |
|
85 |
return null; |
|
86 |
} |
|
87 |
|
|
76 | 88 |
} |
77 | 89 |
|
78 | 90 |
File corpusDirectory = new File(corporaDir, basedirname); |
79 |
if (corpusDirectory.exists()) { |
|
80 |
System.out.println("Aborting loading of "+zipFile+". A directory with the same name already exists: "+corpusDirectory); |
|
81 |
return null; |
|
91 |
if (replace) { |
|
92 |
DeleteDir.deleteDirectory(corpusDirectory); |
|
93 |
} else { |
|
94 |
if (corpusDirectory.exists()) { |
|
95 |
System.out.println("Aborting loading of "+zipFile+". A directory with the same name already exists: "+corpusDirectory); |
|
96 |
return null; |
|
97 |
} |
|
82 | 98 |
} |
83 |
|
|
84 |
if (!canLoad(zipFile)) { |
|
85 |
System.out.println(TXMUIMessages.binaryCorpusIsNotATXM079CorpusNoImportXmlFile); |
|
86 |
return null; |
|
87 |
} |
|
88 |
|
|
99 |
|
|
89 | 100 |
System.out.println(NLS.bind(TXMUIMessages.loadingTheP0BinaryCorpusAsATXM079Corpus, zipFile.getName())); |
90 | 101 |
|
91 | 102 |
//ZIPPED FILE |
tmp/org.txm.rcp/src/main/java/org/txm/rcp/commands/workspace/LoadBinaryCorpus.java (revision 1616) | ||
---|---|---|
106 | 106 |
} |
107 | 107 |
} else { |
108 | 108 |
FileDialog dialog = new FileDialog(shell, SWT.OPEN); |
109 |
dialog.setFilterExtensions(new String[]{"*.txm", "*.zip"});
|
|
109 |
dialog.setFilterExtensions(new String[]{"*.txm"}); |
|
110 | 110 |
if (LastOpened.getFile(ID) != null) { |
111 | 111 |
dialog.setFilterPath(LastOpened.getFolder(ID)); |
112 | 112 |
dialog.setFileName(LastOpened.getFile(ID)); |
... | ... | |
213 | 213 |
@Override |
214 | 214 |
protected IStatus run(final IProgressMonitor monitor) { |
215 | 215 |
this.runInit(monitor); |
216 |
final Project newProject2 = loadBinaryCorpusArchive(zipFile, this, monitor); |
|
216 |
final Project newProject2 = loadBinaryCorpusArchive(zipFile, this, monitor, false);
|
|
217 | 217 |
|
218 | 218 |
this.syncExec(new Runnable() { |
219 | 219 |
@Override |
... | ... | |
257 | 257 |
* @param zipFile |
258 | 258 |
* @param jobhandler |
259 | 259 |
* @param monitor |
260 |
* @param replace |
|
260 | 261 |
* @return |
261 | 262 |
*/ |
262 |
public static Project loadBinaryCorpusArchive(File zipFile, JobHandler jobhandler, final IProgressMonitor monitor) { |
|
263 |
public static Project loadBinaryCorpusArchive(File zipFile, JobHandler jobhandler, final IProgressMonitor monitor, boolean replace) {
|
|
263 | 264 |
Project project = null; |
264 | 265 |
try { |
265 | 266 |
// SearchEngine engine = SearchEnginesManager.getCQPSearchEngine(); |
... | ... | |
269 | 270 |
|
270 | 271 |
//CHECK ZIPPED FILE |
271 | 272 |
if (Load080BinaryCorpus.canLoad(zipFile)) { |
272 |
project = Load080BinaryCorpus.loadBinaryCorpusArchive(zipFile, monitor); |
|
273 |
project = Load080BinaryCorpus.loadBinaryCorpusArchive(zipFile, monitor, replace);
|
|
273 | 274 |
} else if (Load079BinaryCorpus.canLoad(zipFile)) { |
274 |
project = Load079BinaryCorpus.loadBinaryCorpusArchive(zipFile, monitor); |
|
275 |
project = Load079BinaryCorpus.loadBinaryCorpusArchive(zipFile, monitor, replace);
|
|
275 | 276 |
} else { |
276 |
System.out.println(NLS.bind("Error: the {0} archive is not a TXM corpus.", zipFile));
|
|
277 |
Log.warning(NLS.bind("The {0} archive is not a TXM corpus.", zipFile));
|
|
277 | 278 |
return null; |
278 | 279 |
} |
279 | 280 |
if (project == null) { |
280 |
System.out.println(NLS.bind("Error: could not load the {0} corpus.", zipFile));
|
|
281 |
Log.warning(NLS.bind("Failed to load the {0} corpus.", zipFile));
|
|
281 | 282 |
return null; |
282 | 283 |
} |
283 | 284 |
|
... | ... | |
317 | 318 |
/** |
318 | 319 |
* load the content of the file if its a directory containing at least the sub folders : |
319 | 320 |
* txm, html, data and registry. |
321 |
* @param replace |
|
320 | 322 |
* |
321 | 323 |
* @param binCorpusDirectory the basedir |
322 | 324 |
* @return the base |
323 | 325 |
* @throws Exception the exception |
324 | 326 |
*/ |
325 |
public static Project loadBinaryCorpusAsDirectory(File corpusDirectory, IProgressMonitor monitor) throws Exception { |
|
327 |
public static Project loadBinaryCorpusAsDirectory(File corpusDirectory, IProgressMonitor monitor, boolean replace) throws Exception {
|
|
326 | 328 |
if (!(corpusDirectory.exists() && corpusDirectory.isDirectory())) { |
327 |
Log.severe(NLS.bind(TXMUIMessages.failedToLoadCorpusP0, corpusDirectory.getAbsolutePath()));
|
|
329 |
Log.warning(NLS.bind(TXMUIMessages.failedToLoadCorpusP0, corpusDirectory.getAbsolutePath()));
|
|
328 | 330 |
System.out.println(NLS.bind(TXMUIMessages.failedToLoadCorpusP0, corpusDirectory.getAbsolutePath())); |
329 | 331 |
return null; |
330 | 332 |
} |
... | ... | |
349 | 351 |
// test with project name |
350 | 352 |
Project p = Toolbox.workspace.getProject(corpusDirectory.getName().toUpperCase().toUpperCase()); |
351 | 353 |
if (p != null) { |
352 |
System.out.println(NLS.bind("Aborting loading of {0}. A corpus with the same name already exists.", corpusDirectory));
|
|
354 |
Log.warning(NLS.bind("Aborting loading of {0}. A corpus with the same name already exists.", corpusDirectory));
|
|
353 | 355 |
return null; |
354 | 356 |
} |
355 | 357 |
|
... | ... | |
360 | 362 |
String mainCorpusName = mainCorpusDirs[0].getName(); |
361 | 363 |
p = Toolbox.workspace.getProject(mainCorpusName); |
362 | 364 |
if (p != null) { |
363 |
System.out.println(NLS.bind("Aborting loading of {0}. A corpus with the same {1} CQP MainCorpus name already exists.", corpusDirectory, mainCorpusName));
|
|
365 |
Log.warning(NLS.bind("Aborting loading of {0}. A corpus with the same {1} CQP MainCorpus name already exists.", corpusDirectory, mainCorpusName));
|
|
364 | 366 |
return null; |
365 | 367 |
} |
366 | 368 |
} |
... | ... | |
384 | 386 |
System.out.println(NLS.bind(TXMUIMessages.loadingTheP0BinaryCorpusAsATXM079Corpus, destDir)); |
385 | 387 |
project = Load079BinaryCorpus.loadBinaryCorpusAsDirectory(destDir, null); |
386 | 388 |
} else { |
387 |
System.out.println(NLS.bind("Error: {0} is not a binary corpus directory.", destDir));
|
|
389 |
Log.severe(NLS.bind("Error: {0} is not a binary corpus directory.", destDir));
|
|
388 | 390 |
} |
389 | 391 |
|
390 | 392 |
if (!destDir.equals(corpusDirectory) && project == null) { // clean if necessary |
tmp/org.txm.rcp/src/main/java/org/txm/rcp/commands/workspace/Load080BinaryCorpus.java (revision 1616) | ||
---|---|---|
56 | 56 |
/** |
57 | 57 |
* load the content of the file if its a directory containing at least the sub folders : |
58 | 58 |
* txm, html, data and registry. |
59 |
* @param replace |
|
59 | 60 |
* |
60 | 61 |
* @param binCorpusDirectory the zipFile |
61 | 62 |
* @return the base |
62 | 63 |
* @throws Exception the exception |
63 | 64 |
*/ |
64 |
public static Project loadBinaryCorpusArchive(File zipFile, IProgressMonitor monitor) throws Exception { |
|
65 |
public static Project loadBinaryCorpusArchive(File zipFile, IProgressMonitor monitor, boolean replace) throws Exception {
|
|
65 | 66 |
//ZIPPED FILE |
66 | 67 |
if (monitor != null) monitor.beginTask(TXMUIMessages.loadingBinaryCorpus, 100); |
67 | 68 |
if (monitor != null) monitor.subTask(TXMUIMessages.extractingBinaryCorpus); |
68 | 69 |
|
70 |
if (!canLoad(zipFile)) { |
|
71 |
Log.severe(NLS.bind(TXMUIMessages.binaryCorpusIsNotATXM080CorpusNoSettingsNorProjectFile, zipFile.getName())); |
|
72 |
return null; |
|
73 |
} |
|
74 |
|
|
69 | 75 |
String basedirname = Zip.getRoot(zipFile); |
70 | 76 |
|
71 | 77 |
Project p = Toolbox.workspace.getProject(basedirname.toUpperCase()); |
72 | 78 |
if (p != null) { |
73 |
System.out.println("Aborting loading of "+zipFile+". A corpus with the same name already exists."); |
|
74 |
return null; |
|
79 |
if (replace) { |
|
80 |
p.delete(); |
|
81 |
} else { |
|
82 |
System.out.println("Aborting loading of "+zipFile+". A corpus with the same name already exists."); |
|
83 |
return null; |
|
84 |
} |
|
75 | 85 |
} |
76 | 86 |
|
77 | 87 |
File corpusDirectory = new File(Toolbox.workspace.getLocation(), basedirname); |
78 | 88 |
if (corpusDirectory.exists()) { |
79 |
System.out.println("Aborting loading of "+zipFile+". A directory with the same name already exists: "+corpusDirectory); |
|
80 |
return null; |
|
89 |
if (replace) { |
|
90 |
DeleteDir.deleteDirectory(corpusDirectory); |
|
91 |
} else { |
|
92 |
System.out.println("Aborting loading of "+zipFile+". A directory with the same name already exists: "+corpusDirectory); |
|
93 |
return null; |
|
94 |
} |
|
95 |
|
|
81 | 96 |
} |
82 | 97 |
|
83 |
if (!canLoad(zipFile)) { |
|
84 |
Log.severe(NLS.bind(TXMUIMessages.binaryCorpusIsNotATXM080CorpusNoSettingsNorProjectFile, zipFile.getName())); |
|
85 |
return null; |
|
86 |
} |
|
87 |
|
|
88 | 98 |
Log.info(NLS.bind(TXMUIMessages.loadingTheP0BinaryCorpusAsATXM080Corpus, zipFile.getName())); |
89 | 99 |
|
90 | 100 |
try { |
tmp/org.txm.rcp/src/main/java/org/txm/rcp/commands/workspace/ConvertCorpus.java (revision 1616) | ||
---|---|---|
53 | 53 |
converter.start(); |
54 | 54 |
this.releaseSemaphore(); |
55 | 55 |
|
56 |
Project base = LoadBinaryCorpus.loadBinaryCorpusAsDirectory(outdir, monitor); |
|
56 |
Project base = LoadBinaryCorpus.loadBinaryCorpusAsDirectory(outdir, monitor, false);
|
|
57 | 57 |
if (base == null) { |
58 | 58 |
System.out.println(TXMUIMessages.corpusConversionFailed); |
59 | 59 |
return Status.CANCEL_STATUS; |
tmp/org.txm.rcp/src/main/java/org/txm/rcp/ApplicationWorkbenchAdvisor.java (revision 1616) | ||
---|---|---|
264 | 264 |
if (txmHomeRestored) { |
265 | 265 |
//createBackUpDirectory(monitor); |
266 | 266 |
|
267 |
installCorporaFromSamplesDirectory(monitor);
|
|
267 |
installCorporaDirectory(monitor); |
|
268 | 268 |
// this.syncExec(new Runnable() { |
269 | 269 |
// @Override |
270 | 270 |
// public void run() { |
... | ... | |
842 | 842 |
} |
843 | 843 |
|
844 | 844 |
/** |
845 |
* Copy sample corpora in TXM corpora directory
|
|
845 |
* Install the sample corpora and previous TXM version corpora in TXM corpora directory
|
|
846 | 846 |
* @param monitor |
847 | 847 |
*/ |
848 |
private void installCorporaFromSamplesDirectory(IProgressMonitor monitor) {
|
|
848 |
private void installCorporaDirectory(IProgressMonitor monitor) { |
|
849 | 849 |
|
850 | 850 |
String installdirpath = Toolbox.getInstallDirectory(); |
851 | 851 |
File sampleCorporaDirectory = new File(installdirpath, "samples"); //$NON-NLS-1$ |
... | ... | |
856 | 856 |
corporaDir = new File(txmhomedir, "corpora"); //$NON-NLS-1$ |
857 | 857 |
corporaDir.mkdir(); |
858 | 858 |
|
859 |
// load corpora from the install directory |
|
860 |
if (sampleCorporaDirectory.exists()) { //$NON-NLS-1$ |
|
861 |
System.out.println(TXMUIMessages.installingSampleCorpus); |
|
862 |
LoadBinaryCorporaDirectory.loadBinaryCorpusFromCorporaDirectory(sampleCorporaDirectory); |
|
863 |
// Log.info(TXMUIMessages.ApplicationWorkbenchAdvisor_11); |
|
864 |
// monitor.setTaskName(TXMUIMessages.ApplicationWorkbenchAdvisor_11); |
|
865 |
// //File corporaDir = new File(txmhomedir.getAbsolutePath(), "corpora"); //$NON-NLS-1$ |
|
866 |
// |
|
867 |
// |
|
868 |
// File[] sampleCorpusFiles = sampleCorporaDirectory.listFiles(IOUtils.FILTER_HIDDEN); //$NON-NLS-1$ |
|
869 |
// |
|
870 |
// if (sampleCorpusFiles != null) for (File zipFile : sampleCorpusFiles) { |
|
871 |
// try { |
|
872 |
// String filename = zipFile.getName(); |
|
873 |
// File basedir; |
|
874 |
// String basedirname; |
|
875 |
// if (filename.endsWith(".txm") || filename.endsWith(".zip")) { //$NON-NLS-1$ //$NON-NLS-2$ |
|
876 |
// if (!zipFile.canRead()) { |
|
877 |
// System.out.println(NLS.bind(TXMUIMessages.ApplicationWorkbenchAdvisor_45, zipFile)); |
|
878 |
// continue; // go to next binary file |
|
879 |
// } |
|
880 |
// |
|
881 |
// //build binary dir path |
|
882 |
// basedirname = Zip.getRoot(zipFile); |
|
883 |
// basedir = new File(corporaDir, basedirname); |
|
884 |
// |
|
885 |
// try { |
|
886 |
// Zip.decompress(zipFile.getAbsolutePath(), corporaDir.getAbsolutePath(), false); |
|
887 |
// } catch (IOException e) { |
|
888 |
// System.out.println(NLS.bind(TXMUIMessages.couldNotUnzipBinaryCorpusColon, e)); |
|
889 |
// } |
|
890 |
// } else if (zipFile.isDirectory()) { |
|
891 |
// //basedir = zipFile; |
|
892 |
//// basedir = new File(corporaDir, zipFile.getName().toUpperCase()); |
|
893 |
//// if (basedir.exists()) { |
|
894 |
//// System.out.println("Updating "+basedir.getName()+" corpus from TXM sample directory corpus."); |
|
895 |
//// DeleteDir.deleteDirectory(basedir); |
|
896 |
//// } |
|
897 |
//// FileCopy.copyFiles(zipFile, basedir); // copy the sample corpus to load |
|
898 |
// } else { |
|
899 |
// System.out.println(NLS.bind(TXMUIMessages.thisFileIsNotATXMFileColonP0, zipFile)); |
|
900 |
// System.out.println(TXMUIMessages.aBinaryCorpusIsATXMFileExtensionTxmOrZip); |
|
901 |
// continue; |
|
902 |
// } |
|
903 |
// |
|
904 |
//// Project project = LoadBinaryCorpus.loadBinaryCorpusAsDirectory(basedir, monitor); |
|
905 |
//// if (project != null) { |
|
906 |
//// basenames.add(project.getName()); |
|
907 |
//// sampleCorpusLoaded.add(project.getName()); |
|
908 |
//// } |
|
909 |
// |
|
910 |
// } catch (Exception e) { |
|
911 |
// System.out.println(TXMUIMessages.ApplicationWorkbenchAdvisor_51+zipFile); |
|
912 |
// org.txm.utils.logger.Log.printStackTrace(e); |
|
913 |
// } |
|
914 |
// } |
|
859 |
File previousCorporaDirectory = new File(System.getProperty("user.home"), "TXM/corpora"); |
|
860 |
|
|
861 |
|
|
862 |
|
|
863 |
// TXM-0.8.0 previous installation corpora |
|
864 |
if (corporaDir.listFiles(IOUtils.HIDDENFILE_FILTER).length > 0) { // not a new install, restore previous corpora |
|
865 |
Log.info(NLS.bind(TXMUIMessages.installingPreviousCorpusFromP0, corporaDir)); |
|
866 |
JobHandler job = LoadBinaryCorporaDirectory.loadBinaryCorpusFromCorporaDirectory(corporaDir, false, true); |
|
867 |
try { |
|
868 |
job.join(); |
|
869 |
} catch (InterruptedException e) { |
|
870 |
// TODO Auto-generated catch block |
|
871 |
e.printStackTrace(); |
|
872 |
} |
|
915 | 873 |
} |
874 |
|
|
875 |
// TXM previous installation corpora |
|
876 |
if (previousCorporaDirectory.exists()) { // new installation (empty corpora directory) |
|
877 |
Log.info(NLS.bind(TXMUIMessages.installingPreviousCorpusFromP0, previousCorporaDirectory)); |
|
878 |
JobHandler job = LoadBinaryCorporaDirectory.loadBinaryCorpusFromCorporaDirectory(previousCorporaDirectory, false, false); |
|
879 |
try { |
|
880 |
job.join(); |
|
881 |
} catch (InterruptedException e) { |
|
882 |
// TODO Auto-generated catch block |
|
883 |
e.printStackTrace(); |
|
884 |
} |
|
885 |
} |
|
916 | 886 |
|
917 |
// for (File projectDir : corporaDir.listFiles(IOUtils.FILTER_HIDDEN)) { // load sample corpus and previous corpus as well |
|
918 |
// if (projectDir.isDirectory()) { |
|
919 |
// Project project; |
|
920 |
// try { |
|
921 |
// |
|
922 |
// } catch (Exception e) { |
|
923 |
// // TODO Auto-generated catch block |
|
924 |
// e.printStackTrace(); |
|
925 |
// } |
|
926 |
// } |
|
927 |
// } |
|
887 |
// load TXM-0.8.0 sample corpora (from the install directory) |
|
888 |
if (sampleCorporaDirectory.exists()) { |
|
928 | 889 |
|
929 |
// after loading sample corpora, restore older corpus |
|
930 |
// if (backup.exists()) { |
|
931 |
// System.out.print(NLS.bind(TXMUIMessages.ApplicationWorkbenchAdvisor_53, backup)); |
|
932 |
// monitor.setTaskName(NLS.bind(TXMUIMessages.ApplicationWorkbenchAdvisor_53, backup)); |
|
933 |
// |
|
934 |
// File[] corpusDirs = backup.listFiles(IOUtils.FILTER_HIDDEN); |
|
935 |
// |
|
936 |
// if (corpusDirs != null) { |
|
937 |
// |
|
938 |
// for (File corpusDir : corpusDirs) { // fix corpus name lowercase letters |
|
939 |
// if (!corpusDir.getName().equals(corpusDir.getName().toUpperCase())) { |
|
940 |
// File upperCasedCorpusDir = new File(corpusDir.getParentFile(), corpusDir.getName().toUpperCase()); |
|
941 |
// if (!upperCasedCorpusDir.exists()) { |
|
942 |
// corpusDir.renameTo(upperCasedCorpusDir); |
|
943 |
// } |
|
944 |
// } |
|
945 |
// } |
|
946 |
// corpusDirs = backup.listFiles(IOUtils.FILTER_HIDDEN); |
|
947 |
// |
|
948 |
// ArrayList<String> notMoved = new ArrayList<String>(); |
|
949 |
// ArrayList<File> broken = new ArrayList<File>(); |
|
950 |
// |
|
951 |
// for (File corpusDir : corpusDirs) { |
|
952 |
// if (!corpusDir.isDirectory()) continue; // ignore |
|
953 |
// System.out.print("."); //$NON-NLS-1$ |
|
954 |
// File outdir = new File(corporaDir, corpusDir.getName()); |
|
955 |
// if (outdir.exists()) { |
|
956 |
// //System.out.println("This setup provides a new version of the "+corpusDir.getName()+" sample corpus. Skipping the backup of "+corpusDir); |
|
957 |
// notMoved.add(corpusDir.getName()); |
|
958 |
// continue; |
|
959 |
// } |
|
960 |
// |
|
961 |
// try { |
|
962 |
// Convert5To6 converter = new Convert5To6(corpusDir, outdir); |
|
963 |
// if (converter.is5(true)) { |
|
964 |
// if (!converter.start()) { |
|
965 |
// System.out.println(TXMUIMessages.ApplicationWorkbenchAdvisor_22+corpusDir+TXMUIMessages.ApplicationWorkbenchAdvisor_23); |
|
966 |
// System.out.println(TXMUIMessages.ApplicationWorkbenchAdvisor_54+corpusDir+TXMUIMessages.ApplicationWorkbenchAdvisor_55); |
|
967 |
// System.out.println(TXMUIMessages.ApplicationWorkbenchAdvisor_56); |
|
968 |
// broken.add(corpusDir); |
|
969 |
// } else { |
|
970 |
// //System.out.println(Messages.ApplicationWorkbenchAdvisor_57+outdir); |
|
971 |
// Base base = LoadBinaryCorpus.loadBinaryCorpus(outdir); |
|
972 |
// basenames.add(base.getName()); |
|
973 |
// } |
|
974 |
// } else { |
|
975 |
// if (Convert5To6.is6(corpusDir)) { |
|
976 |
// if (corpusDir.renameTo(outdir)) { |
|
977 |
// Base base = LoadBinaryCorpus.loadBinaryCorpus(outdir); |
|
978 |
// if (base == null) { |
|
979 |
// System.out.println(TXMUIMessages.ApplicationWorkbenchAdvisor_58+outdir); |
|
980 |
// System.out.println(TXMUIMessages.ApplicationWorkbenchAdvisor_59+corpusDir); |
|
981 |
// outdir.renameTo(corpusDir); |
|
982 |
// broken.add(corpusDir); |
|
983 |
// } else { |
|
984 |
// basenames.add(base.getName()); |
|
985 |
// } |
|
986 |
// } else { |
|
987 |
// System.out.println(TXMUIMessages.ApplicationWorkbenchAdvisor_24+corpusDir+TXMUIMessages.ApplicationWorkbenchAdvisor_26+outdir); |
|
988 |
// broken.add(corpusDir); |
|
989 |
// } |
|
990 |
// } else { |
|
991 |
// System.out.println(TXMUIMessages.ApplicationWorkbenchAdvisor_60+corpusDir+TXMUIMessages.ApplicationWorkbenchAdvisor_61); |
|
992 |
// broken.add(corpusDir); |
|
993 |
// } |
|
994 |
// } |
|
995 |
// } catch (Throwable e) { |
|
996 |
// System.out.println(TXMUIMessages.ApplicationWorkbenchAdvisor_59+corpusDir); |
|
997 |
// System.out.println(TXMUIMessages.ERROR+e); |
|
998 |
// outdir.renameTo(corpusDir); |
|
999 |
// } |
|
1000 |
// } |
|
1001 |
// System.out.println(); |
|
1002 |
// if (sampleCorpusLoaded.size() > 0) { |
|
1003 |
// if (sampleCorpusLoaded.size() == 1) { |
|
1004 |
// System.out.println(TXMUIMessages.bind(TXMUIMessages.ApplicationWorkbenchAdvisor_43_single, StringUtils.join(sampleCorpusLoaded, ", "))); //$NON-NLS-1$ |
|
1005 |
// } else { |
|
1006 |
// System.out.println(TXMUIMessages.bind(TXMUIMessages.ApplicationWorkbenchAdvisor_43, StringUtils.join(sampleCorpusLoaded, ", "))); //$NON-NLS-1$ |
|
1007 |
// } |
|
1008 |
// } |
|
1009 |
// |
|
1010 |
// if (broken.size() > 0) { |
|
1011 |
// errorbackup.mkdir(); |
|
1012 |
// System.out.println(TXMUIMessages.bind(TXMUIMessages.ApplicationWorkbenchAdvisor_48, StringUtils.join(broken, ", "), errorbackup)); //$NON-NLS-1$ |
|
1013 |
// for(File corpusDir : broken) { |
|
1014 |
// if (corpusDir.exists()) |
|
1015 |
// corpusDir.renameTo(new File(errorbackup, corpusDir.getName())); |
|
1016 |
// } |
|
1017 |
// } |
|
1018 |
// } |
|
1019 |
// } |
|
890 |
Log.info(TXMUIMessages.installingSampleCorpus); |
|
891 |
|
|
892 |
JobHandler job = LoadBinaryCorporaDirectory.loadBinaryCorpusFromCorporaDirectory(sampleCorporaDirectory, false, true); |
|
893 |
try { |
|
894 |
job.join(); |
|
895 |
} catch (InterruptedException e) { |
|
896 |
// TODO Auto-generated catch block |
|
897 |
e.printStackTrace(); |
|
898 |
} |
|
899 |
} |
|
1020 | 900 |
} |
1021 | 901 |
|
1022 |
|
|
1023 | 902 |
/** |
1024 | 903 |
* Executes the specified Groovy script file. |
1025 | 904 |
* @param script |
... | ... | |
1035 | 914 |
Log.printStackTrace(e); |
1036 | 915 |
} |
1037 | 916 |
} |
1038 |
|
|
1039 |
|
|
917 |
|
|
918 |
|
|
1040 | 919 |
/** |
1041 | 920 |
* Called just before the Toolbox is initialized |
1042 | 921 |
*/ |
tmp/org.txm.rcp/src/main/java/org/txm/rcp/messages/TXMUIMessages.java (revision 1616) | ||
---|---|---|
8 | 8 |
|
9 | 9 |
private static final String BUNDLE_NAME = "org.txm.rcp.messages.messages"; //$NON-NLS-1$ |
10 | 10 |
|
11 |
public static final String P0CorpusLoaded = null;
|
|
11 |
public static String P0CorpusLoaded;
|
|
12 | 12 |
|
13 | 13 |
public static String EMPTY; |
14 | 14 |
public static String Explorer_4; |
... | ... | |
506 | 506 |
|
507 | 507 |
public static String theP0CorpusWillBeCreatedFromTheP1Directory; |
508 | 508 |
|
509 |
public static String theP1P0CorpusWillBeReplaced;
|
|
509 |
public static String theP1P0CorpusWillBeReplaced; |
|
510 | 510 |
|
511 |
public static String installingPreviousCorpusFromP0; |
|
511 | 512 |
|
512 |
|
|
513 | 513 |
static { |
514 | 514 |
// initialize resource bundle |
515 | 515 |
Utf8NLS.initializeMessages(BUNDLE_NAME, TXMUIMessages.class); |
tmp/org.txm.rcp/src/main/java/org/txm/rcp/messages/messages.properties (revision 1616) | ||
---|---|---|
976 | 976 |
|
977 | 977 |
theP1P0CorpusWillBeReplaced=The {0} ({1}) corpus will be replaced. |
978 | 978 |
|
979 |
P0CorpusLoaded={0} corpus loaded. |
|
979 |
P0CorpusLoaded={0} corpus loaded. |
|
980 |
|
|
981 |
installingPreviousCorpusFromP0=Installing previous corpus from the {0} corpora directory. |
tmp/org.txm.rcp/src/main/java/org/txm/rcp/messages/messages_fr.properties (revision 1616) | ||
---|---|---|
974 | 974 |
|
975 | 975 |
zoomToSelectionColonCtrlPlusLeftMousePlusdrag = \ Zoomer sur la sélection : Ctrl + Clic Gauche + Glisser\n |
976 | 976 |
|
977 |
P0CorpusLoaded={0} corpus chargées. |
|
977 |
P0CorpusLoaded={0} corpus chargées. |
|
978 |
|
|
979 |
installingPreviousCorpusFromP0=Installation des corpus précédents depuis le répertoire {0}. |
tmp/org.txm.utils/src/org/txm/utils/logger/Log.java (revision 1616) | ||
---|---|---|
50 | 50 |
public class Log { |
51 | 51 |
/** The class id. */ |
52 | 52 |
public static final String id = "org.txm.utils.logger.Log"; |
53 |
|
|
53 |
|
|
54 | 54 |
/** The txm Logger. */ |
55 | 55 |
protected static TXMLogger txm; |
56 | 56 |
|
... | ... | |
59 | 59 |
|
60 | 60 |
/** The CONSOLE flags indicates if messages with level < INFO are printed in console*/ |
61 | 61 |
public static boolean CONSOLE = false; |
62 |
|
|
62 |
|
|
63 | 63 |
/** The caller information. */ |
64 | 64 |
protected static String sourceMethodName; |
65 | 65 |
protected static String sourceClassName; |
66 | 66 |
/** The logger frame list. */ |
67 | 67 |
protected static List<String> frameList; |
68 |
|
|
68 |
|
|
69 | 69 |
static { |
70 | 70 |
//System.out.println("INIT TXMLOGGER"); |
71 | 71 |
txm = new TXMLogger("TXMFileLogger", null); |
... | ... | |
93 | 93 |
// System.out.println("set print in file: "+b); |
94 | 94 |
String filename = null; |
95 | 95 |
if (b) { |
96 |
try {
|
|
97 |
SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd"); //$NON-NLS-1$
|
|
98 |
|
|
99 |
filename = System.getProperty("java.io.tmpdir")+"/TXM-" + f.format(new Date()) + ".log"; //$NON-NLS-1$ //$NON-NLS-2$
|
|
100 |
|
|
101 |
fh = new FileHandler(filename, false);
|
|
102 |
System.out.println(UtilsCoreMessages.Log_3 + new File(filename).getAbsolutePath());
|
|
103 |
fh.setFormatter(new SimpleFormatter());
|
|
104 |
fh.setEncoding("UTF-8"); //$NON-NLS-1$
|
|
105 |
txm.addHandler(fh);
|
|
106 |
} catch (SecurityException e) {
|
|
107 |
printStackTrace(e);
|
|
108 |
} catch (IOException e) {
|
|
109 |
printStackTrace(e);
|
|
110 |
}
|
|
96 |
try { |
|
97 |
SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd"); //$NON-NLS-1$ |
|
98 |
|
|
99 |
filename = System.getProperty("java.io.tmpdir")+"/TXM-" + f.format(new Date()) + ".log"; //$NON-NLS-1$ //$NON-NLS-2$ |
|
100 |
|
|
101 |
fh = new FileHandler(filename, false); |
|
102 |
System.out.println(UtilsCoreMessages.Log_3 + new File(filename).getAbsolutePath()); |
|
103 |
fh.setFormatter(new SimpleFormatter()); |
|
104 |
fh.setEncoding("UTF-8"); //$NON-NLS-1$ |
|
105 |
txm.addHandler(fh); |
|
106 |
} catch (SecurityException e) { |
|
107 |
printStackTrace(e); |
|
108 |
} catch (IOException e) { |
|
109 |
printStackTrace(e); |
|
110 |
} |
|
111 | 111 |
} else { |
112 | 112 |
txm.removeHandler(fh); |
113 | 113 |
} |
... | ... | |
124 | 124 |
if (b) { |
125 | 125 |
if (txm.getHandlers().length == 0 && logfiledir.exists()) { |
126 | 126 |
try { |
127 |
|
|
127 |
|
|
128 | 128 |
fh = new FileHandler( |
129 |
logfiledir.getAbsolutePath()
|
|
130 |
+ "/TXM-" + f.format(new Date()) + ".log", false); //$NON-NLS-1$ //$NON-NLS-2$
|
|
129 |
logfiledir.getAbsolutePath() |
|
130 |
+ "/TXM-" + f.format(new Date()) + ".log", false); //$NON-NLS-1$ //$NON-NLS-2$ |
|
131 | 131 |
System.out.println(UtilsCoreMessages.Log_5 |
132 | 132 |
+ logfiledir.getAbsolutePath() |
133 | 133 |
+ "TXM-" + f.format(new Date()) + ".log"); //$NON-NLS-2$ //$NON-NLS-1$ |
... | ... | |
142 | 142 |
txm.removeHandler(fh); |
143 | 143 |
} |
144 | 144 |
} |
145 |
|
|
145 |
|
|
146 | 146 |
public static void addHandler(Handler handler) { |
147 | 147 |
txm.addHandler(handler); |
148 | 148 |
} |
149 |
|
|
149 |
|
|
150 | 150 |
public static void removeHandler(Handler handler) { |
151 | 151 |
txm.addHandler(handler); |
152 | 152 |
} |
... | ... | |
167 | 167 |
message.append(t.getFileName() |
168 | 168 |
+ ": " + t.getMethodName() + ", l." //$NON-NLS-1$ //$NON-NLS-2$ |
169 | 169 |
+ t.getLineNumber() + " -> " + e.toString()); //$NON-NLS-1$ |
170 |
|
|
170 |
|
|
171 | 171 |
if ("true".equals(log_stacktrace_boolean)) { |
172 | 172 |
message.append(UtilsCoreMessages.Log_8); |
173 | 173 |
for (StackTraceElement se : e.getStackTrace()) |
... | ... | |
190 | 190 |
public static void setPrintInConsole(boolean b) { |
191 | 191 |
CONSOLE = b; |
192 | 192 |
} |
193 |
|
|
193 |
|
|
194 | 194 |
/** |
195 | 195 |
* Sets the prints the in console. |
196 | 196 |
* |
... | ... | |
200 | 200 |
return txm.getUseParentHandlers(); |
201 | 201 |
} |
202 | 202 |
|
203 |
|
|
203 |
|
|
204 | 204 |
/** |
205 | 205 |
* Log a severe message using the default flag |
206 | 206 |
* |
... | ... | |
217 | 217 |
* @param message |
218 | 218 |
*/ |
219 | 219 |
public static void severe(String message) { |
220 |
|
|
220 | 221 |
if (Level.SEVERE.intValue() >= txm.getLevel().intValue()) { |
221 | 222 |
System.out.println(message); |
222 |
System.out.println("STACKTRACE:"); |
|
223 |
|
|
224 |
StackTraceElement[] st = Thread.currentThread().getStackTrace(); |
|
225 |
int stL = 0; |
|
226 |
int maxClassNameLength = 0; |
|
227 |
int maxMethodNameLength = 0; |
|
228 |
|
|
229 |
for (StackTraceElement t : st) { |
|
230 |
String cn = t.getClassName(); |
|
231 |
if (cn.startsWith("org.txm.") && !cn.startsWith(Log.class.getName())) { |
|
232 |
int cns = cn.length(); |
|
233 |
if (cns > maxClassNameLength) maxClassNameLength = cns; |
|
234 |
int mns = t.getMethodName().length(); |
|
235 |
if (mns > maxMethodNameLength) maxMethodNameLength = mns; |
|
236 |
stL++; |
|
237 |
} |
|
238 |
} |
|
239 |
|
|
240 |
int stLs = (int)Math.log10(stL)+1; |
|
241 |
String format = String.format("[%%%dd] %%%ds.%%%ds %%s, %%s", stLs, maxClassNameLength, maxMethodNameLength); |
|
242 |
|
|
243 |
System.out.println("Stacktrace: "); |
|
223 | 244 |
int n = 1; |
224 |
for (StackTraceElement t : Thread.currentThread().getStackTrace()) {
|
|
245 |
for (StackTraceElement t : st) {
|
|
225 | 246 |
if (t.getClassName().startsWith("org.txm.") && !t.getClassName().startsWith(Log.class.getName())) { |
226 |
System.out.println(String.format("[%2d]\t",n++)+t); |
|
227 |
//System.out.println(""+(n++)+"\t"+t); |
|
247 |
System.out.println(String.format(format, n++, t.getClassName(), t.getMethodName(), t.getFileName(), t.getLineNumber())); |
|
228 | 248 |
} |
229 | 249 |
} |
250 |
|
|
251 |
// System.out.println("Stacktrace: "); |
|
252 |
// int n = 1; |
|
253 |
// for (StackTraceElement t : Thread.currentThread().getStackTrace()) { |
|
254 |
// if (t.getClassName().startsWith("org.txm.") && !t.getClassName().startsWith(Log.class.getName())) { |
|
255 |
// System.out.println(String.format("[%2d]\t",n++)+t); |
|
256 |
// } |
|
257 |
// } |
|
230 | 258 |
} |
231 |
|
|
259 |
|
|
232 | 260 |
txm.severe(message); |
233 | 261 |
} |
234 | 262 |
|
... | ... | |
250 | 278 |
public static void warning(String message) { |
251 | 279 |
if (Level.WARNING.intValue() >= txm.getLevel().intValue()) { |
252 | 280 |
System.out.println(message); |
253 |
System.out.print("AT: "); |
|
254 |
int n = 1; |
|
255 |
for (StackTraceElement t : Thread.currentThread().getStackTrace()) { |
|
256 |
if (t.getClassName().startsWith("org.txm.") && !t.getClassName().startsWith(Log.class.getName())) { |
|
257 |
System.out.println(t); |
|
258 |
break; |
|
259 |
} |
|
260 |
} |
|
281 |
// System.out.print("AT: ");
|
|
282 |
// int n = 1;
|
|
283 |
// for (StackTraceElement t : Thread.currentThread().getStackTrace()) {
|
|
284 |
// if (t.getClassName().startsWith("org.txm.") && !t.getClassName().startsWith(Log.class.getName())) {
|
|
285 |
// System.out.println(t);
|
|
286 |
// break;
|
|
287 |
// }
|
|
288 |
// }
|
|
261 | 289 |
} |
262 | 290 |
txm.warning(message); |
263 | 291 |
} |
264 | 292 |
|
265 |
|
|
293 |
|
|
266 | 294 |
/** |
267 | 295 |
* Log an info message using the default flag |
268 | 296 |
* |
... | ... | |
272 | 300 |
info(t.getLocalizedMessage()); |
273 | 301 |
printStackTrace(t); |
274 | 302 |
} |
275 |
|
|
303 |
|
|
276 | 304 |
/** |
277 | 305 |
* Log an info message |
278 | 306 |
* |
... | ... | |
286 | 314 |
txm.info(message); |
287 | 315 |
} |
288 | 316 |
|
289 |
|
|
317 |
|
|
290 | 318 |
/** |
291 | 319 |
* Log an info message |
292 | 320 |
* |
... | ... | |
299 | 327 |
} |
300 | 328 |
txm.finest(message); |
301 | 329 |
} |
302 |
|
|
330 |
|
|
303 | 331 |
/** |
304 | 332 |
* Log an info message |
305 | 333 |
* |
... | ... | |
312 | 340 |
} |
313 | 341 |
txm.fine(message); |
314 | 342 |
} |
315 |
|
|
343 |
|
|
316 | 344 |
/** |
317 | 345 |
* Log an info message |
318 | 346 |
* |
... | ... | |
326 | 354 |
txm.finer(message); |
327 | 355 |
} |
328 | 356 |
|
329 |
|
|
357 |
|
|
330 | 358 |
public static boolean log_stacktrace_boolean = false; |
331 |
|
|
359 |
|
|
332 | 360 |
/** |
333 | 361 |
* Log a stacktrace if the 'Log.log_stacktrace_boolean' is set to true |
334 | 362 |
* |
... | ... | |
343 | 371 |
public static Level getLevel() { |
344 | 372 |
return txm.getLevel(); |
345 | 373 |
} |
346 |
|
|
374 |
|
|
347 | 375 |
public static boolean isPrintingErrors() { |
348 | 376 |
if (txm == null) return false; |
349 | 377 |
return txm.getLevel().intValue() <= Level.INFO.intValue(); |
350 | 378 |
} |
351 |
|
|
352 | 379 |
|
380 |
|
|
353 | 381 |
/** |
354 | 382 |
* Method from LogRecord to determine if a frame is a logger frame |
355 | 383 |
* |
Formats disponibles : Unified diff