Search in sources :

Example 6 with StepVariable

use of com.twinsoft.convertigo.beans.variables.StepVariable in project convertigo by convertigo.

the class ChangeToSingleValuedVariableAction method run.

@Override
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();
            TreeParent treeParent = treeObject.getParent();
            DatabaseObjectTreeObject parentTreeObject = null;
            if (treeParent instanceof DatabaseObjectTreeObject)
                parentTreeObject = (DatabaseObjectTreeObject) treeParent;
            else
                parentTreeObject = (DatabaseObjectTreeObject) treeParent.getParent();
            if (parentTreeObject != null) {
                Object databaseObject = treeObject.getObject();
                if (databaseObject != null) {
                    Variable multi = (Variable) databaseObject;
                    Variable simple = null;
                    if (databaseObject instanceof TestCaseMultiValuedVariable)
                        simple = new TestCaseVariable();
                    if (databaseObject instanceof StepMultiValuedVariable)
                        simple = new StepVariable();
                    if (databaseObject instanceof RequestableMultiValuedVariable)
                        simple = new RequestableVariable();
                    if (databaseObject instanceof RequestableHttpMultiValuedVariable)
                        simple = new RequestableHttpVariable();
                    if (databaseObject instanceof HttpStatementMultiValuedVariable)
                        simple = new HttpStatementVariable();
                    if (simple != null) {
                        if (multi instanceof StepMultiValuedVariable) {
                            ((StepVariable) simple).setSourceDefinition(((StepVariable) multi).getSourceDefinition());
                        }
                        if (multi instanceof RequestableVariable) {
                            ((RequestableVariable) simple).setXmlTypeAffectation(((RequestableVariable) multi).getXmlTypeAffectation());
                        }
                        if (multi instanceof RequestableHttpVariable) {
                            // HttpName
                            ((RequestableHttpVariable) simple).setHttpName(((RequestableHttpVariable) multi).getHttpName());
                            // HttpMethod
                            ((RequestableHttpVariable) simple).setHttpMethod(((RequestableHttpVariable) multi).getHttpMethod());
                        }
                        XMLVector<Object> xmlv = GenericUtils.cast(multi.getValueOrNull());
                        Object value = (xmlv == null) ? null : (xmlv.isEmpty() ? "" : xmlv.get(0).toString());
                        simple.setValueOrNull(value);
                        simple.setVisibility(multi.getVisibility());
                        // Comment
                        simple.setComment(multi.getComment());
                        // Description
                        simple.setDescription(multi.getDescription());
                        // Required
                        simple.setRequired(multi.isRequired());
                        simple.bNew = true;
                        simple.hasChanged = true;
                        // Add new variable to parent
                        DatabaseObject parentDbo = multi.getParent();
                        parentDbo.add(simple);
                        // Set correct order
                        if (parentDbo instanceof TestCase)
                            ((TestCase) parentDbo).insertAtOrder(simple, multi.priority);
                        if (parentDbo instanceof RequestableStep)
                            ((RequestableStep) parentDbo).insertAtOrder(simple, multi.priority);
                        if (parentDbo instanceof Sequence)
                            ((Sequence) parentDbo).insertAtOrder(simple, multi.priority);
                        if (parentDbo instanceof TransactionWithVariables)
                            ((TransactionWithVariables) parentDbo).insertAtOrder(simple, multi.priority);
                        if (parentDbo instanceof HTTPStatement)
                            ((HTTPStatement) parentDbo).insertAtOrder(simple, multi.priority);
                        // Add new variable in Tree
                        VariableTreeObject2 varTreeObject = new VariableTreeObject2(explorerView.viewer, simple);
                        treeParent.addChild(varTreeObject);
                        // Delete simple variable
                        multi.delete();
                        // Set correct name
                        simple.setName(multi.getName());
                        parentTreeObject.hasBeenModified(true);
                        explorerView.reloadTreeObject(parentTreeObject);
                        explorerView.setSelectedTreeObject(explorerView.findTreeObjectByUserObject(simple));
                    }
                }
            }
        }
    } catch (Throwable e) {
        ConvertigoPlugin.logException(e, "Unable to change simple variable to multi valuated variable!");
    } finally {
        shell.setCursor(null);
        waitCursor.dispose();
    }
}
Also used : RequestableHttpVariable(com.twinsoft.convertigo.beans.variables.RequestableHttpVariable) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) RequestableMultiValuedVariable(com.twinsoft.convertigo.beans.variables.RequestableMultiValuedVariable) RequestableHttpVariable(com.twinsoft.convertigo.beans.variables.RequestableHttpVariable) HttpStatementVariable(com.twinsoft.convertigo.beans.variables.HttpStatementVariable) TestCaseVariable(com.twinsoft.convertigo.beans.variables.TestCaseVariable) HttpStatementMultiValuedVariable(com.twinsoft.convertigo.beans.variables.HttpStatementMultiValuedVariable) Variable(com.twinsoft.convertigo.beans.core.Variable) StepVariable(com.twinsoft.convertigo.beans.variables.StepVariable) StepMultiValuedVariable(com.twinsoft.convertigo.beans.variables.StepMultiValuedVariable) TestCaseMultiValuedVariable(com.twinsoft.convertigo.beans.variables.TestCaseMultiValuedVariable) RequestableVariable(com.twinsoft.convertigo.beans.variables.RequestableVariable) RequestableHttpMultiValuedVariable(com.twinsoft.convertigo.beans.variables.RequestableHttpMultiValuedVariable) TreeParent(com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeParent) HttpStatementMultiValuedVariable(com.twinsoft.convertigo.beans.variables.HttpStatementMultiValuedVariable) StepVariable(com.twinsoft.convertigo.beans.variables.StepVariable) Cursor(org.eclipse.swt.graphics.Cursor) HTTPStatement(com.twinsoft.convertigo.beans.statements.HTTPStatement) StepMultiValuedVariable(com.twinsoft.convertigo.beans.variables.StepMultiValuedVariable) Shell(org.eclipse.swt.widgets.Shell) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) VariableTreeObject2(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.VariableTreeObject2) ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) RequestableVariable(com.twinsoft.convertigo.beans.variables.RequestableVariable) Sequence(com.twinsoft.convertigo.beans.core.Sequence) HttpStatementVariable(com.twinsoft.convertigo.beans.variables.HttpStatementVariable) TestCaseVariable(com.twinsoft.convertigo.beans.variables.TestCaseVariable) TestCaseMultiValuedVariable(com.twinsoft.convertigo.beans.variables.TestCaseMultiValuedVariable) RequestableHttpMultiValuedVariable(com.twinsoft.convertigo.beans.variables.RequestableHttpMultiValuedVariable) TestCase(com.twinsoft.convertigo.beans.core.TestCase) RequestableStep(com.twinsoft.convertigo.beans.core.RequestableStep) RequestableMultiValuedVariable(com.twinsoft.convertigo.beans.variables.RequestableMultiValuedVariable) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) TransactionWithVariables(com.twinsoft.convertigo.beans.core.TransactionWithVariables) 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 7 with StepVariable

