Search in sources :

Example 76 with TreeObject

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

the class StepExportVariablesToSequenceAction 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();
            if ((databaseObject != null) && (databaseObject instanceof RequestableStep)) {
                RequestableStep requestableStep = (RequestableStep) databaseObject;
                requestableStep.exportVariableDefinition();
                Sequence sequence = requestableStep.getSequence();
                if (sequence.hasChanged) {
                    SequenceTreeObject sequenceTreeObject = (SequenceTreeObject) explorerView.findTreeObjectByUserObject(sequence);
                    explorerView.reloadTreeObject(sequenceTreeObject);
                    explorerView.setSelectedTreeObject(sequenceTreeObject);
                    StructuredSelection structuredSelection = new StructuredSelection(sequenceTreeObject);
                    ConvertigoPlugin.getDefault().getPropertiesView().selectionChanged((IWorkbenchPart) explorerView, structuredSelection);
                }
            }
        }
    } catch (Throwable e) {
        ConvertigoPlugin.logException(e, "Unable to export step variables to main sequence!");
    } finally {
        shell.setCursor(null);
        waitCursor.dispose();
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) SequenceTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.SequenceTreeObject) RequestableStep(com.twinsoft.convertigo.beans.core.RequestableStep) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) SequenceTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.SequenceTreeObject) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) SequenceTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.SequenceTreeObject) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) Sequence(com.twinsoft.convertigo.beans.core.Sequence) Cursor(org.eclipse.swt.graphics.Cursor) Display(org.eclipse.swt.widgets.Display)

Example 77 with TreeObject

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

the class StepImportSequenceVariablesAction 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();
            if ((databaseObject != null) && (databaseObject instanceof SequenceStep)) {
                SequenceStep sequenceStep = (SequenceStep) databaseObject;
                sequenceStep.importVariableDefinition();
                if (sequenceStep.hasChanged) {
                    explorerView.reloadTreeObject(treeObject);
                    StructuredSelection structuredSelection = new StructuredSelection(treeObject);
                    ConvertigoPlugin.getDefault().getPropertiesView().selectionChanged((IWorkbenchPart) explorerView, structuredSelection);
                }
            }
        }
    } catch (Throwable e) {
        ConvertigoPlugin.logException(e, "Unable to add sequence variables to step!");
    } finally {
        shell.setCursor(null);
        waitCursor.dispose();
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) SequenceStep(com.twinsoft.convertigo.beans.steps.SequenceStep) ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) Cursor(org.eclipse.swt.graphics.Cursor) Display(org.eclipse.swt.widgets.Display)

Example 78 with TreeObject

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

the class MobileComponentCreateAction method run.

public void run() {
    Display display = Display.getDefault();
    Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
    Shell shell = getParentShell();
    shell.setCursor(waitCursor);
    try {
        int folderType = -1;
        TreeObject parentTreeObject = null;
        DatabaseObject databaseObject = null;
        ProjectExplorerView explorerView = getProjectExplorerView();
        if (explorerView != null) {
            parentTreeObject = explorerView.getFirstSelectedTreeObject();
            if (parentTreeObject instanceof ObjectsFolderTreeObject) {
                ObjectsFolderTreeObject folderTreeObject = (ObjectsFolderTreeObject) parentTreeObject;
                folderType = folderTreeObject.folderType;
                parentTreeObject = folderTreeObject.getParent();
                databaseObject = (DatabaseObject) parentTreeObject.getObject();
            } else {
                databaseObject = (DatabaseObject) parentTreeObject.getObject();
            }
            ComponentObjectWizard newObjectWizard = new ComponentObjectWizard(databaseObject, databaseObjectClassName, folderType);
            WizardDialog wzdlg = new WizardDialog(shell, newObjectWizard);
            wzdlg.setPageSize(850, 650);
            wzdlg.open();
            int result = wzdlg.getReturnCode();
            if ((result != Window.CANCEL) && (newObjectWizard.newBean != null)) {
                postCreate(parentTreeObject, newObjectWizard.newBean);
            }
        }
    } catch (Throwable e) {
        ConvertigoPlugin.logException(e, "Unable to create a new database object '" + databaseObjectClassName + "'!");
    } finally {
        shell.setCursor(null);
        waitCursor.dispose();
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) 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) Cursor(org.eclipse.swt.graphics.Cursor) ObjectsFolderTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ObjectsFolderTreeObject) WizardDialog(org.eclipse.jface.wizard.WizardDialog) Display(org.eclipse.swt.widgets.Display) ComponentObjectWizard(com.twinsoft.convertigo.eclipse.wizards.new_mobile.ComponentObjectWizard)

Example 79 with TreeObject

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

