use of com.twinsoft.convertigo.eclipse.editors.CompositeEvent in project convertigo by convertigo.
the class JavelinConnectorComposite method fireHandlerChanged.
private void fireHandlerChanged(String newScreenClassHandler) {
JavelinTransaction transaction = (JavelinTransaction) connector.getLearningTransaction();
transaction.handlers += handlers;
transaction.hasChanged = true;
ConvertigoPlugin.logDebug2("(JavelinConnectorComposite) added new handler to transaction '" + transaction.getName() + "'");
fireObjectChanged(new CompositeEvent(transaction, newScreenClassHandler));
}
use of com.twinsoft.convertigo.eclipse.editors.CompositeEvent in project convertigo by convertigo.
the class UpdateXSDTypesAction method run.
public void run() {
final 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();
ProjectTreeObject projectTreeObject = treeObject.getProjectTreeObject();
MessageBox messageBox = new MessageBox(shell, SWT.YES | SWT.NO | SWT.CANCEL | SWT.ICON_QUESTION | SWT.APPLICATION_MODAL);
String message = "Do you really want to extract the schema?\nWarning: the previous one will be replaced.";
messageBox.setMessage(message);
if (messageBox.open() == SWT.YES) {
RequestableObject requestable = (RequestableObject) treeObject.getObject();
String requestableName = StringUtils.normalize(requestable.getName(), true);
Document document = null;
String result = null;
if (!(requestableName.equals(requestable.getName()))) {
throw new Exception("Requestable name should be normalized");
}
if (requestable instanceof Transaction) {
Connector connector = (Connector) requestable.getParent();
String connectorName = StringUtils.normalize(connector.getName(), true);
if (!(connectorName.equals(connector.getName()))) {
throw new Exception("Connector name should be normalized");
}
if (connector.getDefaultTransaction() == null) {
throw new Exception("Connector must have a default transaction");
}
if (requestable instanceof HtmlTransaction) {
if (extract) {
ConnectorEditor connectorEditor = projectTreeObject.getConnectorEditor(connector);
if (connectorEditor == null) {
ConvertigoPlugin.infoMessageBox("Please open connector first.");
return;
}
document = connectorEditor.getLastGeneratedDocument();
if (document == null) {
ConvertigoPlugin.infoMessageBox("You should first generate the document data before trying to extract the XSD types.");
return;
}
result = requestable.generateXsdTypes(document, extract);
} else {
HtmlTransaction defaultTransaction = (HtmlTransaction) connector.getDefaultTransaction();
String defaultTransactionName = StringUtils.normalize(defaultTransaction.getName(), true);
if (!(defaultTransactionName.equals(defaultTransaction.getName()))) {
throw new Exception("Default transaction name should be normalized");
}
String defaultXsdTypes = defaultTransaction.generateXsdTypes(null, false);
if (requestable.equals(defaultTransaction))
result = defaultXsdTypes;
else {
TransactionXSDTypesDialog dlg = new TransactionXSDTypesDialog(shell, requestable);
if (dlg.open() == Window.OK) {
result = dlg.result;
result += defaultXsdTypes;
}
}
}
} else {
if (extract) {
ConnectorEditor connectorEditor = projectTreeObject.getConnectorEditor(connector);
if (connectorEditor == null) {
ConvertigoPlugin.infoMessageBox("Please open connector first.");
return;
}
document = connectorEditor.getLastGeneratedDocument();
if (document == null) {
ConvertigoPlugin.infoMessageBox("You should first generate the document data before trying to extract the XSD types.");
return;
}
String prefix = requestable.getXsdTypePrefix();
document.getDocumentElement().setAttribute("transaction", prefix + requestableName);
}
if (requestable instanceof XmlHttpTransaction) {
XmlHttpTransaction xmlHttpTransaction = (XmlHttpTransaction) requestable;
XmlQName xmlQName = xmlHttpTransaction.getXmlElementRefAffectation();
String reqn = xmlHttpTransaction.getResponseElementQName();
if (extract && ((!xmlQName.isEmpty()) || (!reqn.equals("")))) {
if (!xmlQName.isEmpty()) {
ConvertigoPlugin.infoMessageBox("You should first unset 'Assigned element QName' property.");
return;
}
if (!reqn.equals("")) {
ConvertigoPlugin.infoMessageBox("You should first unset 'Schema of XML response root element' property.");
return;
}
}
}
result = requestable.generateXsdTypes(document, extract);
}
}
if ((result != null) && (!result.equals(""))) {
String xsdTypes = result;
if (requestable instanceof Transaction) {
if (requestable instanceof XmlHttpTransaction) {
XmlHttpTransaction xmlHttpTransaction = (XmlHttpTransaction) requestable;
XmlQName xmlQName = xmlHttpTransaction.getXmlElementRefAffectation();
String reqn = xmlHttpTransaction.getResponseElementQName();
if (!extract && ((!xmlQName.isEmpty()) || (!reqn.equals("")))) {
// ignore
;
} else
((Transaction) requestable).writeSchemaToFile(xsdTypes);
} else
((Transaction) requestable).writeSchemaToFile(xsdTypes);
}
requestable.hasChanged = true;
Engine.theApp.schemaManager.clearCache(requestable.getProject().getName());
explorerView.refreshFirstSelectedTreeObject();
explorerView.objectSelected(new CompositeEvent(requestable));
}
}
}
} catch (Throwable e) {
ConvertigoPlugin.logException(e, "Unable to update schema!");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
use of com.twinsoft.convertigo.eclipse.editors.CompositeEvent in project convertigo by convertigo.
the class ProjectImportWsReference 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 = null;
RemoteFileReference reference = null;
HttpConnector httpConnector = null;
// Create a new WS reference
if (treeObject instanceof ProjectTreeObject) {
projectTreeObject = (ProjectTreeObject) treeObject;
if (wsType == TYPE_SOAP) {
reference = new WebServiceReference();
reference.bNew = true;
}
if (wsType == TYPE_REST) {
reference = new RestServiceReference();
reference.bNew = true;
}
} else // Update an existing WS reference
if (treeObject instanceof ReferenceTreeObject) {
/* For further use
ReferenceTreeObject referenceTreeObject = (ReferenceTreeObject)treeObject;
webServiceReference = (WebServiceReference) referenceTreeObject.getObject();
projectTreeObject = referenceTreeObject.getProjectTreeObject();*/
}
if (reference != null) {
WsReferenceImportDialog wsReferenceImportDialog = null;
if (wsType == TYPE_SOAP) {
wsReferenceImportDialog = new WsReferenceImportDialog(shell, WsSoapReferenceImportDialogComposite.class, "SOAP Web Service reference");
}
if (wsType == TYPE_REST) {
wsReferenceImportDialog = new WsReferenceImportDialog(shell, WsRestReferenceImportDialogComposite.class, "REST Web Service reference");
}
wsReferenceImportDialog.setProject(projectTreeObject.getObject());
wsReferenceImportDialog.setReference(reference);
wsReferenceImportDialog.open();
if (wsReferenceImportDialog.getReturnCode() != Window.CANCEL) {
httpConnector = wsReferenceImportDialog.getHttpConnector();
}
Project project = projectTreeObject.getObject();
Engine.theApp.schemaManager.clearCache(project.getName());
// Reload project in tree
explorerView.reloadTreeObject(projectTreeObject);
if (httpConnector != null && httpConnector.getParent() != null) {
explorerView.objectSelected(new CompositeEvent(httpConnector));
} else if (reference != null && reference.getParent() != null) {
if (reference.hasChanged)
projectTreeObject.hasBeenModified(true);
explorerView.objectSelected(new CompositeEvent(reference));
}
}
}
}
} catch (Throwable e) {
ConvertigoPlugin.logException(e, "Unable to " + (updateMode ? "update" : "import") + " from remote WS definition!");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
use of com.twinsoft.convertigo.eclipse.editors.CompositeEvent in project convertigo by convertigo.
the class SequenceImportFromXmlAction 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 databaseObjectTreeObject = (DatabaseObjectTreeObject) explorerView.getFirstSelectedTreeObject();
DatabaseObject databaseObject = databaseObjectTreeObject.getObject();
SequenceTreeObject sequenceTreeObject = (SequenceTreeObject) ((databaseObject instanceof Sequence) ? databaseObjectTreeObject : databaseObjectTreeObject.getParentDatabaseObjectTreeObject());
Sequence sequence = (databaseObject instanceof Sequence) ? (Sequence) databaseObject : ((StepWithExpressions) databaseObject).getSequence();
// Open a file dialog to search a XML file
FileDialog fileDialog = new FileDialog(shell, SWT.PRIMARY_MODAL | SWT.SAVE);
fileDialog.setText("Import XML file");
fileDialog.setFilterExtensions(new String[] { "*.xml" });
fileDialog.setFilterNames(new String[] { "XML" });
fileDialog.setFilterPath(Engine.PROJECTS_PATH);
String filePath = fileDialog.open();
if (filePath != null) {
// Get XML content from the file
File xmlFile = new File(filePath);
Charset charset = XMLUtils.getEncoding(xmlFile);
String xmlContent = FileUtils.readFileToString(xmlFile, charset.name());
// Open and add XML content to the dialog area
XmlStructureDialog dlg = new XmlStructureDialog(shell, sequence, xmlContent);
if (dlg.open() == Window.OK) {
if (dlg.result instanceof Throwable) {
throw (Throwable) dlg.result;
} else {
Step step = (Step) dlg.result;
if (step != null) {
if (databaseObject instanceof Sequence) {
sequence.addStep(step);
} else {
StepWithExpressions swe = (StepWithExpressions) databaseObject;
swe.addStep(step);
}
sequence.hasChanged = true;
// Reload sequence in tree without updating its schema for faster reload
ConvertigoPlugin.logDebug("Reload sequence: start");
explorerView.reloadTreeObject(sequenceTreeObject);
ConvertigoPlugin.logDebug("Reload sequence: end");
// Select target dbo in tree
explorerView.objectSelected(new CompositeEvent(databaseObject));
}
}
}
}
}
} catch (Throwable e) {
ConvertigoPlugin.logException(e, "Unable to import step from xml!");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
use of com.twinsoft.convertigo.eclipse.editors.CompositeEvent in project convertigo by convertigo.
the class DatabaseObjectCreateAction method postCreate.
public void postCreate(TreeObject parentTreeObject, DatabaseObject createdDatabaseObject) throws Exception {
ProjectExplorerView explorerView = getProjectExplorerView();
explorerView.reloadTreeObject(parentTreeObject);
explorerView.objectSelected(new CompositeEvent(createdDatabaseObject));
/* No more needed since #20 correction : see DatabaseObjectTreeObject:setParent(TreeParent parent)
TreeObject selectedTreeObject = explorerView.getFirstSelectedTreeObject();
if ((selectedTreeObject != null) && (selectedTreeObject.getObject().equals(createdDatabaseObject)))
explorerView.fireTreeObjectAdded(new TreeObjectEvent(selectedTreeObject));*/
}
Aggregations