use of com.twinsoft.convertigo.beans.variables.StepVariable in project convertigo by convertigo.

the class Migration5_0_0 method newVariable.

private static Variable newVariable(String classname, XMLVector<?> xmlv, int index) throws EngineException {
    Class<? extends DatabaseObject> beanClass;
    try {
        beanClass = GenericUtils.cast(Class.forName(classname));
        if (AbstractHttpTransaction.class.isAssignableFrom(beanClass)) {
            Boolean isMulti = (Boolean) xmlv.get(4);
            RequestableHttpVariable variable;
            variable = (isMulti ? new RequestableHttpMultiValuedVariable() : new RequestableHttpVariable());
            variable.setName((String) xmlv.get(0));
            variable.setDescription((String) xmlv.get(1));
            variable.setValueOrNull(xmlv.get(2));
            variable.setWsdl(((Boolean) xmlv.get(3)));
            variable.setPersonalizable(((Boolean) xmlv.get(5)));
            variable.setCachedKey(((Boolean) xmlv.get(6)));
            variable.setHttpMethod((String) xmlv.get(7));
            variable.setHttpName((String) xmlv.get(8));
            variable.bNew = true;
            variable.hasChanged = true;
            return variable;
        } else if (TransactionWithVariables.class.isAssignableFrom(beanClass) || Sequence.class.isAssignableFrom(beanClass)) {
            Boolean isMulti = (Boolean) xmlv.get(4);
            RequestableVariable variable = (isMulti ? new RequestableMultiValuedVariable() : new RequestableVariable());
            variable.setName((String) xmlv.get(0));
            variable.setDescription((String) xmlv.get(1));
            variable.setValueOrNull(xmlv.get(2));
            variable.setWsdl(((Boolean) xmlv.get(3)));
            variable.setPersonalizable(((Boolean) xmlv.get(5)));
            variable.setCachedKey(((Boolean) xmlv.get(6)));
            variable.bNew = true;
            variable.hasChanged = true;
            return variable;
        } else if (RequestableStep.class.isAssignableFrom(beanClass)) {
            StepVariable variable = new StepVariable();
            variable.setName((String) xmlv.get(0));
            variable.setDescription((String) xmlv.get(1));
            variable.setSourceDefinition(GenericUtils.<XMLVector<String>>cast(xmlv.get(2)));
            variable.setValueOrNull(xmlv.get(3));
            variable.bNew = true;
            variable.hasChanged = true;
            return variable;
        } else if (com.twinsoft.convertigo.beans.statements.HTTPStatement.class.isAssignableFrom(beanClass)) {
            Boolean isMulti = (Boolean) xmlv.get(3);
            HttpStatementVariable variable;
            variable = (isMulti ? new HttpStatementMultiValuedVariable() : new HttpStatementVariable());
            try {
                variable.setName((String) xmlv.get(0));
            } catch (Exception e) {
                variable.setName("variable" + index);
                Engine.logDatabaseObjectManager.warn("[Migration 4.6.0] For variable at index " + index + ", empty name has been replaced by 'variable" + index + "'!");
            }
            variable.setDescription((String) xmlv.get(1));
            variable.setValueOrNull(xmlv.get(2));
            variable.setHttpMethod((String) xmlv.get(4));
            variable.setHttpName((String) xmlv.get(5));
            variable.bNew = true;
            variable.hasChanged = true;
            return variable;
        } else {
            throw new EngineException("[Migration 4.6.0] Unsupported classname \"" + classname + "\"");
        }
    } catch (Exception e) {
        throw new EngineException("[Migration 4.6.0] Unable to create variable bean", e);
    }
}
Also used : RequestableHttpVariable(com.twinsoft.convertigo.beans.variables.RequestableHttpVariable) HttpStatementMultiValuedVariable(com.twinsoft.convertigo.beans.variables.HttpStatementMultiValuedVariable) EngineException(com.twinsoft.convertigo.engine.EngineException) RequestableVariable(com.twinsoft.convertigo.beans.variables.RequestableVariable) StepVariable(com.twinsoft.convertigo.beans.variables.StepVariable) HttpStatementVariable(com.twinsoft.convertigo.beans.variables.HttpStatementVariable) EngineException(com.twinsoft.convertigo.engine.EngineException) RequestableHttpMultiValuedVariable(com.twinsoft.convertigo.beans.variables.RequestableHttpMultiValuedVariable) RequestableMultiValuedVariable(com.twinsoft.convertigo.beans.variables.RequestableMultiValuedVariable)

