Search in sources :

Example 21 with Step

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

the class DatabaseObjectDeleteAction method delete.

private void delete(DatabaseObject databaseObject, boolean deleteProjectOnDisk) throws EngineException, CoreException {
    if (databaseObject instanceof Connector) {
        if (((Connector) databaseObject).isDefault) {
            throw new EngineException("Cannot delete the default connector!");
        }
        String dirPath, projectName;
        File dir;
        projectName = databaseObject.getParent().getName();
        MessageBox messageBox = new MessageBox(getParentShell(), SWT.ICON_QUESTION | SWT.YES | SWT.NO);
        messageBox.setText("Also delete linked resources?");
        // Delete soap templates for this connector
        dirPath = Engine.projectDir(projectName) + "/soap-templates/" + databaseObject.getName();
        dir = new File(dirPath);
        if (dir.exists()) {
            messageBox.setMessage("Some resources are linked to the deleted connector.\n\n" + "Do you also want to delete folder:\n\n\"" + dirPath + "\"");
            if (messageBox.open() == SWT.YES) {
                try {
                    DatabaseObjectsManager.deleteDir(dir);
                } catch (IOException e) {
                    ConvertigoPlugin.logDebug("Unable to delete directory \"" + dirPath + "\"!");
                }
            }
        }
        // Delete directory corresponding to connector under Traces directory
        dirPath = Engine.projectDir(projectName) + "/Traces/" + databaseObject.getName();
        dir = new File(dirPath);
        if (dir.exists()) {
            messageBox.setMessage("Some resources are linked to the deleted connector.\n\n" + "Do you also want to delete folder:\n\n\"" + dirPath + "\"");
            if (messageBox.open() == SWT.YES) {
                try {
                    DatabaseObjectsManager.deleteDir(dir);
                } catch (IOException e) {
                    ConvertigoPlugin.logDebug("Unable to delete directory \"" + dirPath + "\"!");
                }
            }
        }
    } else if (databaseObject instanceof Transaction) {
        if (((Transaction) databaseObject).isDefault) {
            throw new EngineException("Cannot delete the default transaction!");
        }
    } else if (databaseObject instanceof ScreenClass) {
        if ((databaseObject.getParent()) instanceof Project) {
            throw new EngineException("Cannot delete the root screen class!");
        }
    } else if (databaseObject instanceof Statement) {
        if ((databaseObject instanceof ThenStatement) || (databaseObject instanceof ElseStatement)) {
            throw new EngineException("Cannot delete this statement!");
        }
    } else if (databaseObject instanceof Step) {
        if ((databaseObject instanceof ThenStep) || (databaseObject instanceof ElseStep)) {
            throw new EngineException("Cannot delete this step!");
        }
    } else if (databaseObject instanceof MobilePlatform) {
        MobilePlatform mobilePlatform = (MobilePlatform) databaseObject;
        File resourceFolder = mobilePlatform.getResourceFolder();
        if (resourceFolder.exists()) {
            MessageBox messageBox = new MessageBox(getParentShell(), SWT.ICON_QUESTION | SWT.YES | SWT.NO);
            messageBox.setMessage("Do you want to delete the whole resource folder \"" + mobilePlatform.getRelativeResourcePath() + "\"?");
            messageBox.setText("Delete the \"" + resourceFolder.getName() + "\" folder?");
            if (messageBox.open() == SWT.YES) {
                FileUtils.deleteQuietly(resourceFolder);
            }
        }
    } else if (databaseObject instanceof PageComponent) {
        if (((PageComponent) databaseObject).isRoot) {
            throw new EngineException("Cannot delete the root page!");
        }
    }
    String dboQName = databaseObject.getQName();
    if (databaseObject instanceof Project) {
        // Engine.theApp.databaseObjectsManager.deleteProject(databaseObject.getName());
        if (deleteProjectOnDisk) {
            Engine.theApp.databaseObjectsManager.deleteProjectAndCar(databaseObject.getName(), DeleteProjectOption.unloadOnly);
        } else {
            Engine.theApp.databaseObjectsManager.deleteProject(databaseObject.getName(), DeleteProjectOption.unloadOnly);
        }
        ConvertigoPlugin.getDefault().deleteProjectPluginResource(deleteProjectOnDisk, databaseObject.getName());
    } else {
        databaseObject.delete();
    }
    if (databaseObject instanceof CouchDbConnector) {
        CouchDbConnector couchDbConnector = (CouchDbConnector) databaseObject;
        String db = couchDbConnector.getDatabaseName();
        if (!db.isEmpty()) {
            MessageBox messageBox = new MessageBox(getParentShell(), SWT.ICON_QUESTION | SWT.YES | SWT.NO);
            messageBox.setMessage("Do you want to delete the \"" + db + "\" database from the CouchDb server?");
            messageBox.setText("Delete the database?");
            if (messageBox.open() == SWT.YES) {
                couchDbConnector.getCouchClient().deleteDatabase(db);
            }
        }
    }
    ConvertigoPlugin.logDebug("The object \"" + dboQName + "\" has been deleted from the database repository!");
}
Also used : CouchDbConnector(com.twinsoft.convertigo.beans.connectors.CouchDbConnector) Connector(com.twinsoft.convertigo.beans.core.Connector) ElseStep(com.twinsoft.convertigo.beans.steps.ElseStep) ScreenClass(com.twinsoft.convertigo.beans.core.ScreenClass) ElseStatement(com.twinsoft.convertigo.beans.statements.ElseStatement) Statement(com.twinsoft.convertigo.beans.core.Statement) ThenStatement(com.twinsoft.convertigo.beans.statements.ThenStatement) EngineException(com.twinsoft.convertigo.engine.EngineException) ThenStatement(com.twinsoft.convertigo.beans.statements.ThenStatement) IOException(java.io.IOException) Step(com.twinsoft.convertigo.beans.core.Step) ElseStep(com.twinsoft.convertigo.beans.steps.ElseStep) ThenStep(com.twinsoft.convertigo.beans.steps.ThenStep) SimpleStep(com.twinsoft.convertigo.beans.steps.SimpleStep) CouchDbConnector(com.twinsoft.convertigo.beans.connectors.CouchDbConnector) PageComponent(com.twinsoft.convertigo.beans.mobile.components.PageComponent) MessageBox(org.eclipse.swt.widgets.MessageBox) ThenStep(com.twinsoft.convertigo.beans.steps.ThenStep) Project(com.twinsoft.convertigo.beans.core.Project) MobilePlatform(com.twinsoft.convertigo.beans.core.MobilePlatform) Transaction(com.twinsoft.convertigo.beans.core.Transaction) ElseStatement(com.twinsoft.convertigo.beans.statements.ElseStatement) File(java.io.File)

