Project

General

Profile

Download (4.32 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2018 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.preference.wizard;
10

    
11
import java.util.Collection;
12
import java.util.List;
13
import java.util.Map;
14

    
15
import org.eclipse.jface.preference.IPreferenceStore;
16
import org.eclipse.jface.viewers.CheckStateChangedEvent;
17
import org.eclipse.jface.viewers.CheckboxTableViewer;
18
import org.eclipse.jface.viewers.ICheckStateListener;
19
import org.eclipse.jface.viewers.StyledString.Styler;
20
import org.eclipse.jface.viewers.ViewerComparator;
21
import org.eclipse.swt.SWT;
22
import org.eclipse.swt.graphics.TextStyle;
23
import org.eclipse.swt.layout.GridData;
24
import org.eclipse.swt.layout.GridLayout;
25
import org.eclipse.swt.widgets.Composite;
26
import org.eclipse.swt.widgets.Display;
27

    
28
import eu.etaxonomy.cdm.model.common.CdmBase;
29
import eu.etaxonomy.taxeditor.editor.definedterm.VocabularyContentProvider;
30
import eu.etaxonomy.taxeditor.editor.definedterm.VocabularyLabelProvider;
31
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
32
import eu.etaxonomy.taxeditor.session.ICdmEntitySession;
33
import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
34

    
35
/**
36
 * @author k.luther
37
 * @since 04.06.2018
38
 *
39
 */
40
public class AvailableAreaVocabulariesPage  extends AbstractAreaSelectionWizard implements ICdmEntitySessionEnabled{
41
    boolean localPref;
42

    
43
    /**
44
     * @param pageName
45
     */
46
    public AvailableAreaVocabulariesPage(String pageName, boolean localPref) {
47
        super(pageName);
48
        this.localPref = localPref;
49

    
50
    }
51

    
52
     /**
53
     * {@inheritDoc}
54
     */
55
    @Override
56
    public void createControl(Composite parent) {
57
        IPreferenceStore preferenceStore = PreferencesUtil.getPreferenceStore();
58
       // String checkedValues = preferenceStore.getString(PreferencesUtil.DISTRIBUTION_VOCABULARIES);
59

    
60
        String vocString = PreferencesUtil.getPreferredVocabulariesForDistributionEditor(localPref);
61
       // String grayedValues = preferenceStore.getString(PreferencesUtil.DISTRIBUTION_AREA_OCCURENCE_STATUS_GRAYED);
62
        setTitle("Select vocabularies for Distribution Editor");
63
        setDescription("In order to be able to modify and see the distribution status of taxa,\n"
64
                + "you have to select the areas which you like to see.");
65
        Composite composite = new Composite(parent, SWT.NULL);
66
        composite.setLayout(new GridLayout());
67
        setViewer(CheckboxTableViewer.newCheckList(composite, SWT.NULL));
68
        ((CheckboxTableViewer)getViewer()).getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
69
//        viewer.setContentProvider(new TermContentProvider());
70
        Styler styler = new Styler() {
71
            @Override
72
            public void applyStyles(TextStyle textStyle) {
73
                textStyle.foreground = Display.getCurrent().getSystemColor(SWT.COLOR_BLACK);
74
            }
75
        };
76
        getViewer().setContentProvider(new VocabularyContentProvider());
77
        getViewer().setLabelProvider(new VocabularyLabelProvider(styler));
78
        getViewer().setComparator(new ViewerComparator());
79
        ((CheckboxTableViewer)getViewer()).addCheckStateListener(new ICheckStateListener() {
80

    
81
            private boolean ignoreCheckEvent = false;
82

    
83
            @Override
84
            public void checkStateChanged(CheckStateChangedEvent event) {
85

    
86

    
87
                if (ignoreCheckEvent ) {
88
                    return;
89
                }
90

    
91
                ignoreCheckEvent = true;
92

    
93
                try {
94

    
95

    
96
                }
97
                finally {
98
                    ignoreCheckEvent = false;
99
                }
100

    
101
            }
102
        });
103
        rememberCheckedValues(vocString, null);
104
        setControl(composite);
105

    
106
    }
107

    
108
    /**
109
     * {@inheritDoc}
110
     */
111
    @Override
112
    public ICdmEntitySession getCdmEntitySession() {
113
        // TODO Auto-generated method stub
114
        return null;
115
    }
116

    
117
    /**
118
     * {@inheritDoc}
119
     */
120
    @Override
121
    public <T extends CdmBase> Collection<T> getRootEntities() {
122
        // TODO Auto-generated method stub
123
        return null;
124
    }
125

    
126
    /**
127
     * {@inheritDoc}
128
     */
129
    @Override
130
    public Map<Object, List<String>> getPropertyPathsMap() {
131
        // TODO Auto-generated method stub
132
        return null;
133
    }
134

    
135

    
136

    
137
}
(2-2/7)