Search in sources :

Example 46 with DatabaseObjectTreeObject

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

the class ChangeToIfStatementAction 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) {
            TreeObject treeObject = explorerView.getFirstSelectedTreeObject();
            Object databaseObject = treeObject.getObject();
            if ((databaseObject != null) && (databaseObject instanceof IfThenElseStatement)) {
                IfThenElseStatement ifThenElseStatement = (IfThenElseStatement) databaseObject;
                if (ifThenElseStatement.hasThenElseStatements()) {
                    ThenStatement thenStatement = ifThenElseStatement.getThenStatement();
                    List<Statement> list = thenStatement.getStatements();
                    TreePath[] selectedPaths = new TreePath[list.size()];
                    for (int i = 0; i < list.size(); i++) {
                        StatementTreeObject statementTreeObject = (StatementTreeObject) explorerView.findTreeObjectByUserObject(list.get(i));
                        selectedPaths[i] = new TreePath(statementTreeObject);
                    }
                    TreeParent treeParent = treeObject.getParent();
                    DatabaseObjectTreeObject parentTreeObject = null;
                    if (treeParent instanceof DatabaseObjectTreeObject)
                        parentTreeObject = (DatabaseObjectTreeObject) treeParent;
                    else
                        parentTreeObject = (DatabaseObjectTreeObject) treeParent.getParent();
                    if (parentTreeObject != null) {
                        // New If statement
                        IfStatement ifStatement = new IfStatement(ifThenElseStatement.getCondition());
                        ifStatement.bNew = true;
                        ifStatement.hasChanged = true;
                        // Add new If statement to parent
                        DatabaseObject parentDbo = ifThenElseStatement.getParent();
                        parentDbo.add(ifStatement);
                        // Set correct order
                        if (parentDbo instanceof StatementWithExpressions) {
                            int index = ((StatementWithExpressions) parentDbo).getOrderedStatements().get(0).indexOf(ifThenElseStatement.priority);
                            ((StatementWithExpressions) parentDbo).getOrderedStatements().get(0).add(index, ifStatement.priority);
                        }
                        // Add new If statement in Tree
                        StatementTreeObject statementTreeObject = new StatementTreeObject(explorerView.viewer, ifStatement);
                        treeParent.addChild(statementTreeObject);
                        // Cut/Paste steps under If statement
                        if (selectedPaths.length > 0) {
                            new ClipboardAction(ConvertigoPlugin.clipboardManagerDND).cut(explorerView, selectedPaths, ProjectExplorerView.TREE_OBJECT_TYPE_DBO_STEP);
                            for (int i = 0; i < ConvertigoPlugin.clipboardManagerDND.objects.length; i++) {
                                ConvertigoPlugin.clipboardManagerDND.cutAndPaste(ConvertigoPlugin.clipboardManagerDND.objects[i], statementTreeObject);
                            }
                            ConvertigoPlugin.clipboardManagerDND.reset();
                        }
                        // Delete IfThenElse statement
                        ifThenElseStatement.delete();
                        parentTreeObject.hasBeenModified(true);
                        explorerView.reloadTreeObject(parentTreeObject);
                        explorerView.setSelectedTreeObject(explorerView.findTreeObjectByUserObject(ifStatement));
                    }
                }
            }
        }
    } catch (Throwable e) {
        ConvertigoPlugin.logException(e, "Unable to change statement to If 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) IfThenElseStatement(com.twinsoft.convertigo.beans.statements.IfThenElseStatement) IfStatement(com.twinsoft.convertigo.beans.statements.IfStatement) ThenStatement(com.twinsoft.convertigo.beans.statements.ThenStatement) Statement(com.twinsoft.convertigo.beans.core.Statement) TreeParent(com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeParent) IfThenElseStatement(com.twinsoft.convertigo.beans.statements.IfThenElseStatement) ThenStatement(com.twinsoft.convertigo.beans.statements.ThenStatement) Cursor(org.eclipse.swt.graphics.Cursor) IfStatement(com.twinsoft.convertigo.beans.statements.IfStatement) Shell(org.eclipse.swt.widgets.Shell) TreePath(com.twinsoft.convertigo.eclipse.views.projectexplorer.TreePath) StatementWithExpressions(com.twinsoft.convertigo.beans.core.StatementWithExpressions) StatementTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.StatementTreeObject) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) StatementTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.StatementTreeObject) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) 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) StatementTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.StatementTreeObject) Display(org.eclipse.swt.widgets.Display)

Example 47 with DatabaseObjectTreeObject

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

the class ChangeToIfStepAction 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) {
            TreeObject treeObject = explorerView.getFirstSelectedTreeObject();
            Object databaseObject = treeObject.getObject();
            if ((databaseObject != null) && (databaseObject instanceof IfThenElseStep)) {
                IfThenElseStep ifThenElseStep = (IfThenElseStep) databaseObject;
                if (ifThenElseStep.hasThenElseSteps()) {
                    ThenStep thenStep = ifThenElseStep.getThenStep();
                    List<Step> list = thenStep.getSteps();
                    TreePath[] selectedPaths = new TreePath[list.size()];
                    for (int i = 0; i < list.size(); i++) {
                        StepTreeObject stepTreeObject = (StepTreeObject) explorerView.findTreeObjectByUserObject(list.get(i));
                        selectedPaths[i] = new TreePath(stepTreeObject);
                    }
                    TreeParent treeParent = treeObject.getParent();
                    DatabaseObjectTreeObject parentTreeObject = null;
                    if (treeParent instanceof DatabaseObjectTreeObject)
                        parentTreeObject = (DatabaseObjectTreeObject) treeParent;
                    else
                        parentTreeObject = (DatabaseObjectTreeObject) treeParent.getParent();
                    if (parentTreeObject != null) {
                        // New jIf step
                        IfStep ifStep = new IfStep(ifThenElseStep.getCondition());
                        ifStep.bNew = true;
                        ifStep.hasChanged = true;
                        // Add new jIf step to parent
                        DatabaseObject parentDbo = ifThenElseStep.getParent();
                        parentDbo.add(ifStep);
                        // Set correct order
                        if (parentDbo instanceof StepWithExpressions)
                            ((StepWithExpressions) parentDbo).insertAtOrder(ifStep, ifThenElseStep.priority);
                        else if (parentDbo instanceof Sequence)
                            ((Sequence) parentDbo).insertAtOrder(ifStep, ifThenElseStep.priority);
                        // Add new jIf step in Tree
                        StepTreeObject stepTreeObject = new StepTreeObject(explorerView.viewer, ifStep);
                        treeParent.addChild(stepTreeObject);
                        // Cut/Paste steps under jIf step
                        if (selectedPaths.length > 0) {
                            new ClipboardAction(ConvertigoPlugin.clipboardManagerDND).cut(explorerView, selectedPaths, ProjectExplorerView.TREE_OBJECT_TYPE_DBO_STEP);
                            for (int i = 0; i < ConvertigoPlugin.clipboardManagerDND.objects.length; i++) {
                                ConvertigoPlugin.clipboardManagerDND.cutAndPaste(ConvertigoPlugin.clipboardManagerDND.objects[i], stepTreeObject);
                            }
                            ConvertigoPlugin.clipboardManagerDND.reset();
                        }
                        // Delete IfThenElse step
                        long oldPriority = ifThenElseStep.priority;
                        ifThenElseStep.delete();
                        // Simulate move of IfThenElse to If
                        ifStep.getSequence().fireStepMoved(new StepEvent(ifStep, String.valueOf(oldPriority)));
                        parentTreeObject.hasBeenModified(true);
                        explorerView.reloadTreeObject(parentTreeObject);
                        explorerView.setSelectedTreeObject(explorerView.findTreeObjectByUserObject(ifStep));
                    }
                }
            }
        }
    } catch (Throwable e) {
        ConvertigoPlugin.logException(e, "Unable to change step to jIf step!");
    } finally {
        shell.setCursor(null);
        waitCursor.dispose();
    }
}
Also used : StepEvent(com.twinsoft.convertigo.beans.core.StepEvent) 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) TreeParent(com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeParent) StepWithExpressions(com.twinsoft.convertigo.beans.core.StepWithExpressions) ThenStep(com.twinsoft.convertigo.beans.steps.ThenStep) Step(com.twinsoft.convertigo.beans.core.Step) IfStep(com.twinsoft.convertigo.beans.steps.IfStep) IfThenElseStep(com.twinsoft.convertigo.beans.steps.IfThenElseStep) Sequence(com.twinsoft.convertigo.beans.core.Sequence) Cursor(org.eclipse.swt.graphics.Cursor) ThenStep(com.twinsoft.convertigo.beans.steps.ThenStep) Shell(org.eclipse.swt.widgets.Shell) IfThenElseStep(com.twinsoft.convertigo.beans.steps.IfThenElseStep) TreePath(com.twinsoft.convertigo.eclipse.views.projectexplorer.TreePath) 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) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) 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) StepTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.StepTreeObject) Display(org.eclipse.swt.widgets.Display) IfStep(com.twinsoft.convertigo.beans.steps.IfStep)

