use of com.twinsoft.convertigo.beans.mobile.components.MobileSmartSourceType in project convertigo by convertigo.
the class MobileUIComponentTreeObject method refactorSmartSources.
protected void refactorSmartSources(TreeObjectEvent treeObjectEvent) {
TreeObject treeObject = (TreeObject) treeObjectEvent.getSource();
String propertyName = (String) treeObjectEvent.propertyName;
propertyName = ((propertyName == null) ? "" : propertyName);
Object oldValue = treeObjectEvent.oldValue;
Object newValue = treeObjectEvent.newValue;
if (getProjectTreeObject() == null) {
// System.out.println("dbo ignored because it has been deleted: "+ getObject().priority);
return;
}
// Case of DatabaseObjectTreeObject
if (treeObject instanceof DatabaseObjectTreeObject) {
DatabaseObjectTreeObject doto = (DatabaseObjectTreeObject) treeObject;
DatabaseObject dbo = doto.getObject();
try {
boolean sourcesUpdated = false;
// A bean name has changed
if (propertyName.equals("name")) {
boolean fromSameProject = getProjectTreeObject().equals(doto.getProjectTreeObject());
if ((treeObjectEvent.update == TreeObjectEvent.UPDATE_ALL) || ((treeObjectEvent.update == TreeObjectEvent.UPDATE_LOCAL) && fromSameProject)) {
try {
if (dbo instanceof Project) {
String oldName = (String) oldValue;
String newName = (String) newValue;
if (!newValue.equals(oldValue)) {
if (getObject().updateSmartSource("'" + oldName + "\\.", "'" + newName + ".")) {
sourcesUpdated = true;
}
if (getObject().updateSmartSource("\\/" + oldName + "\\.", "/" + newName + ".")) {
sourcesUpdated = true;
}
}
} else if (dbo instanceof Sequence) {
String oldName = (String) oldValue;
String newName = (String) newValue;
String projectName = dbo.getProject().getName();
if (!newValue.equals(oldValue)) {
if (getObject().updateSmartSource("'" + projectName + "\\." + oldName, "'" + projectName + "." + newName)) {
sourcesUpdated = true;
}
}
} else if (dbo instanceof FullSyncConnector) {
String oldName = (String) oldValue;
String newName = (String) newValue;
String projectName = dbo.getProject().getName();
if (!newValue.equals(oldValue)) {
if (getObject().updateSmartSource("\\/" + projectName + "\\." + oldName + "\\.", "/" + projectName + "." + newName + ".")) {
sourcesUpdated = true;
}
if (getObject().updateSmartSource("\\/" + oldName + "\\.", "/" + newName + ".")) {
sourcesUpdated = true;
}
}
} else if (dbo instanceof DesignDocument) {
String oldName = (String) oldValue;
String newName = (String) newValue;
if (!newValue.equals(oldValue)) {
if (getObject().updateSmartSource("ddoc='" + oldName + "'", "ddoc='" + newName + "'")) {
sourcesUpdated = true;
}
}
}
if (dbo instanceof UIComponent) {
if (!newValue.equals(oldValue)) {
try {
String oldName = (String) oldValue;
String newName = (String) newValue;
// SC mode
if (getObject().updateSmartSource("\\?\\." + oldName, "?." + newName)) {
sourcesUpdated = true;
}
// TS mode
if (getObject().getSharedComponent() != null) {
long priority = getObject().getSharedComponent().priority;
if (getObject().updateSmartSource("params" + priority + "\\." + oldName, "params" + priority + "." + newName)) {
sourcesUpdated = true;
}
}
} catch (Exception e) {
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
if (dbo instanceof UIComponent) {
UIComponent uic = (UIComponent) dbo;
if (hasSameScriptComponent(getObject(), uic)) {
// A FormControlName property has changed
if (propertyName.equals("FormControlName") || uic.isFormControlAttribute()) {
if (!newValue.equals(oldValue)) {
try {
String oldSmart = ((MobileSmartSourceType) oldValue).getSmartValue();
String newSmart = ((MobileSmartSourceType) newValue).getSmartValue();
if (uic.getUIForm() != null) {
String form = uic.getUIForm().getFormGroupName();
if (getObject().updateSmartSource(form + "\\?\\.controls\\['" + oldSmart + "'\\]", form + "?.controls['" + newSmart + "']")) {
sourcesUpdated = true;
}
}
} catch (Exception e) {
}
}
}
}
}
// Need TS regeneration
if (sourcesUpdated) {
hasBeenModified(true);
viewer.refresh();
markMainAsDirty(getObject());
}
} catch (Exception e) {
e.printStackTrace();
}
} else // Case of DesignDocumentViewTreeObject
if (treeObject instanceof DesignDocumentViewTreeObject) {
DesignDocumentViewTreeObject ddvto = (DesignDocumentViewTreeObject) treeObject;
try {
boolean sourcesUpdated = false;
// View name changed
if (propertyName.equals("name")) {
boolean fromSameProject = getProjectTreeObject().equals(ddvto.getProjectTreeObject());
if ((treeObjectEvent.update == TreeObjectEvent.UPDATE_ALL) || ((treeObjectEvent.update == TreeObjectEvent.UPDATE_LOCAL) && fromSameProject)) {
try {
String oldName = (String) oldValue;
String newName = (String) newValue;
if (!newValue.equals(oldValue)) {
if (getObject().updateSmartSource("view='" + oldName + "'", "view='" + newName + "'")) {
sourcesUpdated = true;
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
// Need TS regeneration
if (sourcesUpdated) {
hasBeenModified(true);
viewer.refresh();
markMainAsDirty(getObject());
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
use of com.twinsoft.convertigo.beans.mobile.components.MobileSmartSourceType in project convertigo by convertigo.
the class SharedComponentWizard method createControlVariable.
private UIControlVariable createControlVariable(String varName, String varValue) throws Exception {
MobileSmartSourceType var_msst = new MobileSmartSourceType();
var_msst.setMode(Mode.SCRIPT);
var_msst.setSmartValue(varValue);
UIControlVariable controlVariable = new UIControlVariable();
controlVariable.setName(varName);
controlVariable.setVarSmartType(var_msst);
controlVariable.hasChanged = true;
controlVariable.bNew = true;
return controlVariable;
}
use of com.twinsoft.convertigo.beans.mobile.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;
}
Aggregations