the class MobileComponentImportVariablesAction 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();
            if (databaseObject != null) {
                if (databaseObject instanceof UIDynamicAction) {
                    UIDynamicAction dynAction = (UIDynamicAction) databaseObject;
                    IonBean ionBean = ((UIDynamicAction) dynAction).getIonBean();
                    if (ionBean != null) {
                        // Case of CallSequenceAction
                        if (ionBean.getName().equals("CallSequenceAction")) {
                            Object value = ionBean.getProperty("requestable").getValue();
                            if (!value.equals(false)) {
                                String target = value.toString();
                                if (!target.isEmpty()) {
                                    try {
                                        String projectName = target.substring(0, target.indexOf('.'));
                                        String sequenceName = target.substring(target.indexOf('.') + 1);
                                        Project p = Engine.theApp.databaseObjectsManager.getProjectByName(projectName);
                                        Sequence sequence = p.getSequenceByName(sequenceName);
                                        int size = sequence.numberOfVariables();
                                        for (int i = 0; i < size; i++) {
                                            RequestableVariable variable = (RequestableVariable) sequence.getVariable(i);
                                            if (variable != null) {
                                                String variableName = variable.getName();
                                                if (dynAction.getVariable(variableName) == null) {
                                                    if (!StringUtils.isNormalized(variableName))
                                                        throw new EngineException("Variable name is not normalized : \"" + variableName + "\".");
                                                    UIControlVariable uiVariable = new UIControlVariable();
                                                    uiVariable.setName(variableName);
                                                    uiVariable.setComment(variable.getDescription());
                                                    uiVariable.setVarSmartType(new MobileSmartSourceType(variable.getDefaultValue().toString()));
                                                    dynAction.addUIComponent(uiVariable);
                                                    uiVariable.bNew = true;
                                                    uiVariable.hasChanged = true;
                                                    dynAction.hasChanged = true;
                                                }
                                            }
                                        }
                                    } catch (Exception e) {
                                    }
                                }
                            }
                        } else // Case of InvokeAction
                        if (ionBean.getName().equals("InvokeAction")) {
                            UIDynamicInvoke dynInvoke = (UIDynamicInvoke) databaseObject;
                            UIActionStack stack = dynInvoke.getTargetSharedAction();
                            if (stack != null) {
                                for (UIStackVariable variable : stack.getVariables()) {
                                    String variableName = variable.getName();
                                    if (dynAction.getVariable(variableName) == null) {
                                        if (!StringUtils.isNormalized(variableName))
                                            throw new EngineException("Variable name is not normalized : \"" + variableName + "\".");
                                        UIControlVariable uiVariable = new UIControlVariable();
                                        uiVariable.setName(variableName);
                                        uiVariable.setComment(variable.getComment());
                                        MobileSmartSourceType msst = new MobileSmartSourceType();
                                        msst.setMode(MobileSmartSourceType.Mode.SCRIPT);
                                        msst.setSmartValue(variable.getVariableValue());
                                        uiVariable.setVarSmartType(msst);
                                        dynAction.addUIComponent(uiVariable);
                                        uiVariable.bNew = true;
                                        uiVariable.hasChanged = true;
                                        dynAction.hasChanged = true;
                                    }
                                }
                            }
                        }
                        if (dynAction.hasChanged) {
                            IScriptComponent main = dynAction.getMainScriptComponent();
                            if (main != null) {
                                if (main instanceof ApplicationComponent) {
                                    ((ApplicationComponent) main).markApplicationAsDirty();
                                }
                                if (main instanceof PageComponent) {
                                    ((PageComponent) main).markPageAsDirty();
                                }
                            }
                            explorerView.reloadTreeObject(treeObject);
                            StructuredSelection structuredSelection = new StructuredSelection(treeObject);
                            ConvertigoPlugin.getDefault().getPropertiesView().selectionChanged((IWorkbenchPart) explorerView, structuredSelection);
                        }
                    }
                } else if (databaseObject instanceof UIUseShared) {
                    UIUseShared useShared = (UIUseShared) databaseObject;
                    UISharedComponent sharedComp = useShared.getTargetSharedComponent();
                    if (sharedComp != null) {
                        for (UICompVariable variable : sharedComp.getVariables()) {
                            String variableName = variable.getName();
                            if (useShared.getVariable(variableName) == null) {
                                if (!StringUtils.isNormalized(variableName))
                                    throw new EngineException("Variable name is not normalized : \"" + variableName + "\".");
                                UIControlVariable uiVariable = new UIControlVariable();
                                uiVariable.setName(variableName);
                                uiVariable.setComment(variable.getComment());
                                MobileSmartSourceType msst = new MobileSmartSourceType();
                                msst.setMode(MobileSmartSourceType.Mode.SCRIPT);
                                msst.setSmartValue(variable.getVariableValue());
                                uiVariable.setVarSmartType(msst);
                                useShared.addUIComponent(uiVariable);
                                uiVariable.bNew = true;
                                uiVariable.hasChanged = true;
                                useShared.hasChanged = true;
                            }
                        }
                        if (useShared.hasChanged) {
                            IScriptComponent main = useShared.getMainScriptComponent();
                            if (main != null) {
                                if (main instanceof ApplicationComponent) {
                                    ((ApplicationComponent) main).markApplicationAsDirty();
                                }
                                if (main instanceof PageComponent) {
                                    ((PageComponent) main).markPageAsDirty();
                                }
                            }
                            explorerView.reloadTreeObject(treeObject);
                            StructuredSelection structuredSelection = new StructuredSelection(treeObject);
                            ConvertigoPlugin.getDefault().getPropertiesView().selectionChanged((IWorkbenchPart) explorerView, structuredSelection);
                        }
                    }
                }
            }
        }
    } catch (Throwable e) {
        ConvertigoPlugin.logException(e, "Unable to add variables to action !");
    } finally {
        shell.setCursor(null);
        waitCursor.dispose();
    }
}
Also used : IonBean(com.twinsoft.convertigo.beans.mobile.components.dynamic.IonBean) MobileSmartSourceType(com.twinsoft.convertigo.beans.mobile.components.MobileSmartSourceType) UIUseShared(com.twinsoft.convertigo.beans.mobile.components.UIUseShared) EngineException(com.twinsoft.convertigo.engine.EngineException) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) UIControlVariable(com.twinsoft.convertigo.beans.mobile.components.UIControlVariable) Cursor(org.eclipse.swt.graphics.Cursor) UISharedComponent(com.twinsoft.convertigo.beans.mobile.components.UISharedComponent) PageComponent(com.twinsoft.convertigo.beans.mobile.components.PageComponent) Shell(org.eclipse.swt.widgets.Shell) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) UICompVariable(com.twinsoft.convertigo.beans.mobile.components.UICompVariable) ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) IScriptComponent(com.twinsoft.convertigo.beans.mobile.components.IScriptComponent) ApplicationComponent(com.twinsoft.convertigo.beans.mobile.components.ApplicationComponent) RequestableVariable(com.twinsoft.convertigo.beans.variables.RequestableVariable) UIStackVariable(com.twinsoft.convertigo.beans.mobile.components.UIStackVariable) Sequence(com.twinsoft.convertigo.beans.core.Sequence) EngineException(com.twinsoft.convertigo.engine.EngineException) Project(com.twinsoft.convertigo.beans.core.Project) UIActionStack(com.twinsoft.convertigo.beans.mobile.components.UIActionStack) UIDynamicAction(com.twinsoft.convertigo.beans.mobile.components.UIDynamicAction) UIDynamicInvoke(com.twinsoft.convertigo.beans.mobile.components.UIDynamicInvoke) 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) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) Display(org.eclipse.swt.widgets.Display)

