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.viewers.CheckStateChangedEvent;
|
16
|
import org.eclipse.jface.viewers.CheckboxTableViewer;
|
17
|
import org.eclipse.jface.viewers.ICheckStateListener;
|
18
|
import org.eclipse.jface.viewers.StyledString.Styler;
|
19
|
import org.eclipse.jface.viewers.ViewerComparator;
|
20
|
import org.eclipse.swt.SWT;
|
21
|
import org.eclipse.swt.graphics.TextStyle;
|
22
|
import org.eclipse.swt.layout.GridData;
|
23
|
import org.eclipse.swt.layout.GridLayout;
|
24
|
import org.eclipse.swt.widgets.Composite;
|
25
|
import org.eclipse.swt.widgets.Display;
|
26
|
|
27
|
import eu.etaxonomy.cdm.model.common.CdmBase;
|
28
|
import eu.etaxonomy.cdm.model.common.TermType;
|
29
|
import eu.etaxonomy.cdm.model.metadata.CdmPreference;
|
30
|
import eu.etaxonomy.taxeditor.editor.definedterm.VocabularyContentProvider;
|
31
|
import eu.etaxonomy.taxeditor.editor.definedterm.VocabularyLabelProvider;
|
32
|
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
|
33
|
import eu.etaxonomy.taxeditor.session.ICdmEntitySession;
|
34
|
import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
|
35
|
|
36
|
/**
|
37
|
* @author k.luther
|
38
|
* @since 04.06.2018
|
39
|
*
|
40
|
*/
|
41
|
public class AvailableAreaVocabulariesPage extends AbstractTermSelectionWizardPage implements ICdmEntitySessionEnabled{
|
42
|
|
43
|
CdmPreference pref;
|
44
|
String featureTitle;
|
45
|
/**
|
46
|
* @param pageName
|
47
|
*/
|
48
|
public AvailableAreaVocabulariesPage(String pageName, boolean localPref, CdmPreference pref, String featureTitle) {
|
49
|
super(pageName, TermType.NamedArea);
|
50
|
this.localPref = localPref;
|
51
|
this.pref = pref;
|
52
|
this.featureTitle = featureTitle;
|
53
|
|
54
|
}
|
55
|
|
56
|
/**
|
57
|
* {@inheritDoc}
|
58
|
*/
|
59
|
@Override
|
60
|
public void createControl(Composite parent) {
|
61
|
String vocString = null;
|
62
|
if (localPref){
|
63
|
vocString = PreferencesUtil.getPreferredVocabulariesForDistributionEditor(localPref);
|
64
|
}else if (pref != null){
|
65
|
vocString = pref.getValue();
|
66
|
}
|
67
|
setTitle("Select Vocabularies for "+ featureTitle);
|
68
|
setDescription("In order to be able to modify and see the "+ featureTitle +" of taxa,\n"
|
69
|
+ "you have to select the vocabularies to select the areas from.");
|
70
|
Composite composite = new Composite(parent, SWT.NULL);
|
71
|
composite.setLayout(new GridLayout());
|
72
|
setViewer(CheckboxTableViewer.newCheckList(composite, SWT.NULL));
|
73
|
((CheckboxTableViewer)getViewer()).getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
|
74
|
|
75
|
Styler styler = new Styler() {
|
76
|
@Override
|
77
|
public void applyStyles(TextStyle textStyle) {
|
78
|
textStyle.foreground = Display.getCurrent().getSystemColor(SWT.COLOR_BLACK);
|
79
|
}
|
80
|
};
|
81
|
getViewer().setContentProvider(new VocabularyContentProvider());
|
82
|
getViewer().setLabelProvider(new VocabularyLabelProvider(styler));
|
83
|
getViewer().setComparator(new ViewerComparator());
|
84
|
((CheckboxTableViewer)getViewer()).addCheckStateListener(new ICheckStateListener() {
|
85
|
|
86
|
private boolean ignoreCheckEvent = false;
|
87
|
|
88
|
@Override
|
89
|
public void checkStateChanged(CheckStateChangedEvent event) {
|
90
|
|
91
|
|
92
|
if (ignoreCheckEvent ) {
|
93
|
return;
|
94
|
}
|
95
|
|
96
|
ignoreCheckEvent = true;
|
97
|
|
98
|
try {
|
99
|
|
100
|
|
101
|
}
|
102
|
finally {
|
103
|
ignoreCheckEvent = false;
|
104
|
}
|
105
|
|
106
|
}
|
107
|
});
|
108
|
rememberCheckedValues(vocString, null);
|
109
|
((CheckboxTableViewer)getViewer()).setCheckedElements(listCheckedTerms.toArray());
|
110
|
setControl(composite);
|
111
|
|
112
|
}
|
113
|
|
114
|
/**
|
115
|
* {@inheritDoc}
|
116
|
*/
|
117
|
@Override
|
118
|
public ICdmEntitySession getCdmEntitySession() {
|
119
|
return null;
|
120
|
}
|
121
|
|
122
|
/**
|
123
|
* {@inheritDoc}
|
124
|
*/
|
125
|
@Override
|
126
|
public <T extends CdmBase> Collection<T> getRootEntities() {
|
127
|
return null;
|
128
|
}
|
129
|
|
130
|
/**
|
131
|
* {@inheritDoc}
|
132
|
*/
|
133
|
@Override
|
134
|
public Map<Object, List<String>> getPropertyPathsMap() {
|
135
|
return null;
|
136
|
}
|
137
|
|
138
|
|
139
|
|
140
|
}
|