use of com.twinsoft.convertigo.beans.core.DatabaseObject in project convertigo by convertigo.
the class MobileUIComponentTreeObject method formatStyleContent.
private String formatStyleContent(UIStyle ms) {
String formated = ms.getStyleContent().getString();
DatabaseObject parentDbo = ms.getParent();
if (parentDbo != null && parentDbo instanceof UIElement) {
String dboTagClass = ((UIElement) parentDbo).getTagClass();
if (formated.isEmpty()) {
formated = String.format("." + dboTagClass + " {%n%s%n}", formated);
} else {
formated = String.format("." + dboTagClass + " {%n%s}", formated);
}
}
return formated;
}
use of com.twinsoft.convertigo.beans.core.DatabaseObject in project convertigo by convertigo.
the class MobileUIComponentTreeObject 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;
}
}
}
}
}
super.setPropertyValue(id, value);
}
use of com.twinsoft.convertigo.beans.core.DatabaseObject in project convertigo by convertigo.
the class MobileUIComponentTreeObject method handlesBeanNameChanged.
protected void handlesBeanNameChanged(TreeObjectEvent treeObjectEvent) {
DatabaseObjectTreeObject treeObject = (DatabaseObjectTreeObject) treeObjectEvent.getSource();
DatabaseObject databaseObject = (DatabaseObject) treeObject.getObject();
Object oldValue = treeObjectEvent.oldValue;
Object newValue = treeObjectEvent.newValue;
int update = treeObjectEvent.update;
if (update != TreeObjectEvent.UPDATE_NONE) {
// Case a UIStackVariable has been renamed
if (databaseObject instanceof UIStackVariable) {
UIStackVariable variable = (UIStackVariable) databaseObject;
UIActionStack stack = variable.getSharedAction();
if (stack != null) {
// rename variable for InvokeAction
if (getObject() instanceof UIDynamicInvoke) {
UIDynamicInvoke udi = (UIDynamicInvoke) getObject();
if (udi.getSharedActionQName().equals(stack.getQName())) {
boolean isLocalProject = variable.getProject().equals(udi.getProject());
boolean isSameValue = variable.getName().equals(oldValue);
boolean shouldUpdate = (update == TreeObjectEvent.UPDATE_ALL) || ((update == TreeObjectEvent.UPDATE_LOCAL) && (isLocalProject));
if (!isSameValue && shouldUpdate) {
Iterator<UIComponent> it = udi.getUIComponentList().iterator();
while (it.hasNext()) {
UIComponent component = (UIComponent) it.next();
if (component instanceof UIControlVariable) {
UIControlVariable uicv = (UIControlVariable) component;
if (uicv.getName().equals(oldValue)) {
try {
uicv.setName((String) newValue);
uicv.hasChanged = true;
hasBeenModified(true);
viewer.refresh();
markMainAsDirty(udi);
notifyDataseObjectPropertyChanged(uicv, "name", oldValue, newValue, new HashSet<Object>());
break;
} catch (EngineException e) {
ConvertigoPlugin.logException(e, "Unable to refactor the references of '" + newValue + "' variable for InvokeAction !");
}
}
}
}
}
}
}
}
}
// Case a UICompVariable has been renamed
if (databaseObject instanceof UICompVariable) {
UICompVariable variable = (UICompVariable) databaseObject;
UISharedComponent comp = variable.getSharedComponent();
if (comp != null) {
// rename variable for UseShared
if (getObject() instanceof UIUseShared) {
UIUseShared uus = (UIUseShared) getObject();
if (uus.getSharedComponentQName().equals(comp.getQName())) {
boolean isLocalProject = variable.getProject().equals(uus.getProject());
boolean isSameValue = variable.getName().equals(oldValue);
boolean shouldUpdate = (update == TreeObjectEvent.UPDATE_ALL) || ((update == TreeObjectEvent.UPDATE_LOCAL) && (isLocalProject));
if (!isSameValue && shouldUpdate) {
Iterator<UIComponent> it = uus.getUIComponentList().iterator();
while (it.hasNext()) {
UIComponent component = (UIComponent) it.next();
if (component instanceof UIControlVariable) {
UIControlVariable uicv = (UIControlVariable) component;
if (uicv.getName().equals(oldValue)) {
try {
uicv.setName((String) newValue);
uicv.hasChanged = true;
hasBeenModified(true);
viewer.refresh();
markMainAsDirty(uus);
notifyDataseObjectPropertyChanged(uicv, "name", oldValue, newValue, new HashSet<Object>());
break;
} catch (EngineException e) {
ConvertigoPlugin.logException(e, "Unable to refactor the references of '" + newValue + "' variable for UseShared !");
}
}
}
}
}
}
}
}
} else // Case a RequestableVariable has been renamed
if (databaseObject instanceof RequestableVariable) {
RequestableVariable variable = (RequestableVariable) databaseObject;
DatabaseObject parent = variable.getParent();
if (getObject() instanceof UIDynamicAction) {
UIDynamicAction uia = (UIDynamicAction) getObject();
IonBean ionBean = uia.getIonBean();
if (ionBean != null) {
// rename variable for CallSequenceAction
if (ionBean.getName().equals("CallSequenceAction")) {
Object p_val = ionBean.getProperty("requestable").getValue();
if (!p_val.equals(false)) {
if (parent.getQName().equals(p_val.toString())) {
boolean isLocalProject = variable.getProject().equals(uia.getProject());
boolean isSameValue = variable.getName().equals(oldValue);
boolean shouldUpdate = (update == TreeObjectEvent.UPDATE_ALL) || ((update == TreeObjectEvent.UPDATE_LOCAL) && (isLocalProject));
if (!isSameValue && shouldUpdate) {
Iterator<UIComponent> it = uia.getUIComponentList().iterator();
while (it.hasNext()) {
UIComponent component = (UIComponent) it.next();
if (component instanceof UIControlVariable) {
UIControlVariable uicv = (UIControlVariable) component;
if (uicv.getName().equals(oldValue)) {
try {
uicv.setName((String) newValue);
uicv.hasChanged = true;
hasBeenModified(true);
viewer.refresh();
markMainAsDirty(uia);
notifyDataseObjectPropertyChanged(uicv, "name", oldValue, newValue, new HashSet<Object>());
break;
} catch (EngineException e) {
ConvertigoPlugin.logException(e, "Unable to refactor the references of '" + newValue + "' variable for CallSequenceAction !");
}
}
}
}
}
}
}
}
}
}
}
}
}
use of com.twinsoft.convertigo.beans.core.DatabaseObject in project convertigo by convertigo.
the class NgxApplicationComponentTreeObject method treeObjectPropertyChanged.
@Override
public void treeObjectPropertyChanged(TreeObjectEvent treeObjectEvent) {
super.treeObjectPropertyChanged(treeObjectEvent);
TreeObject treeObject = (TreeObject) treeObjectEvent.getSource();
Set<Object> done = checkDone(treeObjectEvent);
String propertyName = (String) treeObjectEvent.propertyName;
propertyName = ((propertyName == null) ? "" : propertyName);
Object oldValue = treeObjectEvent.oldValue;
Object newValue = treeObjectEvent.newValue;
if (treeObject instanceof DatabaseObjectTreeObject) {
DatabaseObjectTreeObject doto = (DatabaseObjectTreeObject) treeObject;
DatabaseObject dbo = doto.getObject();
try {
ApplicationComponent ac = getObject();
// for Page or Menu or Route
if (ac.equals(dbo.getParent())) {
markApplicationAsDirty(done);
} else // for any component inside a route
if (ac.equals(dbo.getParent().getParent())) {
markApplicationAsDirty(done);
} else // for any UI component inside a menu or a stack
if (dbo instanceof UIComponent) {
UIComponent uic = (UIComponent) dbo;
UIDynamicMenu menu = uic.getMenu();
if (menu != null) {
if (ac.equals(menu.getParent())) {
// 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 (menu.updateSmartSource(form+"\\?\\.controls\\['"+oldSmart+"'\\]", form+"?.controls['"+newSmart+"']")) {
// this.viewer.refresh();
// }
// }
// } catch (Exception e) {}
// }
// }
markApplicationAsDirty(done);
}
}
} else // for this application
if (this.equals(doto)) {
if (propertyName.equals("isPWA")) {
if (!newValue.equals(oldValue)) {
markPwaAsDirty();
}
} else if (propertyName.equals("componentScriptContent")) {
if (!newValue.equals(oldValue)) {
markComponentTsAsDirty();
markApplicationAsDirty(done);
}
} else if (propertyName.equals("useClickForTap")) {
for (TreeObject to : this.getChildren()) {
if (to instanceof ObjectsFolderTreeObject) {
ObjectsFolderTreeObject ofto = (ObjectsFolderTreeObject) to;
if (ofto.folderType == ObjectsFolderTreeObject.FOLDER_TYPE_PAGES) {
for (TreeObject cto : ofto.getChildren()) {
if (cto instanceof NgxPageComponentTreeObject) {
((NgxPageComponentTreeObject) cto).markPageAsDirty(done);
}
}
}
}
}
markApplicationAsDirty(done);
} else if (propertyName.equals("tplProjectName")) {
// close app editor and reinitialize builder
Project project = ac.getProject();
closeAllEditors(false);
MobileBuilder.releaseBuilder(project);
MobileBuilder.initBuilder(project);
IProject iproject = ConvertigoPlugin.getDefault().getProjectPluginResource(project.getName());
iproject.refreshLocal(IResource.DEPTH_INFINITE, null);
// force app sources regeneration
for (TreeObject to : this.getChildren()) {
if (to instanceof ObjectsFolderTreeObject) {
ObjectsFolderTreeObject ofto = (ObjectsFolderTreeObject) to;
if (ofto.folderType == ObjectsFolderTreeObject.FOLDER_TYPE_PAGES) {
for (TreeObject cto : ofto.getChildren()) {
if (cto instanceof NgxPageComponentTreeObject) {
((NgxPageComponentTreeObject) cto).markPageAsDirty(done);
}
}
}
}
}
markApplicationAsDirty(done);
// delete node modules and alert user
final File nodeModules = new File(project.getDirPath(), "/_private/ionic/node_modules");
if (nodeModules.exists()) {
ProgressMonitorDialog dialog = new ProgressMonitorDialog(ConvertigoPlugin.getMainShell());
dialog.open();
dialog.run(true, false, new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
monitor.beginTask("deleting node modules", IProgressMonitor.UNKNOWN);
String alert = "template changed!";
if (com.twinsoft.convertigo.engine.util.FileUtils.deleteQuietly(nodeModules)) {
alert = "You have just changed the template.\nPackages have been deleted and will be reinstalled next time you run your application again.";
} else {
alert = "You have just changed the template: packages could not be deleted!\nDo not forget to reinstall the packages before running your application again, otherwise it may be corrupted!";
}
monitor.done();
ConvertigoPlugin.infoMessageBox(alert);
}
});
}
} else {
markApplicationAsDirty(done);
}
}
} catch (Exception e) {
}
}
}
use of com.twinsoft.convertigo.beans.core.DatabaseObject in project convertigo by convertigo.
the class NgxUIComponentTreeObject 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;
// 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;
if (getObject().updateSmartSource("\\." + oldName + "\\b", "." + newName)) {
sourcesUpdated = true;
}
} catch (Exception e) {
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
if (dbo instanceof UIComponent) {
UIComponent uic = (UIComponent) dbo;
if (hasSameScriptComponent(getObject(), uic)) {
// A ControlName property has changed
if (propertyName.equals("ControlName") || uic.isFormControlAttribute()) {
if (!newValue.equals(oldValue)) {
try {
String oldSmart = ((MobileSmartSourceType) oldValue).getSmartValue();
String newSmart = ((MobileSmartSourceType) newValue).getSmartValue();
if (uic.getUIForm() != null) {
if (getObject().updateSmartSource("\\?\\.controls\\['" + oldSmart + "'\\]", "?.controls['" + newSmart + "']")) {
sourcesUpdated = true;
}
}
} catch (Exception e) {
}
}
} else if (propertyName.equals("identifier")) {
if (!newValue.equals(oldValue)) {
try {
String oldId = (String) oldValue;
String newId = (String) newValue;
if (uic.getUIForm() != null) {
if (getObject().updateSmartSource("\"identifier\":\"" + oldId + "\"", "\"identifier\":\"" + newId + "\"")) {
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();
}
}
}
Aggregations