Revision 7e55a0c5
Added by Patrick Plitzner almost 8 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/DerivateView.java | ||
---|---|---|
27 | 27 |
import org.eclipse.swt.layout.GridLayout; |
28 | 28 |
import org.eclipse.swt.widgets.Composite; |
29 | 29 |
import org.eclipse.swt.widgets.Control; |
30 |
import org.eclipse.swt.widgets.Display; |
|
30 | 31 |
import org.eclipse.swt.widgets.Menu; |
31 | 32 |
import org.eclipse.swt.widgets.Tree; |
32 | 33 |
import org.eclipse.ui.IEditorInput; |
... | ... | |
60 | 61 |
import eu.etaxonomy.taxeditor.model.IPartContentHasFactualData; |
61 | 62 |
import eu.etaxonomy.taxeditor.model.IPartContentHasMedia; |
62 | 63 |
import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData; |
64 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
|
63 | 65 |
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled; |
64 | 66 |
import eu.etaxonomy.taxeditor.session.ICdmEntitySession; |
65 | 67 |
import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled; |
... | ... | |
95 | 97 |
"derivationEvents.derivatives.sources" |
96 | 98 |
}); |
97 | 99 |
|
100 |
private static final int WARN_THRESHOLD = 200; |
|
101 |
|
|
102 |
private DelaySelection delaySelection = null; |
|
103 |
/** |
|
104 |
* This is the monitor for the DelaySelection runnable. |
|
105 |
* If it is <code>true</code> then it is currently delaying a selection. |
|
106 |
*/ |
|
107 |
private boolean isInDelay; |
|
108 |
|
|
109 |
|
|
110 |
/** |
|
111 |
* This class invokes internal_selectionChanged() in a separate thread. |
|
112 |
* This allows an asynchronous and/or delayed handling of selection changes |
|
113 |
*/ |
|
114 |
private class DelaySelection implements Runnable{ |
|
115 |
private IWorkbenchPart part; |
|
116 |
private ISelection selection; |
|
117 |
|
|
118 |
public DelaySelection(IWorkbenchPart part, ISelection selection) { |
|
119 |
super(); |
|
120 |
this.part = part; |
|
121 |
this.selection = selection; |
|
122 |
} |
|
123 |
|
|
124 |
@Override |
|
125 |
public void run() { |
|
126 |
try{ |
|
127 |
selectionChanged_internal(part, selection); |
|
128 |
} |
|
129 |
finally{ |
|
130 |
isInDelay = false; |
|
131 |
} |
|
132 |
} |
|
133 |
|
|
134 |
public synchronized void setSelection(ISelection selection) { |
|
135 |
this.selection = selection; |
|
136 |
} |
|
137 |
|
|
138 |
public synchronized void setPart(IWorkbenchPart part) { |
|
139 |
this.part = part; |
|
140 |
} |
|
141 |
|
|
142 |
} |
|
143 |
|
|
98 | 144 |
private ConversationHolder conversation; |
99 | 145 |
|
100 | 146 |
private TreeViewer viewer; |
... | ... | |
202 | 248 |
control.setMenu(menu); |
203 | 249 |
|
204 | 250 |
//init tree |
205 |
updateRootEntities(((DerivateViewEditorInput)getEditorInput()).getDerivativeUuids()); |
|
251 |
Collection<UUID> derivativeUuids = ((DerivateViewEditorInput)getEditorInput()).getDerivativeUuids(); |
|
252 |
checkWarnThreshold(derivativeUuids); |
|
253 |
updateRootEntities(derivativeUuids); |
|
206 | 254 |
//set taxon filter |
207 | 255 |
derivateSearchCompositeController.setTaxonFilter(((DerivateViewEditorInput) getEditorInput()).getTaxonUuid()); |
208 | 256 |
//reset status bar |
... | ... | |
479 | 527 |
cdmEntitySession.dispose(); |
480 | 528 |
} |
481 | 529 |
} |
482 |
|
|
483 |
@Override |
|
484 |
public void selectionChanged(IWorkbenchPart part, ISelection selection) { |
|
485 |
if(part == this){ |
|
530 |
public void selectionChanged_internal(IWorkbenchPart part, ISelection selection) { |
|
531 |
if(part == this){ |
|
486 | 532 |
return; |
487 | 533 |
} |
488 | 534 |
if(viewer.getTree().isDisposed()){ |
... | ... | |
509 | 555 |
for (SpecimenOrObservationBase specimenOrObservationBase : fieldUnits) { |
510 | 556 |
uuids.add(specimenOrObservationBase.getUuid()); |
511 | 557 |
} |
558 |
checkWarnThreshold(uuids); |
|
512 | 559 |
updateRootEntities(uuids); |
513 | 560 |
setPartName("Derivative Editor: " + selectedTaxon.getName()); |
514 | 561 |
} |
515 | 562 |
} |
516 | 563 |
} |
517 | 564 |
|
565 |
@Override |
|
566 |
public void selectionChanged(IWorkbenchPart part, ISelection selection) { |
|
567 |
if(delaySelection==null){ |
|
568 |
delaySelection = new DelaySelection(part, selection); |
|
569 |
} |
|
570 |
delaySelection.setPart(part); |
|
571 |
delaySelection.setSelection(selection); |
|
572 |
if(!isInDelay){ |
|
573 |
isInDelay = true; |
|
574 |
Display.getCurrent().asyncExec(delaySelection); |
|
575 |
} |
|
576 |
} |
|
577 |
|
|
578 |
|
|
579 |
private void checkWarnThreshold(Collection<UUID> uuids) { |
|
580 |
if(uuids!=null && uuids.size()>WARN_THRESHOLD){ |
|
581 |
MessagingUtils.warningDialog("Performance warning", this.getClass(), String.format("Specimens will not be loaded!\n" |
|
582 |
+ "There are %d specimens associated with the current " |
|
583 |
+ "selection. If you really want to show all of them in the specimen editor please " |
|
584 |
+ "use the taxon filter in the search bar.", uuids.size())); |
|
585 |
uuids.clear(); |
|
586 |
} |
|
587 |
} |
|
588 |
|
|
518 | 589 |
public TreeViewer getViewer() { |
519 | 590 |
return viewer; |
520 | 591 |
} |
Also available in: Unified diff
Performance tweak for specimen editor