Search in sources :

Example 6 with ComponentFormat

use of com.servoy.j2db.component.ComponentFormat in project servoy-client by Servoy.

the class DataCalendar method installFormat.

public void installFormat(ComponentFormat componentFormat) {
    // calendar field always works with dates (even if it is attached to a dataprovider of another type
    // - for example it could work with a text column that has a Date <-> String converter)
    ComponentFormat cf;
    if (componentFormat.parsedFormat.isEmpty()) {
        // use default locale short date/time format
        cf = new ComponentFormat(FormatParser.parseFormatProperty(new SimpleDateFormat().toPattern()), IColumnTypes.DATETIME, componentFormat.uiType);
    } else {
        cf = new ComponentFormat(componentFormat.parsedFormat, IColumnTypes.DATETIME, componentFormat.uiType);
    }
    enclosedComponent.installFormat(cf);
}
Also used : SimpleDateFormat(java.text.SimpleDateFormat) ComponentFormat(com.servoy.j2db.component.ComponentFormat)

Example 7 with ComponentFormat

use of com.servoy.j2db.component.ComponentFormat in project servoy-client by Servoy.

the class DataLabel method setValueObject.

public void setValueObject(Object obj) {
    this.rawValue = obj;
    if (needEntireState) {
        String txt = "";
        if (resolver != null) {
            if (dataProviderID != null) {
                try {
                    ComponentFormat fp = getScriptObject().getComponentFormat();
                    txt = Text.processTags(TagResolver.formatObject(obj != null ? obj : "", application.getLocale(), fp.parsedFormat, (fp.parsedFormat.getDisplayFormat() != null ? new ServoyMaskFormatter(fp.parsedFormat.getDisplayFormat(), true) : null)), resolver);
                } catch (ParseException e) {
                    Debug.error(e);
                }
            } else {
                txt = Text.processTags(tagText, resolver);
            }
            if (txt == null)
                txt = "";
        }
        if (!txt.equals(value)) {
            setText(txt);
            value = txt;
        }
        if (tooltip != null) {
            super.setToolTipText(tooltip);
        }
    } else {
        if (obj != null) {
            if (obj.equals(value)) {
                if (scriptable != null && scriptable.getRenderEventExecutor().isRenderStateChanged())
                    fireOnRender(false);
                return;
            }
            if (obj instanceof byte[]) {
                setIconDirect((byte[]) obj, getNextSeq());
            // setIcon(new ImageIcon((byte[])obj));
            } else {
                try {
                    ComponentFormat fp = getScriptObject().getComponentFormat();
                    setText(TagResolver.formatObject(obj, application.getLocale(), fp.parsedFormat, (fp.parsedFormat.getDisplayFormat() != null ? new ServoyMaskFormatter(fp.parsedFormat.getDisplayFormat(), true) : null)));
                } catch (ParseException e) {
                    Debug.error(e);
                }
            }
        } else {
            if (value instanceof byte[]) {
                setIcon((byte[]) null);
            } else {
                // $NON-NLS-1$
                setText("");
            }
        }
        this.value = obj;
        if (tooltip != null) {
            super.setToolTipText(tooltip);
        }
    }
    fireOnRender(false);
}
Also used : ServoyMaskFormatter(com.servoy.j2db.util.text.ServoyMaskFormatter) ParseException(java.text.ParseException) ComponentFormat(com.servoy.j2db.component.ComponentFormat)

Example 8 with ComponentFormat

use of com.servoy.j2db.component.ComponentFormat in project servoy-client by Servoy.

the class ScriptCalculation method setTypeAndCheck.

/**
 * Sets the type.
 *
 * @param type The type to set
 */
public void setTypeAndCheck(int arg, IServiceProvider application) {
    int dpType = arg;
    try // if stored calc type is enforced to be the same
    {
        ITable table = getTable();
        if (table != null) {
            Column c = table.getColumn(getName());
            if (c != null) {
                // use dataprovider type as defined by converter
                ComponentFormat componentFormat = ComponentFormat.getComponentFormat(null, c, application);
                dpType = componentFormat.dpType;
            }
        }
    } catch (Exception e) {
        Debug.error(e);
    }
    setType(dpType);
}
Also used : IBaseColumn(com.servoy.base.persistence.IBaseColumn) ComponentFormat(com.servoy.j2db.component.ComponentFormat)

