Search in sources :

Example 1 with StepWithExpressions

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

the class ClipboardAction method pasteStep.

private Object pasteStep(Shell shell, String source, DatabaseObject targetObject) throws ParserConfigurationException, SAXException, IOException {
    // Can only paste on Sequence or Step
    if (targetObject instanceof Sequence)
        return targetObject;
    else if (!(targetObject instanceof Step))
        return null;
    // cannot paste to IThenElseContainer
    if (targetObject instanceof IThenElseContainer)
        return null;
    else {
        List<Object> objects = clipboardManager.read(source);
        int size = objects.size();
        for (Object ob : objects) {
            // Can only paste step objects
            if (!(ob instanceof Step))
                return null;
            // Can paste only on step which may contain children
            if ((ob instanceof StepWithExpressions) && (!(targetObject instanceof StepWithExpressions)))
                return null;
            // cannot paste a ThenStep
            if (ob instanceof ThenStep)
                return null;
            // cannot paste a ElseStep
            if (ob instanceof ElseStep)
                return null;
            // cannot paste a ThenStatement
            if (ob instanceof ThenStatement)
                return null;
            // cannot paste a ElseStatement
            if (ob instanceof ElseStatement)
                return null;
            // Special case of XMLElementStep, ElementStep
            if ((targetObject instanceof XMLElementStep) || (targetObject instanceof ElementStep)) {
                // Case paste on itself -> target is changed to parent
                if ((size == 1) && ((ob instanceof XMLElementStep) || (ob instanceof ElementStep))) {
                    if (((Step) ob).getName().equals(targetObject.getName())) {
                        return targetObject.getParent();
                    }
                    return null;
                } else // Else, only accept paste of XMLAttributeStep
                if (!(ob instanceof XMLAttributeStep || ob instanceof AttributeStep)) {
                    return null;
                }
            } else // Case of step which may contain children
            if (targetObject instanceof StepWithExpressions) {
                // Case paste on itself -> ask user what to do
                if ((size == 1) && (ob.getClass().equals(targetObject.getClass()))) {
                    if (((Step) ob).getName().equals(targetObject.getName())) {
                        CustomDialog customDialog = new CustomDialog(shell, "Paste a step", "Do you want to paste the step as a sibling or a child step?", 500, 150, new ButtonSpec("As a sibling", true), new ButtonSpec("As a child", false), new ButtonSpec(IDialogConstants.CANCEL_LABEL, false));
                        int response = customDialog.open();
                        if (response == 0) {
                            return targetObject.getParent();
                        } else if (response == 2) {
                            return null;
                        } else
                            break;
                    }
                }
                // Else, paste
                break;
            } else // Other case
            {
                // Case paste on itself -> target is changed to parent
                if ((size == 1) && (ob.getClass().equals(targetObject.getClass()))) {
                    if (((Step) ob).getName().equals(targetObject.getName())) {
                        return targetObject.getParent();
                    }
                    return null;
                }
                // Else, not permitted
                return null;
            }
        }
    }
    return targetObject;
}
Also used : IThenElseContainer(com.twinsoft.convertigo.beans.steps.IThenElseContainer) ElseStep(com.twinsoft.convertigo.beans.steps.ElseStep) XMLElementStep(com.twinsoft.convertigo.beans.steps.XMLElementStep) StepWithExpressions(com.twinsoft.convertigo.beans.core.StepWithExpressions) ThenStatement(com.twinsoft.convertigo.beans.statements.ThenStatement) Sequence(com.twinsoft.convertigo.beans.core.Sequence) ThenStep(com.twinsoft.convertigo.beans.steps.ThenStep) XMLAttributeStep(com.twinsoft.convertigo.beans.steps.XMLAttributeStep) Step(com.twinsoft.convertigo.beans.core.Step) ElementStep(com.twinsoft.convertigo.beans.steps.ElementStep) XMLElementStep(com.twinsoft.convertigo.beans.steps.XMLElementStep) ElseStep(com.twinsoft.convertigo.beans.steps.ElseStep) AttributeStep(com.twinsoft.convertigo.beans.steps.AttributeStep) XMLAttributeStep(com.twinsoft.convertigo.beans.steps.XMLAttributeStep) ThenStep(com.twinsoft.convertigo.beans.steps.ThenStep) CustomDialog(com.twinsoft.convertigo.eclipse.dialogs.CustomDialog) ElseStatement(com.twinsoft.convertigo.beans.statements.ElseStatement) XMLAttributeStep(com.twinsoft.convertigo.beans.steps.XMLAttributeStep) AttributeStep(com.twinsoft.convertigo.beans.steps.AttributeStep) IPropertyTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IPropertyTreeObject) 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) ProjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ProjectTreeObject) IDesignTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IDesignTreeObject) FolderTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.FolderTreeObject) ElementStep(com.twinsoft.convertigo.beans.steps.ElementStep) XMLElementStep(com.twinsoft.convertigo.beans.steps.XMLElementStep) ButtonSpec(com.twinsoft.convertigo.eclipse.dialogs.ButtonSpec)

