use of com.twinsoft.convertigo.beans.ngx.components.UIComponent in project convertigo by convertigo.
the class NgxUIComponentTreeObject 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;
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;
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;
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.ngx.components.UIComponent 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;
}
}
}
} 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();
}
}
}
use of com.twinsoft.convertigo.beans.ngx.components.UIComponent in project convertigo by convertigo.
the class NgxUIComponentTreeObject method treeObjectRemoved.
@Override
public void treeObjectRemoved(TreeObjectEvent treeObjectEvent) {
super.treeObjectRemoved(treeObjectEvent);
TreeObject treeObject = (TreeObject) treeObjectEvent.getSource();
Set<Object> done = checkDone(treeObjectEvent);
if (treeObject instanceof DatabaseObjectTreeObject) {
DatabaseObjectTreeObject deletedTreeObject = (DatabaseObjectTreeObject) treeObject;
try {
if (deletedTreeObject != null && this.equals(deletedTreeObject.getParentDatabaseObjectTreeObject())) {
UIComponent currentDbo = getObject();
UIActionStack uisa = currentDbo.getSharedAction();
UISharedComponent uisc = currentDbo.getSharedComponent();
if (uisa != null) {
notifyDataseObjectPropertyChanged(uisa, "", null, null, done);
} else if (uisc != null) {
notifyDataseObjectPropertyChanged(uisc, "", null, null, done);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
use of com.twinsoft.convertigo.beans.ngx.components.UIComponent in project convertigo by convertigo.
the class NgxUIComponentTreeObject 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);
refactorSmartSources(treeObjectEvent);
if (treeObject instanceof DatabaseObjectTreeObject) {
DatabaseObjectTreeObject doto = (DatabaseObjectTreeObject) treeObject;
DatabaseObject dbo = doto.getObject();
try {
if (this.equals(treeObject)) {
markMainAsDirty(getObject(), done);
UIActionStack uisa = ((UIComponent) dbo).getSharedAction();
UISharedComponent uisc = ((UIComponent) dbo).getSharedComponent();
if (uisa != null && !uisa.equals(getObject())) {
notifyDataseObjectPropertyChanged(uisa, "", null, null, done);
}
if (uisc != null && !uisc.equals(getObject())) {
notifyDataseObjectPropertyChanged(uisc, "", null, null, done);
}
} else {
if (propertyName.equals("name")) {
handlesBeanNameChanged(treeObjectEvent);
}
if (dbo instanceof UIActionStack) {
handleSharedActionChanged((UIActionStack) dbo, done);
} else if (dbo instanceof UISharedComponent) {
handleSharedComponentChanged((UISharedComponent) dbo, done);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
use of com.twinsoft.convertigo.beans.ngx.components.UIComponent in project convertigo by convertigo.
the class NgxUIComponentTreeObject method launchEditor.
@Override
public void launchEditor(String editorType) {
UIComponent uic = getObject();
if (uic instanceof UICustom) {
openHtmlFileEditor();
} else if (uic instanceof UIStyle) {
openCssFileEditor();
} else if (uic instanceof UICustomAction) {
String functionMarker = "function:" + ((UICustomAction) uic).getActionName();
editFunction(uic, functionMarker, "actionValue");
} else {
super.launchEditor(editorType);
}
}
Aggregations