Search in sources :

Example 11 with MobileBuilder

use of com.twinsoft.convertigo.engine.mobile.MobileBuilder in project convertigo by convertigo.

the class ApplicationComponentEditor method launchBuilder.

public void launchBuilder(boolean forceInstall, boolean forceClean) {
    final MobileBuilderBuildMode buildMode = this.buildMode;
    final int buildCount = ++this.buildCount;
    final boolean isDark = SwtUtils.isDark();
    // Close editors (*.temp.ts) to avoid npm error at build launch
    ConvertigoPlugin.getDisplay().syncExec(new Runnable() {

        public void run() {
            try {
                ApplicationComponent mc = applicationEditorInput.application;
                IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
                if (activePage != null) {
                    IEditorReference[] editorRefs = activePage.getEditorReferences();
                    for (int i = 0; i < editorRefs.length; i++) {
                        IEditorReference editorRef = (IEditorReference) editorRefs[i];
                        try {
                            IEditorInput editorInput = editorRef.getEditorInput();
                            if (editorInput != null && editorInput instanceof ComponentFileEditorInput) {
                                if (((ComponentFileEditorInput) editorInput).is(mc) || ((ComponentFileEditorInput) editorInput).isChildOf(mc)) {
                                    activePage.closeEditor(editorRef.getEditor(false), false);
                                }
                            }
                        } catch (Exception e) {
                        }
                    }
                }
            } catch (Throwable t) {
            }
        }
    });
    // Launch build
    Engine.execute(() -> {
        try {
            String loader = IOUtils.toString(getClass().getResourceAsStream("loader.html"), "UTF-8");
            if (isDark) {
                loader = loader.replace("lightblue", "rgb(47,47,47); color: white");
            }
            c8oBrowser.setText(loader);
        } catch (Exception e1) {
            throw new RuntimeException(e1);
        }
        Project project = applicationEditorInput.application.getProject();
        File ionicDir = new File(project.getDirPath(), "_private/ionic");
        File nodeModules = new File(ionicDir, "node_modules");
        String nodeVersion = ProcessUtils.getNodeVersion(project);
        File nodeDir = ProcessUtils.getDefaultNodeDir();
        try {
            nodeDir = ProcessUtils.getNodeDir(nodeVersion, (r, t, x) -> {
                appendOutput("Downloading nodejs " + nodeVersion + ": " + Math.round((r * 100f) / t) + "%");
            });
        } catch (Exception e1) {
        }
        {
            String versions = "Will use nodejs " + ProcessUtils.getNodeVersion(nodeDir) + " and npm " + ProcessUtils.getNpmVersion(nodeDir);
            appendOutput(versions);
            Engine.logStudio.info(versions);
        }
        String path = nodeDir.getAbsolutePath();
        terminateNode();
        MobileBuilder mb = project.getMobileBuilder();
        if (forceInstall || !nodeModules.exists() || mb.getNeedPkgUpdate()) {
            boolean[] running = { true };
            try {
                new File(ionicDir, "package-lock.json").delete();
                if (forceClean) {
                    appendOutput("...", "...", "Removing existing node_modules... This can take several seconds...");
                    Engine.logStudio.info("Removing existing node_modules... This can take several seconds...");
                    com.twinsoft.convertigo.engine.util.FileUtils.deleteQuietly(nodeModules);
                }
                appendOutput("Installing node_modules... This can take several minutes depending on your network connection speed...");
                Engine.logStudio.info("Installing node_modules... This can take several minutes depending on your network connection speed...");
                long start = System.currentTimeMillis();
                ProcessBuilder pb = ProcessUtils.getNpmProcessBuilder(path, "npm", "install", ionicDir.toString(), "--no-shrinkwrap", "--no-package-lock");
                pb.redirectErrorStream(true);
                pb.directory(ionicDir);
                Process p = pb.start();
                Engine.execute(() -> {
                    try {
                        File staging = new File(nodeModules, ".staging");
                        while (running[0] && !staging.exists()) {
                            appendOutput("Resolving dependencies … (" + Math.round(System.currentTimeMillis() - start) / 1000 + " sec)");
                            Thread.sleep(1000);
                        }
                        while (running[0] && staging.exists()) {
                            appendOutput("Collecting node_modules: " + FileUtils.byteCountToDisplaySize(FileUtils.sizeOfAsBigInteger(nodeModules)) + " (" + Math.round(System.currentTimeMillis() - start) / 1000 + " sec)");
                            Engine.logStudio.info("Installing, node_module size is now : " + FileUtils.byteCountToDisplaySize(FileUtils.sizeOfAsBigInteger(nodeModules)));
                            Thread.sleep(1000);
                        }
                    } catch (Exception e) {
                        appendOutput("Something wrong during the install: " + e);
                    }
                });
                processes.add(p);
                BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
                String line;
                while ((line = br.readLine()) != null) {
                    line = pRemoveEchap.matcher(line).replaceAll("");
                    if (StringUtils.isNotBlank(line)) {
                        Engine.logStudio.info(line);
                        appendOutput(line);
                    }
                }
                Engine.logStudio.info(line);
                appendOutput("\\o/");
            } catch (Exception e) {
                appendOutput(":( " + e);
            }
            running[0] = false;
        }
        mb.setNeedPkgUpdate(false);
        Object mutex = new Object();
        mb.setBuildMutex(mutex);
        mb.setAppBuildMode(buildMode);
        try {
            ConvertigoPlugin.getDefault().getProjectPluginResource(project.getName()).refreshLocal(IResource.DEPTH_INFINITE, null);
        } catch (CoreException ce) {
        }
        try {
            mb.startBuild();
            File displayObjectsMobile = new File(project.getDirPath(), "DisplayObjects/mobile");
            displayObjectsMobile.mkdirs();
            appendOutput("removing previous build directory");
            for (File f : displayObjectsMobile.listFiles()) {
                if (!f.getName().equals("assets")) {
                    com.twinsoft.convertigo.engine.util.FileUtils.deleteQuietly(f);
                }
            }
            appendOutput("previous build directory removed");
            this.applicationEditorInput.application.checkFolder();
            try {
                File watchJS = new File(project.getDirPath(), "_private/ionic/node_modules/@ionic/app-scripts/dist/watch.js");
                if (watchJS.exists()) {
                    int ms = ConvertigoPlugin.getMobileBuilderThreshold();
                    String txt = FileUtils.readFileToString(watchJS, "UTF-8");
                    String ntxt = txt.replaceAll("var BUILD_UPDATE_DEBOUNCE_MS = \\d+;", "var BUILD_UPDATE_DEBOUNCE_MS = " + ms + ";");
                    if (!txt.equals(ntxt))
                        ;
                    {
                        FileUtils.writeStringToFile(watchJS, ntxt, "UTF-8");
                    }
                }
            } catch (Exception e) {
                Engine.logStudio.warn("Failed to update DEBOUNCE", e);
            }
            File assets = new File(displayObjectsMobile, "assets");
            if (assets.exists() && assets.isDirectory()) {
                appendOutput("Handle application assets");
                Engine.logStudio.info("Handle application assets");
                File privAssets = new File(ionicDir, "src/assets");
                FileUtils.deleteDirectory(privAssets);
                FileUtils.copyDirectory(assets, privAssets);
            }
            ProcessBuilder pb = ProcessUtils.getNpmProcessBuilder(path, "npm", "run", buildMode.command(), "--nobrowser");
            if (!MobileBuilderBuildMode.production.equals(buildMode)) {
                List<String> cmd = pb.command();
                synchronized (usedPort) {
                    cmd.add("--port");
                    cmd.add("" + (portNode = NetworkUtils.nextAvailable(8100, usedPort)));
                    cmd.add("--livereload-port");
                    cmd.add("" + (portReload = NetworkUtils.nextAvailable(35729, usedPort)));
                    cmd.add("--dev-logger-port");
                    cmd.add("" + (portLogger = NetworkUtils.nextAvailable(53703, usedPort)));
                }
            }
            pb.redirectErrorStream(true);
            pb.directory(ionicDir);
            Process p = pb.start();
            processes.add(p);
            BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
            String line;
            while ((line = br.readLine()) != null) {
                line = pRemoveEchap.matcher(line).replaceAll("");
                if (StringUtils.isNotBlank(line)) {
                    Engine.logStudio.info(line);
                    appendOutput(line);
                    if (line.matches(".*build .*finished.*")) {
                        synchronized (mutex) {
                            mutex.notify();
                        }
                        mb.buildFinished();
                    }
                    Matcher m = pIsServerRunning.matcher(line);
                    if (m.matches()) {
                        JSONObject envJSON = new JSONObject();
                        envJSON.put("remoteBase", EnginePropertiesManager.getProperty(PropertyName.APPLICATION_SERVER_CONVERTIGO_URL) + "/projects/" + project.getName() + "/_private");
                        FileUtils.write(new File(displayObjectsMobile, "env.json"), envJSON.toString(4), "UTF-8");
                        baseUrl = m.group(1);
                        synchronized (mutex) {
                            mutex.notify();
                        }
                        mb.buildFinished();
                        doLoad();
                    }
                }
            }
            if (buildCount == this.buildCount) {
                if (MobileBuilderBuildMode.production.equals(buildMode)) {
                    String SERVER_C8O_URL = EnginePropertiesManager.getProperty(PropertyName.APPLICATION_SERVER_CONVERTIGO_URL);
                    baseUrl = SERVER_C8O_URL + "/projects/" + project.getName() + "/DisplayObjects/mobile/index.html";
                    doLoad();
                    toast("Application in production mode");
                }
                appendOutput("\\o/");
            } else {
                appendOutput("previous build canceled !");
            }
        } catch (Exception e) {
            appendOutput(":( " + e);
        } finally {
            synchronized (mutex) {
                mutex.notify();
            }
            mb.setBuildMutex(null);
            mb.buildFinished();
            try {
                ConvertigoPlugin.getDefault().getProjectPluginResource(project.getName()).refreshLocal(IResource.DEPTH_INFINITE, null);
            } catch (CoreException ce) {
            }
        }
    });
}
Also used : Element(com.teamdev.jxbrowser.dom.Element) CoreException(org.eclipse.core.runtime.CoreException) FocusEvent(org.eclipse.swt.events.FocusEvent) StringUtils(org.apache.commons.lang3.StringUtils) Point(org.eclipse.swt.graphics.Point) Matcher(java.util.regex.Matcher) Composite(org.eclipse.swt.widgets.Composite) PartInitException(org.eclipse.ui.PartInitException) UIUseShared(com.twinsoft.convertigo.beans.mobile.components.UIUseShared) KeyEvent(org.eclipse.swt.events.KeyEvent) UIDynamicElement(com.twinsoft.convertigo.beans.mobile.components.UIDynamicElement) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) KeyAdapter(org.eclipse.swt.events.KeyAdapter) IEditorPart(org.eclipse.ui.IEditorPart) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Text(org.eclipse.swt.widgets.Text) IEditorInput(org.eclipse.ui.IEditorInput) PlatformUI(org.eclipse.ui.PlatformUI) Set(java.util.Set) ToolItem(org.eclipse.swt.widgets.ToolItem) IOUtils(org.apache.commons.io.IOUtils) MenuItem(org.eclipse.swt.widgets.MenuItem) SWT(org.eclipse.swt.SWT) UIActionStack(com.twinsoft.convertigo.beans.mobile.components.UIActionStack) JsAccessible(com.teamdev.jxbrowser.js.JsAccessible) MobileComponent(com.twinsoft.convertigo.beans.mobile.components.MobileComponent) EditorPart(org.eclipse.ui.part.EditorPart) SwtUtils(com.twinsoft.convertigo.eclipse.swt.SwtUtils) DatabaseObjectFoundException(com.twinsoft.convertigo.engine.DatabaseObjectFoundException) SelectionListener(org.eclipse.swt.events.SelectionListener) JFaceResources(org.eclipse.jface.resource.JFaceResources) IEditorSite(org.eclipse.ui.IEditorSite) RequestPermissionCallback(com.teamdev.jxbrowser.permission.callback.RequestPermissionCallback) GridData(org.eclipse.swt.layout.GridData) RowData(org.eclipse.swt.layout.RowData) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) UIDynamicInvoke(com.twinsoft.convertigo.beans.mobile.components.UIDynamicInvoke) Engine(com.twinsoft.convertigo.engine.Engine) JSONObject(org.codehaus.jettison.json.JSONObject) JSONArray(org.codehaus.jettison.json.JSONArray) MobileDebugView(com.twinsoft.convertigo.eclipse.views.mobile.MobileDebugView) MobileBuilderBuildMode(com.twinsoft.convertigo.engine.enums.MobileBuilderBuildMode) JsObject(com.teamdev.jxbrowser.js.JsObject) InputStreamReader(java.io.InputStreamReader) File(java.io.File) Node(com.teamdev.jxbrowser.dom.Node) Project(com.twinsoft.convertigo.beans.core.Project) UISharedComponent(com.twinsoft.convertigo.beans.mobile.components.UISharedComponent) JSONException(org.codehaus.jettison.json.JSONException) ModifyListener(org.eclipse.swt.events.ModifyListener) FileUtils(com.twinsoft.convertigo.engine.util.FileUtils) IEditorReference(org.eclipse.ui.IEditorReference) BufferedReader(java.io.BufferedReader) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ProcessUtils(com.twinsoft.convertigo.engine.util.ProcessUtils) GridLayout(org.eclipse.swt.layout.GridLayout) WalkHelper(com.twinsoft.convertigo.engine.helpers.WalkHelper) ClipboardAction(com.twinsoft.convertigo.eclipse.popup.actions.ClipboardAction) ToolBar(org.eclipse.swt.widgets.ToolBar) VerifyListener(org.eclipse.swt.events.VerifyListener) MobileEventListener(com.twinsoft.convertigo.engine.mobile.MobileEventListener) EnginePropertiesManager(com.twinsoft.convertigo.engine.EnginePropertiesManager) InjectJsCallback(com.teamdev.jxbrowser.browser.callback.InjectJsCallback) NetworkUtils(com.twinsoft.convertigo.engine.util.NetworkUtils) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Collection(java.util.Collection) UIComponent(com.twinsoft.convertigo.beans.mobile.components.UIComponent) UIControlEvent(com.twinsoft.convertigo.beans.mobile.components.UIControlEvent) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ConvertigoPlugin(com.twinsoft.convertigo.eclipse.ConvertigoPlugin) PropertyName(com.twinsoft.convertigo.engine.EnginePropertiesManager.PropertyName) List(java.util.List) Pattern(java.util.regex.Pattern) ShowContextMenuCallback(com.teamdev.jxbrowser.browser.callback.ShowContextMenuCallback) Label(org.eclipse.swt.widgets.Label) CompositeEvent(com.twinsoft.convertigo.eclipse.editors.CompositeEvent) Document(com.teamdev.jxbrowser.dom.Document) Image(org.eclipse.swt.graphics.Image) Rectangle(org.eclipse.swt.graphics.Rectangle) FocusListener(org.eclipse.swt.events.FocusListener) Event(org.eclipse.swt.widgets.Event) Frame(com.teamdev.jxbrowser.frame.Frame) MobileBuilder(com.twinsoft.convertigo.engine.mobile.MobileBuilder) HashSet(java.util.HashSet) PaletteSourceTransfer(com.twinsoft.convertigo.eclipse.dnd.PaletteSourceTransfer) BatchOperationHelper(com.twinsoft.convertigo.engine.helpers.BatchOperationHelper) Charset(java.nio.charset.Charset) Browser(com.teamdev.jxbrowser.browser.Browser) LinkedList(java.util.LinkedList) UIDynamicAction(com.twinsoft.convertigo.beans.mobile.components.UIDynamicAction) Response(com.teamdev.jxbrowser.browser.callback.InjectJsCallback.Response) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) RowLayout(org.eclipse.swt.layout.RowLayout) PageComponent(com.twinsoft.convertigo.beans.mobile.components.PageComponent) IResource(org.eclipse.core.resources.IResource) NumberUtils(org.apache.commons.lang3.math.NumberUtils) ApplicationComponent(com.twinsoft.convertigo.beans.mobile.components.ApplicationComponent) KeyListener(org.eclipse.swt.events.KeyListener) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Menu(org.eclipse.swt.widgets.Menu) FocusAdapter(org.eclipse.swt.events.FocusAdapter) C8oBrowser(com.twinsoft.convertigo.eclipse.swt.C8oBrowser) Control(org.eclipse.swt.widgets.Control) Matcher(java.util.regex.Matcher) IEditorReference(org.eclipse.ui.IEditorReference) InputStreamReader(java.io.InputStreamReader) ApplicationComponent(com.twinsoft.convertigo.beans.mobile.components.ApplicationComponent) MobileBuilderBuildMode(com.twinsoft.convertigo.engine.enums.MobileBuilderBuildMode) Point(org.eclipse.swt.graphics.Point) CoreException(org.eclipse.core.runtime.CoreException) PartInitException(org.eclipse.ui.PartInitException) DatabaseObjectFoundException(com.twinsoft.convertigo.engine.DatabaseObjectFoundException) JSONException(org.codehaus.jettison.json.JSONException) Project(com.twinsoft.convertigo.beans.core.Project) MobileBuilder(com.twinsoft.convertigo.engine.mobile.MobileBuilder) CoreException(org.eclipse.core.runtime.CoreException) JSONObject(org.codehaus.jettison.json.JSONObject) BufferedReader(java.io.BufferedReader) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) JSONObject(org.codehaus.jettison.json.JSONObject) JsObject(com.teamdev.jxbrowser.js.JsObject) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) File(java.io.File) IEditorInput(org.eclipse.ui.IEditorInput)