Example 8 with StepVariable

use of com.twinsoft.convertigo.beans.variables.StepVariable in project convertigo by convertigo.

the class ChangeToMultiValuedVariableAction method run.

@Override
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();
            TreeParent treeParent = treeObject.getParent();
            DatabaseObjectTreeObject parentTreeObject = null;
            if (treeParent instanceof DatabaseObjectTreeObject)
                parentTreeObject = (DatabaseObjectTreeObject) treeParent;
            else
                parentTreeObject = (DatabaseObjectTreeObject) treeParent.getParent();
            if (parentTreeObject != null) {
                Object databaseObject = treeObject.getObject();
                if (databaseObject != null) {
                    Variable simple = (Variable) databaseObject;
                    Variable multi = null;
                    if (databaseObject instanceof TestCaseVariable)
                        multi = new TestCaseMultiValuedVariable();
                    if (databaseObject instanceof StepVariable)
                        multi = new StepMultiValuedVariable();
                    if (databaseObject instanceof RequestableVariable)
                        multi = new RequestableMultiValuedVariable();
                    if (databaseObject instanceof RequestableHttpVariable)
                        multi = new RequestableHttpMultiValuedVariable();
                    if (databaseObject instanceof HttpStatementVariable)
                        multi = new HttpStatementMultiValuedVariable();
                    if (multi != null) {
                        if (multi instanceof StepVariable) {
                            ((StepVariable) multi).setSourceDefinition(((StepVariable) simple).getSourceDefinition());
                        }
                        if (multi instanceof RequestableVariable) {
                            ((RequestableVariable) multi).setXmlTypeAffectation(((RequestableVariable) simple).getXmlTypeAffectation());
                        }
                        if (multi instanceof RequestableHttpVariable) {
                            // HttpName
                            ((RequestableHttpVariable) multi).setHttpName(((RequestableHttpVariable) simple).getHttpName());
                            // HttpMethod
                            ((RequestableHttpVariable) multi).setHttpMethod(((RequestableHttpVariable) simple).getHttpMethod());
                        }
                        Object value = simple.getValueOrNull();
                        multi.setValueOrNull(value);
                        multi.setVisibility(simple.getVisibility());
                        // Comment
                        multi.setComment(simple.getComment());
                        // Description
                        multi.setDescription(simple.getDescription());
                        // Required
                        multi.setRequired(simple.isRequired());
                        multi.bNew = true;
                        multi.hasChanged = true;
                        // Add new variable to parent
                        DatabaseObject parentDbo = simple.getParent();
                        parentDbo.add(multi);
                        // Set correct order
                        if (parentDbo instanceof TestCase)
                            ((TestCase) parentDbo).insertAtOrder(multi, simple.priority);
                        if (parentDbo instanceof RequestableStep)
                            ((RequestableStep) parentDbo).insertAtOrder(multi, simple.priority);
                        if (parentDbo instanceof Sequence)
                            ((Sequence) parentDbo).insertAtOrder(multi, simple.priority);
                        if (parentDbo instanceof TransactionWithVariables)
                            ((TransactionWithVariables) parentDbo).insertAtOrder(multi, simple.priority);
                        if (parentDbo instanceof HTTPStatement)
                            ((HTTPStatement) parentDbo).insertAtOrder(multi, simple.priority);
                        // Add new variable in Tree
                        VariableTreeObject2 varTreeObject = new VariableTreeObject2(explorerView.viewer, multi);
                        treeParent.addChild(varTreeObject);
                        // Delete simple variable
                        simple.delete();
                        // Set correct name
                        multi.setName(simple.getName());
                        parentTreeObject.hasBeenModified(true);
                        explorerView.reloadTreeObject(parentTreeObject);
                        explorerView.setSelectedTreeObject(explorerView.findTreeObjectByUserObject(multi));
                    }
                }
            }
        }
    } catch (Throwable e) {
        ConvertigoPlugin.logException(e, "Unable to change simple variable to multi valuated variable!");
    } finally {
        shell.setCursor(null);
        waitCursor.dispose();
    }
}
Also used : RequestableHttpVariable(com.twinsoft.convertigo.beans.variables.RequestableHttpVariable) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) RequestableMultiValuedVariable(com.twinsoft.convertigo.beans.variables.RequestableMultiValuedVariable) RequestableHttpVariable(com.twinsoft.convertigo.beans.variables.RequestableHttpVariable) HttpStatementVariable(com.twinsoft.convertigo.beans.variables.HttpStatementVariable) TestCaseVariable(com.twinsoft.convertigo.beans.variables.TestCaseVariable) HttpStatementMultiValuedVariable(com.twinsoft.convertigo.beans.variables.HttpStatementMultiValuedVariable) Variable(com.twinsoft.convertigo.beans.core.Variable) StepVariable(com.twinsoft.convertigo.beans.variables.StepVariable) StepMultiValuedVariable(com.twinsoft.convertigo.beans.variables.StepMultiValuedVariable) TestCaseMultiValuedVariable(com.twinsoft.convertigo.beans.variables.TestCaseMultiValuedVariable) RequestableVariable(com.twinsoft.convertigo.beans.variables.RequestableVariable) RequestableHttpMultiValuedVariable(com.twinsoft.convertigo.beans.variables.RequestableHttpMultiValuedVariable) TreeParent(com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeParent) HttpStatementMultiValuedVariable(com.twinsoft.convertigo.beans.variables.HttpStatementMultiValuedVariable) StepVariable(com.twinsoft.convertigo.beans.variables.StepVariable) Cursor(org.eclipse.swt.graphics.Cursor) HTTPStatement(com.twinsoft.convertigo.beans.statements.HTTPStatement) StepMultiValuedVariable(com.twinsoft.convertigo.beans.variables.StepMultiValuedVariable) Shell(org.eclipse.swt.widgets.Shell) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) VariableTreeObject2(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.VariableTreeObject2) ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) RequestableVariable(com.twinsoft.convertigo.beans.variables.RequestableVariable) Sequence(com.twinsoft.convertigo.beans.core.Sequence) HttpStatementVariable(com.twinsoft.convertigo.beans.variables.HttpStatementVariable) TestCaseVariable(com.twinsoft.convertigo.beans.variables.TestCaseVariable) TestCaseMultiValuedVariable(com.twinsoft.convertigo.beans.variables.TestCaseMultiValuedVariable) RequestableHttpMultiValuedVariable(com.twinsoft.convertigo.beans.variables.RequestableHttpMultiValuedVariable) TestCase(com.twinsoft.convertigo.beans.core.TestCase) RequestableStep(com.twinsoft.convertigo.beans.core.RequestableStep) RequestableMultiValuedVariable(com.twinsoft.convertigo.beans.variables.RequestableMultiValuedVariable) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) TransactionWithVariables(com.twinsoft.convertigo.beans.core.TransactionWithVariables) 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 9 with StepVariable

