118 |
118 |
* <p>
|
119 |
119 |
*/
|
120 |
120 |
public class CorporaView extends ViewPart {
|
121 |
|
|
|
121 |
|
122 |
122 |
/** The ID. */
|
123 |
123 |
static public String ID = CorporaView.class.getName();
|
124 |
|
|
|
124 |
|
125 |
125 |
/** The tree viewer. */
|
126 |
126 |
public TreeViewer treeViewer;
|
127 |
|
|
128 |
|
/** The self. */
|
129 |
|
private static CorporaView self;
|
130 |
|
|
|
127 |
|
131 |
128 |
/**
|
132 |
129 |
* stores the class that are managed by a Doubleclick handler
|
133 |
130 |
*/
|
134 |
131 |
// private static HashMap<Class, Class> managedDoubleClickClasses = new HashMap<Class, Class>();
|
135 |
|
|
136 |
|
|
|
132 |
|
|
133 |
|
137 |
134 |
public static HashMap<String, String> doubleClickInstalledCommands = new HashMap<>();
|
138 |
|
|
139 |
|
|
|
135 |
|
|
136 |
|
140 |
137 |
// public static HashMap<Class, Class> getManagedDoubleClickClasses() {
|
141 |
138 |
// return managedDoubleClickClasses;
|
142 |
139 |
// }
|
143 |
|
|
144 |
|
|
|
140 |
|
|
141 |
|
145 |
142 |
/**
|
146 |
143 |
* Gets the single instance of CorporaView.
|
147 |
144 |
*
|
148 |
145 |
* @return single instance of CorporaView
|
149 |
146 |
*/
|
150 |
147 |
public static CorporaView getInstance() {
|
151 |
|
if (self == null) {
|
152 |
|
if (!PlatformUI.isWorkbenchRunning()) return null;
|
153 |
|
|
154 |
|
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
|
155 |
|
if (window == null) return null;
|
156 |
|
IWorkbenchPage page = window.getActivePage();
|
157 |
|
if (page == null) return null;
|
158 |
|
CorporaView corporaView = (CorporaView) page.findView(CorporaView.ID);
|
159 |
|
self = corporaView;
|
160 |
|
}
|
161 |
|
return self;
|
|
148 |
|
|
149 |
if (!PlatformUI.isWorkbenchRunning()) return null;
|
|
150 |
|
|
151 |
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
|
|
152 |
if (window == null) return null;
|
|
153 |
IWorkbenchPage page = window.getActivePage();
|
|
154 |
if (page == null) return null;
|
|
155 |
|
|
156 |
return (CorporaView) page.findView(CorporaView.ID);
|
162 |
157 |
}
|
163 |
|
|
|
158 |
|
164 |
159 |
public TreeViewer getTreeViewer() {
|
165 |
160 |
return treeViewer;
|
166 |
161 |
}
|
167 |
|
|
168 |
|
|
|
162 |
|
|
163 |
|
169 |
164 |
/**
|
170 |
165 |
* Reload.
|
171 |
166 |
*/
|
172 |
167 |
public static void reload() {
|
173 |
168 |
// System.out.println("Reload corpora view");
|
174 |
169 |
CorporaView corporaView = getInstance();
|
175 |
|
if (corporaView != null)
|
|
170 |
if (corporaView != null) {
|
176 |
171 |
corporaView._reload();
|
|
172 |
}
|
177 |
173 |
}
|
178 |
|
|
|
174 |
|
179 |
175 |
/**
|
180 |
176 |
* _reload.
|
181 |
177 |
*/
|
182 |
178 |
public void _reload() {
|
|
179 |
|
183 |
180 |
if (Toolbox.isInitialized()) {
|
184 |
|
|
|
181 |
|
185 |
182 |
treeViewer.setContentProvider(new CorpusViewContentProvider(this));
|
186 |
183 |
ColumnViewerToolTipSupport.enableFor(treeViewer);
|
187 |
|
|
|
184 |
|
188 |
185 |
treeViewer.setLabelProvider(new CorpusViewLabelProvider(new WorkbenchLabelProvider(), PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator()));
|
189 |
|
|
|
186 |
|
190 |
187 |
Workspace w = Toolbox.workspace;
|
191 |
188 |
if (w == null) {
|
192 |
189 |
return;
|
... | ... | |
195 |
192 |
treeViewer.refresh();
|
196 |
193 |
}
|
197 |
194 |
}
|
198 |
|
|
|
195 |
|
199 |
196 |
/**
|
200 |
197 |
* This is a callback that will allow us to create the viewer and initialize
|
201 |
198 |
* it.
|
... | ... | |
204 |
201 |
*/
|
205 |
202 |
@Override
|
206 |
203 |
public void createPartControl(Composite parent) {
|
|
204 |
|
207 |
205 |
treeViewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
|
208 |
206 |
PlatformUI.getWorkbench().getHelpSystem().setHelp(treeViewer.getControl(), TXMUIMessages.corpus);
|
209 |
207 |
getSite().setSelectionProvider(treeViewer);
|
210 |
208 |
treeViewer.setColumnProperties(new String[] { "name" }); // mandatory to enable edit mode -> used to identify columns //$NON-NLS-1$
|
211 |
|
|
212 |
|
|
213 |
|
// ColumnViewerEditorActivationStrategy actSupport = new ColumnViewerEditorActivationStrategy(treeViewer) {
|
214 |
|
// protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event) {
|
215 |
|
// System.out.println("activated");
|
216 |
|
// return event.keyCode == SWT.F2;
|
217 |
|
// }
|
218 |
|
// };
|
219 |
|
// int f = ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR |
|
220 |
|
// ColumnViewerEditor.TABBING_VERTICAL |
|
221 |
|
// ColumnViewerEditor.KEYBOARD_ACTIVATION;
|
222 |
|
//
|
223 |
|
// TreeViewerEditor.create(treeViewer, actSupport, f);
|
224 |
|
//
|
225 |
|
// treeViewer.setCellEditors(new CellEditor[]{new TextCellEditor(treeViewer.getTree())});
|
226 |
|
// treeViewer.setCellModifier(new ICellModifier() {
|
227 |
|
//
|
228 |
|
// @Override
|
229 |
|
// public void modify(Object element, String property, Object value) {
|
230 |
|
// System.out.println("modify: "+element+" "+property+" "+value);
|
231 |
|
// if (element instanceof TreeItem)
|
232 |
|
// {
|
233 |
|
// //update element and tree model
|
234 |
|
// TreeItem treeItem = (TreeItem)element;
|
235 |
|
// TXMResult data = (TXMResult)treeItem.getData();
|
236 |
|
// data.setUserName(value.toString());
|
237 |
|
// treeItem.setText(value.toString());
|
238 |
|
// }
|
239 |
|
// }
|
240 |
|
//
|
241 |
|
// @Override
|
242 |
|
// public Object getValue(Object element, String property) {
|
243 |
|
// if (element instanceof TXMResult) {
|
244 |
|
// return ((TXMResult)element).getUserName();
|
245 |
|
// }
|
246 |
|
// return element.toString();
|
247 |
|
// }
|
248 |
|
//
|
249 |
|
// @Override
|
250 |
|
// public boolean canModify(Object element, String property) {
|
251 |
|
// return element instanceof TXMResult;
|
252 |
|
// }
|
253 |
|
// });
|
254 |
|
|
255 |
|
// treeViewer.addFilter(new ViewerFilter() {
|
256 |
|
// @Override
|
257 |
|
// public boolean select(Viewer viewer, Object parentElement, Object element) {
|
258 |
|
// if (element instanceof Text) return false;
|
259 |
|
// if (element instanceof SavedQuery) return false;
|
260 |
|
// return true;
|
261 |
|
// }
|
262 |
|
// });
|
|
209 |
|
263 |
210 |
treeViewer.setContentProvider(new CorpusViewContentProvider(this));
|
264 |
211 |
treeViewer.setLabelProvider(new DecoratingLabelProvider(new WorkbenchLabelProvider(), PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator()));
|
265 |
|
|
|
212 |
|
266 |
213 |
// for now the sorter is used to sort the Corpus, Subcorpus and partition objects
|
267 |
214 |
treeViewer.setSorter(new ViewerSorter() {
|
268 |
|
|
|
215 |
|
269 |
216 |
@Override
|
270 |
217 |
public int category(Object element) {
|
271 |
218 |
if (element instanceof Subcorpus) return 2; // must do it before the Corpus test
|
... | ... | |
273 |
220 |
else if (element instanceof Partition) return 1;
|
274 |
221 |
else return 3;
|
275 |
222 |
}
|
276 |
|
|
|
223 |
|
277 |
224 |
@Override
|
278 |
225 |
public int compare(Viewer viewer, Object e1, Object e2) {
|
279 |
|
|
|
226 |
|
280 |
227 |
int cat1 = category(e1);
|
281 |
228 |
int cat2 = category(e2);
|
282 |
|
|
|
229 |
|
283 |
230 |
if (cat1 != cat2) {
|
284 |
231 |
return cat1 - cat2;
|
285 |
232 |
}
|
286 |
|
|
|
233 |
|
287 |
234 |
if (e1 instanceof TXMResult && e2 instanceof TXMResult) {
|
288 |
235 |
return ((TXMResult) e1).compareTo((TXMResult) e2);
|
289 |
236 |
}
|
... | ... | |
292 |
239 |
}
|
293 |
240 |
}
|
294 |
241 |
});
|
295 |
|
|
296 |
|
if (Toolbox.isInitialized()) {
|
297 |
|
Workspace w = null;
|
298 |
|
while (w == null) {
|
299 |
|
try {
|
300 |
|
Thread.sleep(100);
|
301 |
|
}
|
302 |
|
catch (InterruptedException e1) {
|
303 |
|
// TODO Auto-generated catch block
|
304 |
|
org.txm.utils.logger.Log.printStackTrace(e1);
|
305 |
|
}
|
306 |
|
w = Toolbox.workspace;
|
307 |
|
if (w == null) continue;
|
308 |
|
else break;// return;
|
309 |
|
}
|
310 |
|
Project p = w.getProject("default"); //$NON-NLS-1$
|
311 |
|
if (p == null) return;
|
312 |
|
treeViewer.setInput(p);
|
313 |
|
}
|
|
242 |
|
|
243 |
treeViewer.setInput(Toolbox.workspace);
|
|
244 |
|
314 |
245 |
// FIXME: SJ: to remove?
|
315 |
246 |
// PlatformUI.getWorkbench().getHelpSystem().setHelp(treeViewer.getTree(), "org.txm.rcp.corporaView" //$NON-NLS-1$);
|
316 |
|
|
|
247 |
|
317 |
248 |
treeViewer.getTree().addSelectionListener(new SelectionListener() {
|
318 |
|
|
|
249 |
|
319 |
250 |
@Override
|
320 |
251 |
public void widgetSelected(SelectionEvent e) {
|
321 |
252 |
TreeItem[] sel = treeViewer.getTree().getSelection();
|
322 |
253 |
if (sel.length == 0)
|
323 |
254 |
return;
|
324 |
|
|
|
255 |
|
325 |
256 |
CorporaSourceProvider.updateSelection(treeViewer.getSelection());
|
326 |
|
|
|
257 |
|
327 |
258 |
CorporaView.this.setFocus(); // force focus on the corpora view -> ensure the active selection is the corpora view selection
|
328 |
|
|
|
259 |
|
329 |
260 |
ISelection tsel = treeViewer.getSelection();
|
330 |
261 |
if (!(tsel instanceof TreeSelection)) return;
|
331 |
|
|
|
262 |
|
332 |
263 |
TreeSelection selection = (TreeSelection) treeViewer.getSelection();
|
333 |
264 |
Object selectedItem = selection.getFirstElement();
|
334 |
|
|
335 |
|
// FIXME : MD tests
|
336 |
|
// if (selectedItem instanceof TXMResult) {
|
337 |
|
// TXMResult r = ((TXMResult)selectedItem);
|
338 |
|
// if (r.compute()) {
|
339 |
|
// String mess = r.getSimpleDetails();
|
340 |
|
// if (mess == null) mess = selectedItem.toString();
|
341 |
|
// StatusLine.setMessage(mess);
|
342 |
|
// }
|
343 |
|
// }
|
344 |
|
|
|
265 |
|
345 |
266 |
// FIXME: SJ tests, define here what to display
|
346 |
267 |
if (selectedItem instanceof TXMResult) {
|
347 |
268 |
TXMResult result = ((TXMResult) selectedItem);
|
... | ... | |
351 |
272 |
// }
|
352 |
273 |
// StatusLine.setMessage(mess);
|
353 |
274 |
// StatusLine.setMessage(((TXMResult)selectedItem).getComputingDoneMessage());
|
354 |
|
|
|
275 |
|
355 |
276 |
if (result instanceof MainCorpus) { // just for this result type, pre-compute to show the corpus size
|
356 |
277 |
try {
|
357 |
278 |
result.compute(false);
|
... | ... | |
361 |
282 |
e1.printStackTrace();
|
362 |
283 |
}
|
363 |
284 |
}
|
364 |
|
|
|
285 |
|
365 |
286 |
// Status bar
|
366 |
287 |
// if (!result.hasBeenComputedOnce() && !(result instanceof Partition)) { // FIXME: SJ: tmp fix for showing Partition parts
|
367 |
288 |
// StatusLine.setMessage("");
|
... | ... | |
370 |
291 |
// // TODO uncomment when status line will be restored
|
371 |
292 |
// // StatusLine.setMessage(((TXMResult) selectedItem).getDetails());
|
372 |
293 |
// }
|
373 |
|
|
|
294 |
|
374 |
295 |
// FIXME : MD re-enable status line on corpora view selection
|
375 |
296 |
if (selectedItem instanceof TXMResult) {
|
376 |
|
|
|
297 |
|
377 |
298 |
TXMResult r = ((TXMResult)selectedItem);
|
378 |
299 |
String mess = null;
|
379 |
300 |
try {mess = r.getSimpleDetails();}
|
... | ... | |
381 |
302 |
Log.warning(NLS.bind(TXMUIMessages.errorWhileGettingResultInformationsP0, e2));
|
382 |
303 |
Log.printStackTrace(e2);
|
383 |
304 |
}
|
384 |
|
|
|
305 |
|
385 |
306 |
if (mess == null) mess = r.getName();
|
386 |
307 |
StatusLine.setMessage(mess);
|
387 |
308 |
}
|
388 |
309 |
}
|
389 |
310 |
}
|
390 |
|
|
|
311 |
|
391 |
312 |
@Override
|
392 |
|
public void widgetDefaultSelected(SelectionEvent e) {
|
393 |
|
// TODO Auto-generated method stub
|
394 |
|
}
|
|
313 |
public void widgetDefaultSelected(SelectionEvent e) { }
|
395 |
314 |
});
|
396 |
|
|
397 |
|
|
|
315 |
|
|
316 |
|
398 |
317 |
// double click listener installation from commands
|
399 |
318 |
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
|
400 |
319 |
ICommandService cmdService = window.getService(ICommandService.class);
|
... | ... | |
411 |
330 |
e1.printStackTrace();
|
412 |
331 |
}
|
413 |
332 |
}
|
414 |
|
|
|
333 |
|
415 |
334 |
treeViewer.addDoubleClickListener(new IDoubleClickListener() {
|
416 |
|
|
|
335 |
|
417 |
336 |
@Override
|
418 |
337 |
public void doubleClick(DoubleClickEvent event) {
|
419 |
338 |
TreeSelection selection = (TreeSelection) treeViewer.getSelection();
|
420 |
339 |
Object selectedItem = selection.getFirstElement();
|
421 |
340 |
if (selectedItem != null) {
|
422 |
341 |
String commandId = doubleClickInstalledCommands.get(selectedItem.getClass().getName());
|
423 |
|
|
|
342 |
|
424 |
343 |
if (commandId == null) {
|
425 |
344 |
for (String clazz : doubleClickInstalledCommands.keySet()) {
|
426 |
345 |
if (selectedItem.getClass().getSuperclass().getName().equals(clazz)) {
|
... | ... | |
429 |
348 |
}
|
430 |
349 |
}
|
431 |
350 |
}
|
432 |
|
|
|
351 |
|
433 |
352 |
if (commandId != null) {
|
434 |
353 |
BaseAbstractHandler.executeCommand(commandId);
|
435 |
354 |
}
|
... | ... | |
447 |
366 |
}
|
448 |
367 |
}
|
449 |
368 |
});
|
450 |
|
|
|
369 |
|
451 |
370 |
treeViewer.getTree().addKeyListener(new KeyAdapter() {
|
452 |
|
|
|
371 |
|
453 |
372 |
@Override
|
454 |
373 |
public void keyPressed(KeyEvent e) {
|
455 |
|
|
|
374 |
|
456 |
375 |
boolean expert = TBXPreferences.getInstance().getBoolean(TBXPreferences.EXPERT_USER);
|
457 |
|
|
|
376 |
|
458 |
377 |
if (expert && (char) e.keyCode == 'c' & ((e.stateMask & SWT.CTRL) != 0)) {
|
459 |
378 |
Object o = treeViewer.getStructuredSelection().getFirstElement();
|
460 |
379 |
if (o != null && o instanceof TXMResult) {
|
461 |
380 |
CopyTXMResultTree.copy((IStructuredSelection) treeViewer.getSelection());
|
462 |
381 |
}
|
463 |
|
|
464 |
382 |
}
|
465 |
383 |
else if (expert && (char) e.keyCode == 'x' & ((e.stateMask & SWT.CTRL) != 0)) {
|
466 |
384 |
Object o = treeViewer.getStructuredSelection().getFirstElement();
|
467 |
385 |
if (o != null && o instanceof TXMResult) {
|
468 |
386 |
CutTXMResultTree.cut((IStructuredSelection) treeViewer.getSelection());
|
469 |
387 |
}
|
470 |
|
|
471 |
388 |
}
|
472 |
389 |
else if (expert && (char) e.keyCode == 'v' & ((e.stateMask & SWT.CTRL) != 0)) {
|
473 |
390 |
Object o = treeViewer.getStructuredSelection().getFirstElement();
|
474 |
391 |
if (o != null && o instanceof TXMResult) {
|
475 |
392 |
PasteTXMResultTree.paste((TXMResult) o);
|
476 |
393 |
}
|
477 |
|
|
478 |
394 |
} else if (e.keyCode == SWT.DEL) {
|
479 |
395 |
final ISelection sel = treeViewer.getSelection();
|
480 |
396 |
if (sel instanceof IStructuredSelection) {
|
481 |
|
|
|
397 |
|
482 |
398 |
if (!DeleteObject.askContinueToDelete((IStructuredSelection) sel)) return;
|
483 |
|
|
|
399 |
|
484 |
400 |
JobHandler job = new JobHandler(TXMUIMessages.deleting, true) {
|
485 |
|
|
|
401 |
|
486 |
402 |
@Override
|
487 |
403 |
protected IStatus run(IProgressMonitor monitor) {
|
488 |
404 |
DeleteObject.delete(sel);
|
489 |
405 |
this.syncExec(new Runnable() {
|
490 |
|
|
|
406 |
|
491 |
407 |
@Override
|
492 |
408 |
public void run() {
|
493 |
409 |
refresh();
|
... | ... | |
516 |
432 |
// }
|
517 |
433 |
}
|
518 |
434 |
});
|
519 |
|
|
|
435 |
|
520 |
436 |
final int IMAGE_MARGIN = 2;
|
521 |
437 |
final Image icon = IImageKeys.getImage("icons/decorators/bullet_green.png"); //$NON-NLS-1$
|
522 |
438 |
final Image icon_lock = IImageKeys.getImage("icons/decorators/lock.png"); //$NON-NLS-1$
|
523 |
|
|
|
439 |
|
524 |
440 |
// FIXME: test to show icon for results that are user persistable
|
525 |
441 |
// final Image icon = AbstractUIPlugin.imageDescriptorFromPlugin("org.eclipse.gef","platform:/plugin/org.eclipse.gef/org/eclipse/gef/internal/icons/pinned.gif").createImage();
|
526 |
442 |
// final Image icon = AbstractUIPlugin.imageDescriptorFromPlugin("org.eclipse.team.svn.help","platform:/plugin/org.eclipse.team.svn.help/images/lock.gif").createImage();
|
527 |
|
|
528 |
|
|
529 |
|
|
|
443 |
|
|
444 |
|
|
445 |
|
530 |
446 |
// treeViewer.getTree().addListener(SWT.MeasureItem, new Listener() {
|
531 |
447 |
// public void handleEvent(Event event) {
|
532 |
448 |
// TreeItem item = (TreeItem)event.item;
|
... | ... | |
537 |
453 |
// }
|
538 |
454 |
// });
|
539 |
455 |
treeViewer.getTree().addListener(SWT.PaintItem, new Listener() {
|
540 |
|
|
|
456 |
|
541 |
457 |
@Override
|
542 |
458 |
public void handleEvent(Event event) {
|
543 |
459 |
if (event.item.getData() instanceof TXMResult && ((TXMResult) event.item.getData()).isLocked()) {
|
... | ... | |
548 |
464 |
int itemHeight = treeViewer.getTree().getItemHeight();
|
549 |
465 |
int imageHeight = trailingImage.getBounds().height;
|
550 |
466 |
int y = 2 + event.y + (itemHeight - imageHeight) / 2;
|
551 |
|
|
|
467 |
|
552 |
468 |
event.gc.drawImage(icon_lock, x, y);
|
553 |
469 |
}
|
554 |
470 |
}
|
555 |
471 |
}
|
556 |
472 |
});
|
557 |
|
|
|
473 |
|
558 |
474 |
MenuManager menuManager = new MenuManager();
|
559 |
475 |
Menu menu = menuManager.createContextMenu(treeViewer.getTree());
|
560 |
|
|
|
476 |
|
561 |
477 |
// Set the MenuManager
|
562 |
478 |
treeViewer.getTree().setMenu(menu);
|
563 |
479 |
getSite().registerContextMenu(menuManager, treeViewer);
|
564 |
480 |
// Make the selection available
|
565 |
481 |
getSite().setSelectionProvider(treeViewer);
|
566 |
|
|
|
482 |
|
567 |
483 |
IContextService contextService = getSite().getService(IContextService.class);
|
568 |
484 |
contextService.activateContext(ID);
|
|
485 |
|
|
486 |
treeViewer.refresh();
|
569 |
487 |
}
|
570 |
|
|
571 |
|
|
|
488 |
|
|
489 |
|
572 |
490 |
/**
|
573 |
491 |
* Passing the focus request to the viewer's control.
|
574 |
492 |
*/
|
... | ... | |
576 |
494 |
public void setFocus() {
|
577 |
495 |
treeViewer.getControl().setFocus();
|
578 |
496 |
}
|
579 |
|
|
|
497 |
|
580 |
498 |
/**
|
581 |
499 |
* Gets the first selected object in the tree.
|
582 |
500 |
*
|
... | ... | |
596 |
514 |
}
|
597 |
515 |
return null;
|
598 |
516 |
}
|
599 |
|
|
|
517 |
|
600 |
518 |
/**
|
601 |
519 |
* Gets the selected objects in the tree.
|
602 |
520 |
*
|
... | ... | |
616 |
534 |
}
|
617 |
535 |
return null;
|
618 |
536 |
}
|
619 |
|
|
|
537 |
|
620 |
538 |
/**
|
621 |
539 |
* Selects some items.
|
622 |
540 |
*
|
623 |
541 |
* @param arrayList
|
624 |
542 |
*/
|
625 |
543 |
public static void select(List<?> arrayList) {
|
626 |
|
|
|
544 |
|
627 |
545 |
if (!PlatformUI.isWorkbenchRunning()) return;
|
628 |
|
|
|
546 |
|
629 |
547 |
CorporaView corporaView = openView();
|
630 |
548 |
if (corporaView != null) {
|
631 |
549 |
StructuredSelection selection = new StructuredSelection(arrayList);
|
... | ... | |
633 |
551 |
corporaView.getTreeViewer().reveal(arrayList); // to be sure
|
634 |
552 |
}
|
635 |
553 |
}
|
636 |
|
|
|
554 |
|
637 |
555 |
/**
|
638 |
556 |
* Opens the Corpora view if not already opened.
|
639 |
557 |
*
|
... | ... | |
643 |
561 |
// open Unit View if not opened
|
644 |
562 |
try {
|
645 |
563 |
if (!PlatformUI.isWorkbenchRunning()) return null;
|
646 |
|
|
|
564 |
|
647 |
565 |
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
648 |
566 |
CorporaView view = (CorporaView) page.findView(CorporaView.ID);
|
649 |
567 |
if (view == null) {
|
... | ... | |
661 |
579 |
}
|
662 |
580 |
return null;
|
663 |
581 |
}
|
664 |
|
|
665 |
|
|
|
582 |
|
|
583 |
|
666 |
584 |
/**
|
667 |
585 |
* Refresh the tree view.
|
668 |
586 |
*/
|
... | ... | |
674 |
592 |
// corporaView.treeViewer.expandAll(); // FIXME
|
675 |
593 |
}
|
676 |
594 |
}
|
677 |
|
|
|
595 |
|
678 |
596 |
/**
|
679 |
597 |
* Refreshes the view and the tree.
|
680 |
598 |
*
|
... | ... | |
683 |
601 |
public static void refresh(CorporaView corporaView) {
|
684 |
602 |
corporaView.treeViewer.refresh();
|
685 |
603 |
}
|
686 |
|
|
687 |
|
|
688 |
|
|
|
604 |
|
|
605 |
|
|
606 |
|
689 |
607 |
/**
|
690 |
608 |
* Refreshes the specified result node in the tree view.
|
691 |
609 |
*
|
... | ... | |
693 |
611 |
*/
|
694 |
612 |
public static void refreshObject(final TXMResult result) {
|
695 |
613 |
Display.getDefault().syncExec(new Runnable() {
|
696 |
|
|
|
614 |
|
697 |
615 |
@Override
|
698 |
616 |
public void run() {
|
699 |
|
|
|
617 |
|
700 |
618 |
CorporaView corporaView = getInstance();
|
701 |
|
|
|
619 |
|
702 |
620 |
corporaView.treeViewer.refresh();
|
703 |
|
|
|
621 |
|
704 |
622 |
try {
|
705 |
623 |
CorporaView.expand(result.getParent());
|
706 |
624 |
}
|
... | ... | |
709 |
627 |
}
|
710 |
628 |
});
|
711 |
629 |
}
|
712 |
|
|
|
630 |
|
713 |
631 |
/**
|
714 |
632 |
* Refreshes the specified result node in the tree view, also synchronizes the TXMResult and the TXMEditor (as the editor part name from the result name, for example).
|
715 |
633 |
*
|
... | ... | |
718 |
636 |
public static void refreshObject(TXMEditor editor) {
|
719 |
637 |
refreshObject(editor.getResult());
|
720 |
638 |
}
|
721 |
|
|
|
639 |
|
722 |
640 |
/**
|
723 |
641 |
* Expands the specified tree node.
|
724 |
642 |
*
|
... | ... | |
730 |
648 |
corporaView.treeViewer.expandToLevel(obj, 1);
|
731 |
649 |
}
|
732 |
650 |
}
|
733 |
|
|
|
651 |
|
734 |
652 |
/**
|
735 |
653 |
*
|
736 |
654 |
* @param obj
|
... | ... | |
741 |
659 |
corporaView.treeViewer.reveal(obj);
|
742 |
660 |
}
|
743 |
661 |
}
|
744 |
|
|
|
662 |
|
745 |
663 |
/**
|
746 |
664 |
* Checks if the Corpora view is active.
|
747 |
665 |
*
|