Search in sources :

Example 6 with IApplicationComponent

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

the class NgxBuilder method appRouteChanged.

@Override
public void appRouteChanged(final IApplicationComponent appComponent) throws EngineException {
    ApplicationComponent app = (ApplicationComponent) appComponent;
    if (app != null && initDone) {
        synchronized (app) {
            writeAppComponentTs(app);
            moveFiles();
            File appComponentTsFile = new File(appDir, "app.component.temp.ts");
            if (appComponentTsFile.exists()) {
                writeAppComponentTempTs(app);
            }
            Engine.logEngine.trace("(MobileBuilder) Handled 'appRouteChanged'");
        }
    }
}
Also used : ApplicationComponent(com.twinsoft.convertigo.beans.ngx.components.ApplicationComponent) IApplicationComponent(com.twinsoft.convertigo.beans.core.IApplicationComponent) File(java.io.File)

Example 7 with IApplicationComponent

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

the class NgxBuilder method appModuleTsChanged.

@Override
public void appModuleTsChanged(final IApplicationComponent appComponent) throws EngineException {
    ApplicationComponent app = (ApplicationComponent) appComponent;
    if (app != null && initDone) {
        synchronized (app) {
            writeAppModuleTs(app);
            moveFiles();
            Engine.logEngine.trace("(MobileBuilder) Handled 'appModuleTsChanged'");
        }
    }
}
Also used : ApplicationComponent(com.twinsoft.convertigo.beans.ngx.components.ApplicationComponent) IApplicationComponent(com.twinsoft.convertigo.beans.core.IApplicationComponent)

Example 8 with IApplicationComponent

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

the class NgxBuilder method appThemeChanged.

@Override
public void appThemeChanged(final IApplicationComponent appComponent) throws EngineException {
    ApplicationComponent app = (ApplicationComponent) appComponent;
    if (app != null && initDone) {
        synchronized (app) {
            writeAppTheme(app);
            moveFiles();
            Engine.logEngine.trace("(MobileBuilder) Handled 'appThemeChanged'");
        }
    }
}
Also used : ApplicationComponent(com.twinsoft.convertigo.beans.ngx.components.ApplicationComponent) IApplicationComponent(com.twinsoft.convertigo.beans.core.IApplicationComponent)

Example 9 with IApplicationComponent

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

the class BuildLocallyAction method build.

/**
 * Function which made the build
 * @param option
 * @param run
 * @param target
 */
