Search in sources :

Example 1 with IPageComponent

use of com.twinsoft.convertigo.beans.core.IPageComponent in project convertigo by convertigo.

the class Ionic3Builder method pageModuleTsChanged.

@Override
public void pageModuleTsChanged(final IPageComponent pageComponent) throws EngineException {
    PageComponent page = (PageComponent) pageComponent;
    if (page != null && page.isEnabled() && initDone) {
        synchronized (page) {
            writePageModuleTs(page);
            moveFiles();
            Engine.logEngine.trace("(MobileBuilder) Handled 'pageModuleTsChanged'");
        }
    }
}
Also used : IPageComponent(com.twinsoft.convertigo.beans.core.IPageComponent) PageComponent(com.twinsoft.convertigo.beans.mobile.components.PageComponent)

Example 2 with IPageComponent

use of com.twinsoft.convertigo.beans.core.IPageComponent in project convertigo by convertigo.

the class Ionic3Builder method pageTsChanged.

@Override
public void pageTsChanged(final IPageComponent pageComponent, boolean forceTemp) throws EngineException {
    PageComponent page = (PageComponent) pageComponent;
    if (page != null && page.isEnabled() && initDone) {
        synchronized (page) {
            writePageTs(page);
            moveFiles();
            String pageName = page.getName();
            File pageDir = new File(ionicWorkDir, "src/pages/" + pageName);
            File tempTsFile = new File(pageDir, pageName.toLowerCase() + ".temp.ts");
            if (forceTemp && tempTsFile.exists()) {
                writePageTempTs(page);
            }
            Engine.logEngine.trace("(MobileBuilder) Handled 'pageTsChanged'");
        }
    }
}
Also used : File(java.io.File) IPageComponent(com.twinsoft.convertigo.beans.core.IPageComponent) PageComponent(com.twinsoft.convertigo.beans.mobile.components.PageComponent)

Example 3 with IPageComponent

use of com.twinsoft.convertigo.beans.core.IPageComponent in project convertigo by convertigo.

the class Ionic3Builder method pageEnabled.

@Override
public void pageEnabled(final IPageComponent pageComponent) throws EngineException {
    PageComponent page = (PageComponent) pageComponent;
    if (page != null && page.isEnabled() && initDone) {
        synchronized (page) {
            addPage(page);
            moveFiles();
            Engine.logEngine.trace("(MobileBuilder) Handled 'pageEnabled'");
        }
    }
}
Also used : IPageComponent(com.twinsoft.convertigo.beans.core.IPageComponent) PageComponent(com.twinsoft.convertigo.beans.mobile.components.PageComponent)

Example 4 with IPageComponent

use of com.twinsoft.convertigo.beans.core.IPageComponent in project convertigo by convertigo.

the class Ionic3Builder method pageAdded.

@Override
public void pageAdded(final IPageComponent pageComponent) throws EngineException {
    PageComponent page = (PageComponent) pageComponent;
    if (page != null && page.isEnabled() && page.bNew && initDone) {
        synchronized (page) {
            addPage(page);
            moveFiles();
            Engine.logEngine.trace("(MobileBuilder) Handled 'pageAdded'");
        }
    }
}
Also used : IPageComponent(com.twinsoft.convertigo.beans.core.IPageComponent) PageComponent(com.twinsoft.convertigo.beans.mobile.components.PageComponent)

Example 5 with IPageComponent

use of com.twinsoft.convertigo.beans.core.IPageComponent in project convertigo by convertigo.

the class Ionic3Builder method writePageTempTs.

@Override
public void writePageTempTs(final IPageComponent pageComponent) throws EngineException {
    PageComponent page = (PageComponent) pageComponent;
    try {
        if (page != null) {
            String pageName = page.getName();
            File pageDir = new File(ionicWorkDir, "src/pages/" + pageName);
            String tsContent;
            if (page.isEnabled()) {
                File pageTsFile = new File(pageDir, pageName.toLowerCase() + ".ts");
                synchronized (writtenFiles) {
                    if (writtenFiles.contains(pageTsFile)) {
                        File pageTsFileTmp = toTmpFile(pageTsFile);
                        if (pageTsFileTmp.exists()) {
                            pageTsFile = pageTsFileTmp;
                        }
                    }
                }
                tsContent = FileUtils.readFileToString(pageTsFile, "UTF-8");
            } else {
                tsContent = getPageTsContent(page);
            }
            // Replace all Begin_c8o_function:XXX, End_c8o_function:XXX
            Pattern pattern = Pattern.compile("/\\*Begin_c8o_function:(.+)\\*/");
            Matcher matcher = pattern.matcher(tsContent);
            while (matcher.find()) {
                String markerId = matcher.group(1);
                String beginMarker = "/*Begin_c8o_function:" + markerId + "*/";
                String endMarker = "/*End_c8o_function:" + markerId + "*/";
                tsContent = tsContent.replace(beginMarker, "//---" + markerId + "---");
                tsContent = tsContent.replace(endMarker, "//---" + markerId + "---");
            }
            // Remove all CTSXXX
            int index = tsContent.indexOf("/*End_c8o_PageFunction*/");
            if (index != -1) {
                tsContent = tsContent.substring(0, index) + "/*End_c8o_PageFunction*/" + System.lineSeparator() + "}";
            }
            // Write file (do not need delay)
            tsContent = LsPattern.matcher(tsContent).replaceAll(System.lineSeparator());
            File tempTsFile = new File(pageDir, pageName.toLowerCase() + ".temp.ts");
            FileUtils.write(tempTsFile, tsContent, "UTF-8");
        }
    } catch (Exception e) {
        throw new EngineException("Unable to write ionic page temp ts file", e);
    }
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) EngineException(com.twinsoft.convertigo.engine.EngineException) File(java.io.File) IPageComponent(com.twinsoft.convertigo.beans.core.IPageComponent) PageComponent(com.twinsoft.convertigo.beans.mobile.components.PageComponent) IOException(java.io.IOException) EngineException(com.twinsoft.convertigo.engine.EngineException)

Aggregations

IPageComponent (com.twinsoft.convertigo.beans.core.IPageComponent)22 PageComponent (com.twinsoft.convertigo.beans.mobile.components.PageComponent)11 PageComponent (com.twinsoft.convertigo.beans.ngx.components.PageComponent)11 IApplicationComponent (com.twinsoft.convertigo.beans.core.IApplicationComponent)6 MobileApplication (com.twinsoft.convertigo.beans.core.MobileApplication)6 File (java.io.File)6 EngineException (com.twinsoft.convertigo.engine.EngineException)4 IOException (java.io.IOException)4 ApplicationComponent (com.twinsoft.convertigo.beans.mobile.components.ApplicationComponent)3 ApplicationComponent (com.twinsoft.convertigo.beans.ngx.components.ApplicationComponent)3 Matcher (java.util.regex.Matcher)2 Pattern (java.util.regex.Pattern)2