use of com.twinsoft.convertigo.beans.statements.ScEntryDefaultHandlerStatement 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();
}
}
}
}
use of com.twinsoft.convertigo.beans.statements.ScEntryDefaultHandlerStatement 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.statements.ScEntryDefaultHandlerStatement 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();
}
}
Aggregations