// $Id$
/**
* Copyright (C) 2007 EDIT
- * European Distributed Institute of Taxonomy
+ * European Distributed Institute of Taxonomy
* http://www.e-taxonomy.eu
- *
+ *
* The contents of this file are subject to the Mozilla Public License Version 1.1
* See LICENSE.TXT at the top of this package for the full license terms.
*/
* <p>
* DateDetailSection class.
* </p>
- *
+ *
* @author n.hoffmann
* @created Mar 31, 2010
* @version 1.0
* <p>
* Constructor for DateDetailSection.
* </p>
- *
+ *
* @param formFactory
* a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
* object.
super(formFactory, parentElement, style);
partialElement_start = formFactory.createPartialElement(this,
- "Start: ", null, style);
- partialElement_end = formFactory.createPartialElement(this, "End: ",
+ "Start ", null, style);
+ partialElement_end = formFactory.createPartialElement(this, "End ",
null, style);
text_parseText = formFactory.createTextWithLabelElement(this, "Parse",
}
return super.getEntity();
}
-
+
/**
* <p>
* Setter for the field <code>timePeriod</code>.
* </p>
- *
+ *
* @param timePeriod
* a {@link eu.etaxonomy.cdm.model.common.TimePeriod} object.
*/
updateTitle();
text_parseText.setText(timePeriod.toString());
}
-
+
/**
* When setting the entity through parsing we do not want to alter the parse field
* @param timePeriod
} else if (eventSource == text_parseText) {
cursorPosition = ((Text) text_parseText.getMainControl())
.getCaretPosition();
- setEntityInternally(TimePeriodParser.parseString(text_parseText.getText()));
+ setEntityInternally(TimePeriodParser.parseString(text_parseText.getText()));
} else if (eventSource == text_freeText) {
getEntity().setFreeText(text_freeText.getText());
}
this.setText(title);
layout();
}
-
+
/*
* (non-Javadoc)
- *
+ *
* @see eu.etaxonomy.taxeditor.forms.AbstractFormSection#dispose()
*/
/** {@inheritDoc} */
// $Id$
/**
* Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy
+* European Distributed Institute of Taxonomy
* http://www.e-taxonomy.eu
-*
+*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* See LICENSE.TXT at the top of this package for the full license terms.
*/
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.forms.widgets.TableWrapLayout;
import org.joda.time.Partial;
import eu.etaxonomy.cdm.model.common.TimePeriod;
private NumberWithLabelElement number_month;
private NumberWithLabelElement number_year;
private Partial partial;
-
+
/**
* <p>Constructor for PartialElement.</p>
*
public PartialElement(CdmFormFactory formFactory,
ICdmFormElement formElement, String labelString, int style) {
super(formFactory, formElement);
-
- formElement.getLayoutComposite().setLayout(LayoutConstants.LAYOUT(7, false));
-
+
+ TableWrapLayout layout = LayoutConstants.LAYOUT(7, false);
+ layout.horizontalSpacing = 5;
+ formElement.getLayoutComposite().setLayout(layout);
+
label = formFactory.createLabel(getLayoutComposite(), labelString);
addControl(label);
-
+
number_year = formFactory.createNumberTextWithLabelElement(this, "Year", null, style);
number_year.setLimits(4, -9999, 9999);
-
- number_month = formFactory.createNumberTextWithLabelElement(this, "Month", null, style);
+
+ number_month = formFactory.createNumberTextWithLabelElement(this, "Month", null, style);
number_month.setLimits(2, 1, 12);
-
+
number_day = formFactory.createNumberTextWithLabelElement(this, "Day", null, style);
number_day.setLimits(2, 1, 31);
-
-
- formFactory.addPropertyChangeListener(this);
+
+
+ formFactory.addPropertyChangeListener(this);
}
-
+
/**
* <p>Setter for the field <code>partial</code>.</p>
*
*/
public void setPartial(Partial partial){
this.partial = partial;
-
+
if(partial != null){
number_day.setNumber(TimePeriod.getPartialValue(partial, TimePeriod.DAY_TYPE));
number_month.setNumber(TimePeriod.getPartialValue(partial, TimePeriod.MONTH_TYPE));
if(event == null){
return;
}
-
+
Object eventSource = event.getSource();
-
+
if(getElements().contains(eventSource)){
if(event instanceof CdmPropertyChangeEvent){
if(((CdmPropertyChangeEvent) event).hasException()){
}
}
handleEvent(eventSource);
- }
+ }
}
-
+
/**
* @param event
*/
} else{
partial = TimePeriod.setPartialField(partial, number_month.getInteger(), TimePeriod.MONTH_TYPE);
}
-
+
}else if(eventSource == number_day){
if (number_day.getInteger() == 0){
partial = TimePeriod.setPartialField(partial, null, TimePeriod.DAY_TYPE);
} else{
partial = TimePeriod.setPartialField(partial, number_day.getInteger(), TimePeriod.DAY_TYPE);
}
-
-
+
+
}else if(eventSource == number_year){
if (number_year.getInteger() == 0){
partial = TimePeriod.setPartialField(partial, null, TimePeriod.YEAR_TYPE);
} else{
partial = TimePeriod.setPartialField(partial, number_year.getInteger(), TimePeriod.YEAR_TYPE);
}
-
+
}
firePropertyChangeEvent(new CdmPropertyChangeEvent(this, null));
}
-
+
/** {@inheritDoc} */
@Override
public void setBackground(Color color) {