| 53 |
53 |
*
|
| 54 |
54 |
*/
|
| 55 |
55 |
public class ProgressionEventCallBack extends EventCallBack {
|
| 56 |
|
|
|
56 |
|
| 57 |
57 |
/**
|
| 58 |
58 |
* To keep track of the concordance lines and recomputing only if the selected item is out of this range.
|
| 59 |
59 |
*/
|
| ... | ... | |
| 63 |
63 |
* To keep track of the concordance lines sort and recomputing only if the sorting order has changed.
|
| 64 |
64 |
*/
|
| 65 |
65 |
protected LineComparator lastSortingComparator = null;
|
| 66 |
|
|
|
66 |
|
| 67 |
67 |
@Override
|
| 68 |
68 |
public void processEvent(final Object event, final int eventArea, final Object o) {
|
| 69 |
69 |
|
| 70 |
70 |
// Need to run this in the SWT UI thread because it's called from the AWT UI thread in TBX charts engine layer
|
| 71 |
71 |
chartEditor.getComposite().getDisplay().asyncExec(new Runnable() {
|
|
72 |
|
|
73 |
@Override
|
| 72 |
74 |
public void run() {
|
| 73 |
|
|
|
75 |
|
| 74 |
76 |
AWTEvent awtEvent = (AWTEvent) event;
|
| 75 |
77 |
|
| 76 |
78 |
// Mouse event
|
| 77 |
|
if(event instanceof MouseEvent) {
|
| 78 |
|
|
| 79 |
|
MouseEvent mouseEvent = (MouseEvent)event;
|
|
79 |
if (event instanceof MouseEvent) {
|
| 80 |
80 |
|
| 81 |
|
//return if it's not the left mouse button
|
| 82 |
|
if(mouseEvent.getButton() != MouseEvent.BUTTON1) {
|
|
81 |
MouseEvent mouseEvent = (MouseEvent) event;
|
|
82 |
|
|
83 |
// return if it's not the left mouse button
|
|
84 |
if (mouseEvent.getButton() != MouseEvent.BUTTON1) {
|
| 83 |
85 |
return;
|
| 84 |
86 |
}
|
| 85 |
87 |
|
| 86 |
88 |
ChartMouseEvent chartEvent = (ChartMouseEvent) o;
|
| 87 |
89 |
ChartEntity entity = chartEvent.getEntity();
|
| 88 |
90 |
final ArrayList<Integer> selectedPointPositions = ((ProgressionChartCreator) chartEditor.getResult().getChartCreator()).getSelectedPointPositions(chartEditor.getChart());
|
| 89 |
|
|
| 90 |
|
if(awtEvent.getID() == MouseEvent.MOUSE_CLICKED && mouseEvent.getClickCount() == 2 && eventArea == EventCallBack.AREA_ITEM && !selectedPointPositions.isEmpty()) {
|
| 91 |
|
|
|
91 |
|
|
92 |
if (awtEvent.getID() == MouseEvent.MOUSE_CLICKED && mouseEvent.getClickCount() == 2 && eventArea == EventCallBack.AREA_ITEM && !selectedPointPositions.isEmpty()) {
|
|
93 |
|
| 92 |
94 |
// Linked edition (CTRL/CMD + double click)
|
| 93 |
|
if((mouseEvent.getModifiers() & ZoomAndPanCallBack.keyboardZoomModifierKeyMask) != 0) {
|
|
95 |
if ((mouseEvent.getModifiers() & ZoomAndPanCallBack.keyboardZoomModifierKeyMask) != 0) {
|
| 94 |
96 |
// Creates or updates the linked editor
|
| 95 |
97 |
updateLinkedEditionEditor((SynopticEditionEditor) chartEditor.getLinkedEditor(SynopticEditionEditor.class), selectedPointPositions);
|
| 96 |
98 |
}
|
| 97 |
99 |
// Linked concordance
|
| 98 |
|
else {
|
|
100 |
else {
|
| 99 |
101 |
// Creates or updates the linked editor
|
| 100 |
102 |
updateLinkedConcordanceEditor(chartEditor.getLinkedEditors(ConcordanceEditor.class), selectedPointPositions);
|
| 101 |
103 |
}
|
| 102 |
104 |
}
|
| 103 |
|
else if(awtEvent.getID() == MouseEvent.MOUSE_CLICKED && mouseEvent.getClickCount() == 1 && eventArea == EventCallBack.AREA_ITEM) {
|
| 104 |
|
|
|
105 |
else if (awtEvent.getID() == MouseEvent.MOUSE_CLICKED && mouseEvent.getClickCount() == 1 && eventArea == EventCallBack.AREA_ITEM) {
|
|
106 |
|
| 105 |
107 |
// Get the linked concordance editors and update the one linked to the progression curve if it exists
|
| 106 |
108 |
ArrayList<EditorPart> linkedConcordancesEditors = chartEditor.getLinkedEditors(ConcordanceEditor.class);
|
| 107 |
|
if(!linkedConcordancesEditors.isEmpty()) {
|
|
109 |
if (!linkedConcordancesEditors.isEmpty()) {
|
| 108 |
110 |
updateLinkedConcordanceEditor(linkedConcordancesEditors, selectedPointPositions);
|
| 109 |
111 |
}
|
| 110 |
112 |
|
| 111 |
113 |
|
| 112 |
114 |
// Get the linked edition editor and update it if exists
|
| 113 |
|
SynopticEditionEditor linkedEditionEditor = (SynopticEditionEditor)chartEditor.getLinkedEditor(SynopticEditionEditor.class);
|
| 114 |
|
if(linkedEditionEditor != null) {
|
|
115 |
SynopticEditionEditor linkedEditionEditor = (SynopticEditionEditor) chartEditor.getLinkedEditor(SynopticEditionEditor.class);
|
|
116 |
if (linkedEditionEditor != null) {
|
| 115 |
117 |
updateLinkedEditionEditor(linkedEditionEditor, selectedPointPositions);
|
| 116 |
118 |
}
|
| 117 |
119 |
|
| 118 |
120 |
}
|
| 119 |
|
else if(awtEvent.getID() == MouseEvent.MOUSE_CLICKED && mouseEvent.getClickCount() == 2 && eventArea == EventCallBack.AREA_EMPTY) {
|
|
121 |
else if (awtEvent.getID() == MouseEvent.MOUSE_CLICKED && mouseEvent.getClickCount() == 2 && eventArea == EventCallBack.AREA_EMPTY) {
|
| 120 |
122 |
// FIXME: debug
|
| 121 |
|
//System.err.println("ProgressionMouseClickedCallBack.processEvent(...).new Runnable() {...}.run(): double click in empty area");
|
|
123 |
// System.err.println("ProgressionMouseClickedCallBack.processEvent(...).new Runnable() {...}.run(): double click in empty area");
|
| 122 |
124 |
}
|
| 123 |
|
else if(awtEvent.getID() == MouseEvent.MOUSE_CLICKED && mouseEvent.getClickCount() == 1 && eventArea == EventCallBack.AREA_EMPTY) {
|
|
125 |
else if (awtEvent.getID() == MouseEvent.MOUSE_CLICKED && mouseEvent.getClickCount() == 1 && eventArea == EventCallBack.AREA_EMPTY) {
|
| 124 |
126 |
// FIXME: debug
|
| 125 |
|
//System.err.println("ProgressionMouseClickedCallBack.processEvent(...).new Runnable() {...}.run(): single click in empty area");
|
|
127 |
// System.err.println("ProgressionMouseClickedCallBack.processEvent(...).new Runnable() {...}.run(): single click in empty area");
|
| 126 |
128 |
}
|
| 127 |
129 |
}
|
| 128 |
130 |
// Key event
|
| 129 |
|
else if(event instanceof KeyEvent) {
|
| 130 |
|
KeyEvent keyEvent = (KeyEvent)event;
|
|
131 |
else if (event instanceof KeyEvent) {
|
|
132 |
KeyEvent keyEvent = (KeyEvent) event;
|
| 131 |
133 |
|
| 132 |
134 |
// return if zoom and pan modifier
|
| 133 |
|
if((keyEvent.getModifiers() & ZoomAndPanCallBack.keyboardZoomModifierKeyMask) != 0) {
|
|
135 |
if ((keyEvent.getModifiers() & ZoomAndPanCallBack.keyboardZoomModifierKeyMask) != 0) {
|
| 134 |
136 |
return;
|
| 135 |
137 |
}
|
| 136 |
138 |
|
| 137 |
139 |
// Arrow keys + return key
|
| 138 |
|
if(keyEvent.getKeyCode() == KeyEvent.VK_LEFT || keyEvent.getKeyCode() == KeyEvent.VK_RIGHT
|
| 139 |
|
|| keyEvent.getKeyCode() == KeyEvent.VK_ENTER) {
|
| 140 |
|
|
|
140 |
if (keyEvent.getKeyCode() == KeyEvent.VK_LEFT || keyEvent.getKeyCode() == KeyEvent.VK_RIGHT
|
|
141 |
|| keyEvent.getKeyCode() == KeyEvent.VK_ENTER) {
|
|
142 |
|
| 141 |
143 |
final ArrayList<Integer> selectedPointPositions = ((ProgressionChartCreator) chartEditor.getResult().getChartCreator()).getSelectedPointPositions(chartEditor.getChart());
|
| 142 |
|
|
|
144 |
|
| 143 |
145 |
// Get the linked concordance editors and update the one linked to the progression curve if it exists
|
| 144 |
146 |
ArrayList<EditorPart> linkedConcordancesEditors = chartEditor.getLinkedEditors(ConcordanceEditor.class);
|
| 145 |
|
if(keyEvent.getKeyCode() == KeyEvent.VK_ENTER || !linkedConcordancesEditors.isEmpty()) {
|
|
147 |
if (keyEvent.getKeyCode() == KeyEvent.VK_ENTER || !linkedConcordancesEditors.isEmpty()) {
|
| 146 |
148 |
updateLinkedConcordanceEditor(linkedConcordancesEditors, selectedPointPositions);
|
| 147 |
149 |
}
|
| 148 |
150 |
|
| 149 |
151 |
// Get the linked edition editor and update it if exists
|
| 150 |
|
SynopticEditionEditor linkedEditionEditor = (SynopticEditionEditor)chartEditor.getLinkedEditor(SynopticEditionEditor.class);
|
| 151 |
|
if(linkedEditionEditor != null) {
|
|
152 |
SynopticEditionEditor linkedEditionEditor = (SynopticEditionEditor) chartEditor.getLinkedEditor(SynopticEditionEditor.class);
|
|
153 |
if (linkedEditionEditor != null) {
|
| 152 |
154 |
updateLinkedEditionEditor(linkedEditionEditor, selectedPointPositions);
|
| 153 |
155 |
}
|
| 154 |
156 |
}
|
| 155 |
157 |
}
|
| 156 |
158 |
}
|
| 157 |
159 |
});
|
| 158 |
|
|
|
160 |
|
| 159 |
161 |
}
|
| 160 |
162 |
|
| 161 |
163 |
|
| ... | ... | |
| 167 |
169 |
* @param linkedEditors
|
| 168 |
170 |
* @param selectedPointPositions
|
| 169 |
171 |
*/
|
| 170 |
|
public void updateLinkedConcordanceEditor(ArrayList<EditorPart> linkedEditors, final ArrayList<Integer> selectedPointPositions) {
|
| 171 |
|
|
|
172 |
public void updateLinkedConcordanceEditor(ArrayList<EditorPart> linkedEditors, final ArrayList<Integer> selectedPointPositions) {
|
|
173 |
|
| 172 |
174 |
// Debug
|
| 173 |
175 |
Log.finest("ProgressionEventCallBack.updateLinkedConcordanceEditor(): linked editors count: " + linkedEditors.size()); //$NON-NLS-1$
|
| 174 |
176 |
|
| 175 |
177 |
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
|
| 176 |
178 |
IWorkbenchPage page = window.getActivePage();
|
| 177 |
|
|
|
179 |
|
| 178 |
180 |
// Get and format the progression query from the selected chart series
|
| 179 |
181 |
// FIXME: case 1, the query is the query of the selected chart series
|
| 180 |
|
// ArrayList<Integer> selectedSeries = chartEditor.getEditorInput().getSWTChartComponentsProvider().getChartsEngine().getProgressionChartSelectedSeries(chartEditor.getChart());
|
| 181 |
|
// String query = ((Progression) chartEditor.getResultData()).getQueries().get(selectedSeries.get(selectedSeries.size() - 1).intValue()).getQueryString();
|
|
182 |
// ArrayList<Integer> selectedSeries = chartEditor.getEditorInput().getSWTChartComponentsProvider().getChartsEngine().getProgressionChartSelectedSeries(chartEditor.getChart());
|
|
183 |
// String query = ((Progression) chartEditor.getResultData()).getQueries().get(selectedSeries.get(selectedSeries.size() - 1).intValue()).getQueryString();
|
| 182 |
184 |
|
| 183 |
185 |
int lastSelectedSeries = ((ProgressionChartCreator) chartEditor.getResult().getChartCreator()).getLastSelectedSeries(chartEditor.getChart());
|
| 184 |
186 |
if (lastSelectedSeries == -1) { // no selection
|
| 185 |
187 |
return;
|
| 186 |
188 |
}
|
| 187 |
189 |
String query = ((Progression) chartEditor.getResult()).getQueries().get(lastSelectedSeries).getQueryString();
|
| 188 |
|
|
| 189 |
|
// // Remove "[" and "]" only if it's a simple query as "[faire]"
|
| 190 |
|
// if(query.startsWith("[") && !query.contains("=")) { //$NON-NLS-1$ //$NON-NLS-2$
|
| 191 |
|
// int length = query.length();
|
| 192 |
|
// if(query.endsWith("]")) { //$NON-NLS-1$
|
| 193 |
|
// length--;
|
| 194 |
|
// }
|
| 195 |
|
// query = query.substring(1, length);
|
| 196 |
|
// }
|
| 197 |
|
|
|
190 |
|
|
191 |
// // Remove "[" and "]" only if it's a simple query as "[faire]"
|
|
192 |
// if(query.startsWith("[") && !query.contains("=")) { //$NON-NLS-1$ //$NON-NLS-2$
|
|
193 |
// int length = query.length();
|
|
194 |
// if(query.endsWith("]")) { //$NON-NLS-1$
|
|
195 |
// length--;
|
|
196 |
// }
|
|
197 |
// query = query.substring(1, length);
|
|
198 |
// }
|
|
199 |
|
| 198 |
200 |
// FIXME: case 2, the query is the combination of all the queries of the progression
|
| 199 |
|
// String query = ((Progression) chartEditor.getResultData()).getQueriesString();
|
|
201 |
// String query = ((Progression) chartEditor.getResultData()).getQueriesString();
|
| 200 |
202 |
|
| 201 |
203 |
// gets the linked editor according to the query if it exists
|
| 202 |
204 |
ConcordanceEditor linkedEditor = null;
|
| 203 |
|
for(int i = 0; i < linkedEditors.size(); i++) {
|
| 204 |
|
if(query.equals(((ConcordanceEditor) linkedEditors.get(i)).getConcordance().getQuery().getQueryString())) {
|
|
205 |
for (int i = 0; i < linkedEditors.size(); i++) {
|
|
206 |
if (query.equals(((ConcordanceEditor) linkedEditors.get(i)).getConcordance().getQuery().getQueryString())) {
|
| 205 |
207 |
linkedEditor = ((ConcordanceEditor) linkedEditors.get(i));
|
| 206 |
208 |
break;
|
| 207 |
209 |
}
|
| ... | ... | |
| 219 |
221 |
newEditor = true;
|
| 220 |
222 |
}
|
| 221 |
223 |
else {
|
| 222 |
|
editorInput = (TXMResultEditorInput) linkedEditor.getEditorInput();
|
|
224 |
editorInput = linkedEditor.getEditorInput();
|
| 223 |
225 |
}
|
| 224 |
|
|
|
226 |
|
| 225 |
227 |
try {
|
| 226 |
228 |
boolean wasOpenedEditor = SWTEditorsUtils.isOpenEditor(editorInput, ConcordanceEditor.ID);
|
| 227 |
229 |
|
| 228 |
230 |
linkedEditor = (ConcordanceEditor) page.openEditor(editorInput, ConcordanceEditor.ID, false);
|
| 229 |
|
if(newEditor) {
|
|
231 |
if (newEditor) {
|
| 230 |
232 |
chartEditor.addLinkedEditor(linkedEditor);
|
| 231 |
233 |
}
|
| 232 |
234 |
|
| 233 |
235 |
// Split the area and insert the new editor
|
| 234 |
|
if(!wasOpenedEditor) {
|
|
236 |
if (!wasOpenedEditor) {
|
| 235 |
237 |
|
| 236 |
238 |
int position = EModelService.BELOW;
|
| 237 |
239 |
EditorPart parentEditor = chartEditor;
|
| 238 |
240 |
|
| 239 |
241 |
// Split vertically if there is already a concordance or an edition editor otherwise split horizontally
|
| 240 |
|
if(linkedEditors != null && !linkedEditors.isEmpty()) {
|
|
242 |
if (linkedEditors != null && !linkedEditors.isEmpty()) {
|
| 241 |
243 |
position = EModelService.RIGHT_OF;
|
| 242 |
244 |
parentEditor = linkedEditors.get(linkedEditors.size() - 1);
|
| 243 |
245 |
|
| ... | ... | |
| 252 |
254 |
catch (PartInitException e) {
|
| 253 |
255 |
System.err.println(NLS.bind(TXMCoreMessages.errorColonP0, e.getLocalizedMessage()));
|
| 254 |
256 |
}
|
| 255 |
|
|
|
257 |
|
| 256 |
258 |
// Compute the concordance if it has never been computed
|
| 257 |
|
if(newEditor) {
|
|
259 |
if (newEditor) {
|
| 258 |
260 |
Job job = linkedEditor.compute(false);
|
| 259 |
|
|
|
261 |
|
| 260 |
262 |
final ConcordanceEditor linkedEditor2 = linkedEditor;
|
| 261 |
263 |
|
| 262 |
|
job.addJobChangeListener(new JobChangeAdapter() {
|
|
264 |
job.addJobChangeListener(new JobChangeAdapter() {
|
|
265 |
|
| 263 |
266 |
@Override
|
| 264 |
267 |
public void done(IJobChangeEvent event) {
|
| 265 |
268 |
super.done(event);
|
| 266 |
269 |
|
| 267 |
270 |
// initialize range change tracking variables
|
| 268 |
271 |
lastConcordanceTopLine = -1;
|
| 269 |
|
//lastConcordanceBottomLine = linkedEditor.getLinePerPage();
|
|
272 |
// lastConcordanceBottomLine = linkedEditor.getLinePerPage();
|
| 270 |
273 |
lastSortingComparator = linkedEditor2.getCurrentComparator();
|
| 271 |
|
|
|
274 |
|
| 272 |
275 |
updateLinkedConcordanceEditor(linkedEditor2, selectedPointPositions, true);
|
| 273 |
276 |
|
| 274 |
277 |
// give back the focus to the chart editor and chart composite
|
| 275 |
278 |
chartEditor.getComposite().getDisplay().asyncExec(new Runnable() {
|
|
279 |
|
| 276 |
280 |
@Override
|
| 277 |
281 |
public void run() {
|
| 278 |
282 |
chartEditor.setFocus();
|
| ... | ... | |
| 286 |
290 |
|
| 287 |
291 |
|
| 288 |
292 |
}
|
| 289 |
|
else {
|
|
293 |
else {
|
| 290 |
294 |
updateLinkedConcordanceEditor(linkedEditor, selectedPointPositions, false);
|
| 291 |
|
//chartEditor.getChartComposite().setFocus();
|
|
295 |
// chartEditor.getChartComposite().setFocus();
|
| 292 |
296 |
}
|
| 293 |
297 |
|
| 294 |
298 |
// give back the focus to chart editor and the chart composite
|
| 295 |
|
//chartEditor.setFocus();
|
| 296 |
|
//chartEditor.getChartComposite().setFocus();
|
|
299 |
// chartEditor.setFocus();
|
|
300 |
// chartEditor.getChartComposite().setFocus();
|
| 297 |
301 |
}
|
| 298 |
|
|
| 299 |
|
|
|
302 |
|
|
303 |
|
| 300 |
304 |
/**
|
| 301 |
305 |
*
|
| 302 |
306 |
* @param linkedEditor
|
| 303 |
307 |
* @param selectedPointPositions
|
| 304 |
308 |
* @param loadLines
|
| 305 |
309 |
*/
|
| 306 |
|
public void updateLinkedConcordanceEditor(final ConcordanceEditor linkedEditor, final ArrayList<Integer> selectedPointPositions, boolean loadLines) {
|
|
310 |
public void updateLinkedConcordanceEditor(final ConcordanceEditor linkedEditor, final ArrayList<Integer> selectedPointPositions, boolean loadLines) {
|
| 307 |
311 |
|
| 308 |
312 |
final TableViewer tableViewer = linkedEditor.getLineTableViewer();
|
| 309 |
313 |
|
| 310 |
|
if(tableViewer.getTable().isDisposed()) {
|
|
314 |
if (tableViewer.getTable().isDisposed()) {
|
| 311 |
315 |
return;
|
| 312 |
316 |
}
|
| 313 |
317 |
|
| 314 |
|
if(selectedPointPositions.size() > 0) {
|
| 315 |
|
|
|
318 |
if (selectedPointPositions.size() > 0) {
|
|
319 |
|
| 316 |
320 |
// Get the index of the last selected point in concordance according to the global token position and concordance sorting order
|
| 317 |
321 |
int lineIndex = linkedEditor.getConcordance().indexOf(selectedPointPositions.get(selectedPointPositions.size() - 1));
|
| 318 |
322 |
|
| ... | ... | |
| 322 |
326 |
|
| 323 |
327 |
// Manage the lazy loading of new lines range in the concordance table
|
| 324 |
328 |
// page change
|
| 325 |
|
if(lastConcordanceTopLine != top) {
|
|
329 |
if (lastConcordanceTopLine != top) {
|
| 326 |
330 |
loadLines = true;
|
| 327 |
331 |
}
|
| 328 |
332 |
// sort change
|
| 329 |
|
else if(lastSortingComparator != linkedEditor.getCurrentComparator()) {
|
|
333 |
else if (lastSortingComparator != linkedEditor.getCurrentComparator()) {
|
| 330 |
334 |
loadLines = true;
|
| 331 |
335 |
}
|
| 332 |
|
|
| 333 |
336 |
|
|
337 |
|
| 334 |
338 |
// Loads new lines, fill the display area and select the table row
|
| 335 |
|
if(loadLines) {
|
|
339 |
if (loadLines) {
|
| 336 |
340 |
Display.getDefault().syncExec(new Runnable() {
|
|
341 |
|
| 337 |
342 |
@Override
|
| 338 |
343 |
public void run() {
|
| 339 |
344 |
linkedEditor.fillDisplayArea(true);
|
| 340 |
345 |
}
|
| 341 |
346 |
});
|
| 342 |
347 |
}
|
| 343 |
|
|
|
348 |
|
| 344 |
349 |
// update range change tracking variables
|
| 345 |
350 |
lastConcordanceTopLine = top;
|
| 346 |
|
//lastConcordanceBottomLine = bottom;
|
|
351 |
// lastConcordanceBottomLine = bottom;
|
| 347 |
352 |
lastSortingComparator = linkedEditor.getCurrentComparator();
|
| 348 |
353 |
|
| 349 |
354 |
|
| 350 |
|
final int selectedPointInTableRange = lineIndex - top;
|
| 351 |
|
|
|
355 |
final int selectedPointInTableRange = lineIndex - top;
|
|
356 |
|
| 352 |
357 |
tableViewer.getControl().getDisplay().asyncExec(new Runnable() {
|
|
358 |
|
| 353 |
359 |
@Override
|
| 354 |
360 |
public void run() {
|
| 355 |
361 |
tableViewer.getTable().deselectAll();
|
| 356 |
362 |
|
| 357 |
363 |
Object line = tableViewer.getElementAt(selectedPointInTableRange);
|
| 358 |
|
if(line != null) {
|
|
364 |
if (line != null) {
|
| 359 |
365 |
tableViewer.setSelection(new StructuredSelection(line), true);
|
| 360 |
366 |
// FIXME: commented because the set top index makes the read of the table difficult
|
| 361 |
|
//tableViewer.getTable().setTopIndex(selectedPointInTableRange);
|
| 362 |
|
Log.finest("ProgressionEventCallBack.updateLinkedConcordanceEditor(...).new Runnable() {...}.run(): Selecting progression point (" + selectedPointInTableRange + " / " + tableViewer.getTable().getItemCount() + ") in the linked Concordance table."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
|
367 |
// tableViewer.getTable().setTopIndex(selectedPointInTableRange);
|
|
368 |
Log.finest("ProgressionEventCallBack.updateLinkedConcordanceEditor(...).new Runnable() {...}.run(): Selecting progression point (" + selectedPointInTableRange + " / " //$NON-NLS-1$ //$NON-NLS-2$
|
|
369 |
+ tableViewer.getTable().getItemCount() + ") in the linked Concordance table."); //$NON-NLS-1$
|
| 363 |
370 |
}
|
| 364 |
|
else {
|
| 365 |
|
Log.finest("ProgressionEventCallBack.updateLinkedConcordanceEditor(...).new Runnable() {...}.run(): Selected progression point (" + selectedPointInTableRange + " / " + tableViewer.getTable().getItemCount() + ") doesn't exist in the linked Concordance table."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
|
371 |
else {
|
|
372 |
Log.finest("ProgressionEventCallBack.updateLinkedConcordanceEditor(...).new Runnable() {...}.run(): Selected progression point (" + selectedPointInTableRange + " / " //$NON-NLS-1$ //$NON-NLS-2$
|
|
373 |
+ tableViewer.getTable().getItemCount() + ") doesn't exist in the linked Concordance table."); //$NON-NLS-1$
|
| 366 |
374 |
}
|
| 367 |
375 |
}
|
| 368 |
376 |
});
|
| 369 |
377 |
}
|
| 370 |
|
else {
|
|
378 |
else {
|
| 371 |
379 |
tableViewer.getTable().deselectAll();
|
| 372 |
380 |
}
|
| 373 |
381 |
}
|
| 374 |
382 |
|
| 375 |
|
//FIXME: version with new SynopticEditionEditor system edition
|
|
383 |
// FIXME: version with new SynopticEditionEditor system edition
|
| 376 |
384 |
/**
|
| 377 |
385 |
* Updates the linked edition editor.
|
| 378 |
386 |
* If the editor doesn't exist it will be created.
|
|
387 |
*
|
| 379 |
388 |
* @param editor
|
| 380 |
389 |
*/
|
| 381 |
|
public void updateLinkedEditionEditor(SynopticEditionEditor linkedEditor, ArrayList<Integer> selectedPointPositions) {
|
|
390 |
public void updateLinkedEditionEditor(SynopticEditionEditor linkedEditor, ArrayList<Integer> selectedPointPositions) {
|
| 382 |
391 |
|
| 383 |
392 |
try {
|
| 384 |
|
|
|
393 |
|
| 385 |
394 |
ArrayList<Color> seriesColors = chartEditor.getResult().getChartCreator().getSeriesShapesColors(chartEditor.getChart());
|
| 386 |
395 |
RGBA selectedWordColor = new RGBA(255, 10, 10);
|
| 387 |
|
|
|
396 |
|
| 388 |
397 |
// Unhighlight all tokens
|
| 389 |
|
if(linkedEditor != null) {
|
|
398 |
if (linkedEditor != null) {
|
| 390 |
399 |
linkedEditor.removeHighlightWords();
|
| 391 |
400 |
linkedEditor.updateWordStyles();
|
| 392 |
401 |
}
|
| ... | ... | |
| 396 |
405 |
Property textP = textS.getProperty(CorpusBuild.ID);
|
| 397 |
406 |
Match selectedWordMatch = new Match(selectedPointPositions.get(selectedPointPositions.size() - 1), selectedPointPositions.get(selectedPointPositions.size() - 1));
|
| 398 |
407 |
String textId = selectedWordMatch.getValueForProperty(textP);
|
| 399 |
|
|
|
408 |
|
| 400 |
409 |
Text text = corpus.getProject().getText(textId);
|
| 401 |
|
if(text == null) {
|
|
410 |
if (text == null) {
|
| 402 |
411 |
Log.severe(ProgressionUIMessages.bind(ProgressionUIMessages.textP0IsMissing, textId));
|
| 403 |
412 |
return;
|
| 404 |
413 |
}
|
| 405 |
|
|
|
414 |
|
| 406 |
415 |
Edition edition = text.getEdition(corpus.getProject().getDefaultEdition());
|
| 407 |
|
|
| 408 |
|
if(edition == null) {
|
|
416 |
|
|
417 |
if (edition == null) {
|
| 409 |
418 |
Log.severe(ProgressionUIMessages.defaultEditionIsMissing);
|
| 410 |
419 |
return;
|
| 411 |
420 |
}
|
| 412 |
|
|
|
421 |
|
| 413 |
422 |
// Compute the edition if needed
|
| 414 |
|
if(!edition.hasBeenComputedOnce()) {
|
|
423 |
if (!edition.hasBeenComputedOnce()) {
|
| 415 |
424 |
edition.compute();
|
| 416 |
425 |
}
|
| 417 |
426 |
|
| 418 |
427 |
// Get the current selected word to highlight more
|
| 419 |
428 |
List<String> selectedWordIds = selectedWordMatch.getValuesForProperty(corpus.getProperty(CorpusBuild.ID));
|
| 420 |
|
|
|
429 |
|
| 421 |
430 |
// Get all words to highlight from the progression chart data set
|
| 422 |
|
ArrayList<ArrayList<Integer>> allPointPositionsBySeries = ((ProgressionChartCreator)chartEditor.getResult().getChartCreator()).getAllPointPositionsBySeries(chartEditor.getChart());
|
|
431 |
ArrayList<ArrayList<Integer>> allPointPositionsBySeries = ((ProgressionChartCreator) chartEditor.getResult().getChartCreator()).getAllPointPositionsBySeries(chartEditor.getChart());
|
| 423 |
432 |
|
| 424 |
|
ArrayList<ArrayList<String>> allWordIds = new ArrayList<ArrayList<String>>(allPointPositionsBySeries.size());
|
| 425 |
|
for(int i = 0; i < allPointPositionsBySeries.size(); i++) {
|
|
433 |
ArrayList<ArrayList<String>> allWordIds = new ArrayList<>(allPointPositionsBySeries.size());
|
|
434 |
for (int i = 0; i < allPointPositionsBySeries.size(); i++) {
|
| 426 |
435 |
ArrayList<Integer> positions = allPointPositionsBySeries.get(i);
|
| 427 |
|
ArrayList<String> wordsIds = new ArrayList<String>();
|
| 428 |
|
for(int j = 0; j < positions.size(); j++) {
|
| 429 |
|
Match match = new Match(positions.get(j), positions.get(j));
|
| 430 |
|
if(match.getValueForProperty(textP).equals(textId)) {
|
| 431 |
|
wordsIds.add(match.getValueForProperty(corpus.getProperty(CorpusBuild.ID))); //$NON-NLS-1$;
|
|
436 |
ArrayList<String> wordsIds = new ArrayList<>();
|
|
437 |
for (int j = 0; j < positions.size(); j++) {
|
|
438 |
Match match = new Match(positions.get(j), positions.get(j));
|
|
439 |
if (match.getValueForProperty(textP).equals(textId)) {
|
|
440 |
wordsIds.add(match.getValueForProperty(corpus.getProperty(CorpusBuild.ID))); // ;
|
| 432 |
441 |
}
|
| 433 |
442 |
}
|
| 434 |
443 |
allWordIds.add(wordsIds);
|
| 435 |
444 |
}
|
| 436 |
|
|
|
445 |
|
| 437 |
446 |
Page openPage = edition.getPageForWordId(selectedWordIds.get(0));
|
| 438 |
|
|
| 439 |
|
if(openPage != null) {
|
| 440 |
|
|
|
447 |
|
|
448 |
if (openPage != null) {
|
|
449 |
|
| 441 |
450 |
// Create the linked editor if needed
|
| 442 |
|
if(linkedEditor == null || linkedEditor.isDisposed()) {
|
|
451 |
if (linkedEditor == null || linkedEditor.isDisposed()) {
|
| 443 |
452 |
linkedEditor = OpenEdition.openEdition(corpus, OpenEdition.getDefaultEditions(corpus));
|
| 444 |
453 |
chartEditor.addLinkedEditor(linkedEditor);
|
| 445 |
454 |
|
| 446 |
455 |
|
| 447 |
|
int position = EModelService.BELOW;;
|
|
456 |
int position = EModelService.BELOW;
|
|
457 |
;
|
| 448 |
458 |
EditorPart parentEditor = chartEditor;
|
| 449 |
459 |
// Split vertically if there is already a concordance editor otherwise split horizontally
|
| 450 |
|
ConcordanceEditor linkedConcordanceEditor = (ConcordanceEditor)chartEditor.getLinkedEditor(ConcordanceEditor.class);
|
| 451 |
|
if(linkedConcordanceEditor != null) {
|
|
460 |
ConcordanceEditor linkedConcordanceEditor = (ConcordanceEditor) chartEditor.getLinkedEditor(ConcordanceEditor.class);
|
|
461 |
if (linkedConcordanceEditor != null) {
|
| 452 |
462 |
position = EModelService.RIGHT_OF;
|
| 453 |
463 |
parentEditor = linkedConcordanceEditor;
|
| 454 |
464 |
}
|
| ... | ... | |
| 456 |
466 |
// Split and add linked editor
|
| 457 |
467 |
SWTEditorsUtils.addEditor(parentEditor, linkedEditor, position);
|
| 458 |
468 |
}
|
| 459 |
|
|
|
469 |
|
| 460 |
470 |
linkedEditor.setText(text, true);
|
| 461 |
471 |
linkedEditor.goToPage(openPage.getName());
|
| 462 |
472 |
|
| 463 |
473 |
// Highlight tokens by series
|
| 464 |
|
for(int i = 0; i < allWordIds.size(); i++) {
|
|
474 |
for (int i = 0; i < allWordIds.size(); i++) {
|
| 465 |
475 |
linkedEditor.addHighlightWordsById(new RGBA(seriesColors.get(i).getRed(), seriesColors.get(i).getGreen(), seriesColors.get(i).getBlue()), allWordIds.get(i));
|
| 466 |
476 |
}
|
| 467 |
477 |
// Highlight selected curve token
|
| ... | ... | |
| 473 |
483 |
|
| 474 |
484 |
// FIXME: SJ: need to check that. Under Linux it seems we need to give back the focus to the chart editor and composite
|
| 475 |
485 |
// give back the focus to the chart editor and chart composite
|
| 476 |
|
// chartEditor.getComposite().getDisplay().asyncExec(new Runnable() {
|
| 477 |
|
// @Override
|
| 478 |
|
// public void run() {
|
| 479 |
|
// chartEditor.setFocus();
|
| 480 |
|
// chartEditor.getChartComposite().setFocus();
|
| 481 |
|
// }
|
| 482 |
|
// });
|
| 483 |
|
|
|
486 |
// chartEditor.getComposite().getDisplay().asyncExec(new Runnable() {
|
|
487 |
// @Override
|
|
488 |
// public void run() {
|
|
489 |
// chartEditor.setFocus();
|
|
490 |
// chartEditor.getChartComposite().setFocus();
|
|
491 |
// }
|
|
492 |
// });
|
|
493 |
|
| 484 |
494 |
}
|
| 485 |
495 |
}
|
| 486 |
|
catch(Exception e) {
|
|
496 |
catch (Exception e) {
|
| 487 |
497 |
Log.printStackTrace(e);
|
| 488 |
498 |
}
|
| 489 |
499 |
}
|
| 490 |
|
|
| 491 |
500 |
|
| 492 |
|
|
| 493 |
|
}
|
|
501 |
|
|
502 |
|
|
503 |
}
|