Search in sources :

Example 81 with DatabaseObject

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

the class EnableMobilePageComponentAction method selectionChanged.

public void selectionChanged(IAction action, ISelection selection) {
    super.selectionChanged(action, selection);
    IStructuredSelection structuredSelection = (IStructuredSelection) selection;
    TreeObject treeObject = (TreeObject) structuredSelection.getFirstElement();
    if (treeObject instanceof MobilePageComponentTreeObject) {
        DatabaseObject dbo = (DatabaseObject) treeObject.getObject();
        ActionModel actionModel = DatabaseObjectsAction.selectionChanged(getClass().getName(), dbo);
        action.setEnabled(actionModel.isEnabled);
    }
}
Also used : MobilePageComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobilePageComponentTreeObject) MobilePageComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobilePageComponentTreeObject) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ActionModel(com.twinsoft.convertigo.engine.studio.ActionModel)

Example 82 with DatabaseObject

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

the class CreateTestCaseAction method selectionChanged.

public void selectionChanged(IAction action, ISelection selection) {
    try {
        boolean enable = true;
        super.selectionChanged(action, selection);
        IStructuredSelection structuredSelection = (IStructuredSelection) selection;
        TreeObject treeObject = (TreeObject) structuredSelection.getFirstElement();
        if (treeObject instanceof ObjectsFolderTreeObject) {
            enable = ((ObjectsFolderTreeObject) treeObject).folderType == ObjectsFolderTreeObject.FOLDER_TYPE_TESTCASES;
        } else {
            DatabaseObject dbo = (DatabaseObject) treeObject.getObject();
            ActionModel actionModel = DatabaseObjectsAction.selectionChanged(getClass().getName(), dbo);
            enable = actionModel.isEnabled;
        }
        action.setEnabled(enable);
    } catch (Exception e) {
    }
}
Also used : ObjectsFolderTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ObjectsFolderTreeObject) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ObjectsFolderTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ObjectsFolderTreeObject) ActionModel(com.twinsoft.convertigo.engine.studio.ActionModel)

Example 83 with DatabaseObject

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

the class EnableNgxPageComponentAction method selectionChanged.

public void selectionChanged(IAction action, ISelection selection) {
    super.selectionChanged(action, selection);
    IStructuredSelection structuredSelection = (IStructuredSelection) selection;
    TreeObject treeObject = (TreeObject) structuredSelection.getFirstElement();
    if (treeObject instanceof NgxPageComponentTreeObject) {
        DatabaseObject dbo = (DatabaseObject) treeObject.getObject();
        ActionModel actionModel = DatabaseObjectsAction.selectionChanged(getClass().getName(), dbo);
        action.setEnabled(actionModel.isEnabled);
    }
}
Also used : 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) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ActionModel(com.twinsoft.convertigo.engine.studio.ActionModel)

Example 84 with DatabaseObject

use of com.twinsoft.convertigo.beans.core.DatabaseObject 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 85 with DatabaseObject

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

the class EmulatorTechnologyWizardPage method dialogChanged.

private void dialogChanged() {
    String emTech = getEmulatorTechnology();
    if (emTech.length() == 0) {
        updateStatus("Emulator technology must be specified");
        return;
    }
    try {
        DatabaseObject dbo = ((ObjectExplorerWizardPage) getWizard().getPage("ObjectExplorerWizardPage")).getCreatedBean();
        if (dbo != null) {
            if (dbo instanceof JavelinConnector) {
                ((JavelinConnector) dbo).setEmulatorTechnology(emTech);
                ((JavelinConnector) dbo).emulatorID = ((JavelinConnector) dbo).findEmulatorId();
            }
        }
        ServiceCodeWizardPage servCodeWP = (ServiceCodeWizardPage) getWizard().getPage("ServiceCodeWizardPage");
        servCodeWP.update();
    } catch (NullPointerException e) {
        updateStatus("New Bean has not been instantiated");
        return;
    } catch (EngineException e) {
        updateStatus("Emulmator id couldn't be found from emulator technology.");
        return;
    }
    updateStatus(null);
}
Also used : JavelinConnector(com.twinsoft.convertigo.beans.connectors.JavelinConnector) EngineException(com.twinsoft.convertigo.engine.EngineException) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) ObjectExplorerWizardPage(com.twinsoft.convertigo.eclipse.wizards.new_object.ObjectExplorerWizardPage)

Aggregations

DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)296 TreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject)98 DatabaseObjectTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject)97 EngineException (com.twinsoft.convertigo.engine.EngineException)88 Shell (org.eclipse.swt.widgets.Shell)46 ProjectExplorerView (com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView)45 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)43 Cursor (org.eclipse.swt.graphics.Cursor)42 Display (org.eclipse.swt.widgets.Display)42 Sequence (com.twinsoft.convertigo.beans.core.Sequence)41 Project (com.twinsoft.convertigo.beans.core.Project)38 CoreException (org.eclipse.core.runtime.CoreException)36 IOException (java.io.IOException)35 Step (com.twinsoft.convertigo.beans.core.Step)33 ActionModel (com.twinsoft.convertigo.engine.studio.ActionModel)33 TreeParent (com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeParent)31 Element (org.w3c.dom.Element)30 ObjectsFolderTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ObjectsFolderTreeObject)27 StepTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.StepTreeObject)27 PartInitException (org.eclipse.ui.PartInitException)26