Search in sources :

Example 36 with ApplicationComponent

use of com.twinsoft.convertigo.beans.mobile.components.ApplicationComponent in project convertigo by convertigo.

the class Ionic3Builder 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(ionicWorkDir, "src/app/app.component.temp.ts");
            if (appComponentTsFile.exists()) {
                writeAppComponentTempTs(app);
            }
            Engine.logEngine.trace("(MobileBuilder) Handled 'appRouteChanged'");
        }
    }
}
Also used : IApplicationComponent(com.twinsoft.convertigo.beans.core.IApplicationComponent) ApplicationComponent(com.twinsoft.convertigo.beans.mobile.components.ApplicationComponent) File(java.io.File)

Example 37 with ApplicationComponent

use of com.twinsoft.convertigo.beans.mobile.components.ApplicationComponent in project convertigo by convertigo.

the class Ionic3Builder method pageRenamed.

@Override
public void pageRenamed(final IPageComponent pageComponent, final String oldName) throws EngineException {
    PageComponent page = (PageComponent) pageComponent;
    if (page != null && page.isEnabled() && initDone) {
        synchronized (page) {
            MobileApplication mobileApplication = project.getMobileApplication();
            if (mobileApplication != null) {
                ApplicationComponent application = (ApplicationComponent) mobileApplication.getApplicationComponent();
                if (application != null) {
                    writePageSourceFiles(page);
                    writeAppSourceFiles(application);
                    deleteUselessDir(oldName);
                    moveFiles();
                    Engine.logEngine.trace("(MobileBuilder) Handled 'pageRenamed'");
                }
            }
        }
    }
}
Also used : MobileApplication(com.twinsoft.convertigo.beans.core.MobileApplication) IApplicationComponent(com.twinsoft.convertigo.beans.core.IApplicationComponent) ApplicationComponent(com.twinsoft.convertigo.beans.mobile.components.ApplicationComponent) IPageComponent(com.twinsoft.convertigo.beans.core.IPageComponent) PageComponent(com.twinsoft.convertigo.beans.mobile.components.PageComponent)

Example 38 with ApplicationComponent

use of com.twinsoft.convertigo.beans.mobile.components.ApplicationComponent in project convertigo by convertigo.

the class MobileUIComponentTreeObject method editFunction.

private void editFunction(final UIComponent uic, final String functionMarker, final String propertyName) {
    try {
        IScriptComponent main = uic.getMainScriptComponent();
        if (main == null) {
            return;
        }
        // Refresh project resources for editor
        String projectName = uic.getProject().getName();
        IProject project = ConvertigoPlugin.getDefault().getProjectPluginResource(projectName);
        project.refreshLocal(IResource.DEPTH_INFINITE, null);
        // Close editor and Reopen it after file has been rewritten
        String relativePath = uic.getProject().getMobileBuilder().getFunctionTempTsRelativePath(uic);
        IFile file = project.getFile(relativePath);
        if (!(uic instanceof UICustomAction)) {
            closeComponentFileEditor(file);
        }
        if (main instanceof ApplicationComponent) {
            if (uic.compareToTplVersion("7.5.2.0") < 0) {
                ConvertigoPlugin.logError("The ability to use forms or actions inside a menu is avalaible since 7.5.2 version." + "\nPlease change your Template project for the 'mobilebuilder_tpl_7_5_2' template.", true);
                return;
            }
        }
        uic.getProject().getMobileBuilder().writeFunctionTempTsFile(uic, functionMarker);
        file.refreshLocal(IResource.DEPTH_ZERO, null);
        // Open file in editor
        if (file.exists()) {
            IEditorInput input = new ComponentFileEditorInput(file, uic);
            if (input != null) {
                IEditorDescriptor desc = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(file.getName());
                IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
                String editorId = desc.getId();
                IEditorPart editorPart = activePage.openEditor(input, editorId);
                addMarkers(file, editorPart);
                editorPart.addPropertyListener(new IPropertyListener() {

                    boolean isFirstChange = false;

                    @Override
                    public void propertyChanged(Object source, int propId) {
                        if (source instanceof ITextEditor) {
                            if (propId == IEditorPart.PROP_DIRTY) {
                                if (!isFirstChange) {
                                    isFirstChange = true;
                                    return;
                                }
                                isFirstChange = false;
                                ITextEditor editor = (ITextEditor) source;
                                IDocumentProvider dp = editor.getDocumentProvider();
                                IDocument doc = dp.getDocument(editor.getEditorInput());
                                String marker = MobileBuilder.getMarker(doc.get(), functionMarker);
                                String content = MobileBuilder.getFormatedContent(marker, functionMarker);
                                FormatedContent formated = new FormatedContent(content);
                                MobileUIComponentTreeObject.this.setPropertyValue(propertyName, formated);
                            }
                        }
                    }
                });
            }
        }
    } catch (Exception e) {
        ConvertigoPlugin.logException(e, "Unable to edit function for '" + uic.getName() + "' component!");
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) ITextEditor(org.eclipse.ui.texteditor.ITextEditor) IScriptComponent(com.twinsoft.convertigo.beans.mobile.components.IScriptComponent) ApplicationComponent(com.twinsoft.convertigo.beans.mobile.components.ApplicationComponent) ComponentFileEditorInput(com.twinsoft.convertigo.eclipse.editors.mobile.ComponentFileEditorInput) IEditorDescriptor(org.eclipse.ui.IEditorDescriptor) IEditorPart(org.eclipse.ui.IEditorPart) IProject(org.eclipse.core.resources.IProject) IPropertyListener(org.eclipse.ui.IPropertyListener) CoreException(org.eclipse.core.runtime.CoreException) EngineException(com.twinsoft.convertigo.engine.EngineException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) IDocumentProvider(org.eclipse.ui.texteditor.IDocumentProvider) UICustomAction(com.twinsoft.convertigo.beans.mobile.components.UICustomAction) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) FormatedContent(com.twinsoft.convertigo.beans.common.FormatedContent) IEditorInput(org.eclipse.ui.IEditorInput) IDocument(org.eclipse.jface.text.IDocument)

