Révision 1515
tmp/org.txm.core/src/java/org/txm/objects/CorpusBuild.java (revision 1515) | ||
---|---|---|
172 | 172 |
* @return the base directory |
173 | 173 |
*/ |
174 | 174 |
public File getProjectDirectory() { |
175 |
return getProject().getProjectDirectory(); |
|
175 |
if (getProject() != null) { |
|
176 |
return getProject().getProjectDirectory(); |
|
177 |
} |
|
178 |
return null; |
|
176 | 179 |
} |
177 | 180 |
|
178 | 181 |
public String getCQLLimitQuery() { |
tmp/org.txm.annotation.kr.core/src/org/txm/annotation/kr/core/KRAnnotationEngine.java (revision 1515) | ||
---|---|---|
421 | 421 |
|
422 | 422 |
if (r instanceof MainCorpus && "clean".equals(state)) { |
423 | 423 |
MainCorpus c = (MainCorpus)r; |
424 |
if (!c.getProjectDirectory().exists()) { |
|
425 |
return; |
|
426 |
} |
|
424 | 427 |
File buildDirectory = new File(c.getProjectDirectory(), "temporary_annotations/"+c.getID()); |
425 | 428 |
if (buildDirectory.exists()) { |
426 | 429 |
DeleteDir.deleteDirectory(buildDirectory); |
tmp/org.txm.rcp/src/main/java/org/txm/rcp/views/fileexplorer/MacroExplorer.java (revision 1515) | ||
---|---|---|
236 | 236 |
IWorkbenchWindow acWindow = TXMWindows.getActiveWindow(); |
237 | 237 |
IWorkbenchPart page = acWindow.getActivePage().getActivePart(); |
238 | 238 |
|
239 |
ExecuteGroovyMacro.execute(selectedItem.getAbsolutePath(), page, selection); |
|
239 |
ExecuteGroovyMacro.execute(selectedItem.getAbsolutePath(), page, selection, "");
|
|
240 | 240 |
} else { |
241 | 241 |
changeState(selection); |
242 | 242 |
} |
tmp/org.txm.rcp/src/main/java/org/txm/rcp/handlers/scripts/ExecuteLastGroovyScript.java (revision 1515) | ||
---|---|---|
90 | 90 |
return; |
91 | 91 |
} |
92 | 92 |
|
93 |
ExecuteGroovyScript.executeScript(currentRootDir, lastScript.getAbsolutePath(), page, selection, false); |
|
93 |
ExecuteGroovyScript.executeScript(currentRootDir, lastScript.getAbsolutePath(), page, selection, false, "");
|
|
94 | 94 |
} |
95 | 95 |
} |
tmp/org.txm.rcp/src/main/java/org/txm/rcp/handlers/scripts/ExecuteGroovyMacro.java (revision 1515) | ||
---|---|---|
62 | 62 |
|
63 | 63 |
String filenameParameter = event |
64 | 64 |
.getParameter("org.txm.rcp.command.parameter.file"); //$NON-NLS-1$ |
65 |
String stringArgs = event.getParameter("args"); //$NON-NLS-1$ |
|
65 | 66 |
|
66 |
|
|
67 | 67 |
// the file to execute |
68 | 68 |
String result = ""; //$NON-NLS-1$ |
69 | 69 |
IWorkbenchPart page = HandlerUtil.getActiveWorkbenchWindow(event) |
... | ... | |
111 | 111 |
LastOpened.set(ID, new File(result)); |
112 | 112 |
} |
113 | 113 |
|
114 |
execute(result, page, selection); |
|
114 |
execute(result, page, selection, stringArgs);
|
|
115 | 115 |
return null; |
116 | 116 |
} |
117 | 117 |
|
118 |
public static void execute(String scriptpath, IWorkbenchPart page, ISelection selection) { |
|
118 |
public static void execute(String scriptpath, IWorkbenchPart page, ISelection selection, String stringArgs) {
|
|
119 | 119 |
IPreferencesService service = Platform.getPreferencesService(); |
120 | 120 |
String scriptRootDir = Toolbox.getTxmHomePath() + "/scripts"; //$NON-NLS-1$ |
121 | 121 |
File currentRootDir = new File(scriptRootDir, "groovy/user"); //$NON-NLS-1$ |
122 | 122 |
|
123 |
ExecuteGroovyScript.executeScript(currentRootDir, scriptpath, page, selection, false); |
|
123 |
ExecuteGroovyScript.executeScript(currentRootDir, scriptpath, page, selection, false, stringArgs);
|
|
124 | 124 |
} |
125 | 125 |
} |
tmp/org.txm.rcp/src/main/java/org/txm/rcp/handlers/scripts/ExecuteGroovyScript.java (revision 1515) | ||
---|---|---|
83 | 83 |
|
84 | 84 |
String filenameParameter = event |
85 | 85 |
.getParameter("org.txm.rcp.command.parameter.file"); //$NON-NLS-1$ |
86 |
String stringArgs = event.getParameter("args"); //$NON-NLS-1$ |
|
86 | 87 |
|
87 | 88 |
// the file to execute |
88 | 89 |
String result = ""; //$NON-NLS-1$ |
... | ... | |
130 | 131 |
if (result == null) return null; |
131 | 132 |
LastOpened.set(ID, new File(result)); |
132 | 133 |
} |
133 |
executeScript(result, page, sel); |
|
134 |
executeScript(result, page, sel, stringArgs);
|
|
134 | 135 |
|
135 | 136 |
return null; |
136 | 137 |
} |
... | ... | |
142 | 143 |
* @param page current active page, might be null |
143 | 144 |
* @param sel current selection, might be null |
144 | 145 |
*/ |
145 |
public static void executeScript(String scriptpath, final IWorkbenchPart page, final ISelection selection, boolean modal) { |
|
146 |
public static void executeScript(String scriptpath, final IWorkbenchPart page, final ISelection selection, boolean modal, String stringArgs) {
|
|
146 | 147 |
IPreferencesService service = Platform.getPreferencesService(); |
147 | 148 |
// String scriptRootDir = service.getString(Application.PLUGIN_ID, |
148 | 149 |
// ScriptPreferencePage.SCRIPT_ROOT_DIR, |
... | ... | |
151 | 152 |
String scriptRootDir = Toolbox.getTxmHomePath() + "/scripts"; //$NON-NLS-1$ |
152 | 153 |
File currentRootDir = new File(scriptRootDir, "groovy/user"); //$NON-NLS-1$ |
153 | 154 |
|
154 |
executeScript(currentRootDir, scriptpath, page, selection, modal); |
|
155 |
executeScript(currentRootDir, scriptpath, page, selection, modal, stringArgs);
|
|
155 | 156 |
} |
156 | 157 |
|
157 | 158 |
/** |
... | ... | |
161 | 162 |
* @param page current active page, might be null |
162 | 163 |
* @param sel current selection, might be null |
163 | 164 |
*/ |
165 |
public static void executeScript(String scriptpath, final IWorkbenchPart page, final ISelection selection, String stringArgs) { |
|
166 |
executeScript(scriptpath, page, selection, false, null); |
|
167 |
} |
|
168 |
|
|
169 |
/** |
|
170 |
* |
|
171 |
* @param currentRootDir |
|
172 |
* @param scriptpath |
|
173 |
* @param page current active page, might be null |
|
174 |
* @param sel current selection, might be null |
|
175 |
*/ |
|
164 | 176 |
public static void executeScript(String scriptpath, final IWorkbenchPart page, final ISelection selection) { |
165 |
executeScript(scriptpath, page, selection, false); |
|
177 |
executeScript(scriptpath, page, selection, false, null);
|
|
166 | 178 |
} |
167 | 179 |
|
168 | 180 |
/** |
... | ... | |
172 | 184 |
* @param page current active page, might be null |
173 | 185 |
* @param sel current selection, might be null |
174 | 186 |
*/ |
175 |
public static void executeScript(final File currentRootDir, String scriptpath, final IWorkbenchPart page, final ISelection sel, final boolean modal) { |
|
187 |
public static void executeScript(final File currentRootDir, String scriptpath, final IWorkbenchPart page, final ISelection sel, final boolean modal, final String stringArgs) {
|
|
176 | 188 |
// check script |
177 | 189 |
final File scriptfile = new File(scriptpath); |
178 | 190 |
if (!scriptfile.exists()) { |
... | ... | |
236 | 248 |
binding.setVariable("corpusViewSelections", corpusViewSelections); //$NON-NLS-1$ |
237 | 249 |
binding.setProperty("monitor", this); //$NON-NLS-1$ |
238 | 250 |
binding.setProperty("MONITOR", this); //$NON-NLS-1$ |
251 |
binding.setProperty("stringArgs", stringArgs); //$NON-NLS-1$ |
|
239 | 252 |
binding.setProperty("gse", gse); |
240 | 253 |
|
241 | 254 |
System.out.println(NLS.bind(TXMUIMessages.executingGroovyScript, scriptfile.getName())); |
tmp/org.txm.rcp/src/main/java/org/txm/rcp/handlers/results/DeleteObject.java (revision 1515) | ||
---|---|---|
53 | 53 |
import org.txm.core.engines.EngineType; |
54 | 54 |
import org.txm.core.messages.TXMCoreMessages; |
55 | 55 |
import org.txm.core.results.TXMResult; |
56 |
import org.txm.objects.Project; |
|
56 | 57 |
import org.txm.rcp.StatusLine; |
57 | 58 |
import org.txm.rcp.editors.TXMEditor; |
58 | 59 |
import org.txm.rcp.messages.TXMUIMessages; |
... | ... | |
264 | 265 |
if (r.isLocked()) return deleted; |
265 | 266 |
|
266 | 267 |
if (r instanceof MainCorpus) { |
267 |
((MainCorpus)o).getProject().delete(); |
|
268 |
Project p = ((MainCorpus)o).getProject(); |
|
269 |
if (p != null) { |
|
270 |
p.delete(); |
|
271 |
} else { |
|
272 |
((MainCorpus)o).delete(); |
|
273 |
} |
|
268 | 274 |
} else { |
269 | 275 |
r.delete(); |
270 | 276 |
} |
tmp/org.txm.rcp/src/main/java/org/txm/rcp/handlers/files/DownloadFile.java (revision 1515) | ||
---|---|---|
11 | 11 |
import org.eclipse.core.commands.AbstractHandler; |
12 | 12 |
import org.eclipse.core.commands.ExecutionEvent; |
13 | 13 |
import org.eclipse.core.commands.ExecutionException; |
14 |
import org.eclipse.osgi.util.NLS; |
|
14 | 15 |
import org.txm.rcp.utils.DownloadJobHandler; |
15 | 16 |
import org.txm.utils.logger.Log; |
16 | 17 |
|
... | ... | |
24 | 25 |
|
25 | 26 |
public static boolean download(URL url, File outputDirectory) { |
26 | 27 |
String filename = url.getFile(); |
27 |
File outfile = new File(outputDirectory, filename); |
|
28 |
|
|
29 |
File outfile = new File(outputDirectory, new File(filename).getName()); |
|
28 | 30 |
Boolean done = false; |
29 | 31 |
|
30 | 32 |
BufferedOutputStream writeFile = null; |
... | ... | |
45 | 47 |
} else { |
46 | 48 |
done = false; |
47 | 49 |
|
48 |
DownloadJobHandler job = new DownloadJobHandler("Download "+url, outfile, contentLength, done); |
|
49 |
job.schedule(); |
|
50 |
System.out.print(NLS.bind("Downloading {0} file...", url)); |
|
51 |
|
|
52 |
DownloadJobHandler job = new DownloadJobHandler("Download "+url, url, outfile, contentLength, done); |
|
53 |
job.setUser(true); |
|
54 |
job.schedule(); |
|
55 |
|
|
56 |
try { |
|
57 |
job.join(); |
|
58 |
} catch (InterruptedException e) { |
|
59 |
// TODO Auto-generated catch block |
|
60 |
e.printStackTrace(); |
|
61 |
} |
|
62 |
|
|
63 |
// writeFile = new BufferedOutputStream(new FileOutputStream(outfile)); |
|
64 |
// input = connection.getInputStream(); |
|
65 |
// byte[] buffer = new byte[1024]; |
|
66 |
// int read; |
|
67 |
// while ((read = input.read(buffer)) > 0) { |
|
68 |
// writeFile.write(buffer, 0, read); |
|
69 |
// } |
|
70 |
// |
|
71 |
// writeFile.close(); |
|
72 |
// input.close(); |
|
73 |
// done = true; |
|
74 |
// System.out.println("Done."); |
|
50 | 75 |
|
51 |
writeFile = new BufferedOutputStream(new FileOutputStream(outfile)); |
|
52 |
input = connection.getInputStream(); |
|
53 |
byte[] buffer = new byte[1024]; |
|
54 |
int read; |
|
55 |
while ((read = input.read(buffer)) > 0) |
|
56 |
writeFile.write(buffer, 0, read); |
|
57 |
|
|
58 |
done = true; |
|
59 |
job.done(); |
|
60 | 76 |
} |
61 | 77 |
} |
62 | 78 |
} catch (IOException e) { |
tmp/org.txm.rcp/src/main/java/org/txm/rcp/utils/DownloadJobHandler.java (revision 1515) | ||
---|---|---|
27 | 27 |
// |
28 | 28 |
package org.txm.rcp.utils; |
29 | 29 |
|
30 |
import java.io.BufferedOutputStream; |
|
30 | 31 |
import java.io.File; |
32 |
import java.io.FileOutputStream; |
|
33 |
import java.io.IOException; |
|
34 |
import java.io.InputStream; |
|
35 |
import java.net.HttpURLConnection; |
|
36 |
import java.net.URL; |
|
31 | 37 |
|
32 | 38 |
import org.eclipse.core.runtime.IProgressMonitor; |
33 | 39 |
import org.eclipse.core.runtime.IStatus; |
34 | 40 |
import org.eclipse.core.runtime.Status; |
41 |
import org.eclipse.osgi.util.NLS; |
|
35 | 42 |
import org.txm.rcp.messages.TXMUIMessages; |
43 |
import org.txm.utils.logger.Log; |
|
36 | 44 |
|
37 | 45 |
// TODO: Auto-generated Javadoc |
38 | 46 |
/** |
... | ... | |
42 | 50 |
*/ |
43 | 51 |
public class DownloadJobHandler extends JobHandler { |
44 | 52 |
|
45 |
private File file; |
|
53 |
private File outfile;
|
|
46 | 54 |
private int contentLength; |
47 | 55 |
private Boolean done; |
56 |
|
|
57 |
BufferedOutputStream writeFile = null; |
|
58 |
HttpURLConnection connection = null; |
|
59 |
InputStream input = null; |
|
60 |
private URL url; |
|
48 | 61 |
|
49 |
public DownloadJobHandler(String title, File file, int contentLength, Boolean done) { |
|
62 |
public DownloadJobHandler(String title, URL url, File file, int contentLength, Boolean done) {
|
|
50 | 63 |
super(title); |
51 |
this.file = file; |
|
64 |
this.outfile = file;
|
|
52 | 65 |
this.contentLength = contentLength; |
53 | 66 |
this.done = done; |
67 |
this.url = url; |
|
54 | 68 |
} |
69 |
|
|
70 |
public void done() { |
|
71 |
this.done = true; |
|
72 |
} |
|
55 | 73 |
|
56 | 74 |
@Override |
57 | 75 |
protected IStatus run(final IProgressMonitor monitor) { |
58 | 76 |
this.runInit(monitor); |
59 |
//this.setCurrentMonitor(monitor); |
|
60 |
monitor.beginTask(TXMUIMessages.downloading, contentLength); |
|
61 |
long size = file.length(); |
|
62 |
while (!done) { |
|
63 |
try { |
|
64 |
wait(1000); |
|
65 |
long current_size = file.length(); |
|
66 |
monitor.worked((int) (current_size - size)); |
|
67 |
size = current_size; |
|
68 |
} catch (InterruptedException e) { |
|
69 |
// TODO Auto-generated catch block |
|
70 |
e.printStackTrace(); |
|
71 |
return Status.CANCEL_STATUS; |
|
77 |
// //this.setCurrentMonitor(monitor); |
|
78 |
// monitor.beginTask(TXMUIMessages.downloading, contentLength); |
|
79 |
// long size = file.length(); |
|
80 |
// while (!done) { |
|
81 |
// long current_size = file.length(); |
|
82 |
// monitor.worked((int) (current_size - size)); |
|
83 |
// size = current_size; |
|
84 |
// } |
|
85 |
// |
|
86 |
// BufferedOutputStream writeFile = new BufferedOutputStream(new FileOutputStream(outfile)); |
|
87 |
// input = connection.getInputStream(); |
|
88 |
// byte[] buffer = new byte[1024]; |
|
89 |
// int read; |
|
90 |
// while ((read = input.read(buffer)) > 0) { |
|
91 |
// writeFile.write(buffer, 0, read); |
|
92 |
// } |
|
93 |
// |
|
94 |
// writeFile.close(); |
|
95 |
// input.close(); |
|
96 |
|
|
97 |
try { |
|
98 |
connection = (HttpURLConnection)url.openConnection(); |
|
99 |
connection.connect(); |
|
100 |
|
|
101 |
// Check if the request is handled successfully |
|
102 |
if (connection.getResponseCode() / 100 == 2) { |
|
103 |
|
|
104 |
// size in bytes |
|
105 |
final int contentLength = connection.getContentLength(); |
|
106 |
|
|
107 |
if (contentLength == -1) { |
|
108 |
System.out.println("Could not get file size"); |
|
109 |
} else { |
|
110 |
done = false; |
|
111 |
|
|
112 |
System.out.print(NLS.bind("Downloading {0} file...", url)); |
|
113 |
|
|
114 |
// DownloadJobHandler job = new DownloadJobHandler("Download "+url, outfile, contentLength, done); |
|
115 |
// job.setUser(true); |
|
116 |
// job.schedule(); |
|
117 |
|
|
118 |
writeFile = new BufferedOutputStream(new FileOutputStream(outfile)); |
|
119 |
input = connection.getInputStream(); |
|
120 |
byte[] buffer = new byte[1024]; |
|
121 |
int read; |
|
122 |
while ((read = input.read(buffer)) > 0) { |
|
123 |
writeFile.write(buffer, 0, read); |
|
124 |
} |
|
125 |
|
|
126 |
writeFile.close(); |
|
127 |
input.close(); |
|
128 |
done = true; |
|
129 |
System.out.println("Done."); |
|
130 |
// job.done(); |
|
131 |
} |
|
72 | 132 |
} |
133 |
} catch (IOException e) { |
|
134 |
Log.printStackTrace(e); |
|
135 |
return Status.CANCEL_STATUS; |
|
136 |
} finally { |
|
137 |
if (writeFile != null) |
|
138 |
try { |
|
139 |
writeFile.close(); |
|
140 |
} catch (IOException e) { |
|
141 |
// TODO Auto-generated catch block |
|
142 |
e.printStackTrace(); |
|
143 |
} |
|
144 |
if (input != null) |
|
145 |
try { |
|
146 |
input.close(); |
|
147 |
} catch (IOException e) { |
|
148 |
// TODO Auto-generated catch block |
|
149 |
e.printStackTrace(); |
|
150 |
} |
|
151 |
if (connection != null) connection.disconnect(); |
|
73 | 152 |
} |
153 |
|
|
74 | 154 |
|
75 | 155 |
return Status.OK_STATUS; |
76 | 156 |
} |
tmp/org.txm.rcp/src/main/java/org/txm/rcp/commands/workspace/Load079BinaryCorpus.java (revision 1515) | ||
---|---|---|
124 | 124 |
} |
125 | 125 |
|
126 | 126 |
MainCorpus c = new MainCorpus(project); |
127 |
BaseOldParameters params = new BaseOldParameters(new File(project.getProjectDirectory(), "import.xml"));
|
|
127 |
BaseOldParameters params = new BaseOldParameters(new File(binCorpusDirectory, "import.xml"));
|
|
128 | 128 |
params.load(); |
129 | 129 |
c._load(params.getCorpusElement()); |
130 | 130 |
|
tmp/org.txm.rcp/src/main/java/org/txm/rcp/commands/workspace/LoadBinaryCorpus.java (revision 1515) | ||
---|---|---|
28 | 28 |
package org.txm.rcp.commands.workspace; |
29 | 29 |
|
30 | 30 |
import java.io.File; |
31 |
import java.net.MalformedURLException; |
|
32 |
import java.net.URL; |
|
31 | 33 |
|
32 | 34 |
import org.eclipse.core.commands.AbstractHandler; |
33 | 35 |
import org.eclipse.core.commands.ExecutionEvent; |
... | ... | |
47 | 49 |
import org.txm.objects.Project; |
48 | 50 |
import org.txm.rcp.StatusLine; |
49 | 51 |
import org.txm.rcp.commands.RestartTXM; |
52 |
import org.txm.rcp.handlers.files.DownloadFile; |
|
50 | 53 |
import org.txm.rcp.messages.TXMUIMessages; |
51 | 54 |
import org.txm.rcp.swt.dialog.LastOpened; |
52 | 55 |
import org.txm.rcp.utils.JobHandler; |
... | ... | |
81 | 84 |
|
82 | 85 |
// create dialog to get the corpus directory |
83 | 86 |
Shell shell = HandlerUtil.getActiveWorkbenchWindowChecked(event).getShell(); |
84 |
FileDialog dialog = new FileDialog(shell, SWT.OPEN); |
|
85 |
dialog.setFilterExtensions(new String[]{"*.txm", "*.zip"}); |
|
86 |
if (LastOpened.getFile(ID) != null) { |
|
87 |
dialog.setFilterPath(LastOpened.getFolder(ID)); |
|
88 |
dialog.setFileName(LastOpened.getFile(ID)); |
|
89 |
} |
|
90 | 87 |
|
91 |
if (dialog.open() != null) { |
|
92 |
final String path = dialog.getFilterPath(); |
|
93 |
final String filename = dialog.getFileName(); |
|
88 |
String url = event.getParameter("url"); |
|
94 | 89 |
|
95 |
zipFile = new File(path, filename); |
|
96 |
LastOpened.set(ID, zipFile); |
|
90 |
if (url != null && url.length() > 0 && url.endsWith(".txm")) { |
|
91 |
zipFile = new File(url); |
|
92 |
if (!zipFile.exists() && url.startsWith("http")) { |
|
93 |
try { |
|
94 |
URL u = new URL(url); |
|
95 |
File f = new File(url); |
|
96 |
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) { |
|
103 |
// TODO Auto-generated catch block |
|
104 |
e.printStackTrace(); |
|
105 |
} |
|
106 |
} |
|
107 |
} else { |
|
108 |
FileDialog dialog = new FileDialog(shell, SWT.OPEN); |
|
109 |
dialog.setFilterExtensions(new String[]{"*.txm", "*.zip"}); |
|
110 |
if (LastOpened.getFile(ID) != null) { |
|
111 |
dialog.setFilterPath(LastOpened.getFolder(ID)); |
|
112 |
dialog.setFileName(LastOpened.getFile(ID)); |
|
113 |
} |
|
97 | 114 |
|
98 |
return loadBinaryCorpusArchive(zipFile); |
|
115 |
if (dialog.open() != null) { |
|
116 |
final String path = dialog.getFilterPath(); |
|
117 |
final String filename = dialog.getFileName(); |
|
118 |
|
|
119 |
zipFile = new File(path, filename); |
|
120 |
LastOpened.set(ID, zipFile); |
|
121 |
} |
|
99 | 122 |
} |
100 |
return null; |
|
123 |
|
|
124 |
|
|
125 |
return loadBinaryCorpusArchive(zipFile); |
|
101 | 126 |
} |
102 | 127 |
|
103 | 128 |
/** |
... | ... | |
125 | 150 |
System.out.println(NLS.bind(TXMUIMessages.cannotReadTheFileP0, zipFile)); |
126 | 151 |
return false; |
127 | 152 |
} |
128 |
|
|
153 |
|
|
129 | 154 |
try { |
130 | 155 |
SearchEnginesManager.getCQPSearchEngine().stop(); |
131 | 156 |
} catch (Exception e1) { |
... | ... | |
135 | 160 |
|
136 | 161 |
//build binary dir path |
137 | 162 |
String basedirname = Zip.getRoot(zipFile); |
138 |
|
|
163 |
|
|
139 | 164 |
File corpusdir = new File(corporaDir, basedirname); |
140 | 165 |
Project p = Toolbox.workspace.getProject(basedirname); |
141 |
|
|
166 |
|
|
142 | 167 |
if (corpusdir.exists() || p != null) { |
143 | 168 |
boolean b = MessageDialog.openConfirm(Display.getCurrent().getActiveShell(), TXMUIMessages.warning, NLS.bind(TXMUIMessages.theP0CorpusDirectoryAlreadyExistsDoYouWantToReplaceIt, corpusdir.getName().toUpperCase())); |
144 | 169 |
if (b) { |
145 | 170 |
//TODO: to enable backup of binary corpus I need to be able to reload correctly a corpus in CQP corpus manager |
146 |
// backup = new File(corpusdir.getParentFile(), corpusdir.getName()+"-back"); //$NON-NLS-1$ |
|
147 |
// DeleteDir.deleteDirectory(backup); |
|
148 |
// if (backup.exists()) { |
|
149 |
// System.out.println(Messages.LoadBinaryCorpus_1+backup); |
|
150 |
// return false; |
|
151 |
// } |
|
152 |
// if (!corpusdir.renameTo(backup)) { |
|
153 |
// System.out.println(Messages.LoadBinaryCorpus_2+backup); |
|
154 |
// return false; |
|
155 |
// } |
|
156 |
|
|
171 |
// backup = new File(corpusdir.getParentFile(), corpusdir.getName()+"-back"); //$NON-NLS-1$
|
|
172 |
// DeleteDir.deleteDirectory(backup);
|
|
173 |
// if (backup.exists()) {
|
|
174 |
// System.out.println(Messages.LoadBinaryCorpus_1+backup);
|
|
175 |
// return false;
|
|
176 |
// }
|
|
177 |
// if (!corpusdir.renameTo(backup)) {
|
|
178 |
// System.out.println(Messages.LoadBinaryCorpus_2+backup);
|
|
179 |
// return false;
|
|
180 |
// }
|
|
181 |
|
|
157 | 182 |
if (p != null) { |
158 | 183 |
p.delete(); // the user said yes, so delete the previous project |
159 | 184 |
} else { |
160 | 185 |
DeleteDir.deleteDirectory(corpusdir); |
161 | 186 |
} |
162 |
|
|
187 |
|
|
163 | 188 |
if (corpusdir.exists()) { |
164 | 189 |
System.out.println("Error: previous binary corpus directory was not deleted: "+corpusdir); |
165 | 190 |
try { |
... | ... | |
188 | 213 |
protected IStatus run(final IProgressMonitor monitor) { |
189 | 214 |
this.runInit(monitor); |
190 | 215 |
final Project newProject2 = loadBinaryCorpusArchive(zipFile, this, monitor); |
191 |
|
|
216 |
|
|
192 | 217 |
this.syncExec(new Runnable() { |
193 | 218 |
@Override |
194 | 219 |
public void run() { |
195 |
|
|
220 |
|
|
196 | 221 |
try { |
197 | 222 |
SearchEnginesManager.getCQPSearchEngine().start(); |
198 | 223 |
} catch (Exception e) { |
199 | 224 |
e.printStackTrace(); |
200 | 225 |
} |
201 |
|
|
226 |
|
|
202 | 227 |
if (newProject2 != null) { |
203 | 228 |
newProject2.compute(); |
204 | 229 |
RestartTXM.reloadViews(); |
... | ... | |
224 | 249 |
|
225 | 250 |
return true; |
226 | 251 |
} |
227 |
|
|
252 |
|
|
228 | 253 |
/** |
229 | 254 |
* don't manage the SearchEngine restart |
230 | 255 |
* |
... | ... | |
236 | 261 |
public static Project loadBinaryCorpusArchive(File zipFile, JobHandler jobhandler, final IProgressMonitor monitor) { |
237 | 262 |
Project project = null; |
238 | 263 |
try { |
239 |
// SearchEngine engine = SearchEnginesManager.getCQPSearchEngine(); |
|
240 |
// if (engine.isRunning()) { |
|
241 |
// engine.stop(); |
|
242 |
// } |
|
243 |
|
|
264 |
// SearchEngine engine = SearchEnginesManager.getCQPSearchEngine();
|
|
265 |
// if (engine.isRunning()) {
|
|
266 |
// engine.stop();
|
|
267 |
// }
|
|
268 |
|
|
244 | 269 |
//CHECK ZIPPED FILE |
245 | 270 |
project = Load080BinaryCorpus.loadBinaryCorpus(zipFile, monitor); |
246 | 271 |
if (project == null) { |
... | ... | |
250 | 275 |
System.out.println("Error: cant load corpus from file="+zipFile); |
251 | 276 |
return null; |
252 | 277 |
} |
253 |
|
|
254 |
// final Project newProject2 = project; |
|
255 |
// jobhandler.syncExec(new Runnable() { |
|
256 |
// @Override |
|
257 |
// public void run() { |
|
258 |
// |
|
259 |
// SearchEngine engine = SearchEnginesManager.getCQPSearchEngine(); |
|
260 |
// if (!engine.isRunning()) { |
|
261 |
// try { |
|
262 |
// engine.start(monitor); |
|
263 |
// } catch (Exception e) { |
|
264 |
// // TODO Auto-generated catch block |
|
265 |
// e.printStackTrace(); |
|
266 |
// } |
|
267 |
// } |
|
268 |
// |
|
269 |
// RestartTXM.reloadViews(); |
|
270 |
// //System.out.println("Select newly loaded corpus: "+base2.getCorpora().values()); |
|
271 |
// CorporaView.select(newProject2.getChildren(MainCorpus.class)); |
|
272 |
// System.err.println(TXMUIMessages.info_txmIsReady); |
|
273 |
// StatusLine.setMessage(TXMUIMessages.info_txmIsReady); |
|
274 |
// } |
|
275 |
// }); |
|
278 |
|
|
279 |
// final Project newProject2 = project;
|
|
280 |
// jobhandler.syncExec(new Runnable() {
|
|
281 |
// @Override
|
|
282 |
// public void run() {
|
|
283 |
//
|
|
284 |
// SearchEngine engine = SearchEnginesManager.getCQPSearchEngine();
|
|
285 |
// if (!engine.isRunning()) {
|
|
286 |
// try {
|
|
287 |
// engine.start(monitor);
|
|
288 |
// } catch (Exception e) {
|
|
289 |
// // TODO Auto-generated catch block
|
|
290 |
// e.printStackTrace();
|
|
291 |
// }
|
|
292 |
// }
|
|
293 |
//
|
|
294 |
// RestartTXM.reloadViews();
|
|
295 |
// //System.out.println("Select newly loaded corpus: "+base2.getCorpora().values());
|
|
296 |
// CorporaView.select(newProject2.getChildren(MainCorpus.class));
|
|
297 |
// System.err.println(TXMUIMessages.info_txmIsReady);
|
|
298 |
// StatusLine.setMessage(TXMUIMessages.info_txmIsReady);
|
|
299 |
// }
|
|
300 |
// });
|
|
276 | 301 |
} catch (ThreadDeath td) { |
277 | 302 |
return null; |
278 | 303 |
} catch (Exception e2) { |
279 | 304 |
org.txm.rcp.utils.Logger.printStackTrace(e2); |
280 | 305 |
return null; |
281 | 306 |
} finally { |
282 |
|
|
307 |
|
|
283 | 308 |
} |
284 | 309 |
return project; |
285 | 310 |
} |
... | ... | |
299 | 324 |
return null; |
300 | 325 |
} |
301 | 326 |
|
302 |
// SearchEngine engine = SearchEnginesManager.getCQPSearchEngine(); |
|
303 |
// if (engine.isRunning()) { |
|
304 |
// engine.stop(); |
|
305 |
// } |
|
306 |
|
|
307 |
// //File txmregistry = new File(Toolbox.getTxmHomePath(), "registry"); //$NON-NLS-1$ |
|
308 |
// //txmregistry.mkdir(); |
|
309 |
// File txmcorpora = new File(Toolbox.getTxmHomePath(), "corpora"); //$NON-NLS-1$ |
|
310 |
// txmcorpora.mkdir(); |
|
311 |
// Project base = Toolbox.workspace.scanDirectory(binCorpusDirectory); |
|
312 |
// if (base == null) { |
|
313 |
// Log.severe(NLS.bind(TXMUIMessages.failedToLoadCorpusFromDirectoryColonP0WeCannotFindTheNecessaryComponents, binCorpusDirectory)); |
|
314 |
// return null; |
|
315 |
// } |
|
316 |
// |
|
317 |
// Toolbox.workspace.save(); |
|
318 |
|
|
327 |
// SearchEngine engine = SearchEnginesManager.getCQPSearchEngine();
|
|
328 |
// if (engine.isRunning()) {
|
|
329 |
// engine.stop();
|
|
330 |
// }
|
|
331 |
|
|
332 |
// //File txmregistry = new File(Toolbox.getTxmHomePath(), "registry"); //$NON-NLS-1$
|
|
333 |
// //txmregistry.mkdir();
|
|
334 |
// File txmcorpora = new File(Toolbox.getTxmHomePath(), "corpora"); //$NON-NLS-1$
|
|
335 |
// txmcorpora.mkdir();
|
|
336 |
// Project base = Toolbox.workspace.scanDirectory(binCorpusDirectory);
|
|
337 |
// if (base == null) {
|
|
338 |
// Log.severe(NLS.bind(TXMUIMessages.failedToLoadCorpusFromDirectoryColonP0WeCannotFindTheNecessaryComponents, binCorpusDirectory));
|
|
339 |
// return null;
|
|
340 |
// }
|
|
341 |
//
|
|
342 |
// Toolbox.workspace.save();
|
|
343 |
|
|
319 | 344 |
Project p = Toolbox.workspace.getProject(corpusDirectory.getName().toUpperCase().toUpperCase()); |
320 | 345 |
if (p != null) { |
321 | 346 |
System.out.println("Aborting loading of "+corpusDirectory+". A corpus with the same name already exists."); |
322 | 347 |
return null; |
323 | 348 |
} |
324 |
|
|
349 |
|
|
325 | 350 |
// seems like a binary corpus directory |
326 | 351 |
// copy files in the new current corpora directory |
327 | 352 |
File destDir = new File(Toolbox.workspace.getLocation(), corpusDirectory.getName().toUpperCase()); |
328 | 353 |
if (!destDir.equals(corpusDirectory)) { |
329 | 354 |
FileCopy.copyFiles(corpusDirectory, destDir); // the corpus directory is not in the corpora directory |
330 | 355 |
} |
331 |
|
|
356 |
|
|
332 | 357 |
Project project = null; |
333 | 358 |
File paramFile = new File(destDir, ".settings"); |
334 | 359 |
if (paramFile.exists() && paramFile.isDirectory()) { |
335 | 360 |
project = Load080BinaryCorpus.loadBinaryCorpusAsDirectory(destDir); |
336 |
// continue; |
|
361 |
// continue;
|
|
337 | 362 |
} |
338 |
|
|
363 |
|
|
339 | 364 |
paramFile = new File(destDir, "import.xml"); |
340 | 365 |
if (paramFile.exists()) { |
341 | 366 |
project = Load079BinaryCorpus.loadBinaryCorpusAsDirectory(destDir, null); |
342 |
// continue; |
|
367 |
// continue;
|
|
343 | 368 |
} |
344 |
|
|
369 |
|
|
345 | 370 |
return project; |
346 | 371 |
} |
347 | 372 |
} |
tmp/org.txm.rcp/src/main/java/org/txm/rcp/ApplicationWorkbenchAdvisor.java (revision 1515) | ||
---|---|---|
1021 | 1021 |
try { |
1022 | 1022 |
File startupScript = new File(Toolbox.getTxmHomePath(), "scripts/user/start.groovy");//$NON-NLS-1$ |
1023 | 1023 |
if (startupScript.exists() && startupScript.canRead()) { |
1024 |
ExecuteGroovyScript.executeScript(startupScript.getAbsolutePath(), null, null, true); |
|
1024 |
ExecuteGroovyScript.executeScript(startupScript.getAbsolutePath(), null, null, true, "");
|
|
1025 | 1025 |
} |
1026 | 1026 |
} catch(Exception e) { |
1027 | 1027 |
System.out.println(TXMCoreMessages.bind("Fail to execute 'start.groovy' script: {0}.", e)); |
... | ... | |
1037 | 1037 |
File stopScript = new File(Toolbox.getTxmHomePath(), "scripts/user/stop.groovy"); //$NON-NLS-1$ |
1038 | 1038 |
if (stopScript.exists() && stopScript.canRead()) { |
1039 | 1039 |
|
1040 |
ExecuteGroovyScript.executeScript(stopScript.getAbsolutePath(), null, null, true); |
|
1040 |
ExecuteGroovyScript.executeScript(stopScript.getAbsolutePath(), null, null, true, "");
|
|
1041 | 1041 |
} |
1042 | 1042 |
} catch(Exception e) { |
1043 | 1043 |
System.out.println(TXMCoreMessages.bind("Fail to execute 'stop.groovy' script: {0}.", e)); |
tmp/org.txm.rcp/plugin.xml (revision 1515) | ||
---|---|---|
2796 | 2796 |
name="%commandParameter.name.5" |
2797 | 2797 |
optional="true"> |
2798 | 2798 |
</commandParameter> |
2799 |
<commandParameter |
|
2800 |
id="args" |
|
2801 |
name="string args" |
|
2802 |
optional="true"> |
|
2803 |
</commandParameter> |
|
2799 | 2804 |
</command> |
2800 | 2805 |
<command |
2801 | 2806 |
categoryId="org.txm.rcp.categories.scripts" |
... | ... | |
2813 | 2818 |
name="%commandParameter.name.6" |
2814 | 2819 |
optional="true"> |
2815 | 2820 |
</commandParameter> |
2821 |
<commandParameter |
|
2822 |
id="args" |
|
2823 |
name="string args" |
|
2824 |
optional="true"> |
|
2825 |
</commandParameter> |
|
2816 | 2826 |
</command> |
2817 | 2827 |
<command |
2818 | 2828 |
categoryId="org.txm.rcp.categories.scripts" |
... | ... | |
2830 | 2840 |
defaultHandler="org.txm.rcp.commands.workspace.LoadBinaryCorpus" |
2831 | 2841 |
id="org.txm.rcp.commands.workspace.LoadBinaryCorpus" |
2832 | 2842 |
name="LoadBinaryCorpus"> |
2843 |
<commandParameter |
|
2844 |
id="url" |
|
2845 |
name="URL" |
|
2846 |
optional="true"> |
|
2847 |
</commandParameter> |
|
2833 | 2848 |
</command> |
2834 | 2849 |
</extension> |
2835 | 2850 |
<extension |
Formats disponibles : Unified diff