Search in sources :

Example 21 with PageComponent

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

the class NgxApplicationComponentTreeObject method treeObjectAdded.

@Override
public void treeObjectAdded(TreeObjectEvent treeObjectEvent) {
    super.treeObjectAdded(treeObjectEvent);
    TreeObject treeObject = (TreeObject) treeObjectEvent.getSource();
    String propertyName = (String) treeObjectEvent.propertyName;
    propertyName = ((propertyName == null) ? "" : propertyName);
    if (treeObject instanceof DatabaseObjectTreeObject) {
        DatabaseObjectTreeObject doto = (DatabaseObjectTreeObject) treeObject;
        DatabaseObject dbo = doto.getObject();
        try {
            // we add a page to this app
            if (dbo instanceof PageComponent && getObject().equals(dbo.getParent())) {
                PageComponent page = (PageComponent) dbo;
                if (page.bNew) {
                    page.markPageAsDirty();
                }
            }
        } catch (Exception e) {
        }
    }
}
Also used : DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) PageComponent(com.twinsoft.convertigo.beans.ngx.components.PageComponent) InvalidParameterException(java.security.InvalidParameterException) PartInitException(org.eclipse.ui.PartInitException) InvocationTargetException(java.lang.reflect.InvocationTargetException) EngineException(com.twinsoft.convertigo.engine.EngineException)

Example 22 with PageComponent

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

the class NgxPageComponentTreeObject method getNamedSourceSelector.

