Révision 761

tmp/org.txm.rcp.feature/feature.xml (revision 761)
194 194
      <import plugin="org.eclipse.e4.ui.workbench.addons.swt" version="0.10.0" match="greaterOrEqual"/>
195 195
      <import plugin="org.eclipse.emf.ecore" version="2.7.0" match="greaterOrEqual"/>
196 196
      <import plugin="org.txm.ca.core"/>
197
      <import plugin="org.eclipse.jdt.core"/>
198
      <import plugin="org.eclipse.jdt.ui"/>
199
      <import plugin="org.eclipse.debug.ui"/>
200
      <import plugin="org.eclipse.jdt.debug"/>
201
      <import plugin="org.eclipse.jdt.launching"/>
202
      <import plugin="org.eclipse.jdt.debug.ui"/>
203
      <import plugin="org.eclipse.ltk.core.refactoring" version="3.5.0" match="greaterOrEqual"/>
204
      <import plugin="org.eclipse.ltk.ui.refactoring" version="3.4.100" match="greaterOrEqual"/>
205
      <import plugin="org.eclipse.jdt.core.manipulation" version="1.3.0" match="greaterOrEqual"/>
206
      <import plugin="org.eclipse.ui.views"/>
207
      <import plugin="org.eclipse.core.variables"/>
208
      <import plugin="org.eclipse.search" version="3.6.0" match="greaterOrEqual"/>
209 197
   </requires>
210 198

  
211 199
   <plugin
tmp/org.txm.setups/shared/debian/DEBIAN/preinst (revision 761)
1 1
#!/bin/bash
2 2

  
3
rm -rf "/usr/lib/TXM"
4
rm -rf "/usr/share/doc/txm"
5
rm -rf "/usr/share/lintian/overrides/txm"
6
rm -rf "/usr/share/TXM"
7
rm "/usr/share/applications/TXM.desktop"
8
rm "/usr/share/applications/TXM debug.desktop"
9
rm "/usr/bin/TXM"
3
if [ ! -d "/usr/lib/TXM" ]; then
4
	rm -rf "/usr/lib/TXM"
5
fi
10 6

  
7
if [ ! -d "/usr/share/doc/txm" ]; then
8
	rm -rf "/usr/share/doc/txm"
9
fi
11 10

  
11
if [ ! -d "/usr/share/lintian/overrides/txm" ]; then
12
	rm -rf "/usr/share/lintian/overrides/txm"
13
fi
14

  
15
if [ ! -d "/usr/share/TXM" ]; then
16
	rm -rf "/usr/share/TXM"
17
fi
18

  
19
if [ ! -f "/usr/share/applications/TXM.desktop" ]; then
20
	rm "/usr/share/applications/TXM.desktop"
21
	rm "/usr/share/applications/TXM debug.desktop"
22
fi
23

  
24
if [ ! -f "/usr/bin/TXM" ]; then
25
	rm "/usr/bin/TXM"
26
fi
27

  
28
echo "/usr/lib/TXM pre-installation done."
12 29

  
tmp/org.txm.rcp/plugin.xml (revision 761)
487 487
                     visible="false">
488 488
               </separator>
489 489
            </menu>
490
            <command
491
                  commandId="org.txm.rcp.commands.workspace.AddBase"
492
                  label="%command.label.50"
493
                  style="push">
494
            </command>
495 490
            <menu
491
                  id="menu.file.load"
492
                  label="Charger">
493
               <command
494
                     commandId="org.txm.rcp.commands.workspace.LoadBinaryCorpus"
495
                     label="un corpus (.txm)..."
496
                     style="push">
497
               </command>
498
               <command
499
                     commandId="org.txm.rcp.commands.workspace.LoadBinaryCorporaDirectory"
500
                     label="un répertoire de corpus binaires...."
501
                     style="push">
502
               </command>
503
               <separator
504
                     name="menu.file.load.separator.end"
505
                     visible="false">
506
               </separator>
507
            </menu>
508
            <menu
496 509
                  icon="icons/functions/export.png"
497 510
                  id="menu.file.export"
498 511
                  label="%menu.label.5">
......
2484 2497
      </command>
2485 2498
      <command
2486 2499
            defaultHandler="org.txm.rcp.commands.workspace.LoadBinaryCorpus"
2487
            id="org.txm.rcp.commands.workspace.AddBase"
2500
            id="org.txm.rcp.commands.workspace.LoadBinaryCorpus"
2488 2501
            name="%command.name.13">
2489 2502
      </command>
2490 2503
      <command
2504
            defaultHandler="org.txm.rcp.commands.workspace.LoadBinaryCorporaDirectory"
2505
            id="org.txm.rcp.commands.workspace.LoadBinaryCorporaDirectory"
2506
            name="Add bases">
2507
      </command>
2508
      <command
2491 2509
            defaultHandler="org.txm.rcp.commands.workspace.RemoveBase"
