Révision 2860
| tmp/org.txm.rcp/src/main/java/org/txm/rcp/messages/TXMUIMessages.java (revision 2860) | ||
|---|---|---|
| 8 | 8 |
|
| 9 | 9 |
private static final String BUNDLE_NAME = "org.txm.rcp.messages.messages"; //$NON-NLS-1$ |
| 10 | 10 |
|
| 11 |
public static String theP0FileAlreadyExistsWouldYouLikeToReplaceIt; |
|
| 12 |
|
|
| 11 | 13 |
public static String theP0directoryNotABinaryCorpus; |
| 12 | 14 |
|
| 13 | 15 |
public static String P0CorpusLoaded; |
| tmp/org.txm.rcp/src/main/java/org/txm/rcp/messages/messages.properties (revision 2860) | ||
|---|---|---|
| 9 | 9 |
Explorer_7 = ⌂ |
| 10 | 10 |
|
| 11 | 11 |
FileTreeContentProvider_4 = ' |
| 12 |
|
|
| 12 |
|
|
| 13 |
theP0FileAlreadyExistsWouldYouLikeToReplaceIt=the {0} file already exists. Would you like to replace it?
|
|
| 13 | 14 |
LoadBinaryCorporaDirectory_aCorpusNamedP0alreadyExistsLoadingOfP1Canceled = A corpus named {0} already exists, loading of {1} canceled.
|
| 14 | 15 |
LoadBinaryCorporaDirectory_corporaDirectoryNotFoundAborting = Corpora directory not found. Aborting. |
| 15 | 16 |
LoadBinaryCorporaDirectory_corpusLoad = Corpus load |
| ... | ... | |
| 469 | 470 |
exporting = Exporting… |
| 470 | 471 |
|
| 471 | 472 |
exporting = Exporting {0}…
|
| 472 |
|
|
| 473 |
exportingP0 = Exporting {0}…
|
|
| 473 | 474 |
exportingAnnotations = Exporting annotations. |
| 474 | 475 |
|
| 475 | 476 |
exportingP0ThisMayTakeAWhile = Exporting {0}. This can take time, depending on the size of the corpus.
|
| tmp/org.txm.rcp/src/main/java/org/txm/rcp/messages/messages_fr.properties (revision 2860) | ||
|---|---|---|
| 9 | 9 |
Explorer_7 = ⌂ |
| 10 | 10 |
|
| 11 | 11 |
FileTreeContentProvider_4 = ' |
| 12 |
|
|
| 12 |
theP0FileAlreadyExistsWouldYouLikeToReplaceIt=Le fichier {0} existe déjà. Voulez vous vraiment le remplacer ?
|
|
| 13 | 13 |
P0CorpusLoaded = {0} corpus chargé(s).
|
| 14 | 14 |
|
| 15 | 15 |
SourceDirectoryPage_0 = Selection du répertoire des fichiers sources |
| ... | ... | |
| 419 | 419 |
exporting = Exportation… |
| 420 | 420 |
|
| 421 | 421 |
exporting = Exportation de {0}…
|
| 422 |
|
|
| 422 |
exportingP0 = Exportation de {0}…
|
|
| 423 | 423 |
exportingAnnotations = Exportation des annotations… |
| 424 | 424 |
|
| 425 | 425 |
exportingP0ThisMayTakeAWhile = Exportation de {0}. Cela peut prendre du temps, en fonction de la taille du corpus.
|
| tmp/org.txm.core/src/java/org/txm/Toolbox.java (revision 2860) | ||
|---|---|---|
| 80 | 80 |
public class Toolbox {
|
| 81 | 81 |
|
| 82 | 82 |
public static final DateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd");
|
| 83 |
public static final DateFormat shortUKDateformat = new SimpleDateFormat("dd-MM-yy");
|
|
| 83 |
//public static final DateFormat shortUKDateformat = new SimpleDateFormat("dd-MM-yy");
|
|
| 84 | 84 |
|
| 85 | 85 |
private static LinkedHashMap<EngineType, EnginesManager<?>> enginesManagers = new LinkedHashMap<EngineType, EnginesManager<?>>(); |
| 86 | 86 |
|
| tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/handlers/base/ExportCorpus.java (revision 2860) | ||
|---|---|---|
| 55 | 55 |
* Export a corpus to the .txm binary format (Zip) |
| 56 | 56 |
*/ |
| 57 | 57 |
public class ExportCorpus extends AbstractHandler {
|
| 58 |
|
|
| 58 |
|
|
| 59 | 59 |
public final static String ID = "org.txm.rcp.commands.base.ExportCorpus"; //$NON-NLS-1$ |
| 60 |
|
|
| 60 |
|
|
| 61 | 61 |
/** The selection. */ |
| 62 | 62 |
private IStructuredSelection selection; |
| 63 |
|
|
| 63 |
|
|
| 64 | 64 |
/** The lastopenedfile. */ |
| 65 | 65 |
private static String lastopenedfile; |
| 66 |
|
|
| 66 |
|
|
| 67 | 67 |
/* |
| 68 | 68 |
* (non-Javadoc) |
| 69 | 69 |
* @see |
| ... | ... | |
| 73 | 73 |
@Override |
| 74 | 74 |
public Object execute(ExecutionEvent event) throws ExecutionException {
|
| 75 | 75 |
selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event); |
| 76 |
|
|
| 76 |
|
|
| 77 | 77 |
Shell shell = HandlerUtil.getActiveWorkbenchWindowChecked(event) |
| 78 | 78 |
.getShell(); |
| 79 |
|
|
| 79 |
|
|
| 80 | 80 |
if (!(selection.getFirstElement() instanceof MainCorpus)) |
| 81 | 81 |
return null; |
| 82 |
|
|
| 82 |
|
|
| 83 | 83 |
final MainCorpus corpus = (MainCorpus) selection.getFirstElement(); |
| 84 |
|
|
| 84 |
|
|
| 85 | 85 |
try {
|
| 86 | 86 |
corpus.compute(false); |
| 87 | 87 |
} |
| ... | ... | |
| 90 | 90 |
e.printStackTrace(); |
| 91 | 91 |
return null; |
| 92 | 92 |
} |
| 93 |
|
|
| 93 |
|
|
| 94 | 94 |
if (corpus.isModified()) {
|
| 95 | 95 |
boolean ret = MessageDialog.openConfirm(shell, "Export - " + corpus.getName() + " annotations not saved", |
| 96 | 96 |
"Do you wish to export without the current annotations?\n\n(to include the current annotations in the exported corpus, you need to save them before calling the \"Export\" command)"); |
| 97 | 97 |
if (!ret) return null; |
| 98 | 98 |
} |
| 99 |
|
|
| 99 |
|
|
| 100 | 100 |
ExportCorpusDialog dialog = new ExportCorpusDialog(shell, corpus); |
| 101 |
|
|
| 101 |
|
|
| 102 | 102 |
if (dialog.open() == Window.OK) {
|
| 103 |
|
|
| 103 |
|
|
| 104 | 104 |
final File outfile = dialog.getZipFile(); |
| 105 |
|
|
| 106 |
if (outfile.exists()) {
|
|
| 107 |
boolean ret = MessageDialog.openConfirm(shell, "Export - " + corpus.getName() + " warning", |
|
| 108 |
TXMUIMessages.bind(TXMUIMessages.theP0FileAlreadyExistsWouldYouLikeToReplaceIt, outfile.getAbsoluteFile())); |
|
| 109 |
if (!ret) {
|
|
| 110 |
Log.info(TXMUIMessages.abort); |
|
| 111 |
return null; |
|
| 112 |
} |
|
| 113 |
} |
|
| 114 |
|
|
| 105 | 115 |
Log.info(NLS.bind(TXMUIMessages.exportingP0, corpus.getName())); |
| 106 | 116 |
JobHandler jobhandler = new JobHandler(NLS.bind(TXMUIMessages.exportingP0, corpus.getName())) {
|
| 107 |
|
|
| 117 |
|
|
| 108 | 118 |
@Override |
| 109 | 119 |
protected IStatus run(IProgressMonitor monitor) {
|
| 110 | 120 |
this.runInit(monitor); |
| 111 | 121 |
try {
|
| 112 | 122 |
monitor.beginTask(NLS.bind(TXMUIMessages.exportingP0ThisMayTakeAWhile, corpus.getName()), 100); |
| 113 |
|
|
| 123 |
|
|
| 124 |
|
|
| 125 |
|
|
| 114 | 126 |
if (!corpus.export(outfile, this, dialog.getIgnoreNames())) {
|
| 115 | 127 |
System.out.println(NLS.bind(TXMUIMessages.failedToExportCorpusP0, corpus.getName())); |
| 116 | 128 |
} |
| 117 |
|
|
| 129 |
|
|
| 118 | 130 |
System.out.println(TXMUIMessages.bind(TXMUIMessages.doneTheCreatedBinaryFileIsP0, outfile.getAbsolutePath())); |
| 119 | 131 |
monitor.worked(100); |
| 120 | 132 |
} |
| ... | ... | |
| 129 | 141 |
}; |
| 130 | 142 |
jobhandler.startJob(); |
| 131 | 143 |
} |
| 132 |
|
|
| 144 |
|
|
| 133 | 145 |
return null; |
| 134 | 146 |
} |
| 135 | 147 |
} |
| tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/dialogs/ExportCorpusDialog.java (revision 2860) | ||
|---|---|---|
| 32 | 32 |
import org.eclipse.swt.widgets.TableItem; |
| 33 | 33 |
import org.eclipse.swt.widgets.Text; |
| 34 | 34 |
import org.txm.Toolbox; |
| 35 |
import org.txm.core.results.TXMResult;
|
|
| 35 |
import org.txm.core.preferences.TXMPreferences;
|
|
| 36 | 36 |
import org.txm.objects.Project; |
| 37 |
import org.txm.rcp.swt.dialog.LastOpened; |
|
| 38 | 37 |
import org.txm.searchengine.cqp.corpus.CQPCorpus; |
| 39 | 38 |
|
| 40 | 39 |
/** |
| ... | ... | |
| 43 | 42 |
* |
| 44 | 43 |
*/ |
| 45 | 44 |
public class ExportCorpusDialog extends Dialog {
|
| 46 |
|
|
| 45 |
|
|
| 47 | 46 |
/** |
| 48 | 47 |
* list of the default files to include in the corpus binary |
| 49 | 48 |
*/ |
| 50 | 49 |
private List<String> defaultFiles = Arrays.asList("HTML", "txm", "data", "registry", "annotations", "analec", "temporary_annotations", "xsl", "css", ".settings", ".project");
|
| 51 |
|
|
| 50 |
|
|
| 52 | 51 |
private File zipFile; |
| 53 |
|
|
| 52 |
|
|
| 54 | 53 |
private LinkedHashMap<File, Boolean> selectedFiles; |
| 55 |
|
|
| 54 |
|
|
| 56 | 55 |
private CQPCorpus corpus; |
| 57 |
|
|
| 56 |
|
|
| 58 | 57 |
private TableViewer treeViewer; |
| 59 |
|
|
| 58 |
|
|
| 60 | 59 |
private TableViewerColumn nameColumn; |
| 61 |
|
|
| 60 |
|
|
| 62 | 61 |
private Text textField; |
| 63 |
|
|
| 62 |
|
|
| 64 | 63 |
private Button selectButton; |
| 65 |
|
|
| 64 |
|
|
| 66 | 65 |
public final static String ID = ExportCorpusDialog.class.getName(); |
| 67 |
|
|
| 66 |
|
|
| 68 | 67 |
/** |
| 69 | 68 |
* |
| 70 | 69 |
* @param parentShell |
| ... | ... | |
| 76 | 75 |
super(parentShell); |
| 77 | 76 |
this.corpus = corpus; |
| 78 | 77 |
} |
| 79 |
|
|
| 78 |
|
|
| 80 | 79 |
@Override |
| 81 | 80 |
protected void configureShell(Shell newShell) {
|
| 82 | 81 |
super.configureShell(newShell); |
| 83 | 82 |
newShell.setText(NLS.bind("Exporting {0}...", corpus.getName()));
|
| 84 |
newShell.setMinimumSize(400, 200);
|
|
| 83 |
newShell.setMinimumSize(400, 300);
|
|
| 85 | 84 |
} |
| 86 |
|
|
| 85 |
|
|
| 87 | 86 |
@Override |
| 88 | 87 |
protected Control createDialogArea(Composite parent) {
|
| 89 | 88 |
Composite comp = (Composite) super.createDialogArea(parent); |
| 90 |
|
|
| 89 |
|
|
| 91 | 90 |
GridLayout layout = (GridLayout) comp.getLayout(); |
| 92 | 91 |
layout.numColumns = 3; |
| 93 |
|
|
| 92 |
|
|
| 94 | 93 |
Label l = new Label(comp, SWT.LEFT); |
| 95 | 94 |
l.setText("Output file");
|
| 96 | 95 |
l.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false)); |
| 97 |
|
|
| 96 |
|
|
| 98 | 97 |
textField = new Text(comp, SWT.SINGLE | SWT.BORDER); |
| 99 | 98 |
textField.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false)); |
| 100 |
textField.setText(Toolbox.getTxmHomePath() + "/" + corpus.getName() + "-" + Toolbox.shortUKDateformat.format(Calendar.getInstance().getTime()) + ".txm"); //$NON-NLS-1$ |
|
| 101 |
|
|
| 99 |
String previousPath = TXMPreferences.getString("path", ExportCorpusDialog.class.getName());
|
|
| 100 |
if (previousPath == null || previousPath.length() == 0) {
|
|
| 101 |
previousPath = System.getProperty("user.home"); ////$NON-NLS-0$
|
|
| 102 |
} |
|
| 103 |
textField.setText(previousPath + "/" + corpus.getName() + "-" + Toolbox.dateformat.format(Calendar.getInstance().getTime()) + ".txm"); //$NON-NLS-1$ |
|
| 104 |
|
|
| 102 | 105 |
selectButton = new Button(comp, SWT.PUSH); |
| 103 | 106 |
selectButton.setText("...");
|
| 104 | 107 |
selectButton.addSelectionListener(new SelectionListener() {
|
| 105 |
|
|
| 108 |
|
|
| 106 | 109 |
@Override |
| 107 | 110 |
public void widgetSelected(SelectionEvent e) {
|
| 108 | 111 |
FileDialog dialog = new FileDialog(selectButton.getShell(), SWT.SAVE); |
| 109 |
|
|
| 112 |
|
|
| 110 | 113 |
String[] exts = { "*.txm", "*.zip" }; //$NON-NLS-1$ //$NON-NLS-2$
|
| 111 | 114 |
dialog.setFilterExtensions(exts); |
| 112 |
dialog.setFilterPath(textField.getText()); |
|
| 113 |
dialog.setFileName(textField.getText()); |
|
| 114 |
|
|
| 115 |
String path = dialog.open(); |
|
| 115 |
String path = textField.getText(); |
|
| 116 |
if (path != null && path.length() > 0) {
|
|
| 117 |
File p = new File(path); |
|
| 118 |
if (p.isDirectory()) {
|
|
| 119 |
dialog.setFilterPath(textField.getText()); |
|
| 120 |
} else {
|
|
| 121 |
dialog.setFilterPath(p.getParent()); |
|
| 122 |
dialog.setFileName(p.getName()); |
|
| 123 |
} |
|
| 124 |
} |
|
| 125 |
// |
|
| 126 |
|
|
| 127 |
path = dialog.open(); |
|
| 116 | 128 |
if (path != null) {
|
| 117 | 129 |
textField.setText(path); |
| 118 |
getButton(IDialogConstants.OK_ID).setEnabled(new File(path).getParentFile().exists()); |
|
| 130 |
File dir = new File(path).getParentFile(); |
|
| 131 |
getButton(IDialogConstants.OK_ID).setEnabled(dir.exists()); |
|
| 132 |
TXMPreferences.put(ExportCorpusDialog.class.getName(), "path", dir.getAbsolutePath()); |
|
| 119 | 133 |
} |
| 120 | 134 |
} |
| 121 |
|
|
| 135 |
|
|
| 122 | 136 |
@Override |
| 123 | 137 |
public void widgetDefaultSelected(SelectionEvent e) {}
|
| 124 | 138 |
}); |
| 125 |
|
|
| 139 |
|
|
| 126 | 140 |
selectedFiles = new LinkedHashMap<>(); |
| 127 | 141 |
Project project = corpus.getProject(); |
| 128 | 142 |
File directory = project.getProjectDirectory(); |
| 129 | 143 |
if (directory.exists()) {
|
| 130 |
|
|
| 144 |
|
|
| 131 | 145 |
File[] files = directory.listFiles(new FileFilter() {
|
| 132 |
|
|
| 146 |
|
|
| 133 | 147 |
@Override |
| 134 | 148 |
public boolean accept(File f) {
|
| 135 | 149 |
return !f.getName().startsWith(".") && !f.isHidden() && f.isDirectory() && !defaultFiles.contains(f.getName());
|
| 136 | 150 |
} |
| 137 | 151 |
}); |
| 138 | 152 |
Arrays.sort(files, new Comparator<File>() {
|
| 139 |
|
|
| 153 |
|
|
| 140 | 154 |
@Override |
| 141 | 155 |
public int compare(File arg0, File arg1) {
|
| 142 | 156 |
if (arg0.isDirectory() && arg1.isDirectory()) {
|
| ... | ... | |
| 157 | 171 |
}); |
| 158 | 172 |
for (File f : files) {
|
| 159 | 173 |
if (!f.isHidden() && f.isDirectory()) {
|
| 160 |
|
|
| 174 |
|
|
| 161 | 175 |
if (defaultFiles.contains(f.getName())) {
|
| 162 | 176 |
selectedFiles.put(f, true); |
| 163 | 177 |
} |
| ... | ... | |
| 166 | 180 |
} |
| 167 | 181 |
} |
| 168 | 182 |
} |
| 169 |
|
|
| 183 |
|
|
| 170 | 184 |
if (files.length > 0) {
|
| 171 | 185 |
treeViewer = new TableViewer(comp, SWT.CHECK | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); |
| 172 |
|
|
| 186 |
|
|
| 173 | 187 |
treeViewer.setContentProvider(new ArrayContentProvider()); |
| 174 |
|
|
| 188 |
|
|
| 175 | 189 |
treeViewer.getTable().addListener(SWT.Selection, event -> {
|
| 176 |
|
|
| 190 |
|
|
| 177 | 191 |
if (event.detail == SWT.CHECK) {
|
| 178 | 192 |
TableItem item = (TableItem) event.item; |
| 179 | 193 |
selectedFiles.put((File) event.item.getData(), item.getChecked()); |
| 180 | 194 |
} |
| 181 | 195 |
}); |
| 182 |
|
|
| 196 |
|
|
| 183 | 197 |
treeViewer.getTable().setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true, 3, 1)); |
| 184 | 198 |
treeViewer.getTable().setHeaderVisible(true); |
| 185 | 199 |
treeViewer.getTable().setLinesVisible(true); |
| 186 |
|
|
| 200 |
|
|
| 187 | 201 |
nameColumn = new TableViewerColumn(treeViewer, SWT.NONE); |
| 188 | 202 |
nameColumn.getColumn().setText("Extra files");
|
| 189 | 203 |
nameColumn.getColumn().pack(); |
| 190 | 204 |
nameColumn.setLabelProvider(new CellLabelProvider() {
|
| 191 |
|
|
| 205 |
|
|
| 192 | 206 |
@Override |
| 193 | 207 |
public void update(ViewerCell cell) {
|
| 194 | 208 |
Object element = cell.getElement(); |
| 195 |
|
|
| 209 |
|
|
| 196 | 210 |
if (element instanceof File) {
|
| 197 | 211 |
File f = (File) element; |
| 198 | 212 |
cell.setText(f.getName()); |
| ... | ... | |
| 202 | 216 |
} |
| 203 | 217 |
} |
| 204 | 218 |
}); |
| 205 |
|
|
| 219 |
|
|
| 206 | 220 |
treeViewer.setInput(files); |
| 207 | 221 |
for (int i = 0; i < files.length; i++) {
|
| 208 | 222 |
treeViewer.getTable().getItem(i).setChecked(selectedFiles.get(files[i])); |
| 209 | 223 |
} |
| 210 |
|
|
| 224 |
|
|
| 211 | 225 |
Button selectAllButton = new Button(comp, SWT.PUSH); |
| 212 | 226 |
selectAllButton.setText("Select All");
|
| 213 | 227 |
selectAllButton.addSelectionListener(new SelectionListener() {
|
| 214 |
|
|
| 228 |
|
|
| 215 | 229 |
@Override |
| 216 | 230 |
public void widgetSelected(SelectionEvent e) {
|
| 217 | 231 |
massSelect(true); |
| 218 | 232 |
} |
| 219 |
|
|
| 233 |
|
|
| 220 | 234 |
@Override |
| 221 | 235 |
public void widgetDefaultSelected(SelectionEvent e) {}
|
| 222 | 236 |
}); |
| 223 |
|
|
| 237 |
|
|
| 224 | 238 |
Button clearAllButton = new Button(comp, SWT.PUSH); |
| 225 | 239 |
clearAllButton.setText("Clear selection");
|
| 226 | 240 |
clearAllButton.addSelectionListener(new SelectionListener() {
|
| 227 |
|
|
| 241 |
|
|
| 228 | 242 |
@Override |
| 229 | 243 |
public void widgetSelected(SelectionEvent e) {
|
| 230 | 244 |
massSelect(false); |
| 231 | 245 |
} |
| 232 |
|
|
| 246 |
|
|
| 233 | 247 |
@Override |
| 234 | 248 |
public void widgetDefaultSelected(SelectionEvent e) {}
|
| 235 | 249 |
}); |
| 236 | 250 |
} |
| 237 | 251 |
} |
| 238 |
|
|
| 252 |
|
|
| 239 | 253 |
return comp; |
| 240 | 254 |
} |
| 241 |
|
|
| 255 |
|
|
| 242 | 256 |
protected void massSelect(boolean b) {
|
| 243 | 257 |
for (int i = 0; i < treeViewer.getTable().getItems().length; i++) {
|
| 244 | 258 |
treeViewer.getTable().getItem(i).setChecked(b); |
| ... | ... | |
| 247 | 261 |
selectedFiles.put(f, b); |
| 248 | 262 |
} |
| 249 | 263 |
} |
| 250 |
|
|
| 264 |
|
|
| 251 | 265 |
@Override |
| 252 | 266 |
protected boolean isResizable() {
|
| 253 | 267 |
return true; |
| 254 | 268 |
} |
| 255 |
|
|
| 269 |
|
|
| 256 | 270 |
@Override |
| 257 | 271 |
protected void buttonPressed(int buttonId) {
|
| 258 | 272 |
if (buttonId == Dialog.OK) {
|
| ... | ... | |
| 260 | 274 |
} |
| 261 | 275 |
super.buttonPressed(buttonId); |
| 262 | 276 |
} |
| 263 |
|
|
| 277 |
|
|
| 264 | 278 |
public File getZipFile() {
|
| 265 | 279 |
return zipFile; |
| 266 | 280 |
} |
| 267 |
|
|
| 281 |
|
|
| 268 | 282 |
public LinkedHashMap<File, Boolean> getFileSelection() {
|
| 269 | 283 |
return selectedFiles; |
| 270 | 284 |
} |
| 271 |
|
|
| 285 |
|
|
| 272 | 286 |
public HashSet<String> getIgnoreNames() {
|
| 273 | 287 |
HashSet<String> ignore = new HashSet<>(); |
| 274 | 288 |
for (File f : selectedFiles.keySet()) {
|
Formats disponibles : Unified diff