use of com.twinsoft.convertigo.beans.core.StepWithExpressions in project convertigo by convertigo.
the class ClipboardAction method pasteStep.
private Object pasteStep(Shell shell, String source, DatabaseObject targetObject) throws ParserConfigurationException, SAXException, IOException {
// Can only paste on Sequence or Step
if (targetObject instanceof Sequence)
return targetObject;
else if (!(targetObject instanceof Step))
return null;
// cannot paste to IThenElseContainer
if (targetObject instanceof IThenElseContainer)
return null;
else {
List<Object> objects = clipboardManager.read(source);
int size = objects.size();
for (Object ob : objects) {
// Can only paste step objects
if (!(ob instanceof Step))
return null;
// Can paste only on step which may contain children
if ((ob instanceof StepWithExpressions) && (!(targetObject instanceof StepWithExpressions)))
return null;
// cannot paste a ThenStep
if (ob instanceof ThenStep)
return null;
// cannot paste a ElseStep
if (ob instanceof ElseStep)
return null;
// cannot paste a ThenStatement
if (ob instanceof ThenStatement)
return null;
// cannot paste a ElseStatement
if (ob instanceof ElseStatement)
return null;
// Special case of XMLElementStep, ElementStep
if ((targetObject instanceof XMLElementStep) || (targetObject instanceof ElementStep)) {
// Case paste on itself -> target is changed to parent
if ((size == 1) && ((ob instanceof XMLElementStep) || (ob instanceof ElementStep))) {
if (((Step) ob).getName().equals(targetObject.getName())) {
return targetObject.getParent();
}
return null;
} else // Else, only accept paste of XMLAttributeStep
if (!(ob instanceof XMLAttributeStep || ob instanceof AttributeStep)) {
return null;
}
} else // Case of step which may contain children
if (targetObject instanceof StepWithExpressions) {
// Case paste on itself -> ask user what to do
if ((size == 1) && (ob.getClass().equals(targetObject.getClass()))) {
if (((Step) ob).getName().equals(targetObject.getName())) {
CustomDialog customDialog = new CustomDialog(shell, "Paste a step", "Do you want to paste the step as a sibling or a child step?", 500, 150, new ButtonSpec("As a sibling", true), new ButtonSpec("As a child", false), new ButtonSpec(IDialogConstants.CANCEL_LABEL, false));
int response = customDialog.open();
if (response == 0) {
return targetObject.getParent();
} else if (response == 2) {
return null;
} else
break;
}
}
// Else, paste
break;
} else // Other case
{
// Case paste on itself -> target is changed to parent
if ((size == 1) && (ob.getClass().equals(targetObject.getClass()))) {
if (((Step) ob).getName().equals(targetObject.getName())) {
return targetObject.getParent();
}
return null;
}
// Else, not permitted
return null;
}
}
}
return targetObject;
}
use of com.twinsoft.convertigo.beans.core.StepWithExpressions in project convertigo by convertigo.
the class ProjectTreeObject method checkForImports.
private void checkForImports(List<String> missingList, List<Step> steps) {
String targetProjectName;
for (Step step : steps) {
if (step instanceof StepWithExpressions) {
checkForImports(missingList, ((StepWithExpressions) step).getSteps());
} else {
if (step instanceof TransactionStep) {
TransactionStep transactionStep = ((TransactionStep) step);
targetProjectName = transactionStep.getProjectName();
if (!targetProjectName.equals(getName())) {
try {
transactionStep.getSequence().getLoadedProject(targetProjectName);
} catch (EngineException e) {
if (!missingList.contains(targetProjectName))
missingList.add(targetProjectName);
}
}
} else if (step instanceof SequenceStep) {
SequenceStep sequenceStep = ((SequenceStep) step);
targetProjectName = sequenceStep.getProjectName();
if (!targetProjectName.equals(getName())) {
try {
sequenceStep.getSequence().getLoadedProject(targetProjectName);
} catch (EngineException e) {
if (!missingList.contains(targetProjectName))
missingList.add(targetProjectName);
}
}
}
}
}
}
use of com.twinsoft.convertigo.beans.core.StepWithExpressions in project convertigo by convertigo.
the class SequenceExecuteSelectedAction method openEditors.
private void openEditors(/*ProjectExplorerView explorerView, */
List<Step> steps, Set<SequenceStep> alreadyOpened) {
for (Step step : steps) {
if (step.isEnabled()) {
if (step instanceof SequenceStep) {
SequenceStep sequenceStep = (SequenceStep) step;
String projectName = sequenceStep.getProjectName();
// load project if necessary
if (!step.getSequence().getProject().getName().equals(projectName)) {
// loadProject(explorerView, projectName);
}
if (alreadyOpened.contains(sequenceStep)) {
// avoid sequence recursion
return;
}
alreadyOpened.add(sequenceStep);
try {
// ProjectTreeObject projectTreeObject = (ProjectTreeObject)explorerView.getProjectRootObject(projectName);
Project p = step.getProject();
Sequence subSequence = p.getSequenceByName(sequenceStep.getSequenceName());
SequenceView subSequenceTreeObject = (SequenceView) Studio.getViewFromDbo(subSequence, studio);
// recurse on sequence
openEditors(/*explorerView, */
subSequenceTreeObject, alreadyOpened);
} catch (EngineException e) {
}
} else if (step instanceof TransactionStep) {
TransactionStep transactionStep = (TransactionStep) step;
String projectName = transactionStep.getProjectName();
if (!step.getSequence().getProject().getName().equals(projectName)) {
// loadProject(explorerView, projectName); // load project if necessary
}
try {
// ProjectTreeObject projectTreeObject = (ProjectTreeObject)explorerView.getProjectRootObject(projectName);
Project project = Engine.theApp.databaseObjectsManager.getProjectByName(projectName);
ProjectView projectTreeObject = new ProjectView(project, studio);
Connector connector = projectTreeObject.getObject().getConnectorByName(transactionStep.getConnectorName());
ConnectorView connectorTreeObject = new ConnectorView(connector, studio);
// open connector editor
connectorTreeObject.openConnectorEditor();
} catch (EngineException e) {
}
} else if (step instanceof StepWithExpressions) {
openEditors(/*explorerView, */
((StepWithExpressions) step).getSteps(), alreadyOpened);
}
}
}
}
use of com.twinsoft.convertigo.beans.core.StepWithExpressions in project convertigo by convertigo.
the class SourcePickerHelperWrap method displayTargetWsdlDom.
public void displayTargetWsdlDom(DatabaseObject dbo) {
try {
if (dbo instanceof Step) {
Step step = (Step) dbo;
String xpath = getSourceXPath();
String anchor = step.getAnchor();
Document stepDoc = null;
Step targetStep = step;
while (targetStep instanceof IteratorStep) {
targetStep = getTargetStep(targetStep);
}
if (targetStep != null) {
Project project = step.getProject();
XmlSchema schema = Engine.theApp.schemaManager.getSchemaForProject(project.getName(), Option.fullSchema);
XmlSchemaObject xso = SchemaMeta.getXmlSchemaObject(schema, targetStep);
if (xso != null) {
stepDoc = XmlSchemaUtils.getDomInstance(xso);
}
}
if (stepDoc != null) /* && !(targetStep instanceof IteratorStep)*/
{
// stepDoc can be null for non "xml" step : e.g jIf
Document doc = step.getSequence().createDOM();
Element root = (Element) doc.importNode(stepDoc.getDocumentElement(), true);
doc.replaceChild(root, doc.getDocumentElement());
removeUserDefinedNodes(doc.getDocumentElement());
boolean shouldDisplayDom = (!(!step.isXml() && (step instanceof StepWithExpressions) && !(step instanceof IteratorStep)));
if ((doc != null) && (shouldDisplayDom)) {
xpath = onDisplayXhtml(xpath);
displayXhtml(doc);
xpathEvaluator.removeAnchor();
xpathEvaluator.displaySelectionXpathWithAnchor(twsDomTree, anchor, xpath);
return;
}
}
}
} catch (Exception e) {
// ConvertigoPlugin.logException(e, StringUtils.readStackTraceCauses(e));
}
clean();
}
use of com.twinsoft.convertigo.beans.core.StepWithExpressions in project convertigo by convertigo.
the class TreeDropAdapter method move.
private boolean move(Node node, TreeObject targetTreeObject) throws EngineException {
if (targetTreeObject instanceof DatabaseObjectTreeObject) {
DatabaseObject parent = ((DatabaseObjectTreeObject) targetTreeObject).getObject();
DatabaseObject databaseObject = paste(node, null, true);
Element element = (Element) ((Element) node).getElementsByTagName("dnd").item(0);
// SEQUENCER
if (parent instanceof Sequence || parent instanceof StepWithExpressions) {
;
} else // URLMAPPER
if (parent instanceof UrlMappingOperation) {
// Set associated requestable
if (databaseObject instanceof RequestableObject) {
String dboQName = "";
if (databaseObject instanceof Sequence) {
dboQName = ((Element) element.getElementsByTagName("project").item(0)).getAttribute("name") + "." + databaseObject.getName();
} else if (databaseObject instanceof Transaction) {
dboQName = ((Element) element.getElementsByTagName("project").item(0)).getAttribute("name") + "." + ((Element) element.getElementsByTagName("connector").item(0)).getAttribute("name") + "." + databaseObject.getName();
}
UrlMappingOperation operation = (UrlMappingOperation) parent;
operation.setTargetRequestable(dboQName);
if (operation.getComment().isEmpty()) {
operation.setComment(databaseObject.getComment());
}
operation.hasChanged = true;
return true;
}
} else if (parent instanceof UrlMappingParameter) {
// Set associated mapped variable for parameter
if (databaseObject instanceof RequestableVariable) {
RequestableVariable variable = (RequestableVariable) databaseObject;
UrlMappingParameter parameter = (UrlMappingParameter) parent;
parameter.setMappedVariableName(variable.getName());
parameter.hasChanged = true;
return true;
}
}
}
return false;
}
Aggregations