Search in sources :

Example 31 with ProjectExplorerView

use of com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView in project convertigo by convertigo.

the class EnableMobileRouteEventComponentAction method run.

public void run() {
    Display display = Display.getDefault();
    Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
    Shell shell = getParentShell();
    shell.setCursor(waitCursor);
    try {
        ProjectExplorerView explorerView = getProjectExplorerView();
        if (explorerView != null) {
            DatabaseObjectTreeObject treeObject = null;
            RouteEventComponent component = null;
            TreeObject[] treeObjects = explorerView.getSelectedTreeObjects();
            for (int i = treeObjects.length - 1; i >= 0; i--) {
                treeObject = (DatabaseObjectTreeObject) treeObjects[i];
                if (treeObject instanceof MobileRouteEventComponentTreeObject) {
                    MobileRouteEventComponentTreeObject componentTreeObject = (MobileRouteEventComponentTreeObject) treeObject;
                    component = (RouteEventComponent) componentTreeObject.getObject();
                    component.setEnabled(true);
                    componentTreeObject.setEnabled(true);
                    componentTreeObject.hasBeenModified(true);
                    TreeObjectEvent treeObjectEvent = new TreeObjectEvent(componentTreeObject, "isEnabled", false, true);
                    explorerView.fireTreeObjectPropertyChanged(treeObjectEvent);
                }
            }
            explorerView.refreshSelectedTreeObjects();
        }
    } catch (Throwable e) {
        ConvertigoPlugin.logException(e, "Unable to enable event!");
    } finally {
        shell.setCursor(null);
        waitCursor.dispose();
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) MobileRouteEventComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileRouteEventComponentTreeObject) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) MobileRouteEventComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileRouteEventComponentTreeObject) TreeObjectEvent(com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeObjectEvent) Cursor(org.eclipse.swt.graphics.Cursor) RouteEventComponent(com.twinsoft.convertigo.beans.mobile.components.RouteEventComponent) Display(org.eclipse.swt.widgets.Display)

Example 32 with ProjectExplorerView

use of com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView in project convertigo by convertigo.

the class EnableMobileUIComponentAction method run.

public void run() {
    Display display = Display.getDefault();
    Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
    Shell shell = getParentShell();
    shell.setCursor(waitCursor);
    try {
        ProjectExplorerView explorerView = getProjectExplorerView();
        if (explorerView != null) {
            DatabaseObjectTreeObject treeObject = null;
            UIComponent component = null;
            TreeObject[] treeObjects = explorerView.getSelectedTreeObjects();
            for (int i = treeObjects.length - 1; i >= 0; i--) {
                treeObject = (DatabaseObjectTreeObject) treeObjects[i];
                if (treeObject instanceof MobileUIComponentTreeObject) {
                    MobileUIComponentTreeObject componentTreeObject = (MobileUIComponentTreeObject) treeObject;
                    component = (UIComponent) componentTreeObject.getObject();
                    component.setEnabled(true);
                    componentTreeObject.setEnabled(true);
                    componentTreeObject.hasBeenModified(true);
                    TreeObjectEvent treeObjectEvent = new TreeObjectEvent(componentTreeObject, "isEnabled", false, true);
                    explorerView.fireTreeObjectPropertyChanged(treeObjectEvent);
                }
            }
            explorerView.refreshSelectedTreeObjects();
        }
    } catch (Throwable e) {
        ConvertigoPlugin.logException(e, "Unable to enable component!");
    } finally {
        shell.setCursor(null);
        waitCursor.dispose();
    }
}
Also used : MobileUIComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileUIComponentTreeObject) Shell(org.eclipse.swt.widgets.Shell) ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) UIComponent(com.twinsoft.convertigo.beans.mobile.components.UIComponent) MobileUIComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileUIComponentTreeObject) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) TreeObjectEvent(com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeObjectEvent) Cursor(org.eclipse.swt.graphics.Cursor) Display(org.eclipse.swt.widgets.Display)

Example 33 with ProjectExplorerView

use of com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView in project convertigo by convertigo.

the class EnableNgxPageComponentAction method run.