public void build(final String option, final boolean run, final String target) {
    Cursor waitCursor = null;
    if (parentShell != null) {
        waitCursor = new Cursor(ConvertigoPlugin.getDisplay(), SWT.CURSOR_WAIT);
        parentShell.setCursor(waitCursor);
    }
    try {
        if (mobilePlatform != null) {
            // Check endpoint url is empty or not
            MobileApplication mobileApplication = mobilePlatform.getObject().getParent();
            String[] exEndpoint = { mobileApplication.getEndpoint() };
            String[] curEndpoint = { exEndpoint[0] };
            try {
                MobileApplicationEndpointEditorComposite[] mob = new MobileApplicationEndpointEditorComposite[1];
                Dialog dialog = new Dialog(parentShell) {

                    @Override
                    protected void createButtonsForButtonBar(Composite parent) {
                        createButton(parent, IDialogConstants.OK_ID, "Build (temporary end point)", true);
                        createButton(parent, IDialogConstants.FINISH_ID, "Build (permanent end point)", false);
                        createButton(parent, IDialogConstants.CANCEL_ID, "Cancel Build", false);
                    }

                    @Override
                    protected void buttonPressed(int buttonId) {
                        super.buttonPressed(buttonId);
                        if (IDialogConstants.FINISH_ID == buttonId) {
                            setReturnCode(buttonId);
                            close();
                        }
                    }

                    @Override
                    protected Control createDialogArea(Composite parent) {
                        Composite composite = (Composite) super.createDialogArea(parent);
                        mob[0] = new MobileApplicationEndpointEditorComposite(composite, SWT.NONE, mobileApplication);
                        return composite;
                    }
                };
                int code = dialog.open();
                if (code == Dialog.OK || code == IDialogConstants.FINISH_ID) {
                    curEndpoint[0] = mob[0].getValue();
                } else {
                    return;
                }
                if (code == IDialogConstants.FINISH_ID) {
                    String s = mobileApplication.getEndpoint();
                    if (!s.equals(curEndpoint[0])) {
                        mobileApplication.setEndpoint(curEndpoint[0]);
                        mobilePlatform.getParentDatabaseObjectTreeObject().hasBeenModified(true);
                        ProjectExplorerView explorerView = getProjectExplorerView();
                        if (explorerView != null) {
                            ConvertigoPlugin.getDisplay().asyncExec(() -> {
                                explorerView.viewer.refresh(mobilePlatform.getProjectTreeObject(), true);
                            });
                        }
                    }
                    exEndpoint[0] = null;
                }
            } catch (Exception e) {
            }
            if (curEndpoint[0].equals("")) {
                if (parentShell != null) {
                    MessageBox informDialog = new MessageBox(parentShell, SWT.ICON_INFORMATION | SWT.OK);
                    informDialog.setText("Endpoint URL is empty");
                    informDialog.setMessage("You need to have an endpoint URL to continue the local build.\n" + "Please enter a valid endpoint URL in the property \"Convertigo server endpoint\" present on \"" + mobileApplication.getName() + "\" object.");
                    informDialog.open();
                } else {
                // TODO
                }
                return;
            }
            IApplicationComponent app = mobileApplication.getApplicationComponent();
            String msg = app != null ? app.getUnbuiltMessage() : null;
            if (msg != null && parentShell != null) {
                MessageBox informDialog = new MessageBox(parentShell, SWT.ICON_QUESTION | SWT.YES | SWT.NO);
                informDialog.setText("Application not ready");
                informDialog.setMessage(msg + "\nThen launch the Local Build again.\n" + "Do you want to build now anyway?");
                int result = informDialog.open();
                if (result == SWT.NO) {
                    return;
                }
            }
            // OK we are sure we have a Cordova environment.. Start the build
            Job buildJob = new Job("Local Cordova Build " + (run ? "and Run " : "") + "in progress...") {

                @Override
                protected IStatus run(IProgressMonitor progressMonitor) {
                    BuildLocally.Status status = buildLocally.installCordova();
                    if (status == BuildLocally.Status.CANCEL) {
                        return org.eclipse.core.runtime.Status.CANCEL_STATUS;
                    }
                    try {
                        mobileApplication.setEndpoint(curEndpoint[0]);
                        status = buildLocally.runBuild(option, run, target);
                        if (status == BuildLocally.Status.OK) {
                            return org.eclipse.core.runtime.Status.OK_STATUS;
                        }
                        return org.eclipse.core.runtime.Status.CANCEL_STATUS;
                    } finally {
                        if (exEndpoint[0] != null) {
                            mobileApplication.setEndpoint(exEndpoint[0]);
                        }
                    }
                }

                @Override
                protected void canceling() {
                    buildLocally.cancelBuild(run);
                }
            };
            buildJob.setUser(true);
            buildJob.schedule();
        }
    } catch (Throwable e) {
        ConvertigoPlugin.logException(e, "Unable to build locally with Cordova");
    } finally {
        parentShell.setCursor(null);
        waitCursor.dispose();
    }
}
Also used : BuildLocally(com.twinsoft.convertigo.engine.localbuild.BuildLocally) ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) MobileApplicationEndpointEditorComposite(com.twinsoft.convertigo.eclipse.property_editors.MobileApplicationEndpointEditorComposite) Composite(org.eclipse.swt.widgets.Composite) Cursor(org.eclipse.swt.graphics.Cursor) MessageBox(org.eclipse.swt.widgets.MessageBox) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) MobileApplication(com.twinsoft.convertigo.beans.core.MobileApplication) Dialog(org.eclipse.jface.dialogs.Dialog) BuildLocallyEndingDialog(com.twinsoft.convertigo.eclipse.dialogs.BuildLocallyEndingDialog) MobileApplicationEndpointEditorComposite(com.twinsoft.convertigo.eclipse.property_editors.MobileApplicationEndpointEditorComposite) Job(org.eclipse.core.runtime.jobs.Job) IApplicationComponent(com.twinsoft.convertigo.beans.core.IApplicationComponent)

Example 10 with IApplicationComponent

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

the class GetTestPlatform method getServiceResult.

