use of org.sablo.BaseWebObject in project servoy-client by Servoy.
the class DataAdapterList method setFindMode.
@Override
public void setFindMode(boolean findMode) {
if (this.findMode != findMode) {
this.findMode = findMode;
((BaseWebObject) formController.getFormUI()).setProperty("findmode", findMode);
for (IFindModeAwarePropertyValue x : findModeAwareProperties) {
x.findModeChanged(findMode);
}
}
}
use of org.sablo.BaseWebObject in project servoy-client by Servoy.
the class WebServiceScriptable method put.
@Override
public void put(String name, Scriptable start, Object value) {
PropertyDescription desc = serviceSpecification.getProperty(name);
BaseWebObject service = (BaseWebObject) application.getWebsocketSession().getClientService(serviceSpecification.getName());
if (desc != null) {
Object previousVal = service.getProperty(name);
Object val = NGConversions.INSTANCE.convertRhinoToSabloComponentValue(value, previousVal, desc, service);
if (val != previousVal)
service.setProperty(name, val);
} else {
WebObjectFunctionDefinition apiFunction = serviceSpecification.getApiFunction(name);
// don't allow api to be overwritten.
if (apiFunction != null)
return;
// TODO conversion should happen from string (color representation) to Color object.
// DesignConversion.toObject(value, type)
service.setProperty(name, value);
}
}
use of org.sablo.BaseWebObject in project servoy-client by Servoy.
the class RecordPropertyType method fromJSON.
@Override
public IRecordInternal fromJSON(Object newJSONValue, IRecordInternal previousSabloValue, PropertyDescription pd, IBrowserConverterContext dataConverterContext, ValueReference<Boolean> returnValueAdjustedIncommingValue) {
IRecordInternal record = null;
if (newJSONValue instanceof JSONObject) {
JSONObject jsonRecord = (JSONObject) newJSONValue;
BaseWebObject webObject = dataConverterContext.getWebObject();
if (webObject != null && jsonRecord.has(FoundsetTypeSabloValue.ROW_ID_COL_KEY)) {
String rowIDValue = jsonRecord.optString(FoundsetTypeSabloValue.ROW_ID_COL_KEY);
Pair<String, Integer> splitHashAndIndex = FoundsetTypeSabloValue.splitPKHashAndIndex(rowIDValue);
if (jsonRecord.has(FoundsetTypeSabloValue.FOUNDSET_ID)) {
int foundsetID = Utils.getAsInteger(jsonRecord.get(FoundsetTypeSabloValue.FOUNDSET_ID));
if (foundsetID >= 0 && webObject instanceof IContextProvider) {
IFoundSetInternal foundset = ((IContextProvider) webObject).getDataConverterContext().getApplication().getFoundSetManager().findFoundset(foundsetID);
if (foundset != null) {
int recordIndex = foundset.getRecordIndex(splitHashAndIndex.getLeft(), splitHashAndIndex.getRight().intValue());
if (recordIndex != -1) {
return foundset.getRecord(recordIndex);
}
}
}
}
Collection<PropertyDescription> properties = webObject.getSpecification().getProperties(FoundsetPropertyType.INSTANCE);
for (PropertyDescription foundsetPd : properties) {
FoundsetTypeSabloValue fsSablo = (FoundsetTypeSabloValue) webObject.getProperty(foundsetPd.getName());
int recordIndex = fsSablo.getFoundset().getRecordIndex(splitHashAndIndex.getLeft(), splitHashAndIndex.getRight().intValue());
if (recordIndex != -1) {
record = fsSablo.getFoundset().getRecord(recordIndex);
break;
}
}
}
if (// $NON-NLS-1$
record == null && jsonRecord.has("recordhash")) {
// $NON-NLS-1$
record = getReference(jsonRecord.optString("recordhash"));
}
}
return record;
}
use of org.sablo.BaseWebObject in project servoy-client by Servoy.
the class JSDNDEventType method fromJSON.
@Override
public JSDNDEvent fromJSON(Object newJSONValue, JSDNDEvent previousSabloValue, PropertyDescription pd, IBrowserConverterContext dataConverterContext, ValueReference<Boolean> returnValueAdjustedIncommingValue) {
JSDNDEvent event = null;
if (newJSONValue instanceof JSONObject) {
JSONObject jsonObject = (JSONObject) newJSONValue;
// $NON-NLS-1$
event = getReference(jsonObject.optString("jseventhash"));
if (event == null) {
BaseWebObject webObject = dataConverterContext.getWebObject();
event = new JSDNDEvent();
JSEventType.fillJSEvent(event, jsonObject, webObject, null);
}
}
return event;
}
use of org.sablo.BaseWebObject in project servoy-client by Servoy.
the class FormatPropertyType method writeComponentFormatToJSON.
public JSONWriter writeComponentFormatToJSON(JSONWriter writer, String key, ComponentFormat format, DataConversion dataConversions, IBrowserConverterContext dataConverterContext) {
Map<String, Object> map = new HashMap<>();
String type = Column.getDisplayTypeString(format.uiType);
map.put("type", type);
boolean isMask = format.parsedFormat.isMask();
boolean isAllUppercase = format.parsedFormat.isAllUpperCase();
boolean isAllLowercase = format.parsedFormat.isAllLowerCase();
String placeHolder = null;
if (format.parsedFormat.getPlaceHolderString() != null)
placeHolder = format.parsedFormat.getPlaceHolderString();
else if (format.parsedFormat.getPlaceHolderCharacter() != 0)
placeHolder = Character.toString(format.parsedFormat.getPlaceHolderCharacter());
String mask = format.parsedFormat.getEditFormat();
if (isMask && type.equals("DATETIME")) {
mask = format.parsedFormat.getDateMask();
if (placeHolder == null)
placeHolder = format.parsedFormat.getDisplayFormat();
} else if (format.parsedFormat.getDisplayFormat() != null && type.equals("TEXT")) {
isMask = true;
mask = format.parsedFormat.getDisplayFormat();
}
map.put("isMask", Boolean.valueOf(isMask));
map.put("isRaw", Boolean.valueOf(format.parsedFormat.isRaw()));
map.put("edit", mask);
map.put("placeHolder", placeHolder);
map.put("allowedCharacters", format.parsedFormat.getAllowedCharacters());
map.put("display", format.parsedFormat.getDisplayFormat());
map.put("isNumberValidator", Boolean.valueOf(format.parsedFormat.isNumberValidator()));
if (type.equals("NUMBER") || type.equals("INTEGER") || format.parsedFormat.isNumberValidator()) {
BaseWebObject webObject = dataConverterContext.getWebObject();
Locale clientLocale;
if (webObject instanceof IContextProvider) {
clientLocale = ((IContextProvider) webObject).getDataConverterContext().getApplication().getLocale();
} else {
Debug.warn("Cannot get client locale for : " + webObject.toString() + " , using system default");
clientLocale = Locale.getDefault();
}
DecimalFormatSymbols dfs = RoundHalfUpDecimalFormat.getDecimalFormatSymbols(clientLocale);
// the commented out values are already available client-side in numeral.localeData(); they are taken from there now
// map.put("decimalSeparator", String.valueOf(dfs.getDecimalSeparator()));
// map.put("groupingSeparator", String.valueOf(dfs.getGroupingSeparator()));
// map.put("currencySymbol", dfs.getCurrencySymbol());
map.put("percent", String.valueOf(dfs.getPercent()));
}
if (format.parsedFormat.getMaxLength() != null) {
map.put("maxLength", format.parsedFormat.getMaxLength());
}
if (isAllUppercase)
map.put("uppercase", Boolean.valueOf(isAllUppercase));
else if (isAllLowercase)
map.put("lowercase", Boolean.valueOf(isAllLowercase));
// here dataConversions is not used I think, could be null
return JSONUtils.toBrowserJSONFullValue(writer, key, map, null, dataConversions, null);
}
Aggregations