Example 39 with ApplicationComponent

use of com.twinsoft.convertigo.beans.mobile.components.ApplicationComponent in project convertigo by convertigo.

the class MobileApplicationComponentTreeObject method closeAllEditors.

@Override
public void closeAllEditors(boolean save) {
    // will close any child component editor
    super.closeAllEditors(save);
    ApplicationComponent application = (ApplicationComponent) getObject();
    synchronized (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 ApplicationComponentEditorInput) {
                        if (((ApplicationComponentEditorInput) editorInput).is(application)) {
                            activePage.closeEditor(editorRef.getEditor(false), false);
                        }
                    }
                } catch (Exception e) {
                }
            }
        }
    }
}
Also used : IEditorReference(org.eclipse.ui.IEditorReference) ApplicationComponentEditorInput(com.twinsoft.convertigo.eclipse.editors.mobile.ApplicationComponentEditorInput) ApplicationComponent(com.twinsoft.convertigo.beans.mobile.components.ApplicationComponent) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IEditorInput(org.eclipse.ui.IEditorInput) InvalidParameterException(java.security.InvalidParameterException) PartInitException(org.eclipse.ui.PartInitException) InvocationTargetException(java.lang.reflect.InvocationTargetException) EngineException(com.twinsoft.convertigo.engine.EngineException)

Example 40 with ApplicationComponent

use of com.twinsoft.convertigo.beans.mobile.components.ApplicationComponent in project convertigo by convertigo.

the class MobilePickerContentProvider method addActions.

