use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TransactionTreeObject in project convertigo by convertigo.
the class TransactionCreateHandlerAction method selectionChanged.
@Override
public void selectionChanged(IAction action, ISelection selection) {
try {
boolean enable = false;
super.selectionChanged(action, selection);
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
TreeObject treeObject = (TreeObject) structuredSelection.getFirstElement();
if (treeObject instanceof TransactionTreeObject)
enable = true;
else if (treeObject instanceof ObjectsFolderTreeObject)
enable = ((ObjectsFolderTreeObject) treeObject).folderType == ObjectsFolderTreeObject.FOLDER_TYPE_FUNCTIONS;
action.setEnabled(enable);
} catch (Exception e) {
}
}
use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TransactionTreeObject in project convertigo by convertigo.
the class CreateFormFromTransactionAction 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) {
Transaction transaction = null;
Connector connector = null;
TreeObject treeObject = explorerView.getFirstSelectedTreeObject();
if (treeObject instanceof TransactionTreeObject) {
transaction = (Transaction) treeObject.getObject();
connector = (Connector) transaction.getParent();
if (transaction instanceof TransactionWithVariables) {
TransactionWithVariables tr = (TransactionWithVariables) transaction;
// if (tr.getVariablesDefinitionSize() == 0) {
if (tr.numberOfVariables() == 0) {
MessageBox messageBox = new MessageBox(shell, SWT.YES | SWT.APPLICATION_MODAL);
messageBox.setMessage("No variables are defined for transaction " + tr.getName());
messageBox.open();
} else {
String xslContent = generateXSLForm(connector, tr);
// Refresh project resource
IProject project = ConvertigoPlugin.getDefault().getProjectPluginResource(tr.getProject().getName());
// Compute the targetXSL file name
String xslForm = tr.getName() + "Request.xsl";
IFile file = project.getFile(xslForm);
ByteArrayInputStream bais = new ByteArrayInputStream(xslContent.getBytes());
if (file.exists()) {
file.setContents((InputStream) bais, IFile.FORCE | IFile.KEEP_HISTORY, null);
} else {
file.create((InputStream) bais, true, null);
}
TransactionWithVariables newTrans = (TransactionWithVariables) tr.clone();
newTrans.hasChanged = true;
newTrans.bNew = true;
XMLVector<XMLVector<Long>> orderedVariables = new XMLVector<XMLVector<Long>>();
orderedVariables.add(new XMLVector<Long>());
newTrans.setOrderedVariables(orderedVariables);
newTrans.setSheetLocation(Transaction.SHEET_LOCATION_FROM_REQUESTABLE);
HandlerStatement handler = new HandlerStatement(HandlerStatement.EVENT_TRANSACTION_STARTED, HandlerStatement.RETURN_CANCEL);
newTrans.add(handler);
newTrans.setName(tr.getName() + "Request");
Sheet sheet = new Sheet();
sheet.setBrowser("*");
sheet.setUrl(xslForm);
newTrans.addSheet(sheet);
connector.add(newTrans);
postCreate(treeObject.getConnectorTreeObject(), newTrans);
}
}
}
}
} catch (Throwable e) {
ConvertigoPlugin.logException(e, "Unable to generate a requestForm widget");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
Aggregations