Search in sources :

Example 1 with ScExitDefaultHandlerStatement

use of com.twinsoft.convertigo.beans.statements.ScExitDefaultHandlerStatement in project convertigo by convertigo.

the class CreateHandlerDialogComposite method generateStatementHandler.

public void generateStatementHandler() throws EngineException {
    String normalizedScreenClassName, handlerName = "";
    if (jCheckBoxTransactionStarted.getSelection()) {
        handlerName = "on" + Transaction.EVENT_TRANSACTION_STARTED;
        if (((HtmlTransaction) transaction).getHandlerStatement(handlerName) == null) {
            HandlerStatement statement = new HandlerStatement(HandlerStatement.EVENT_TRANSACTION_STARTED, "");
            addElement(statement, handlerName);
        } else
            Beep();
    }
    if (jCheckBoxXmlGenerated.getSelection()) {
        handlerName = "on" + Transaction.EVENT_XML_GENERATED;
        if (((HtmlTransaction) transaction).getHandlerStatement(handlerName) == null) {
            HandlerStatement statement = new HandlerStatement(HandlerStatement.EVENT_XML_GENERATED, "");
            addElement(statement, handlerName);
        } else
            Beep();
    }
    if (jCheckBoxTransactionDefaultHandlerEntry.getSelection()) {
        handlerName = "onTransactionDefaultHandlerEntry";
        if (((HtmlTransaction) transaction).getHandlerStatement(handlerName) == null) {
            ScEntryDefaultHandlerStatement statement = new ScEntryDefaultHandlerStatement();
            addElement(statement, handlerName);
        } else
            Beep();
    }
    if (jCheckBoxTransactionDefaultHandlerExit.getSelection()) {
        handlerName = "onTransactionDefaultHandlerExit";
        if (((HtmlTransaction) transaction).getHandlerStatement(handlerName) == null) {
            ScExitDefaultHandlerStatement statement = new ScExitDefaultHandlerStatement();
            addElement(statement, handlerName);
        } else
            Beep();
    }
    if (jCheckBoxEntry.getSelection() || jCheckBoxExit.getSelection()) {
        TreeItem[] treeItems = tree.getSelection();
        for (int i = 0; i < treeItems.length; i++) {
            String selectedScreenClass = treeItems[i].getText();
            normalizedScreenClassName = StringUtils.normalize(selectedScreenClass);
            if (jCheckBoxEntry.getSelection()) {
                handlerName = "on" + normalizedScreenClassName + "Entry";
                if (((HtmlTransaction) transaction).getHandlerStatement(handlerName) == null) {
                    ScEntryHandlerStatement statement = new ScEntryHandlerStatement(normalizedScreenClassName);
                    addElement(statement, handlerName);
                } else
                    Beep();
            }
            if (jCheckBoxExit.getSelection()) {
                handlerName = "on" + normalizedScreenClassName + "Exit";
                if (((HtmlTransaction) transaction).getHandlerStatement(handlerName) == null) {
                    ScExitHandlerStatement statement = new ScExitHandlerStatement(normalizedScreenClassName);
                    addElement(statement, handlerName);
                } else
                    Beep();
            }
        }
    }
}
Also used : ScEntryHandlerStatement(com.twinsoft.convertigo.beans.statements.ScEntryHandlerStatement) TreeItem(org.eclipse.swt.widgets.TreeItem) ScExitDefaultHandlerStatement(com.twinsoft.convertigo.beans.statements.ScExitDefaultHandlerStatement) ScExitDefaultHandlerStatement(com.twinsoft.convertigo.beans.statements.ScExitDefaultHandlerStatement) ScExitHandlerStatement(com.twinsoft.convertigo.beans.statements.ScExitHandlerStatement) ScEntryDefaultHandlerStatement(com.twinsoft.convertigo.beans.statements.ScEntryDefaultHandlerStatement) HandlerStatement(com.twinsoft.convertigo.beans.statements.HandlerStatement) ScEntryHandlerStatement(com.twinsoft.convertigo.beans.statements.ScEntryHandlerStatement) ScEntryDefaultHandlerStatement(com.twinsoft.convertigo.beans.statements.ScEntryDefaultHandlerStatement) ScExitHandlerStatement(com.twinsoft.convertigo.beans.statements.ScExitHandlerStatement)

Example 2 with ScExitDefaultHandlerStatement

