use of com.twinsoft.convertigo.beans.ngx.components.UIActionStack 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;
DatabaseObject deletedObject = deletedTreeObject.getObject();
try {
if (deletedTreeObject != null && this.equals(deletedTreeObject.getParentDatabaseObjectTreeObject())) {
UIComponent parentDbo = getObject();
if (deletedObject instanceof UIUseShared) {
UIUseShared use = (UIUseShared) deletedObject;
String compQName = use.getSharedComponentQName();
String useQNname = parentDbo.getQName() + "." + deletedObject.getName();
ComponentRefManager.get(Mode.use).removeConsumer(compQName, useQNname);
}
UIActionStack uisa = parentDbo.getSharedAction();
UISharedComponent uisc = parentDbo.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.UIActionStack 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 + "\".");
UIUseVariable uiVariable = new UIUseVariable();
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();
}
}
use of com.twinsoft.convertigo.beans.ngx.components.UIActionStack in project convertigo by convertigo.
the class ApplicationComponentEditor method highlightPoint.
private void highlightPoint(int x, int y) {
x = c8oBrowser.fixDPI(x);
y = c8oBrowser.fixDPI(y);
Node node = browser.mainFrame().get().inspect(x, y).node().orElse(null);
while (!(node == null || node instanceof Element)) {
node = node.parent().orElse(null);
}
if (node == null) {
return;
}
Object shadowHost = c8oBrowser.executeFunctionAndReturnValue("_c8o_getShadowHost", node);
if (shadowHost != null && shadowHost instanceof Element) {
node = (Element) shadowHost;
}
while (node != null) {
Element element = (Element) node;
if (element.equals(exHighlightElement)) {
return;
}
exHighlightElement = element;
String classes = element.attributeValue("class");
Matcher mPriority = pPriority.matcher(classes);
if (mPriority.find()) {
try {
node = null;
long priority = Long.parseLong(mPriority.group(1));
new WalkHelper() {
@Override
protected void walk(DatabaseObject databaseObject) throws Exception {
if (databaseObject instanceof UISharedComponent) {
UISharedComponent uisc = (UISharedComponent) databaseObject;
if (uisc != null) {
databaseObject = uisc;
}
} else if (databaseObject instanceof UIUseShared) {
UISharedComponent uisc = ((UIUseShared) databaseObject).getTargetSharedComponent();
if (uisc != null) {
databaseObject = uisc;
}
} else if (databaseObject instanceof UIDynamicInvoke) {
UIDynamicInvoke uidi = (UIDynamicInvoke) databaseObject;
UIActionStack uisa = uidi.getTargetSharedAction();
if (uisa != null) {
if (!uidi.isRecursive()) {
databaseObject = uisa;
}
}
}
if (databaseObject.priority == priority) {
throw new DatabaseObjectFoundException(databaseObject);
}
super.walk(databaseObject);
}
}.init(applicationEditorInput.application);
} catch (DatabaseObjectFoundException e) {
DatabaseObject databaseObject = e.getDatabaseObject();
if (databaseObject instanceof MobileComponent && !databaseObject.equals(exHighlightMobileComponent)) {
if (dragStartMobileComponent != null) {
DatabaseObject ancestor = databaseObject;
while (dragStartMobileComponent != ancestor && ancestor != null) {
ancestor = ancestor.getParent();
}
if (dragStartMobileComponent == ancestor) {
return;
}
}
c8oBrowser.getDisplay().asyncExec(() -> ConvertigoPlugin.getDefault().getProjectExplorerView().objectSelected(new CompositeEvent(databaseObject)));
highlightComponent(exHighlightMobileComponent = (MobileComponent) databaseObject, false);
}
} catch (Exception e) {
e.printStackTrace();
}
} else {
node = node.parent().orElse(null);
while (!(node == null || node instanceof Element)) {
node = node.parent().orElse(null);
}
}
}
}
use of com.twinsoft.convertigo.beans.ngx.components.UIActionStack in project convertigo by convertigo.
the class NgxPickerContentProvider method addActions.
private void addActions(TVObject tvi, Object object) {
if (object != null) {
List<? extends UIComponent> list = null;
if (object instanceof ApplicationComponent) {
ApplicationComponent app = (ApplicationComponent) object;
list = app.getUIAppEventList();
list.addAll(GenericUtils.cast(app.getUIEventSubscriberList()));
list.addAll(GenericUtils.cast(app.getSharedActionList()));
} else if (object instanceof UIActionStack) {
if (tvi != null && "actions".equals(tvi.getName())) {
list = new ArrayList<>(Arrays.asList((UIActionStack) object));
} else {
list = ((UIActionStack) object).getUIComponentList();
}
} else if (object instanceof UISharedComponent) {
list = ((UISharedComponent) object).getUIComponentList();
} else if (object instanceof PageComponent) {
list = ((PageComponent) object).getUIComponentList();
} else if (object instanceof UIComponent) {
list = ((UIComponent) object).getUIComponentList();
}
if (list != null) {
TVObject tvEvents = null, tvControls = null;
if (tvi != null && "actions".equals(tvi.getName())) {
tvEvents = tvi.children.get(0);
tvControls = tvi.children.get(1);
}
for (UIComponent uic : list) {
// do not add to prevent selection on itself or children
if (uic.equals(selected)) {
return;
}
// do not add if not parent of selected (popped picker only)
boolean showInPicker = true;
if (selected != null && selected instanceof UIComponent) {
String selectedQName = ((UIComponent) selected).getQName();
String uicQName = uic.getQName() + ".";
if (!selectedQName.startsWith(uicQName)) {
showInPicker = false;
}
}
if (showInPicker) {
if (uic instanceof UIAppEvent || uic instanceof UIPageEvent || uic instanceof UISharedComponentEvent || uic instanceof UIEventSubscriber) {
TVObject tve = tvEvents == null ? tvi.add(new TVObject(uic.toString(), uic, null)) : tvEvents.add(new TVObject(uic.toString(), uic, null));
addActions(tve, uic);
} else if (uic instanceof UIActionEvent || uic instanceof UIControlEvent) {
TVObject tve = tvControls == null ? tvi.add(new TVObject(uic.toString(), uic, null)) : tvControls.add(new TVObject(uic.toString(), uic, null));
addActions(tve, uic);
} else if (uic instanceof IAction || uic instanceof UIActionStack) {
SourceData sd = null;
try {
sd = Filter.Action.toSourceData(new JSONObject().put("priority", uic.priority));
} catch (JSONException e) {
e.printStackTrace();
}
TVObject tuic = tvi.add(new TVObject(uic.toString(), uic, sd));
addActions(tuic, uic);
} else {
addActions(tvi, uic);
}
// } else {
// addActions(tvi, uic);
}
}
}
}
}
use of com.twinsoft.convertigo.beans.ngx.components.UIActionStack in project convertigo by convertigo.
the class NgxBuilder method getFunctionTempTsRelativePath.
@Override
public String getFunctionTempTsRelativePath(final IUIComponent uiComponent) throws EngineException {
UIComponent uic = (UIComponent) uiComponent;
IScriptComponent main = uic.getMainScriptComponent();
if (main != null) {
File tempTsDir = null;
String tempTsFileName = null;
if (main instanceof ApplicationComponent) {
UIActionStack stack = uic.getSharedAction();
tempTsDir = stack == null ? appDir : servicesDir;
tempTsFileName = stack == null ? "app.component.function.temp.ts" : "actionbeans.service.function.temp.ts";
}
if (main instanceof PageComponent) {
PageComponent page = (PageComponent) main;
String pageName = page.getName();
tempTsDir = pageDir(page);
tempTsFileName = pageName.toLowerCase() + ".function.temp.ts";
}
if (main instanceof UISharedComponent) {
UISharedComponent comp = (UISharedComponent) main;
String compName = comp.getName();
tempTsDir = compDir(comp);
tempTsFileName = compName.toLowerCase() + ".function.temp.ts";
}
if (tempTsDir != null && tempTsFileName != null) {
if (uiComponent instanceof UICustomAction) {
tempTsFileName = "CTS" + ((UICustomAction) uiComponent).priority + ".temp.ts";
}
File tempTsFile = new File(tempTsDir, tempTsFileName);
return tempTsFile.getPath().replace(projectDir.getPath(), File.separator);
}
}
return null;
}
Aggregations