use of com.twinsoft.convertigo.eclipse.editors.CompositeEvent 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();
}
}
use of com.twinsoft.convertigo.eclipse.editors.CompositeEvent in project convertigo by convertigo.
the class VariableGenerateFromXmlAndLinkAction 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();
Object databaseObject = treeObject.getObject();
if ((databaseObject != null) && ((databaseObject instanceof StepVariable))) {
StepVariable stepVariable = (StepVariable) databaseObject;
RequestableStep requestableStep = (RequestableStep) stepVariable.getParent();
if (requestableStep != null) {
DatabaseObjectTreeObject parentDboTreeObject = ((DatabaseObjectTreeObject) treeObject).getParentDatabaseObjectTreeObject().getParentDatabaseObjectTreeObject();
RequestableObject requestableObject = null;
if (requestableStep instanceof SequenceStep) {
requestableObject = ((SequenceStep) requestableStep).getTargetSequence();
} else if (requestableStep instanceof TransactionStep) {
requestableObject = ((TransactionStep) requestableStep).getTargetTransaction();
}
if ((requestableObject != null) && (requestableObject instanceof IVariableContainer)) {
String variableName = stepVariable.getName();
IVariableContainer container = (IVariableContainer) requestableObject;
RequestableVariable variable = (RequestableVariable) container.getVariable(variableName);
// generate dom model
Document document = null;
try {
String description = variable.getDescription();
document = XMLUtils.parseDOMFromString(description);
} catch (Exception e) {
}
if (document != null) {
Element root = document.getDocumentElement();
if (root != null) {
// create step's structure from dom
DatabaseObject parentObject = requestableStep.getParent();
Step step = StepUtils.createStepFromXmlDomModel(parentObject, root);
// add step's structure to parent of requestableStep
if (parentObject instanceof Sequence) {
Sequence parentSequence = (Sequence) parentObject;
parentSequence.addStep(step);
parentSequence.insertAtOrder(step, requestableStep.priority);
} else {
StepWithExpressions parentSwe = (StepWithExpressions) parentObject;
parentSwe.addStep(step);
parentSwe.insertAtOrder(step, requestableStep.priority);
}
// set source definition of variable
XMLVector<String> sourceDefinition = new XMLVector<String>();
sourceDefinition.add(String.valueOf(step.priority));
sourceDefinition.add(".");
stepVariable.setSourceDefinition(sourceDefinition);
stepVariable.hasChanged = true;
// Reload parent dbo in tree
explorerView.reloadTreeObject(parentDboTreeObject);
// Select variable dbo in tree
explorerView.objectSelected(new CompositeEvent(databaseObject));
}
}
}
}
}
}
} catch (Throwable e) {
ConvertigoPlugin.logException(e, "Unable to generate and link variable!");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
use of com.twinsoft.convertigo.eclipse.editors.CompositeEvent in project convertigo by convertigo.
the class MobileComponentCreateAction 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));*/
}
use of com.twinsoft.convertigo.eclipse.editors.CompositeEvent in project convertigo by convertigo.
the class SequenceImportFromXsdAction 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();
FileDialog fileDialog = new FileDialog(shell, SWT.PRIMARY_MODAL | SWT.SAVE);
fileDialog.setText("Import schema file");
fileDialog.setFilterExtensions(new String[] { "*.xsd" });
fileDialog.setFilterNames(new String[] { "Schema files" });
fileDialog.setFilterPath(Engine.PROJECTS_PATH);
String filePath = fileDialog.open();
if (filePath != null) {
filePath = filePath.replaceAll("\\\\", "/");
XmlSchemaCollection collection = new XmlSchemaCollection();
collection.setBaseUri(filePath);
XmlSchema xmlSchema = SchemaUtils.loadSchema(new File(filePath), collection);
SchemaMeta.setCollection(xmlSchema, collection);
SchemaObjectsDialog dlg = new SchemaObjectsDialog(shell, sequence, xmlSchema);
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);
sequence.hasChanged = true;
} else {
StepWithExpressions swe = (StepWithExpressions) databaseObject;
swe.addStep(step);
swe.hasChanged = true;
}
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 xsd!");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
use of com.twinsoft.convertigo.eclipse.editors.CompositeEvent in project convertigo by convertigo.
the class DatabaseObjectFindDialog method findDatabaseObject.
protected void findDatabaseObject() {
Pattern pattern = null;
String substring = "";
try {
pattern = bRegExp ? (bMatchCase ? Pattern.compile(objectTextSubstring) : Pattern.compile(objectTextSubstring, Pattern.CASE_INSENSITIVE)) : null;
} catch (Exception pex) {
ConvertigoPlugin.errorMessageBox(pex.getClass().getName() + ":\n" + pex.getMessage());
return;
}
substring = bMatchCase ? objectTextSubstring : objectTextSubstring.toLowerCase();
while (true) {
Enumeration<DatabaseObjectTreeObject> enumDatabaseObjects = Collections.enumeration(vDatabaseObjects);
while (enumDatabaseObjects.hasMoreElements()) {
DatabaseObjectTreeObject databaseObjectTreeObject = (DatabaseObjectTreeObject) enumDatabaseObjects.nextElement();
DatabaseObject databaseObject = databaseObjectTreeObject.getObject();
boolean bContinue = false;
switch(objectType) {
case // *
0:
bContinue = true;
break;
case // Mobile Component
1:
bContinue = databaseObject.getDatabaseType().equals("MobileComponent");
break;
case // Screen class
2:
bContinue = databaseObject.getDatabaseType().equals("ScreenClass");
break;
case // Criteria
3:
bContinue = databaseObject.getDatabaseType().equals("Criteria");
break;
case // Extraction rule
4:
bContinue = databaseObject.getDatabaseType().equals("ExtractionRule");
break;
case // Sheet
5:
bContinue = databaseObject.getDatabaseType().equals("Sheet");
break;
case // Transaction
6:
bContinue = databaseObject.getDatabaseType().equals("Transaction");
break;
case // Statement
7:
bContinue = databaseObject.getDatabaseType().equals("Statement");
break;
case // Sequence
8:
bContinue = databaseObject.getDatabaseType().equals("Sequence");
break;
case // Step
9:
bContinue = databaseObject.getDatabaseType().equals("Step");
break;
}
if (bContinue) {
String text = databaseObjectTreeObject.toString();
try {
text = YamlConverter.toYaml(databaseObject.toXml(XMLUtils.createDom()));
} catch (Exception e) {
e.printStackTrace();
}
boolean bFound = false;
if (bRegExp) {
Matcher matcher = pattern.matcher(text);
bFound = matcher.find();
} else {
text = bMatchCase ? text : text.toLowerCase();
bFound = text.indexOf(substring) != -1;
}
if (bFound) {
// Object found !!!
// System.out.println(text);
ConvertigoPlugin.getDefault().getProjectExplorerView().objectSelected(new CompositeEvent(databaseObject));
vDatabaseObjects.remove(databaseObjectTreeObject);
return;
}
}
}
TreeObject treeSelected = firstSelected == null ? ConvertigoPlugin.projectManager.currentProjectTreeObject : firstSelected;
MessageBox messageBox = new MessageBox(getShell(), SWT.YES | SWT.NO | SWT.ICON_QUESTION | SWT.APPLICATION_MODAL);
String message = "End of the search for " + treeSelected.toString() + " object.\nDo you want to retry the search from the beginning?";
messageBox.setMessage(message);
int ret = messageBox.open();
if (ret == SWT.YES) {
ConvertigoPlugin.getDefault().getProjectExplorerView().setSelectedTreeObject(treeSelected);
vDatabaseObjects.clear();
getDatabaseObjects(null);
} else {
return;
}
}
}
Aggregations