Example 80 with TreeObject

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

the class MobileSharedComponentExtractAction method selectionChanged.

public void selectionChanged(IAction action, ISelection selection) {
    boolean enable = false;
    try {
        super.selectionChanged(action, selection);
        IStructuredSelection structuredSelection = (IStructuredSelection) selection;
        if (structuredSelection.size() > 0) {
            boolean doIt = true;
            TreeObject previous = null;
            @SuppressWarnings("unchecked") List<TreeObject> list = structuredSelection.toList();
            for (TreeObject to : list) {
                if (!isAllowed(to)) {
                    doIt = false;
                    break;
                }
                if (previous != null) {
                    if (!to.getPreviousSibling().equals(previous)) {
                        doIt = false;
                        break;
                    }
                }
                previous = to;
            }
            if (doIt) {
                enable = true;
            }
        }
    } catch (Exception e) {
    }
    action.setEnabled(enable);
}
Also used : TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Aggregations

TreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject)207 DatabaseObjectTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject)129 ProjectExplorerView (com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView)112 Shell (org.eclipse.swt.widgets.Shell)111 Cursor (org.eclipse.swt.graphics.Cursor)107 Display (org.eclipse.swt.widgets.Display)107 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)97 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)64 ProjectTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ProjectTreeObject)53 StepTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.StepTreeObject)47 ObjectsFolderTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ObjectsFolderTreeObject)45 ConnectorTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ConnectorTreeObject)36 TransactionTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TransactionTreeObject)36 EngineException (com.twinsoft.convertigo.engine.EngineException)36 TreeParent (com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeParent)35 IPropertyTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IPropertyTreeObject)33 Sequence (com.twinsoft.convertigo.beans.core.Sequence)32 PropertyTableRowTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableRowTreeObject)32 SequenceTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.SequenceTreeObject)32 PropertyTableTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableTreeObject)31