public abstract class AbstractCdmEditorPartE4
implements IConversationEnabled, IDirtyMarkable, ISelectionElementEditingPart, IPostOperationEnabled{
+ private DelaySelection delaySelection = null;
+ /**
+ * This is the monitor for the DelaySelection runnable.
+ * If it is <code>true</code> then it is currently delaying a selection.
+ */
+ private boolean isInDelay;
+
+
+ /**
+ * This class invokes internal_selectionChanged() in a separate thread.
+ * This allows an asynchronous and/or delayed handling of selection changes
+ */
+ private class DelaySelection implements Runnable{
+ private Object selection;
+ private MPart activePart;
+ private MPart thisPart;
+
+ public DelaySelection(Object selection, MPart activePart, MPart thisPart) {
+ super();
+ this.selection = selection;
+ this.activePart= activePart;
+ this.thisPart = thisPart;
+ }
+
+ @Override
+ public void run() {
+ try{
+ selectionChanged_internal(selection, activePart, thisPart);
+ }
+ finally{
+ isInDelay = false;
+ }
+ }
+
+ public synchronized void setSelection(Object selection) {
+ this.selection = selection;
+ }
+
+ public synchronized void setActivePart(MPart activePart) {
+ this.activePart = activePart;
+ }
+
+ public synchronized void setThisPart(MPart thisPart) {
+ this.thisPart = thisPart;
+ }
+
+ }
+
+ protected abstract void selectionChanged_internal(Object selection, MPart activePart, MPart thisPart);
+
+ @Inject
+ @Optional
+ public void selectionChanged(
+ @Named(IServiceConstants.ACTIVE_SELECTION)Object selection,
+ @Named(IServiceConstants.ACTIVE_PART)MPart activePart,
+ MPart thisPart){
+ if(delaySelection==null){
+ delaySelection = new DelaySelection(selection, activePart, thisPart);
+ }
+ delaySelection.setSelection(selection);
+ delaySelection.setActivePart(activePart);
+ delaySelection.setThisPart(thisPart);
+ if(!isInDelay){
+ isInDelay = true;
+ Display.getCurrent().asyncExec(delaySelection);
+ }
+ }
+
protected Viewer viewer;
+ protected MPart thisPart;
+
protected MPart selectionProvidingPart;
/** {@inheritDoc} */
}
@PostConstruct
- public void create(Composite parent) {
- viewer = new SupplementalDataViewerE4(parent, this);
+ public void create(Composite parent, MPart thisPart) {
+
+ this.thisPart = thisPart;
+
+ viewer = new SupplementalDataViewerE4(parent, this);
}
- @Inject
- @Optional
- protected void selectionChanged_internal(
- @Named(IServiceConstants.ACTIVE_SELECTION)Object selection,
- @Named(IServiceConstants.ACTIVE_PART)MPart activePart,
- MPart thisPart) {
+ @Override
+ public void selectionChanged_internal(Object selection, MPart activePart, MPart thisPart) {
if(activePart==thisPart){
return;
}