use of com.twinsoft.convertigo.beans.ngx.components.MobileSmartSourceType in project convertigo by convertigo.
the class ComponentManager method loadBean.
public static IonBean loadBean(String jsonString) throws Exception {
JSONObject jsonBean = new JSONObject(jsonString);
String modelName = "Unknown";
if (jsonBean.has(IonBean.Key.name.name())) {
modelName = jsonBean.getString(IonBean.Key.name.name());
}
final IonBean model = instance.bCache.get(modelName);
// The model exists
if (model != null) {
boolean hasChanged = false;
IonBean dboBean = new IonBean(jsonString);
IonBean ionBean = new IonBean(model.toString());
for (IonProperty ionProperty : ionBean.getProperties().values()) {
String propertyName = ionProperty.getName();
IonProperty dboProperty = dboBean.getProperty(propertyName);
if (dboProperty != null) {
MobileSmartSourceType msst = dboProperty.getSmartType();
if (msst != null) {
ionProperty.setSmartType(msst);
ionBean.putProperty(ionProperty);
}
} else {
System.out.println("(ComponentManager) Ion property \"" + propertyName + "\" not found for model \"" + modelName + "\": ignore it.");
if (Engine.isStarted) {
Engine.logBeans.warn("(ComponentManager) Ion property \"" + propertyName + "\" not found for model \"" + modelName + "\": ignore it.");
}
hasChanged = true;
}
}
if (hasChanged) {
// TODO
}
return ionBean;
} else // The model doesn't exist (anymore)
{
System.out.println("(ComponentManager) Model \"" + modelName + "\" does not exist anymore in cache (" + jsonString + ").");
if (Engine.isStarted) {
Engine.logBeans.warn("(ComponentManager) Model \"" + modelName + "\" does not exist anymore in cache (" + jsonString + ").");
}
return new IonBean(jsonString);
}
}
use of com.twinsoft.convertigo.beans.ngx.components.MobileSmartSourceType in project convertigo by convertigo.
the class IonProperty method getSmartType.
public MobileSmartSourceType getSmartType() {
MobileSmartSourceType msst = new MobileSmartSourceType() {
private static final long serialVersionUID = 5907963275354985836L;
@Override
public Object getEditorData() {
String smartValue = getSmartValue();
return smartValue.equals("not set") ? "" : super.getEditorData();
}
};
String mode = getMode();
msst.setMode(Mode.valueOf(mode.toUpperCase()));
Object value = getValue();
msst.setSmartValue(value.equals(false) ? "not set" : value.toString());
return msst;
}
use of com.twinsoft.convertigo.beans.ngx.components.MobileSmartSourceType in project convertigo by convertigo.
the class IonProperty method getSmartValue.
public String getSmartValue() {
MobileSmartSourceType msst = getSmartType();
String value = msst.getValue();
if (isAttrPropertyBind()) {
if (Mode.PLAIN.equals(msst.getMode())) {
if (!value.startsWith("'") && !value.endsWith("'")) {
value = "'" + MobileSmartSourceType.escapeStringForTpl(value) + "'";
}
}
} else if (isAttrEventBind()) {
} else {
if (!Mode.PLAIN.equals(msst.getMode())) {
value = "{{" + value + "}}";
}
}
return value;
}
use of com.twinsoft.convertigo.beans.ngx.components.MobileSmartSourceType in project convertigo by convertigo.
the class NgxUIComponentTreeObject method setPropertyValue.
@Override
public void setPropertyValue(Object id, Object value) {
DatabaseObject dbo = getObject();
if (dbo instanceof UIDynamicElement) {
IonBean ionBean = ((UIDynamicElement) dbo).getIonBean();
if (ionBean != null) {
if (ionBean.hasProperty((String) id)) {
if (value != null) {
if (value instanceof String) {
value = new MobileSmartSourceType((String) value);
}
Object oldValue = ionBean.getPropertyValue((String) id);
if (!value.equals(oldValue)) {
ionBean.setPropertyValue((String) id, value);
TreeViewer viewer = (TreeViewer) getAdapter(TreeViewer.class);
hasBeenModified(true);
viewer.update(this, null);
TreeObjectEvent treeObjectEvent = new TreeObjectEvent(this, (String) id, oldValue, value);
ConvertigoPlugin.projectManager.getProjectExplorerView().fireTreeObjectPropertyChanged(treeObjectEvent);
return;
}
}
}
}
}
if (dbo instanceof UIAppGuard) {
UIAppGuard dboGuard = (UIAppGuard) dbo;
if ("guardType".equals(id)) {
String guardType = (String) value;
if (!guardType.equals(dboGuard.getGuardType().name())) {
if (dboGuard.getApplication().hasGuard(AppGuardType.valueOf(guardType))) {
return;
}
}
}
}
super.setPropertyValue(id, value);
}
use of com.twinsoft.convertigo.beans.ngx.components.MobileSmartSourceType in project convertigo by convertigo.
the class NgxPickerComposite method lookupModelData.
private Map<String, Object> lookupModelData(TVObject tvObject) {
Map<String, Object> data = new HashMap<String, Object>();
Map<String, String> params = new HashMap<String, String>();
DatabaseObject dbo = null;
String searchPath = "";
Object object = tvObject.getObject();
JSONObject infos = tvObject.getInfos();
if (object != null) {
try {
if (object instanceof RequestableObject) {
dbo = (RequestableObject) object;
searchPath = "";
} else if (object instanceof DesignDocument) {
dbo = (DesignDocument) object;
DesignDocument dd = (DesignDocument) dbo;
params.put("ddoc", dd.getName());
params.put("view", tvObject.getParent().getName());
params.put("include_docs", infos.has("include_docs") ? infos.getString("include_docs") : "false");
searchPath = tvObject.getName().startsWith("get") ? ".rows.value" : "";
} else if (object instanceof UIControlDirective) {
dbo = (UIControlDirective) object;
do {
UIControlDirective directive = (UIControlDirective) dbo;
String rootDboName = "";
if (directive.getPage() != null) {
rootDboName = directive.getPage().getName();
} else if (directive.getMenu() != null) {
rootDboName = directive.getMenu().getName();
}
MobileSmartSourceType msst = directive.getSourceSmartType();
MobileSmartSource mss = msst.getSmartSource();
if (mss != null) {
dbo = mss.getDatabaseObject(rootDboName);
params.putAll(mss.getParameters());
searchPath = mss.getModelPath().replaceAll("\\?\\.", ".") + searchPath;
} else {
dbo = null;
}
} while (dbo != null && dbo instanceof UIControlDirective);
} else if (object instanceof UIForm) {
dbo = (UIForm) object;
searchPath = "";
} else if (object instanceof ApplicationComponent) {
dbo = (ApplicationComponent) object;
params.put("json", infos.toString());
searchPath = "";
} else if (object instanceof UIActionStack) {
dbo = (UIActionStack) object;
searchPath = "";
} else if (object instanceof IAction) {
if (object instanceof UIDynamicAction) {
dbo = (UIDynamicAction) object;
searchPath = "";
} else if (object instanceof UICustomAction) {
dbo = (UICustomAction) object;
searchPath = "";
}
} else if (object instanceof UISharedComponent) {
dbo = (UISharedComponent) object;
searchPath = "";
}
} catch (Exception e) {
e.printStackTrace();
}
}
data.put("databaseObject", dbo);
data.put("params", params);
data.put("searchPath", searchPath);
return data;
}
Aggregations