Revision 9fe7e119
Added by Katja Luther almost 5 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/matching/AbstractMatchingPreferences.java | ||
---|---|---|
9 | 9 |
|
10 | 10 |
package eu.etaxonomy.taxeditor.preference.matching; |
11 | 11 |
|
12 |
|
|
12 | 13 |
import java.lang.reflect.Field; |
13 | 14 |
import java.util.ArrayList; |
14 | 15 |
import java.util.Arrays; |
... | ... | |
17 | 18 |
import java.util.Map; |
18 | 19 |
|
19 | 20 |
import org.eclipse.jface.preference.ComboFieldEditor; |
20 |
import org.eclipse.swt.widgets.Combo; |
|
21 |
import org.eclipse.swt.SWT; |
|
22 |
import org.eclipse.swt.layout.GridData; |
|
23 |
import org.eclipse.swt.widgets.Composite; |
|
24 |
import org.eclipse.swt.widgets.Control; |
|
21 | 25 |
|
22 | 26 |
import eu.etaxonomy.cdm.model.common.IdentifiableEntity; |
23 | 27 |
import eu.etaxonomy.cdm.strategy.match.IMatchStrategy; |
24 | 28 |
import eu.etaxonomy.cdm.strategy.match.MatchException; |
25 | 29 |
import eu.etaxonomy.cdm.strategy.match.MatchMode; |
26 |
import eu.etaxonomy.taxeditor.preference.menu.FieldEditorPreferencePageE4; |
|
27 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
|
30 |
import eu.etaxonomy.taxeditor.preference.menu.CdmPreferencePage; |
|
28 | 31 |
|
29 | 32 |
/** |
30 | 33 |
* @author n.hoffmann |
31 | 34 |
* @created Jan 22, 2010 |
32 | 35 |
* @version 1.0 |
33 | 36 |
*/ |
34 |
public abstract class AbstractMatchingPreferences<T extends IdentifiableEntity> extends FieldEditorPreferencePageE4 {
|
|
37 |
public abstract class AbstractMatchingPreferences<T extends IdentifiableEntity> extends CdmPreferencePage {
|
|
35 | 38 |
|
36 | 39 |
/** |
37 | 40 |
* Fields that will be excluded from the display |
38 | 41 |
*/ |
39 | 42 |
private static final String ExcludePattern = "serialVersionUID|logger|allFields|ajc.*|id|updated|updatedBy|created|createdBy|uuid" + |
40 |
"|parsingProblem|problemStarts|problemEnds|PROTECTED|NOT_PROTECTED|propertyChangeSupport"; |
|
43 |
"|parsingProblem|problemStarts|problemEnds|PROTECTED|NOT_PROTECTED|propertyChangeSupport|CLOB_LENGTH|newEntityListener|.*SWITCH_TABLE.*";
|
|
41 | 44 |
|
42 | 45 |
protected IMatchStrategy matchStrategy; |
43 | 46 |
|
... | ... | |
45 | 48 |
|
46 | 49 |
private List<MatchMode> matchModeList; |
47 | 50 |
|
48 |
protected Map<String, Combo> matchModeCombos = new HashMap<String, Combo>();
|
|
51 |
protected Map<String, ComboFieldEditor> matchModeCombos = new HashMap();
|
|
49 | 52 |
|
50 |
/** |
|
51 |
* {@inheritDoc} |
|
52 |
*/ |
|
53 |
@Override |
|
54 |
protected void createFieldEditors() { |
|
55 |
if(CdmStore.isActive()) { |
|
56 |
for(String fieldName : getFieldNames()){ |
|
57 |
String[][] comboValues = new String[getMatchModeList().size()][2]; |
|
58 |
for (int i=0;i<getMatchModeList().size();i++) { |
|
59 |
comboValues[i][0] = getMatchModeList().get(i).name(); |
|
60 |
comboValues[i][1] = getMatchModeList().get(i).name(); |
|
61 |
} |
|
62 |
addField(new ComboFieldEditor(this.getClass().getCanonicalName()+fieldName, |
|
63 |
fieldName, comboValues, |
|
64 |
getFieldEditorParent())); |
|
65 |
} |
|
66 |
} |
|
67 |
} |
|
53 |
@Override |
|
54 |
protected Control createContents(Composite parent) { |
|
55 |
|
|
56 |
Composite top = new Composite(parent, SWT.LEFT); |
|
57 |
GridData layoutData = new GridData(SWT.FILL, SWT.TOP, true, false); |
|
58 |
|
|
59 |
layoutData.heightHint = 300; |
|
60 |
|
|
61 |
top.setLayoutData(layoutData); |
|
62 |
|
|
63 |
|
|
64 |
// final GridLayout gridLayout = new GridLayout(); |
|
65 |
// gridLayout.numColumns = 2; |
|
66 |
// |
|
67 |
// top.setLayout(gridLayout); |
|
68 |
|
|
69 |
for(String fieldName : getFieldNames()){ |
|
70 |
String[][] comboValues = new String[getMatchModeList().size()][2]; |
|
71 |
for (int i=0;i<getMatchModeList().size();i++) { |
|
72 |
comboValues[i][0] = getMatchModeList().get(i).name(); |
|
73 |
comboValues[i][1] = getMatchModeList().get(i).name(); |
|
74 |
} |
|
75 |
|
|
76 |
ComboFieldEditor editor = new ComboFieldEditor(this.getClass().getCanonicalName()+fieldName, |
|
77 |
fieldName, comboValues, |
|
78 |
top); |
|
79 |
|
|
80 |
editor.setPreferenceStore(getPreferenceStore()); |
|
81 |
editor.load(); |
|
82 |
editor.fillIntoGrid(top, editor.getNumberOfControls()); |
|
83 |
matchModeCombos.put(fieldName, editor); |
|
84 |
} |
|
85 |
|
|
86 |
return top; |
|
87 |
|
|
88 |
} |
|
89 |
|
|
90 |
@Override |
|
91 |
public void createControl(Composite parent){ |
|
92 |
super.createControl(parent); |
|
93 |
if (getApplyButton() != null){ |
|
94 |
this.getApplyButton().setEnabled(true); |
|
95 |
} |
|
96 |
} |
|
97 |
|
|
98 |
@Override |
|
99 |
public boolean performOk() { |
|
100 |
if (matchModeCombos.size() >0){ |
|
101 |
for (ComboFieldEditor editor: matchModeCombos.values()){ |
|
102 |
editor.store(); |
|
103 |
} |
|
104 |
} |
|
105 |
return super.performOk(); |
|
106 |
|
|
107 |
} |
|
108 |
@Override |
|
109 |
protected void performDefaults() { |
|
110 |
if (matchModeCombos.size() >0){ |
|
111 |
for (ComboFieldEditor editor: matchModeCombos.values()){ |
|
112 |
editor.loadDefault(); |
|
113 |
} |
|
114 |
} |
|
115 |
super.performDefaults(); |
|
116 |
} |
|
117 |
|
|
118 |
|
|
119 |
|
|
120 |
|
|
121 |
// /** |
|
122 |
// * {@inheritDoc} |
|
123 |
// */ |
|
124 |
// @Override |
|
125 |
// protected void createFieldEditors() { |
|
126 |
// if(CdmStore.isActive()) { |
|
127 |
// for(String fieldName : getFieldNames()){ |
|
128 |
// String[][] comboValues = new String[getMatchModeList().size()][2]; |
|
129 |
// for (int i=0;i<getMatchModeList().size();i++) { |
|
130 |
// comboValues[i][0] = getMatchModeList().get(i).name(); |
|
131 |
// comboValues[i][1] = getMatchModeList().get(i).name(); |
|
132 |
// } |
|
133 |
// addField(new ComboFieldEditor(this.getClass().getCanonicalName()+fieldName, |
|
134 |
// fieldName, comboValues, |
|
135 |
// getFieldEditorParent())); |
|
136 |
// } |
|
137 |
// } |
|
138 |
// } |
|
68 | 139 |
|
69 | 140 |
/** |
70 | 141 |
* Transforms the MatchMode enum into a list. |
Also available in: Unified diff
ref #8045: show possible entries for preferences in combo boxes and show default value