Search in sources :

Example 16 with TransactionTreeObject

use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TransactionTreeObject in project convertigo by convertigo.

the class TransactionCreateHandlerAction method selectionChanged.

@Override
public void selectionChanged(IAction action, ISelection selection) {
    try {
        boolean enable = false;
        super.selectionChanged(action, selection);
        IStructuredSelection structuredSelection = (IStructuredSelection) selection;
        TreeObject treeObject = (TreeObject) structuredSelection.getFirstElement();
        if (treeObject instanceof TransactionTreeObject)
            enable = true;
        else if (treeObject instanceof ObjectsFolderTreeObject)
            enable = ((ObjectsFolderTreeObject) treeObject).folderType == ObjectsFolderTreeObject.FOLDER_TYPE_FUNCTIONS;
        action.setEnabled(enable);
    } catch (Exception e) {
    }
}
Also used : TransactionTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TransactionTreeObject) ObjectsFolderTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ObjectsFolderTreeObject) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) TransactionTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TransactionTreeObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ObjectsFolderTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ObjectsFolderTreeObject) IOException(java.io.IOException)

Example 17 with TransactionTreeObject

use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TransactionTreeObject 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

TransactionTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TransactionTreeObject)17 TreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject)15 Connector (com.twinsoft.convertigo.beans.core.Connector)9 Transaction (com.twinsoft.convertigo.beans.core.Transaction)9 ProjectExplorerView (com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView)9 Shell (org.eclipse.swt.widgets.Shell)9 Cursor (org.eclipse.swt.graphics.Cursor)8 Display (org.eclipse.swt.widgets.Display)8 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)7 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)6 ProjectTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ProjectTreeObject)6 ConnectorTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ConnectorTreeObject)5 IEditableTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IEditableTreeObject)5 ObjectsFolderTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ObjectsFolderTreeObject)5 SequenceTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.SequenceTreeObject)5 Sequence (com.twinsoft.convertigo.beans.core.Sequence)4 TestCaseTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TestCaseTreeObject)4 EngineException (com.twinsoft.convertigo.engine.EngineException)4 Statement (com.twinsoft.convertigo.beans.core.Statement)3 ConnectorEditor (com.twinsoft.convertigo.eclipse.editors.connector.ConnectorEditor)3