private void addActions(TVObject tvi, Object object) {
    if (object != null) {
        List<? extends UIComponent> list = null;
        if (object instanceof ApplicationComponent) {
            ApplicationComponent app = (ApplicationComponent) object;
            list = app.getUIAppEventList();
            list.addAll(GenericUtils.cast(app.getUIEventSubscriberList()));
            list.addAll(GenericUtils.cast(app.getSharedActionList()));
        } else if (object instanceof UIActionStack) {
            if (tvi != null && "actions".equals(tvi.getName())) {
                list = new ArrayList<>(Arrays.asList((UIActionStack) object));
            } else {
                list = ((UIActionStack) object).getUIComponentList();
            }
        } else if (object instanceof UISharedComponent) {
            list = ((UISharedComponent) object).getUIComponentList();
        } else if (object instanceof PageComponent) {
            list = ((PageComponent) object).getUIComponentList();
        } else if (object instanceof UIComponent) {
            list = ((UIComponent) object).getUIComponentList();
        }
        if (list != null) {
            TVObject tvEvents = null, tvControls = null;
            if (tvi != null && "actions".equals(tvi.getName())) {
                tvEvents = tvi.children.get(0);
                tvControls = tvi.children.get(1);
            }
            for (UIComponent uic : list) {
                // do not add to prevent selection on itself or children
                if (uic.equals(selected)) {
                    return;
                }
                // do not add if not parent of selected (popped picker only)
                boolean showInPicker = true;
                if (selected != null && selected instanceof UIComponent) {
                    String selectedQName = ((UIComponent) selected).getQName();
                    String uicQName = uic.getQName() + ".";
                    if (!selectedQName.startsWith(uicQName)) {
                        showInPicker = false;
                    }
                }
                if (showInPicker) {
                    if (uic instanceof UIAppEvent || uic instanceof UIPageEvent || uic instanceof UIEventSubscriber) {
                        TVObject tve = tvEvents == null ? tvi.add(new TVObject(uic.toString(), uic, null)) : tvEvents.add(new TVObject(uic.toString(), uic, null));
                        addActions(tve, uic);
                    } else if (uic instanceof UIActionEvent || uic instanceof UIControlEvent) {
                        TVObject tve = tvControls == null ? tvi.add(new TVObject(uic.toString(), uic, null)) : tvControls.add(new TVObject(uic.toString(), uic, null));
                        addActions(tve, uic);
                    } else if (uic instanceof IAction || uic instanceof UIActionStack) {
                        SourceData sd = null;
                        try {
                            sd = Filter.Action.toSourceData(new JSONObject().put("priority", uic.priority));
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                        TVObject tuic = tvi.add(new TVObject(uic.toString(), uic, sd));
                        addActions(tuic, uic);
                    } else {
                        addActions(tvi, uic);
                    }
                // } else {
                // addActions(tvi, uic);
                }
            }
        }
    }
}
Also used : UIAppEvent(com.twinsoft.convertigo.beans.mobile.components.UIAppEvent) UIPageEvent(com.twinsoft.convertigo.beans.mobile.components.UIPageEvent) IAction(com.twinsoft.convertigo.beans.mobile.components.IAction) ApplicationComponent(com.twinsoft.convertigo.beans.mobile.components.ApplicationComponent) ArrayList(java.util.ArrayList) UIComponent(com.twinsoft.convertigo.beans.mobile.components.UIComponent) JSONException(org.codehaus.jettison.json.JSONException) UIEventSubscriber(com.twinsoft.convertigo.beans.mobile.components.UIEventSubscriber) UISharedComponent(com.twinsoft.convertigo.beans.mobile.components.UISharedComponent) PageComponent(com.twinsoft.convertigo.beans.mobile.components.PageComponent) SourceData(com.twinsoft.convertigo.beans.mobile.components.MobileSmartSource.SourceData) UIActionStack(com.twinsoft.convertigo.beans.mobile.components.UIActionStack) UIControlEvent(com.twinsoft.convertigo.beans.mobile.components.UIControlEvent) JSONObject(org.codehaus.jettison.json.JSONObject) UIActionEvent(com.twinsoft.convertigo.beans.mobile.components.UIActionEvent)

Aggregations

ApplicationComponent (com.twinsoft.convertigo.beans.mobile.components.ApplicationComponent)42 IApplicationComponent (com.twinsoft.convertigo.beans.core.IApplicationComponent)20 PageComponent (com.twinsoft.convertigo.beans.mobile.components.PageComponent)16 File (java.io.File)14 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)13 EngineException (com.twinsoft.convertigo.engine.EngineException)12 UISharedComponent (com.twinsoft.convertigo.beans.mobile.components.UISharedComponent)10 UIComponent (com.twinsoft.convertigo.beans.mobile.components.UIComponent)9 UIActionStack (com.twinsoft.convertigo.beans.mobile.components.UIActionStack)8 InvocationTargetException (java.lang.reflect.InvocationTargetException)8 JSONObject (org.codehaus.jettison.json.JSONObject)8 JSONException (org.codehaus.jettison.json.JSONException)7 PartInitException (org.eclipse.ui.PartInitException)7 MobileApplication (com.twinsoft.convertigo.beans.core.MobileApplication)6 Project (com.twinsoft.convertigo.beans.core.Project)6 UIUseShared (com.twinsoft.convertigo.beans.mobile.components.UIUseShared)6 IOException (java.io.IOException)6 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)6 IPageComponent (com.twinsoft.convertigo.beans.core.IPageComponent)5 UICustomAction (com.twinsoft.convertigo.beans.mobile.components.UICustomAction)5