diff options
24 files changed, 1058 insertions, 695 deletions
diff --git a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/cell/Cell.java b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/cell/Cell.java index b7bc815e65..155b66540a 100644 --- a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/cell/Cell.java +++ b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/cell/Cell.java @@ -293,6 +293,7 @@ public class Cell implements ICell { } } + @Override public IProcessingStatus getErrorStatus() { return m_errorStatus; } diff --git a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/cell/ICell.java b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/cell/ICell.java index 3a1c6bd335..fde7328af5 100644 --- a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/cell/ICell.java +++ b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/cell/ICell.java @@ -10,6 +10,7 @@ ******************************************************************************/ package org.eclipse.scout.rt.client.ui.basic.cell; +import org.eclipse.scout.commons.exception.IProcessingStatus; import org.eclipse.scout.rt.client.ClientJob; import org.eclipse.scout.rt.client.ui.basic.table.ITable; import org.eclipse.scout.rt.shared.data.basic.FontSpec; @@ -55,4 +56,6 @@ public interface ICell { ICellObserver getObserver(); + IProcessingStatus getErrorStatus(); + } diff --git a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/AbstractTable.java b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/AbstractTable.java index ae28d3050e..3948510f70 100644 --- a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/AbstractTable.java +++ b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/AbstractTable.java @@ -130,6 +130,7 @@ public abstract class AbstractTable extends AbstractPropertyObserver implements private final EventListenerList m_listenerList = new EventListenerList(); //cell editing private P_CellEditorContext m_editContext; + private HashMap<ITableRow, Boolean> m_rowValidty; //checkable table private IBooleanColumn m_checkableColumn; //auto filter @@ -149,6 +150,7 @@ public abstract class AbstractTable extends AbstractPropertyObserver implements if (DesktopProfiler.getInstance().isEnabled()) { DesktopProfiler.getInstance().registerTable(this); } + m_rowValidty = new HashMap<ITableRow, Boolean>(); m_cachedRowsLock = new Object(); m_cachedFilteredRowsLock = new Object(); m_rows = Collections.synchronizedList(new ArrayList<ITableRow>(1)); @@ -2561,6 +2563,12 @@ public abstract class AbstractTable extends AbstractPropertyObserver implements } private ITableRow addRowImpl(ITableRow newRow, boolean markAsInserted) throws ProcessingException { + + for (IColumn<?> col : getColumns()) { + if (col instanceof AbstractColumn<?>) { + ((AbstractColumn<?>) col).validateColumnValue(newRow, null); + } + } if (markAsInserted) { newRow.setStatus(ITableRow.STATUS_INSERTED); } @@ -3565,6 +3573,20 @@ public abstract class AbstractTable extends AbstractPropertyObserver implements } } + public boolean wasEverValid(ITableRow row) { + Boolean res = BooleanUtility.nvl(m_rowValidty.get(row)); + if (!res) { + for (IColumn<?> col : getColumns()) { + if (row.getCell(col).getErrorStatus() != null) { + return res; + } + } + res = true; + m_rowValidty.put(row, res); + } + return res; + } + protected void decorateCellInternal(Cell view, ITableRow row, IColumn<?> col) { } @@ -3928,6 +3950,9 @@ public abstract class AbstractTable extends AbstractPropertyObserver implements m_tableEventBuffer.add(e); } else { + //Ensure all editor values have been applied. +// getUIFacade().completeCellEditFromUI(); + EventListener[] listeners = m_listenerList.getListeners(TableListener.class); if (listeners != null && listeners.length > 0) { for (int i = 0; i < listeners.length; i++) { diff --git a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/AbstractBigDecimalColumn.java b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/AbstractBigDecimalColumn.java index a710c944e5..4a147ac0a4 100644 --- a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/AbstractBigDecimalColumn.java +++ b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/AbstractBigDecimalColumn.java @@ -18,9 +18,6 @@ import java.text.DecimalFormat; import java.text.NumberFormat; import org.eclipse.scout.commons.LocaleThreadLocal; -import org.eclipse.scout.commons.annotations.ConfigProperty; -import org.eclipse.scout.commons.annotations.ConfigPropertyValue; -import org.eclipse.scout.commons.annotations.Order; import org.eclipse.scout.commons.exception.ProcessingException; import org.eclipse.scout.rt.client.ui.basic.cell.Cell; import org.eclipse.scout.rt.client.ui.basic.table.ITableRow; @@ -30,217 +27,12 @@ import org.eclipse.scout.rt.client.ui.form.fields.bigdecimalfield.AbstractBigDec /** * Column holding Double */ -public abstract class AbstractBigDecimalColumn extends AbstractColumn<BigDecimal> implements IBigDecimalColumn { - // DO NOT init members, this has the same effect as if they were set AFTER - // initConfig() - private String m_format; - private boolean m_groupingUsed; - private int m_maxFractionDigits; - private int m_minFractionDigits; - private boolean m_percent; - private int m_multiplier; - private NumberFormat m_fmt; +public abstract class AbstractBigDecimalColumn extends AbstractDecimalColumn<BigDecimal> implements IBigDecimalColumn { public AbstractBigDecimalColumn() { super(); } - /* - * Configuration - */ - - /** - * Configures the format used to render the value. See {@link DecimalFormat#applyPattern(String)} for more information - * about the expected format. - * <p> - * This property has higher priority than {@link #getConfiguredMaxFractionDigits()}, - * {@link #getConfiguredMinFractionDigits()} and {@link #getConfiguredGroupingUsed()}. Hence, if a format is - * specified, these properties will be ignored. - * <p> - * Subclasses can override this method. Default is {@code null}. - * - * @return Format of this column. - */ - @ConfigProperty(ConfigProperty.STRING) - @Order(140) - @ConfigPropertyValue("null") - protected String getConfiguredFormat() { - return null; - } - - /** - * Configures the minimum number of fraction digits used to display the value. To use an exact number of fraction - * digits, the same number as for {@link #getConfiguredMaxFractionDigits()} must be returned. - * <p> - * This property only has an effect if no format is specified by {@link #getConfiguredFormat()}. - * <p> - * Subclasses can override this method. Default is {@code 2}. - * - * @return Minimum number of fraction digits of this column. - */ - @ConfigProperty(ConfigProperty.INTEGER) - @Order(150) - @ConfigPropertyValue("2") - protected int getConfiguredMinFractionDigits() { - return 2; - } - - /** - * Configures the maximum number of fraction digits used to display the value. To use an exact number of fraction - * digits, the same number as for {@link #getConfiguredMinFractionDigits()} must be returned. - * <p> - * This property only has an effect if no format is specified by {@link #getConfiguredFormat()}. - * <p> - * Subclasses can override this method. Default is {@code 2}. - * - * @return maximum number of fraction digits of this column. - */ - @ConfigProperty(ConfigProperty.INTEGER) - @Order(160) - @ConfigPropertyValue("2") - protected int getConfiguredMaxFractionDigits() { - return 2; - } - - /** - * Configures whether grouping is used for this column. If grouping is used, the values may be displayed with a digit - * group separator. - * <p> - * This property only has an effect if no format is specified by {@link #getConfiguredFormat()}. - * <p> - * Subclasses can override this method. Default is {@code true}. - * - * @return {@code true} if grouping is used for this column, {@code false} otherwise. - */ - @ConfigProperty(ConfigProperty.BOOLEAN) - @Order(170) - @ConfigPropertyValue("true") - protected boolean getConfiguredGroupingUsed() { - return true; - } - - /** - * Configures whether the value is a percentage and is displayed with the appropriate sign. A value of 12 is displayed - * as 12 % (depending on the locale). Use {@link #getConfiguredMultiplier()} to handle the value differently (e.g. - * display a value of 0.12 as 12 %). - * <p> - * Subclasses can override this method. Default is {@code false}. - * - * @return {@code true} if the column represents a percentage value, {@code false} otherwise. - */ - @ConfigProperty(ConfigProperty.BOOLEAN) - @Order(180) - @ConfigPropertyValue("false") - protected boolean getConfiguredPercent() { - return false; - } - - /** - * Configures the multiplier used to display the value. See {@link DecimalFormat#setMultiplier(int)} for more - * information about multipliers. - * <p> - * Subclasses can override this method. Default is {@code 1}. - * - * @return The multiplier used to display the value. - */ - @ConfigProperty(ConfigProperty.INTEGER) - @Order(190) - @ConfigPropertyValue("1") - protected int getConfiguredMultiplier() { - return 1; - } - - @Override - protected int getConfiguredHorizontalAlignment() { - return 1; - } - - @Override - protected void initConfig() { - super.initConfig(); - setFormat(getConfiguredFormat()); - setMinFractionDigits(getConfiguredMinFractionDigits()); - setMaxFractionDigits(getConfiguredMaxFractionDigits()); - setGroupingUsed(getConfiguredGroupingUsed()); - setPercent(getConfiguredPercent()); - setMultiplier(getConfiguredMultiplier()); - } - - /* - * Runtime - */ - @Override - public void setFormat(String s) { - m_format = s; - m_fmt = null; - } - - @Override - public String getFormat() { - return m_format; - } - - @Override - public void setMinFractionDigits(int i) { - if (i > getMaxFractionDigits()) { - m_maxFractionDigits = i; - } - m_minFractionDigits = i; - m_fmt = null; - } - - @Override - public int getMinFractionDigits() { - return m_minFractionDigits; - } - - @Override - public void setMaxFractionDigits(int i) { - if (i < getMinFractionDigits()) { - m_minFractionDigits = i; - } - m_maxFractionDigits = i; - m_fmt = null; - } - - @Override - public int getMaxFractionDigits() { - return m_maxFractionDigits; - } - - @Override - public void setGroupingUsed(boolean b) { - m_groupingUsed = b; - m_fmt = null; - } - - @Override - public boolean isGroupingUsed() { - return m_groupingUsed; - } - - @Override - public void setPercent(boolean b) { - m_percent = b; - m_fmt = null; - } - - @Override - public boolean isPercent() { - return m_percent; - } - - @Override - public void setMultiplier(int i) { - m_multiplier = i; - m_fmt = null; - } - - @Override - public int getMultiplier() { - return m_multiplier; - } - @Override protected BigDecimal parseValueInternal(ITableRow row, Object rawValue) throws ProcessingException { BigDecimal validValue = null; @@ -264,16 +56,18 @@ public abstract class AbstractBigDecimalColumn extends AbstractColumn<BigDecimal @Override protected IFormField prepareEditInternal(ITableRow row) throws ProcessingException { - AbstractBigDecimalField f = new AbstractBigDecimalField() { + return super.prepareEditInternal(row); + } + + @Override + protected AbstractBigDecimalField getEditorField() { + return new AbstractBigDecimalField() { + @Override + protected void initConfig() { + super.initConfig(); + propertySupport.putPropertiesMap(AbstractBigDecimalColumn.this.propertySupport.getPropertiesMap()); + } }; - f.setFormat(getFormat()); - f.setMaxFractionDigits(getMaxFractionDigits()); - f.setMinFractionDigits(getMinFractionDigits()); - f.setFractionDigits(getNumberFormat().getMaximumFractionDigits()); - f.setMultiplier(getMultiplier()); - f.setGroupingUsed(isGroupingUsed()); - f.setPercent(isPercent()); - return f; } @Override @@ -289,31 +83,33 @@ public abstract class AbstractBigDecimalColumn extends AbstractColumn<BigDecimal @Override public NumberFormat getNumberFormat() { - if (m_fmt == null) { + if (super.getNumberFormat() == null) { + NumberFormat fmt; if (isPercent()) { - m_fmt = NumberFormat.getPercentInstance(LocaleThreadLocal.get()); + fmt = NumberFormat.getPercentInstance(LocaleThreadLocal.get()); } else { - m_fmt = NumberFormat.getNumberInstance(LocaleThreadLocal.get()); + fmt = NumberFormat.getNumberInstance(LocaleThreadLocal.get()); } - if (m_fmt instanceof DecimalFormat) { - ((DecimalFormat) m_fmt).setMultiplier(getMultiplier()); + if (fmt instanceof DecimalFormat) { + ((DecimalFormat) fmt).setMultiplier(getMultiplier()); if (getFormat() != null) { - ((DecimalFormat) m_fmt).applyPattern(getFormat()); + ((DecimalFormat) fmt).applyPattern(getFormat()); } else { - m_fmt.setMinimumFractionDigits(getMinFractionDigits()); - m_fmt.setMaximumFractionDigits(getMaxFractionDigits()); - m_fmt.setGroupingUsed(isGroupingUsed()); + fmt.setMinimumFractionDigits(getMinFractionDigits()); + fmt.setMaximumFractionDigits(getMaxFractionDigits()); + fmt.setGroupingUsed(isGroupingUsed()); } } else { - m_fmt.setMinimumFractionDigits(getMinFractionDigits()); - m_fmt.setMaximumFractionDigits(getMaxFractionDigits()); - m_fmt.setGroupingUsed(isGroupingUsed()); + fmt.setMinimumFractionDigits(getMinFractionDigits()); + fmt.setMaximumFractionDigits(getMaxFractionDigits()); + fmt.setGroupingUsed(isGroupingUsed()); } + setNumberFormat(fmt); } - return m_fmt; + return super.getNumberFormat(); } } diff --git a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/AbstractBooleanColumn.java b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/AbstractBooleanColumn.java index c38dad6985..48f8412e92 100644 --- a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/AbstractBooleanColumn.java +++ b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/AbstractBooleanColumn.java @@ -70,6 +70,11 @@ public abstract class AbstractBooleanColumn extends AbstractColumn<Boolean> impl @Override protected IFormField prepareEditInternal(final ITableRow row) throws ProcessingException { AbstractBooleanField f = new AbstractBooleanField() { + @Override + protected void initConfig() { + super.initConfig(); + propertySupport.putPropertiesMap(AbstractBooleanColumn.this.propertySupport.getPropertiesMap()); + } }; return f; } @@ -77,8 +82,7 @@ public abstract class AbstractBooleanColumn extends AbstractColumn<Boolean> impl /** * Configures the horizontal alignment of text inside this column (including header text). * <p> - * Subclasses can override this method. For boolean columns, the default is {@code 0} (center - * alignment). + * Subclasses can override this method. For boolean columns, the default is {@code 0} (center alignment). * * @return {@code -1} for left, {@code 0} for center and {@code 1} for right alignment. */ diff --git a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/AbstractColumn.java b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/AbstractColumn.java index 0b3e90149d..d5b9aab345 100644 --- a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/AbstractColumn.java +++ b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/AbstractColumn.java @@ -16,7 +16,9 @@ import java.lang.reflect.Array; import java.security.Permission; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashMap; import java.util.HashSet; +import java.util.Map; import org.eclipse.scout.commons.CompareUtility; import org.eclipse.scout.commons.StringUtility; @@ -27,6 +29,7 @@ import org.eclipse.scout.commons.annotations.ConfigPropertyValue; import org.eclipse.scout.commons.annotations.Order; import org.eclipse.scout.commons.annotations.Replace; import org.eclipse.scout.commons.beans.AbstractPropertyObserver; +import org.eclipse.scout.commons.exception.IProcessingStatus; import org.eclipse.scout.commons.exception.ProcessingException; import org.eclipse.scout.commons.logger.IScoutLogger; import org.eclipse.scout.commons.logger.ScoutLogManager; @@ -45,7 +48,9 @@ import org.eclipse.scout.rt.client.ui.form.fields.AbstractValueField; import org.eclipse.scout.rt.client.ui.form.fields.GridData; import org.eclipse.scout.rt.client.ui.form.fields.IFormField; import org.eclipse.scout.rt.client.ui.form.fields.IValueField; +import org.eclipse.scout.rt.client.ui.form.fields.ParsingFailedStatus; import org.eclipse.scout.rt.client.ui.form.fields.tablefield.AbstractTableField; +import org.eclipse.scout.rt.shared.ScoutTexts; import org.eclipse.scout.rt.shared.data.basic.FontSpec; import org.eclipse.scout.rt.shared.data.form.AbstractFormData; import org.eclipse.scout.rt.shared.services.common.security.IAccessControlService; @@ -72,6 +77,10 @@ public abstract class AbstractColumn<T> extends AbstractPropertyObserver impleme private boolean m_initialSortAscending; private boolean m_initialAlwaysIncludeSortAtBegin; private boolean m_initialAlwaysIncludeSortAtEnd; + /** + * Used for mutable tables to keep last valid value per row and column. + */ + private Map<ITableRow, T> m_validatedValues; public AbstractColumn() { m_headerCell = new HeaderCell(); @@ -88,6 +97,16 @@ public abstract class AbstractColumn<T> extends AbstractPropertyObserver impleme } } }); + + clearValidatedValues(); + } + + public final void clearValidatedValues() { + m_validatedValues = new HashMap<ITableRow, T>(); + } + + protected Map<String, Object> getPropertiesMap() { + return propertySupport.getPropertiesMap(); } /* @@ -594,9 +613,6 @@ public abstract class AbstractColumn<T> extends AbstractPropertyObserver impleme IFormField f = prepareEditInternal(row); if (f != null) { f.setLabelVisible(false); - if (getConfiguredMandatory()) { - f.setMandatory(true); - } GridData gd = f.getGridDataHints(); // apply horizontal alignment of column to respective editor field gd.horizontalAlignment = getHorizontalAlignment(); @@ -626,8 +642,14 @@ public abstract class AbstractColumn<T> extends AbstractPropertyObserver impleme protected void execCompleteEdit(ITableRow row, IFormField editingField) throws ProcessingException { if (editingField instanceof IValueField) { IValueField v = (IValueField) editingField; - if (v.isSaveNeeded()) { - applyValueInternal(row, parseValue(row, ((IValueField) editingField).getValue())); + if (v.isSaveNeeded() || editingField.getErrorStatus() != null || row.getCell(this).getErrorStatus() != null) { + T parsedValue = parseValue(row, v.getValue()); + applyValueInternal(row, parsedValue); + validateColumnValue(row, editingField); + if (editingField.isContentValid()) { + m_validatedValues.put(row, parsedValue); + } + persistRowChange(row); } } } @@ -735,6 +757,17 @@ public abstract class AbstractColumn<T> extends AbstractPropertyObserver impleme } @Override + public void setMandatory(boolean mandatory) { + propertySupport.setPropertyBool(IFormField.PROP_MANDATORY, mandatory); + validateColumnValues(); + } + + @Override + public boolean isMandatory() { + return propertySupport.getPropertyBool(IFormField.PROP_MANDATORY); + } + + @Override public boolean isInitialVisible() { return m_initialVisible; } @@ -842,8 +875,17 @@ public abstract class AbstractColumn<T> extends AbstractPropertyObserver impleme } @Override - @SuppressWarnings("unchecked") public T getValue(ITableRow r) { + T validatedValue = m_validatedValues.get(r); + if (validatedValue == null) { + validatedValue = getValueInternal(r); + } + m_validatedValues.put(r, validatedValue); + return validatedValue; + } + + @SuppressWarnings("unchecked") + protected T getValueInternal(ITableRow r) { return (r != null) ? (T) r.getCellValue(getColumnIndex()) : null; } @@ -1180,8 +1222,9 @@ public abstract class AbstractColumn<T> extends AbstractPropertyObserver impleme protected IFormField prepareEditInternal(ITableRow row) throws ProcessingException { AbstractValueField<T> f = new AbstractValueField<T>() { @Override - public Class<T> getHolderType() { - return AbstractColumn.this.getDataType(); + protected void initConfig() { + super.initConfig(); + propertySupport.putPropertiesMap(AbstractColumn.this.propertySupport.getPropertiesMap()); } }; return f; @@ -1205,7 +1248,9 @@ public abstract class AbstractColumn<T> extends AbstractPropertyObserver impleme @Override public void decorateCell(ITableRow row) { Cell cell = row.getCellForUpdate(getColumnIndex()); - decorateCellInternal(cell, row); + if (cell.getErrorStatus() == null) { + decorateCellInternal(cell, row); + } try { execDecorateCell(cell, row); } @@ -1445,4 +1490,72 @@ public abstract class AbstractColumn<T> extends AbstractPropertyObserver impleme return getClass().getSimpleName() + "[" + getHeaderCell().getText() + " width=" + getWidth() + (isPrimaryKey() ? " primaryKey" : "") + (isSummary() ? " summary" : "") + " viewIndexHint=" + getVisibleColumnIndexHint() + "]"; } + /** + * Called when a value has been changed in an editable cell. + * Can be used to persist data directly after a value has been modified in a cell editor. + * CAUTION: This method is called even when an invalid value has been entered in the cell editor. + * In this case the last valid value is retrieved while {@link #getValue(ITableRow)} is called. + * @param row The row changed in the table. + * + * @throws ProcessingException + */ + protected void persistRowChange(ITableRow row) throws ProcessingException { + } + + public void validateColumnValues() { + if (getTable() == null) { + return; + } + for (ITableRow row : getTable().getRows()) { + validateColumnValue(row, null); + } + } + + public void validateColumnValue(ITableRow row, IFormField editor) { + if (row == null) { + LOG.error("validateColumnValue called with row=null"); + return; + } + if (isCellEditable(row)) { + try { + if (editor == null) { + editor = prepareEdit(row); + } + if (editor != null) { + IProcessingStatus errorStatus = editor.getErrorStatus(); + boolean editorValid = editor.isContentValid() && errorStatus == null; + Cell cell = row.getCellForUpdate(this); + if (!editorValid) { + if (isDisplayable() && !isVisible()) { + //column should become visible + setVisible(true); + } + if (errorStatus != null) { + cell.setErrorStatus(errorStatus); + if (errorStatus instanceof ParsingFailedStatus) { + cell.setText(((ParsingFailedStatus) errorStatus).getParseInputString()); + } + + } + else { + cell.setErrorStatus(ScoutTexts.get("FormEmptyMandatoryFieldsMessage")); + } + } + else { + cell.clearErrorStatus(); + decorateCellInternal(cell, row); + ITable table = getTable(); + if (table instanceof AbstractTable) { + ((AbstractTable) table).wasEverValid(row); + } + } + } + } + catch (Throwable t) { + LOG.error("validating " + getTable().getClass().getSimpleName() + " for new row for column " + getClass().getSimpleName(), t); + } + } + + } + } diff --git a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/AbstractDateColumn.java b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/AbstractDateColumn.java index 7d02f40643..7d1bd511e1 100644 --- a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/AbstractDateColumn.java +++ b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/AbstractDateColumn.java @@ -35,6 +35,7 @@ public abstract class AbstractDateColumn extends AbstractColumn<Date> implements private boolean m_hasTime; private boolean m_hasDate; private DateFormat m_fmt; + private long m_autoTimeMillis; public AbstractDateColumn() { super(); @@ -89,12 +90,23 @@ public abstract class AbstractDateColumn extends AbstractColumn<Date> implements return false; } + /** + * When a date without time is picked, this time value is used as hh/mm/ss. + */ + @ConfigProperty(ConfigProperty.LONG) + @Order(152) + @ConfigPropertyValue("0") + protected long getConfiguredAutoTimeMillis() { + return 0; + } + @Override protected void initConfig() { super.initConfig(); setFormat(getConfiguredFormat()); setHasDate(getConfiguredHasDate()); setHasTime(getConfiguredHasTime()); + setAutoTimeMillis(getConfiguredAutoTimeMillis()); } /* @@ -104,6 +116,7 @@ public abstract class AbstractDateColumn extends AbstractColumn<Date> implements public void setFormat(String s) { m_format = s; m_fmt = null; + validateColumnValues(); } @Override @@ -115,12 +128,14 @@ public abstract class AbstractDateColumn extends AbstractColumn<Date> implements public void setHasDate(boolean b) { m_hasDate = b; m_fmt = null; + validateColumnValues(); } @Override public void setHasTime(boolean b) { m_hasTime = b; m_fmt = null; + validateColumnValues(); } @Override @@ -134,6 +149,21 @@ public abstract class AbstractDateColumn extends AbstractColumn<Date> implements } @Override + public void setAutoTimeMillis(long l) { + m_autoTimeMillis = l; + } + + @Override + public void setAutoTimeMillis(int hour, int minute, int second) { + setAutoTimeMillis(((hour * 60L + minute) * 60L + second) * 1000L); + } + + @Override + public long getAutoTimeMillis() { + return m_autoTimeMillis; + } + + @Override protected Date parseValueInternal(ITableRow row, Object rawValue) throws ProcessingException { //legacy support if (rawValue instanceof Number) { @@ -172,10 +202,16 @@ public abstract class AbstractDateColumn extends AbstractColumn<Date> implements @Override protected IFormField prepareEditInternal(ITableRow row) throws ProcessingException { AbstractDateField f = new AbstractDateField() { + @Override + protected void initConfig() { + super.initConfig(); + propertySupport.putPropertiesMap(AbstractDateColumn.this.propertySupport.getPropertiesMap()); + } }; f.setFormat(getFormat()); f.setHasDate(isHasDate()); f.setHasTime(isHasTime()); + f.setAutoTimeMillis(getAutoTimeMillis()); return f; } diff --git a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/AbstractDecimalColumn.java b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/AbstractDecimalColumn.java new file mode 100644 index 0000000000..15fb8ab451 --- /dev/null +++ b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/AbstractDecimalColumn.java @@ -0,0 +1,302 @@ +/******************************************************************************* + * Copyright (c) 2010 BSI Business Systems Integration AG. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * BSI Business Systems Integration AG - initial API and implementation + ******************************************************************************/ +package org.eclipse.scout.rt.client.ui.basic.table.columns; + +import java.text.DecimalFormat; +import java.text.NumberFormat; + +import org.eclipse.scout.commons.annotations.ConfigProperty; +import org.eclipse.scout.commons.annotations.ConfigPropertyValue; +import org.eclipse.scout.commons.annotations.Order; +import org.eclipse.scout.commons.exception.ProcessingException; +import org.eclipse.scout.rt.client.ui.basic.table.ITableRow; +import org.eclipse.scout.rt.client.ui.form.fields.IFormField; +import org.eclipse.scout.rt.client.ui.form.fields.decimalfield.AbstractDecimalField; + +/** + * Column holding Decimal number + */ +public abstract class AbstractDecimalColumn<T extends Number> extends AbstractColumn<T> implements IDecimalColumn<T> { + // DO NOT init members, this has the same effect as if they were set AFTER + // initConfig() + private String m_format; + private boolean m_groupingUsed; + private NumberFormat m_fmt; + private int m_maxFractionDigits; + private int m_minFractionDigits; + private int m_fractionDigits; + private boolean m_percent; + private int m_multiplier; + private T m_minValue; + private T m_maxValue; + + public AbstractDecimalColumn() { + super(); + } + + @Override + protected int getConfiguredHorizontalAlignment() { + return 1; + } + + /* + * Configuration + */ + + /** + * Configures the format used to render the value. See {@link DecimalFormat#applyPattern(String)} for more information + * about the expected format. + * <p> + * Subclasses can override this method. Default is {@code null}. + * + * @return Format of this column. + */ + @ConfigProperty(ConfigProperty.STRING) + @Order(140) + @ConfigPropertyValue("null") + protected String getConfiguredFormat() { + return null; + } + + /** + * Configures whether grouping is used for this column. If grouping is used, the values may be displayed with a digit + * group separator. + * <p> + * Subclasses can override this method. Default is {@code true}. + * + * @return {@code true} if grouping is used for this column, {@code false} otherwise. + */ + @ConfigProperty(ConfigProperty.BOOLEAN) + @Order(150) + @ConfigPropertyValue("true") + protected boolean getConfiguredGroupingUsed() { + return true; + } + + /** + * Configures the minimum number of fraction digits used to display the value. To use an exact number of fraction + * digits, the same number as for {@link #getConfiguredMaxFractionDigits()} must be returned. + * <p> + * This property only has an effect if no format is specified by {@link #getConfiguredFormat()}. + * <p> + * Subclasses can override this method. Default is {@code 2}. + * + * @return Minimum number of fraction digits of this column. + */ + @ConfigProperty(ConfigProperty.INTEGER) + @Order(160) + @ConfigPropertyValue("2") + protected int getConfiguredMinFractionDigits() { + return 2; + } + + /** + * Configures the maximum number of fraction digits used to display the value. To use an exact number of fraction + * digits, the same number as for {@link #getConfiguredMinFractionDigits()} must be returned. + * <p> + * This property only has an effect if no format is specified by {@link #getConfiguredFormat()}. + * <p> + * Subclasses can override this method. Default is {@code 2}. + * + * @return maximum number of fraction digits of this column. + */ + @ConfigProperty(ConfigProperty.INTEGER) + @Order(170) + @ConfigPropertyValue("2") + protected int getConfiguredMaxFractionDigits() { + return 2; + } + + /** + * Configures whether the value is a percentage and is displayed with the appropriate sign. A value of 12 is displayed + * as 12 % (depending on the locale). Use {@link #getConfiguredMultiplier()} to handle the value differently (e.g. + * display a value of 0.12 as 12 %). + * <p> + * Subclasses can override this method. Default is {@code false}. + * + * @return {@code true} if the column represents a percentage value, {@code false} otherwise. + */ + @ConfigProperty(ConfigProperty.BOOLEAN) + @Order(180) + @ConfigPropertyValue("false") + protected boolean getConfiguredPercent() { + return false; + } + + /** + * Configures the multiplier used to display the value. See {@link DecimalFormat#setMultiplier(int)} for more + * information about multipliers. + * <p> + * Subclasses can override this method. Default is {@code 1}. + * + * @return The multiplier used to display the value. + */ + @ConfigProperty(ConfigProperty.INTEGER) + @Order(190) + @ConfigPropertyValue("1") + protected int getConfiguredMultiplier() { + return 1; + } + + @ConfigProperty(ConfigProperty.INTEGER) + @Order(200) + @ConfigPropertyValue("2") + protected int getConfiguredFractionDigits() { + return 2; + } + + @Override + protected void initConfig() { + super.initConfig(); + setFormat(getConfiguredFormat()); + setGroupingUsed(getConfiguredGroupingUsed()); + setMinFractionDigits(getConfiguredMinFractionDigits()); + setMaxFractionDigits(getConfiguredMaxFractionDigits()); + setPercent(getConfiguredPercent()); + setFractionDigits(getConfiguredFractionDigits()); + setMultiplier(getConfiguredMultiplier()); + } + + /* + * Runtime + */ + @Override + public void setFormat(String s) { + m_format = s; + setNumberFormat(null); + } + + protected final void setNumberFormat(NumberFormat fmt) { + m_fmt = fmt; + validateColumnValues(); + } + + @Override + public NumberFormat getNumberFormat() { + return m_fmt; + } + + @Override + public String getFormat() { + return m_format; + } + + @Override + public void setGroupingUsed(boolean b) { + m_groupingUsed = b; + setNumberFormat(null); + } + + @Override + public boolean isGroupingUsed() { + return m_groupingUsed; + } + + @Override + public void setMinFractionDigits(int i) { + if (i > getMaxFractionDigits()) { + m_maxFractionDigits = i; + } + m_minFractionDigits = i; + setNumberFormat(null); + } + + @Override + public int getMinFractionDigits() { + return m_minFractionDigits; + } + + @Override + public void setMaxFractionDigits(int i) { + if (i < getMinFractionDigits()) { + m_minFractionDigits = i; + } + m_maxFractionDigits = i; + setNumberFormat(null); + } + + @Override + public int getMaxFractionDigits() { + return m_maxFractionDigits; + } + + @Override + public void setPercent(boolean b) { + m_percent = b; + setNumberFormat(null); + } + + @Override + public boolean isPercent() { + return m_percent; + } + + @Override + public void setFractionDigits(int i) { + m_fractionDigits = i; + } + + @Override + public int getFractionDigits() { + return m_fractionDigits; + } + + @Override + public void setMultiplier(int i) { + m_multiplier = i; + setNumberFormat(null); + } + + @Override + public int getMultiplier() { + return m_multiplier; + } + + @Override + public void setMaxValue(T value) { + m_maxValue = value; + validateColumnValues(); + } + + @Override + public T getMaxValue() { + return m_maxValue; + } + + @Override + public void setMinValue(T value) { + m_minValue = value; + validateColumnValues(); + } + + @Override + public T getMinValue() { + return m_minValue; + } + + protected abstract AbstractDecimalField<T> getEditorField(); + + @Override + protected IFormField prepareEditInternal(ITableRow row) throws ProcessingException { + AbstractDecimalField<T> f = getEditorField(); + f.setFormat(getFormat()); + f.setMaxFractionDigits(getMaxFractionDigits()); + f.setMinFractionDigits(getMinFractionDigits()); + f.setFractionDigits(getNumberFormat().getMaximumFractionDigits()); + f.setMultiplier(getMultiplier()); + f.setGroupingUsed(isGroupingUsed()); + f.setPercent(isPercent()); + f.setMinValue(getMinValue()); + f.setMaxValue(getMaxValue()); + return f; + } + +} diff --git a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/AbstractDoubleColumn.java b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/AbstractDoubleColumn.java index c34b0cd819..9cf725935b 100644 --- a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/AbstractDoubleColumn.java +++ b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/AbstractDoubleColumn.java @@ -20,22 +20,12 @@ import org.eclipse.scout.commons.annotations.Order; import org.eclipse.scout.commons.exception.ProcessingException; import org.eclipse.scout.rt.client.ui.basic.cell.Cell; import org.eclipse.scout.rt.client.ui.basic.table.ITableRow; -import org.eclipse.scout.rt.client.ui.form.fields.IFormField; import org.eclipse.scout.rt.client.ui.form.fields.doublefield.AbstractDoubleField; /** * Column holding Double */ -public abstract class AbstractDoubleColumn extends AbstractColumn<Double> implements IDoubleColumn { - // DO NOT init members, this has the same effect as if they were set AFTER - // initConfig() - private String m_format; - private boolean m_groupingUsed; - private int m_maxFractionDigits; - private int m_minFractionDigits; - private boolean m_percent; - private int m_multiplier; - private NumberFormat m_fmt; +public abstract class AbstractDoubleColumn extends AbstractDecimalColumn<Double> implements IDoubleColumn { public AbstractDoubleColumn() { super(); @@ -50,192 +40,30 @@ public abstract class AbstractDoubleColumn extends AbstractColumn<Double> implem * Configuration */ - /** - * Configures the format used to render the value. See {@link DecimalFormat#applyPattern(String)} for more information - * about the expected format. - * <p> - * This property has higher priority than {@link #getConfiguredMaxFractionDigits()}, - * {@link #getConfiguredMinFractionDigits()} and {@link #getConfiguredGroupingUsed()}. Hence, if a format is - * specified, these properties will be ignored. - * <p> - * Subclasses can override this method. Default is {@code null}. - * - * @return Format of this column. - */ - @ConfigProperty(ConfigProperty.STRING) - @Order(140) + @ConfigProperty(ConfigProperty.DOUBLE) + @Order(200) @ConfigPropertyValue("null") - protected String getConfiguredFormat() { + protected Double getConfiguredMaxValue() { return null; } - /** - * Configures the minimum number of fraction digits used to display the value. To use an exact number of fraction - * digits, the same number as for {@link #getConfiguredMaxFractionDigits()} must be returned. - * <p> - * This property only has an effect if no format is specified by {@link #getConfiguredFormat()}. - * <p> - * Subclasses can override this method. Default is {@code 2}. - * - * @return Minimum number of fraction digits of this column. - */ - @ConfigProperty(ConfigProperty.INTEGER) - @Order(150) - @ConfigPropertyValue("2") - protected int getConfiguredMinFractionDigits() { - return 2; - } - - /** - * Configures the maximum number of fraction digits used to display the value. To use an exact number of fraction - * digits, the same number as for {@link #getConfiguredMinFractionDigits()} must be returned. - * <p> - * This property only has an effect if no format is specified by {@link #getConfiguredFormat()}. - * <p> - * Subclasses can override this method. Default is {@code 2}. - * - * @return maximum number of fraction digits of this column. - */ - @ConfigProperty(ConfigProperty.INTEGER) - @Order(160) - @ConfigPropertyValue("2") - protected int getConfiguredMaxFractionDigits() { - return 2; - } - - /** - * Configures whether grouping is used for this column. If grouping is used, the values may be displayed with a digit - * group separator. - * <p> - * This property only has an effect if no format is specified by {@link #getConfiguredFormat()}. - * <p> - * Subclasses can override this method. Default is {@code true}. - * - * @return {@code true} if grouping is used for this column, {@code false} otherwise. - */ - @ConfigProperty(ConfigProperty.BOOLEAN) - @Order(170) - @ConfigPropertyValue("true") - protected boolean getConfiguredGroupingUsed() { - return true; - } - - /** - * Configures whether the value is a percentage and is displayed with the appropriate sign. A value of 12 is displayed - * as 12 % (depending on the locale). Use {@link #getConfiguredMultiplier()} to handle the value differently (e.g. - * display a value of 0.12 as 12 %). - * <p> - * Subclasses can override this method. Default is {@code false}. - * - * @return {@code true} if the column represents a percentage value, {@code false} otherwise. - */ - @ConfigProperty(ConfigProperty.BOOLEAN) - @Order(180) - @ConfigPropertyValue("false") - protected boolean getConfiguredPercent() { - return false; - } - - /** - * Configures the multiplier used to display the value. See {@link DecimalFormat#setMultiplier(int)} for more - * information about multipliers. - * <p> - * Subclasses can override this method. Default is {@code 1}. - * - * @return The multiplier used to display the value. - */ - @ConfigProperty(ConfigProperty.INTEGER) - @Order(190) - @ConfigPropertyValue("1") - protected int getConfiguredMultiplier() { - return 1; + @ConfigProperty(ConfigProperty.DOUBLE) + @Order(210) + @ConfigPropertyValue("null") + protected Double getConfiguredMinValue() { + return null; } @Override protected void initConfig() { super.initConfig(); - setFormat(getConfiguredFormat()); - setMinFractionDigits(getConfiguredMinFractionDigits()); - setMaxFractionDigits(getConfiguredMaxFractionDigits()); - setGroupingUsed(getConfiguredGroupingUsed()); - setPercent(getConfiguredPercent()); - setMultiplier(getConfiguredMultiplier()); + setMaxValue(getConfiguredMaxValue()); + setMinValue(getConfiguredMinValue()); } /* * Runtime */ - @Override - public void setFormat(String s) { - m_format = s; - m_fmt = null; - } - - @Override - public String getFormat() { - return m_format; - } - - @Override - public void setMinFractionDigits(int i) { - if (i > getMaxFractionDigits()) { - m_maxFractionDigits = i; - } - m_minFractionDigits = i; - m_fmt = null; - } - - @Override - public int getMinFractionDigits() { - return m_minFractionDigits; - } - - @Override - public void setMaxFractionDigits(int i) { - if (i < getMinFractionDigits()) { - m_minFractionDigits = i; - } - m_maxFractionDigits = i; - m_fmt = null; - } - - @Override - public int getMaxFractionDigits() { - return m_maxFractionDigits; - } - - @Override - public void setGroupingUsed(boolean b) { - m_groupingUsed = b; - m_fmt = null; - } - - @Override - public boolean isGroupingUsed() { - return m_groupingUsed; - } - - @Override - public void setPercent(boolean b) { - m_percent = b; - m_fmt = null; - } - - @Override - public boolean isPercent() { - return m_percent; - } - - @Override - public void setMultiplier(int i) { - m_multiplier = i; - m_fmt = null; - } - - @Override - public int getMultiplier() { - return m_multiplier; - } @Override protected Double parseValueInternal(ITableRow row, Object rawValue) throws ProcessingException { @@ -256,17 +84,14 @@ public abstract class AbstractDoubleColumn extends AbstractColumn<Double> implem } @Override - protected IFormField prepareEditInternal(ITableRow row) throws ProcessingException { - AbstractDoubleField f = new AbstractDoubleField() { + protected AbstractDoubleField getEditorField() { + return new AbstractDoubleField() { + @Override + protected void initConfig() { + super.initConfig(); + propertySupport.putPropertiesMap(AbstractDoubleColumn.this.propertySupport.getPropertiesMap()); + } }; - f.setFormat(getFormat()); - f.setMaxFractionDigits(getMaxFractionDigits()); - f.setMinFractionDigits(getMinFractionDigits()); - f.setFractionDigits(getNumberFormat().getMaximumFractionDigits()); - f.setMultiplier(getMultiplier()); - f.setGroupingUsed(isGroupingUsed()); - f.setPercent(isPercent()); - return f; } @Override @@ -282,31 +107,33 @@ public abstract class AbstractDoubleColumn extends AbstractColumn<Double> implem @Override public NumberFormat getNumberFormat() { - if (m_fmt == null) { + if (super.getNumberFormat() == null) { + NumberFormat fmt; if (isPercent()) { - m_fmt = NumberFormat.getPercentInstance(LocaleThreadLocal.get()); + fmt = NumberFormat.getPercentInstance(LocaleThreadLocal.get()); } else { - m_fmt = NumberFormat.getNumberInstance(LocaleThreadLocal.get()); + fmt = NumberFormat.getNumberInstance(LocaleThreadLocal.get()); } - if (m_fmt instanceof DecimalFormat) { - ((DecimalFormat) m_fmt).setMultiplier(getMultiplier()); + if (fmt instanceof DecimalFormat) { + ((DecimalFormat) fmt).setMultiplier(getMultiplier()); if (getFormat() != null) { - ((DecimalFormat) m_fmt).applyPattern(getFormat()); + ((DecimalFormat) fmt).applyPattern(getFormat()); } else { - m_fmt.setMinimumFractionDigits(getMinFractionDigits()); - m_fmt.setMaximumFractionDigits(getMaxFractionDigits()); - m_fmt.setGroupingUsed(isGroupingUsed()); + fmt.setMinimumFractionDigits(getMinFractionDigits()); + fmt.setMaximumFractionDigits(getMaxFractionDigits()); + fmt.setGroupingUsed(isGroupingUsed()); } } else { - m_fmt.setMinimumFractionDigits(getMinFractionDigits()); - m_fmt.setMaximumFractionDigits(getMaxFractionDigits()); - m_fmt.setGroupingUsed(isGroupingUsed()); + fmt.setMinimumFractionDigits(getMinFractionDigits()); + fmt.setMaximumFractionDigits(getMaxFractionDigits()); + fmt.setGroupingUsed(isGroupingUsed()); } + setNumberFormat(fmt); } - return m_fmt; + return super.getNumberFormat(); } } diff --git a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/AbstractIntegerColumn.java b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/AbstractIntegerColumn.java index 6ef22bf50a..f265d72692 100644 --- a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/AbstractIntegerColumn.java +++ b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/AbstractIntegerColumn.java @@ -20,18 +20,12 @@ import org.eclipse.scout.commons.annotations.Order; import org.eclipse.scout.commons.exception.ProcessingException; import org.eclipse.scout.rt.client.ui.basic.cell.Cell; import org.eclipse.scout.rt.client.ui.basic.table.ITableRow; -import org.eclipse.scout.rt.client.ui.form.fields.IFormField; import org.eclipse.scout.rt.client.ui.form.fields.integerfield.AbstractIntegerField; /** * Column holding Integer */ -public abstract class AbstractIntegerColumn extends AbstractColumn<Integer> implements IIntegerColumn { - // DO NOT init members, this has the same effect as if they were set AFTER - // initConfig() - private String m_format; - private boolean m_groupingUsed; - private NumberFormat m_fmt; +public abstract class AbstractIntegerColumn extends AbstractNumberColumn<Integer> implements IIntegerColumn { public AbstractIntegerColumn() { super(); @@ -46,67 +40,30 @@ public abstract class AbstractIntegerColumn extends AbstractColumn<Integer> impl * Configuration */ - /** - * Configures the format used to render the value. See {@link DecimalFormat#applyPattern(String)} for more information - * about the expected format. - * <p> - * Subclasses can override this method. Default is {@code null}. - * - * @return Format of this column. - */ - @ConfigProperty(ConfigProperty.STRING) - @Order(140) + @ConfigProperty(ConfigProperty.INTEGER) + @Order(160) @ConfigPropertyValue("null") - protected String getConfiguredFormat() { + protected Integer getConfiguredMaxValue() { return null; } - /** - * Configures whether grouping is used for this column. If grouping is used, the values may be displayed with a digit - * group separator. - * <p> - * Subclasses can override this method. Default is {@code true}. - * - * @return {@code true} if grouping is used for this column, {@code false} otherwise. - */ - @ConfigProperty(ConfigProperty.BOOLEAN) - @Order(150) - @ConfigPropertyValue("true") - protected boolean getConfiguredGroupingUsed() { - return true; + @ConfigProperty(ConfigProperty.INTEGER) + @Order(170) + @ConfigPropertyValue("null") + protected Integer getConfiguredMinValue() { + return null; } @Override protected void initConfig() { super.initConfig(); - setFormat(getConfiguredFormat()); - setGroupingUsed(getConfiguredGroupingUsed()); + setMaxValue(getConfiguredMaxValue()); + setMinValue(getConfiguredMinValue()); } /* * Runtime */ - @Override - public void setFormat(String s) { - m_format = s; - m_fmt = null; - } - - @Override - public String getFormat() { - return m_format; - } - - @Override - public void setGroupingUsed(boolean b) { - m_groupingUsed = b; - m_fmt = null; - } - - @Override - public boolean isGroupingUsed() { - return m_groupingUsed; - } @Override protected Integer parseValueInternal(ITableRow row, Object rawValue) throws ProcessingException { @@ -127,12 +84,14 @@ public abstract class AbstractIntegerColumn extends AbstractColumn<Integer> impl } @Override - protected IFormField prepareEditInternal(ITableRow row) throws ProcessingException { - AbstractIntegerField f = new AbstractIntegerField() { + protected AbstractIntegerField getEditorField() { + return new AbstractIntegerField() { + @Override + protected void initConfig() { + super.initConfig(); + propertySupport.putPropertiesMap(AbstractIntegerColumn.this.propertySupport.getPropertiesMap()); + } }; - f.setFormat(getFormat()); - f.setGroupingUsed(isGroupingUsed()); - return f; } @Override @@ -148,22 +107,23 @@ public abstract class AbstractIntegerColumn extends AbstractColumn<Integer> impl @Override public NumberFormat getNumberFormat() { - if (m_fmt == null) { + if (super.getNumberFormat() == null) { if (getFormat() != null) { DecimalFormat x = (DecimalFormat) DecimalFormat.getNumberInstance(LocaleThreadLocal.get()); x.applyPattern(getFormat()); x.setMinimumFractionDigits(0); x.setMaximumFractionDigits(0); - m_fmt = x; + setNumberFormat(x); } else { - m_fmt = NumberFormat.getNumberInstance(LocaleThreadLocal.get()); - m_fmt.setMinimumFractionDigits(0); - m_fmt.setMaximumFractionDigits(0); - m_fmt.setGroupingUsed(isGroupingUsed()); + NumberFormat y = NumberFormat.getNumberInstance(LocaleThreadLocal.get()); + y.setMinimumFractionDigits(0); + y.setMaximumFractionDigits(0); + y.setGroupingUsed(isGroupingUsed()); + setNumberFormat(y); } } - return m_fmt; + return super.getNumberFormat(); } } diff --git a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/AbstractLongColumn.java b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/AbstractLongColumn.java index b6debd191d..ff2a1dd4e2 100644 --- a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/AbstractLongColumn.java +++ b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/AbstractLongColumn.java @@ -20,93 +20,45 @@ import org.eclipse.scout.commons.annotations.Order; import org.eclipse.scout.commons.exception.ProcessingException; import org.eclipse.scout.rt.client.ui.basic.cell.Cell; import org.eclipse.scout.rt.client.ui.basic.table.ITableRow; -import org.eclipse.scout.rt.client.ui.form.fields.IFormField; import org.eclipse.scout.rt.client.ui.form.fields.longfield.AbstractLongField; /** * Column holding Long */ -public abstract class AbstractLongColumn extends AbstractColumn<Long> implements ILongColumn { - // DO NOT init members, this has the same effect as if they were set AFTER - // initConfig() - private String m_format; - private boolean m_groupingUsed; - private NumberFormat m_fmt; +public abstract class AbstractLongColumn extends AbstractNumberColumn<Long> implements ILongColumn { public AbstractLongColumn() { super(); } - @Override - protected int getConfiguredHorizontalAlignment() { - return 1; - } - /* * Configuration */ - /** - * Configures the format used to render the value. See {@link DecimalFormat#applyPattern(String)} for more information - * about the expected format. - * <p> - * Subclasses can override this method. Default is {@code null}. - * - * @return Format of this column. - */ - @ConfigProperty(ConfigProperty.STRING) - @Order(140) + @ConfigProperty(ConfigProperty.LONG) + @Order(160) @ConfigPropertyValue("null") - protected String getConfiguredFormat() { + protected Long getConfiguredMaxValue() { return null; } - /** - * Configures whether grouping is used for this column. If grouping is used, the values may be displayed with a digit - * group separator. - * <p> - * Subclasses can override this method. Default is {@code true}. - * - * @return {@code true} if grouping is used for this column, {@code false} otherwise. - */ - @ConfigProperty(ConfigProperty.BOOLEAN) - @Order(150) - @ConfigPropertyValue("true") - protected boolean getConfiguredGroupingUsed() { - return true; + @ConfigProperty(ConfigProperty.LONG) + @Order(170) + @ConfigPropertyValue("null") + protected Long getConfiguredMinValue() { + return null; } @Override protected void initConfig() { super.initConfig(); - setFormat(getConfiguredFormat()); - setGroupingUsed(getConfiguredGroupingUsed()); + setMaxValue(getConfiguredMaxValue()); + setMinValue(getConfiguredMinValue()); } /* * Runtime */ - @Override - public void setFormat(String s) { - m_format = s; - m_fmt = null; - } - - @Override - public String getFormat() { - return m_format; - } - - @Override - public void setGroupingUsed(boolean b) { - m_groupingUsed = b; - m_fmt = null; - } - - @Override - public boolean isGroupingUsed() { - return m_groupingUsed; - } @Override protected Long parseValueInternal(ITableRow row, Object rawValue) throws ProcessingException { @@ -127,12 +79,14 @@ public abstract class AbstractLongColumn extends AbstractColumn<Long> implements } @Override - protected IFormField prepareEditInternal(ITableRow row) throws ProcessingException { - AbstractLongField f = new AbstractLongField() { + protected AbstractLongField getEditorField() { + return new AbstractLongField() { + @Override + protected void initConfig() { + super.initConfig(); + propertySupport.putPropertiesMap(AbstractLongColumn.this.propertySupport.getPropertiesMap()); + } }; - f.setFormat(getFormat()); - f.setGroupingUsed(isGroupingUsed()); - return f; } @Override @@ -148,22 +102,23 @@ public abstract class AbstractLongColumn extends AbstractColumn<Long> implements @Override public NumberFormat getNumberFormat() { - if (m_fmt == null) { + if (super.getNumberFormat() == null) { if (getFormat() != null) { DecimalFormat x = (DecimalFormat) DecimalFormat.getNumberInstance(LocaleThreadLocal.get()); x.applyPattern(getFormat()); x.setMinimumFractionDigits(0); x.setMaximumFractionDigits(0); - m_fmt = x; + setNumberFormat(x); } else { - m_fmt = NumberFormat.getNumberInstance(LocaleThreadLocal.get()); - m_fmt.setMinimumFractionDigits(0); - m_fmt.setMaximumFractionDigits(0); - m_fmt.setGroupingUsed(isGroupingUsed()); + NumberFormat y = NumberFormat.getNumberInstance(LocaleThreadLocal.get()); + y.setMinimumFractionDigits(0); + y.setMaximumFractionDigits(0); + y.setGroupingUsed(isGroupingUsed()); + setNumberFormat(y); } } - return m_fmt; + return super.getNumberFormat(); } } diff --git a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/AbstractNumberColumn.java b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/AbstractNumberColumn.java new file mode 100644 index 0000000000..61738652ed --- /dev/null +++ b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/AbstractNumberColumn.java @@ -0,0 +1,155 @@ +/******************************************************************************* + * Copyright (c) 2010 BSI Business Systems Integration AG. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * BSI Business Systems Integration AG - initial API and implementation + ******************************************************************************/ +package org.eclipse.scout.rt.client.ui.basic.table.columns; + +import java.text.DecimalFormat; +import java.text.NumberFormat; + +import org.eclipse.scout.commons.annotations.ConfigProperty; +import org.eclipse.scout.commons.annotations.ConfigPropertyValue; +import org.eclipse.scout.commons.annotations.Order; +import org.eclipse.scout.commons.exception.ProcessingException; +import org.eclipse.scout.rt.client.ui.basic.table.ITableRow; +import org.eclipse.scout.rt.client.ui.form.fields.IFormField; +import org.eclipse.scout.rt.client.ui.form.fields.numberfield.AbstractNumberField; + +/** + * Column holding Number + */ +public abstract class AbstractNumberColumn<T extends Number> extends AbstractColumn<T> implements INumberColumn<T> { + // DO NOT init members, this has the same effect as if they were set AFTER + // initConfig() + private String m_format; + private boolean m_groupingUsed; + private NumberFormat m_fmt; + private T m_minValue; + private T m_maxValue; + + public AbstractNumberColumn() { + super(); + } + + @Override + protected int getConfiguredHorizontalAlignment() { + return 1; + } + + /* + * Configuration + */ + + /** + * Configures the format used to render the value. See {@link DecimalFormat#applyPattern(String)} for more information + * about the expected format. + * <p> + * Subclasses can override this method. Default is {@code null}. + * + * @return Format of this column. + */ + @ConfigProperty(ConfigProperty.STRING) + @Order(140) + @ConfigPropertyValue("null") + protected String getConfiguredFormat() { + return null; + } + + /** + * Configures whether grouping is used for this column. If grouping is used, the values may be displayed with a digit + * group separator. + * <p> + * Subclasses can override this method. Default is {@code true}. + * + * @return {@code true} if grouping is used for this column, {@code false} otherwise. + */ + @ConfigProperty(ConfigProperty.BOOLEAN) + @Order(150) + @ConfigPropertyValue("true") + protected boolean getConfiguredGroupingUsed() { + return true; + } + + @Override + protected void initConfig() { + super.initConfig(); + setFormat(getConfiguredFormat()); + setGroupingUsed(getConfiguredGroupingUsed()); + } + + /* + * Runtime + */ + @Override + public void setFormat(String s) { + m_format = s; + setNumberFormat(null); + } + + protected final void setNumberFormat(NumberFormat fmt) { + m_fmt = fmt; + validateColumnValues(); + } + + @Override + public NumberFormat getNumberFormat() { + return m_fmt; + } + + @Override + public String getFormat() { + return m_format; + } + + @Override + public void setGroupingUsed(boolean b) { + m_groupingUsed = b; + setNumberFormat(null); + } + + @Override + public boolean isGroupingUsed() { + return m_groupingUsed; + } + + @Override + public void setMaxValue(T value) { + m_maxValue = value; + validateColumnValues(); + } + + @Override + public T getMaxValue() { + return m_maxValue; + } + + @Override + public void setMinValue(T value) { + m_minValue = value; + validateColumnValues(); + } + + @Override + public T getMinValue() { + return m_minValue; + } + + protected abstract AbstractNumberField<T> getEditorField(); + + @Override + protected IFormField prepareEditInternal(ITableRow row) throws ProcessingException { + AbstractNumberField<T> f = getEditorField(); + f.setFormat(getFormat()); + f.setGroupingUsed(isGroupingUsed()); + f.setMinValue(getMinValue()); + f.setMaxValue(getMaxValue()); + return f; + } + +} diff --git a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/AbstractSmartColumn.java b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/AbstractSmartColumn.java index f4c0262acf..8493246bd0 100644 --- a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/AbstractSmartColumn.java +++ b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/AbstractSmartColumn.java @@ -93,6 +93,16 @@ public abstract class AbstractSmartColumn<T> extends AbstractColumn<T> implement } /** + * valid when configuredBrowseHierarchy=true + */ + @ConfigProperty(ConfigProperty.BOOLEAN) + @Order(280) + @ConfigPropertyValue("true") + protected boolean getConfiguredBrowseAutoExpandAll() { + return true; + } + + /** * Configures whether the values are sorted by display text or by sort code in case of a code type class. This * configuration only is useful if a code type class is set (see {@link #getConfiguredCodeType()}). In case of a * lookup call, the values are sorted by display text. @@ -108,6 +118,59 @@ public abstract class AbstractSmartColumn<T> extends AbstractColumn<T> implement return false; } + @ConfigProperty(ConfigProperty.INTEGER) + @Order(265) + @ConfigPropertyValue("100") + protected int getConfiguredBrowseMaxRowCount() { + return 100; + } + + /** + * When the smart proposal finds no matching records and this property is not + * null, then it displays a link or menu with this label.<br> + * When clicked the method {@link #execBrowseNew(String)} is invoked, which in + * most cases is implemented as opening a "New XY..." dialog + */ + @ConfigProperty(ConfigProperty.STRING) + @Order(315) + @ConfigPropertyValue("null") + protected String getConfiguredBrowseNewText() { + return null; + } + + /** + * @return true: inactive rows are display together with active rows<br> + * false: inactive rows ae only displayed when selected by the model + */ + @ConfigProperty(ConfigProperty.BOOLEAN) + @Order(270) + @ConfigPropertyValue("false") + protected boolean getConfiguredActiveFilterEnabled() { + return false; + } + + /** + * valid when configuredBrowseHierarchy=true + */ + @ConfigProperty(ConfigProperty.BOOLEAN) + @Order(240) + @ConfigPropertyValue("false") + protected boolean getConfiguredBrowseLoadIncremental() { + return false; + } + + /** + * Code-Assistant<br> + * Don't just allow smart field values, but also custom text as valid values; + * smartfield is simply used as code assistent + */ + @ConfigProperty(ConfigProperty.BOOLEAN) + @Order(290) + @ConfigPropertyValue("false") + protected boolean getConfiguredAllowCustomText() { + return false; + } + @ConfigOperation @Order(140) protected void execPrepareLookup(LookupCall call, ITableRow row) { @@ -155,6 +218,7 @@ public abstract class AbstractSmartColumn<T> extends AbstractColumn<T> implement if (m_codeTypeClass != null) { m_lookupCall = CodeLookupCall.newInstanceByService(m_codeTypeClass); } + validateColumnValues(); } @Override @@ -187,7 +251,7 @@ public abstract class AbstractSmartColumn<T> extends AbstractColumn<T> implement public LookupCall prepareLookupCall(ITableRow row) { if (getLookupCall() != null) { LookupCall call = SERVICES.getService(ILookupCallProvisioningService.class).newClonedInstance(getLookupCall(), new TableProvisioningContext(getTable(), row, AbstractSmartColumn.this)); - call.setKey(getValue(row)); + call.setKey(getValueInternal(row)); call.setText(null); call.setAll(null); call.setRec(null); @@ -224,6 +288,12 @@ public abstract class AbstractSmartColumn<T> extends AbstractColumn<T> implement protected IFormField prepareEditInternal(final ITableRow row) throws ProcessingException { AbstractSmartField<T> f = new AbstractSmartField<T>() { @Override + protected void initConfig() { + super.initConfig(); + propertySupport.putPropertiesMap(AbstractSmartColumn.this.propertySupport.getPropertiesMap()); + } + + @Override public Class<T> getHolderType() { return AbstractSmartColumn.this.getDataType(); } @@ -234,8 +304,15 @@ public abstract class AbstractSmartColumn<T> extends AbstractColumn<T> implement } }; + f.setCodeTypeClass(getCodeTypeClass()); f.setLookupCall(getLookupCall()); f.setBrowseHierarchy(getConfiguredBrowseHierarchy()); + f.setBrowseMaxRowCount(getConfiguredBrowseMaxRowCount()); + f.setBrowseNewText(getConfiguredBrowseNewText()); + f.setActiveFilterEnabled(getConfiguredActiveFilterEnabled()); + f.setBrowseAutoExpandAll(getConfiguredBrowseAutoExpandAll()); + f.setBrowseLoadIncremental(getConfiguredBrowseLoadIncremental()); + f.setAllowCustomText(getConfiguredAllowCustomText()); return f; } diff --git a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/AbstractStringColumn.java b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/AbstractStringColumn.java index 7d8431cb58..2d334eed12 100644 --- a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/AbstractStringColumn.java +++ b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/AbstractStringColumn.java @@ -20,6 +20,7 @@ import org.eclipse.scout.rt.client.ui.basic.table.ITable; import org.eclipse.scout.rt.client.ui.basic.table.ITableRow; import org.eclipse.scout.rt.client.ui.form.fields.IFormField; import org.eclipse.scout.rt.client.ui.form.fields.stringfield.AbstractStringField; +import org.eclipse.scout.rt.client.ui.form.fields.stringfield.IStringField; /** * Column holding Strings @@ -27,9 +28,6 @@ import org.eclipse.scout.rt.client.ui.form.fields.stringfield.AbstractStringFiel public abstract class AbstractStringColumn extends AbstractColumn<String> implements IStringColumn { // DO NOT init members, this has the same effect as if they were set AFTER // initConfig() - private boolean m_inputMasked; - private String m_format; - private boolean m_wrap; public AbstractStringColumn() { super(); @@ -99,12 +97,41 @@ public abstract class AbstractStringColumn extends AbstractColumn<String> implem return false; } + @ConfigProperty(ConfigProperty.STRING) + @Order(170) + @ConfigPropertyValue("null") + protected String getConfiguredFormat() { + return null; + } + + @ConfigProperty(ConfigProperty.BOOLEAN) + @Order(180) + @ConfigPropertyValue("true") + protected boolean getConfiguredSelectAllOnEdit() { + return true; + } + + /** + * Causes the ui to send a validate event every time the text field content is changed. + * <p> + * Be careful when using this property since this can influence performance and the charateristics of text input. + */ + @ConfigProperty(ConfigProperty.BOOLEAN) + @Order(180) + @ConfigPropertyValue("false") + protected boolean getConfiguredValidateOnAnyKey() { + return false; + } + @Override protected void initConfig() { super.initConfig(); setInputMasked(getConfiguredInputMasked()); setDisplayFormat(getConfiguredDisplayFormat()); + setMaxLength(getConfiguredMaxLength()); setTextWrap(getConfiguredTextWrap()); + setSelectAllOnEdit(getConfiguredSelectAllOnEdit()); + setValidateOnAnyKey(getConfiguredValidateOnAnyKey()); } /* @@ -112,32 +139,70 @@ public abstract class AbstractStringColumn extends AbstractColumn<String> implem */ @Override public void setInputMasked(boolean b) { - m_inputMasked = b; + propertySupport.setPropertyBool(IStringField.PROP_INPUT_MASKED, b); } @Override public boolean isInputMasked() { - return m_inputMasked; + return propertySupport.getPropertyBool(IStringField.PROP_INPUT_MASKED); } @Override public void setDisplayFormat(String s) { - m_format = s; + propertySupport.setPropertyString(IStringField.PROP_FORMAT, s); } @Override public String getDisplayFormat() { - return m_format; + return propertySupport.getPropertyString(IStringField.PROP_FORMAT); } @Override public void setTextWrap(boolean b) { - m_wrap = b; + propertySupport.setPropertyBool(IStringField.PROP_WRAP_TEXT, b); + validateColumnValues(); } @Override public boolean isTextWrap() { - return m_wrap; + return propertySupport.getPropertyBool(IStringField.PROP_WRAP_TEXT); + } + + @Override + public boolean isSelectAllOnEdit() { + return propertySupport.getPropertyBool(IStringField.PROP_SELECT_ALL_ON_FOCUS); + } + + @Override + public void setSelectAllOnEdit(boolean b) { + propertySupport.setPropertyBool(IStringField.PROP_SELECT_ALL_ON_FOCUS, b); + } + + @Override + public void setValidateOnAnyKey(boolean b) { + propertySupport.setPropertyBool(IStringField.PROP_VALIDATE_ON_ANY_KEY, b); + } + + @Override + public boolean isValidateOnAnyKey() { + return propertySupport.getPropertyBool(IStringField.PROP_VALIDATE_ON_ANY_KEY); + } + + @Override + public void setMaxLength(int len) { + if (len > 0) { + propertySupport.setPropertyInt(IStringField.PROP_MAX_LENGTH, len); + } + validateColumnValues(); + } + + @Override + public int getMaxLength() { + int len = propertySupport.getPropertyInt(IStringField.PROP_MAX_LENGTH); + if (len <= 0) { + len = 200; + } + return len; } @Override @@ -172,9 +237,13 @@ public abstract class AbstractStringColumn extends AbstractColumn<String> implem @Override protected IFormField prepareEditInternal(ITableRow row) throws ProcessingException { AbstractStringField f = new AbstractStringField() { + @Override + protected void initConfig() { + super.initConfig(); + propertySupport.putPropertiesMap(AbstractStringColumn.this.propertySupport.getPropertiesMap()); + } + }; - f.setMaxLength(getConfiguredMaxLength()); - f.setInputMasked(isInputMasked()); boolean multi = (getTable() != null ? getTable().isMultilineText() : isTextWrap()); f.setMultilineText(multi); f.setWrapText(true); // avoid to have an horizontal scroll bar @@ -183,12 +252,13 @@ public abstract class AbstractStringColumn extends AbstractColumn<String> implem @Override protected void decorateCellInternal(Cell cell, ITableRow row) { + String format = getDisplayFormat(); super.decorateCellInternal(cell, row); - if (m_format != null && cell.getValue() != null) { - if (FORMAT_LOWER.equals(m_format)) { + if (format != null && cell.getValue() != null) { + if (FORMAT_LOWER.equals(format)) { cell.setText(((String) cell.getValue()).toLowerCase()); } - else if (FORMAT_UPPER.equals(m_format)) { + else if (FORMAT_UPPER.equals(format)) { cell.setText(((String) cell.getValue()).toUpperCase()); } } diff --git a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/IBigDecimalColumn.java b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/IBigDecimalColumn.java index af24da0714..990852a2e9 100644 --- a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/IBigDecimalColumn.java +++ b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/IBigDecimalColumn.java @@ -4,41 +4,14 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * BSI Business Systems Integration AG - initial API and implementation ******************************************************************************/ package org.eclipse.scout.rt.client.ui.basic.table.columns; import java.math.BigDecimal; -import java.text.NumberFormat; -public interface IBigDecimalColumn extends IColumn<BigDecimal> { - - void setFormat(String s); - - String getFormat(); - - void setMinFractionDigits(int i); - - int getMinFractionDigits(); - - void setMaxFractionDigits(int i); - - int getMaxFractionDigits(); - - void setGroupingUsed(boolean b); - - boolean isGroupingUsed(); - - void setPercent(boolean b); - - boolean isPercent(); - - void setMultiplier(int b); - - int getMultiplier(); - - NumberFormat getNumberFormat(); +public interface IBigDecimalColumn extends IDecimalColumn<BigDecimal> { } diff --git a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/IColumn.java b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/IColumn.java index cd1cc45598..4ee24b1a5f 100644 --- a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/IColumn.java +++ b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/IColumn.java @@ -409,4 +409,8 @@ public interface IColumn<T> extends IPropertyObserver { */ void setAutoOptimizeWidth(boolean optimize); + boolean isMandatory(); + + void setMandatory(boolean mandatory); + } diff --git a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/IDateColumn.java b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/IDateColumn.java index c6b734f83f..5b71e0ea01 100644 --- a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/IDateColumn.java +++ b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/IDateColumn.java @@ -27,4 +27,10 @@ public interface IDateColumn extends IColumn<Date> { void setHasTime(boolean b); + void setAutoTimeMillis(long l); + + void setAutoTimeMillis(int hour, int minute, int second); + + long getAutoTimeMillis(); + } diff --git a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/IDecimalColumn.java b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/IDecimalColumn.java new file mode 100644 index 0000000000..2c8c0ed263 --- /dev/null +++ b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/IDecimalColumn.java @@ -0,0 +1,57 @@ +/******************************************************************************* + * Copyright (c) 2010 BSI Business Systems Integration AG. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * BSI Business Systems Integration AG - initial API and implementation + ******************************************************************************/ +package org.eclipse.scout.rt.client.ui.basic.table.columns; + +import java.text.NumberFormat; + +/** + * + */ +public interface IDecimalColumn<T extends Number> extends IColumn<T> { + + void setFormat(String s); + + String getFormat(); + + void setMinFractionDigits(int i); + + int getMinFractionDigits(); + + void setMaxFractionDigits(int i); + + int getMaxFractionDigits(); + + void setGroupingUsed(boolean b); + + boolean isGroupingUsed(); + + void setPercent(boolean b); + + boolean isPercent(); + + void setFractionDigits(int i); + + int getFractionDigits(); + + void setMinValue(T d); + + T getMinValue(); + + void setMaxValue(T d); + + T getMaxValue(); + + void setMultiplier(int b); + + int getMultiplier(); + + NumberFormat getNumberFormat(); +} diff --git a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/IDoubleColumn.java b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/IDoubleColumn.java index 78f71558ff..e6384ef6d2 100644 --- a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/IDoubleColumn.java +++ b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/IDoubleColumn.java @@ -4,39 +4,12 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * BSI Business Systems Integration AG - initial API and implementation ******************************************************************************/ package org.eclipse.scout.rt.client.ui.basic.table.columns; -import java.text.NumberFormat; +public interface IDoubleColumn extends IDecimalColumn<Double> { -public interface IDoubleColumn extends IColumn<Double> { - - void setFormat(String s); - - String getFormat(); - - void setMinFractionDigits(int i); - - int getMinFractionDigits(); - - void setMaxFractionDigits(int i); - - int getMaxFractionDigits(); - - void setGroupingUsed(boolean b); - - boolean isGroupingUsed(); - - void setPercent(boolean b); - - boolean isPercent(); - - void setMultiplier(int b); - - int getMultiplier(); - - NumberFormat getNumberFormat(); } diff --git a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/IIntegerColumn.java b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/IIntegerColumn.java index 09cbb94b51..567e08e3e8 100644 --- a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/IIntegerColumn.java +++ b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/IIntegerColumn.java @@ -4,23 +4,13 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * BSI Business Systems Integration AG - initial API and implementation ******************************************************************************/ package org.eclipse.scout.rt.client.ui.basic.table.columns; -import java.text.NumberFormat; -public interface IIntegerColumn extends IColumn<Integer> { +public interface IIntegerColumn extends INumberColumn<Integer> { - void setFormat(String s); - - String getFormat(); - - void setGroupingUsed(boolean b); - - boolean isGroupingUsed(); - - NumberFormat getNumberFormat(); } diff --git a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/ILongColumn.java b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/ILongColumn.java index f9f16f6b6b..912dae3b94 100644 --- a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/ILongColumn.java +++ b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/ILongColumn.java @@ -4,23 +4,13 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * BSI Business Systems Integration AG - initial API and implementation ******************************************************************************/ package org.eclipse.scout.rt.client.ui.basic.table.columns; -import java.text.NumberFormat; -public interface ILongColumn extends IColumn<Long> { +public interface ILongColumn extends INumberColumn<Long> { - void setFormat(String s); - - String getFormat(); - - void setGroupingUsed(boolean b); - - boolean isGroupingUsed(); - - NumberFormat getNumberFormat(); } diff --git a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/INumberColumn.java b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/INumberColumn.java new file mode 100644 index 0000000000..e2e1dc9157 --- /dev/null +++ b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/INumberColumn.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright (c) 2010 BSI Business Systems Integration AG. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * BSI Business Systems Integration AG - initial API and implementation + ******************************************************************************/ +package org.eclipse.scout.rt.client.ui.basic.table.columns; + +import java.text.NumberFormat; + +/** + * + */ +public interface INumberColumn<T extends Number> extends IColumn<T> { + + void setFormat(String s); + + String getFormat(); + + void setGroupingUsed(boolean b); + + boolean isGroupingUsed(); + + void setMinValue(T value); + + T getMinValue(); + + void setMaxValue(T value); + + T getMaxValue(); + + NumberFormat getNumberFormat(); +} diff --git a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/IStringColumn.java b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/IStringColumn.java index 6178f3aab5..24067a8ae8 100644 --- a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/IStringColumn.java +++ b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/table/columns/IStringColumn.java @@ -35,4 +35,16 @@ public interface IStringColumn extends IColumn<String> { boolean isTextWrap(); + boolean isSelectAllOnEdit(); + + public void setSelectAllOnEdit(boolean b); + + public void setValidateOnAnyKey(boolean b); + + public boolean isValidateOnAnyKey(); + + public void setMaxLength(int len); + + public int getMaxLength(); + } diff --git a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/form/fields/tablefield/AbstractTableField.java b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/form/fields/tablefield/AbstractTableField.java index d41bf1fa59..8baec3d777 100644 --- a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/form/fields/tablefield/AbstractTableField.java +++ b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/form/fields/tablefield/AbstractTableField.java @@ -39,6 +39,7 @@ import org.eclipse.scout.commons.xmlparser.SimpleXmlElement; import org.eclipse.scout.rt.client.ui.action.keystroke.IKeyStroke; import org.eclipse.scout.rt.client.ui.action.keystroke.KeyStroke; import org.eclipse.scout.rt.client.ui.action.menu.IMenu; +import org.eclipse.scout.rt.client.ui.basic.cell.ICell; import org.eclipse.scout.rt.client.ui.basic.table.AbstractTable; import org.eclipse.scout.rt.client.ui.basic.table.ITable; import org.eclipse.scout.rt.client.ui.basic.table.ITable2; @@ -51,7 +52,6 @@ import org.eclipse.scout.rt.client.ui.basic.table.columns.IDoubleColumn; import org.eclipse.scout.rt.client.ui.basic.table.columns.IIntegerColumn; import org.eclipse.scout.rt.client.ui.basic.table.columns.ILongColumn; import org.eclipse.scout.rt.client.ui.form.fields.AbstractFormField; -import org.eclipse.scout.rt.client.ui.form.fields.IFormField; import org.eclipse.scout.rt.client.ui.form.fields.IValidateContentDescriptor; import org.eclipse.scout.rt.client.ui.form.fields.ValidateFormFieldDescriptor; import org.eclipse.scout.rt.shared.ScoutTexts; @@ -555,19 +555,16 @@ public abstract class AbstractTableField<T extends ITable> extends AbstractFormF for (IColumn col : table.getColumns()) { if (col.isCellEditable(row)) { try { - IFormField editor = col.prepareEdit(row); - if (editor != null) { - boolean editorValid = editor.isContentValid(); - if (!editorValid) { - if (col.isDisplayable() && !col.isVisible()) { - //column should become visible - invisbleColumnsWithErrors.add(col); - } - if (tableDesc == null) { - tableDesc = new ValidateTableFieldDescriptor(this, row, col); - } - columnNames.add(col.getHeaderCell().getText()); + ICell cell = row.getCell(col); + if (cell.getErrorStatus() != null) { + if (col.isDisplayable() && !col.isVisible()) { + //column should become visible + invisbleColumnsWithErrors.add(col); } + if (tableDesc == null) { + tableDesc = new ValidateTableFieldDescriptor(this, row, col); + } + columnNames.add(col.getHeaderCell().getText()); } } catch (Throwable t) { |