Example 22 with Step

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

the class DisableStepAction method run.

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

Example 23 with Step

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

the class OutputStepAction method output.

private void output(Step step) {
    if (step != null) {
        step.setOutput(output);
        step.hasChanged = true;
        if (recurse && (step instanceof StepWithExpressions)) {
            for (Step child : ((StepWithExpressions) step).getSteps()) {
                output(child);
            }
        }
    }
}
Also used : StepWithExpressions(com.twinsoft.convertigo.beans.core.StepWithExpressions) AttributeStep(com.twinsoft.convertigo.beans.steps.AttributeStep) XMLAttributeStep(com.twinsoft.convertigo.beans.steps.XMLAttributeStep) Step(com.twinsoft.convertigo.beans.core.Step)

Example 24 with Step

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

the class OutputStepAction 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 StepTreeObject) {
        Step step = ((StepTreeObject) treeObject).getObject();
        if (step instanceof AttributeStep || step instanceof XMLAttributeStep) {
            action.setText("Attribute always output true.");
            action.setEnabled(false);
        } else {
            output = !step.isOutput();
            String actionText = output ? "Output true" : "Output false";
            actionText += recurse ? " recursively" : "";
            action.setText(actionText);
        }
    }
}
Also used : StepTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.StepTreeObject) AttributeStep(com.twinsoft.convertigo.beans.steps.AttributeStep) XMLAttributeStep(com.twinsoft.convertigo.beans.steps.XMLAttributeStep) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) StepTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.StepTreeObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) AttributeStep(com.twinsoft.convertigo.beans.steps.AttributeStep) XMLAttributeStep(com.twinsoft.convertigo.beans.steps.XMLAttributeStep) Step(com.twinsoft.convertigo.beans.core.Step) XMLAttributeStep(com.twinsoft.convertigo.beans.steps.XMLAttributeStep)

Example 25 with Step

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