@Override
public NamedSourceSelector getNamedSourceSelector() {
    return new NamedSourceSelector() {

        @Override
        Object thisTreeObject() {
            return NgxPageComponentTreeObject.this;
        }

        @Override
        protected List<String> getPropertyNamesForSource(Class<?> c) {
            List<String> list = new ArrayList<String>();
            if (getObject() instanceof PageComponent) {
                if (ProjectTreeObject.class.isAssignableFrom(c) || MobileApplicationTreeObject.class.isAssignableFrom(c) || NgxApplicationComponentTreeObject.class.isAssignableFrom(c) || NgxUIComponentTreeObject.class.isAssignableFrom(c)) {
                    list.add("startMenu");
                    list.add("endMenu");
                }
            }
            return list;
        }

        @Override
        protected boolean isNamedSource(String propertyName) {
            if (getObject() instanceof PageComponent) {
                return "startMenu".equals(propertyName) || "endMenu".equals(propertyName);
            }
            return false;
        }

        @Override
        public boolean isSelectable(String propertyName, Object nsObject) {
            if (getObject() instanceof PageComponent) {
                if ("startMenu".equals(propertyName) || "endMenu".equals(propertyName)) {
                    PageComponent pc = getObject();
                    if (nsObject instanceof UIDynamicMenu) {
                        return (((UIDynamicMenu) nsObject).getProject().equals(pc.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;
                String pValue = (String) getPropertyValue(propertyName);
                if (pValue != null && pValue.startsWith(oldName)) {
                    String _pValue = newName + pValue.substring(oldName.length());
                    if (!pValue.equals(_pValue)) {
                        if (getObject() instanceof PageComponent) {
                            if ("startMenu".equals(propertyName)) {
                                getObject().setStartMenu(_pValue);
                                hasBeenRenamed = true;
                            }
                            if ("endMenu".equals(propertyName)) {
                                getObject().setEndMenu(_pValue);
                                hasBeenRenamed = true;
                            }
                        }
                    }
                }
                if (hasBeenRenamed) {
                    hasBeenModified(true);
                    ConvertigoPlugin.projectManager.getProjectExplorerView().updateTreeObject(NgxPageComponentTreeObject.this);
                    // refresh editors (e.g labels in combobox)
                    getDescriptors();
                    TreeObjectEvent treeObjectEvent = new TreeObjectEvent(NgxPageComponentTreeObject.this, propertyName, "", "");
                    ConvertigoPlugin.projectManager.getProjectExplorerView().fireTreeObjectPropertyChanged(treeObjectEvent);
                }
            }
        }
    };
}
Also used : ArrayList(java.util.ArrayList) PageComponent(com.twinsoft.convertigo.beans.ngx.components.PageComponent) UIDynamicMenu(com.twinsoft.convertigo.beans.ngx.components.UIDynamicMenu) TreeObjectEvent(com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeObjectEvent)

Example 23 with PageComponent

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

the class NgxBuilder method pageStyleChanged.

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

Example 24 with PageComponent

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

the class NgxBuilder method updateSourceFiles.

private void updateSourceFiles() throws EngineException {
    try {
        MobileApplication mobileApplication = project.getMobileApplication();
        if (mobileApplication != null) {
            ApplicationComponent application = (ApplicationComponent) mobileApplication.getApplicationComponent();
            if (application != null) {
                String appTplVersion = application.requiredTplVersion();
                if (compareVersions(tplVersion, appTplVersion) >= 0) {
                    for (PageComponent page : getEnabledPages(application)) {
                        writePageSourceFiles(page);
                    }
                    writeAppSourceFiles(application);
                    removeUselessPages(application);
                    Engine.logEngine.trace("(MobileBuilder) Application source files updated for ionic project '" + project.getName() + "'");
                } else {
                    cleanDirectories();
                    throw new EngineException("Template project minimum " + appTplVersion + " is required for this project.\n" + "You can change template by configuring the 'Template project' property of your project's 'Application' object.\n" + "Then, be sure to update the project node modules packages (Application Right Click->Update packages and execute) \n");
                }
            }
        }
    } catch (EngineException e) {
        throw e;
    } catch (Exception e) {
        throw new EngineException("Unable to update application source files for ionic project '" + project.getName() + "'", e);
    }
}
Also used : MobileApplication(com.twinsoft.convertigo.beans.core.MobileApplication) ApplicationComponent(com.twinsoft.convertigo.beans.ngx.components.ApplicationComponent) IApplicationComponent(com.twinsoft.convertigo.beans.core.IApplicationComponent) EngineException(com.twinsoft.convertigo.engine.EngineException) IPageComponent(com.twinsoft.convertigo.beans.core.IPageComponent) PageComponent(com.twinsoft.convertigo.beans.ngx.components.PageComponent) IOException(java.io.IOException) EngineException(com.twinsoft.convertigo.engine.EngineException)

Example 25 with PageComponent

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

the class NgxBuilder method writeAppPackageJson.

private void writeAppPackageJson(ApplicationComponent app) throws EngineException {
    try {
        if (app != null) {
            Map<String, String> pkg_dependencies = new HashMap<>();
            // Menus contributors
            for (Contributor contributor : app.getContributors()) {
                pkg_dependencies.putAll(contributor.getPackageDependencies());
            }
            // Pages contributors
            List<PageComponent> pages = forceEnable ? app.getPageComponentList() : getEnabledPages(app);
            for (PageComponent page : pages) {
                List<Contributor> contributors = page.getContributors();
                for (Contributor contributor : contributors) {
                    pkg_dependencies.putAll(contributor.getPackageDependencies());
                }
            }
            File appPkgJsonTpl = new File(ionicTplDir, "package.json");
            String mContent = FileUtils.readFileToString(appPkgJsonTpl, "UTF-8");
            mContent = mContent.replaceAll("../DisplayObjects", "../../DisplayObjects");
            JSONObject jsonPackage = new JSONObject(mContent);
            JSONObject jsonDependencies = jsonPackage.getJSONObject("dependencies");
            for (String pkg : pkg_dependencies.keySet()) {
                jsonDependencies.put(pkg, pkg_dependencies.get(pkg));
                if (!existPackage(pkg)) {
                    setNeedPkgUpdate(true);
                }
            }
            boolean addNode = !jsonDependencies.has("@types/node");
            if (addNode) {
                try {
                    String version = new JSONObject(FileUtils.readFileToString(new File(ionicTplDir, "version.json"), "utf-8")).getString("version");
                    addNode = version.matches("7\\.[0-7]\\..*");
                } catch (Exception e) {
                }
                if (addNode) {
                    jsonDependencies.put("@types/node", "12.0.10");
                }
            }
            File appPkgJson = new File(ionicWorkDir, "package.json");
            writeFile(appPkgJson, jsonPackage.toString(2), "UTF-8");
            if (initDone) {
                Engine.logEngine.trace("(MobileBuilder) Ionic package json file generated");
            }
        }
    } catch (Exception e) {
        throw new EngineException("Unable to write ionic package json file", e);
    }
}
Also used : JSONObject(org.codehaus.jettison.json.JSONObject) HashMap(java.util.HashMap) EngineException(com.twinsoft.convertigo.engine.EngineException) Contributor(com.twinsoft.convertigo.beans.ngx.components.Contributor) File(java.io.File) IPageComponent(com.twinsoft.convertigo.beans.core.IPageComponent) PageComponent(com.twinsoft.convertigo.beans.ngx.components.PageComponent) IOException(java.io.IOException) EngineException(com.twinsoft.convertigo.engine.EngineException)

Aggregations

PageComponent (com.twinsoft.convertigo.beans.ngx.components.PageComponent)36 IPageComponent (com.twinsoft.convertigo.beans.core.IPageComponent)21 EngineException (com.twinsoft.convertigo.engine.EngineException)14 File (java.io.File)13 ApplicationComponent (com.twinsoft.convertigo.beans.ngx.components.ApplicationComponent)11 IOException (java.io.IOException)10 UIComponent (com.twinsoft.convertigo.beans.ngx.components.UIComponent)7 IApplicationComponent (com.twinsoft.convertigo.beans.core.IApplicationComponent)6 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)5 UIActionStack (com.twinsoft.convertigo.beans.ngx.components.UIActionStack)5 UISharedComponent (com.twinsoft.convertigo.beans.ngx.components.UISharedComponent)5 ProjectExplorerView (com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView)5 ArrayList (java.util.ArrayList)5 Cursor (org.eclipse.swt.graphics.Cursor)5 Display (org.eclipse.swt.widgets.Display)5 Shell (org.eclipse.swt.widgets.Shell)5 MobileApplication (com.twinsoft.convertigo.beans.core.MobileApplication)4 Contributor (com.twinsoft.convertigo.beans.ngx.components.Contributor)4 UIUseShared (com.twinsoft.convertigo.beans.ngx.components.UIUseShared)4 TreeObjectEvent (com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeObjectEvent)4