From 82ef24f36a4fd423b432e819ecd384833b722aa0 Mon Sep 17 00:00:00 2001
From: Patrick Plitzner
Date: Mon, 26 Oct 2015 10:23:43 +0100
Subject: [PATCH] Listen to selection changes in DerivativeEditor - Convert to
ViewPart - Add toolbar button to toggle listening to selection changes
---
eu.etaxonomy.taxeditor.editor/plugin.xml | 38 +++-----
.../editor/view/derivate/DerivateView.java | 97 +++++++++++--------
.../ListenToSelectionChangeHandler.java | 23 +++++
.../operation/DeleteDerivateOperation.java | 5 -
.../DerivateSearchCompositeController.java | 2 -
5 files changed, 91 insertions(+), 74 deletions(-)
create mode 100644 eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/handler/ListenToSelectionChangeHandler.java
diff --git a/eu.etaxonomy.taxeditor.editor/plugin.xml b/eu.etaxonomy.taxeditor.editor/plugin.xml
index baa84a8dd..d1d818b56 100644
--- a/eu.etaxonomy.taxeditor.editor/plugin.xml
+++ b/eu.etaxonomy.taxeditor.editor/plugin.xml
@@ -1038,30 +1038,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -1072,6 +1048,15 @@
tooltip="%command.tooltip">
+
+
+
+
@@ -1556,6 +1541,11 @@
typeId="eu.etaxonomy.taxeditor.specimenUuidParameterType">
+
+
true if this view is listening to selection changes
+ */
+ private boolean listenToSelectionChange;
+
/**
* Default constructor
*/
public DerivateView() {
+ this.derivateToRootEntityMap = new HashMap, SpecimenOrObservationBase>>();
+ this.rootElements = new HashSet>();
+
+ if (CdmStore.isActive() && conversation == null) {
+ conversation = CdmStore.createConversation();
+ }
+ if (CdmStore.isActive()) {
+ cdmEntitySession = CdmStore.getCurrentSessionManager().newSession(this, true);
+ }
}
@Override
@@ -173,13 +186,7 @@ public class DerivateView extends EditorPart implements IPartContentHasFactualDa
labelProvider.setMultiLinkSingleReads(multiLinkSingleReads);
//init tree
- DerivateViewEditorInput editorInput = (DerivateViewEditorInput) getEditorInput();
- if(editorInput.getDerivativeUUIDs()!=null){
- updateRootEntities(editorInput.getDerivativeUUIDs());
- }
- else{
- updateRootEntities();
- }
+ updateRootEntities();
//add drag'n'drop support
Transfer[] transfers = new Transfer[] {LocalSelectionTransfer.getTransfer(),};
@@ -221,10 +228,6 @@ public class DerivateView extends EditorPart implements IPartContentHasFactualDa
@Override
public void doSave(IProgressMonitor monitor) {
String taskName = Messages.DerivateView_SAVING_HIERARCHY;
- if(getEditorInput() instanceof DerivateViewEditorInput){
- DerivateViewEditorInput derivateViewEditorInput = (DerivateViewEditorInput) getEditorInput();
- taskName += " "+derivateViewEditorInput.getName(); //$NON-NLS-1$
- }
monitor.beginTask(taskName, 3);
if (!conversation.isBound()) {
conversation.bind();
@@ -256,28 +259,9 @@ public class DerivateView extends EditorPart implements IPartContentHasFactualDa
@Override
public String getTitleToolTip() {
- if(getEditorInput() instanceof DerivateViewEditorInput){
- DerivateViewEditorInput derivateViewEditorInput = (DerivateViewEditorInput) getEditorInput();
- return derivateViewEditorInput.getName();
- }
return Messages.DerivateView_DERIVATIVE_EDITOR;
}
- @Override
- public void init(IEditorSite site, IEditorInput input) throws PartInitException {
- setSite(site);
- setInput(input);
- this.derivateToRootEntityMap = new HashMap, SpecimenOrObservationBase>>();
- this.rootElements = new HashSet>();
-
- if (CdmStore.isActive() && conversation == null) {
- conversation = CdmStore.createConversation();
- }
- if (CdmStore.isActive()) {
- cdmEntitySession = CdmStore.getCurrentSessionManager().newSession(this, true);
- }
- }
-
@Override
public boolean isDirty() {
return isDirty;
@@ -319,6 +303,7 @@ public class DerivateView extends EditorPart implements IPartContentHasFactualDa
/**
* @return the viewer
*/
+ @Override
public TreeViewer getViewer() {
return viewer;
}
@@ -335,11 +320,6 @@ public class DerivateView extends EditorPart implements IPartContentHasFactualDa
changed(null);
}
- @Override
- public Set> getRootEntities() {
- return rootElements;
- }
-
@Override
public Map