protected void getServiceResult(HttpServletRequest request, Document document) throws Exception {
    Element root = document.getDocumentElement();
    String projectName = request.getParameter("projectName");
    Project project = Engine.theApp.databaseObjectsManager.getOriginalProjectByName(projectName);
    Element e_project = createDatabaseObjectElement(document, project);
    Connector defaultConnector = project.getDefaultConnector();
    e_project.setAttribute("defaultConnector", defaultConnector.getName());
    e_project.setAttribute("defaultTransaction", defaultConnector.getDefaultTransaction().getName());
    boolean bTpHiddenRole = Engine.authenticatedSessionManager.hasRole(request.getSession(), Role.TEST_PLATFORM_HIDDEN);
    boolean bTpPrivateRole = Engine.authenticatedSessionManager.hasRole(request.getSession(), Role.TEST_PLATFORM_PRIVATE);
    for (Connector connector : project.getConnectorsList()) {
        Element e_connector = createDatabaseObjectElement(document, connector);
        for (Transaction transaction : connector.getTransactionsList()) {
            // WEB_ADMIN role is allowed to execute all requestables
            if (transaction.isPublicAccessibility() || (transaction.isHiddenAccessibility() && bTpHiddenRole) || bTpPrivateRole) {
                e_connector.appendChild(createRequestableElement(document, transaction));
            }
        }
        e_project.appendChild(e_connector);
    }
    for (Sequence sequence : project.getSequencesList()) {
        // WEB_ADMIN role is allowed to execute all requestables
        if (sequence.isPublicAccessibility() || (sequence.isHiddenAccessibility() && bTpHiddenRole) || bTpPrivateRole) {
            e_project.appendChild(createRequestableElement(document, sequence));
        }
    }
    MobileApplication mobileApplication = project.getMobileApplication();
    if (mobileApplication != null && (mobileApplication.getAccessibility() == Accessibility.Public || (mobileApplication.getAccessibility() == Accessibility.Hidden && bTpHiddenRole) || bTpPrivateRole)) {
        Element e_mobileApplication = createDatabaseObjectElement(document, mobileApplication);
        String applicationID = mobileApplication.getComputedApplicationId();
        e_mobileApplication.setAttribute("applicationID", applicationID);
        String endpoint = mobileApplication.getComputedEndpoint(request);
        e_mobileApplication.setAttribute("endpoint", endpoint);
        String version = mobileApplication.getComputedApplicationVersion();
        e_mobileApplication.setAttribute("applicationVersion", version);
        e_project.appendChild(e_mobileApplication);
        for (MobilePlatform platform : mobileApplication.getMobilePlatformList()) {
            Element e_device = createDatabaseObjectElement(document, platform);
            e_device.setAttribute("classname", platform.getClass().getSimpleName());
            e_device.setAttribute("displayName", CachedIntrospector.getBeanInfo(platform.getClass()).getBeanDescriptor().getDisplayName());
            e_device.setAttribute("packageType", platform.getPackageType());
            e_device.setAttribute("revision", "computing...");
            e_mobileApplication.appendChild(e_device);
        }
        try {
            String mobileProjectName = mobileApplication.getComputedApplicationName();
            e_mobileApplication.setAttribute("mobileProjectName", mobileProjectName);
        } catch (Exception e) {
            Engine.logAdmin.error("Failed to retrieve the application mobile name", e);
        }
        IApplicationComponent app = mobileApplication.getApplicationComponent();
        String msg = app != null ? app.getUnbuiltMessage() : null;
        if (msg != null) {
            e_mobileApplication.setAttribute("unbuiltMessage", msg);
        }
    }
    root.appendChild(e_project);
}
Also used : Project(com.twinsoft.convertigo.beans.core.Project) Connector(com.twinsoft.convertigo.beans.core.Connector) MobilePlatform(com.twinsoft.convertigo.beans.core.MobilePlatform) Transaction(com.twinsoft.convertigo.beans.core.Transaction) MobileApplication(com.twinsoft.convertigo.beans.core.MobileApplication) Element(org.w3c.dom.Element) Sequence(com.twinsoft.convertigo.beans.core.Sequence) IApplicationComponent(com.twinsoft.convertigo.beans.core.IApplicationComponent)

Aggregations

IApplicationComponent (com.twinsoft.convertigo.beans.core.IApplicationComponent)27 ApplicationComponent (com.twinsoft.convertigo.beans.mobile.components.ApplicationComponent)12 ApplicationComponent (com.twinsoft.convertigo.beans.ngx.components.ApplicationComponent)12 File (java.io.File)11 EngineException (com.twinsoft.convertigo.engine.EngineException)4 IOException (java.io.IOException)4 MobileApplication (com.twinsoft.convertigo.beans.core.MobileApplication)2 Composite (org.eclipse.swt.widgets.Composite)2 Connector (com.twinsoft.convertigo.beans.core.Connector)1 MobilePlatform (com.twinsoft.convertigo.beans.core.MobilePlatform)1 Project (com.twinsoft.convertigo.beans.core.Project)1 Sequence (com.twinsoft.convertigo.beans.core.Sequence)1 Transaction (com.twinsoft.convertigo.beans.core.Transaction)1 BuildLocallyEndingDialog (com.twinsoft.convertigo.eclipse.dialogs.BuildLocallyEndingDialog)1 MobileApplicationEndpointEditorComposite (com.twinsoft.convertigo.eclipse.property_editors.MobileApplicationEndpointEditorComposite)1 ProjectExplorerView (com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView)1 ArchiveExportOption (com.twinsoft.convertigo.engine.enums.ArchiveExportOption)1 BuildLocally (com.twinsoft.convertigo.engine.localbuild.BuildLocally)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 Job (org.eclipse.core.runtime.jobs.Job)1