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);
}
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);
}
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);
}
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();
}
}
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();
}
}
Aggregations