Révision 2018
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xtz/XTZPager.groovy (revision 2018) | ||
---|---|---|
210 | 210 |
continue; |
211 | 211 |
} |
212 | 212 |
|
213 |
|
|
214 | 213 |
def pages = ed.getPageFiles() |
215 | 214 |
for (i = 0 ; i < pages.size();) { |
216 | 215 |
File f = pages[i][0]; |
... | ... | |
280 | 279 |
xslParams["number-words-per-page"] = Integer.parseInt(s); |
281 | 280 |
xslParams["pagination-element"] = project.getEditionDefinition("default").getPageElement(); |
282 | 281 |
xslParams["import-xml-path"] = project.getProjectDirectory() |
283 |
//println "XSL PARAMS: "+xslParams
|
|
282 |
println "XSL PARAMS: "+xslParams |
|
284 | 283 |
|
285 | 284 |
def xslFiles = xslDirectory.listFiles() |
286 | 285 |
xslFiles = xslFiles.sort() { f -> |
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xtz/XTZDefaultPagerStep.groovy (revision 2018) | ||
---|---|---|
300 | 300 |
return false; |
301 | 301 |
} |
302 | 302 |
|
303 |
println "DEBUG: start parsing" |
|
304 | 303 |
for (int event = parser.next(); event != XMLStreamConstants.END_DOCUMENT; event = parser.next()) { |
305 | 304 |
rend = ""; |
306 | 305 |
switch (event) { |
tmp/org.txm.concordance.rcp/src/org/txm/concordance/rcp/editors/ConcordanceEditor.java (revision 2018) | ||
---|---|---|
352 | 352 |
displayArea.setLayout(new FormLayout()); |
353 | 353 |
|
354 | 354 |
viewerLeft = new TableViewer(displayArea, SWT.MULTI | SWT.BORDER | SWT.VIRTUAL); |
355 |
viewerLeft.getTable().addKeyListener(new TableKeyListener(viewerLeft)); |
|
355 |
|
|
356 | 356 |
viewerLeft.setLabelProvider(new LineLabelProvider(this) { |
357 | 357 |
@Override |
358 | 358 |
public String getColumnText(Object element, int columnIndex) { |
... | ... | |
408 | 408 |
viewerRight = new TableViewer(displayArea, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER |
409 | 409 |
// | SWT.VIRTUAL |
410 | 410 |
); |
411 |
viewerRight.getTable().addKeyListener(new TableKeyListener(viewerRight)); |
|
411 |
|
|
412 | 412 |
//viewer.setLabelProvider(new LineLabelProvider(this)); |
413 | 413 |
viewerRight.setContentProvider(new ConcordancesProvider()); |
414 | 414 |
viewerRight.getTable().setLinesVisible(true); |
... | ... | |
454 | 454 |
viewerRight.getTable().addKeyListener(kldelete); |
455 | 455 |
viewerLeft.getTable().addKeyListener(kldelete); |
456 | 456 |
|
457 |
TableKeyListener tlistener = new TableKeyListener(viewerLeft, viewerRight); |
|
458 |
viewerRight.getTable().addKeyListener(tlistener); |
|
459 |
viewerLeft.getTable().addKeyListener(tlistener); |
|
460 |
|
|
457 | 461 |
firstColumn = new TableColumn(viewerRight.getTable(), SWT.LEFT); |
458 | 462 |
firstColumn.setWidth(0); |
459 | 463 |
firstColumn.setResizable(false); |
tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TableKeyListener.java (revision 2018) | ||
---|---|---|
17 | 17 |
import org.txm.utils.logger.Log; |
18 | 18 |
|
19 | 19 |
public class TableKeyListener implements KeyListener { |
20 |
TableViewer viewer;
|
|
20 |
TableViewer[] viewers;
|
|
21 | 21 |
|
22 |
public TableKeyListener(TableViewer viewer) {
|
|
23 |
this.viewer = viewer;
|
|
22 |
public TableKeyListener(TableViewer... viewers) {
|
|
23 |
this.viewers = viewers;
|
|
24 | 24 |
} |
25 | 25 |
|
26 | 26 |
@Override |
... | ... | |
32 | 32 |
public void keyPressed(KeyEvent e) { |
33 | 33 |
//System.out.println("key code: "+e.keyCode); |
34 | 34 |
if ((e.stateMask & SWT.CTRL) != 0 && e.keyCode == 99 ) { // CTRL + C |
35 |
copyLinesToClipboard(); |
|
35 |
copyLinesToClipboard(e);
|
|
36 | 36 |
} else if ((e.stateMask & SWT.CTRL) != 0 && e.keyCode == 102 ) { // CTRL + F |
37 |
searchInLines(); |
|
37 |
searchInLines(e);
|
|
38 | 38 |
} else if ((e.stateMask & SWT.COMMAND) != 0 && e.keyCode == 99 ) { // CMD + C |
39 |
copyLinesToClipboard(); |
|
39 |
copyLinesToClipboard(e);
|
|
40 | 40 |
} else if ((e.stateMask & SWT.COMMAND) != 0 && e.keyCode == 102 ) { // CMD + F |
41 |
searchInLines(); |
|
41 |
searchInLines(e);
|
|
42 | 42 |
} |
43 | 43 |
} |
44 | 44 |
|
45 | 45 |
/** |
46 | 46 |
* Opens a dialog box to enter a REGEX that selects lines in the table. |
47 | 47 |
*/ |
48 |
public void searchInLines() { |
|
49 |
TableItem[] items = viewer.getTable().getItems(); |
|
50 |
//System.out.println("search in tablein items: "+Arrays.toString(items)); |
|
48 |
public void searchInLines(KeyEvent e) { |
|
49 |
|
|
50 |
InputDialog dialog = new InputDialog(viewers[0].getTable().getShell(), "Compute", TXMUIMessages.common_enterRegularExpressionOfYourSearch, "", null); //$NON-NLS-1$ |
|
51 |
if (dialog.open() == Window.OK) { |
|
52 |
for (TableViewer viewer : viewers) { |
|
53 |
TableItem[] items = viewer.getTable().getItems(); |
|
54 |
//System.out.println("search in tablein items: "+Arrays.toString(items)); |
|
51 | 55 |
|
52 |
TableColumn[] cols = viewer.getTable().getColumns(); |
|
53 |
InputDialog dialog = new InputDialog(viewer.getTable().getShell(), "Compute", TXMUIMessages.common_enterRegularExpressionOfYourSearch, "", null); //$NON-NLS-1$
|
|
54 |
if (dialog.open() == Window.OK) {
|
|
55 |
String reg = dialog.getValue();
|
|
56 |
Pattern p = Pattern.compile(reg);
|
|
57 |
// TODO: useless ?
|
|
58 |
//ArrayList<TableItem> matchingItem = new ArrayList<TableItem>();
|
|
59 |
ArrayList<Integer> matchingIndexes = new ArrayList<Integer>();
|
|
60 |
for (int l = 0 ; l < items.length ; l++) {
|
|
61 |
TableItem item = items[l];
|
|
62 |
for (int i = 0 ; i < cols.length ; i++) {
|
|
63 |
if (p.matcher(item.getText(i)).matches()) {
|
|
64 |
// TODO: useless
|
|
65 |
//matchingItem.add(item);
|
|
66 |
matchingIndexes.add(l);
|
|
67 |
break; // next line
|
|
56 |
TableColumn[] cols = viewer.getTable().getColumns();
|
|
57 |
String reg = dialog.getValue();
|
|
58 |
Pattern p = Pattern.compile(reg);
|
|
59 |
// TODO: useless ?
|
|
60 |
//ArrayList<TableItem> matchingItem = new ArrayList<TableItem>();
|
|
61 |
ArrayList<Integer> matchingIndexes = new ArrayList<Integer>();
|
|
62 |
for (int l = 0 ; l < items.length ; l++) {
|
|
63 |
TableItem item = items[l];
|
|
64 |
for (int i = 0 ; i < cols.length ; i++) {
|
|
65 |
if (p.matcher(item.getText(i)).matches()) {
|
|
66 |
// TODO: useless
|
|
67 |
//matchingItem.add(item);
|
|
68 |
matchingIndexes.add(l);
|
|
69 |
break; // next line
|
|
70 |
}
|
|
71 |
}
|
|
68 | 72 |
} |
69 |
} |
|
70 |
} |
|
71 |
Log.fine(TXMCoreMessages.bind(TXMUIMessages.foundLinesColon, matchingIndexes)); |
|
73 |
Log.fine(TXMCoreMessages.bind(TXMUIMessages.foundLinesColon, matchingIndexes)); |
|
72 | 74 |
|
73 |
// TODO: useless ? |
|
74 |
// int[] indexes = new int[matchingIndexes.size()]; |
|
75 |
// TableItem[] mitems = new TableItem[matchingItem.size()]; |
|
76 |
// int i = 0; |
|
77 |
// for(int index : matchingIndexes) { |
|
78 |
// indexes[i++] = index; |
|
79 |
// } |
|
80 |
// i = 0; |
|
81 |
// for(TableItem item : matchingItem) { |
|
82 |
// mitems[i++] = item; |
|
83 |
// } |
|
75 |
// TODO: useless ?
|
|
76 |
// int[] indexes = new int[matchingIndexes.size()];
|
|
77 |
// TableItem[] mitems = new TableItem[matchingItem.size()];
|
|
78 |
// int i = 0;
|
|
79 |
// for(int index : matchingIndexes) {
|
|
80 |
// indexes[i++] = index;
|
|
81 |
// }
|
|
82 |
// i = 0;
|
|
83 |
// for(TableItem item : matchingItem) {
|
|
84 |
// mitems[i++] = item;
|
|
85 |
// }
|
|
84 | 86 |
|
85 |
// TODO: old version which doesn't trigger selection event |
|
86 |
// if (mitems.length > 0) { |
|
87 |
// viewer.getTable().showItem(mitems[0]); // useless: viewer.getTable().setSelection(indexes) can replace these 3 lines of code |
|
88 |
// viewer.getTable().deselectAll(); // useless: viewer.getTable().setSelection(indexes) can replace these 3 lines of code |
|
89 |
// viewer.getTable().select(indexes); // useless: viewer.getTable().setSelection(indexes) can replace these 3 lines of code |
|
90 |
|
|
91 |
// trigger selection event on viewer |
|
92 |
if (matchingIndexes.size() > 0) { |
|
93 |
ArrayList elements = new ArrayList(matchingIndexes.size()); |
|
94 |
for(int j = 0; j < matchingIndexes.size(); j++) { |
|
95 |
elements.add(viewer.getElementAt(matchingIndexes.get(j))); |
|
96 |
} |
|
97 |
viewer.setSelection(new StructuredSelection(elements), true); |
|
87 |
// TODO: old version which doesn't trigger selection event |
|
88 |
// if (mitems.length > 0) { |
|
89 |
// viewer.getTable().showItem(mitems[0]); // useless: viewer.getTable().setSelection(indexes) can replace these 3 lines of code |
|
90 |
// viewer.getTable().deselectAll(); // useless: viewer.getTable().setSelection(indexes) can replace these 3 lines of code |
|
91 |
// viewer.getTable().select(indexes); // useless: viewer.getTable().setSelection(indexes) can replace these 3 lines of code |
|
92 |
|
|
93 |
// trigger selection event on viewer |
|
94 |
if (matchingIndexes.size() > 0) { |
|
95 |
ArrayList elements = new ArrayList(matchingIndexes.size()); |
|
96 |
for(int j = 0; j < matchingIndexes.size(); j++) { |
|
97 |
elements.add(viewer.getElementAt(matchingIndexes.get(j))); |
|
98 |
} |
|
99 |
viewer.setSelection(new StructuredSelection(elements), true); |
|
100 |
for (TableViewer oViewer : viewers) { |
|
101 |
if (oViewer != viewer) { |
|
102 |
oViewer.getTable().deselectAll(); |
|
103 |
oViewer.getTable().select(viewer.getTable().getSelectionIndices()); |
|
104 |
} |
|
105 |
} |
|
106 |
return; |
|
107 |
} |
|
98 | 108 |
} |
99 | 109 |
} |
100 | 110 |
} |
... | ... | |
102 | 112 |
/** |
103 | 113 |
* Copies the current lines selection to the clipboard. |
104 | 114 |
*/ |
105 |
public void copyLinesToClipboard() { |
|
106 |
TableItem[] items = viewer.getTable().getSelection(); |
|
107 |
String str = ""; //$NON-NLS-1$ |
|
108 |
TableColumn[] cols = viewer.getTable().getColumns(); |
|
109 |
for (int l = 0 ; l < items.length ; l++) { |
|
110 |
TableItem item = items[l]; |
|
111 |
if (l > 0) str += "\n"; //$NON-NLS-1$ |
|
112 |
for (int i = 0 ; i < cols.length ; i++) { |
|
113 |
if (cols[i].getText().trim().length() >0) { |
|
114 |
if (i > 0) str += "\t"; //$NON-NLS-1$ |
|
115 |
str += item.getText(i); |
|
115 |
public void copyLinesToClipboard(KeyEvent e) { |
|
116 |
|
|
117 |
StringBuffer str = new StringBuffer(); //$NON-NLS-1$ |
|
118 |
|
|
119 |
for (int l = 0 ; l < viewers[0].getTable().getSelection().length ; l++) { |
|
120 |
|
|
121 |
if (l > 0) str.append("\n"); //$NON-NLS-1$ |
|
122 |
|
|
123 |
for (TableViewer viewer : viewers) { |
|
124 |
TableColumn[] cols = viewer.getTable().getColumns(); |
|
125 |
TableItem[] items = viewer.getTable().getSelection(); |
|
126 |
TableItem item = items[l]; |
|
127 |
|
|
128 |
for (int i = 0 ; i < cols.length ; i++) { |
|
129 |
if (cols[i].getText().trim().length() >0) { |
|
130 |
if (i > 0) str.append("\t"); //$NON-NLS-1$ |
|
131 |
str.append(item.getText(i)); |
|
132 |
} |
|
116 | 133 |
} |
117 | 134 |
} |
135 |
|
|
118 | 136 |
} |
119 |
org.txm.rcp.utils.IOClipboard.write(str); |
|
120 |
Log.info(TXMCoreMessages.bind(TXMUIMessages.copiedLinesColon, str)); |
|
137 |
String strr = str.toString(); |
|
138 |
org.txm.rcp.utils.IOClipboard.write(strr); |
|
139 |
Log.info(TXMCoreMessages.bind(TXMUIMessages.copiedLinesColon, strr)); |
|
121 | 140 |
} |
122 | 141 |
} |
tmp/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/SuperTableViewer.java (revision 2018) | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import java.util.ArrayList; |
4 | 4 |
|
5 |
import org.eclipse.jface.util.Util; |
|
5 | 6 |
import org.eclipse.jface.viewers.TableViewer; |
7 |
import org.eclipse.jface.viewers.TableViewerColumn; |
|
6 | 8 |
import org.eclipse.swt.SWT; |
9 |
import org.eclipse.swt.events.KeyListener; |
|
10 |
import org.eclipse.swt.events.MouseListener; |
|
7 | 11 |
import org.eclipse.swt.events.SelectionAdapter; |
8 | 12 |
import org.eclipse.swt.events.SelectionEvent; |
13 |
import org.eclipse.swt.events.SelectionListener; |
|
9 | 14 |
import org.eclipse.swt.layout.FormAttachment; |
10 | 15 |
import org.eclipse.swt.layout.FormData; |
11 | 16 |
import org.eclipse.swt.layout.FormLayout; |
12 | 17 |
import org.eclipse.swt.widgets.Composite; |
18 |
import org.eclipse.swt.widgets.Event; |
|
19 |
import org.eclipse.swt.widgets.Listener; |
|
13 | 20 |
import org.eclipse.swt.widgets.Sash; |
21 |
import org.eclipse.swt.widgets.ScrollBar; |
|
22 |
import org.eclipse.swt.widgets.Table; |
|
23 |
import org.eclipse.swt.widgets.TableColumn; |
|
14 | 24 |
|
15 | 25 |
public class SuperTableViewer extends Composite { |
16 | 26 |
|
... | ... | |
30 | 40 |
public SuperTableColumn newColumn(String name) { |
31 | 41 |
return newColumn(name, -1); |
32 | 42 |
} |
33 |
|
|
43 |
|
|
34 | 44 |
public SuperTableColumn newColumn(String name, int position) { |
35 | 45 |
SuperTableColumn col = new SuperTableColumn(this, name); |
36 | 46 |
if (position > 0) { |
... | ... | |
42 | 52 |
return col; |
43 | 53 |
} |
44 | 54 |
|
55 |
public void setInput(Object input) { |
|
56 |
for (SuperTableColumn column : columns) { |
|
57 |
column.setInput(input); |
|
58 |
} |
|
59 |
} |
|
60 |
|
|
61 |
public void addKeyListener(KeyListener listener) { |
|
62 |
// for (SuperTableColumn column : columns) { |
|
63 |
// column.getTable().addKeyListener(listener); |
|
64 |
// } |
|
65 |
super.addKeyListener(listener); |
|
66 |
} |
|
67 |
|
|
68 |
public void addMouseListener(MouseListener listener) { |
|
69 |
// for (SuperTableColumn column : columns) { |
|
70 |
// column.getTable().addMouseListener(listener); |
|
71 |
// } |
|
72 |
super.addMouseListener(listener); |
|
73 |
} |
|
74 |
|
|
45 | 75 |
public class SuperTableColumn extends TableViewer { |
46 | 76 |
SuperTableViewer table; |
77 |
Table t; |
|
47 | 78 |
Sash sash; |
48 | 79 |
FormData data = new FormData(); |
49 | 80 |
FormData data2 = new FormData(); |
50 | 81 |
String name; |
51 | 82 |
int position; |
52 | 83 |
|
53 |
protected SuperTableColumn(SuperTableViewer table, String name) { |
|
54 |
super(table, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER); |
|
84 |
protected SuperTableColumn(SuperTableViewer table2, String name) {
|
|
85 |
super(table2, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER);
|
|
55 | 86 |
|
56 |
this.table = table; |
|
87 |
this.table = table2; |
|
88 |
this.t = this.getTable(); |
|
89 |
getTable().setLinesVisible(true); |
|
90 |
getTable().setHeaderVisible(true); |
|
57 | 91 |
|
92 |
TableColumn firstColumn = new TableColumn(getTable(), SWT.LEFT); |
|
93 |
firstColumn.setWidth(0); |
|
94 |
firstColumn.setResizable(false); |
|
95 |
|
|
58 | 96 |
sash = new Sash(table, SWT.VERTICAL); |
59 | 97 |
sash.addSelectionListener(new SelectionAdapter() { |
60 | 98 |
public void widgetSelected(SelectionEvent event) { |
... | ... | |
62 | 100 |
sash.getParent().layout(); |
63 | 101 |
} |
64 | 102 |
}); |
103 |
|
|
104 |
t.addSelectionListener(new SelectionListener() { |
|
105 |
@Override |
|
106 |
public void widgetSelected(SelectionEvent e) { |
|
107 |
for (SuperTableColumn col : table.columns) { |
|
108 |
if (col != SuperTableColumn.this) { |
|
109 |
col.getTable().deselectAll(); |
|
110 |
col.getTable().select(t.getSelectionIndices()); |
|
111 |
} |
|
112 |
} |
|
113 |
|
|
114 |
} |
|
115 |
@Override |
|
116 |
public void widgetDefaultSelected(SelectionEvent e) { } |
|
117 |
}); |
|
118 |
ScrollBar vBarLeft = t.getVerticalBar(); |
|
119 |
vBarLeft.addListener(SWT.Selection, new Listener() { |
|
120 |
@Override |
|
121 |
public void handleEvent(Event event) { |
|
122 |
for (SuperTableColumn col : table.columns) { |
|
123 |
if (col != SuperTableColumn.this) { |
|
124 |
if (Util.isLinux()) { |
|
125 |
col.setSelection(getSelection()); |
|
126 |
} else { |
|
127 |
col.getTable().setTopIndex(t.getTopIndex()); |
|
128 |
} |
|
129 |
} |
|
130 |
} |
|
131 |
|
|
132 |
} |
|
133 |
}); |
|
65 | 134 |
} |
66 | 135 |
|
67 | 136 |
public void updatePosition(int position) { |
... | ... | |
85 | 154 |
} |
86 | 155 |
sash.setLayoutData(data2); |
87 | 156 |
} |
157 |
|
|
158 |
public TableViewerColumn newColumn(int style) { |
|
159 |
TableViewerColumn col = new TableViewerColumn(this, style); |
|
160 |
return col; |
|
161 |
} |
|
162 |
|
|
163 |
public void setWidth(int w) { |
|
164 |
data2.left = new FormAttachment(w); |
|
165 |
} |
|
88 | 166 |
} |
89 | 167 |
|
90 | 168 |
public SuperTableColumn getColumn(int i) { |
Formats disponibles : Unified diff