use of org.eclipse.scout.rt.platform.util.TriState in project scout.rt by eclipse.
the class JsonSmartField2 method initJsonProperties.
@Override
protected void initJsonProperties(MODEL model) {
super.initJsonProperties(model);
putJsonProperty(new JsonProperty<ISmartField2<VALUE>>(IValueField.PROP_VALUE, model) {
@Override
protected VALUE modelValue() {
return getModel().getValue();
}
@Override
@SuppressWarnings("unchecked")
public Object prepareValueForToJson(Object value) {
return JsonSmartField2.this.valueToJson((VALUE) value);
}
});
putJsonProperty(new JsonProperty<ISmartField2<VALUE>>(ISmartField2.PROP_RESULT, model) {
@Override
protected Object modelValue() {
return getModel().getResult();
}
@Override
@SuppressWarnings("unchecked")
public Object prepareValueForToJson(Object value) {
return resultToJson((SmartField2Result<VALUE>) value);
}
});
putJsonProperty(new JsonProperty<ISmartField2<VALUE>>(ISmartField2.PROP_LOOKUP_ROW, model) {
@Override
protected Object modelValue() {
return getModel().getLookupRow();
}
@Override
@SuppressWarnings("unchecked")
public Object prepareValueForToJson(Object value) {
return lookupRowToJson((LookupRow<VALUE>) value, hasMultipleColumns());
}
});
putJsonProperty(new JsonProperty<ISmartField2<VALUE>>(ISmartField2.PROP_BROWSE_MAX_ROW_COUNT, model) {
@Override
protected Integer modelValue() {
return getModel().getBrowseMaxRowCount();
}
});
putJsonProperty(new JsonProperty<ISmartField2<VALUE>>(ISmartField2.PROP_BROWSE_AUTO_EXPAND_ALL, model) {
@Override
protected Boolean modelValue() {
return getModel().isBrowseAutoExpandAll();
}
});
putJsonProperty(new JsonProperty<ISmartField2<VALUE>>(ISmartField2.PROP_BROWSE_LOAD_INCREMENTAL, model) {
@Override
protected Boolean modelValue() {
return getModel().isBrowseLoadIncremental();
}
});
putJsonProperty(new JsonProperty<ISmartField2<VALUE>>(ISmartField2.PROP_ACTIVE_FILTER_ENABLED, model) {
@Override
protected Boolean modelValue() {
return getModel().isActiveFilterEnabled();
}
});
putJsonProperty(new JsonProperty<ISmartField2<VALUE>>(ISmartField2.PROP_ACTIVE_FILTER, model) {
@Override
protected TriState modelValue() {
return getModel().getActiveFilter();
}
});
putJsonProperty(new JsonProperty<ISmartField2<VALUE>>(ISmartField2.PROP_ACTIVE_FILTER_LABELS, model) {
@Override
protected String[] modelValue() {
return getModel().getActiveFilterLabels();
}
@Override
public Object prepareValueForToJson(Object value) {
return new JSONArray(value);
}
});
putJsonProperty(new JsonProperty<ISmartField2<VALUE>>(ISmartField2.PROP_COLUMN_DESCRIPTORS, model) {
@Override
protected ColumnDescriptor[] modelValue() {
return getModel().getColumnDescriptors();
}
@Override
public Object prepareValueForToJson(Object value) {
return columnDescriptorsToJson(value);
}
});
}
use of org.eclipse.scout.rt.platform.util.TriState in project scout.rt by eclipse.
the class AbstractSmartField2 method callBrowseLookupInBackground.
@Override
public IFuture<List<ILookupRow<VALUE>>> callBrowseLookupInBackground(String browseHint, boolean cancelRunningJobs) {
TriState activeState = isActiveFilterEnabled() ? getActiveFilter() : TriState.TRUE;
final ILookupRowProvider<VALUE> provider = newByAllLookupRowProvider(browseHint, activeState);
return callInBackground(provider, cancelRunningJobs);
}
use of org.eclipse.scout.rt.platform.util.TriState in project scout.rt by eclipse.
the class AbstractSqlStyle method toPlainText.
@Override
public String toPlainText(Object value) {
if (value instanceof IHolder) {
value = ((IHolder) value).getValue();
}
//
if (value == null) {
return "null";
} else if (value instanceof Boolean) {
Boolean b = (Boolean) value;
return b ? "1" : "0";
} else if (value instanceof TriState) {
TriState t = (TriState) value;
return "" + t.toString();
} else if (value instanceof String) {
String s = (String) value;
if (s.length() > MAX_SQL_STRING_LENGTH) {
s = s.substring(0, MAX_SQL_STRING_LENGTH);
LOG.warn("toPlainText of a String with more than {} characters failed; truncated to '{}'", MAX_SQL_STRING_LENGTH, s);
return "'" + s.replaceAll("'", "''") + "'";
}
return "'" + s.replaceAll("'", "''") + "'";
} else if (value instanceof char[]) {
if (((char[]) value).length > MAX_SQL_STRING_LENGTH) {
String s = new String((char[]) value, 0, MAX_SQL_STRING_LENGTH);
LOG.warn("toPlainText of a CLOB with more than {} characters failed; truncated to '{}'", MAX_SQL_STRING_LENGTH, s);
return "'" + s.replaceAll("'", "''") + "'";
}
String s = new String((char[]) value);
return "'" + s.replaceAll("'", "''") + "'";
} else if (value instanceof byte[]) {
LOG.warn("toPlainText of a BLOB failed; using NULL");
return "NULL";
} else if (value instanceof Date) {
Date d = (Date) value;
SimpleDateFormat fmt = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
return "to_date('" + fmt.format(d) + "','dd.mm.yyyy hh24:mi:ss')";
} else if (value instanceof Collection || value.getClass().isArray()) {
Object array;
if (value instanceof Collection) {
array = ((Collection) value).toArray();
} else {
array = value;
}
int n = Array.getLength(array);
StringBuilder buf = new StringBuilder();
buf.append("(");
if (n > 0) {
for (int i = 0; i < n; i++) {
if (i > 0) {
buf.append(",");
}
buf.append(toPlainText(Array.get(array, i)));
}
} else {
buf.append("-1");
}
buf.append(")");
return buf.toString();
} else {
return value.toString();
}
}
use of org.eclipse.scout.rt.platform.util.TriState in project scout.rt by eclipse.
the class AbstractContentAssistField method callBrowseLookupInBackground.
@Override
public IFuture<List<ILookupRow<LOOKUP_KEY>>> callBrowseLookupInBackground(String browseHint, boolean cancelRunningJobs) {
TriState activeState = isActiveFilterEnabled() ? getActiveFilter() : TriState.TRUE;
final ILookupRowProvider<LOOKUP_KEY> provider = newByAllLookupRowProvider(browseHint, activeState);
return callInBackground(provider, cancelRunningJobs);
}
Aggregations