Search in sources :

Example 66 with Transaction

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

the class TransactionExecuteDefaultAction method run2.

@Override
protected void run2() throws Exception {
    try {
        WrapDatabaseObject treeObject = (WrapDatabaseObject) studio.getFirstSelectedTreeObject();
        if (treeObject != null) {
            ProjectView projectTreeObject = treeObject.getProjectViewObject();
            Connector connector = null;
            if (treeObject.instanceOf(Connector.class)) {
                ConnectorView connectorTreeObject = (ConnectorView) treeObject;
                connectorTreeObject.openConnectorEditor();
                connector = connectorTreeObject.getObject();
            } else {
                connector = ((Project) projectTreeObject.getObject()).getDefaultConnector();
                ConnectorView connectorTreeObject = (ConnectorView) Studio.getViewFromDbo(connector, studio);
                if (connectorTreeObject != null) {
                    connectorTreeObject.openConnectorEditor();
                }
            }
            Transaction transaction = connector.getDefaultTransaction();
            ConnectorEditorWrap connectorEditor = projectTreeObject.getConnectorEditor(connector);
            if (connectorEditor != null) {
                // getActivePage().activate(connectorEditor);
                connectorEditor.getDocument(transaction.getName(), false);
            }
        }
    } catch (Exception e) {
        throw e;
    }
}
Also used : Connector(com.twinsoft.convertigo.beans.core.Connector) ConnectorEditorWrap(com.twinsoft.convertigo.engine.studio.editors.connectors.ConnectorEditorWrap) Transaction(com.twinsoft.convertigo.beans.core.Transaction) ConnectorView(com.twinsoft.convertigo.engine.studio.views.projectexplorer.model.ConnectorView) WrapDatabaseObject(com.twinsoft.convertigo.engine.studio.views.projectexplorer.model.WrapDatabaseObject) ProjectView(com.twinsoft.convertigo.engine.studio.views.projectexplorer.model.ProjectView)

Example 67 with Transaction

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

the class CreateFormFromTransactionAction 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) {
            Transaction transaction = null;
            Connector connector = null;
            TreeObject treeObject = explorerView.getFirstSelectedTreeObject();
            if (treeObject instanceof TransactionTreeObject) {
                transaction = (Transaction) treeObject.getObject();
                connector = (Connector) transaction.getParent();
                if (transaction instanceof TransactionWithVariables) {
                    TransactionWithVariables tr = (TransactionWithVariables) transaction;
                    // if (tr.getVariablesDefinitionSize() == 0) {
                    if (tr.numberOfVariables() == 0) {
                        MessageBox messageBox = new MessageBox(shell, SWT.YES | SWT.APPLICATION_MODAL);
                        messageBox.setMessage("No variables are defined for transaction " + tr.getName());
                        messageBox.open();
                    } else {
                        String xslContent = generateXSLForm(connector, tr);
                        // Refresh project resource
                        IProject project = ConvertigoPlugin.getDefault().getProjectPluginResource(tr.getProject().getName());
                        // Compute the targetXSL file name
                        String xslForm = tr.getName() + "Request.xsl";
                        IFile file = project.getFile(xslForm);
                        ByteArrayInputStream bais = new ByteArrayInputStream(xslContent.getBytes());
                        if (file.exists()) {
                            file.setContents((InputStream) bais, IFile.FORCE | IFile.KEEP_HISTORY, null);
                        } else {
                            file.create((InputStream) bais, true, null);
                        }
                        TransactionWithVariables newTrans = (TransactionWithVariables) tr.clone();
                        newTrans.hasChanged = true;
                        newTrans.bNew = true;
                        XMLVector<XMLVector<Long>> orderedVariables = new XMLVector<XMLVector<Long>>();
                        orderedVariables.add(new XMLVector<Long>());
                        newTrans.setOrderedVariables(orderedVariables);
                        newTrans.setSheetLocation(Transaction.SHEET_LOCATION_FROM_REQUESTABLE);
                        HandlerStatement handler = new HandlerStatement(HandlerStatement.EVENT_TRANSACTION_STARTED, HandlerStatement.RETURN_CANCEL);
                        newTrans.add(handler);
                        newTrans.setName(tr.getName() + "Request");
                        Sheet sheet = new Sheet();
                        sheet.setBrowser("*");
                        sheet.setUrl(xslForm);
                        newTrans.addSheet(sheet);
                        connector.add(newTrans);
                        postCreate(treeObject.getConnectorTreeObject(), newTrans);
                    }
                }
            }
        }
    } catch (Throwable e) {
        ConvertigoPlugin.logException(e, "Unable to generate a requestForm widget");
    } finally {
        shell.setCursor(null);
        waitCursor.dispose();
    }
}
Also used : Connector(com.twinsoft.convertigo.beans.core.Connector) TransactionTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TransactionTreeObject) ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) IFile(org.eclipse.core.resources.IFile) XMLVector(com.twinsoft.convertigo.beans.common.XMLVector) HandlerStatement(com.twinsoft.convertigo.beans.statements.HandlerStatement) Cursor(org.eclipse.swt.graphics.Cursor) IProject(org.eclipse.core.resources.IProject) MessageBox(org.eclipse.swt.widgets.MessageBox) Shell(org.eclipse.swt.widgets.Shell) Transaction(com.twinsoft.convertigo.beans.core.Transaction) ByteArrayInputStream(java.io.ByteArrayInputStream) TransactionTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TransactionTreeObject) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) TransactionWithVariables(com.twinsoft.convertigo.beans.core.TransactionWithVariables) Sheet(com.twinsoft.convertigo.beans.core.Sheet) Display(org.eclipse.swt.widgets.Display)

Aggregations

Transaction (com.twinsoft.convertigo.beans.core.Transaction)67 Connector (com.twinsoft.convertigo.beans.core.Connector)43 Sequence (com.twinsoft.convertigo.beans.core.Sequence)29 EngineException (com.twinsoft.convertigo.engine.EngineException)27 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)24 Project (com.twinsoft.convertigo.beans.core.Project)23 HtmlTransaction (com.twinsoft.convertigo.beans.transactions.HtmlTransaction)21 Step (com.twinsoft.convertigo.beans.core.Step)17 ScreenClass (com.twinsoft.convertigo.beans.core.ScreenClass)16 TreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject)16 HtmlConnector (com.twinsoft.convertigo.beans.connectors.HtmlConnector)15 JavelinConnector (com.twinsoft.convertigo.beans.connectors.JavelinConnector)15 TransactionStep (com.twinsoft.convertigo.beans.steps.TransactionStep)13 ProjectExplorerView (com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView)13 RequestableStep (com.twinsoft.convertigo.beans.core.RequestableStep)12 Statement (com.twinsoft.convertigo.beans.core.Statement)12 ElseStep (com.twinsoft.convertigo.beans.steps.ElseStep)12 SequenceStep (com.twinsoft.convertigo.beans.steps.SequenceStep)12 ThenStep (com.twinsoft.convertigo.beans.steps.ThenStep)12 JavelinTransaction (com.twinsoft.convertigo.beans.transactions.JavelinTransaction)12