Example 12 with MobileBuilder

use of com.twinsoft.convertigo.engine.mobile.MobileBuilder in project convertigo by convertigo.

the class NgxUIComponentTreeObject method setPropertyValue.

@Override
public void setPropertyValue(Object id, Object value) {
    DatabaseObject dbo = getObject();
    if (dbo instanceof UIDynamicElement) {
        IonBean ionBean = ((UIDynamicElement) dbo).getIonBean();
        if (ionBean != null) {
            if (ionBean.hasProperty((String) id)) {
                if (value != null) {
                    if (value instanceof String) {
                        value = new MobileSmartSourceType((String) value);
                    }
                    Object oldValue = ionBean.getPropertyValue((String) id);
                    if (!value.equals(oldValue)) {
                        MobileBuilder mb = null;
                        IEditorPart editorPart = ConvertigoPlugin.getDefault().getApplicationComponentEditor();
                        if (editorPart != null) {
                            IEditorInput input = editorPart.getEditorInput();
                            if (input instanceof com.twinsoft.convertigo.eclipse.editors.ngx.ApplicationComponentEditorInput) {
                                com.twinsoft.convertigo.eclipse.editors.ngx.ApplicationComponentEditorInput editorInput = GenericUtils.cast(input);
                                mb = editorInput.getApplication().getProject().getMobileBuilder();
                            }
                        }
                        try {
                            ionBean.setPropertyValue((String) id, value);
                            TreeViewer viewer = (TreeViewer) getAdapter(TreeViewer.class);
                            hasBeenModified(true);
                            viewer.update(this, null);
                            Engine.logStudio.info("---------------------- SetPropertyValue started: " + (String) id + "----------------------");
                            if (mb != null) {
                                mb.prepareBatchBuild();
                            }
                            BatchOperationHelper.start();
                            TreeObjectEvent treeObjectEvent = new TreeObjectEvent(this, (String) id, oldValue, value);
                            ConvertigoPlugin.projectManager.getProjectExplorerView().fireTreeObjectPropertyChanged(treeObjectEvent);
                            BatchOperationHelper.stop();
                        } catch (Exception e) {
                        } finally {
                            BatchOperationHelper.cancel();
                            Engine.logStudio.info("---------------------- SetPropertyValue ended:   " + (String) id + "----------------------");
                        }
                        return;
                    }
                }
            }
        }
    }
    if (dbo instanceof UIAppGuard) {
        UIAppGuard dboGuard = (UIAppGuard) dbo;
        if ("guardType".equals(id)) {
            String guardType = (String) value;
            if (!guardType.equals(dboGuard.getGuardType().name())) {
                if (dboGuard.getApplication().hasGuard(AppGuardType.valueOf(guardType))) {
                    return;
                }
            }
        }
    }
    super.setPropertyValue(id, value);
}
Also used : IonBean(com.twinsoft.convertigo.beans.ngx.components.dynamic.IonBean) MobileSmartSourceType(com.twinsoft.convertigo.beans.ngx.components.MobileSmartSourceType) TreeViewer(org.eclipse.jface.viewers.TreeViewer) UIDynamicElement(com.twinsoft.convertigo.beans.ngx.components.UIDynamicElement) IEditorPart(org.eclipse.ui.IEditorPart) CoreException(org.eclipse.core.runtime.CoreException) EngineException(com.twinsoft.convertigo.engine.EngineException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) UIAppGuard(com.twinsoft.convertigo.beans.ngx.components.UIAppGuard) MobileBuilder(com.twinsoft.convertigo.engine.mobile.MobileBuilder) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) TreeObjectEvent(com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeObjectEvent) IEditorInput(org.eclipse.ui.IEditorInput)

