Project

General

Profile

« Previous | Next » 

Revision 20f51c0a

Added by Patrick Plitzner over 3 years ago

ref #7887 Fix preference persisting (based on DTOs)

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/wizard/AvailableDistributionWizard.java
14 14

  
15 15
import org.apache.commons.collections.CollectionUtils;
16 16
import org.apache.commons.lang.StringUtils;
17
import org.eclipse.jface.viewers.CheckboxTreeViewer;
18 17
import org.eclipse.jface.wizard.Wizard;
19 18

  
20 19
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
21 20
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
22
import eu.etaxonomy.cdm.model.common.OrderedTermVocabulary;
23
import eu.etaxonomy.cdm.model.location.NamedArea;
21
import eu.etaxonomy.cdm.persistence.dto.TermDto;
22
import eu.etaxonomy.cdm.persistence.dto.TermVocabularyDto;
24 23
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
25 24
import eu.etaxonomy.taxeditor.l10n.Messages;
26 25
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
......
51 50
    public boolean performFinish() {
52 51
        // TODO: get Selection and save in EditorPreferences
53 52
        if (!checkNoneChecked()) {
54
            Object[] checkedElements = ((CheckboxTreeViewer)aPage.getViewer()).getCheckedElements();
55
            Object[] grayedElements = ((CheckboxTreeViewer)aPage.getViewer()).getGrayedElements();
53
            Object[] checkedElements = aPage.getViewer().getCheckedElements();
54
            Object[] grayedElements = aPage.getViewer().getGrayedElements();
56 55
            ArrayList checkedList = new ArrayList(Arrays.asList(checkedElements));
57 56
            ArrayList grayedList = new ArrayList(Arrays.asList(grayedElements));
58 57
            checkedList = (ArrayList) CollectionUtils.subtract(checkedList, grayedList);
59 58
            ArrayList<UUID> listUIIDChecked = new ArrayList<UUID>();
60 59
            ArrayList<UUID> listUIIDGrayed = new ArrayList<UUID>();
61 60
            for (Object o : checkedList) {
62
                if (o instanceof NamedAreaWrapper) {
63
                    NamedArea na = (NamedArea)((NamedAreaWrapper) o).getNamedArea();
64
                    listUIIDChecked.add(na.getUuid());
61
                if (o instanceof TermDto) {
62
                    listUIIDChecked.add(((TermDto) o).getUuid());
65 63

  
66
                }else if(o instanceof OrderedTermVocabulary){
67
                    OrderedTermVocabulary otb = (OrderedTermVocabulary) o;
68
                    listUIIDGrayed.add(otb.getUuid());
64
                }else if(o instanceof TermVocabularyDto){
65
                    TermVocabularyDto termVocDto = (TermVocabularyDto) o;
66
                    listUIIDGrayed.add(termVocDto.getUuid());
69 67
                }
70 68
            }
71 69
            for (Object o : grayedList) {
72
                if (o instanceof NamedAreaWrapper) {
73
                    NamedArea na = (NamedArea)((NamedAreaWrapper) o).getNamedArea();
74
                    listUIIDGrayed.add(na.getUuid());
75
                }else if(o instanceof OrderedTermVocabulary){
76
                    OrderedTermVocabulary otb = (OrderedTermVocabulary) o;
77
                    listUIIDGrayed.add(otb.getUuid());
78
                }
70
                if (o instanceof TermDto) {
71
                    listUIIDChecked.add(((TermDto) o).getUuid());
79 72

  
73
                }else if(o instanceof TermVocabularyDto){
74
                    TermVocabularyDto termVocDto = (TermVocabularyDto) o;
75
                    listUIIDGrayed.add(termVocDto.getUuid());
76
                }
80 77
            }
81 78

  
82 79
            String saveCheckedElements = StringUtils.join(listUIIDChecked, ";"); //$NON-NLS-1$
......
100 97

  
101 98
    private boolean checkNoneChecked() {
102 99

  
103
        if (((CheckboxTreeViewer)aPage.getViewer()).getCheckedElements().length == 0) {
100
        if (aPage.getViewer().getCheckedElements().length == 0) {
104 101
            aPage.setMessage(Messages.AvailableDistributionWizard_CHECK_MESSAGE, aPage.WARNING);
105 102
            return true;
106 103
        } else {

Also available in: Unified diff