Project

General

Profile

« Previous | Next » 

Revision 18154a72

Added by Patrick Plitzner over 5 years ago

ref #7887 Fix preference persisting (based on DTOs)

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/RootElementsOnlyTreeContentProvider.java
1
/**
2
* Copyright (C) 2009 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.taxeditor.editor.definedterm;
10

  
11
import java.util.Collection;
12

  
13
import org.eclipse.jface.viewers.ITreeContentProvider;
14

  
15
import eu.etaxonomy.cdm.model.common.TermVocabulary;
16

  
17
/**
18
 *
19
 * @author pplitzner
20
 * @since Nov 12, 2018
21
 *
22
 */
23
public class RootElementsOnlyTreeContentProvider implements ITreeContentProvider {
24

  
25
    @Override
26
    public Object[] getElements(Object inputElement) {
27
        return ((Collection<TermVocabulary>)inputElement).toArray();
28
    }
29

  
30
    @Override
31
    public Object[] getChildren(Object parentElement) {
32
        return new Object[0];
33
    }
34

  
35
    @Override
36
    public Object getParent(Object element) {
37
        return null;
38
    }
39

  
40
    @Override
41
    public boolean hasChildren(Object element) {
42
        return false;
43
    }
44

  
45
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/VocabularyContentProvider.java
1
/**
2
* Copyright (C) 2009 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.taxeditor.editor.definedterm;
10

  
11
import java.util.Collection;
12

  
13
import org.eclipse.jface.viewers.IStructuredContentProvider;
14
import org.eclipse.jface.viewers.Viewer;
15

  
16
import eu.etaxonomy.cdm.model.common.TermVocabulary;
17

  
18
/**
19
 * @author l.morris
20
 * @date 8 Dec 2011
21
 *
22
 */
23
public class VocabularyContentProvider implements IStructuredContentProvider {
24

  
25
	/* (non-Javadoc)
26
	 * @see org.eclipse.jface.viewers.IContentProvider#dispose()
27
	 */
28
	@Override
29
	public void dispose() {
30
		// TODO Auto-generated method stub
31

  
32
	}
33

  
34
	/* (non-Javadoc)
35
	 * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
36
	 */
37
	@Override
38
	public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
39
		// TODO Auto-generated method stub
40

  
41
	}
42

  
43
	/* (non-Javadoc)
44
	 * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
45
	 */
46
	@Override
47
	public Object[] getElements(Object inputElement) {
48

  
49
		Collection<TermVocabulary> inputElements = (Collection<TermVocabulary>) inputElement;
50
		return inputElements.toArray();
51

  
52
	}
53

  
54
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/wizard/AvailableAreaVocabulariesPage.java
26 26
import eu.etaxonomy.cdm.model.metadata.CdmPreference;
27 27
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
28 28
import eu.etaxonomy.cdm.persistence.dto.TermVocabularyDto;
29
import eu.etaxonomy.taxeditor.editor.definedterm.RootElementsOnlyTreeContentProvider;
29 30
import eu.etaxonomy.taxeditor.l10n.Messages;
30 31
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
31 32
import eu.etaxonomy.taxeditor.session.ICdmEntitySession;
......
62 63
        setDescription(String.format(Messages.AvailableAreaVocabulariesPage_PAGE_DESCRIPTION, featureTitle));
63 64

  
64 65
        super.createControl(parent);
66
        treeComposite.getViewer().setContentProvider(new RootElementsOnlyTreeContentProvider());
65 67
    }
66 68

  
67 69
    /**
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/wizard/AvailableDistributionStatusWizard.java
23 23
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
24 24
import eu.etaxonomy.cdm.model.metadata.CdmPreference;
25 25
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
26
import eu.etaxonomy.cdm.persistence.dto.TermDto;
26 27
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
27 28
import eu.etaxonomy.taxeditor.l10n.Messages;
28 29
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
......
119 120
        List<UUID> listUIIDChecked = new ArrayList<>();
120 121
        List<DefinedTermBase> preferredTerms = new ArrayList<>();
121 122
        for (Object o : checkedElements) {
122
            if(o instanceof DefinedTermBase){
123
                DefinedTermBase otb = (DefinedTermBase) o;
123
            if(o instanceof TermDto){
124
                TermDto otb = (TermDto) o;
124 125
                listUIIDChecked.add(otb.getUuid());
125
                preferredTerms.add(otb);
126
                preferredTerms.add(CdmStore.getService(ITermService.class).load(otb.getUuid()));
126 127
            }
127 128
        }
128 129
        String saveCheckedElements = StringUtils.join(listUIIDChecked, ";"); //$NON-NLS-1$
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/wizard/AvailableVocabularyWizard.java
17 17

  
18 18
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
19 19
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
20
import eu.etaxonomy.cdm.model.common.TermVocabulary;
21 20
import eu.etaxonomy.cdm.model.metadata.CdmPreference;
22 21
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
23 22
import eu.etaxonomy.cdm.model.metadata.PreferenceSubject;
23
import eu.etaxonomy.cdm.persistence.dto.TermVocabularyDto;
24 24
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
25 25
import eu.etaxonomy.taxeditor.l10n.Messages;
26 26
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
......
119 119

  
120 120
        ArrayList<UUID> listUIIDChecked = new ArrayList<UUID>();
121 121
        for (Object o : checkedElements) {
122
               if(o instanceof TermVocabulary){
123
                    TermVocabulary otb = (TermVocabulary) o;
122
               if(o instanceof TermVocabularyDto){
123
                   TermVocabularyDto otb = (TermVocabularyDto) o;
124 124
                    listUIIDChecked.add(otb.getUuid());
125 125
                }
126 126
            }

Also available in: Unified diff