2492 2510
            id="org.txm.rcp.commands.workspace.RemoveBase"
2493 2511
            name="%command.name.14">
tmp/org.txm.rcp/src/main/java/org/txm/rcp/commands/workspace/LoadBinaryCorporaDirectory.java (revision 761)
1
// Copyright © 2010-2013 ENS de Lyon.
2
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
3
// Lyon 2, University of Franche-Comté, University of Nice
4
// Sophia Antipolis, University of Paris 3.
5
// 
6
// The TXM platform is free software: you can redistribute it
7
// and/or modify it under the terms of the GNU General Public
8
// License as published by the Free Software Foundation,
9
// either version 2 of the License, or (at your option) any
10
// later version.
11
// 
12
// The TXM platform is distributed in the hope that it will be
13
// useful, but WITHOUT ANY WARRANTY; without even the implied
14
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15
// PURPOSE. See the GNU General Public License for more
16
// details.
17
// 
18
// You should have received a copy of the GNU General
19
// Public License along with the TXM platform. If not, see
20
// http://www.gnu.org/licenses.
21
// 
22
// 
23
// 
24
// $LastChangedDate:$
25
// $LastChangedRevision:$
26
// $LastChangedBy:$ 
27
//
28
package org.txm.rcp.commands.workspace;
29

  
30
import java.io.File;
31
import java.util.ArrayList;
32

  
33
import org.eclipse.core.commands.AbstractHandler;
34
import org.eclipse.core.commands.ExecutionEvent;
35
import org.eclipse.core.commands.ExecutionException;
36
import org.eclipse.core.runtime.IProgressMonitor;
37
import org.eclipse.core.runtime.IStatus;
38
import org.eclipse.core.runtime.Status;
39
import org.eclipse.jface.dialogs.MessageDialog;
40
import org.eclipse.osgi.util.NLS;
41
import org.eclipse.swt.SWT;
42
import org.eclipse.swt.widgets.DirectoryDialog;
43
import org.eclipse.swt.widgets.Display;
44
import org.eclipse.swt.widgets.FileDialog;
45
import org.eclipse.swt.widgets.Shell;
46
import org.eclipse.ui.handlers.HandlerUtil;
47
import org.txm.EngineType;
48
import org.txm.Toolbox;
49
import org.txm.Toolbox;
50
import org.txm.core.preferences.TBXPreferences;
51
import org.txm.objects.Base;
52
import org.txm.objects.Project;
53
import org.txm.objects.Workspace;
54
import org.txm.rcp.StatusLine;
55
import org.txm.rcp.commands.RestartTXM;
56
import org.txm.rcp.messages.TXMUIMessages;
57
import org.txm.rcp.swt.dialog.LastOpened;
58
import org.txm.rcp.utils.JobHandler;
59
import org.txm.rcp.views.corpora.CorporaView;
60
import org.txm.searchengine.cqp.corpus.Corpus;
61
import org.txm.searchengine.cqp.corpus.MainCorpus;
62
import org.txm.utils.DeleteDir;
63
import org.txm.utils.io.FileCopy;
64
import org.txm.utils.logger.Log;
65
import org.txm.utils.zip.Zip;
66

  
67
// TODO: Auto-generated Javadoc
68
/**
69
 * Create a base from binary files of a base.
70
 *
71
 * @author mdecorde
72
 */