Example 2 with StepWithExpressions

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

the class ProjectTreeObject method checkForImports.

private void checkForImports(List<String> missingList, List<Step> steps) {
    String targetProjectName;
    for (Step step : steps) {
        if (step instanceof StepWithExpressions) {
            checkForImports(missingList, ((StepWithExpressions) step).getSteps());
        } else {
            if (step instanceof TransactionStep) {
                TransactionStep transactionStep = ((TransactionStep) step);
                targetProjectName = transactionStep.getProjectName();
                if (!targetProjectName.equals(getName())) {
                    try {
                        transactionStep.getSequence().getLoadedProject(targetProjectName);
                    } catch (EngineException e) {
                        if (!missingList.contains(targetProjectName))
                            missingList.add(targetProjectName);
                    }
                }
            } else if (step instanceof SequenceStep) {
                SequenceStep sequenceStep = ((SequenceStep) step);
                targetProjectName = sequenceStep.getProjectName();
                if (!targetProjectName.equals(getName())) {
                    try {
                        sequenceStep.getSequence().getLoadedProject(targetProjectName);
                    } catch (EngineException e) {
                        if (!missingList.contains(targetProjectName))
                            missingList.add(targetProjectName);
                    }
                }
            }
        }
    }
}
Also used : TransactionStep(com.twinsoft.convertigo.beans.steps.TransactionStep) SequenceStep(com.twinsoft.convertigo.beans.steps.SequenceStep) StepWithExpressions(com.twinsoft.convertigo.beans.core.StepWithExpressions) EngineException(com.twinsoft.convertigo.engine.EngineException) Step(com.twinsoft.convertigo.beans.core.Step) RequestableStep(com.twinsoft.convertigo.beans.core.RequestableStep) SequenceStep(com.twinsoft.convertigo.beans.steps.SequenceStep) TransactionStep(com.twinsoft.convertigo.beans.steps.TransactionStep)

Example 3 with StepWithExpressions

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

the class SequenceExecuteSelectedAction method openEditors.

