Search in sources :

Example 11 with UISharedComponent

use of com.twinsoft.convertigo.beans.ngx.components.UISharedComponent in project convertigo by convertigo.

the class NgxBuilder method compTemplateChanged.

@Override
public void compTemplateChanged(final ISharedComponent sharedComponent) throws EngineException {
    UISharedComponent comp = (UISharedComponent) sharedComponent;
    if (comp != null && initDone) {
        synchronized (comp) {
            writeCompTemplate(comp);
            moveFiles();
            Engine.logEngine.trace("(MobileBuilder) Handled 'compTemplateChanged'");
        }
    }
}
Also used : UISharedComponent(com.twinsoft.convertigo.beans.ngx.components.UISharedComponent)

Example 12 with UISharedComponent

use of com.twinsoft.convertigo.beans.ngx.components.UISharedComponent in project convertigo by convertigo.

the class NgxBuilder method getTempTsRelativePath.

@Override
public String getTempTsRelativePath(final ISharedComponent compComponent) throws EngineException {
    UISharedComponent comp = (UISharedComponent) compComponent;
    try {
        if (comp != null) {
            String compName = comp.getName();
            File compDir = compDir(comp);
            File tempTsFile = new File(compDir, compName.toLowerCase() + ".temp.ts");
            String filePath = tempTsFile.getPath().replace(projectDir.getPath(), File.separator);
            return filePath;
        }
    } catch (Exception e) {
        throw new EngineException("Unable to write component temp ts file", e);
    }
    return null;
}
Also used : EngineException(com.twinsoft.convertigo.engine.EngineException) UISharedComponent(com.twinsoft.convertigo.beans.ngx.components.UISharedComponent) File(java.io.File) IOException(java.io.IOException) EngineException(com.twinsoft.convertigo.engine.EngineException)

Example 13 with UISharedComponent

use of com.twinsoft.convertigo.beans.ngx.components.UISharedComponent in project convertigo by convertigo.

the class NgxBuilder method compRenamed.

@Override
public void compRenamed(final ISharedComponent sharedComponent, final String oldName) throws EngineException {
    UISharedComponent comp = (UISharedComponent) sharedComponent;
    if (comp != null && initDone) {
        synchronized (comp) {
            String newName = comp.getName();
            String newQName = comp.getQName();
            String oldQName = newQName.replace("." + newName, "." + oldName);
            ComponentRefManager.get(Mode.use).copyKey(oldQName, newQName);
            MobileApplication mobileApplication = project.getMobileApplication();
            if (mobileApplication != null) {
                ApplicationComponent application = (ApplicationComponent) mobileApplication.getApplicationComponent();
                if (application != null) {
                    writeCompSourceFiles(comp);
                    writeAppSourceFiles(application);
                    deleteUselessCompDir(oldName, oldQName);
                    moveFiles();
                    Engine.logEngine.trace("(MobileBuilder) Handled 'compRenamed'");
                }
            }
        }
    }
}
Also used : MobileApplication(com.twinsoft.convertigo.beans.core.MobileApplication) ApplicationComponent(com.twinsoft.convertigo.beans.ngx.components.ApplicationComponent) IApplicationComponent(com.twinsoft.convertigo.beans.core.IApplicationComponent) UISharedComponent(com.twinsoft.convertigo.beans.ngx.components.UISharedComponent)

Example 14 with UISharedComponent

use of com.twinsoft.convertigo.beans.ngx.components.UISharedComponent in project convertigo by convertigo.

the class NgxBuilder method compModuleTsChanged.

@Override
public void compModuleTsChanged(ISharedComponent sharedComponent) throws EngineException {
    UISharedComponent comp = (UISharedComponent) sharedComponent;
    if (comp != null && initDone) {
        synchronized (comp) {
            writeCompModuleTs(comp);
            moveFiles();
            Engine.logEngine.trace("(MobileBuilder) Handled 'compModuleTsChanged'");
        }
    }
}
Also used : UISharedComponent(com.twinsoft.convertigo.beans.ngx.components.UISharedComponent)

Example 15 with UISharedComponent

use of com.twinsoft.convertigo.beans.ngx.components.UISharedComponent in project convertigo by convertigo.

the class NgxBuilder method writeCompTempTs.

@Override
public void writeCompTempTs(final ISharedComponent compComponent) throws EngineException {
    UISharedComponent comp = (UISharedComponent) compComponent;
    try {
        if (comp != null) {
            String compName = comp.getName();
            File compDir = compDir(comp);
            String tsContent;
            boolean isEnabled = true;
            if (isEnabled) {
                File compTsFile = new File(compDir, compName.toLowerCase() + ".ts");
                synchronized (writtenFiles) {
                    if (writtenFiles.contains(compTsFile)) {
                        File compTsFileTmp = toTmpFile(compTsFile);
                        if (compTsFileTmp.exists()) {
                            compTsFile = compTsFileTmp;
                        }
                    }
                }
                tsContent = FileUtils.readFileToString(compTsFile, "UTF-8");
            } else {
                tsContent = getCompTsContent(comp);
            }
            // 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_CompFunction*/");
            if (index != -1) {
                tsContent = tsContent.substring(0, index) + "/*End_c8o_CompFunction*/" + System.lineSeparator() + "}";
            }
            // Write file (do not need delay)
            tsContent = LsPattern.matcher(tsContent).replaceAll(System.lineSeparator());
            File tempTsFile = new File(compDir, compName.toLowerCase() + ".temp.ts");
            FileUtils.write(tempTsFile, tsContent, "UTF-8");
        }
    } catch (Exception e) {
        throw new EngineException("Unable to write ionic component temp ts file", e);
    }
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) EngineException(com.twinsoft.convertigo.engine.EngineException) UISharedComponent(com.twinsoft.convertigo.beans.ngx.components.UISharedComponent) File(java.io.File) IOException(java.io.IOException) EngineException(com.twinsoft.convertigo.engine.EngineException)

Aggregations

UISharedComponent (com.twinsoft.convertigo.beans.ngx.components.UISharedComponent)34 ApplicationComponent (com.twinsoft.convertigo.beans.ngx.components.ApplicationComponent)16 EngineException (com.twinsoft.convertigo.engine.EngineException)15 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)13 UIActionStack (com.twinsoft.convertigo.beans.ngx.components.UIActionStack)13 PageComponent (com.twinsoft.convertigo.beans.ngx.components.PageComponent)11 UIComponent (com.twinsoft.convertigo.beans.ngx.components.UIComponent)11 UIUseShared (com.twinsoft.convertigo.beans.ngx.components.UIUseShared)8 MobileApplication (com.twinsoft.convertigo.beans.core.MobileApplication)7 File (java.io.File)7 IApplicationComponent (com.twinsoft.convertigo.beans.core.IApplicationComponent)6 IOException (java.io.IOException)6 CoreException (org.eclipse.core.runtime.CoreException)6 IPageComponent (com.twinsoft.convertigo.beans.core.IPageComponent)5 UIDynamicAction (com.twinsoft.convertigo.beans.ngx.components.UIDynamicAction)5 UIDynamicInvoke (com.twinsoft.convertigo.beans.ngx.components.UIDynamicInvoke)5 UnsupportedEncodingException (java.io.UnsupportedEncodingException)5 IScriptComponent (com.twinsoft.convertigo.beans.ngx.components.IScriptComponent)4 MobileSmartSourceType (com.twinsoft.convertigo.beans.ngx.components.MobileSmartSourceType)4 TreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject)4