73
public class LoadBinaryCorporaDirectory extends AbstractHandler {
74

  
75
	private static final String ID = LoadBinaryCorporaDirectory.class.getName();
76

  
77
	@Override
78
	/**
79
	 * calling this command will : open a directory dialog and try to load the content of the selected directory
80
	 */
81
	public Object execute(ExecutionEvent event) throws ExecutionException {
82

  
83
		// create dialog to get the corpus directory
84
		Shell shell = HandlerUtil.getActiveWorkbenchWindowChecked(event).getShell();
85
		DirectoryDialog dialog = new DirectoryDialog(shell, SWT.OPEN);
86
		if (LastOpened.getFile(ID) != null) {
87
			dialog.setFilterPath(LastOpened.getFolder(ID));
88
		}
89

  
90
		if (dialog.open() != null) {
91

  
92
			File directory = new File(dialog.getFilterPath());
93

  
94
			if (directory.exists()) {
95

  
96
				LastOpened.set(ID, directory);
97
				return loadBinaryCorporaDirectory(directory);
98
			}
99
		}
100
		return null;
101
	}
102

  
103
	/**
104
	 * stop engines, load binary corpora from a directory, restart engines and refresh views
105
	 * 
106
	 * @param directory
107
	 * @return
108
	 */
109
	public static JobHandler loadBinaryCorporaDirectory(final File directory) {
110

  
111
		JobHandler jobhandler = new JobHandler("Scanning "+directory+"...", true) {
112
			@Override
113
			protected IStatus run(IProgressMonitor monitor) {
114
				this.runInit(monitor);
115

  
116
				File corporaDirectory = new File(Toolbox.getTXMHOMEPATH(), "corpora");
117
				if (!corporaDirectory.exists()) {
118
					System.out.println("Corpora directory not found. Aborting.");
119
					return Status.CANCEL_STATUS;
120
				}
121
				try {
122
					monitor.beginTask(TXMUIMessages.AddBase_27, 100);
123
					this.acquireSemaphore();
124
					Toolbox.getEngineManager(EngineType.SEARCH).stopEngines();
125
					this.releaseSemaphore();
126

  
127
					monitor.subTask(TXMUIMessages.AddBase_32);
128
					for (File corpusDirectory : directory.listFiles()) {
129

  
130
						if (corpusDirectory.isDirectory() && new File(corpusDirectory, "import.xml").exists()) {
131
							// seems like a binary corpus directory
132
							// copy files in the new current corpora directory
133
							File destDir = new File(corporaDirectory, corpusDirectory.getName());
134
							if (destDir.exists()) {
135
								System.out.println("Le répertoire "+destDir+" existe déjà. Chargement du corpus du répertoire "+corpusDirectory+" ignoré.");
136
								continue;
137
							}
138

  
139
							FileCopy.copyFiles(corpusDirectory, destDir);
140

  
141
							corpusDirectory = destDir;
142
						} else if (corpusDirectory.getName().endsWith(".txm")) {
143
							// corpusDirectory is a TXM archive
144
							String basedirname = Zip.getRoot(corpusDirectory); 
145
							Zip.decompress(corpusDirectory.getAbsolutePath(), corporaDirectory.getAbsolutePath(), false, this);
146
							corpusDirectory = new File(corporaDirectory, basedirname);
147
						} else {
148
							continue; // not a corpus
149
						}
150

  
151
						if (!corpusDirectory.exists()) {
152
							continue;
153
						}
154

  
155
						Base base = LoadBinaryCorpus.loadBinaryCorpus(corpusDirectory);
156
						if (base == null) {
157
							System.out.println("Fail to load binary corpus: "+corpusDirectory);
158
						}
159
					}
160

  
161
					monitor.subTask(TXMUIMessages.AddBase_33);
162

  
163
					this.acquireSemaphore();
164
					org.txm.Toolbox.restartWorkspace(monitor);
165
					Toolbox.getEngineManager(EngineType.SEARCH).restartEngines();
166
					this.releaseSemaphore();
167

  
168

  
169
					syncExec(new Runnable() {
170
						@Override
171
						public void run() {
172
							RestartTXM.reloadViews();
173
							System.err.println(TXMUIMessages.AddBase_10);
174
							StatusLine.setMessage(TXMUIMessages.AddBase_10);
175
						}
176
					});
177
				} catch (ThreadDeath td) { 
178
					return Status.CANCEL_STATUS;
179
				} catch (Exception e2) {
180
					org.txm.rcp.utils.Logger.printStackTrace(e2);
181
					return Status.CANCEL_STATUS;
182
				} finally {
183
					monitor.done();
184
				}
185

  
186
				return Status.OK_STATUS;
187
			}
188
		};
189

  
190
		jobhandler.schedule();
191
		return jobhandler;
192
	}
193
}
0 194

  
tmp/org.txm.rcp/src/main/java/org/txm/rcp/commands/workspace/LoadBinaryCorpus.java (revision 761)
28 28
package org.txm.rcp.commands.workspace;
29 29

  
30 30
import java.io.File;
31
import java.util.ArrayList;
32 31

  
33 32
import org.eclipse.core.commands.AbstractHandler;
34 33
import org.eclipse.core.commands.ExecutionEvent;
......
45 44
import org.eclipse.ui.handlers.HandlerUtil;
46 45
import org.txm.EngineType;
47 46
import org.txm.Toolbox;
48
import org.txm.Toolbox;
49
import org.txm.core.preferences.TBXPreferences;
50 47
import org.txm.objects.Base;
51 48
import org.txm.objects.Project;
52 49
import org.txm.objects.Workspace;
......
56 53
import org.txm.rcp.swt.dialog.LastOpened;
57 54
import org.txm.rcp.utils.JobHandler;
58 55
import org.txm.rcp.views.corpora.CorporaView;
59
import org.txm.searchengine.cqp.corpus.Corpus;
60 56
import org.txm.searchengine.cqp.corpus.MainCorpus;
61 57
import org.txm.utils.DeleteDir;
62 58
import org.txm.utils.logger.Log;
......
70 66
 */
71 67
public class LoadBinaryCorpus extends AbstractHandler {
72 68

  
73
	private static final String ID = "org.txm.rcp.commands.workspace.AddBase"; //$NON-NLS-1$
69
	private static final String ID = LoadBinaryCorpus.class.getName();
74 70

  
75 71
	File corpusdir;
76 72
	private File zipFile;

Formats disponibles : Unified diff