private void openEditors(/*ProjectExplorerView explorerView, */
List<Step> steps, Set<SequenceStep> alreadyOpened) {
    for (Step step : steps) {
        if (step.isEnabled()) {
            if (step instanceof SequenceStep) {
                SequenceStep sequenceStep = (SequenceStep) step;
                String projectName = sequenceStep.getProjectName();
                // load project if necessary
                if (!step.getSequence().getProject().getName().equals(projectName)) {
                // loadProject(explorerView, projectName);
                }
                if (alreadyOpened.contains(sequenceStep)) {
                    // avoid sequence recursion
                    return;
                }
                alreadyOpened.add(sequenceStep);
                try {
                    // ProjectTreeObject projectTreeObject = (ProjectTreeObject)explorerView.getProjectRootObject(projectName);
                    Project p = step.getProject();
                    Sequence subSequence = p.getSequenceByName(sequenceStep.getSequenceName());
                    SequenceView subSequenceTreeObject = (SequenceView) Studio.getViewFromDbo(subSequence, studio);
                    // recurse on sequence
                    openEditors(/*explorerView, */
                    subSequenceTreeObject, alreadyOpened);
                } catch (EngineException e) {
                }
            } else if (step instanceof TransactionStep) {
                TransactionStep transactionStep = (TransactionStep) step;
                String projectName = transactionStep.getProjectName();
                if (!step.getSequence().getProject().getName().equals(projectName)) {
                // loadProject(explorerView, projectName); // load project if necessary
                }
                try {
                    // ProjectTreeObject projectTreeObject = (ProjectTreeObject)explorerView.getProjectRootObject(projectName);
                    Project project = Engine.theApp.databaseObjectsManager.getProjectByName(projectName);
                    ProjectView projectTreeObject = new ProjectView(project, studio);
                    Connector connector = projectTreeObject.getObject().getConnectorByName(transactionStep.getConnectorName());
                    ConnectorView connectorTreeObject = new ConnectorView(connector, studio);
                    // open connector editor
                    connectorTreeObject.openConnectorEditor();
                } catch (EngineException e) {
                }
            } else if (step instanceof StepWithExpressions) {
                openEditors(/*explorerView, */
                ((StepWithExpressions) step).getSteps(), alreadyOpened);
            }
        }
    }
}
Also used : TransactionStep(com.twinsoft.convertigo.beans.steps.TransactionStep) Project(com.twinsoft.convertigo.beans.core.Project) Connector(com.twinsoft.convertigo.beans.core.Connector) SequenceStep(com.twinsoft.convertigo.beans.steps.SequenceStep) SequenceView(com.twinsoft.convertigo.engine.studio.views.projectexplorer.model.SequenceView) ConnectorView(com.twinsoft.convertigo.engine.studio.views.projectexplorer.model.ConnectorView) EngineException(com.twinsoft.convertigo.engine.EngineException) StepWithExpressions(com.twinsoft.convertigo.beans.core.StepWithExpressions) Step(com.twinsoft.convertigo.beans.core.Step) SequenceStep(com.twinsoft.convertigo.beans.steps.SequenceStep) TransactionStep(com.twinsoft.convertigo.beans.steps.TransactionStep) Sequence(com.twinsoft.convertigo.beans.core.Sequence) ProjectView(com.twinsoft.convertigo.engine.studio.views.projectexplorer.model.ProjectView)

Example 4 with StepWithExpressions

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

the class SourcePickerHelperWrap method displayTargetWsdlDom.

public void displayTargetWsdlDom(DatabaseObject dbo) {
    try {
        if (dbo instanceof Step) {
            Step step = (Step) dbo;
            String xpath = getSourceXPath();
            String anchor = step.getAnchor();
            Document stepDoc = null;
            Step targetStep = step;
            while (targetStep instanceof IteratorStep) {
                targetStep = getTargetStep(targetStep);
            }
            if (targetStep != null) {
                Project project = step.getProject();
                XmlSchema schema = Engine.theApp.schemaManager.getSchemaForProject(project.getName(), Option.fullSchema);
                XmlSchemaObject xso = SchemaMeta.getXmlSchemaObject(schema, targetStep);
                if (xso != null) {
                    stepDoc = XmlSchemaUtils.getDomInstance(xso);
                }
            }
            if (stepDoc != null) /* && !(targetStep instanceof IteratorStep)*/
            {
                // stepDoc can be null for non "xml" step : e.g jIf
                Document doc = step.getSequence().createDOM();
                Element root = (Element) doc.importNode(stepDoc.getDocumentElement(), true);
                doc.replaceChild(root, doc.getDocumentElement());
                removeUserDefinedNodes(doc.getDocumentElement());
                boolean shouldDisplayDom = (!(!step.isXml() && (step instanceof StepWithExpressions) && !(step instanceof IteratorStep)));
                if ((doc != null) && (shouldDisplayDom)) {
                    xpath = onDisplayXhtml(xpath);
                    displayXhtml(doc);
                    xpathEvaluator.removeAnchor();
                    xpathEvaluator.displaySelectionXpathWithAnchor(twsDomTree, anchor, xpath);
                    return;
                }
            }
        }
    } catch (Exception e) {
    // ConvertigoPlugin.logException(e, StringUtils.readStackTraceCauses(e));
    }
    clean();
}
Also used : Project(com.twinsoft.convertigo.beans.core.Project) IteratorStep(com.twinsoft.convertigo.beans.steps.IteratorStep) XmlSchemaObject(org.apache.ws.commons.schema.XmlSchemaObject) XmlSchema(org.apache.ws.commons.schema.XmlSchema) Element(org.w3c.dom.Element) StepWithExpressions(com.twinsoft.convertigo.beans.core.StepWithExpressions) Step(com.twinsoft.convertigo.beans.core.Step) IteratorStep(com.twinsoft.convertigo.beans.steps.IteratorStep) Document(org.w3c.dom.Document) TransformerException(javax.xml.transform.TransformerException) EngineException(com.twinsoft.convertigo.engine.EngineException)

