use of com.twinsoft.convertigo.beans.core.Connector 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.Connector in project convertigo by convertigo.
the class AbstractConnectorCompositeWrap method checkEventSource.
protected boolean checkEventSource(EventObject event) {
boolean isSourceFromConnector = false;
Object source = event.getSource();
if (event instanceof ConnectorEvent) {
if (source instanceof DatabaseObject) {
Connector connector = ((DatabaseObject) source).getConnector();
if ((connector != null) && (connector.equals(this.connector)))
isSourceFromConnector = true;
}
}
return isSourceFromConnector;
}
use of com.twinsoft.convertigo.beans.core.Connector in project convertigo by convertigo.
the class TestCaseExecuteSelectedAction 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) {
TreeObject treeObject = explorerView.getFirstSelectedTreeObject();
if ((treeObject != null) && (treeObject instanceof TestCaseTreeObject)) {
TestCase testCase = (TestCase) treeObject.getObject();
ProjectTreeObject projectTreeObject = treeObject.getProjectTreeObject();
RequestableObject requestable = (RequestableObject) testCase.getParent();
if (requestable instanceof Transaction) {
TransactionTreeObject transactionTreeObject = (TransactionTreeObject) treeObject.getParent().getParent();
transactionTreeObject.getConnectorTreeObject().openConnectorEditor();
Transaction transaction = (Transaction) testCase.getParent();
Connector connector = (Connector) transaction.getParent();
ConnectorEditor connectorEditor = projectTreeObject.getConnectorEditor(connector);
if (connectorEditor != null) {
getActivePage().activate(connectorEditor);
connectorEditor.getDocument(transaction.getName(), testCase.getName(), false);
}
}
if (requestable instanceof Sequence) {
SequenceTreeObject sequenceTreeObject = (SequenceTreeObject) treeObject.getParent().getParent();
new SequenceExecuteSelectedAction().openEditors(explorerView, sequenceTreeObject);
Sequence sequence = (Sequence) testCase.getParent();
SequenceEditor sequenceEditor = projectTreeObject.getSequenceEditor(sequence);
if (sequenceEditor != null) {
getActivePage().activate(sequenceEditor);
sequenceEditor.getDocument(sequence.getName(), testCase.getName(), false);
}
}
}
}
} catch (Throwable e) {
ConvertigoPlugin.logException(e, "Unable to execute the selected test case!");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
use of com.twinsoft.convertigo.beans.core.Connector in project convertigo by convertigo.
the class TransactionExecuteDefaultAction 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) {
TreeObject treeObject = explorerView.getFirstSelectedTreeObject();
if (treeObject != null) {
ProjectTreeObject projectTreeObject = treeObject.getProjectTreeObject();
Connector connector = null;
if (treeObject instanceof ConnectorTreeObject) {
ConnectorTreeObject connectorTreeObject = (ConnectorTreeObject) treeObject;
connectorTreeObject.openConnectorEditor();
connector = connectorTreeObject.getObject();
} else {
connector = ((Project) projectTreeObject.getObject()).getDefaultConnector();
ConnectorTreeObject connectorTreeObject = (ConnectorTreeObject) explorerView.findTreeObjectByUserObject(connector);
if (connectorTreeObject != null)
connectorTreeObject.openConnectorEditor();
}
Transaction transaction = connector.getDefaultTransaction();
ConnectorEditor connectorEditor = projectTreeObject.getConnectorEditor(connector);
if (connectorEditor != null) {
getActivePage().activate(connectorEditor);
connectorEditor.getDocument(transaction.getName(), false);
}
}
}
} catch (Throwable e) {
ConvertigoPlugin.logException(e, "Unable to execute the default transaction!");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
use of com.twinsoft.convertigo.beans.core.Connector in project convertigo by convertigo.
the class TransactionExecuteSelectedAction method 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();
if ((treeObject != null) && (treeObject instanceof TransactionTreeObject)) {
TransactionTreeObject transactionTreeObject = (TransactionTreeObject) treeObject;
Transaction transaction = transactionTreeObject.getObject();
transactionTreeObject.getConnectorTreeObject().openConnectorEditor();
Connector connector = (Connector) transaction.getParent();
ProjectTreeObject projectTreeObject = transactionTreeObject.getProjectTreeObject();
ConnectorEditor connectorEditor = projectTreeObject.getConnectorEditor(connector);
if (connectorEditor != null) {
getActivePage().activate(connectorEditor);
connectorEditor.getDocument(transaction.getName(), isStubRequested());
}
}
}
} catch (Throwable e) {
ConvertigoPlugin.logException(e, "Unable to execute the selected transaction!");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
Aggregations