Example 48 with DatabaseObjectTreeObject

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

the class ChangeToIfThenElseStepAction 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) {
            TreeObject treeObject = explorerView.getFirstSelectedTreeObject();
            Object databaseObject = treeObject.getObject();
            if ((databaseObject != null) && (databaseObject instanceof IfStep)) {
                IfStep ifStep = (IfStep) databaseObject;
                List<Step> list = ifStep.getSteps();
                TreePath[] selectedPaths = new TreePath[list.size()];
                for (int i = 0; i < list.size(); i++) {
                    StepTreeObject stepTreeObject = (StepTreeObject) explorerView.findTreeObjectByUserObject(list.get(i));
                    selectedPaths[i] = new TreePath(stepTreeObject);
                }
                TreeParent treeParent = treeObject.getParent();
                DatabaseObjectTreeObject parentTreeObject = null;
                if (treeParent instanceof DatabaseObjectTreeObject)
                    parentTreeObject = (DatabaseObjectTreeObject) treeParent;
                else
                    parentTreeObject = (DatabaseObjectTreeObject) treeParent.getParent();
                if (parentTreeObject != null) {
                    // New IfThenElseStep step
                    IfThenElseStep ifThenElseStep = new IfThenElseStep(ifStep.getCondition());
                    ifThenElseStep.bNew = true;
                    ifThenElseStep.hasChanged = true;
                    // Add new IfThenElseStep step to parent
                    DatabaseObject parentDbo = ifStep.getParent();
                    parentDbo.add(ifThenElseStep);
                    // Set correct order
                    if (parentDbo instanceof StepWithExpressions)
                        ((StepWithExpressions) parentDbo).insertAtOrder(ifThenElseStep, ifStep.priority);
                    else if (parentDbo instanceof Sequence)
                        ((Sequence) parentDbo).insertAtOrder(ifThenElseStep, ifStep.priority);
                    // Add Then/Else steps
                    ThenStep thenStep = new ThenStep();
                    thenStep.bNew = true;
                    ifThenElseStep.addStep(thenStep);
                    ElseStep elseStep = new ElseStep();
                    elseStep.bNew = true;
                    ifThenElseStep.addStep(elseStep);
                    // Add new IfThenElseStep step in Tree
                    StepTreeObject stepTreeObject = new StepTreeObject(explorerView.viewer, ifThenElseStep);
                    treeParent.addChild(stepTreeObject);
                    StepTreeObject thenTreeObject = new StepTreeObject(explorerView.viewer, thenStep);
                    stepTreeObject.addChild(thenTreeObject);
                    StepTreeObject elseTreeObject = new StepTreeObject(explorerView.viewer, elseStep);
                    stepTreeObject.addChild(elseTreeObject);
                    // Cut/Paste steps under Then step
                    if (selectedPaths.length > 0) {
                        new ClipboardAction(ConvertigoPlugin.clipboardManagerDND).cut(explorerView, selectedPaths, ProjectExplorerView.TREE_OBJECT_TYPE_DBO_STEP);
                        for (int i = 0; i < ConvertigoPlugin.clipboardManagerDND.objects.length; i++) {
                            ConvertigoPlugin.clipboardManagerDND.cutAndPaste(ConvertigoPlugin.clipboardManagerDND.objects[i], thenTreeObject);
                        }
                        ConvertigoPlugin.clipboardManagerDND.reset();
                    }
                    // Delete If step
                    long oldPriority = ifStep.priority;
                    ifStep.delete();
                    // Simulate move of If to IfThenElse
                    ifThenElseStep.getSequence().fireStepMoved(new StepEvent(ifThenElseStep, String.valueOf(oldPriority)));
                    parentTreeObject.hasBeenModified(true);
                    explorerView.reloadTreeObject(parentTreeObject);
                    explorerView.setSelectedTreeObject(explorerView.findTreeObjectByUserObject(ifThenElseStep));
                }
            }
        }
    } catch (Throwable e) {
        ConvertigoPlugin.logException(e, "Unable to change step to jIfThenElse step!");
    } finally {
        shell.setCursor(null);
        waitCursor.dispose();
    }
}
Also used : DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) IfThenElseStep(com.twinsoft.convertigo.beans.steps.IfThenElseStep) ElseStep(com.twinsoft.convertigo.beans.steps.ElseStep) StepTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.StepTreeObject) TreeParent(com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeParent) StepWithExpressions(com.twinsoft.convertigo.beans.core.StepWithExpressions) ThenStep(com.twinsoft.convertigo.beans.steps.ThenStep) Step(com.twinsoft.convertigo.beans.core.Step) IfStep(com.twinsoft.convertigo.beans.steps.IfStep) IfThenElseStep(com.twinsoft.convertigo.beans.steps.IfThenElseStep) ElseStep(com.twinsoft.convertigo.beans.steps.ElseStep) Cursor(org.eclipse.swt.graphics.Cursor) ThenStep(com.twinsoft.convertigo.beans.steps.ThenStep) Shell(org.eclipse.swt.widgets.Shell) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) StepEvent(com.twinsoft.convertigo.beans.core.StepEvent) ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) Sequence(com.twinsoft.convertigo.beans.core.Sequence) IfThenElseStep(com.twinsoft.convertigo.beans.steps.IfThenElseStep) TreePath(com.twinsoft.convertigo.eclipse.views.projectexplorer.TreePath) 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) 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) StepTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.StepTreeObject) Display(org.eclipse.swt.widgets.Display) IfStep(com.twinsoft.convertigo.beans.steps.IfStep)

