Search in sources :

Example 71 with Connector

use of com.twinsoft.convertigo.beans.core.Connector 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 72 with Connector

use of com.twinsoft.convertigo.beans.core.Connector 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

Connector (com.twinsoft.convertigo.beans.core.Connector)72 Transaction (com.twinsoft.convertigo.beans.core.Transaction)43 Project (com.twinsoft.convertigo.beans.core.Project)32 EngineException (com.twinsoft.convertigo.engine.EngineException)28 JavelinConnector (com.twinsoft.convertigo.beans.connectors.JavelinConnector)22 Sequence (com.twinsoft.convertigo.beans.core.Sequence)21 HtmlConnector (com.twinsoft.convertigo.beans.connectors.HtmlConnector)17 Step (com.twinsoft.convertigo.beans.core.Step)17 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)16 HttpConnector (com.twinsoft.convertigo.beans.connectors.HttpConnector)15 SiteClipperConnector (com.twinsoft.convertigo.beans.connectors.SiteClipperConnector)14 ScreenClass (com.twinsoft.convertigo.beans.core.ScreenClass)14 HtmlTransaction (com.twinsoft.convertigo.beans.transactions.HtmlTransaction)14 TreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject)12 CouchDbConnector (com.twinsoft.convertigo.beans.connectors.CouchDbConnector)11 SqlConnector (com.twinsoft.convertigo.beans.connectors.SqlConnector)11 Statement (com.twinsoft.convertigo.beans.core.Statement)11 ElseStep (com.twinsoft.convertigo.beans.steps.ElseStep)11 ThenStep (com.twinsoft.convertigo.beans.steps.ThenStep)11 ProjectExplorerView (com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView)11