use of com.twinsoft.convertigo.beans.statements.ScExitDefaultHandlerStatement in project convertigo by convertigo.

the class ChangeToScEntryHandlerStatementAction method run.

/* (non-Javadoc)
	 * @see com.twinsoft.convertigo.eclipse.popup.actions.MyAbstractAction#run()
	 */
@Override
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 = (DatabaseObjectTreeObject) explorerView.getFirstSelectedTreeObject();
            DatabaseObject databaseObject = treeObject.getObject();
            // For ScExitHandler statement
            if ((databaseObject != null) && (databaseObject instanceof ScExitHandlerStatement || databaseObject instanceof ScExitDefaultHandlerStatement)) {
                HandlerStatement scExitHandlerStatement = (HandlerStatement) databaseObject;
                DatabaseObjectTreeObject parentTreeObject = treeObject.getOwnerDatabaseObjectTreeObject();
                if (parentTreeObject != null) {
                    // New ScEntryHandler statement
                    HandlerStatement scEntryHandlerStatement = databaseObject instanceof ScExitHandlerStatement ? new ScEntryHandlerStatement() : new ScEntryDefaultHandlerStatement();
                    // Set properties
                    String handlerResult = scExitHandlerStatement.getHandlerResult();
                    if (ScHandlerStatement.RETURN_ACCUMULATE.equals(handlerResult)) {
                        handlerResult = ScHandlerStatement.RETURN_REDETECT;
                    }
                    scEntryHandlerStatement.setHandlerResult(handlerResult);
                    scEntryHandlerStatement.setComment(scExitHandlerStatement.getComment());
                    scEntryHandlerStatement.setEnabled(scExitHandlerStatement.isEnabled());
                    scEntryHandlerStatement.setPreventFromLoops(scExitHandlerStatement.preventFromLoops());
                    scEntryHandlerStatement.setParent(scExitHandlerStatement.getParent());
                    scEntryHandlerStatement.setReturnedValue(scExitHandlerStatement.getReturnedValue());
                    scEntryHandlerStatement.setVersion(scExitHandlerStatement.getVersion());
                    if (databaseObject instanceof ScExitHandlerStatement) {
                        ScExitHandlerStatement scExit = (ScExitHandlerStatement) scExitHandlerStatement;
                        ScEntryHandlerStatement scEntry = (ScEntryHandlerStatement) scEntryHandlerStatement;
                        scEntry.setNormalizedScreenClassName(scExit.getNormalizedScreenClassName());
                        scEntry.setName("on" + scExit.getNormalizedScreenClassName() + "Entry");
                    }
                    // Change status of ScEntryHandler statement
                    scEntryHandlerStatement.bNew = true;
                    scEntryHandlerStatement.hasChanged = true;
                    // Add new ScEntryHandler statement to parent
                    DatabaseObject parentDbo = scEntryHandlerStatement.getParent();
                    parentDbo.add(scEntryHandlerStatement);
                    for (Statement statement : scExitHandlerStatement.getStatements()) {
                        scEntryHandlerStatement.addStatement(statement);
                    }
                    // Delete ScExitHandler statement
                    scExitHandlerStatement.delete();
                    parentTreeObject.hasBeenModified(true);
                    explorerView.reloadTreeObject(parentTreeObject);
                    DatabaseObjectTreeObject newTreeObject = parentTreeObject.findDatabaseObjectTreeObjectChild(scEntryHandlerStatement);
                    explorerView.setSelectedTreeObject(newTreeObject);
                }
            }
        }
    } catch (Throwable e) {
        ConvertigoPlugin.logException(e, "Unable to change screen class exit handler statement to screen class entry handler statement!");
    } finally {
        shell.setCursor(null);
        waitCursor.dispose();
    }
}
Also used : ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) ScExitDefaultHandlerStatement(com.twinsoft.convertigo.beans.statements.ScExitDefaultHandlerStatement) ScExitHandlerStatement(com.twinsoft.convertigo.beans.statements.ScExitHandlerStatement) ScHandlerStatement(com.twinsoft.convertigo.beans.statements.ScHandlerStatement) ScExitDefaultHandlerStatement(com.twinsoft.convertigo.beans.statements.ScExitDefaultHandlerStatement) ScEntryDefaultHandlerStatement(com.twinsoft.convertigo.beans.statements.ScEntryDefaultHandlerStatement) Statement(com.twinsoft.convertigo.beans.core.Statement) HandlerStatement(com.twinsoft.convertigo.beans.statements.HandlerStatement) ScEntryHandlerStatement(com.twinsoft.convertigo.beans.statements.ScEntryHandlerStatement) ScExitHandlerStatement(com.twinsoft.convertigo.beans.statements.ScExitHandlerStatement) ScHandlerStatement(com.twinsoft.convertigo.beans.statements.ScHandlerStatement) ScExitDefaultHandlerStatement(com.twinsoft.convertigo.beans.statements.ScExitDefaultHandlerStatement) ScEntryDefaultHandlerStatement(com.twinsoft.convertigo.beans.statements.ScEntryDefaultHandlerStatement) HandlerStatement(com.twinsoft.convertigo.beans.statements.HandlerStatement) ScEntryHandlerStatement(com.twinsoft.convertigo.beans.statements.ScEntryHandlerStatement) Cursor(org.eclipse.swt.graphics.Cursor) ScEntryDefaultHandlerStatement(com.twinsoft.convertigo.beans.statements.ScEntryDefaultHandlerStatement) ScExitHandlerStatement(com.twinsoft.convertigo.beans.statements.ScExitHandlerStatement) Shell(org.eclipse.swt.widgets.Shell) ScEntryHandlerStatement(com.twinsoft.convertigo.beans.statements.ScEntryHandlerStatement) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) Display(org.eclipse.swt.widgets.Display)