use of com.twinsoft.convertigo.beans.variables.StepVariable in project convertigo by convertigo.

the class CanCreateSource method canCreateSource.

public static boolean canCreateSource(Object obj, StepSourceWrap ssw) {
    // if (target instanceof TreeObject) {
    // TreeObject targetTreeObject = (TreeObject) target;
    // Check for drop to a step which contains a stepSource definition
    // if (targetTreeObject.getObject() instanceof IStepSourceContainer) {
    DatabaseObject targetDbo = (DatabaseObject) obj;
    if (targetDbo instanceof Step && ((Step) targetDbo).canWorkOnSource() || targetDbo instanceof IStepSourceContainer) {
        // StepSourceTransfer.getInstance().getStepSource();
        StepSourceWrap stepSource = ssw;
        if (stepSource != null) {
            Step targetStep = (Step) ((targetDbo instanceof StepVariable) ? ((StepVariable) targetDbo).getParent() : targetDbo);
            // Check for drop to a step in the same sequence
            Long key = Long.valueOf(stepSource.getPriority());
            Step sourceStep = targetStep.getSequence().loadedSteps.get(key);
            if ((sourceStep != null) && (!targetStep.equals(sourceStep))) {
                // Check for drop on a 'following' step
                try {
                    List<DatabaseObject> siblings = new ArrayList<>();
                    getNextSiblings(siblings, targetDbo.getProject(), sourceStep);
                    // System.out.println("siblings: "+siblings.toString());
                    return siblings.contains(targetDbo);
                } catch (Exception e) {
                    e.printStackTrace(System.out);
                }
                ;
            }
        }
    }
    // }
    return false;
}
Also used : ArrayList(java.util.ArrayList) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) Step(com.twinsoft.convertigo.beans.core.Step) StepVariable(com.twinsoft.convertigo.beans.variables.StepVariable) IStepSourceContainer(com.twinsoft.convertigo.beans.core.IStepSourceContainer) StepSourceWrap(com.twinsoft.convertigo.engine.studio.dnd.StepSourceWrap)