the class VariableGenerateFromXmlAndLinkAction 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 StepVariable))) {
                StepVariable stepVariable = (StepVariable) databaseObject;
                RequestableStep requestableStep = (RequestableStep) stepVariable.getParent();
                if (requestableStep != null) {
                    DatabaseObjectTreeObject parentDboTreeObject = ((DatabaseObjectTreeObject) treeObject).getParentDatabaseObjectTreeObject().getParentDatabaseObjectTreeObject();
                    RequestableObject requestableObject = null;
                    if (requestableStep instanceof SequenceStep) {
                        requestableObject = ((SequenceStep) requestableStep).getTargetSequence();
                    } else if (requestableStep instanceof TransactionStep) {
                        requestableObject = ((TransactionStep) requestableStep).getTargetTransaction();
                    }
                    if ((requestableObject != null) && (requestableObject instanceof IVariableContainer)) {
                        String variableName = stepVariable.getName();
                        IVariableContainer container = (IVariableContainer) requestableObject;
                        RequestableVariable variable = (RequestableVariable) container.getVariable(variableName);
                        // generate dom model
                        Document document = null;
                        try {
                            String description = variable.getDescription();
                            document = XMLUtils.parseDOMFromString(description);
                        } catch (Exception e) {
                        }
                        if (document != null) {
                            Element root = document.getDocumentElement();
                            if (root != null) {
                                // create step's structure from dom
                                DatabaseObject parentObject = requestableStep.getParent();
                                Step step = StepUtils.createStepFromXmlDomModel(parentObject, root);
                                // add step's structure to parent of requestableStep
                                if (parentObject instanceof Sequence) {
                                    Sequence parentSequence = (Sequence) parentObject;
                                    parentSequence.addStep(step);
                                    parentSequence.insertAtOrder(step, requestableStep.priority);
                                } else {
                                    StepWithExpressions parentSwe = (StepWithExpressions) parentObject;
                                    parentSwe.addStep(step);
                                    parentSwe.insertAtOrder(step, requestableStep.priority);
                                }
                                // set source definition of variable
                                XMLVector<String> sourceDefinition = new XMLVector<String>();
                                sourceDefinition.add(String.valueOf(step.priority));
                                sourceDefinition.add(".");
                                stepVariable.setSourceDefinition(sourceDefinition);
                                stepVariable.hasChanged = true;
                                // Reload parent dbo in tree
                                explorerView.reloadTreeObject(parentDboTreeObject);
                                // Select variable dbo in tree
                                explorerView.objectSelected(new CompositeEvent(databaseObject));
                            }
                        }
                    }
                }
            }
        }
    } catch (Throwable e) {
        ConvertigoPlugin.logException(e, "Unable to generate and link variable!");
    } finally {
        shell.setCursor(null);
        waitCursor.dispose();
    }
}
Also used : DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) XMLVector(com.twinsoft.convertigo.beans.common.XMLVector) Element(org.w3c.dom.Element) StepWithExpressions(com.twinsoft.convertigo.beans.core.StepWithExpressions) StepVariable(com.twinsoft.convertigo.beans.variables.StepVariable) Step(com.twinsoft.convertigo.beans.core.Step) SequenceStep(com.twinsoft.convertigo.beans.steps.SequenceStep) RequestableStep(com.twinsoft.convertigo.beans.core.RequestableStep) TransactionStep(com.twinsoft.convertigo.beans.steps.TransactionStep) Cursor(org.eclipse.swt.graphics.Cursor) Document(org.w3c.dom.Document) Shell(org.eclipse.swt.widgets.Shell) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) CompositeEvent(com.twinsoft.convertigo.eclipse.editors.CompositeEvent) SequenceStep(com.twinsoft.convertigo.beans.steps.SequenceStep) ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) RequestableObject(com.twinsoft.convertigo.beans.core.RequestableObject) RequestableVariable(com.twinsoft.convertigo.beans.variables.RequestableVariable) Sequence(com.twinsoft.convertigo.beans.core.Sequence) TransactionStep(com.twinsoft.convertigo.beans.steps.TransactionStep) RequestableStep(com.twinsoft.convertigo.beans.core.RequestableStep) IVariableContainer(com.twinsoft.convertigo.beans.core.IVariableContainer) 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) RequestableObject(com.twinsoft.convertigo.beans.core.RequestableObject) Display(org.eclipse.swt.widgets.Display)

Aggregations

Step (com.twinsoft.convertigo.beans.core.Step)70 Sequence (com.twinsoft.convertigo.beans.core.Sequence)36 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)32 StepWithExpressions (com.twinsoft.convertigo.beans.core.StepWithExpressions)26 EngineException (com.twinsoft.convertigo.engine.EngineException)26 DatabaseObjectTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject)25 ThenStep (com.twinsoft.convertigo.beans.steps.ThenStep)24 TreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject)24 TransactionStep (com.twinsoft.convertigo.beans.steps.TransactionStep)21 ProjectExplorerView (com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView)21 ElseStep (com.twinsoft.convertigo.beans.steps.ElseStep)20 SequenceStep (com.twinsoft.convertigo.beans.steps.SequenceStep)19 RequestableStep (com.twinsoft.convertigo.beans.core.RequestableStep)18 Connector (com.twinsoft.convertigo.beans.core.Connector)17 Project (com.twinsoft.convertigo.beans.core.Project)17 Cursor (org.eclipse.swt.graphics.Cursor)17 Display (org.eclipse.swt.widgets.Display)17 Shell (org.eclipse.swt.widgets.Shell)17 Transaction (com.twinsoft.convertigo.beans.core.Transaction)16 StepTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.StepTreeObject)16