import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.forms.widgets.FormToolkit;
/**
* @author pplitzner
- * @date 23.07.2013
+ * @date 01.08.2013
*
*/
-public class TextWithLabelComposite extends AbstractCdmFormElementComposite implements ModifyListener, IEnableableFormElement, ISelectable {
+public class CdmTextField extends AbstractCdmFormElementComposite implements ModifyListener, IEnableableFormElement, ISelectable{
protected Text text;
- private final Label label;
/** Constant <code>MAX_HEIGHT=0</code> */
public static final int MAX_HEIGHT = 0;
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));
}
//^^^^^^^^^^^^^^
- 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);
// 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);
}
}
});
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
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());
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.TableWrapData;
-import org.eclipse.ui.forms.widgets.TableWrapLayout;
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
import eu.etaxonomy.taxeditor.model.AbstractUtility;
import eu.etaxonomy.taxeditor.preference.Resources;
-import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
+import eu.etaxonomy.taxeditor.ui.element.CdmElementFactory;
+import eu.etaxonomy.taxeditor.ui.element.CdmNumberField;
+import eu.etaxonomy.taxeditor.ui.element.CdmTextField;
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
-import eu.etaxonomy.taxeditor.ui.element.NumberWithLabelElementComposite;
-import eu.etaxonomy.taxeditor.ui.element.TextWithLabelComposite;
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElementComposite;
/**
+ private final CdmNumberField absoluteElevationError;
+ private final CdmNumberField number_absoluteElevationMinimum;
+ private final CdmNumberField number_absoluteElevationMaximum;
+ private final CdmTextField collectingMethod;
+ private final CdmNumberField number_distanceToGround;
+ private final CdmNumberField number_distanceToWaterSurface;
+ private final CdmTextField gatheringEventDescription;
// private CollectingAreasDetailSection section_collectingAreas;
- private final NumberWithLabelElementComposite absoluteElevationError;
- private final NumberWithLabelElementComposite number_absoluteElevationMinimum;
- private final NumberWithLabelElementComposite number_absoluteElevationMaximum;
- private final TextWithLabelComposite collectingMethod;
- private final NumberWithLabelElementComposite number_distanceToGround;
- private final NumberWithLabelElementComposite number_distanceToWaterSurface;
- private final TextWithLabelComposite gatheringEventDescription;
/**
* <p>
*/
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);
}
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;
- }
}