Example 10 with StepVariable

use of com.twinsoft.convertigo.beans.variables.StepVariable in project convertigo by convertigo.

the class TreeDropAdapter method validateDrop.

/* (non-Javadoc)
	 * @see org.eclipse.jface.viewers.ViewerDropAdapter#validateDrop(java.lang.Object, int, org.eclipse.swt.dnd.TransferData)
	 */
@Override
public boolean validateDrop(Object target, int operation, TransferData transferType) {
    if (TextTransfer.getInstance().isSupportedType(transferType)) {
        if (getCurrentOperation() == DND.DROP_MOVE) {
            Object targetObject = getCurrentTarget();
            Object sourceObject = getSelectedObject();
            if (targetObject != null && targetObject instanceof TreeObject) {
                TreeObject targetTreeObject = (TreeObject) targetObject;
                if (sourceObject != null && sourceObject instanceof TreeObject) {
                    TreeObject sourceTreeObject = (TreeObject) sourceObject;
                    boolean isFocus = sourceTreeObject.viewer.getControl().isFocusControl();
                    if (isFocus && (sourceObject == targetObject || targetTreeObject.isChildOf(sourceTreeObject))) {
                        return false;
                    }
                }
                if (targetObject instanceof DatabaseObjectTreeObject) {
                    try {
                        String xmlData = TextTransfer.getInstance().nativeToJava(transferType).toString();
                        List<Object> list = ConvertigoPlugin.clipboardManagerDND.read(xmlData);
                        DatabaseObject databaseObject = (DatabaseObject) list.get(0);
                        DatabaseObject targetDatabaseObject = ((DatabaseObjectTreeObject) target).getObject();
                        if (DatabaseObjectsManager.acceptDatabaseObjects(targetDatabaseObject, databaseObject)) {
                            return true;
                        }
                        DatabaseObject parentDatabaseObject = targetDatabaseObject.getParent();
                        if (parentDatabaseObject != null && DatabaseObjectsManager.acceptDatabaseObjects(parentDatabaseObject, databaseObject)) {
                            return true;
                        }
                        return false;
                    } catch (Exception e) {
                        e.printStackTrace(System.out);
                    }
                }
            }
        }
        return true;
    }
    if (StepSourceTransfer.getInstance().isSupportedType(transferType)) {
        if (target instanceof TreeObject) {
            TreeObject targetTreeObject = (TreeObject) target;
            // Check for drop to a step which contains a stepSource definition
            // if (targetTreeObject.getObject() instanceof IStepSourceContainer) {
            Object ob = targetTreeObject.getObject();
            if (ob instanceof Step && ((Step) ob).canWorkOnSource() || ob instanceof IStepSourceContainer) {
                StepSource stepSource = StepSourceTransfer.getInstance().getStepSource();
                if (stepSource != null) {
                    Step targetStep = (Step) ((ob instanceof StepVariable) ? ((StepVariable) ob).getParent() : ob);
                    // Check for drop to a step in the same sequence
                    Long key = Long.valueOf(stepSource.getPriority());
                    Step sourceStep = targetStep.getSequence().loadedSteps.get(key);
                    if ((sourceStep != null) && (!targetStep.equals(sourceStep))) {
                        // Check for drop on a 'following' step
                        try {
                            List<TreeObject> siblings = new ArrayList<TreeObject>();
                            getNextSiblings(siblings, targetTreeObject.getProjectTreeObject(), sourceStep);
                            // System.out.println("siblings: "+siblings.toString());
                            return siblings.contains(targetTreeObject);
                        } catch (Exception e) {
                            e.printStackTrace(System.out);
                        }
                        ;
                    }
                }
            }
        }
    }
    if (PaletteSourceTransfer.getInstance().isSupportedType(transferType)) {
        if (target instanceof TreeObject) {
            TreeObject targetTreeObject = (TreeObject) target;
            PaletteSource paletteSource = PaletteSourceTransfer.getInstance().getPaletteSource();
            if (paletteSource != null) {
                try {
                    String xmlData = paletteSource.getXmlData();
                    List<Object> list = ConvertigoPlugin.clipboardManagerDND.read(xmlData);
                    DatabaseObject databaseObject = (DatabaseObject) list.get(0);
                    if (targetTreeObject instanceof ObjectsFolderTreeObject) {
                        ObjectsFolderTreeObject folderTreeObject = (ObjectsFolderTreeObject) targetTreeObject;
                        if (!ProjectExplorerView.folderAcceptMobileComponent(folderTreeObject.folderType, databaseObject)) {
                            return false;
                        }
                        // continue
                        targetTreeObject = folderTreeObject.getParent();
                    }
                    if (targetTreeObject instanceof DatabaseObjectTreeObject) {
                        DatabaseObject targetDatabaseObject = ((DatabaseObjectTreeObject) targetTreeObject).getObject();
                        if (targetDatabaseObject != null) {
                            if (!DatabaseObjectsManager.acceptDatabaseObjects(targetDatabaseObject, databaseObject)) {
                                return false;
                            }
                            if (targetTreeObject instanceof MobileComponentTreeObject) {
                                if (!com.twinsoft.convertigo.beans.mobile.components.dynamic.ComponentManager.acceptDatabaseObjects(targetDatabaseObject, databaseObject)) {
                                    return false;
                                }
                                if (!com.twinsoft.convertigo.beans.mobile.components.dynamic.ComponentManager.isTplCompatible(targetDatabaseObject, databaseObject)) {
                                    return false;
                                }
                            }
                            if (targetTreeObject instanceof NgxComponentTreeObject) {
                                if (!com.twinsoft.convertigo.beans.ngx.components.dynamic.ComponentManager.acceptDatabaseObjects(targetDatabaseObject, databaseObject)) {
                                    return false;
                                }
                                if (!com.twinsoft.convertigo.beans.ngx.components.dynamic.ComponentManager.isTplCompatible(targetDatabaseObject, databaseObject)) {
                                    return false;
                                }
                            }
                            return true;
                        }
                    }
                } catch (Exception e) {
                    e.printStackTrace(System.out);
                }
            }
        }
    }
    if (MobileSourceTransfer.getInstance().isSupportedType(transferType)) {
        MobileSource mobileSource = MobileSourceTransfer.getInstance().getMobileSource();
        if (mobileSource != null) {
            if (target instanceof MobileUIComponentTreeObject) {
                MobileUIComponentTreeObject mcto = GenericUtils.cast(target);
                com.twinsoft.convertigo.beans.mobile.components.MobileSmartSource mss = com.twinsoft.convertigo.beans.mobile.components.MobileSmartSource.valueOf(mobileSource.getJsonString());
                if (mss == null || !mss.isDroppableInto(mcto.getObject())) {
                    return false;
                }
                for (IPropertyDescriptor descriptor : mcto.getPropertyDescriptors()) {
                    if (descriptor instanceof MobileSmartSourcePropertyDescriptor) {
                        if (!((MobileSmartSourcePropertyDescriptor) descriptor).isReadOnly()) {
                            return true;
                        }
                    }
                }
            }
            if (target instanceof NgxUIComponentTreeObject) {
                NgxUIComponentTreeObject mcto = GenericUtils.cast(target);
                com.twinsoft.convertigo.beans.ngx.components.MobileSmartSource mss = com.twinsoft.convertigo.beans.ngx.components.MobileSmartSource.valueOf(mobileSource.getJsonString());
                if (mss == null || !mss.isDroppableInto(mcto.getObject())) {
                    return false;
                }
                for (IPropertyDescriptor descriptor : mcto.getPropertyDescriptors()) {
                    if (descriptor instanceof NgxSmartSourcePropertyDescriptor) {
                        if (!((NgxSmartSourcePropertyDescriptor) descriptor).isReadOnly()) {
                            return true;
                        }
                    }
                }
            }
        }
    }
    return false;
}
Also used : NgxUIComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxUIComponentTreeObject) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) MobileSmartSourcePropertyDescriptor(com.twinsoft.convertigo.eclipse.property_editors.MobileSmartSourcePropertyDescriptor) NgxComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxComponentTreeObject) ArrayList(java.util.ArrayList) SequenceStep(com.twinsoft.convertigo.beans.steps.SequenceStep) XMLElementStep(com.twinsoft.convertigo.beans.steps.XMLElementStep) Step(com.twinsoft.convertigo.beans.core.Step) TransactionStep(com.twinsoft.convertigo.beans.steps.TransactionStep) StepVariable(com.twinsoft.convertigo.beans.variables.StepVariable) NgxSmartSourcePropertyDescriptor(com.twinsoft.convertigo.eclipse.property_editors.NgxSmartSourcePropertyDescriptor) IStepSourceContainer(com.twinsoft.convertigo.beans.core.IStepSourceContainer) ObjectsFolderTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ObjectsFolderTreeObject) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) MobileComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileComponentTreeObject) IOException(java.io.IOException) ObjectWithSameNameException(com.twinsoft.convertigo.engine.ObjectWithSameNameException) SAXException(org.xml.sax.SAXException) EngineException(com.twinsoft.convertigo.engine.EngineException) InvalidOperationException(com.twinsoft.convertigo.engine.InvalidOperationException) MobileUIComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileUIComponentTreeObject) PropertyTableRowTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableRowTreeObject) NgxComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxComponentTreeObject) IOrderableTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IOrderableTreeObject) ProjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ProjectTreeObject) FolderTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.FolderTreeObject) ObjectsFolderTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ObjectsFolderTreeObject) NgxUIComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxUIComponentTreeObject) MobileUIComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileUIComponentTreeObject) IPropertyTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IPropertyTreeObject) PropertyTableTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableTreeObject) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) ScreenClassTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ScreenClassTreeObject) MobileComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileComponentTreeObject) PropertyTableRowTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableRowTreeObject) NgxComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxComponentTreeObject) IOrderableTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IOrderableTreeObject) ProjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ProjectTreeObject) FolderTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.FolderTreeObject) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) ObjectsFolderTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ObjectsFolderTreeObject) NgxUIComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxUIComponentTreeObject) MobileUIComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileUIComponentTreeObject) IPropertyTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IPropertyTreeObject) RequestableObject(com.twinsoft.convertigo.beans.core.RequestableObject) PropertyTableTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableTreeObject) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) ScreenClassTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ScreenClassTreeObject) MobileComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileComponentTreeObject) IPropertyDescriptor(org.eclipse.ui.views.properties.IPropertyDescriptor)

