use of com.twinsoft.convertigo.beans.core.Statement in project convertigo by convertigo.
the class FunctionStatement method executeNextStatement.
@Override
public boolean executeNextStatement(Context javascriptContext, Scriptable scope) throws EngineException {
if (isEnabled()) {
if (hasStatements()) {
List<Statement> v = getStatements();
if (currentChildStatement < v.size()) {
Statement st = (Statement) v.get(currentChildStatement);
executeNextStatement(st, javascriptContext, scope);
if (bContinue)
return executeNextStatement(javascriptContext, scope);
}
}
return true;
}
return false;
}
use of com.twinsoft.convertigo.beans.core.Statement in project convertigo by convertigo.
the class BlockStatement method executeNextStatement.
public boolean executeNextStatement(Context javascriptContext, Scriptable scope) throws EngineException {
if (isEnabled()) {
if (hasStatements()) {
if (currentChildStatement < numberOfStatements()) {
Statement st = (Statement) getStatements().get(currentChildStatement);
executeNextStatement(st, javascriptContext, scope);
if (bContinue)
return executeNextStatement(javascriptContext, scope);
} else {
if (isLoop) {
currentChildStatement = 0;
if (bContinue)
return doLoop(javascriptContext, scope);
}
}
}
return true;
}
return false;
}
use of com.twinsoft.convertigo.beans.core.Statement in project convertigo by convertigo.
the class DatabaseObjectDeleteAction method delete.
private void delete(DatabaseObject databaseObject, boolean deleteProjectOnDisk) throws EngineException, CoreException {
if (databaseObject instanceof Connector) {
if (((Connector) databaseObject).isDefault) {
throw new EngineException("Cannot delete the default connector!");
}
String dirPath, projectName;
File dir;
projectName = databaseObject.getParent().getName();
MessageBox messageBox = new MessageBox(getParentShell(), SWT.ICON_QUESTION | SWT.YES | SWT.NO);
messageBox.setText("Also delete linked resources?");
// Delete soap templates for this connector
dirPath = Engine.projectDir(projectName) + "/soap-templates/" + databaseObject.getName();
dir = new File(dirPath);
if (dir.exists()) {
messageBox.setMessage("Some resources are linked to the deleted connector.\n\n" + "Do you also want to delete folder:\n\n\"" + dirPath + "\"");
if (messageBox.open() == SWT.YES) {
try {
DatabaseObjectsManager.deleteDir(dir);
} catch (IOException e) {
ConvertigoPlugin.logDebug("Unable to delete directory \"" + dirPath + "\"!");
}
}
}
// Delete directory corresponding to connector under Traces directory
dirPath = Engine.projectDir(projectName) + "/Traces/" + databaseObject.getName();
dir = new File(dirPath);
if (dir.exists()) {
messageBox.setMessage("Some resources are linked to the deleted connector.\n\n" + "Do you also want to delete folder:\n\n\"" + dirPath + "\"");
if (messageBox.open() == SWT.YES) {
try {
DatabaseObjectsManager.deleteDir(dir);
} catch (IOException e) {
ConvertigoPlugin.logDebug("Unable to delete directory \"" + dirPath + "\"!");
}
}
}
} else if (databaseObject instanceof Transaction) {
if (((Transaction) databaseObject).isDefault) {
throw new EngineException("Cannot delete the default transaction!");
}
} else if (databaseObject instanceof ScreenClass) {
if ((databaseObject.getParent()) instanceof Project) {
throw new EngineException("Cannot delete the root screen class!");
}
} else if (databaseObject instanceof Statement) {
if ((databaseObject instanceof ThenStatement) || (databaseObject instanceof ElseStatement)) {
throw new EngineException("Cannot delete this statement!");
}
} else if (databaseObject instanceof Step) {
if ((databaseObject instanceof ThenStep) || (databaseObject instanceof ElseStep)) {
throw new EngineException("Cannot delete this step!");
}
} else if (databaseObject instanceof MobilePlatform) {
MobilePlatform mobilePlatform = (MobilePlatform) databaseObject;
File resourceFolder = mobilePlatform.getResourceFolder();
if (resourceFolder.exists()) {
MessageBox messageBox = new MessageBox(getParentShell(), SWT.ICON_QUESTION | SWT.YES | SWT.NO);
messageBox.setMessage("Do you want to delete the whole resource folder \"" + mobilePlatform.getRelativeResourcePath() + "\"?");
messageBox.setText("Delete the \"" + resourceFolder.getName() + "\" folder?");
if (messageBox.open() == SWT.YES) {
FileUtils.deleteQuietly(resourceFolder);
}
}
} else if (databaseObject instanceof PageComponent) {
if (((PageComponent) databaseObject).isRoot) {
throw new EngineException("Cannot delete the root page!");
}
}
String dboQName = databaseObject.getQName();
if (databaseObject instanceof Project) {
// Engine.theApp.databaseObjectsManager.deleteProject(databaseObject.getName());
if (deleteProjectOnDisk) {
Engine.theApp.databaseObjectsManager.deleteProjectAndCar(databaseObject.getName(), DeleteProjectOption.unloadOnly);
} else {
Engine.theApp.databaseObjectsManager.deleteProject(databaseObject.getName(), DeleteProjectOption.unloadOnly);
}
ConvertigoPlugin.getDefault().deleteProjectPluginResource(deleteProjectOnDisk, databaseObject.getName());
} else {
databaseObject.delete();
}
if (databaseObject instanceof CouchDbConnector) {
CouchDbConnector couchDbConnector = (CouchDbConnector) databaseObject;
String db = couchDbConnector.getDatabaseName();
if (!db.isEmpty()) {
MessageBox messageBox = new MessageBox(getParentShell(), SWT.ICON_QUESTION | SWT.YES | SWT.NO);
messageBox.setMessage("Do you want to delete the \"" + db + "\" database from the CouchDb server?");
messageBox.setText("Delete the database?");
if (messageBox.open() == SWT.YES) {
couchDbConnector.getCouchClient().deleteDatabase(db);
}
}
}
ConvertigoPlugin.logDebug("The object \"" + dboQName + "\" has been deleted from the database repository!");
}
use of com.twinsoft.convertigo.beans.core.Statement in project convertigo by convertigo.
the class DisableStatementAction 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) {
DatabaseObjectTreeObject treeObject = null;
Statement statement = null;
TreeObject[] treeObjects = explorerView.getSelectedTreeObjects();
for (int i = treeObjects.length - 1; i >= 0; i--) {
treeObject = (DatabaseObjectTreeObject) treeObjects[i];
if (treeObject instanceof StatementTreeObject) {
StatementTreeObject statementTreeObject = (StatementTreeObject) treeObject;
statement = (Statement) statementTreeObject.getObject();
statement.setEnabled(false);
statementTreeObject.setEnabled(false);
statementTreeObject.hasBeenModified(true);
}
}
explorerView.refreshSelectedTreeObjects();
}
} catch (Throwable e) {
ConvertigoPlugin.logException(e, "Unable to disable statement!");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
use of com.twinsoft.convertigo.beans.core.Statement in project convertigo by convertigo.
the class TransactionCreateHandlerAction method run.
@Override
public void run() {
Display display = Display.getDefault();
Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
Shell shell = getParentShell();
shell.setCursor(waitCursor);
Statement lastStatement = null;
try {
ProjectExplorerView explorerView = getProjectExplorerView();
if (explorerView != null) {
TreeObject treeObject = explorerView.getFirstSelectedTreeObject();
if (treeObject != null) {
Transaction transaction = null;
if (treeObject instanceof TransactionTreeObject) {
transaction = (Transaction) treeObject.getObject();
} else if (treeObject instanceof ObjectsFolderTreeObject) {
transaction = (Transaction) treeObject.getParent().getObject();
}
if (transaction != null) {
CreateHandlerDialog createHandlerDialog = new CreateHandlerDialog(shell, transaction);
createHandlerDialog.open();
if (createHandlerDialog.getReturnCode() != Window.CANCEL) {
List<?> result = createHandlerDialog.result;
if (result != null) {
int len = result.size();
if (len > 0) {
if (transaction instanceof HtmlTransaction) {
HtmlTransaction htmlTransaction = (HtmlTransaction) transaction;
Statement statement = null;
for (int i = 0; i < len; i++) {
statement = (Statement) result.get(i);
htmlTransaction.addStatement(statement);
}
lastStatement = statement;
} else {
String handler = null;
for (int i = 0; i < len; i++) {
handler = (String) result.get(i);
transaction.handlers += handler;
transaction.hasChanged = true;
}
// Update the opened handlers editor if any
JScriptEditorInput jsinput = ConvertigoPlugin.getDefault().getJScriptEditorInput(transaction);
if (jsinput != null) {
jsinput.reload();
}
}
// Reload transaction in tree and select last created Statement.
try {
ProjectExplorerView projectExplorerView = ConvertigoPlugin.getDefault().getProjectExplorerView();
projectExplorerView.reloadDatabaseObject(transaction);
if (transaction instanceof HtmlTransaction) {
if (lastStatement != null) {
projectExplorerView.objectSelected(new CompositeEvent(lastStatement));
}
} else {
projectExplorerView.objectSelected(new CompositeEvent(transaction));
}
} catch (IOException e) {
}
}
}
}
}
}
}
} catch (Throwable e) {
ConvertigoPlugin.logException(e, "Unable to create new handler for transaction!");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
Aggregations