package eu.etaxonomy.taxeditor.preference.matching;
+
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import org.eclipse.jface.preference.ComboFieldEditor;
-import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
import eu.etaxonomy.cdm.strategy.match.IMatchStrategy;
import eu.etaxonomy.cdm.strategy.match.MatchException;
import eu.etaxonomy.cdm.strategy.match.MatchMode;
-import eu.etaxonomy.taxeditor.preference.menu.FieldEditorPreferencePageE4;
-import eu.etaxonomy.taxeditor.store.CdmStore;
+import eu.etaxonomy.taxeditor.preference.menu.CdmPreferencePage;
/**
* @author n.hoffmann
* @created Jan 22, 2010
* @version 1.0
*/
-public abstract class AbstractMatchingPreferences<T extends IdentifiableEntity> extends FieldEditorPreferencePageE4 {
+public abstract class AbstractMatchingPreferences<T extends IdentifiableEntity> extends CdmPreferencePage {
/**
* Fields that will be excluded from the display
*/
private static final String ExcludePattern = "serialVersionUID|logger|allFields|ajc.*|id|updated|updatedBy|created|createdBy|uuid" +
- "|parsingProblem|problemStarts|problemEnds|PROTECTED|NOT_PROTECTED|propertyChangeSupport";
+ "|parsingProblem|problemStarts|problemEnds|PROTECTED|NOT_PROTECTED|propertyChangeSupport|CLOB_LENGTH|newEntityListener|.*SWITCH_TABLE.*";
protected IMatchStrategy matchStrategy;
private List<MatchMode> matchModeList;
- protected Map<String, Combo> matchModeCombos = new HashMap<String, Combo>();
+ protected Map<String, ComboFieldEditor> matchModeCombos = new HashMap();
- /**
- * {@inheritDoc}
- */
- @Override
- protected void createFieldEditors() {
- if(CdmStore.isActive()) {
- for(String fieldName : getFieldNames()){
- String[][] comboValues = new String[getMatchModeList().size()][2];
- for (int i=0;i<getMatchModeList().size();i++) {
- comboValues[i][0] = getMatchModeList().get(i).name();
- comboValues[i][1] = getMatchModeList().get(i).name();
- }
- addField(new ComboFieldEditor(this.getClass().getCanonicalName()+fieldName,
- fieldName, comboValues,
- getFieldEditorParent()));
- }
- }
- }
+ @Override
+ protected Control createContents(Composite parent) {
+
+ Composite top = new Composite(parent, SWT.LEFT);
+ GridData layoutData = new GridData(SWT.FILL, SWT.TOP, true, false);
+
+ layoutData.heightHint = 300;
+
+ top.setLayoutData(layoutData);
+
+
+// final GridLayout gridLayout = new GridLayout();
+// gridLayout.numColumns = 2;
+//
+// top.setLayout(gridLayout);
+
+ for(String fieldName : getFieldNames()){
+ String[][] comboValues = new String[getMatchModeList().size()][2];
+ for (int i=0;i<getMatchModeList().size();i++) {
+ comboValues[i][0] = getMatchModeList().get(i).name();
+ comboValues[i][1] = getMatchModeList().get(i).name();
+ }
+
+ ComboFieldEditor editor = new ComboFieldEditor(this.getClass().getCanonicalName()+fieldName,
+ fieldName, comboValues,
+ top);
+
+ editor.setPreferenceStore(getPreferenceStore());
+ editor.load();
+ editor.fillIntoGrid(top, editor.getNumberOfControls());
+ matchModeCombos.put(fieldName, editor);
+ }
+
+ return top;
+
+ }
+
+ @Override
+ public void createControl(Composite parent){
+ super.createControl(parent);
+ if (getApplyButton() != null){
+ this.getApplyButton().setEnabled(true);
+ }
+ }
+
+ @Override
+ public boolean performOk() {
+ if (matchModeCombos.size() >0){
+ for (ComboFieldEditor editor: matchModeCombos.values()){
+ editor.store();
+ }
+ }
+ return super.performOk();
+
+ }
+ @Override
+ protected void performDefaults() {
+ if (matchModeCombos.size() >0){
+ for (ComboFieldEditor editor: matchModeCombos.values()){
+ editor.loadDefault();
+ }
+ }
+ super.performDefaults();
+ }
+
+
+
+
+// /**
+// * {@inheritDoc}
+// */
+// @Override
+// protected void createFieldEditors() {
+// if(CdmStore.isActive()) {
+// for(String fieldName : getFieldNames()){
+// String[][] comboValues = new String[getMatchModeList().size()][2];
+// for (int i=0;i<getMatchModeList().size();i++) {
+// comboValues[i][0] = getMatchModeList().get(i).name();
+// comboValues[i][1] = getMatchModeList().get(i).name();
+// }
+// addField(new ComboFieldEditor(this.getClass().getCanonicalName()+fieldName,
+// fieldName, comboValues,
+// getFieldEditorParent()));
+// }
+// }
+// }
/**
* Transforms the MatchMode enum into a list.