Example 5 with StepWithExpressions

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

the class TreeDropAdapter method move.

private boolean move(Node node, TreeObject targetTreeObject) throws EngineException {
    if (targetTreeObject instanceof DatabaseObjectTreeObject) {
        DatabaseObject parent = ((DatabaseObjectTreeObject) targetTreeObject).getObject();
        DatabaseObject databaseObject = paste(node, null, true);
        Element element = (Element) ((Element) node).getElementsByTagName("dnd").item(0);
        // SEQUENCER
        if (parent instanceof Sequence || parent instanceof StepWithExpressions) {
            ;
        } else // URLMAPPER
        if (parent instanceof UrlMappingOperation) {
            // Set associated requestable
            if (databaseObject instanceof RequestableObject) {
                String dboQName = "";
                if (databaseObject instanceof Sequence) {
                    dboQName = ((Element) element.getElementsByTagName("project").item(0)).getAttribute("name") + "." + databaseObject.getName();
                } else if (databaseObject instanceof Transaction) {
                    dboQName = ((Element) element.getElementsByTagName("project").item(0)).getAttribute("name") + "." + ((Element) element.getElementsByTagName("connector").item(0)).getAttribute("name") + "." + databaseObject.getName();
                }
                UrlMappingOperation operation = (UrlMappingOperation) parent;
                operation.setTargetRequestable(dboQName);
                if (operation.getComment().isEmpty()) {
                    operation.setComment(databaseObject.getComment());
                }
                operation.hasChanged = true;
                return true;
            }
        } else if (parent instanceof UrlMappingParameter) {
            // Set associated mapped variable for parameter
            if (databaseObject instanceof RequestableVariable) {
                RequestableVariable variable = (RequestableVariable) databaseObject;
                UrlMappingParameter parameter = (UrlMappingParameter) parent;
                parameter.setMappedVariableName(variable.getName());
                parameter.hasChanged = true;
                return true;
            }
        }
    }
    return false;
}
Also used : DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) UrlMappingOperation(com.twinsoft.convertigo.beans.core.UrlMappingOperation) RequestableObject(com.twinsoft.convertigo.beans.core.RequestableObject) Transaction(com.twinsoft.convertigo.beans.core.Transaction) HtmlTransaction(com.twinsoft.convertigo.beans.transactions.HtmlTransaction) UrlMappingParameter(com.twinsoft.convertigo.beans.core.UrlMappingParameter) Element(org.w3c.dom.Element) StepWithExpressions(com.twinsoft.convertigo.beans.core.StepWithExpressions) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) RequestableVariable(com.twinsoft.convertigo.beans.variables.RequestableVariable) Sequence(com.twinsoft.convertigo.beans.core.Sequence)

Aggregations

StepWithExpressions (com.twinsoft.convertigo.beans.core.StepWithExpressions)35 Sequence (com.twinsoft.convertigo.beans.core.Sequence)27 Step (com.twinsoft.convertigo.beans.core.Step)26 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)24 DatabaseObjectTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject)22 TreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject)19 Cursor (org.eclipse.swt.graphics.Cursor)19 Display (org.eclipse.swt.widgets.Display)19 Shell (org.eclipse.swt.widgets.Shell)19 ProjectExplorerView (com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView)18 EngineException (com.twinsoft.convertigo.engine.EngineException)16 StepEvent (com.twinsoft.convertigo.beans.core.StepEvent)15 TreeParent (com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeParent)15 StepTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.StepTreeObject)15 ThenStep (com.twinsoft.convertigo.beans.steps.ThenStep)10 TreePath (com.twinsoft.convertigo.eclipse.views.projectexplorer.TreePath)8 SequenceStep (com.twinsoft.convertigo.beans.steps.SequenceStep)7 ElseStep (com.twinsoft.convertigo.beans.steps.ElseStep)6 TransactionStep (com.twinsoft.convertigo.beans.steps.TransactionStep)6 XMLElementStep (com.twinsoft.convertigo.beans.steps.XMLElementStep)6