Revision 751c610c
Added by Katja Luther almost 8 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/checklist/ChecklistEditor.java | ||
---|---|---|
12 | 12 |
|
13 | 13 |
import java.util.ArrayList; |
14 | 14 |
import java.util.Arrays; |
15 |
import java.util.Collection; |
|
16 | 15 |
import java.util.Collections; |
17 | 16 |
import java.util.HashMap; |
18 | 17 |
import java.util.List; |
... | ... | |
58 | 57 |
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled; |
59 | 58 |
import eu.etaxonomy.cdm.api.service.ITaxonNodeService; |
60 | 59 |
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper; |
61 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
|
62 | 60 |
import eu.etaxonomy.cdm.model.common.DefinedTermBase; |
63 | 61 |
import eu.etaxonomy.cdm.model.taxon.Classification; |
64 | 62 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
... | ... | |
77 | 75 |
import eu.etaxonomy.taxeditor.model.IPartContentHasFactualData; |
78 | 76 |
import eu.etaxonomy.taxeditor.preference.PreferencesUtil; |
79 | 77 |
import eu.etaxonomy.taxeditor.preference.Resources; |
80 |
import eu.etaxonomy.taxeditor.session.ICdmEntitySession; |
|
81 |
import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled; |
|
82 | 78 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
83 | 79 |
|
84 | 80 |
/** |
... | ... | |
90 | 86 |
* @created 30.04.2014 |
91 | 87 |
* @version 1.0 |
92 | 88 |
*/ |
93 |
public class ChecklistEditor extends EditorPart implements ISelectionListener, IPartContentHasFactualData, |
|
94 |
IConversationEnabled, IContextListener, IPartContentHasDetails, IDirtyMarkable, ICdmEntitySessionEnabled {
|
|
89 |
public class ChecklistEditor extends EditorPart implements ISelectionListener, IPartContentHasFactualData, IConversationEnabled,
|
|
90 |
IContextListener, IPartContentHasDetails, IDirtyMarkable{//, ICdmEntitySessionEnabled {
|
|
95 | 91 |
|
96 | 92 |
private static final Logger logger = Logger.getLogger(ChecklistEditor.class); |
97 | 93 |
/** |
... | ... | |
189 | 185 |
|
190 | 186 |
private Label statusLabel; |
191 | 187 |
|
192 |
private final ICdmEntitySession cdmEntitySession; |
|
188 |
// private final ICdmEntitySession cdmEntitySession;
|
|
193 | 189 |
|
194 | 190 |
private ChecklistLabelProvider labelProvider; |
195 | 191 |
|
... | ... | |
218 | 214 |
* </p> |
219 | 215 |
*/ |
220 | 216 |
public ChecklistEditor() { |
221 |
cdmEntitySession = CdmStore.getCurrentSessionManager().newSession(this, true); |
|
217 |
//cdmEntitySession = CdmStore.getCurrentSessionManager().newSession(this, true);
|
|
222 | 218 |
|
223 | 219 |
} |
224 | 220 |
|
... | ... | |
472 | 468 |
/** {@inheritDoc} */ |
473 | 469 |
@Override |
474 | 470 |
public void dispose() { |
475 |
cdmEntitySession.dispose(); |
|
471 |
this.checklistEditorInput.dispose(); |
|
472 |
|
|
473 |
conversation.unregisterForDataStoreChanges(this); |
|
474 |
conversation.close(); |
|
476 | 475 |
super.dispose(); |
477 | 476 |
} |
478 | 477 |
|
479 | 478 |
/** {@inheritDoc} */ |
480 | 479 |
@Override |
481 | 480 |
public void setFocus() { |
482 |
cdmEntitySession.bind(); |
|
481 |
|
|
483 | 482 |
viewer.getControl().setFocus(); |
484 | 483 |
} |
485 | 484 |
|
... | ... | |
615 | 614 |
public void doSave(IProgressMonitor monitor) { |
616 | 615 |
try { |
617 | 616 |
monitor.beginTask("Saving Editor", 1); |
618 |
getConversationHolder().bind(); |
|
619 |
getConversationHolder().commit(true); |
|
617 |
if (!conversation.isBound()) { |
|
618 |
conversation.bind(); |
|
619 |
} |
|
620 |
CdmStore.getService(ITaxonNodeService.class).merge(selectedTaxonNodes, true); |
|
621 |
//this.checklistEditorInput.merge(); |
|
622 |
conversation.commit(true); |
|
620 | 623 |
setDirty(false); |
621 | 624 |
monitor.worked(1); |
622 | 625 |
} finally { |
... | ... | |
636 | 639 |
if (input instanceof ChecklistEditorInput) { |
637 | 640 |
checklistEditorInput = (ChecklistEditorInput) input; |
638 | 641 |
setPartName(getPartName() + ": " + checklistEditorInput.getName()); |
639 |
conversation = ((ChecklistEditorInput) input).getConversationHolder(); |
|
642 |
conversation = checklistEditorInput.getConversation(); |
|
643 |
conversation.registerForDataStoreChanges(this); |
|
640 | 644 |
} |
641 | 645 |
simpleSelectionProvider = new SimpleSelectionProvider(); |
642 | 646 |
getSite().setSelectionProvider(simpleSelectionProvider); |
647 |
|
|
643 | 648 |
} |
644 | 649 |
|
645 | 650 |
@Override |
... | ... | |
657 | 662 |
public void selectionChanged(IWorkbenchPart part, ISelection selection) { |
658 | 663 |
} |
659 | 664 |
|
660 |
/* |
|
661 |
* (non-Javadoc) |
|
662 |
* |
|
663 |
* @see |
|
664 |
* eu.etaxonomy.cdm.persistence.hibernate.ICdmPostDataChangeObserver#update |
|
665 |
* (eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap) |
|
666 |
*/ |
|
667 |
@Override |
|
668 |
public void update(CdmDataChangeMap changeEvents) { |
|
669 | 665 |
|
670 |
} |
|
671 | 666 |
|
672 |
/* |
|
673 |
* (non-Javadoc) |
|
674 |
* |
|
675 |
* @see |
|
676 |
* eu.etaxonomy.cdm.api.conversation.IConversationEnabled#getConversationHolder |
|
677 |
* () |
|
678 |
*/ |
|
679 |
@Override |
|
680 |
public ConversationHolder getConversationHolder() { |
|
681 |
return conversation; |
|
682 |
} |
|
667 |
|
|
683 | 668 |
|
684 | 669 |
/* |
685 | 670 |
* (non-Javadoc) |
... | ... | |
755 | 740 |
private static final List<String> NODE_INIT_STRATEGY = Arrays.asList(new String[] { "descriptions", |
756 | 741 |
"descriptions.*", "description.state", "feature", "feature.*", "childNodes", "childNodes.taxon", |
757 | 742 |
"childNodes.taxon.name", "taxonNodes", "taxonNodes.*", "taxonNodes.taxon.*", "taxon.*", |
758 |
"taxon.descriptions", "taxon.sec", "taxon.name.*", "taxon.synonymRelations", "terms", "name.*",
|
|
759 |
"name.rank.representations", "name.status.type.representations", "sources.$", "stateData.$" });
|
|
743 |
"taxon.descriptions", "taxon.sec", "taxon.name.*", "terms", "name.*", |
|
744 |
"name.rank.representations", "name.status.type.representations", "stateData.$" }); |
|
760 | 745 |
|
761 | 746 |
/* |
762 | 747 |
* (non-Javadoc) |
... | ... | |
800 | 785 |
/* (non-Javadoc) |
801 | 786 |
* @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getCdmEntitySession() |
802 | 787 |
*/ |
803 |
@Override |
|
804 |
public ICdmEntitySession getCdmEntitySession() { |
|
805 |
// TODO Auto-generated method stub |
|
806 |
return null; |
|
788 |
|
|
789 |
|
|
790 |
// /* (non-Javadoc) |
|
791 |
// * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getRootEntities() |
|
792 |
// */ |
|
793 |
// @Override |
|
794 |
// public <T extends CdmBase> Collection<T> getRootEntities() { |
|
795 |
// // TODO Auto-generated method stub |
|
796 |
// return null; |
|
797 |
// } |
|
798 |
// |
|
799 |
// /* (non-Javadoc) |
|
800 |
// * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getPropertyPathsMap() |
|
801 |
// */ |
|
802 |
// @Override |
|
803 |
// public Map<Object, List<String>> getPropertyPathsMap() { |
|
804 |
// // TODO Auto-generated method stub |
|
805 |
// return null; |
|
806 |
// } |
|
807 |
|
|
808 |
/** |
|
809 |
* @return the labelProvider |
|
810 |
*/ |
|
811 |
public ChecklistLabelProvider getLabelProvider() { |
|
812 |
return labelProvider; |
|
807 | 813 |
} |
808 | 814 |
|
809 | 815 |
/* (non-Javadoc) |
810 |
* @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getRootEntities()
|
|
816 |
* @see eu.etaxonomy.cdm.persistence.hibernate.ICdmPostDataChangeObserver#update(eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap)
|
|
811 | 817 |
*/ |
812 | 818 |
@Override |
813 |
public <T extends CdmBase> Collection<T> getRootEntities() {
|
|
819 |
public void update(CdmDataChangeMap arg0) {
|
|
814 | 820 |
// TODO Auto-generated method stub |
815 |
return null; |
|
821 |
|
|
816 | 822 |
} |
817 | 823 |
|
818 | 824 |
/* (non-Javadoc) |
819 |
* @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getPropertyPathsMap()
|
|
825 |
* @see eu.etaxonomy.cdm.api.conversation.IConversationEnabled#getConversationHolder()
|
|
820 | 826 |
*/ |
821 | 827 |
@Override |
822 |
public Map<Object, List<String>> getPropertyPathsMap() { |
|
823 |
// TODO Auto-generated method stub |
|
824 |
return null; |
|
825 |
} |
|
828 |
public ConversationHolder getConversationHolder() { |
|
826 | 829 |
|
827 |
/** |
|
828 |
* @return the labelProvider |
|
829 |
*/ |
|
830 |
public ChecklistLabelProvider getLabelProvider() { |
|
831 |
return labelProvider; |
|
830 |
return conversation; |
|
832 | 831 |
} |
833 | 832 |
} |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/checklist/ChecklistEditorInput.java | ||
---|---|---|
9 | 9 |
*/ |
10 | 10 |
package eu.etaxonomy.taxeditor.editor.view.checklist; |
11 | 11 |
|
12 |
import java.util.ArrayList; |
|
13 |
import java.util.Arrays; |
|
14 |
import java.util.List; |
|
12 | 15 |
import java.util.UUID; |
13 | 16 |
|
14 | 17 |
import org.eclipse.jface.resource.ImageDescriptor; |
... | ... | |
18 | 21 |
import org.eclipse.ui.IPersistableElement; |
19 | 22 |
|
20 | 23 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
24 |
import eu.etaxonomy.cdm.api.service.ITaxonService; |
|
21 | 25 |
import eu.etaxonomy.cdm.model.taxon.Classification; |
26 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase; |
|
22 | 27 |
import eu.etaxonomy.cdm.model.taxon.TaxonNode; |
28 |
import eu.etaxonomy.taxeditor.editor.CdmEntitySessionInput; |
|
23 | 29 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
24 | 30 |
|
25 | 31 |
/** |
... | ... | |
28 | 34 |
* @date 25.04.2014 |
29 | 35 |
* |
30 | 36 |
*/ |
31 |
public class ChecklistEditorInput implements IEditorInput, IPersistable { |
|
37 |
public class ChecklistEditorInput extends CdmEntitySessionInput implements IEditorInput, IPersistable {
|
|
32 | 38 |
|
33 | 39 |
/** |
34 | 40 |
* The selected classification |
35 | 41 |
*/ |
36 | 42 |
private TaxonNode taxonNode = null; |
37 | 43 |
|
44 |
private final List<TaxonBase> taxa = new ArrayList<TaxonBase>(); |
|
45 |
|
|
38 | 46 |
private Classification classification = null; |
39 | 47 |
|
40 |
private final ConversationHolder conversationHolder;
|
|
48 |
private final ConversationHolder conversation; |
|
41 | 49 |
|
42 | 50 |
|
43 | 51 |
/** |
... | ... | |
46 | 54 |
* @param taxonNode |
47 | 55 |
*/ |
48 | 56 |
public ChecklistEditorInput(TaxonNode taxonNode){ |
49 |
super(); |
|
50 |
this.conversationHolder = CdmStore.createConversation();
|
|
57 |
super(true);
|
|
58 |
this.conversation = CdmStore.createConversation(); |
|
51 | 59 |
this.taxonNode = CdmStore.getCurrentApplicationConfiguration().getTaxonNodeService().load(taxonNode.getUuid()); |
60 |
// getChildTaxa(taxonNode); |
|
52 | 61 |
classification = taxonNode.getClassification(); |
53 | 62 |
} |
54 | 63 |
|
64 |
/** |
|
65 |
* @param taxonNode2 |
|
66 |
*/ |
|
67 |
private void getChildTaxa(TaxonNode taxonNode2) { |
|
68 |
taxonNode2.removeNullValueFromChildren(); |
|
69 |
if (taxonNode2.hasChildNodes()){ |
|
70 |
for (TaxonNode node: taxonNode2.getChildNodes()){ |
|
71 |
taxa.add(node.getTaxon()); |
|
72 |
getChildTaxa(node); |
|
73 |
} |
|
74 |
} |
|
75 |
|
|
76 |
|
|
77 |
} |
|
78 |
|
|
55 | 79 |
/** |
56 | 80 |
* Creates an editor input for the {@link ChecklistView} with the currently selected classification. |
57 | 81 |
* @param classificationUuid |
58 | 82 |
*/ |
59 | 83 |
public ChecklistEditorInput(Classification classification) { |
60 |
super(); |
|
61 |
this.conversationHolder = CdmStore.createConversation();
|
|
84 |
super(true);
|
|
85 |
this.conversation = CdmStore.createConversation(); |
|
62 | 86 |
this.classification = CdmStore.getCurrentApplicationConfiguration().getClassificationService().load(classification.getUuid()); |
63 | 87 |
|
64 | 88 |
} |
... | ... | |
133 | 157 |
return classification; |
134 | 158 |
} |
135 | 159 |
|
136 |
/** |
|
137 |
* @return the conversationHolder |
|
138 |
*/ |
|
139 |
public ConversationHolder getConversationHolder() { |
|
140 |
return conversationHolder; |
|
141 |
} |
|
160 |
// /**
|
|
161 |
// * @return the conversationHolder
|
|
162 |
// */
|
|
163 |
// public ConversationHolder getConversationHolder() {
|
|
164 |
// return conversationHolder;
|
|
165 |
// }
|
|
142 | 166 |
|
143 | 167 |
|
144 | 168 |
|
... | ... | |
194 | 218 |
UUID uuid = classification.getUuid(); |
195 | 219 |
} |
196 | 220 |
|
221 |
@Override |
|
222 |
public void merge() { |
|
223 |
for (TaxonBase taxon:taxa){ |
|
224 |
CdmStore.getService(ITaxonService.class).merge(taxon, true); |
|
225 |
} |
|
226 |
|
|
227 |
// CdmStore.getService(ITaxonNodeService.class).merge(taxonNode, true); |
|
228 |
} |
|
229 |
|
|
230 |
/* (non-Javadoc) |
|
231 |
* @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getRootEntities() |
|
232 |
*/ |
|
233 |
@Override |
|
234 |
public List<TaxonNode> getRootEntities() { |
|
235 |
return Arrays.asList(taxonNode); |
|
236 |
} |
|
237 |
|
|
238 |
/** |
|
239 |
* @return the conversation |
|
240 |
*/ |
|
241 |
public ConversationHolder getConversation() { |
|
242 |
return conversation; |
|
243 |
} |
|
244 |
|
|
197 | 245 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/ChecklistEditorGeneralPreference.java | ||
---|---|---|
94 | 94 |
@Override |
95 | 95 |
public void widgetSelected(SelectionEvent e) { |
96 | 96 |
boolean isShowRank = activateRankButton.getSelection(); |
97 |
PreferencesUtil.setShowRankInChecklistEditor(isEditorActivated);
|
|
97 |
PreferencesUtil.setShowRankInChecklistEditor(isShowRank);
|
|
98 | 98 |
} |
99 | 99 |
}); |
100 | 100 |
|
Also available in: Unified diff
fix save of checklist editor, fix show rank preference