Example 13 with MobileBuilder

use of com.twinsoft.convertigo.engine.mobile.MobileBuilder in project convertigo by convertigo.

the class ConvertigoPartListener method partClosed.

/* (non-Javadoc)
	 * @see org.eclipse.ui.IPartListener#partClosed(org.eclipse.ui.IWorkbenchPart)
	 */
public void partClosed(IWorkbenchPart part) {
    if (part instanceof ConnectorEditor) {
        // close editor properly
        ((ConnectorEditor) part).close();
    }
    if (part instanceof SequenceEditor) {
        // close editor properly
        ((SequenceEditor) part).close();
    }
    if (part instanceof ProjectExplorerView) {
        // close view properly
        ((ProjectExplorerView) part).close();
    }
    if (part instanceof SourcePickerView) {
        // close view properly
        ((SourcePickerView) part).close();
    }
    if (part instanceof ConsoleView) {
        ConvertigoPlugin convertigoPlugin = ConvertigoPlugin.getDefault();
        boolean shuttingDown = convertigoPlugin.isShuttingDown();
        if (shuttingDown) {
            IConsole[] tabConsoles = ConsolePlugin.getDefault().getConsoleManager().getConsoles();
            String openedConsoles = "";
            for (IConsole console : tabConsoles) {
                if (console instanceof MessageConsole) {
                    if ((console.equals(convertigoPlugin.engineConsole)) && (openedConsoles.indexOf("engine") == -1))
                        openedConsoles += (openedConsoles.equals("") ? "" : ",") + "engine";
                    else if ((console.equals(convertigoPlugin.stdoutConsole)) && (openedConsoles.indexOf("stdout") == -1))
                        openedConsoles += (openedConsoles.equals("") ? "" : ",") + "stdout";
                }
            }
            ConvertigoPlugin.setProperty(ConvertigoPlugin.PREFERENCE_OPENED_CONSOLES, openedConsoles);
        }
    }
    if (part instanceof EditorPart) {
        IEditorInput input = ((EditorPart) part).getEditorInput();
        if (input instanceof com.twinsoft.convertigo.eclipse.editors.mobile.ApplicationComponentEditorInput) {
            try {
                com.twinsoft.convertigo.eclipse.editors.mobile.ApplicationComponentEditorInput acei = GenericUtils.cast(input);
                MobileBuilder mb = acei.getApplication().getProject().getMobileBuilder();
                mb.removeMobileEventListener((com.twinsoft.convertigo.eclipse.editors.mobile.ApplicationComponentEditor) part);
                mb.setAutoBuild(true);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        if (input instanceof com.twinsoft.convertigo.eclipse.editors.ngx.ApplicationComponentEditorInput) {
            try {
                com.twinsoft.convertigo.eclipse.editors.ngx.ApplicationComponentEditorInput acei = GenericUtils.cast(input);
                MobileBuilder mb = acei.getApplication().getProject().getMobileBuilder();
                mb.removeMobileEventListener((com.twinsoft.convertigo.eclipse.editors.ngx.ApplicationComponentEditor) part);
                mb.setAutoBuild(true);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        if (input instanceof JScriptEditorInput) {
            try {
                ((JScriptEditorInput) input).getFile().getParent().delete(true, null);
            } catch (Exception e) {
                e.printStackTrace();
            }
        } else if (input instanceof com.twinsoft.convertigo.eclipse.editors.mobile.ComponentFileEditorInput) {
            try {
                ((com.twinsoft.convertigo.eclipse.editors.mobile.ComponentFileEditorInput) input).getFile().delete(true, null);
            } catch (Exception e) {
                e.printStackTrace();
            }
        } else if (input instanceof com.twinsoft.convertigo.eclipse.editors.ngx.ComponentFileEditorInput) {
            try {
                ((com.twinsoft.convertigo.eclipse.editors.ngx.ComponentFileEditorInput) input).getFile().delete(true, null);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}
Also used : SourcePickerView(com.twinsoft.convertigo.eclipse.views.sourcepicker.SourcePickerView) JScriptEditorInput(com.twinsoft.convertigo.eclipse.editors.jscript.JScriptEditorInput) ConnectorEditor(com.twinsoft.convertigo.eclipse.editors.connector.ConnectorEditor) ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) MessageConsole(org.eclipse.ui.console.MessageConsole) ConsoleView(org.eclipse.ui.internal.console.ConsoleView) SequenceEditor(com.twinsoft.convertigo.eclipse.editors.sequence.SequenceEditor) IConsole(org.eclipse.ui.console.IConsole) EditorPart(org.eclipse.ui.part.EditorPart) MobileBuilder(com.twinsoft.convertigo.engine.mobile.MobileBuilder) IEditorInput(org.eclipse.ui.IEditorInput)

Example 14 with MobileBuilder

use of com.twinsoft.convertigo.engine.mobile.MobileBuilder in project convertigo by convertigo.

the class ConvertigoPartListener method partOpened.

/* (non-Javadoc)
	 * @see org.eclipse.ui.IPartListener#partOpened(org.eclipse.ui.IWorkbenchPart)
	 */
public void partOpened(IWorkbenchPart part) {
    if (part instanceof PropertySheet) {
        PropertySheet view = (PropertySheet) part;
        if (view != null) {
            if (view.getCurrentPage().getControl() instanceof Tree) {
                Tree tree = (Tree) view.getCurrentPage().getControl();
                if (tree != null) {
                    if (SwtUtils.isDark()) {
                        tree.setLinesVisible(false);
                    }
                    try {
                        tree.getColumn(1).setWidth(tree.getBounds().width);
                    } catch (Exception e) {
                    }
                    tree.addKeyListener(new KeyAdapter() {

                        @Override
                        public void keyReleased(KeyEvent event) {
                            boolean bCtrl = (((event.stateMask & SWT.CONTROL) != 0) || ((event.stateMask & SWT.CTRL) != 0));
                            int keyCode = event.keyCode;
                            char c = event.character;
                            if (bCtrl) {
                                if ((c == 's') || (keyCode == 115)) {
                                    ProjectExplorerView projectExplorerView = ConvertigoPlugin.getDefault().getProjectExplorerView();
                                    if (projectExplorerView != null) {
                                        projectExplorerView.projectExplorerSaveAllAction.run();
                                    }
                                }
                            }
                        }
                    });
                }
            }
        }
    }
    if (part instanceof EditorPart) {
        IEditorInput input = ((EditorPart) part).getEditorInput();
        if (input instanceof com.twinsoft.convertigo.eclipse.editors.mobile.ApplicationComponentEditorInput) {
            try {
                com.twinsoft.convertigo.eclipse.editors.mobile.ApplicationComponentEditorInput acei = GenericUtils.cast(input);
                MobileBuilder mb = acei.getApplication().getProject().getMobileBuilder();
                mb.addMobileEventListener((com.twinsoft.convertigo.eclipse.editors.mobile.ApplicationComponentEditor) part);
                mb.setAutoBuild(true);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        if (input instanceof com.twinsoft.convertigo.eclipse.editors.ngx.ApplicationComponentEditorInput) {
            try {
                com.twinsoft.convertigo.eclipse.editors.ngx.ApplicationComponentEditorInput acei = GenericUtils.cast(input);
                MobileBuilder mb = acei.getApplication().getProject().getMobileBuilder();
                mb.addMobileEventListener((com.twinsoft.convertigo.eclipse.editors.ngx.ApplicationComponentEditor) part);
                mb.setAutoBuild(true);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}
Also used : ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) PropertySheet(org.eclipse.ui.views.properties.PropertySheet) KeyAdapter(org.eclipse.swt.events.KeyAdapter) EditorPart(org.eclipse.ui.part.EditorPart) KeyEvent(org.eclipse.swt.events.KeyEvent) MobileBuilder(com.twinsoft.convertigo.engine.mobile.MobileBuilder) Tree(org.eclipse.swt.widgets.Tree) IEditorInput(org.eclipse.ui.IEditorInput)

Example 15 with MobileBuilder

use of com.twinsoft.convertigo.engine.mobile.MobileBuilder in project convertigo by convertigo.

the class MyAbstractAction method run.

@Override
public void run(IAction action) {
    this.action = action;
    MobileBuilder mb = null;
    IEditorPart editorPart = ConvertigoPlugin.getDefault().getApplicationComponentEditor();
    if (editorPart != null) {
        IEditorInput input = editorPart.getEditorInput();
        if (input instanceof com.twinsoft.convertigo.eclipse.editors.mobile.ApplicationComponentEditorInput) {
            com.twinsoft.convertigo.eclipse.editors.mobile.ApplicationComponentEditorInput editorInput = GenericUtils.cast(input);
            mb = editorInput.getApplication().getProject().getMobileBuilder();
        }
        if (input instanceof com.twinsoft.convertigo.eclipse.editors.ngx.ApplicationComponentEditorInput) {
            com.twinsoft.convertigo.eclipse.editors.ngx.ApplicationComponentEditorInput editorInput = GenericUtils.cast(input);
            mb = editorInput.getApplication().getProject().getMobileBuilder();
        }
    }
    try {
        Engine.logStudio.info("---------------------- Action started: " + action.getId() + "----------------------");
        if (mb != null) {
            mb.prepareBatchBuild();
        }
        BatchOperationHelper.start();
        run();
        BatchOperationHelper.stop();
    } finally {
        BatchOperationHelper.cancel();
        Engine.logStudio.info("---------------------- Action ended:   " + action.getId() + "----------------------");
    }
}
Also used : IEditorPart(org.eclipse.ui.IEditorPart) MobileBuilder(com.twinsoft.convertigo.engine.mobile.MobileBuilder) IEditorInput(org.eclipse.ui.IEditorInput)

Aggregations

MobileBuilder (com.twinsoft.convertigo.engine.mobile.MobileBuilder)16 IEditorInput (org.eclipse.ui.IEditorInput)10 IEditorPart (org.eclipse.ui.IEditorPart)8 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)7 CoreException (org.eclipse.core.runtime.CoreException)7 Text (org.eclipse.swt.widgets.Text)7 Project (com.twinsoft.convertigo.beans.core.Project)6 ProjectExplorerView (com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView)6 File (java.io.File)6 Matcher (java.util.regex.Matcher)6 JSONArray (org.codehaus.jettison.json.JSONArray)6 JSONException (org.codehaus.jettison.json.JSONException)6 Point (org.eclipse.swt.graphics.Point)6 Rectangle (org.eclipse.swt.graphics.Rectangle)6 Composite (org.eclipse.swt.widgets.Composite)6 Control (org.eclipse.swt.widgets.Control)6 MobileDebugView (com.twinsoft.convertigo.eclipse.views.mobile.MobileDebugView)5 DatabaseObjectFoundException (com.twinsoft.convertigo.engine.DatabaseObjectFoundException)5 MessageDialog (org.eclipse.jface.dialogs.MessageDialog)5 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)5