Aggregations

StepVariable (com.twinsoft.convertigo.beans.variables.StepVariable)15 RequestableVariable (com.twinsoft.convertigo.beans.variables.RequestableVariable)8 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)6 StepMultiValuedVariable (com.twinsoft.convertigo.beans.variables.StepMultiValuedVariable)6 DatabaseObjectTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject)6 TreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject)6 RequestableMultiValuedVariable (com.twinsoft.convertigo.beans.variables.RequestableMultiValuedVariable)5 EngineException (com.twinsoft.convertigo.engine.EngineException)5 ArrayList (java.util.ArrayList)5 Sequence (com.twinsoft.convertigo.beans.core.Sequence)4 RequestableObject (com.twinsoft.convertigo.beans.core.RequestableObject)3 RequestableStep (com.twinsoft.convertigo.beans.core.RequestableStep)3 Step (com.twinsoft.convertigo.beans.core.Step)3 TransactionWithVariables (com.twinsoft.convertigo.beans.core.TransactionWithVariables)3 Variable (com.twinsoft.convertigo.beans.core.Variable)3 SequenceStep (com.twinsoft.convertigo.beans.steps.SequenceStep)3 TransactionStep (com.twinsoft.convertigo.beans.steps.TransactionStep)3 IStepSourceContainer (com.twinsoft.convertigo.beans.core.IStepSourceContainer)2 StepWithExpressions (com.twinsoft.convertigo.beans.core.StepWithExpressions)2 TestCase (com.twinsoft.convertigo.beans.core.TestCase)2