From: Patric Plitzner
MAX_HEIGHT=0
*/
public static final int MAX_HEIGHT = 0;
@@ -43,11 +41,13 @@ public class TextWithLabelComposite extends AbstractCdmFormElementComposite impl
public static final int SINGLE = -1;
/**
- *
- *
+ * Create the composite.
+ * @param parent
+ * @param style
+ * @param initialText
+ * @param textHeight
*/
- public TextWithLabelComposite(Composite parent, FormToolkit formFactory, ICdmFormElement parentFormElement, String labelString,
- String initialText, Integer textHeight, int style) {
+ public CdmTextField(Composite parent, FormToolkit formFactory, ICdmFormElement parentFormElement, String initialText, Integer textHeight, int style) {
super(parent, formFactory, parentFormElement, style);
setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
@@ -65,17 +65,9 @@ public class TextWithLabelComposite extends AbstractCdmFormElementComposite impl
}
//^^^^^^^^^^^^^^
- label = new Label(this, SWT.NONE);
- TableWrapData twd_lblNewLabel = new TableWrapData(TableWrapData.RIGHT, TableWrapData.TOP);
- twd_lblNewLabel.grabHorizontal = true;
- twd_lblNewLabel.align = TableWrapData.LEFT;
- label.setLayoutData(twd_lblNewLabel);
- label.setText(labelString);
-
text = new Text(this, SWT.NONE);
- TableWrapData twd_text_1 = new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP);
- twd_text_1.align = TableWrapData.RIGHT;
- twd_text_1.grabHorizontal = false;
+ TableWrapData twd_text_1 = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP);
+ twd_text_1.grabHorizontal = true;
text.setText(initialText);
text.setLayoutData(twd_text_1);
@@ -93,7 +85,7 @@ public class TextWithLabelComposite extends AbstractCdmFormElementComposite impl
// traverse is not working for wrapped text widgets so
// we reintroduce it here
e.doit = false;
- TextWithLabelComposite.this.text.traverse(SWT.TRAVERSE_TAB_NEXT);
+ CdmTextField.this.text.traverse(SWT.TRAVERSE_TAB_NEXT);
}
}
});
@@ -108,10 +100,14 @@ public class TextWithLabelComposite extends AbstractCdmFormElementComposite impl
text.addModifyListener(this);
- addControl(label);
addControl(text);
+
}
+ @Override
+ protected void checkSubclass() {
+ // Disable the check that prevents subclassing of SWT components
+ }
/**
* Get the text of this composites text composite
@@ -172,15 +168,6 @@ public class TextWithLabelComposite extends AbstractCdmFormElementComposite impl
text.setBackground(color);
}
- /** {@inheritDoc} */
- @Override
- public void setBackground(Color color) {
- super.setBackground(color);
- if (label != null) {
- label.setBackground(color);
- }
- }
-
@Override
public void setSelected(boolean selected) {
setBackground(selected ? SELECTED : getPersistentBackground());
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/AbstractCdmDetailElementComposite.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/AbstractCdmDetailElementComposite.java
index de28154cf..cc73e6080 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/AbstractCdmDetailElementComposite.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/AbstractCdmDetailElementComposite.java
@@ -15,6 +15,7 @@ import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.wb.swt.SWTResourceManager;
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
@@ -53,6 +54,7 @@ public abstract class AbstractCdmDetailElementComposite@@ -56,48 +56,86 @@ public class GatheringEventDetailElementComposite extends AbstractCdmDetailEleme */ public GatheringEventDetailElementComposite(Composite parent, FormToolkit formFactory, ICdmFormElement parentFormElement, int style) { super(parent, formFactory, parentFormElement, style); - TableWrapLayout tableWrapLayout = (TableWrapLayout) getLayout(); - tableWrapLayout.numColumns = 1; - - absoluteElevationError = CdmFormFactory.createNumberWithLabelElementComposite(this, getFormFactory(), this, "Elevation Error", new Float(0), SWT.NONE); - TableWrapData twd_absoluteElevationError = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1); - twd_absoluteElevationError.grabHorizontal = true; - absoluteElevationError.setLayoutData(twd_absoluteElevationError); - getFormFactory().adapt(absoluteElevationError); - getFormFactory().paintBordersFor(absoluteElevationError); - - number_absoluteElevationMinimum = CdmFormFactory.createNumberWithLabelElementComposite(this, getFormFactory(), this, "Elevation Minimum (m)", new Float(0), SWT.NONE); - TableWrapData twd_number_absoluteElevationMinimum = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1); - twd_number_absoluteElevationMinimum.grabHorizontal = true; - number_absoluteElevationMinimum.setLayoutData(twd_number_absoluteElevationMinimum); + + Label lblNewLabel_4 = new Label(this, SWT.NONE); + formFactory.adapt(lblNewLabel_4, true, true); + lblNewLabel_4.setText("Elevation Error"); + + absoluteElevationError = CdmElementFactory.createCdmNumberField(this, formFactory, this, (Integer) null, 0); + ((TableWrapData) absoluteElevationError.getMainControl().getLayoutData()).grabVertical = false; + TableWrapData twd_cdmNumberField = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1); + twd_cdmNumberField.grabHorizontal = true; + absoluteElevationError.setLayoutData(twd_cdmNumberField); + formFactory.adapt(absoluteElevationError); + formFactory.paintBordersFor(absoluteElevationError); + + Label lblNewLabel_3 = new Label(this, SWT.NONE); + formFactory.adapt(lblNewLabel_3, true, true); + lblNewLabel_3.setText("Elevation Error Minumum (m)"); + + number_absoluteElevationMinimum = CdmElementFactory.createCdmNumberField(this, formFactory, this, (Integer) null, 0); + TableWrapData tableWrapData = (TableWrapData) number_absoluteElevationMinimum.getMainControl().getLayoutData(); + tableWrapData.valign = TableWrapData.TOP; + tableWrapData.grabVertical = false; + TableWrapData twd_cdmNumberField_1 = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1); + twd_cdmNumberField_1.grabHorizontal = true; + number_absoluteElevationMinimum.setLayoutData(twd_cdmNumberField_1); formFactory.paintBordersFor(number_absoluteElevationMinimum); - number_absoluteElevationMaximum = CdmFormFactory.createNumberWithLabelElementComposite(this, getFormFactory(), parentFormElement, "Elevation Maximum (m)", new Float(0), SWT.NONE); - TableWrapData twd_numberWithLabelElementComposite = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1); - twd_numberWithLabelElementComposite.grabVertical = true; - twd_numberWithLabelElementComposite.grabHorizontal = true; - number_absoluteElevationMaximum.setLayoutData(twd_numberWithLabelElementComposite); - formFactory.paintBordersFor(number_absoluteElevationMaximum); + Label lblNewLabel_2 = new Label(this, SWT.NONE); + formFactory.adapt(lblNewLabel_2, true, true); + lblNewLabel_2.setText("Elevation Maximum (m)"); - collectingMethod = CdmFormFactory.createTextWithLabelComposite(this, getFormFactory(), this, "Collecting Method", "", (Integer) null, SWT.NONE); - TableWrapData twd_collectingMethod = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1); - twd_collectingMethod.grabHorizontal = true; - collectingMethod.setLayoutData(twd_collectingMethod); - getFormFactory().adapt(collectingMethod); - getFormFactory().paintBordersFor(collectingMethod); + number_absoluteElevationMaximum = CdmElementFactory.createCdmNumberField(this, formFactory, this, (Integer) null, 0); + TableWrapData twd_cdmNumberField_2 = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1); + twd_cdmNumberField_2.grabHorizontal = true; + number_absoluteElevationMaximum.setLayoutData(twd_cdmNumberField_2); + formFactory.adapt(number_absoluteElevationMaximum); + formFactory.paintBordersFor(number_absoluteElevationMaximum); - number_distanceToGround = CdmFormFactory.createNumberWithLabelElementComposite(this, getFormFactory(), parentFormElement, "Distance To Ground (m)", new Float(0), SWT.NONE); + Label lblTestLabel = new Label(this, SWT.NONE); + formFactory.adapt(lblTestLabel, true, true); + lblTestLabel.setText("Collecting Method"); + + collectingMethod = CdmElementFactory.createCdmTextField(this, formFactory, this, (String) null, (Integer) null, 0); + TableWrapData twd_cdmTextField_1 = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1); + twd_cdmTextField_1.grabHorizontal = true; + collectingMethod.setLayoutData(twd_cdmTextField_1); + formFactory.adapt(collectingMethod); + formFactory.paintBordersFor(collectingMethod); + + Label lblNewLabel_5 = new Label(this, SWT.NONE); + formFactory.adapt(lblNewLabel_5, true, true); + lblNewLabel_5.setText("Distance To Ground (m)"); + + number_distanceToGround = CdmElementFactory.createCdmNumberField(this, formFactory, this, (Integer) null, 0); + TableWrapData twd_cdmNumberField_3 = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1); + twd_cdmNumberField_3.grabHorizontal = true; + number_distanceToGround.setLayoutData(twd_cdmNumberField_3); + formFactory.adapt(number_distanceToGround); formFactory.paintBordersFor(number_distanceToGround); - number_distanceToWaterSurface = CdmFormFactory.createNumberWithLabelElementComposite(this, getFormFactory(), parentFormElement, "Distance To Water Surface (m)", new Float(0), SWT.NONE); + Label lblNewLabel_6 = new Label(this, SWT.NONE); + formFactory.adapt(lblNewLabel_6, true, true); + lblNewLabel_6.setText("Distance To Water Surface"); + + number_distanceToWaterSurface = CdmElementFactory.createCdmNumberField(this, formFactory, this, (Integer) null, 0); + TableWrapData twd_cdmNumberField_4 = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1); + twd_cdmNumberField_4.grabHorizontal = true; + number_distanceToWaterSurface.setLayoutData(twd_cdmNumberField_4); + formFactory.adapt(number_distanceToWaterSurface); formFactory.paintBordersFor(number_distanceToWaterSurface); - gatheringEventDescription = CdmFormFactory.createTextWithLabelComposite(this, getFormFactory(), this, "Gathering Event Description", "", (Integer) null, SWT.NONE); - TableWrapData twd_gatheringEventDescription = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1); - twd_gatheringEventDescription.grabHorizontal = true; - gatheringEventDescription.setLayoutData(twd_gatheringEventDescription); - getFormFactory().adapt(gatheringEventDescription); - getFormFactory().paintBordersFor(gatheringEventDescription); + Label lblNewLabel = new Label(this, SWT.NONE); + formFactory.adapt(lblNewLabel, true, true); + lblNewLabel.setText("Gathering Event Description"); + + gatheringEventDescription = CdmElementFactory.createCdmTextField(this, formFactory, this, (String) null, (Integer) null, 0); + TableWrapData twd_cdmTextField_2 = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1); + twd_cdmTextField_2.grabHorizontal = true; + gatheringEventDescription.setLayoutData(twd_cdmTextField_2); + formFactory.adapt(gatheringEventDescription); + formFactory.paintBordersFor(gatheringEventDescription); } @@ -151,20 +189,14 @@ public class GatheringEventDetailElementComposite extends AbstractCdmDetailEleme number_absoluteElevationMaximum.setBackground(getColor(Resources.COLOR_PARSE_ERROR)); AbstractUtility.warn(getClass(), e.getLocalizedMessage()); } - } else if (eventSource == getCollectingMethod()) { - getEntity().setCollectingMethod(getCollectingMethod().getText()); + } else if (eventSource == collectingMethod) { + getEntity().setCollectingMethod(collectingMethod.getText()); } else if (eventSource == number_distanceToGround) { getEntity().setDistanceToGround(number_distanceToGround.getInteger()); } else if (eventSource == number_distanceToWaterSurface) { getEntity().setDistanceToWaterSurface(number_distanceToWaterSurface.getInteger()); - } else if (eventSource == getGatheringEventDescription()) { - getEntity().setGatheringEventDescription(getGatheringEventDescription().getText()); + } else if (eventSource == gatheringEventDescription) { + getEntity().setGatheringEventDescription(gatheringEventDescription.getText()); } } - public TextWithLabelComposite getGatheringEventDescription() { - return gatheringEventDescription; - } - public TextWithLabelComposite getCollectingMethod() { - return collectingMethod; - } }