public void run() {
    Display display = Display.getDefault();
    Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
    Shell shell = getParentShell();
    shell.setCursor(waitCursor);
    try {
        ProjectExplorerView explorerView = getProjectExplorerView();
        if (explorerView != null) {
            DatabaseObjectTreeObject treeObject = null;
            PageComponent component = null;
            TreeObject[] treeObjects = explorerView.getSelectedTreeObjects();
            for (int i = treeObjects.length - 1; i >= 0; i--) {
                treeObject = (DatabaseObjectTreeObject) treeObjects[i];
                if (treeObject instanceof NgxPageComponentTreeObject) {
                    NgxPageComponentTreeObject componentTreeObject = GenericUtils.cast(treeObject);
                    component = (PageComponent) componentTreeObject.getObject();
                    component.setEnabled(true);
                    componentTreeObject.setEnabled(true);
                    componentTreeObject.hasBeenModified(true);
                    TreeObjectEvent treeObjectEvent = new TreeObjectEvent(componentTreeObject, "isEnabled", false, true);
                    explorerView.fireTreeObjectPropertyChanged(treeObjectEvent);
                }
            }
            explorerView.refreshSelectedTreeObjects();
        }
    } catch (Throwable e) {
        ConvertigoPlugin.logException(e, "Unable to enable page!");
    } finally {
        shell.setCursor(null);
        waitCursor.dispose();
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) NgxPageComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxPageComponentTreeObject) NgxPageComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxPageComponentTreeObject) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) TreeObjectEvent(com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeObjectEvent) Cursor(org.eclipse.swt.graphics.Cursor) PageComponent(com.twinsoft.convertigo.beans.ngx.components.PageComponent) Display(org.eclipse.swt.widgets.Display)

Example 34 with ProjectExplorerView

use of com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView in project convertigo by convertigo.

the class CreateMobileApplicationTranslationsFileAction method run.

public void run() {
    Display display = Display.getDefault();
    Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
    Shell shell = getParentShell();
    shell.setCursor(waitCursor);
    try {
        ProjectExplorerView explorerView = getProjectExplorerView();
        if (explorerView != null) {
            TreeObject treeObject = explorerView.getFirstSelectedTreeObject();
            Object databaseObject = treeObject.getObject();
            List<String> textList = new ArrayList<String>();
            if ((databaseObject != null) && (databaseObject instanceof ApplicationComponent)) {
                ApplicationComponent application = (ApplicationComponent) databaseObject;
                new WalkHelper() {

                    @Override
                    protected void walk(DatabaseObject databaseObject) throws Exception {
                        String text = null;
                        if (databaseObject instanceof PageComponent) {
                            PageComponent page = (PageComponent) databaseObject;
                            text = page.getTitle();
                        } else if (databaseObject instanceof UIUseShared) {
                            UIUseShared uius = (UIUseShared) databaseObject;
                            UISharedComponent uisc = uius.getTargetSharedComponent();
                            if (uisc != null && !uius.isRecursive()) {
                                super.walk(uisc);
                            }
                        } else if (databaseObject instanceof UIText) {
                            UIText uiText = (UIText) databaseObject;
                            MobileSmartSourceType msst = uiText.getTextSmartType();
                            if (Mode.PLAIN.equals(msst.getMode())) {
                                text = msst.getValue();
                            }
                        }
                        if (text != null && !textList.contains(text)) {
                            textList.add(text);
                        }
                        super.walk(databaseObject);
                    }
                }.init(application);
                MobileApplicationTranslationsDialog dlg = new MobileApplicationTranslationsDialog(shell);
                int ret = dlg.open();
                if (ret != Window.OK) {
                    return;
                }
                Locale from = dlg.getLocaleFrom();
                Locale to = dlg.getLocaleTo();
                boolean auto = dlg.isAuto();
                File i18nDir = new File(application.getProject().getDirPath(), "DisplayObjects/mobile/assets/i18n");
                // store source file
                File source = new File(i18nDir, from.getLanguage() + ".json");
                TranslateUtils.storeTranslations(textList, source);
                ConvertigoPlugin.logDebug(source.getName() + " file successfully created or updated.");
                // store target file
                if (!to.equals(from)) {
                    File target = new File(i18nDir, to.getLanguage() + ".json");
                    // translate with google api
                    if (auto) {
                        ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
                        dialog.run(true, false, new IRunnableWithProgress() {

                            @Override
                            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                                monitor.beginTask("translating", IProgressMonitor.UNKNOWN);
                                Translator translator = TranslateUtils.newTranslator();
                                try {
                                    translator.translate(from, source, to, target);
                                    ConvertigoPlugin.logDebug(target.getName() + " file successfully translated.");
                                } catch (Exception e) {
                                    ConvertigoPlugin.logError(e.getMessage(), false);
                                    try {
                                        TranslateUtils.storeTranslations(textList, target);
                                    } catch (Exception ex) {
                                    }
                                }
                                monitor.done();
                            }
                        });
                    } else // do not translate
                    {
                        TranslateUtils.storeTranslations(textList, target);
                    }
                    ConvertigoPlugin.logDebug(target.getName() + " file successfully created or updated.");
                }
                // regenerate app templates
                try {
                    application.markApplicationAsDirty();
                    for (PageComponent page : application.getPageComponentList()) {
                        if (page.isEnabled()) {
                            page.markPageAsDirty();
                        }
                    }
                } catch (Throwable t) {
                }
                ConvertigoPlugin.logInfo("Translations file(s) successfully created or updated.", true);
            }
        }
    } catch (Throwable e) {
        ConvertigoPlugin.logException(e, "Unable to create the Mobile application translations file(s)!");
    } finally {
        shell.setCursor(null);
        waitCursor.dispose();
    }
}
Also used : Locale(java.util.Locale) MobileApplicationTranslationsDialog(com.twinsoft.convertigo.eclipse.dialogs.MobileApplicationTranslationsDialog) MobileSmartSourceType(com.twinsoft.convertigo.beans.mobile.components.MobileSmartSourceType) UIUseShared(com.twinsoft.convertigo.beans.mobile.components.UIUseShared) ArrayList(java.util.ArrayList) WalkHelper(com.twinsoft.convertigo.engine.helpers.WalkHelper) Cursor(org.eclipse.swt.graphics.Cursor) UISharedComponent(com.twinsoft.convertigo.beans.mobile.components.UISharedComponent) PageComponent(com.twinsoft.convertigo.beans.mobile.components.PageComponent) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) Shell(org.eclipse.swt.widgets.Shell) Translator(com.twinsoft.convertigo.engine.mobile.TranslateUtils.Translator) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) UIText(com.twinsoft.convertigo.beans.mobile.components.UIText) ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) ApplicationComponent(com.twinsoft.convertigo.beans.mobile.components.ApplicationComponent) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) File(java.io.File) Display(org.eclipse.swt.widgets.Display)

