use of com.twinsoft.convertigo.beans.ngx.components.PageComponent 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.PageComponent 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.PageComponent in project convertigo by convertigo.
the class NgxBuilder method writeAppModuleTs.
private void writeAppModuleTs(ApplicationComponent app) throws EngineException {
try {
if (app != null) {
String c8o_PagesImport = "";
String c8o_PagesLinks = "";
String c8o_PagesDeclarations = "";
int i = 1;
Map<String, File> comp_beans_dirs = new HashMap<>();
Map<String, String> module_ts_imports = new HashMap<>();
Set<String> module_ng_imports = new HashSet<String>();
Set<String> module_ng_providers = new HashSet<String>();
Set<String> module_ng_declarations = new HashSet<String>();
Set<String> module_ng_components = new HashSet<String>();
// App contributors
for (Contributor contributor : app.getContributors()) {
comp_beans_dirs.putAll(contributor.getCompBeanDir());
module_ts_imports.putAll(contributor.getModuleTsImports());
module_ng_imports.addAll(contributor.getModuleNgImports());
module_ng_providers.addAll(contributor.getModuleNgProviders());
module_ng_declarations.addAll(contributor.getModuleNgDeclarations());
module_ng_components.addAll(contributor.getModuleNgComponents());
}
// Pages contributors
List<PageComponent> pages = getEnabledPages(app);
for (PageComponent page : pages) {
String pageName = page.getName();
String pageSegment = page.getSegment();
boolean isLastPage = i == pages.size();
if (app.compareToTplVersion("7.7.0.2") < 0) {
c8o_PagesImport += "import { " + pageName + " } from \"../pages/" + pageName + "/" + pageName.toLowerCase() + "\";" + System.lineSeparator();
c8o_PagesLinks += " { component: " + pageName + ", name: \"" + pageName + "\", segment: \"" + pageSegment + "\" }" + (isLastPage ? "" : ",");
c8o_PagesDeclarations += " " + pageName + (isLastPage ? "" : ",");
List<Contributor> contributors = page.getContributors();
for (Contributor contributor : contributors) {
comp_beans_dirs.putAll(contributor.getCompBeanDir());
module_ts_imports.putAll(contributor.getModuleTsImports());
module_ng_imports.addAll(contributor.getModuleNgImports());
module_ng_providers.addAll(contributor.getModuleNgProviders());
module_ng_declarations.addAll(contributor.getModuleNgDeclarations());
module_ng_components.addAll(contributor.getModuleNgComponents());
}
} else {
List<Contributor> contributors = page.getContributors();
for (Contributor contributor : contributors) {
if (contributor.isNgModuleForApp()) {
comp_beans_dirs.putAll(contributor.getCompBeanDir());
module_ts_imports.putAll(contributor.getModuleTsImports());
module_ng_imports.addAll(contributor.getModuleNgImports());
module_ng_providers.addAll(contributor.getModuleNgProviders());
module_ng_declarations.addAll(contributor.getModuleNgDeclarations());
module_ng_components.addAll(contributor.getModuleNgComponents());
}
}
writePageModuleTs(page);
writePageRoutingTs(page);
}
i++;
}
String c8o_ModuleTsImports = "";
Map<String, String> tpl_ts_imports = getTplAppModuleTsImports();
if (!module_ts_imports.isEmpty()) {
for (String comp : module_ts_imports.keySet()) {
if (!tpl_ts_imports.containsKey(comp)) {
if (comp.indexOf(" as ") != -1) {
c8o_ModuleTsImports += "import " + comp + " from '" + module_ts_imports.get(comp) + "';" + System.lineSeparator();
} else {
c8o_ModuleTsImports += "import { " + comp + " } from '" + module_ts_imports.get(comp) + "';" + System.lineSeparator();
}
}
}
}
String c8o_ModuleNgImports = "";
String tpl_ng_imports = getTplAppModuleNgImports();
if (!module_ng_imports.isEmpty()) {
for (String module : module_ng_imports) {
if (!tpl_ng_imports.contains(module)) {
c8o_ModuleNgImports += "\t" + module + "," + System.lineSeparator();
}
}
if (!c8o_ModuleNgImports.isEmpty()) {
c8o_ModuleNgImports = System.lineSeparator() + c8o_ModuleNgImports;
}
}
String c8o_ModuleNgProviders = "";
String tpl_ng_providers = getTplAppModuleNgProviders();
if (!module_ng_providers.isEmpty()) {
for (String provider : module_ng_providers) {
if (!tpl_ng_providers.contains(provider)) {
c8o_ModuleNgProviders += "\t" + provider + "," + System.lineSeparator();
}
}
if (!c8o_ModuleNgProviders.isEmpty()) {
c8o_ModuleNgProviders = System.lineSeparator() + c8o_ModuleNgProviders;
}
}
String c8o_ModuleNgDeclarations = "";
String tpl_ng_declarations = getTplAppModuleNgDeclarations();
if (!module_ng_declarations.isEmpty()) {
for (String declaration : module_ng_declarations) {
if (!tpl_ng_declarations.contains(declaration)) {
c8o_ModuleNgDeclarations += "\t" + declaration + "," + System.lineSeparator();
}
}
if (!c8o_ModuleNgDeclarations.isEmpty()) {
c8o_ModuleNgDeclarations = System.lineSeparator() + c8o_ModuleNgDeclarations;
}
}
String c8o_ModuleNgComponents = "";
String tpl_ng_components = getTplAppModuleNgComponents();
if (!module_ng_components.isEmpty()) {
for (String component : module_ng_components) {
if (!tpl_ng_components.contains(component)) {
c8o_ModuleNgComponents += "\t" + component + "," + System.lineSeparator();
}
}
if (!c8o_ModuleNgComponents.isEmpty()) {
c8o_ModuleNgComponents = System.lineSeparator() + c8o_ModuleNgComponents;
}
}
File appModuleTpl = new File(ionicTplDir, "src/app/app.module.ts");
String mContent = FileUtils.readFileToString(appModuleTpl, "UTF-8");
mContent = mContent.replaceAll("/\\*\\=c8o_ModuleTsImports\\*/", c8o_ModuleTsImports);
mContent = mContent.replaceAll("/\\*\\=c8o_PagesImport\\*/", c8o_PagesImport);
mContent = mContent.replaceAll("/\\*\\=c8o_PagesLinks\\*/", c8o_PagesLinks);
mContent = mContent.replaceAll("/\\*\\=c8o_PagesDeclarations\\*/", c8o_PagesDeclarations);
mContent = mContent.replaceAll("/\\*Begin_c8o_NgModules\\*/", c8o_ModuleNgImports);
mContent = mContent.replaceAll("/\\*End_c8o_NgModules\\*/", "");
mContent = mContent.replaceAll("/\\*Begin_c8o_NgProviders\\*/", c8o_ModuleNgProviders);
mContent = mContent.replaceAll("/\\*End_c8o_NgProviders\\*/", "");
mContent = mContent.replaceAll("/\\*Begin_c8o_NgDeclarations\\*/", c8o_ModuleNgDeclarations);
mContent = mContent.replaceAll("/\\*End_c8o_NgDeclarations\\*/", "");
mContent = mContent.replaceAll("/\\*Begin_c8o_NgComponents\\*/", c8o_ModuleNgComponents);
mContent = mContent.replaceAll("/\\*End_c8o_NgComponents\\*/", "");
File appModuleTsFile = new File(appDir, "app.module.ts");
writeFile(appModuleTsFile, mContent, "UTF-8");
for (String compbean : comp_beans_dirs.keySet()) {
File srcCompDir = comp_beans_dirs.get(compbean);
for (File f : srcCompDir.listFiles()) {
String fContent = FileUtils.readFileToString(f, "UTF-8");
File destFile = new File(componentsDir, compbean + "/" + f.getName());
writeFile(destFile, fContent, "UTF-8");
}
}
if (initDone) {
Engine.logEngine.trace("(MobileBuilder) Ionic module ts file generated for 'app'");
}
}
} catch (Exception e) {
throw new EngineException("Unable to write ionic app module ts file", e);
}
}
use of com.twinsoft.convertigo.beans.ngx.components.PageComponent in project convertigo by convertigo.
the class NgxBuilder method pageDisabled.
@Override
public synchronized void pageDisabled(final IPageComponent pageComponent) throws EngineException {
PageComponent page = (PageComponent) pageComponent;
if (page != null && !page.isEnabled() && initDone) {
MobileApplication mobileApplication = project.getMobileApplication();
if (mobileApplication != null) {
ApplicationComponent application = (ApplicationComponent) mobileApplication.getApplicationComponent();
if (application != null) {
writePageSourceFiles(page);
writeAppSourceFiles(application);
moveFiles();
Engine.logEngine.trace("(MobileBuilder) Handled 'pageDisabled'");
}
}
}
}
use of com.twinsoft.convertigo.beans.ngx.components.PageComponent in project convertigo by convertigo.
the class NgxBuilder method getAppComponentTsContent.
private String getAppComponentTsContent(ApplicationComponent app) throws IOException {
String c8o_AppProdMode = "";
String c8o_PagesImport = "";
String c8o_PagesVariables = "";
String c8o_PagesVariablesKeyValue = "";
String c8o_RootPage = "null";
String c8o_PageArrayDef = "Array<>";
String c8o_Version = app.getC8oVersion();
String c8o_AppComponentMarkers = app.getComponentScriptContent().getString();
String c8o_AppImports = app.getComputedImports();
String c8o_AppDeclarations = app.getComputedDeclarations();
String c8o_AppConstructors = app.getComputedConstructors();
String c8o_AppFunctions = app.getComputedFunctions();
int i = 1;
if (app.compareToTplVersion("7.9.0.2") >= 0) {
// c8o_PageArrayDef = "Array<{title: string, titleKey: string, icon: string, iconPos: string, component: any, name: string, includedInAutoMenu?: boolean}>";
c8o_PageArrayDef = "Array<{title: string, titleKey: string, url: string, icon: string, iconPos: string, name: string, includedInAutoMenu?: boolean}>";
}
List<PageComponent> pages = getEnabledPages(app);
for (PageComponent page : pages) {
String pageName = page.getName();
String pageIcon = page.getIcon();
String pageIconPos = page.getIconPosition();
String pageTitle = page.getTitle();
String pageSegment = page.getSegment();
String pageTitleKey = TranslateUtils.getComputedKey(project, page.getTitle());
boolean isRootPage = page.isRoot;
boolean isMenuPage = page.isInAutoMenu();
boolean isLastPage = i == pages.size();
if (isRootPage) {
c8o_RootPage = pageName;
}
if (app.compareToTplVersion("7.9.0.2") >= 0) {
if (isRootPage) {
c8o_RootPage = "'" + c8o_RootPage + "'";
}
c8o_PagesVariables += " { title: \"" + pageTitle + "\", titleKey: \"" + pageTitleKey + "\", url: \"" + pageSegment + "\", icon: \"" + pageIcon + "\", iconPos: \"" + pageIconPos + "\", name: \"" + pageName + "\", includedInAutoMenu: " + isMenuPage + "}" + (isLastPage ? "" : ",");
c8o_PagesVariablesKeyValue += pageName + ":" + "this.rootPage" + (isLastPage ? "" : ",");
}
i++;
}
String computedRoute = app.getComputedRoute();
File appComponentTpl = new File(ionicTplDir, "src/app/app.component.ts");
String cContent = FileUtils.readFileToString(appComponentTpl, "UTF-8");
if (app.compareToTplVersion("7.7.0.2") >= 0) {
c8o_AppProdMode = MobileBuilderBuildMode.production.equals(buildMode) ? "enableProdMode();" : "";
}
cContent = cContent.replaceAll("/\\*\\=c8o_PagesImport\\*/", c8o_PagesImport);
cContent = cContent.replaceAll("/\\*\\=c8o_RootPage\\*/", c8o_RootPage);
cContent = cContent.replaceAll("/\\*\\=c8o_PageArrayDef\\*/", c8o_PageArrayDef);
cContent = cContent.replaceAll("/\\*\\=c8o_PagesVariables\\*/", c8o_PagesVariables);
cContent = cContent.replaceAll("/\\*\\=c8o_PagesVariablesKeyValue\\*/", c8o_PagesVariablesKeyValue);
cContent = cContent.replaceAll("/\\*\\=c8o_RoutingTable\\*/", computedRoute);
cContent = cContent.replaceAll("/\\*\\=c8o_AppImports\\*/", c8o_AppImports);
cContent = cContent.replaceAll("/\\*\\=c8o_AppDeclarations\\*/", c8o_AppDeclarations);
cContent = cContent.replaceAll("/\\*\\=c8o_AppConstructors\\*/", c8o_AppConstructors);
cContent = cContent.replaceAll("/\\*\\=c8o_AppProdMode\\*/", c8o_AppProdMode);
String c8oInit = "settings.addHeader(\"x-convertigo-mb\", \"" + c8o_Version + "\");\n\t\tthis.c8o.init(";
cContent = cContent.replaceFirst("this\\.c8o\\.init\\(", c8oInit);
// begin c8o marker
Pattern pattern = Pattern.compile("/\\*Begin_c8o_(.+)\\*/");
Matcher matcher = pattern.matcher(cContent);
while (matcher.find()) {
String markerId = matcher.group(1);
String tplMarker = getMarker(cContent, markerId);
String customMarker = getMarker(c8o_AppComponentMarkers, markerId);
if (!customMarker.isEmpty()) {
cContent = cContent.replace(tplMarker, customMarker);
}
}
cContent = cContent.replaceAll("/\\*\\=c8o_AppFunctions\\*/", Matcher.quoteReplacement(c8o_AppFunctions));
return cContent;
}
Aggregations