use of com.twinsoft.convertigo.beans.core.Statement in project convertigo by convertigo.
the class HtmlTransaction method addStatement.
public void addStatement(Statement statement) throws EngineException {
checkSubLoaded();
// Do not use getChildBeanName here because of ScHandlerStatement!!
String newDatabaseObjectName = statement.getName();
for (Statement st : vStatements) {
if (newDatabaseObjectName.equals(st.getName())) {
throw new ObjectWithSameNameException("Unable to add the statement \"" + newDatabaseObjectName + "\" to the html transaction class because a statement with the same name already exists.");
}
}
vStatements.add(statement);
// do not call super.add otherwise it will generate an exception
statement.setParent(this);
if (statement.priority != 0) {
statement.priority = 0;
statement.hasChanged = true;
}
}
use of com.twinsoft.convertigo.beans.core.Statement 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();
}
}
use of com.twinsoft.convertigo.beans.core.Statement 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();
}
}
use of com.twinsoft.convertigo.beans.core.Statement 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();
}
}
use of com.twinsoft.convertigo.beans.core.Statement 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();
}
}
Aggregations