Revision c82a307b
Added by Patrick Plitzner over 6 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/matching/AbstractMatchingPreferences.java | ||
---|---|---|
12 | 12 |
import java.lang.reflect.Field; |
13 | 13 |
import java.util.ArrayList; |
14 | 14 |
import java.util.Arrays; |
15 |
import java.util.HashMap; |
|
15 | 16 |
import java.util.List; |
16 |
|
|
17 |
import javax.inject.Inject; |
|
17 |
import java.util.Map; |
|
18 | 18 |
|
19 | 19 |
import org.eclipse.jface.preference.ComboFieldEditor; |
20 | 20 |
import org.eclipse.jface.preference.FieldEditorPreferencePage; |
21 |
import org.eclipse.swt.widgets.Composite; |
|
22 |
import org.eclipse.swt.widgets.Control; |
|
21 |
import org.eclipse.swt.widgets.Combo; |
|
22 |
import org.eclipse.ui.IWorkbench; |
|
23 |
import org.eclipse.ui.IWorkbenchPreferencePage; |
|
23 | 24 |
|
24 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
|
25 | 25 |
import eu.etaxonomy.cdm.model.common.IdentifiableEntity; |
26 | 26 |
import eu.etaxonomy.cdm.strategy.match.IMatchStrategy; |
27 | 27 |
import eu.etaxonomy.cdm.strategy.match.MatchException; |
28 | 28 |
import eu.etaxonomy.cdm.strategy.match.MatchMode; |
29 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
|
29 | 30 |
import eu.etaxonomy.taxeditor.preference.PreferencesUtil; |
30 | 31 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
31 | 32 |
|
... | ... | |
34 | 35 |
* @created Jan 22, 2010 |
35 | 36 |
* @version 1.0 |
36 | 37 |
*/ |
37 |
public abstract class AbstractMatchingPreferences<T extends IdentifiableEntity> extends FieldEditorPreferencePage { |
|
38 |
public abstract class AbstractMatchingPreferences<T extends IdentifiableEntity> extends FieldEditorPreferencePage implements |
|
39 |
IWorkbenchPreferencePage { |
|
38 | 40 |
|
39 | 41 |
/** |
40 | 42 |
* Fields that will be excluded from the display |
... | ... | |
42 | 44 |
private static final String ExcludePattern = "serialVersionUID|logger|allFields|ajc.*|id|updated|updatedBy|created|createdBy|uuid" + |
43 | 45 |
"|parsingProblem|problemStarts|problemEnds|PROTECTED|NOT_PROTECTED|propertyChangeSupport"; |
44 | 46 |
|
47 |
protected IMatchStrategy matchStrategy; |
|
48 |
|
|
45 | 49 |
protected Class<T> clazz; |
46 | 50 |
|
47 | 51 |
private List<MatchMode> matchModeList; |
48 | 52 |
|
49 |
@Inject |
|
53 |
protected Map<String, Combo> matchModeCombos = new HashMap<String, Combo>(); |
|
54 |
|
|
50 | 55 |
@Override |
51 |
protected Control createContents(Composite parent) { |
|
52 |
Control contents = super.createContents(parent); |
|
56 |
public void init(IWorkbench workbench) { |
|
53 | 57 |
setPreferenceStore(PreferencesUtil.getPreferenceStore()); |
54 |
return contents; |
|
55 | 58 |
} |
56 | 59 |
|
57 | 60 |
/** |
... | ... | |
59 | 62 |
*/ |
60 | 63 |
@Override |
61 | 64 |
protected void createFieldEditors() { |
62 |
if(CdmStore.isActive()) { |
|
65 |
if(!CdmStore.isActive()) { |
|
66 |
MessagingUtils.noDataSourceWarningDialog(null); |
|
67 |
}else{ |
|
63 | 68 |
for(String fieldName : getFieldNames()){ |
64 | 69 |
String[][] comboValues = new String[getMatchModeList().size()][2]; |
65 | 70 |
for (int i=0;i<getMatchModeList().size();i++) { |
... | ... | |
85 | 90 |
return matchModeList; |
86 | 91 |
} |
87 | 92 |
|
88 |
public abstract Class<? extends CdmBase> getType(); |
|
89 |
|
|
90 | 93 |
/** |
91 | 94 |
* Get names of all declared fields |
92 | 95 |
* |
... | ... | |
95 | 98 |
private List<String> getFieldNames(){ |
96 | 99 |
List<Field> fields = new ArrayList<Field>(); |
97 | 100 |
|
98 |
fields = getAllFields(fields, getType());
|
|
101 |
fields = getAllFields(fields, clazz);
|
|
99 | 102 |
List<String> fieldNames = new ArrayList<String>(); |
100 | 103 |
|
101 | 104 |
for(Field field : fields){ |
Also available in: Unified diff
ref #7006 Revert opcoach plugin for preferences