use of com.twinsoft.convertigo.beans.core.DatabaseObject in project convertigo by convertigo.
the class GenericTextEditor method openDialogBox.
@Override
protected Object openDialogBox(Control cellEditorWindow) {
if (dialogCompositeClass != TextEditorComposite.class) {
return super.openDialogBox(cellEditorWindow);
}
try {
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
if (activePage == null) {
return null;
}
String propertyName = (String) propertyDescriptor.getId();
java.beans.PropertyDescriptor[] propertyDescriptors = databaseObjectTreeObject.databaseObjectBeanInfo.getPropertyDescriptors();
java.beans.PropertyDescriptor propertyDescriptor = null;
for (java.beans.PropertyDescriptor pd : propertyDescriptors) {
if (propertyName.equals(pd.getName())) {
propertyDescriptor = pd;
break;
}
}
String extension = (propertyDescriptor != null && propertyDescriptor.getValue(MySimpleBeanInfo.GENERIC_EDITOR_EXTENSION) != null) ? propertyDescriptor.getValue(MySimpleBeanInfo.GENERIC_EDITOR_EXTENSION).toString() : "txt";
DatabaseObject dbo = databaseObjectTreeObject.getObject();
IFile file = databaseObjectTreeObject.getProjectTreeObject().getFile("_private/editor/" + dbo.getShortQName() + "/" + propertyName + "." + extension);
SwtUtils.fillFile(file, getValue().toString());
FileInPlaceEditorInput input = new FileInPlaceEditorInput(file);
IEditorPart editor = activePage.openEditor(input, "org.eclipse.ui.genericeditor.GenericEditor");
editor.addPropertyListener((Object source, int propId) -> {
if (propId == IEditorPart.PROP_DIRTY && !((IEditorPart) source).isDirty()) {
try (InputStream is = file.getContents()) {
setNewValue(IOUtils.toString(is, "UTF-8"));
} catch (Exception e) {
Engine.logStudio.error("Failed to save " + file.getName(), e);
}
}
});
} catch (PartInitException e) {
Engine.logStudio.error("failed to open editor", e);
}
return null;
}
use of com.twinsoft.convertigo.beans.core.DatabaseObject 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;
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 !");
}
}
}
}
}
}
}
}
} else // 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 UIUseVariable) {
UIUseVariable uicv = (UIUseVariable) 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 UICompEvent has been renamed
if (databaseObject instanceof UICompEvent) {
UICompEvent event = (UICompEvent) databaseObject;
UISharedComponent comp = event.getSharedComponent();
if (comp != null) {
// rename control event for UseShared
if (getObject() instanceof UIUseShared) {
UIUseShared uus = (UIUseShared) getObject();
if (uus.getSharedComponentQName().equals(comp.getQName())) {
boolean isLocalProject = event.getProject().equals(uus.getProject());
boolean isSameValue = event.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 UIControlEvent) {
UIControlEvent uice = (UIControlEvent) component;
if (uice.getEventName().equals(oldValue)) {
try {
uice.setEventName((String) newValue);
uice.hasChanged = true;
hasBeenModified(true);
viewer.refresh();
markMainAsDirty(uus);
notifyDataseObjectPropertyChanged(uice, "eventName", oldValue, newValue, new HashSet<Object>());
break;
} catch (EngineException e) {
ConvertigoPlugin.logException(e, "Unable to refactor the references of '" + newValue + "' event 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 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);
Object oldValue = treeObjectEvent.oldValue;
Object newValue = treeObjectEvent.newValue;
refactorSmartSources(treeObjectEvent);
if (treeObject instanceof DatabaseObjectTreeObject) {
DatabaseObjectTreeObject doto = (DatabaseObjectTreeObject) treeObject;
DatabaseObject dbo = doto.getObject();
try {
if (this.equals(treeObject)) {
if (propertyName.equals("scriptContent")) {
if (!newValue.equals(oldValue)) {
markMainTsAsDirty();
markMainAsDirty(getObject(), done);
}
} else {
if (propertyName.equals("sharedcomponent")) {
if (!newValue.equals(oldValue)) {
if (!((String) newValue).isBlank()) {
ComponentRefManager.get(Mode.use).addConsumer((String) newValue, dbo.getQName());
}
}
}
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) {
if (getObject() instanceof UIUseShared) {
UIUseShared uiUse = (UIUseShared) getObject();
String useQName = uiUse.getQName();
String compQName = dbo.getQName();
if (ComponentRefManager.get(Mode.use).getAllConsumers(compQName).contains(useQName)) {
((NgxBuilder) uiUse.getProject().getMobileBuilder()).updateConsumer();
}
}
handleSharedComponentChanged((UISharedComponent) dbo, done);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
use of com.twinsoft.convertigo.beans.core.DatabaseObject in project convertigo by convertigo.
the class MobileUIComponentTreeObject method unformatStyleContent.
private String unformatStyleContent(UIStyle ms, String s) {
String unformated = s;
DatabaseObject parentDbo = ms.getParent();
if (parentDbo != null && parentDbo instanceof UIElement) {
try {
unformated = unformated.replaceFirst("^\\.class\\d+\\s?\\{\\r?\\n?", "");
unformated = unformated.substring(0, unformated.lastIndexOf("}"));
} catch (Exception e) {
unformated = s;
e.printStackTrace();
}
}
;
return unformated;
}
use of com.twinsoft.convertigo.beans.core.DatabaseObject in project convertigo by convertigo.
the class MobileUIComponentTreeObject method getDynamicPropertyDescriptors.
@Override
protected List<PropertyDescriptor> getDynamicPropertyDescriptors() {
List<PropertyDescriptor> l = super.getDynamicPropertyDescriptors();
DatabaseObject dbo = getObject();
if (dbo instanceof UIDynamicElement) {
IonBean ionBean = ((UIDynamicElement) dbo).getIonBean();
if (ionBean != null) {
for (IonProperty property : ionBean.getProperties().values()) {
String id = property.getName();
String displayName = property.getLabel();
String editor = property.getEditor();
Object[] values = property.getValues();
int len = values.length;
if (property.isHidden()) {
continue;
}
PropertyDescriptor propertyDescriptor = null;
if (editor.isEmpty()) {
if (len == 0) {
propertyDescriptor = new TextPropertyDescriptor(id, displayName);
} else if (len == 1) {
propertyDescriptor = new PropertyDescriptor(id, displayName);
} else {
boolean isEditable = values[len - 1].equals(true);
int size = isEditable ? len - 1 : len;
String[] tags = new String[size];
for (int i = 0; i < size; i++) {
Object value = values[i];
tags[i] = value.equals(false) ? "not set" : value.toString();
}
// propertyDescriptor = new StringComboBoxPropertyDescriptor(id, displayName, tags, !isEditable);
propertyDescriptor = new MobileSmartSourcePropertyDescriptor(id, displayName, tags, !isEditable);
((MobileSmartSourcePropertyDescriptor) propertyDescriptor).databaseObjectTreeObject = this;
}
} else {
if (editor.equals("StringComboBoxPropertyDescriptor")) {
try {
Class<?> c = Class.forName("com.twinsoft.convertigo.eclipse.property_editors." + editor);
Method getTags = c.getDeclaredMethod("getTags", new Class[] { DatabaseObjectTreeObject.class, String.class });
String[] tags = (String[]) getTags.invoke(null, new Object[] { this, id });
propertyDescriptor = new StringComboBoxPropertyDescriptor(id, displayName, tags, true);
} catch (Exception e) {
e.printStackTrace();
}
} else {
propertyDescriptor = new PropertyDescriptor(id, displayName) {
@Override
public CellEditor createPropertyEditor(Composite parent) {
CellEditor cellEditor = null;
try {
Class<?> c = Class.forName("com.twinsoft.convertigo.eclipse.property_editors." + editor);
cellEditor = (CellEditor) c.getConstructor(Composite.class).newInstance(parent);
if (cellEditor instanceof AbstractDialogCellEditor) {
((AbstractDialogCellEditor) cellEditor).databaseObjectTreeObject = MobileUIComponentTreeObject.this;
((AbstractDialogCellEditor) cellEditor).propertyDescriptor = this;
}
} catch (Exception e) {
e.printStackTrace();
}
return cellEditor;
}
};
}
}
propertyDescriptor.setCategory(property.getCategory());
propertyDescriptor.setDescription(cleanDescription(property.getDescription()));
propertyDescriptor.setValidator(getValidator(id));
l.add(propertyDescriptor);
}
}
}
return l;
}
Aggregations