use of com.twinsoft.convertigo.beans.ngx.components.MobileSmartSourceType in project convertigo by convertigo.
the class CreateNgxApplicationTranslationsFileAction method run.
public void run() {
Display display = Display.getDefault();
Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
Shell shell = getParentShell();
shell.setCursor(waitCursor);
try {
ProjectExplorerView explorerView = getProjectExplorerView();
if (explorerView != null) {
TreeObject treeObject = explorerView.getFirstSelectedTreeObject();
Object databaseObject = treeObject.getObject();
List<String> textList = new ArrayList<String>();
if ((databaseObject != null) && (databaseObject instanceof ApplicationComponent)) {
ApplicationComponent application = (ApplicationComponent) databaseObject;
new WalkHelper() {
@Override
protected void walk(DatabaseObject databaseObject) throws Exception {
String text = null;
if (databaseObject instanceof PageComponent) {
PageComponent page = (PageComponent) databaseObject;
text = page.getTitle();
} else if (databaseObject instanceof UIUseShared) {
UIUseShared uius = (UIUseShared) databaseObject;
UISharedComponent uisc = uius.getTargetSharedComponent();
if (uisc != null && !uius.isRecursive()) {
super.walk(uisc);
}
} else if (databaseObject instanceof UIText) {
UIText uiText = (UIText) databaseObject;
MobileSmartSourceType msst = uiText.getTextSmartType();
if (Mode.PLAIN.equals(msst.getMode())) {
text = msst.getValue();
}
}
if (text != null && !textList.contains(text)) {
textList.add(text);
}
super.walk(databaseObject);
}
}.init(application);
MobileApplicationTranslationsDialog dlg = new MobileApplicationTranslationsDialog(shell);
int ret = dlg.open();
if (ret != Window.OK) {
return;
}
Locale from = dlg.getLocaleFrom();
Locale to = dlg.getLocaleTo();
boolean auto = dlg.isAuto();
File i18nDir = new File(application.getProject().getDirPath(), "DisplayObjects/mobile/assets/i18n");
// store source file
File source = new File(i18nDir, from.getLanguage() + ".json");
TranslateUtils.storeTranslations(textList, source);
ConvertigoPlugin.logDebug(source.getName() + " file successfully created or updated.");
// store target file
if (!to.equals(from)) {
File target = new File(i18nDir, to.getLanguage() + ".json");
// translate with google api
if (auto) {
ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
dialog.run(true, false, new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
monitor.beginTask("translating", IProgressMonitor.UNKNOWN);
Translator translator = TranslateUtils.newTranslator();
try {
translator.translate(from, source, to, target);
ConvertigoPlugin.logDebug(target.getName() + " file successfully translated.");
} catch (Exception e) {
ConvertigoPlugin.logError(e.getMessage(), false);
try {
TranslateUtils.storeTranslations(textList, target);
} catch (Exception ex) {
}
}
monitor.done();
}
});
} else // do not translate
{
TranslateUtils.storeTranslations(textList, target);
}
ConvertigoPlugin.logDebug(target.getName() + " file successfully created or updated.");
}
// regenerate app templates
try {
application.markApplicationAsDirty();
for (PageComponent page : application.getPageComponentList()) {
if (page.isEnabled()) {
page.markPageAsDirty();
}
}
} catch (Throwable t) {
}
ConvertigoPlugin.logInfo("Translations file(s) successfully created or updated.", true);
}
}
} catch (Throwable e) {
ConvertigoPlugin.logException(e, "Unable to create the Mobile application translations file(s)!");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
use of com.twinsoft.convertigo.beans.ngx.components.MobileSmartSourceType 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.MobileSmartSourceType in project convertigo by convertigo.
the class NgxUIComponentTreeObject method getNamedSourceSelector.
@Override
public NamedSourceSelector getNamedSourceSelector() {
return new NamedSourceSelector() {
@Override
Object thisTreeObject() {
return NgxUIComponentTreeObject.this;
}
@Override
protected List<String> getPropertyNamesForSource(Class<?> c) {
List<String> list = new ArrayList<String>();
UIComponent object = getObject();
if (object instanceof UIDynamicTabButton) {
if (ProjectTreeObject.class.isAssignableFrom(c) || MobileApplicationTreeObject.class.isAssignableFrom(c) || NgxApplicationComponentTreeObject.class.isAssignableFrom(c) || NgxPageComponentTreeObject.class.isAssignableFrom(c)) {
list.add("tabpage");
}
} else if (object instanceof UIDynamicMenuItem) {
if (ProjectTreeObject.class.isAssignableFrom(c) || MobileApplicationTreeObject.class.isAssignableFrom(c) || NgxApplicationComponentTreeObject.class.isAssignableFrom(c) || NgxPageComponentTreeObject.class.isAssignableFrom(c)) {
list.add("itempage");
}
} else if (object instanceof UIDynamicAnimate) {
if (ProjectTreeObject.class.isAssignableFrom(c) || MobileApplicationTreeObject.class.isAssignableFrom(c) || NgxApplicationComponentTreeObject.class.isAssignableFrom(c) || NgxPageComponentTreeObject.class.isAssignableFrom(c) || NgxUIComponentTreeObject.class.isAssignableFrom(c)) {
list.add("identifiable");
}
} else if (object instanceof UIDynamicInvoke) {
if (ProjectTreeObject.class.isAssignableFrom(c) || MobileApplicationTreeObject.class.isAssignableFrom(c) || NgxApplicationComponentTreeObject.class.isAssignableFrom(c) || NgxUIComponentTreeObject.class.isAssignableFrom(c)) {
list.add("stack");
}
} else if (object instanceof UIUseShared) {
if (ProjectTreeObject.class.isAssignableFrom(c) || MobileApplicationTreeObject.class.isAssignableFrom(c) || NgxApplicationComponentTreeObject.class.isAssignableFrom(c) || NgxUIComponentTreeObject.class.isAssignableFrom(c)) {
list.add("sharedcomponent");
}
} else if (object instanceof UIDynamicInfiniteScroll) {
if (ProjectTreeObject.class.isAssignableFrom(c) || MobileApplicationTreeObject.class.isAssignableFrom(c) || NgxApplicationComponentTreeObject.class.isAssignableFrom(c) || NgxPageComponentTreeObject.class.isAssignableFrom(c) || NgxUIComponentTreeObject.class.isAssignableFrom(c)) {
list.add("scrollaction");
}
} else if (object instanceof UIDynamicElement) {
if (ProjectTreeObject.class.isAssignableFrom(c) || SequenceTreeObject.class.isAssignableFrom(c) || ConnectorTreeObject.class.isAssignableFrom(c)) {
list.add("requestable");
}
if (ProjectTreeObject.class.isAssignableFrom(c) || MobileApplicationTreeObject.class.isAssignableFrom(c) || NgxApplicationComponentTreeObject.class.isAssignableFrom(c) || NgxPageComponentTreeObject.class.isAssignableFrom(c)) {
list.add("page");
}
if (ProjectTreeObject.class.isAssignableFrom(c) || ConnectorTreeObject.class.isAssignableFrom(c) || DesignDocumentTreeObject.class.isAssignableFrom(c) || DesignDocumentViewTreeObject.class.isAssignableFrom(c)) {
list.add("fsview");
}
}
return list;
}
@Override
protected boolean isNamedSource(String propertyName) {
UIComponent object = getObject();
if (object instanceof UIDynamicTab) {
return "tabpage".equals(propertyName);
} else if (object instanceof UIDynamicMenuItem) {
return "itempage".equals(propertyName);
} else if (object instanceof UIDynamicAnimate) {
return "identifiable".equals(propertyName);
} else if (object instanceof UIDynamicInvoke) {
return "stack".equals(propertyName);
} else if (object instanceof UIUseShared) {
return "sharedcomponent".equals(propertyName);
} else if (object instanceof UIDynamicInfiniteScroll) {
return "scrollaction".equals(propertyName);
} else if (object instanceof UIDynamicElement) {
return "requestable".equals(propertyName) || "fsview".equals(propertyName) || "page".equals(propertyName);
}
return false;
}
@Override
public boolean isSelectable(String propertyName, Object nsObject) {
UIComponent object = getObject();
if (object instanceof UIDynamicTabButton) {
if ("tabpage".equals(propertyName)) {
if (nsObject instanceof PageComponent) {
return (((PageComponent) nsObject).getProject().equals(object.getProject()));
}
}
} else if (object instanceof UIDynamicMenuItem) {
if ("itempage".equals(propertyName)) {
if (nsObject instanceof PageComponent) {
return (((PageComponent) nsObject).getProject().equals(object.getProject()));
}
}
} else if (object instanceof UIDynamicAnimate) {
if ("identifiable".equals(propertyName)) {
UIDynamicAnimate uda = (UIDynamicAnimate) object;
if (nsObject instanceof UIElement) {
UIElement ue = (UIElement) nsObject;
if (hasSameScriptComponent(uda, ue)) {
return !ue.getIdentifier().isEmpty();
}
}
}
} else if (object instanceof UIDynamicInvoke) {
if ("stack".equals(propertyName)) {
return nsObject instanceof UIActionStack;
}
} else if (object instanceof UIUseShared) {
if ("sharedcomponent".equals(propertyName)) {
return nsObject instanceof UISharedComponent;
}
} else if (object instanceof UIDynamicInfiniteScroll) {
if ("scrollaction".equals(propertyName)) {
if (nsObject instanceof UIDynamicAction) {
UIDynamicAction uida = (UIDynamicAction) nsObject;
if (uida.getProject().equals(object.getProject())) {
if (uida.getIonBean().getName().equals("CallSequenceAction")) {
return true;
}
if (uida.getIonBean().getName().equals("FullSyncViewAction")) {
return true;
}
}
}
}
} else if (object instanceof UIDynamicElement) {
if ("requestable".equals(propertyName)) {
UIDynamicElement cc = (UIDynamicElement) object;
if (cc.getIonBean().getName().equals("CallSequenceAction")) {
return nsObject instanceof Sequence;
}
if (cc.getIonBean().getName().equals("CallFullSyncAction")) {
return nsObject instanceof FullSyncConnector;
}
if (cc.getIonBean().getName().equals("FullSyncSyncAction")) {
return nsObject instanceof FullSyncConnector;
}
if (cc.getIonBean().getName().equals("FullSyncViewAction")) {
return nsObject instanceof DesignDocument;
}
if (cc.getIonBean().getName().equals("FullSyncPostAction")) {
return nsObject instanceof FullSyncConnector;
}
if (cc.getIonBean().getName().equals("FullSyncGetAction")) {
return nsObject instanceof FullSyncConnector;
}
if (cc.getIonBean().getName().equals("FullSyncDeleteAction")) {
return nsObject instanceof FullSyncConnector;
}
if (cc.getIonBean().getName().equals("FullSyncPutAttachmentAction")) {
return nsObject instanceof FullSyncConnector;
}
if (cc.getIonBean().getName().equals("FullSyncDeleteAttachmentAction")) {
return nsObject instanceof FullSyncConnector;
}
if (cc.getIonBean().getName().equals("FSImage")) {
return nsObject instanceof FullSyncConnector;
}
if (cc.getIonBean().getName().equals("AutoScrollComponent")) {
return nsObject instanceof Sequence;
}
}
if ("fsview".equals(propertyName)) {
UIDynamicElement cc = (UIDynamicElement) object;
if (cc.getIonBean().getName().equals("FullSyncViewAction")) {
return nsObject instanceof String;
}
if (cc.getIonBean().getName().equals("AutoScrollComponent")) {
return nsObject instanceof DesignDocument || nsObject instanceof String;
}
}
if ("page".equals(propertyName)) {
if (nsObject instanceof PageComponent) {
return (((PageComponent) nsObject).getProject().equals(object.getProject()));
}
}
}
return false;
}
@Override
protected void handleSourceCleared(String propertyName) {
// nothing to do
}
@Override
protected void handleSourceRenamed(String propertyName, String oldName, String newName) {
if (isNamedSource(propertyName)) {
boolean hasBeenRenamed = false;
Object oValue = getPropertyValue(propertyName);
String pValue;
if (oValue instanceof MobileSmartSourceType) {
MobileSmartSourceType sst = (MobileSmartSourceType) oValue;
pValue = sst.getSmartValue();
} else {
pValue = (String) oValue;
}
String _pValue = pValue;
if (pValue != null && (pValue.startsWith(oldName + ".") || pValue.equals(oldName))) {
_pValue = newName + pValue.substring(oldName.length());
if (!pValue.equals(_pValue)) {
UIComponent object = getObject();
if (object instanceof UIDynamicTab) {
if ("tabpage".equals(propertyName)) {
((UIDynamicTab) object).setTabPage(_pValue);
hasBeenRenamed = true;
}
} else if (object instanceof UIDynamicMenuItem) {
if ("itempage".equals(propertyName)) {
((UIDynamicMenuItem) object).setItemPage(_pValue);
hasBeenRenamed = true;
}
} else if (object instanceof UIDynamicAnimate) {
if ("identifiable".equals(propertyName)) {
((UIDynamicAnimate) object).setIdentifiable(_pValue);
hasBeenRenamed = true;
}
} else if (object instanceof UIDynamicInvoke) {
if ("stack".equals(propertyName)) {
((UIDynamicInvoke) object).setSharedActionQName(_pValue);
hasBeenRenamed = true;
}
} else if (object instanceof UIUseShared) {
if ("sharedcomponent".equals(propertyName)) {
((UIUseShared) object).setSharedComponentQName(_pValue);
hasBeenRenamed = true;
}
} else if (object instanceof UIDynamicInfiniteScroll) {
if ("scrollaction".equals(propertyName)) {
((UIDynamicInfiniteScroll) object).setScrollAction(_pValue);
hasBeenRenamed = true;
}
} else if (object instanceof UIDynamicElement) {
if ("requestable".equals(propertyName)) {
((UIDynamicElement) object).getIonBean().setPropertyValue("requestable", new MobileSmartSourceType(_pValue));
hasBeenRenamed = true;
}
if ("fsview".equals(propertyName)) {
((UIDynamicElement) object).getIonBean().setPropertyValue("fsview", new MobileSmartSourceType(_pValue));
hasBeenRenamed = true;
}
if ("page".equals(propertyName)) {
((UIDynamicElement) object).getIonBean().setPropertyValue("page", new MobileSmartSourceType(_pValue));
hasBeenRenamed = true;
}
} else if (object instanceof UIText) {
if ("textValue".equals(propertyName)) {
((UIText) object).setTextSmartType(new MobileSmartSourceType(_pValue));
hasBeenRenamed = true;
}
}
}
}
if (hasBeenRenamed) {
hasBeenModified(true);
viewer.refresh();
ConvertigoPlugin.projectManager.getProjectExplorerView().updateTreeObject(NgxUIComponentTreeObject.this);
// refresh editors (e.g labels in combobox)
getDescriptors();
TreeObjectEvent treeObjectEvent = new TreeObjectEvent(NgxUIComponentTreeObject.this, propertyName, pValue, _pValue);
ConvertigoPlugin.projectManager.getProjectExplorerView().fireTreeObjectPropertyChanged(treeObjectEvent);
}
}
}
@Override
protected void refactorSmartSources(Class<?> c, String oldName, String newName) {
try {
// A project has been renamed
if (ProjectTreeObject.class.isAssignableFrom(c)) {
UIComponent object = getObject();
for (java.beans.PropertyDescriptor pd : CachedIntrospector.getBeanInfo(object).getPropertyDescriptors()) {
if (pd.getPropertyType().equals(MobileSmartSourceType.class)) {
String propertyName = pd.getName();
Object oValue = getPropertyValue(propertyName);
MobileSmartSourceType msst = (MobileSmartSourceType) oValue;
MobileSmartSource mss = msst.getSmartSource();
boolean hasBeenChanged = false;
if (mss != null) {
if (oldName.equals(mss.getProjectName())) {
mss.setProjectName(newName);
msst.setSmartValue(mss.toJsonString());
hasBeenChanged = true;
}
}
if (hasBeenChanged) {
Object nValue = getPropertyValue(propertyName);
hasBeenModified(true);
viewer.refresh();
ConvertigoPlugin.projectManager.getProjectExplorerView().updateTreeObject(NgxUIComponentTreeObject.this);
// refresh editors (e.g labels in combobox)
getDescriptors();
TreeObjectEvent treeObjectEvent = new TreeObjectEvent(NgxUIComponentTreeObject.this, propertyName, oValue, nValue);
ConvertigoPlugin.projectManager.getProjectExplorerView().fireTreeObjectPropertyChanged(treeObjectEvent);
}
}
}
}
} catch (Exception e) {
// TODO: handle exception
}
}
};
}
use of com.twinsoft.convertigo.beans.ngx.components.MobileSmartSourceType in project convertigo by convertigo.
the class NgxSmartSourceTypeCellEditor method setValidator.
@Override
public void setValidator(ICellEditorValidator validator) {
super.setValidator(new ICellEditorValidator() {
@Override
public String isValid(Object value) {
String error = null;
String txt = null;
Mode mode = null;
if (value instanceof MobileSmartSourceType) {
MobileSmartSourceType m = (MobileSmartSourceType) value;
mode = m.getMode();
txt = m.getValue();
if (!Mode.PLAIN.equals(m.getMode())) {
String s = m.getValue();
if (s.isEmpty()) {
error = "cannot be empty";
}
}
} else if (value instanceof String && msst != null) {
mode = msst.getMode();
txt = (String) value;
}
if (txt != null) {
if (!Mode.PLAIN.equals(mode) && txt.isEmpty()) {
error = "value cannot be empty with mode " + mode.label();
} else if (validator != null) {
error = validator.isValid(txt);
}
}
return error;
}
});
}
use of com.twinsoft.convertigo.beans.ngx.components.MobileSmartSourceType in project convertigo by convertigo.
the class NgxComponentImportVariablesAction method run.
public void run() {
Display display = Display.getDefault();
Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
Shell shell = getParentShell();
shell.setCursor(waitCursor);
try {
ProjectExplorerView explorerView = getProjectExplorerView();
if (explorerView != null) {
TreeObject treeObject = explorerView.getFirstSelectedTreeObject();
Object databaseObject = treeObject.getObject();
if (databaseObject != null) {
if (databaseObject instanceof UIDynamicAction) {
UIDynamicAction dynAction = (UIDynamicAction) databaseObject;
IonBean ionBean = ((UIDynamicAction) dynAction).getIonBean();
if (ionBean != null) {
// Case of CallSequenceAction
if (ionBean.getName().equals("CallSequenceAction")) {
Object value = ionBean.getProperty("requestable").getValue();
if (!value.equals(false)) {
String target = value.toString();
if (!target.isEmpty()) {
try {
String projectName = target.substring(0, target.indexOf('.'));
String sequenceName = target.substring(target.indexOf('.') + 1);
Project p = Engine.theApp.databaseObjectsManager.getProjectByName(projectName);
Sequence sequence = p.getSequenceByName(sequenceName);
int size = sequence.numberOfVariables();
for (int i = 0; i < size; i++) {
RequestableVariable variable = (RequestableVariable) sequence.getVariable(i);
if (variable != null) {
String variableName = variable.getName();
if (dynAction.getVariable(variableName) == null) {
if (!StringUtils.isNormalized(variableName))
throw new EngineException("Variable name is not normalized : \"" + variableName + "\".");
UIControlVariable uiVariable = new UIControlVariable();
uiVariable.setName(variableName);
uiVariable.setComment(variable.getDescription());
uiVariable.setVarSmartType(new MobileSmartSourceType(variable.getDefaultValue().toString()));
dynAction.addUIComponent(uiVariable);
uiVariable.bNew = true;
uiVariable.hasChanged = true;
dynAction.hasChanged = true;
}
}
}
} catch (Exception e) {
}
}
}
} else // Case of InvokeAction
if (ionBean.getName().equals("InvokeAction")) {
UIDynamicInvoke dynInvoke = (UIDynamicInvoke) databaseObject;
UIActionStack stack = dynInvoke.getTargetSharedAction();
if (stack != null) {
for (UIStackVariable variable : stack.getVariables()) {
String variableName = variable.getName();
if (dynAction.getVariable(variableName) == null) {
if (!StringUtils.isNormalized(variableName))
throw new EngineException("Variable name is not normalized : \"" + variableName + "\".");
UIControlVariable uiVariable = new UIControlVariable();
uiVariable.setName(variableName);
uiVariable.setComment(variable.getComment());
MobileSmartSourceType msst = new MobileSmartSourceType();
msst.setMode(MobileSmartSourceType.Mode.SCRIPT);
msst.setSmartValue(variable.getVariableValue());
uiVariable.setVarSmartType(msst);
dynAction.addUIComponent(uiVariable);
uiVariable.bNew = true;
uiVariable.hasChanged = true;
dynAction.hasChanged = true;
}
}
}
}
if (dynAction.hasChanged) {
IScriptComponent main = dynAction.getMainScriptComponent();
if (main != null) {
if (main instanceof ApplicationComponent) {
((ApplicationComponent) main).markApplicationAsDirty();
}
if (main instanceof PageComponent) {
((PageComponent) main).markPageAsDirty();
}
}
explorerView.reloadTreeObject(treeObject);
StructuredSelection structuredSelection = new StructuredSelection(treeObject);
ConvertigoPlugin.getDefault().getPropertiesView().selectionChanged((IWorkbenchPart) explorerView, structuredSelection);
}
}
} else if (databaseObject instanceof UIUseShared) {
UIUseShared useShared = (UIUseShared) databaseObject;
UISharedComponent sharedComp = useShared.getTargetSharedComponent();
if (sharedComp != null) {
for (UICompVariable variable : sharedComp.getVariables()) {
String variableName = variable.getName();
if (useShared.getVariable(variableName) == null) {
if (!StringUtils.isNormalized(variableName))
throw new EngineException("Variable name is not normalized : \"" + variableName + "\".");
UIControlVariable uiVariable = new UIControlVariable();
uiVariable.setName(variableName);
uiVariable.setComment(variable.getComment());
MobileSmartSourceType msst = new MobileSmartSourceType();
msst.setMode(MobileSmartSourceType.Mode.SCRIPT);
msst.setSmartValue(variable.getVariableValue());
uiVariable.setVarSmartType(msst);
useShared.addUIComponent(uiVariable);
uiVariable.bNew = true;
uiVariable.hasChanged = true;
useShared.hasChanged = true;
}
}
if (useShared.hasChanged) {
IScriptComponent main = useShared.getMainScriptComponent();
if (main != null) {
if (main instanceof ApplicationComponent) {
((ApplicationComponent) main).markApplicationAsDirty();
}
if (main instanceof PageComponent) {
((PageComponent) main).markPageAsDirty();
}
}
explorerView.reloadTreeObject(treeObject);
StructuredSelection structuredSelection = new StructuredSelection(treeObject);
ConvertigoPlugin.getDefault().getPropertiesView().selectionChanged((IWorkbenchPart) explorerView, structuredSelection);
}
}
}
}
}
} catch (Throwable e) {
ConvertigoPlugin.logException(e, "Unable to add variables to action !");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
Aggregations