Example 9 with ComponentFormat

use of com.servoy.j2db.component.ComponentFormat in project servoy-client by Servoy.

the class AbstractRuntimeFormattedValuelistComponent method setFormat.

public void setFormat(String formatString) {
    if (!Utils.safeEquals(formatString, getFormat())) {
        setComponentFormat(new ComponentFormat(FormatParser.parseFormatProperty(application.getI18NMessageIfPrefixed(formatString)), componentFormat == null ? IColumnTypes.TEXT : componentFormat.dpType, componentFormat == null ? IColumnTypes.TEXT : componentFormat.uiType));
        getChangesRecorder().setChanged();
        clearRenderableWrapperProperty(RenderableWrapper.PROPERTY_FORMAT);
        fireOnRender();
    }
}
Also used : ComponentFormat(com.servoy.j2db.component.ComponentFormat)

Example 10 with ComponentFormat

use of com.servoy.j2db.component.ComponentFormat in project servoy-client by Servoy.

the class RuntimeDataCalendar method setFormat.

public void setFormat(String formatString) {
    if (!Utils.safeEquals(formatString, getFormat())) {
        setComponentFormat(new ComponentFormat(FormatParser.parseFormatProperty(application.getI18NMessageIfPrefixed(formatString)), componentFormat == null ? IColumnTypes.TEXT : componentFormat.dpType, componentFormat == null ? IColumnTypes.TEXT : componentFormat.uiType));
        getChangesRecorder().setChanged();
        RenderEventExecutor renderEventExecutor = getRenderEventExecutor();
        IScriptRenderMethods renderable = getRenderable();
        if (renderEventExecutor != null && !renderEventExecutor.isOnRenderExecuting() && renderable instanceof RenderableWrapper) {
            ((RenderableWrapper) renderable).clearProperty(RenderableWrapper.PROPERTY_FORMAT);
        }
        fireOnRender();
    }
}
Also used : IScriptRenderMethods(com.servoy.j2db.ui.IScriptRenderMethods) RenderEventExecutor(com.servoy.j2db.ui.RenderEventExecutor) RenderableWrapper(com.servoy.j2db.ui.RenderableWrapper) ComponentFormat(com.servoy.j2db.component.ComponentFormat)

Aggregations

ComponentFormat (com.servoy.j2db.component.ComponentFormat)14 ServoyMaskFormatter (com.servoy.j2db.util.text.ServoyMaskFormatter)5 ParseException (java.text.ParseException)5 ITable (com.servoy.j2db.persistence.ITable)3 Form (com.servoy.j2db.persistence.Form)2 IDataProvider (com.servoy.j2db.persistence.IDataProvider)2 Relation (com.servoy.j2db.persistence.Relation)2 IContextProvider (com.servoy.j2db.server.ngclient.IContextProvider)2 FoundsetTypeSabloValue (com.servoy.j2db.server.ngclient.property.FoundsetTypeSabloValue)2 IConverter (org.apache.wicket.util.convert.IConverter)2 IBaseColumn (com.servoy.base.persistence.IBaseColumn)1 FlattenedSolution (com.servoy.j2db.FlattenedSolution)1 FormAndTableDataProviderLookup (com.servoy.j2db.FormAndTableDataProviderLookup)1 FormController (com.servoy.j2db.FormController)1 FormManager (com.servoy.j2db.FormManager)1 GlobalMethodValueList (com.servoy.j2db.dataprocessing.GlobalMethodValueList)1 IValueList (com.servoy.j2db.dataprocessing.IValueList)1 Column (com.servoy.j2db.persistence.Column)1 ColumnInfo (com.servoy.j2db.persistence.ColumnInfo)1 IColumn (com.servoy.j2db.persistence.IColumn)1