Example 49 with DatabaseObjectTreeObject

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

the class ChangeToIfXpathExistsStatementAction 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();
            if ((databaseObject != null) && (databaseObject instanceof IfXpathExistsThenElseStatement)) {
                IfXpathExistsThenElseStatement ifThenElseStatement = (IfXpathExistsThenElseStatement) databaseObject;
                // IfXpathExistsThenElse statement
                if (ifThenElseStatement.hasThenElseStatements()) {
                    DatabaseObjectTreeObject parentTreeObject = treeObject.getOwnerDatabaseObjectTreeObject();
                    if (parentTreeObject != null) {
                        // New IfXpathExistsStatement statement
                        IfXpathExistsStatement ifStatement = new IfXpathExistsStatement();
                        ifStatement.bNew = true;
                        ifStatement.hasChanged = true;
                        // Add new If statement to parent
                        StatementWithExpressions parentDbo = (StatementWithExpressions) ifThenElseStatement.getParent();
                        parentDbo.addStatementAfter(ifStatement, ifThenElseStatement);
                        for (Statement statement : ifThenElseStatement.getThenStatement().getStatements()) {
                            ifStatement.addStatement(statement);
                        }
                        // Set properties
                        ifStatement.setCondition(ifThenElseStatement.getCondition());
                        ifStatement.setComment(ifThenElseStatement.getComment());
                        ifStatement.setEnabled(ifThenElseStatement.isEnabled());
                        ifStatement.setVersion(ifThenElseStatement.getVersion());
                        String name = ifThenElseStatement.getName();
                        // Delete IfThenElse statement
                        ifThenElseStatement.delete();
                        ifStatement.setName(name);
                        parentTreeObject.hasBeenModified(true);
                        explorerView.reloadTreeObject(parentTreeObject);
                        explorerView.setSelectedTreeObject(parentTreeObject.findTreeObjectByUserObject(ifStatement));
                    }
                }
            }
        }
    } catch (Throwable e) {
        ConvertigoPlugin.logException(e, "Unable to change statement to If statement!");
    } 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) StatementWithExpressions(com.twinsoft.convertigo.beans.core.StatementWithExpressions) IfXpathExistsThenElseStatement(com.twinsoft.convertigo.beans.statements.IfXpathExistsThenElseStatement) Statement(com.twinsoft.convertigo.beans.core.Statement) IfXpathExistsStatement(com.twinsoft.convertigo.beans.statements.IfXpathExistsStatement) IfXpathExistsThenElseStatement(com.twinsoft.convertigo.beans.statements.IfXpathExistsThenElseStatement) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) Cursor(org.eclipse.swt.graphics.Cursor) IfXpathExistsStatement(com.twinsoft.convertigo.beans.statements.IfXpathExistsStatement) Display(org.eclipse.swt.widgets.Display)

