Project

General

Profile

« Previous | Next » 

Revision 751c610c

Added by Katja Luther almost 8 years ago

fix save of checklist editor, fix show rank preference

View differences:

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
}

Also available in: Unified diff