use of com.servoy.j2db.component.ComponentFormat in project servoy-client by Servoy.
the class WebDataButton method onBeforeRender.
/**
* @see org.apache.wicket.Component#onBeforeRender()
*/
@Override
protected void onBeforeRender() {
super.onBeforeRender();
IModel<?> model = getInnermostModel();
if (needEntireState && model instanceof RecordItemModel) {
if (dataProviderID != null) {
Object val = getModelObject();
if (val instanceof byte[]) {
setIcon((byte[]) val);
} else if (icon != null) {
setIcon(null);
} else {
try {
ComponentFormat fp = getScriptObject().getComponentFormat();
if (fp == null) {
bodyText = Text.processTags((String) val, resolver);
} else {
bodyText = Text.processTags(TagResolver.formatObject(val, application.getLocale(), fp.parsedFormat, (fp.parsedFormat.getDisplayFormat() != null ? new ServoyMaskFormatter(fp.parsedFormat.getDisplayFormat(), true) : null)), resolver);
}
} catch (ParseException e) {
Debug.error(e);
}
}
} else {
bodyText = Text.processTags(tagText, resolver);
}
if (bodyText != null) {
if (HtmlUtils.startsWithHtml(bodyText)) {
bodyText = StripHTMLTagsConverter.convertBodyText(this, bodyText, getScriptObject().trustDataAsHtml(), application.getFlattenedSolution()).getBodyTxt();
} else {
// convert the text
final IConverter converter = getConverter(String.class);
bodyText = converter.convertToString(bodyText, getLocale());
}
}
} else {
Object modelObject = getModelObject();
if (modelObject instanceof byte[]) {
setIcon((byte[]) modelObject);
} else if (icon != null) {
setIcon(null);
} else {
ComponentFormat cf = getScriptObject().getComponentFormat();
if (cf == null) {
bodyText = Text.processTags(getDefaultModelObjectAsString(), resolver);
} else {
try {
bodyText = TagResolver.formatObject(modelObject, application.getLocale(), cf.parsedFormat, (cf.parsedFormat.getDisplayFormat() != null ? new ServoyMaskFormatter(cf.parsedFormat.getDisplayFormat(), true) : null));
} catch (ParseException e) {
Debug.error(e);
}
}
if (HtmlUtils.startsWithHtml(modelObject)) {
// ignore script/header contributions for now
bodyText = StripHTMLTagsConverter.convertBodyText(this, bodyText, getScriptObject().trustDataAsHtml(), application.getFlattenedSolution()).getBodyTxt();
}
}
}
if (model instanceof RecordItemModel) {
((RecordItemModel) model).updateRenderedValue(this);
}
}
use of com.servoy.j2db.component.ComponentFormat in project servoy-client by Servoy.
the class WebDataLabel method onBeforeRender.
/**
* @see org.apache.wicket.Component#onBeforeRender()
*/
@Override
protected void onBeforeRender() {
super.onBeforeRender();
IModel<?> model = getInnermostModel();
hasHTML = false;
if (needEntireState && model instanceof RecordItemModel) {
if (dataProviderID != null) {
Object val = getDefaultModelObject();
if (val instanceof byte[]) {
setIcon((byte[]) val);
} else if (icon != null) {
setIcon(null);
} else {
ComponentFormat cf = getComponentFormat();
if (cf == null) {
bodyText = Text.processTags((String) val, resolver);
} else {
try {
bodyText = Text.processTags(TagResolver.formatObject(val, application.getLocale(), cf.parsedFormat, (cf.parsedFormat.getDisplayFormat() != null ? new ServoyMaskFormatter(cf.parsedFormat.getDisplayFormat(), true) : null)), resolver);
} catch (ParseException e) {
Debug.error(e);
}
}
}
} else {
bodyText = Text.processTags(tagText, resolver);
}
if (bodyText != null) {
if (HtmlUtils.startsWithHtml(bodyText)) {
bodyText = StripHTMLTagsConverter.convertBodyText(this, bodyText, getScriptObject().trustDataAsHtml(), application.getFlattenedSolution()).getBodyTxt();
hasHTML = true;
} else {
// convert the text (strip html if needed)
final IConverter converter = getConverter(String.class);
bodyText = converter.convertToString(bodyText, getLocale());
}
}
} else {
Object modelObject = getDefaultModelObject();
if (modelObject instanceof byte[]) {
setIcon((byte[]) modelObject);
} else if (icon != null) {
setIcon(null);
} else {
ComponentFormat cf = getComponentFormat();
if (cf == null) {
bodyText = Text.processTags(getDefaultModelObjectAsString(), resolver);
} else {
try {
bodyText = TagResolver.formatObject(modelObject, application.getLocale(), cf.parsedFormat, (cf.parsedFormat.getDisplayFormat() != null ? new ServoyMaskFormatter(cf.parsedFormat.getDisplayFormat(), true) : null));
} catch (ParseException e) {
Debug.error(e);
}
}
if (HtmlUtils.startsWithHtml(modelObject)) {
// ignore script/header contributions for now
bodyText = StripHTMLTagsConverter.convertBodyText(this, bodyText, getScriptObject().trustDataAsHtml(), application.getFlattenedSolution()).getBodyTxt();
hasHTML = true;
}
}
}
if (model instanceof RecordItemModel) {
((RecordItemModel) model).updateRenderedValue(this);
}
}
use of com.servoy.j2db.component.ComponentFormat in project servoy-client by Servoy.
the class AbstractRuntimeLabel method setFormat.
public void setFormat(String formatString) {
String oldFormatString = getFormat();
if (!Utils.safeEquals(formatString, oldFormatString)) {
setComponentFormat(new ComponentFormat(FormatParser.parseFormatProperty(application.getI18NMessageIfPrefixed(formatString)), componentFormat == null ? IColumnTypes.TEXT : componentFormat.dpType, componentFormat == null ? IColumnTypes.TEXT : componentFormat.uiType));
firePropertyChange("format", oldFormatString, formatString);
getChangesRecorder().setChanged();
clearRenderableWrapperProperty(RenderableWrapper.PROPERTY_FORMAT);
fireOnRender();
}
}
use of com.servoy.j2db.component.ComponentFormat in project servoy-client by Servoy.
the class DataProviderEditor method fillDataProviderList.
protected void fillDataProviderList() {
try {
ITable table = null;
if (definedTable == null) {
FormManager fm = (FormManager) application.getFormManager();
FormController fc = fm.getCurrentMainShowingFormController();
if (fc != null) {
Form form = fc.getForm();
table = application.getFlattenedSolution().getTable(form.getDataSource());
}
} else {
if (!showRelatedOptionsOnly)
table = definedTable;
}
DefaultListModel model = (DefaultListModel) list.getModel();
model.removeAllElements();
if (showNoneOption)
model.addElement("-none-");
if (!showColumnsOnly)
model.addElement("*columns");
Object o = relationsComboBox.getSelectedItem();
if (o != null) {
if (o instanceof String) {
// table = form.getTable();
} else {
table = application.getFlattenedSolution().getTable(((Relation) o).getForeignDataSource());
}
if (table != null) {
Iterator<Column> it = table.getColumnsSortedByName();
while (it.hasNext()) {
IColumn c = it.next();
ColumnInfo ci = c.getColumnInfo();
if (ci != null && ci.isExcluded()) {
continue;
}
if (hideMediaColumns) {
// use dataprovider type as defined by column converter
ComponentFormat componentFormat = ComponentFormat.getComponentFormat(null, c, application);
if (componentFormat.dpType == IColumnTypes.MEDIA) {
continue;
}
}
model.addElement(c);
}
}
}
FlattenedSolution s = application.getFlattenedSolution();
if (table != null && !showColumnsOnly) {
Iterator it = s.getScriptCalculations(table, true);
if (it.hasNext()) {
model.addElement("*calculations");
}
while (it.hasNext()) {
ScriptCalculation sc = (ScriptCalculation) it.next();
for (int i = 0; i < model.size(); i++) {
Object obj = model.elementAt(i);
if (obj instanceof IDataProvider) {
IDataProvider dp = (IDataProvider) obj;
if (dp.getDataProviderID().equals(sc.getDataProviderID())) {
// remove the column from the list if use by
model.remove(i);
// stored calc
break;
}
}
}
model.addElement(sc);
}
Iterator it2 = s.getScriptVariables(true);
if (it2.hasNext()) {
model.addElement("*globals");
}
while (it2.hasNext()) {
model.addElement(it2.next());
}
Iterator it3 = s.getAggregateVariables(table, true);
if (it3.hasNext()) {
model.addElement("*aggregates");
}
while (it3.hasNext()) {
model.addElement(it3.next());
}
}
if (table != null && showColumnsOnly && showSortableOnly) {
Iterator it3 = s.getAggregateVariables(table, true);
while (it3.hasNext()) {
model.addElement(it3.next());
}
}
if (showGlobalsOption && showColumnsOnly) {
Iterator it2 = s.getScriptVariables(true);
if (it2.hasNext()) {
model.addElement("*globals");
}
while (it2.hasNext()) {
model.addElement(it2.next());
}
}
} catch (Exception ex) {
Debug.error(ex);
}
}
use of com.servoy.j2db.component.ComponentFormat in project servoy-client by Servoy.
the class DataButton method setValueObject.
public void setValueObject(Object obj) {
if (needEntireState) {
if (resolver != null) {
if (dataProviderID != null) {
try {
ComponentFormat cf = getScriptObject().getComponentFormat();
setText(Text.processTags(obj != null ? TagResolver.formatObject(obj, application.getLocale(), cf.parsedFormat, (cf.parsedFormat.getDisplayFormat() != null ? new ServoyMaskFormatter(cf.parsedFormat.getDisplayFormat(), true) : null)) : "", resolver));
} catch (ParseException e) {
Debug.error(e);
}
} else {
setText(Text.processTags(tagText, resolver));
}
} else {
// $NON-NLS-1$
setText("");
}
if (tooltip != null) {
// empty tooltip will unregister from tooltip manager //$NON-NLS-1$
super.setToolTipText("button");
}
} else {
if (obj != null) {
if (obj instanceof byte[]) {
setIcon((byte[]) obj);
} else {
ComponentFormat cf = getScriptObject().getComponentFormat();
try {
setText(TagResolver.formatObject(obj, application.getLocale(), cf.parsedFormat, (cf.parsedFormat.getDisplayFormat() != null ? new ServoyMaskFormatter(cf.parsedFormat.getDisplayFormat(), true) : null)));
} catch (ParseException e) {
Debug.error(e);
}
}
} else {
if (value instanceof byte[]) {
setIcon((Icon) null);
} else if (value != null) {
// $NON-NLS-1$
setText("");
}
}
this.value = obj;
}
fireOnRender(false);
}
Aggregations