Example 50 with DatabaseObjectTreeObject

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

the class ChangeToIfXpathExistsThenElseStatementAction 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();
            // IfXpathExists
            if ((databaseObject != null) && (databaseObject instanceof IfXpathExistsStatement)) {
                IfXpathExistsStatement ifStatement = (IfXpathExistsStatement) databaseObject;
                DatabaseObjectTreeObject parentTreeObject = treeObject.getOwnerDatabaseObjectTreeObject();
                if (parentTreeObject != null) {
                    // New IfXpathExistsThenElseStatement statement
                    IfXpathExistsThenElseStatement ifThenElseStatement = new IfXpathExistsThenElseStatement();
                    ifThenElseStatement.bNew = true;
                    ifThenElseStatement.hasChanged = true;
                    // Add new IfThenElseStatement statement to parent
                    StatementWithExpressions parentDbo = (StatementWithExpressions) ifStatement.getParent();
                    parentDbo.addStatementAfter(ifThenElseStatement, ifStatement);
                    // Add Then/Else statement
                    ThenStatement thenStatement = new ThenStatement();
                    thenStatement.bNew = true;
                    ifThenElseStatement.addStatement(thenStatement);
                    ElseStatement elseStatement = new ElseStatement();
                    elseStatement.bNew = true;
                    ifThenElseStatement.addStatement(elseStatement);
                    for (Statement statement : ifStatement.getStatements()) {
                        thenStatement.addStatement(statement);
                    }
                    String name = ifStatement.getName();
                    // Set properties
                    ifThenElseStatement.setCondition(ifStatement.getCondition());
                    ifThenElseStatement.setComment(ifStatement.getComment());
                    ifThenElseStatement.setEnabled(ifStatement.isEnabled());
                    ifThenElseStatement.setVersion(ifStatement.getVersion());
                    // Delete If statement
                    ifStatement.delete();
                    ifThenElseStatement.setName(name);
                    parentTreeObject.hasBeenModified(true);
                    explorerView.reloadTreeObject(parentTreeObject);
                    explorerView.setSelectedTreeObject(parentTreeObject.findTreeObjectByUserObject(ifThenElseStatement));
                }
            }
        }
    } catch (Throwable e) {
        ConvertigoPlugin.logException(e, "Unable to change statement to IfThenElse 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) ElseStatement(com.twinsoft.convertigo.beans.statements.ElseStatement) IfXpathExistsThenElseStatement(com.twinsoft.convertigo.beans.statements.IfXpathExistsThenElseStatement) ThenStatement(com.twinsoft.convertigo.beans.statements.ThenStatement) Statement(com.twinsoft.convertigo.beans.core.Statement) IfXpathExistsStatement(com.twinsoft.convertigo.beans.statements.IfXpathExistsStatement) IfXpathExistsThenElseStatement(com.twinsoft.convertigo.beans.statements.IfXpathExistsThenElseStatement) ThenStatement(com.twinsoft.convertigo.beans.statements.ThenStatement) Cursor(org.eclipse.swt.graphics.Cursor) Shell(org.eclipse.swt.widgets.Shell) StatementWithExpressions(com.twinsoft.convertigo.beans.core.StatementWithExpressions) ElseStatement(com.twinsoft.convertigo.beans.statements.ElseStatement) IfXpathExistsThenElseStatement(com.twinsoft.convertigo.beans.statements.IfXpathExistsThenElseStatement) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) IfXpathExistsStatement(com.twinsoft.convertigo.beans.statements.IfXpathExistsStatement) Display(org.eclipse.swt.widgets.Display)

Aggregations

DatabaseObjectTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject)119 TreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject)93 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)81 Shell (org.eclipse.swt.widgets.Shell)67 ProjectExplorerView (com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView)66 Cursor (org.eclipse.swt.graphics.Cursor)64 Display (org.eclipse.swt.widgets.Display)64 TreeParent (com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeParent)37 StepTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.StepTreeObject)31 EngineException (com.twinsoft.convertigo.engine.EngineException)28 Sequence (com.twinsoft.convertigo.beans.core.Sequence)26 ObjectsFolderTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ObjectsFolderTreeObject)23 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)21 StepWithExpressions (com.twinsoft.convertigo.beans.core.StepWithExpressions)20 PropertyTableRowTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableRowTreeObject)20 Step (com.twinsoft.convertigo.beans.core.Step)19 TreeObjectEvent (com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeObjectEvent)18 PropertyTableTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableTreeObject)18 IPropertyTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IPropertyTreeObject)17 ProjectTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ProjectTreeObject)17