Example 35 with ProjectExplorerView

use of com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView in project convertigo by convertigo.

the class CustomStatisticsAction method run.

public void run() {
    Display display = Display.getDefault();
    Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
    Shell shell = getParentShell();
    shell.setCursor(waitCursor);
    try {
        ProjectExplorerView explorerView = getProjectExplorerView();
        if (explorerView != null) {
            ProjectTreeObject projectTreeObject = (ProjectTreeObject) explorerView.getFirstSelectedTreeObject();
            if (projectTreeObject != null) {
                StatisticsDialog stats = new StatisticsDialog(shell, projectTreeObject.getName(), projectTreeObject.getObject().getComment(), projectTreeObject.getObject().getVersion());
                stats.open();
            }
        }
    } catch (Throwable e) {
        ConvertigoPlugin.logException(e, "Unable to compute statistics!");
    } finally {
        shell.setCursor(null);
        waitCursor.dispose();
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) ProjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ProjectTreeObject) StatisticsDialog(com.twinsoft.convertigo.eclipse.dialogs.StatisticsDialog) Cursor(org.eclipse.swt.graphics.Cursor) Display(org.eclipse.swt.widgets.Display)

Aggregations

ProjectExplorerView (com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView)175 Cursor (org.eclipse.swt.graphics.Cursor)144 Display (org.eclipse.swt.widgets.Display)144 Shell (org.eclipse.swt.widgets.Shell)144 TreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject)113 DatabaseObjectTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject)73 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)49 TreeParent (com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeParent)38 Sequence (com.twinsoft.convertigo.beans.core.Sequence)35 EngineException (com.twinsoft.convertigo.engine.EngineException)26 Project (com.twinsoft.convertigo.beans.core.Project)24 Step (com.twinsoft.convertigo.beans.core.Step)22 TreeObjectEvent (com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeObjectEvent)22 ProjectTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ProjectTreeObject)22 StepTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.StepTreeObject)21 StepWithExpressions (com.twinsoft.convertigo.beans.core.StepWithExpressions)19 CompositeEvent (com.twinsoft.convertigo.eclipse.editors.CompositeEvent)19 StepEvent (com.twinsoft.convertigo.beans.core.StepEvent)15 Transaction (com.twinsoft.convertigo.beans.core.Transaction)14 File (java.io.File)14