Example 3 with ScExitDefaultHandlerStatement

use of com.twinsoft.convertigo.beans.statements.ScExitDefaultHandlerStatement in project convertigo by convertigo.

the class ChangeToScExitHandlerStatementAction method run.

/* (non-Javadoc)
	 * @see com.twinsoft.convertigo.eclipse.popup.actions.MyAbstractAction#run()
	 */
@Override
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 = (DatabaseObjectTreeObject) explorerView.getFirstSelectedTreeObject();
            DatabaseObject databaseObject = treeObject.getObject();
            // For ScEntryHandler statement
            if ((databaseObject != null) && (databaseObject instanceof ScEntryHandlerStatement || databaseObject instanceof ScEntryDefaultHandlerStatement)) {
                HandlerStatement scEntryHandlerStatement = (HandlerStatement) databaseObject;
                DatabaseObjectTreeObject parentTreeObject = treeObject.getOwnerDatabaseObjectTreeObject();
                if (parentTreeObject != null) {
                    // New ScExitHandler statement
                    HandlerStatement scExitHandlerStatement = databaseObject instanceof ScEntryHandlerStatement ? new ScExitHandlerStatement() : new ScExitDefaultHandlerStatement();
                    // Set properties
                    String handlerResult = scEntryHandlerStatement.getHandlerResult();
                    if (ScHandlerStatement.RETURN_REDETECT.equals(handlerResult)) {
                        handlerResult = ScHandlerStatement.RETURN_ACCUMULATE;
                    } else if (ScHandlerStatement.RETURN_SKIP.equals(handlerResult)) {
                        handlerResult = "";
                    }
                    scExitHandlerStatement.setHandlerResult(handlerResult);
                    scExitHandlerStatement.setComment(scEntryHandlerStatement.getComment());
                    scExitHandlerStatement.setEnabled(scEntryHandlerStatement.isEnabled());
                    scExitHandlerStatement.setPreventFromLoops(scEntryHandlerStatement.preventFromLoops());
                    scExitHandlerStatement.setParent(scEntryHandlerStatement.getParent());
                    scExitHandlerStatement.setReturnedValue(scEntryHandlerStatement.getReturnedValue());
                    scExitHandlerStatement.setVersion(scEntryHandlerStatement.getVersion());
                    if (databaseObject instanceof ScEntryHandlerStatement) {
                        ScExitHandlerStatement scExit = (ScExitHandlerStatement) scExitHandlerStatement;
                        ScEntryHandlerStatement scEntry = (ScEntryHandlerStatement) scEntryHandlerStatement;
                        scExit.setNormalizedScreenClassName(scEntry.getNormalizedScreenClassName());
                        scExit.setName("on" + scEntry.getNormalizedScreenClassName() + "Exit");
                    }
                    // Change status of scExitHanlder statement
                    scExitHandlerStatement.bNew = true;
                    scExitHandlerStatement.hasChanged = true;
                    // Add new ScExitHandler statement to parent
                    DatabaseObject parentDbo = scEntryHandlerStatement.getParent();
                    parentDbo.add(scExitHandlerStatement);
                    // Add new ScExitHandler statement in Tree
                    StatementTreeObject statementTreeObject = new StatementTreeObject(explorerView.viewer, scExitHandlerStatement);
                    parentTreeObject.addChild(statementTreeObject);
                    for (Statement statement : scEntryHandlerStatement.getStatements()) {
                        scExitHandlerStatement.addStatement(statement);
                    }
                    // Delete ScEntryHandler statement
                    scEntryHandlerStatement.delete();
                    parentTreeObject.hasBeenModified(true);
                    explorerView.reloadTreeObject(parentTreeObject);
                    DatabaseObjectTreeObject newTreeObject = parentTreeObject.findDatabaseObjectTreeObjectChild(scExitHandlerStatement);
                    explorerView.setSelectedTreeObject(newTreeObject);
                }
            }
        }
    } catch (Throwable e) {
        ConvertigoPlugin.logException(e, "Unable to change screen class entry handler statement to screen class exit handler statement!");
    } finally {
        shell.setCursor(null);
        waitCursor.dispose();
    }
}
Also used : ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) ScExitDefaultHandlerStatement(com.twinsoft.convertigo.beans.statements.ScExitDefaultHandlerStatement) ScExitHandlerStatement(com.twinsoft.convertigo.beans.statements.ScExitHandlerStatement) ScHandlerStatement(com.twinsoft.convertigo.beans.statements.ScHandlerStatement) ScExitDefaultHandlerStatement(com.twinsoft.convertigo.beans.statements.ScExitDefaultHandlerStatement) ScEntryDefaultHandlerStatement(com.twinsoft.convertigo.beans.statements.ScEntryDefaultHandlerStatement) Statement(com.twinsoft.convertigo.beans.core.Statement) HandlerStatement(com.twinsoft.convertigo.beans.statements.HandlerStatement) ScEntryHandlerStatement(com.twinsoft.convertigo.beans.statements.ScEntryHandlerStatement) ScExitHandlerStatement(com.twinsoft.convertigo.beans.statements.ScExitHandlerStatement) ScHandlerStatement(com.twinsoft.convertigo.beans.statements.ScHandlerStatement) ScExitDefaultHandlerStatement(com.twinsoft.convertigo.beans.statements.ScExitDefaultHandlerStatement) ScEntryDefaultHandlerStatement(com.twinsoft.convertigo.beans.statements.ScEntryDefaultHandlerStatement) HandlerStatement(com.twinsoft.convertigo.beans.statements.HandlerStatement) ScEntryHandlerStatement(com.twinsoft.convertigo.beans.statements.ScEntryHandlerStatement) Cursor(org.eclipse.swt.graphics.Cursor) ScEntryDefaultHandlerStatement(com.twinsoft.convertigo.beans.statements.ScEntryDefaultHandlerStatement) ScExitHandlerStatement(com.twinsoft.convertigo.beans.statements.ScExitHandlerStatement) Shell(org.eclipse.swt.widgets.Shell) ScEntryHandlerStatement(com.twinsoft.convertigo.beans.statements.ScEntryHandlerStatement) StatementTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.StatementTreeObject) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) Display(org.eclipse.swt.widgets.Display)

Aggregations

HandlerStatement (com.twinsoft.convertigo.beans.statements.HandlerStatement)3 ScEntryDefaultHandlerStatement (com.twinsoft.convertigo.beans.statements.ScEntryDefaultHandlerStatement)3 ScEntryHandlerStatement (com.twinsoft.convertigo.beans.statements.ScEntryHandlerStatement)3 ScExitDefaultHandlerStatement (com.twinsoft.convertigo.beans.statements.ScExitDefaultHandlerStatement)3 ScExitHandlerStatement (com.twinsoft.convertigo.beans.statements.ScExitHandlerStatement)3 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)2 Statement (com.twinsoft.convertigo.beans.core.Statement)2 ScHandlerStatement (com.twinsoft.convertigo.beans.statements.ScHandlerStatement)2 ProjectExplorerView (com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView)2 DatabaseObjectTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject)2 Cursor (org.eclipse.swt.graphics.Cursor)2 Display (org.eclipse.swt.widgets.Display)2 Shell (org.eclipse.swt.widgets.Shell)2 StatementTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.StatementTreeObject)1 TreeItem (org.eclipse.swt.widgets.TreeItem)1