Révision 2046
tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/view/ElementSearchView.java (revision 2046) | ||
---|---|---|
118 | 118 |
|
119 | 119 |
private IEditorPart fromEditor; |
120 | 120 |
|
121 |
private Concordance concordance; |
|
122 |
|
|
121 | 123 |
public static void closeView() { |
122 | 124 |
try { |
123 | 125 |
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); |
... | ... | |
128 | 130 |
view = (ElementSearchView) page.showView(ElementSearchView.ID); |
129 | 131 |
page.hideView(view); |
130 | 132 |
} |
131 |
|
|
133 |
|
|
132 | 134 |
return; |
133 | 135 |
} catch (PartInitException e1) { |
134 | 136 |
System.out.println("Part initialisation error: "+e1.getLocalizedMessage()); |
... | ... | |
501 | 503 |
sizes.add(size); |
502 | 504 |
} |
503 | 505 |
|
504 |
List<WordProperty> viewProperties = Arrays.asList(corpus.getWordProperty()); |
|
505 |
ReferencePattern ref = new ReferencePattern(corpus.getStructuralUnit("text").getProperty("id")); |
|
506 |
final Concordance concordance = new Concordance(corpus); |
|
507 |
concordance.setParameters(new CQLQuery(""), |
|
506 |
|
|
507 |
concordance = null; |
|
508 |
|
|
509 |
if (concordanceEditor == null || concordanceEditor.isDisposed()) { |
|
510 |
concordance = new Concordance(corpus); |
|
511 |
List<WordProperty> viewProperties = Arrays.asList(corpus.getWordProperty()); |
|
512 |
ReferencePattern ref = new ReferencePattern(corpus.getStructuralUnit("text").getProperty("id")); |
|
513 |
concordance.setParameters(new CQLQuery(""), |
|
508 | 514 |
viewProperties, viewProperties, viewProperties, |
509 | 515 |
viewProperties, viewProperties, viewProperties, |
510 | 516 |
ref, ref, |
511 | 517 |
7, 10); |
512 |
concordance.compute(); |
|
518 |
} else { |
|
519 |
concordance = concordanceEditor.getConcordance(); |
|
520 |
} |
|
521 |
concordance.setQueryResult(fqr); |
|
513 | 522 |
|
514 | 523 |
e.widget.getDisplay().syncExec(new Runnable() { |
515 | 524 |
|
516 | 525 |
@Override |
517 | 526 |
public void run() { |
518 |
// if (concordanceEditor == null || // no editor opened |
|
519 |
// concordanceEditor.getLineTableViewer().getTable().isDisposed() // editor was closed |
|
520 |
// || !concordanceEditor.getCorpus().equals(corpus)) { // editor opened but with different corpus |
|
521 |
// |
|
522 |
// IEditorPart editor = ComputeConcordance.openEditor(concordance); |
|
523 |
// if (editor == null) { |
|
524 |
// return; |
|
525 |
// } |
|
526 |
// concordanceEditor = (ConcordanceEditor) editor; |
|
527 |
// if (toolbar.getEditor() != null) { |
|
528 |
// SWTEditorsUtils.addEditor(toolbar.getEditor(), concordanceEditor, EModelService.BELOW); |
|
529 |
// } |
|
530 |
// BackToText.associateEditors(toolbar.getEditor(), concordanceEditor); |
|
531 |
// } else { |
|
532 |
// concordanceEditor.setConcordance(corpus, concordance); |
|
533 |
// } |
|
534 |
// |
|
535 |
// concordanceEditor.compute(true); |
|
536 |
// IWorkbenchPage attachedPage = concordanceEditor.getEditorSite().getPage(); |
|
537 |
// attachedPage.activate(concordanceEditor); |
|
527 |
if (concordanceEditor == null || // no editor opened |
|
528 |
concordanceEditor.getLineTableViewer().getTable().isDisposed() // editor was closed |
|
529 |
|| !concordanceEditor.getCorpus().equals(corpus)) { // editor opened but with different corpus |
|
530 |
|
|
531 |
IEditorPart editor = ComputeConcordance.openEditor(concordance); |
|
532 |
if (editor == null) { |
|
533 |
return; |
|
534 |
} |
|
535 |
concordanceEditor = (ConcordanceEditor) editor; |
|
536 |
|
|
537 |
if (toolbar.getEditor() != null) { |
|
538 |
SWTEditorsUtils.addEditor(toolbar.getEditor(), concordanceEditor, EModelService.BELOW); |
|
539 |
} |
|
540 |
//BackToText.associateEditors(toolbar.getEditor(), concordanceEditor); |
|
541 |
toolbar.getEditor().addLinkedEditor(concordanceEditor); |
|
542 |
concordanceEditor.addLinkedEditor(toolbar.getEditor()); |
|
543 |
} |
|
544 |
|
|
545 |
concordanceEditor.compute(false); |
|
546 |
IWorkbenchPage attachedPage = concordanceEditor.getEditorSite().getPage(); |
|
547 |
attachedPage.activate(concordanceEditor); |
|
538 | 548 |
} |
539 | 549 |
}); |
540 | 550 |
} |
tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/view/ElementPropertiesView.java (revision 2046) | ||
---|---|---|
237 | 237 |
|
238 | 238 |
clear(); |
239 | 239 |
this.needUpdate = true; |
240 |
this.setPartName("Element"); |
|
241 |
this.setContentDescription("No annotation selected"); |
|
240 | 242 |
} |
241 | 243 |
|
242 | 244 |
public void loadElement(org.txm.searchengine.cqp.corpus.CQPCorpus corpus, Corpus analecCorpus, Element newElement, URSAnnotationToolbar toolbar) { |
... | ... | |
333 | 335 |
} else if (newElement instanceof Schema) { |
334 | 336 |
Schema schema = (Schema)newElement; |
335 | 337 |
this.setPartName(corpus.getName()+" - "+schema.getType()+" "+schema.getUnitesSousjacentes().length+" unités"); |
338 |
} else { |
|
339 |
this.setPartName("Element"); |
|
336 | 340 |
} |
341 |
this.setContentDescription(""); |
|
337 | 342 |
} |
338 | 343 |
|
339 | 344 |
protected void saveFieldValue(Combo t) { |
tmp/org.txm.groovy.core/src/groovy/org/txm/macro/office/MergeExcelDirMacro.groovy (revision 2046) | ||
---|---|---|
18 | 18 |
import org.apache.poi.ss.util.* |
19 | 19 |
|
20 | 20 |
@Field @Option(name="inputDirectory", usage="répertoire des fichiers Excel à fusionner", widget="Folder", required=true, def="") |
21 |
def inputDirectory
|
|
21 |
def inputDirectory |
|
22 | 22 |
|
23 | 23 |
@Field @Option(name="outputFile", usage="output file", widget="FileSave", required=true, def="") |
24 |
def outputFile
|
|
24 |
def outputFile |
|
25 | 25 |
|
26 | 26 |
@Field @Option(name="sheetName", usage="sheet name (if no name is given the first sheet will be used)", widget="String", required=false, def="") |
27 |
def sheetName
|
|
27 |
def sheetName |
|
28 | 28 |
|
29 | 29 |
@Field @Option(name="columnList", usage="list of columns to extract, separated by comma", widget="String", required=false, def="") |
30 |
def columnList
|
|
30 |
def columnList |
|
31 | 31 |
|
32 |
@Field @Option(name="multipleValues", usage="list of columns with multiple values, separated by comma", widget="String", required=false, def="") |
|
33 |
def multipleValues |
|
34 |
|
|
35 |
@Field @Option(name="normalizeIdentifiers", usage="normalize column names to simple lower case letters", widget="Boolean", required=true, def="true") |
|
36 |
def normalizeIdentifiers |
|
37 |
|
|
38 |
def stringToIdent = { str -> org.txm.utils.AsciiUtils.buildAttributeId(org.txm.utils.AsciiUtils.convertNonAscii(str)).toLowerCase() } |
|
39 |
|
|
32 | 40 |
if (!ParametersDialog.open(this)) return false |
33 | 41 |
|
34 | 42 |
if (!inputDirectory.exists()) { |
... | ... | |
45 | 53 |
|
46 | 54 |
def scriptName = this.class.getSimpleName() |
47 | 55 |
|
48 |
columnList = columnList.split(",") |
|
56 |
columnList = columnList.split(",") as List
|
|
49 | 57 |
|
50 | 58 |
println "columnList = "+columnList |
51 | 59 |
|
60 |
multipleValues = multipleValues.split(",") as List |
|
61 |
|
|
52 | 62 |
// create output file |
53 | 63 |
out = new FileOutputStream(outputFile) |
54 | 64 |
HSSFWorkbook wb = new HSSFWorkbook() |
... | ... | |
59 | 69 |
r = finalSheet.createRow(0) |
60 | 70 |
columnList.eachWithIndex { columnName, i -> |
61 | 71 |
c = r.createCell(i) |
62 |
c.setCellValue(columnName) |
|
72 |
c.setCellValue(normalizeIdentifiers?stringToIdent(columnName):columnName)
|
|
63 | 73 |
} |
64 | 74 |
|
65 | 75 |
def f = [] |
... | ... | |
73 | 83 |
|
74 | 84 |
debug = false |
75 | 85 |
//ConsoleProgressBar cpb = new ConsoleProgressBar(f.size()) |
86 |
|
|
76 | 87 |
try { |
77 | 88 |
|
89 |
// for each .xlsx input file (lexicographic order) |
|
78 | 90 |
f.sort { it.name }.each { inputFile -> |
79 | 91 |
|
92 |
if (aborted) return false |
|
93 |
|
|
80 | 94 |
if (debug) println "Processing "+inputFile+"." |
81 | 95 |
//cpb.tick() |
82 | 96 |
rownum = 0 |
... | ... | |
104 | 118 |
nRows = ws.getPhysicalNumberOfRows() |
105 | 119 |
if (debug) println nRows+" rows." |
106 | 120 |
|
121 |
// get columns positions |
|
107 | 122 |
firstRow = ws.getRow(0) |
108 |
nCells = firstRow.getPhysicalNumberOfCells() |
|
123 |
nCols = firstRow.getPhysicalNumberOfCells() |
|
124 |
def colNames = [] |
|
109 | 125 |
def cellIndexes = [] |
110 |
0.upto(nCells-1, { iCell -> |
|
111 |
value = firstRow.getCell(iCell).getStringCellValue() |
|
126 |
def multipleValuesCols = [] |
|
127 |
0.upto(nCols-1, { iCol -> |
|
128 |
value = firstRow.getCell(iCol).getStringCellValue() |
|
112 | 129 |
if (columnList.contains(value)) { |
113 |
cellIndexes << iCell |
|
130 |
colNames << value |
|
131 |
cellIndexes << iCol |
|
114 | 132 |
} |
133 |
if (multipleValues.contains(value)) { |
|
134 |
multipleValuesCols << iCol |
|
135 |
} |
|
115 | 136 |
}) |
116 | 137 |
|
117 | 138 |
if (cellIndexes.size() != columnList.size()) { |
118 |
println "** $scriptName: some columns missing in file $inputFile. Aborting." |
|
139 |
columnList.removeAll(colNames) |
|
140 |
println "** $scriptName: some columns missing in file $inputFile: "+columnList.join(", ")+". Aborting." |
|
141 |
|
|
119 | 142 |
aborted = true |
120 | 143 |
return false |
121 | 144 |
} |
122 | 145 |
|
146 |
// sort columns indexes by columnList parameter order |
|
147 |
cellIndexes.sort { columnList.indexOf(colNames[cellIndexes.indexOf(it)]) } |
|
148 |
|
|
149 |
// copy column values |
|
123 | 150 |
1.upto(nRows-1, { iRow -> |
124 | 151 |
row = ws.getRow(iRow) |
125 | 152 |
r = finalSheet.createRow(nFinalRows) |
126 | 153 |
|
127 | 154 |
nCellCreated = 0 |
128 |
cellIndexes.each { iCell ->
|
|
129 |
value = row.getCell(iCell).getStringCellValue()
|
|
155 |
cellIndexes.each { iCol ->
|
|
156 |
value = row.getCell(iCol).getStringCellValue()
|
|
130 | 157 |
c = r.createCell(nCellCreated) |
131 |
c.setCellValue(value) |
|
158 |
if (iCol in multipleValuesCols && value.size() > 0) { |
|
159 |
(lstr = value.split(";")*.trim() as List).removeAll { it.isEmpty() } |
|
160 |
c.setCellValue("|"+lstr.join("|")+"|") |
|
161 |
} else { |
|
162 |
c.setCellValue(value) |
|
163 |
} |
|
132 | 164 |
nCellCreated++ |
133 | 165 |
} |
134 | 166 |
|
tmp/org.txm.edition.rcp/src/org/txm/edition/rcp/handlers/BackToText.java (revision 2046) | ||
---|---|---|
43 | 43 |
import org.eclipse.ui.IWorkbenchPage; |
44 | 44 |
import org.eclipse.ui.IWorkbenchWindow; |
45 | 45 |
import org.eclipse.ui.handlers.HandlerUtil; |
46 |
import org.eclipse.ui.part.EditorPart; |
|
46 | 47 |
import org.txm.concordance.core.functions.Concordance; |
47 | 48 |
import org.txm.concordance.rcp.editors.ConcordanceEditor; |
48 | 49 |
import org.txm.concordance.rcp.handlers.BackToTextCommand; |
... | ... | |
77 | 78 |
public final static RGBA lightred = new RGBA(249,208,208); |
78 | 79 |
public final static RGBA red = new RGBA(249, 160, 160); |
79 | 80 |
//TODO: this kind of link associations must be transfered to a TXMEditor class |
80 |
private static HashMap<ConcordanceEditor, SynopticEditionEditor> associatedEditors = new HashMap<ConcordanceEditor, SynopticEditionEditor>(); |
|
81 |
//private static HashMap<ConcordanceEditor, SynopticEditionEditor> associatedEditors = new HashMap<ConcordanceEditor, SynopticEditionEditor>();
|
|
81 | 82 |
private static HashMap<ConcordanceEditor, List<String>> associatedEditorsPreviousOtherWordIDs = new HashMap<ConcordanceEditor, List<String>>(); |
82 | 83 |
private static HashMap<ConcordanceEditor, List<String>> associatedEditorsPreviousLineids = new HashMap<ConcordanceEditor, List<String>>(); |
83 | 84 |
|
... | ... | |
152 | 153 |
} |
153 | 154 |
|
154 | 155 |
SynopticEditionEditor editor = null; |
156 |
boolean newEditor = false; |
|
155 | 157 |
if (ieditor != null && ieditor instanceof SynopticEditionEditor) { |
156 | 158 |
editor = (SynopticEditionEditor)ieditor; |
157 | 159 |
} else { |
158 | 160 |
editor = OpenEdition.openEdition(corpus, editions); |
161 |
newEditor = true; |
|
159 | 162 |
} |
160 | 163 |
|
161 | 164 |
Text text = null; |
... | ... | |
241 | 244 |
|
242 | 245 |
Log.fine("Loading line informations..."); |
243 | 246 |
|
244 |
SynopticEditionEditor attachedBrowserEditor = associatedEditors.get(editor); |
|
247 |
EditorPart l_editor = editor.getLinkedEditor(SynopticEditionEditor.class); |
|
248 |
SynopticEditionEditor attachedBrowserEditor = null; |
|
249 |
if (l_editor != null) { |
|
250 |
attachedBrowserEditor = (SynopticEditionEditor) l_editor;//associatedEditors.get(editor); |
|
251 |
} |
|
252 |
|
|
245 | 253 |
if (attachedBrowserEditor!= null && attachedBrowserEditor.isDisposed()) { |
246 | 254 |
associatedEditorsPreviousOtherWordIDs.put(editor, new ArrayList<String>()); |
247 | 255 |
associatedEditorsPreviousLineids.put(editor, new ArrayList<String>()); |
... | ... | |
268 | 276 |
} |
269 | 277 |
|
270 | 278 |
attachedBrowserEditor = OpenEdition.openEdition(corpus, editionsToOpen); |
271 |
associatedEditors.put(editor, attachedBrowserEditor);
|
|
279 |
editor.addLinkedEditor(attachedBrowserEditor);
|
|
272 | 280 |
SWTEditorsUtils.addEditor(editor, attachedBrowserEditor, EModelService.ABOVE); |
273 | 281 |
} |
274 | 282 |
|
tmp/org.txm.concordance.rcp/src/org/txm/concordance/rcp/editors/ConcordanceEditor.java (revision 2046) | ||
---|---|---|
2089 | 2089 |
} |
2090 | 2090 |
|
2091 | 2091 |
|
2092 |
public boolean isDisposed() { |
|
2093 |
return viewerLeft.getTable().isDisposed(); |
|
2094 |
} |
|
2092 | 2095 |
} |
tmp/org.txm.concordance.core/src/org/txm/concordance/core/functions/Concordance.java (revision 2046) | ||
---|---|---|
385 | 385 |
Log.finest("Concordance.canCompute(): Corpus is not set."); //$NON-NLS-1$ |
386 | 386 |
go = false; |
387 | 387 |
} |
388 |
if(pQuery == null || pQuery.isEmpty()) {
|
|
389 |
Log.finest("Concordance.canCompute(): Query is not set or empty."); //$NON-NLS-1$
|
|
388 |
if (pQueryResult == null && (pQuery == null || pQuery.isEmpty())) {
|
|
389 |
Log.finer("Concordance.canCompute(): Query is not set or empty."); //$NON-NLS-1$
|
|
390 | 390 |
go = false; |
391 | 391 |
} |
392 | 392 |
return go; |
Formats disponibles : Unified diff