use of com.twinsoft.convertigo.beans.ngx.components.UISharedComponent 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.UISharedComponent 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;
}
use of com.twinsoft.convertigo.beans.ngx.components.UISharedComponent in project convertigo by convertigo.
the class NgxBuilder method compRemoved.
@Override
public void compRemoved(final ISharedComponent sharedComponent) throws EngineException {
UISharedComponent comp = (UISharedComponent) sharedComponent;
if (comp != null && initDone) {
synchronized (comp) {
MobileApplication mobileApplication = project.getMobileApplication();
if (mobileApplication != null) {
ApplicationComponent application = (ApplicationComponent) mobileApplication.getApplicationComponent();
if (application != null) {
writeAppSourceFiles(application);
deleteUselessCompDir(comp.getName(), comp.getQName());
moveFiles();
Engine.logEngine.trace("(MobileBuilder) Handled 'compRemoved'");
ComponentRefManager.get(Mode.use).removeKey(comp.getQName());
}
}
}
}
}
use of com.twinsoft.convertigo.beans.ngx.components.UISharedComponent in project convertigo by convertigo.
the class NgxBuilder method compStyleChanged.
@Override
public void compStyleChanged(ISharedComponent sharedComponent) throws EngineException {
UISharedComponent comp = (UISharedComponent) sharedComponent;
if (comp != null && initDone) {
synchronized (comp) {
writeCompStyle(comp);
moveFiles();
Engine.logEngine.trace("(MobileBuilder) Handled 'compStyleChanged'");
}
}
}
use of com.twinsoft.convertigo.beans.ngx.components.UISharedComponent in project convertigo by convertigo.
the class ApplicationComponentEditor method highlightComponent.
public void highlightComponent(MobileComponent mobileComponent, boolean selectPage) {
C8oBrowser.run(() -> {
if (selectPage && mobileComponent instanceof UIComponent) {
PageComponent pageComponent = ((UIComponent) mobileComponent).getPage();
if (pageComponent != null) {
selectPage(pageComponent.getSegment());
}
}
});
C8oBrowser.run(() -> {
Document doc = browser.mainFrame().get().document().get();
MobileComponent mc = mobileComponent;
if (mc instanceof UISharedComponent) {
UISharedComponent uisc = (UISharedComponent) mc;
if (uisc != null) {
try {
mc = uisc.getDisplayableComponentList().get(0);
} catch (IndexOutOfBoundsException ioobe) {
}
}
} else if (mc instanceof UIUseShared) {
UISharedComponent uisc = ((UIUseShared) mc).getTargetSharedComponent();
if (uisc != null) {
try {
mc = uisc.getDisplayableComponentList().get(0);
} catch (IndexOutOfBoundsException ioobe) {
}
}
}
while (doc.findElementsByClassName("class" + mc.priority).isEmpty()) {
DatabaseObject parent = mc.getParent();
if (parent instanceof MobileComponent) {
mc = (MobileComponent) parent;
} else {
return;
}
}
c8oBrowser.executeJavaScriptAndReturnValue("_c8o_highlight_class('class" + mc.priority + "');");
});
}
Aggregations