Revision 1b9e4990
Added by Patrick Plitzner over 8 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/DerivateView.java | ||
---|---|---|
31 | 31 |
import org.eclipse.swt.widgets.Menu; |
32 | 32 |
import org.eclipse.swt.widgets.Tree; |
33 | 33 |
import org.eclipse.ui.IEditorPart; |
34 |
import org.eclipse.ui.IMemento; |
|
34 | 35 |
import org.eclipse.ui.ISaveablePart2; |
35 | 36 |
import org.eclipse.ui.IWorkbenchPart; |
36 | 37 |
|
... | ... | |
47 | 48 |
import eu.etaxonomy.taxeditor.editor.EditorUtil; |
48 | 49 |
import eu.etaxonomy.taxeditor.editor.Messages; |
49 | 50 |
import eu.etaxonomy.taxeditor.editor.view.derivate.searchFilter.DerivateSearchCompositeController; |
51 |
import eu.etaxonomy.taxeditor.model.IContextListener; |
|
50 | 52 |
import eu.etaxonomy.taxeditor.model.IPartContentHasDetails; |
51 | 53 |
import eu.etaxonomy.taxeditor.model.IPartContentHasFactualData; |
52 | 54 |
import eu.etaxonomy.taxeditor.model.IPartContentHasMedia; |
... | ... | |
62 | 64 |
* |
63 | 65 |
*/ |
64 | 66 |
public class DerivateView extends AbstractCdmViewPart implements IPartContentHasFactualData, ISaveablePart2, |
65 |
IPartContentHasDetails, IPartContentHasSupplementalData, IPartContentHasMedia { |
|
67 |
IPartContentHasDetails, IPartContentHasSupplementalData, IPartContentHasMedia, IContextListener {
|
|
66 | 68 |
public static final String ID = "eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView"; //$NON-NLS-1$ |
67 | 69 |
|
68 | 70 |
public static final String YOU_NEED_TO_SAVE_BEFORE_PERFORMING_THIS_ACTION = Messages.DerivateView_YOU_NEED_TO_SAVE; |
... | ... | |
125 | 127 |
* Default constructor |
126 | 128 |
*/ |
127 | 129 |
public DerivateView() { |
130 |
init(); |
|
131 |
} |
|
132 |
|
|
133 |
/** |
|
134 |
* |
|
135 |
*/ |
|
136 |
private void init() { |
|
128 | 137 |
this.derivateToRootEntityMap = new HashMap<SpecimenOrObservationBase<?>, SpecimenOrObservationBase<?>>(); |
129 | 138 |
this.rootElements = new HashSet<SpecimenOrObservationBase<?>>(); |
130 | 139 |
|
... | ... | |
134 | 143 |
if (CdmStore.isActive()) { |
135 | 144 |
cdmEntitySession = CdmStore.getCurrentSessionManager().newSession(this, true); |
136 | 145 |
} |
146 |
//listen to context changes |
|
147 |
CdmStore.getContextManager().addContextListener(this); |
|
137 | 148 |
} |
138 | 149 |
|
139 | 150 |
@Override |
... | ... | |
195 | 206 |
if (!conversation.isBound()) { |
196 | 207 |
conversation.bind(); |
197 | 208 |
} |
209 |
/* |
|
210 |
* If the active session is not the session of the Derivate Editor then we will |
|
211 |
* save it, bind temporarily to our session and rebind to the original session. |
|
212 |
* This happens e.g. if a selection change happens in the taxon editor and |
|
213 |
* "Link with editor" is enabled. The selection change event and thus the |
|
214 |
* loading in updateRootEntities() happens in the session of the taxon |
|
215 |
* editor. |
|
216 |
*/ |
|
217 |
ICdmEntitySession previousCdmEntitySession = CdmStore.getCurrentSessionManager().getActiveSession(); |
|
218 |
if(cdmEntitySession != null) { |
|
219 |
cdmEntitySession.bind(); |
|
220 |
} |
|
221 |
|
|
198 | 222 |
if(derivativeUuids!=null){ |
199 | 223 |
this.derivateToRootEntityMap = new HashMap<SpecimenOrObservationBase<?>, SpecimenOrObservationBase<?>>(); |
200 | 224 |
this.rootElements = new HashSet<SpecimenOrObservationBase<?>>(); |
... | ... | |
219 | 243 |
} |
220 | 244 |
viewer.setInput(rootElements); |
221 | 245 |
refreshTree(); |
246 |
previousCdmEntitySession.bind(); |
|
222 | 247 |
} |
223 | 248 |
} |
224 | 249 |
|
... | ... | |
250 | 275 |
public void doSaveAs() { |
251 | 276 |
} |
252 | 277 |
|
253 |
public Set<SpecimenOrObservationBase<?>> getRootElements() { |
|
254 |
return rootElements; |
|
255 |
} |
|
256 |
|
|
257 | 278 |
@Override |
258 | 279 |
public String getTitleToolTip() { |
259 | 280 |
return Messages.DerivateView_DERIVATIVE_EDITOR; |
... | ... | |
280 | 301 |
public void setFocus() { |
281 | 302 |
viewer.getControl().setFocus(); |
282 | 303 |
//make sure to bind again if maybe in another view the conversation was unbound |
283 |
if(!conversation.isBound()){ |
|
304 |
if(conversation!=null && !conversation.isBound()){
|
|
284 | 305 |
conversation.bind(); |
285 | 306 |
} |
286 | 307 |
if(cdmEntitySession != null) { |
... | ... | |
450 | 471 |
} |
451 | 472 |
} |
452 | 473 |
|
474 |
/** |
|
475 |
* {@inheritDoc} |
|
476 |
*/ |
|
477 |
@Override |
|
478 |
public List<SpecimenOrObservationBase<?>> getRootEntities() { |
|
479 |
return new ArrayList<SpecimenOrObservationBase<?>>(rootElements); |
|
480 |
} |
|
481 |
|
|
453 | 482 |
@Override |
454 | 483 |
public void createViewer(Composite parent) { |
455 | 484 |
// TODO Auto-generated method stub |
... | ... | |
468 | 497 |
|
469 | 498 |
public void toggleListenToSelectionChange() { |
470 | 499 |
listenToSelectionChange = !listenToSelectionChange; |
471 |
derivateSearchCompositeController.setEnabled(listenToSelectionChange); |
|
500 |
derivateSearchCompositeController.setEnabled(!listenToSelectionChange); |
|
501 |
} |
|
502 |
|
|
503 |
/** |
|
504 |
* {@inheritDoc} |
|
505 |
*/ |
|
506 |
@Override |
|
507 |
public void contextAboutToStop(IMemento memento, IProgressMonitor monitor) { |
|
508 |
} |
|
509 |
|
|
510 |
/** |
|
511 |
* {@inheritDoc} |
|
512 |
*/ |
|
513 |
@Override |
|
514 |
public void contextStop(IMemento memento, IProgressMonitor monitor) { |
|
515 |
derivateSearchCompositeController.setEnabled(false); |
|
516 |
viewer.setInput(null); |
|
517 |
} |
|
518 |
|
|
519 |
/** |
|
520 |
* {@inheritDoc} |
|
521 |
*/ |
|
522 |
@Override |
|
523 |
public void contextStart(IMemento memento, IProgressMonitor monitor) { |
|
524 |
init(); |
|
525 |
derivateSearchCompositeController.setEnabled(!listenToSelectionChange); |
|
526 |
refreshTree(); |
|
527 |
} |
|
528 |
|
|
529 |
/** |
|
530 |
* {@inheritDoc} |
|
531 |
*/ |
|
532 |
@Override |
|
533 |
public void contextRefresh(IProgressMonitor monitor) { |
|
534 |
} |
|
535 |
|
|
536 |
/** |
|
537 |
* {@inheritDoc} |
|
538 |
*/ |
|
539 |
@Override |
|
540 |
public void workbenchShutdown(IMemento memento, IProgressMonitor monitor) { |
|
472 | 541 |
} |
473 | 542 |
|
474 | 543 |
} |
Also available in: Unified diff
Fix session problems with remoting