use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject in project convertigo by convertigo.
the class ChangeToXMLAttributeStepAction method run.
/* (non-Javadoc)
* @see com.twinsoft.convertigo.eclipse.popup.actions.MyAbstractAction#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();
Object databaseObject = treeObject.getObject();
// Attribute
if ((databaseObject != null) && (databaseObject instanceof AttributeStep)) {
AttributeStep attributeStep = (AttributeStep) databaseObject;
TreeParent treeParent = treeObject.getParent();
DatabaseObjectTreeObject parentTreeObject = null;
if (treeParent instanceof DatabaseObjectTreeObject)
parentTreeObject = (DatabaseObjectTreeObject) treeParent;
else
parentTreeObject = (DatabaseObjectTreeObject) treeParent.getParent();
if (parentTreeObject != null) {
// New XMLAttribute step
XMLAttributeStep xmlAttributeStep = new XMLAttributeStep();
if (DatabaseObjectsManager.acceptDatabaseObjects(attributeStep.getParent(), xmlAttributeStep)) {
// Set properties
xmlAttributeStep.setOutput(attributeStep.isOutput());
xmlAttributeStep.setEnabled(attributeStep.isEnabled());
xmlAttributeStep.setComment(attributeStep.getComment());
// xmlAttributeStep.setSourceDefinition(xmlElementStep.getSourceDefinition());
xmlAttributeStep.setNodeText(attributeStep.getNodeText());
xmlAttributeStep.setNodeName(attributeStep.getNodeName());
xmlAttributeStep.bNew = true;
xmlAttributeStep.hasChanged = true;
// Add new XMLAttribute step to parent
DatabaseObject parentDbo = attributeStep.getParent();
parentDbo.add(xmlAttributeStep);
// Set correct order
if (parentDbo instanceof StepWithExpressions)
((StepWithExpressions) parentDbo).insertAtOrder(xmlAttributeStep, attributeStep.priority);
else if (parentDbo instanceof Sequence)
((Sequence) parentDbo).insertAtOrder(xmlAttributeStep, attributeStep.priority);
// Add new XMLAttribute step in Tree
StepTreeObject stepTreeObject = new StepTreeObject(explorerView.viewer, attributeStep);
treeParent.addChild(stepTreeObject);
// Delete XMLElement step
long oldPriority = attributeStep.priority;
attributeStep.delete();
xmlAttributeStep.getSequence().fireStepMoved(new StepEvent(xmlAttributeStep, String.valueOf(oldPriority)));
parentTreeObject.hasBeenModified(true);
explorerView.reloadTreeObject(parentTreeObject);
explorerView.setSelectedTreeObject(explorerView.findTreeObjectByUserObject(xmlAttributeStep));
} else {
throw new EngineException("You cannot paste to a " + attributeStep.getParent().getClass().getSimpleName() + " a database object of type " + xmlAttributeStep.getClass().getSimpleName());
}
}
}
// XML Element
if ((databaseObject != null) && (databaseObject instanceof XMLElementStep)) {
XMLElementStep xmlElementStep = (XMLElementStep) databaseObject;
TreeParent treeParent = treeObject.getParent();
DatabaseObjectTreeObject parentTreeObject = null;
if (treeParent instanceof DatabaseObjectTreeObject)
parentTreeObject = (DatabaseObjectTreeObject) treeParent;
else
parentTreeObject = (DatabaseObjectTreeObject) treeParent.getParent();
if (parentTreeObject != null) {
// New XMLAttribute step
XMLAttributeStep xmlAttributeStep = new XMLAttributeStep();
if (DatabaseObjectsManager.acceptDatabaseObjects(xmlElementStep.getParent(), xmlAttributeStep)) {
// Set properties
xmlAttributeStep.setOutput(xmlElementStep.isOutput());
xmlAttributeStep.setEnabled(xmlElementStep.isEnabled());
xmlAttributeStep.setComment(xmlElementStep.getComment());
xmlAttributeStep.setSourceDefinition(xmlElementStep.getSourceDefinition());
xmlAttributeStep.setNodeText(xmlElementStep.getNodeText());
xmlAttributeStep.setNodeName(xmlElementStep.getNodeName());
xmlAttributeStep.bNew = true;
xmlAttributeStep.hasChanged = true;
// Add new XMLAttribute step to parent
DatabaseObject parentDbo = xmlElementStep.getParent();
parentDbo.add(xmlAttributeStep);
// Set correct order
if (parentDbo instanceof StepWithExpressions)
((StepWithExpressions) parentDbo).insertAtOrder(xmlAttributeStep, xmlElementStep.priority);
else if (parentDbo instanceof Sequence)
((Sequence) parentDbo).insertAtOrder(xmlAttributeStep, xmlElementStep.priority);
// Add new XMLAttribute step in Tree
StepTreeObject stepTreeObject = new StepTreeObject(explorerView.viewer, xmlElementStep);
treeParent.addChild(stepTreeObject);
// Delete XMLElement step
long oldPriority = xmlElementStep.priority;
xmlElementStep.delete();
xmlAttributeStep.getSequence().fireStepMoved(new StepEvent(xmlAttributeStep, String.valueOf(oldPriority)));
parentTreeObject.hasBeenModified(true);
explorerView.reloadTreeObject(parentTreeObject);
explorerView.setSelectedTreeObject(explorerView.findTreeObjectByUserObject(xmlAttributeStep));
} else {
throw new EngineException("You cannot paste to a " + xmlElementStep.getParent().getClass().getSimpleName() + " a database object of type " + xmlAttributeStep.getClass().getSimpleName());
}
}
}
}
} catch (Throwable e) {
ConvertigoPlugin.logException(e, "Unable to change to XMLAttribute step!");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject in project convertigo by convertigo.
the class ChangeToXMLConcatStepAction method run.
/* (non-Javadoc)
* @see com.twinsoft.convertigo.eclipse.popup.actions.MyAbstractAction#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();
Object databaseObject = treeObject.getObject();
if ((databaseObject != null) && (databaseObject instanceof XMLElementStep)) {
XMLElementStep elementStep = (XMLElementStep) databaseObject;
TreeParent treeParent = treeObject.getParent();
DatabaseObjectTreeObject parentTreeObject = null;
if (treeParent instanceof DatabaseObjectTreeObject)
parentTreeObject = (DatabaseObjectTreeObject) treeParent;
else
parentTreeObject = (DatabaseObjectTreeObject) treeParent.getParent();
if (parentTreeObject != null) {
// New XMLConcatStep step
XMLConcatStep concatStep = new XMLConcatStep();
if (DatabaseObjectsManager.acceptDatabaseObjects(elementStep.getParent(), concatStep)) {
XMLVector<XMLVector<Object>> sources = new XMLVector<XMLVector<Object>>();
XMLVector<Object> source = new XMLVector<Object>();
source.add("description");
source.add(elementStep.getSourceDefinition());
source.add(elementStep.getNodeText());
sources.add(source);
concatStep.setOutput(elementStep.isOutput());
concatStep.setEnabled(elementStep.isEnabled());
concatStep.setComment(elementStep.getComment());
// elementStep.getNodeText();
concatStep.setNodeName(elementStep.getNodeName());
concatStep.setSourcesDefinition(sources);
concatStep.bNew = true;
concatStep.hasChanged = true;
// Add new XMLConcatStep step to parent
DatabaseObject parentDbo = elementStep.getParent();
parentDbo.add(concatStep);
// Set correct order
if (parentDbo instanceof StepWithExpressions)
((StepWithExpressions) parentDbo).insertAtOrder(concatStep, elementStep.priority);
else if (parentDbo instanceof Sequence)
((Sequence) parentDbo).insertAtOrder(concatStep, elementStep.priority);
// Add new XMLConcatStep step in Tree
StepTreeObject stepTreeObject = new StepTreeObject(explorerView.viewer, concatStep);
treeParent.addChild(stepTreeObject);
// Delete XMLElementStep step
long oldPriority = elementStep.priority;
elementStep.delete();
concatStep.getSequence().fireStepMoved(new StepEvent(concatStep, String.valueOf(oldPriority)));
parentTreeObject.hasBeenModified(true);
explorerView.reloadTreeObject(parentTreeObject);
explorerView.setSelectedTreeObject(explorerView.findTreeObjectByUserObject(concatStep));
} else {
throw new EngineException("You cannot paste to a " + elementStep.getParent().getClass().getSimpleName() + " a database object of type " + concatStep.getClass().getSimpleName());
}
}
}
}
} catch (Throwable e) {
ConvertigoPlugin.logException(e, "Unable to change XMLElement to XMLConcat step!");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject in project convertigo by convertigo.
the class ChangeToXMLElementStepAction method run.
/* (non-Javadoc)
* @see com.twinsoft.convertigo.eclipse.popup.actions.MyAbstractAction#run()
*/
@SuppressWarnings("unchecked")
@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();
Object databaseObject = treeObject.getObject();
// XML Concat step
if ((databaseObject != null) && (databaseObject instanceof XMLConcatStep)) {
XMLConcatStep concatStep = (XMLConcatStep) databaseObject;
TreeParent treeParent = treeObject.getParent();
DatabaseObjectTreeObject parentTreeObject = null;
if (treeParent instanceof DatabaseObjectTreeObject)
parentTreeObject = (DatabaseObjectTreeObject) treeParent;
else
parentTreeObject = (DatabaseObjectTreeObject) treeParent.getParent();
if (parentTreeObject != null) {
// New XMLElementStep step
XMLElementStep elementStep = new XMLElementStep();
if (DatabaseObjectsManager.acceptDatabaseObjects(concatStep.getParent(), elementStep)) {
if (concatStep.getSourcesDefinition().toString().equals("[[]]")) {
elementStep.setSourceDefinition(new XMLVector<String>());
} else {
// Set properties (Default value and Source)
XMLVector<XMLVector<Object>> sources = concatStep.getSourcesDefinition();
XMLVector<String> sourceDefinition = new XMLVector<String>();
String defaultValue = "";
for (XMLVector<Object> source : sources) {
if (sources.lastElement() == source) {
defaultValue += source.get(2);
} else {
defaultValue += source.get(2) + concatStep.getSeparator();
}
if (sourceDefinition.toString().equals("[]") && (!source.get(1).toString().equals("") && !source.get(1).toString().equals("[]"))) {
sourceDefinition = (XMLVector<String>) source.get(1);
}
}
elementStep.setOutput(concatStep.isOutput());
elementStep.setEnabled(concatStep.isEnabled());
elementStep.setComment(concatStep.getComment());
elementStep.setNodeName(concatStep.getNodeName());
elementStep.setNodeText(defaultValue);
elementStep.setSourceDefinition(sourceDefinition);
}
elementStep.bNew = true;
elementStep.hasChanged = true;
// Add new XMLElementStep step to parent
DatabaseObject parentDbo = concatStep.getParent();
parentDbo.add(elementStep);
// Set correct order
if (parentDbo instanceof StepWithExpressions)
((StepWithExpressions) parentDbo).insertAtOrder(elementStep, concatStep.priority);
else if (parentDbo instanceof Sequence)
((Sequence) parentDbo).insertAtOrder(elementStep, concatStep.priority);
// Add new XMLElementStep step in Tree
StepTreeObject stepTreeObject = new StepTreeObject(explorerView.viewer, elementStep);
treeParent.addChild(stepTreeObject);
// Delete XMLConcatStep step
long oldPriority = concatStep.priority;
concatStep.delete();
elementStep.getSequence().fireStepMoved(new StepEvent(elementStep, String.valueOf(oldPriority)));
parentTreeObject.hasBeenModified(true);
explorerView.reloadTreeObject(parentTreeObject);
explorerView.setSelectedTreeObject(explorerView.findTreeObjectByUserObject(elementStep));
} else {
throw new EngineException("You cannot paste to a " + concatStep.getParent().getClass().getSimpleName() + " a database object of type " + elementStep.getClass().getSimpleName());
}
}
}
// XML Attribute
if ((databaseObject != null) && (databaseObject instanceof XMLAttributeStep)) {
XMLAttributeStep attributeStep = (XMLAttributeStep) databaseObject;
TreeParent treeParent = treeObject.getParent();
DatabaseObjectTreeObject parentTreeObject = null;
if (treeParent instanceof DatabaseObjectTreeObject)
parentTreeObject = (DatabaseObjectTreeObject) treeParent;
else
parentTreeObject = (DatabaseObjectTreeObject) treeParent.getParent();
if (parentTreeObject != null) {
// New XMLElement step
XMLElementStep elementStep = new XMLElementStep();
if (DatabaseObjectsManager.acceptDatabaseObjects(attributeStep.getParent(), elementStep)) {
// Set properties
elementStep.setOutput(attributeStep.isOutput());
elementStep.setEnabled(attributeStep.isEnabled());
elementStep.setComment(attributeStep.getComment());
elementStep.setSourceDefinition(attributeStep.getSourceDefinition());
elementStep.setNodeText(attributeStep.getNodeText());
elementStep.setNodeName(attributeStep.getNodeName());
elementStep.bNew = true;
elementStep.hasChanged = true;
// Add new XMLElement step to parent
DatabaseObject parentDbo = attributeStep.getParent();
parentDbo.add(elementStep);
// Set correct order
if (parentDbo instanceof StepWithExpressions)
((StepWithExpressions) parentDbo).insertAtOrder(elementStep, attributeStep.priority);
else if (parentDbo instanceof Sequence)
((Sequence) parentDbo).insertAtOrder(elementStep, attributeStep.priority);
// Add new XMLElement step in Tree
StepTreeObject stepTreeObject = new StepTreeObject(explorerView.viewer, attributeStep);
treeParent.addChild(stepTreeObject);
// Delete XMLAttribute step
long oldPriority = attributeStep.priority;
attributeStep.delete();
elementStep.getSequence().fireStepMoved(new StepEvent(elementStep, String.valueOf(oldPriority)));
parentTreeObject.hasBeenModified(true);
explorerView.reloadTreeObject(parentTreeObject);
explorerView.setSelectedTreeObject(explorerView.findTreeObjectByUserObject(elementStep));
} else {
throw new EngineException("You cannot paste to a " + attributeStep.getParent().getClass().getSimpleName() + " a database object of type " + elementStep.getClass().getSimpleName());
}
}
}
// JElement
if ((databaseObject != null) && (databaseObject instanceof ElementStep)) {
ElementStep jelementStep = (ElementStep) databaseObject;
TreeParent treeParent = treeObject.getParent();
DatabaseObjectTreeObject parentTreeObject = null;
if (treeParent instanceof DatabaseObjectTreeObject)
parentTreeObject = (DatabaseObjectTreeObject) treeParent;
else
parentTreeObject = (DatabaseObjectTreeObject) treeParent.getParent();
if (parentTreeObject != null) {
// New XMLElement step
XMLElementStep elementStep = new XMLElementStep();
if (DatabaseObjectsManager.acceptDatabaseObjects(jelementStep.getParent(), elementStep)) {
// Set properties
elementStep.setOutput(jelementStep.isOutput());
elementStep.setEnabled(jelementStep.isEnabled());
elementStep.setComment(jelementStep.getComment());
// elementStep.setSourceDefinition(jelementStep.getSourceDefinition());
elementStep.setNodeText(jelementStep.getNodeText());
elementStep.setNodeName(jelementStep.getNodeName());
elementStep.bNew = true;
elementStep.hasChanged = true;
// Add new XMLElement step to parent
DatabaseObject parentDbo = jelementStep.getParent();
parentDbo.add(elementStep);
for (Step step : jelementStep.getAllSteps()) {
try {
elementStep.addStep(step);
} catch (Throwable t) {
}
}
// Set correct order
if (parentDbo instanceof StepWithExpressions)
((StepWithExpressions) parentDbo).insertAtOrder(elementStep, jelementStep.priority);
else if (parentDbo instanceof Sequence)
((Sequence) parentDbo).insertAtOrder(elementStep, jelementStep.priority);
// Add new XMLElement step in Tree
StepTreeObject stepTreeObject = new StepTreeObject(explorerView.viewer, jelementStep);
treeParent.addChild(stepTreeObject);
// Delete XMLAttribute step
long oldPriority = jelementStep.priority;
jelementStep.delete();
elementStep.getSequence().fireStepMoved(new StepEvent(elementStep, String.valueOf(oldPriority)));
parentTreeObject.hasBeenModified(true);
explorerView.reloadTreeObject(parentTreeObject);
explorerView.setSelectedTreeObject(explorerView.findTreeObjectByUserObject(elementStep));
} else {
throw new EngineException("You cannot paste to a " + jelementStep.getParent().getClass().getSimpleName() + " a database object of type " + elementStep.getClass().getSimpleName());
}
}
}
}
} catch (Throwable e) {
ConvertigoPlugin.logException(e, "Unable to change step to XMLElement step!");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject in project convertigo by convertigo.
the class ChangeToIsInStepAction method run.
/* (non-Javadoc)
* @see com.twinsoft.convertigo.eclipse.popup.actions.MyAbstractAction#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();
Object databaseObject = treeObject.getObject();
// For IsInThenElse step
if ((databaseObject != null) && (databaseObject instanceof IsInThenElseStep)) {
IsInThenElseStep ifThenElseStep = (IsInThenElseStep) databaseObject;
if (ifThenElseStep.hasThenElseSteps()) {
ThenStep thenStep = ifThenElseStep.getThenStep();
List<Step> list = thenStep.getSteps();
TreePath[] selectedPaths = new TreePath[list.size()];
for (int i = 0; i < list.size(); i++) {
StepTreeObject stepTreeObject = (StepTreeObject) explorerView.findTreeObjectByUserObject(list.get(i));
selectedPaths[i] = new TreePath(stepTreeObject);
}
TreeParent treeParent = treeObject.getParent();
DatabaseObjectTreeObject parentTreeObject = null;
if (treeParent instanceof DatabaseObjectTreeObject)
parentTreeObject = (DatabaseObjectTreeObject) treeParent;
else
parentTreeObject = (DatabaseObjectTreeObject) treeParent.getParent();
if (parentTreeObject != null) {
// New jIf step
IsInStep ifStep = new IsInStep();
// Set properties
ifStep.setSourceDefinition(ifThenElseStep.getSourceDefinition());
ifStep.setTestDefinition(ifThenElseStep.getTestDefinition());
ifStep.setComment(ifThenElseStep.getComment());
ifStep.setCondition(ifThenElseStep.getCondition());
ifStep.setEnabled(ifThenElseStep.isEnabled());
ifStep.setOutput(ifThenElseStep.isOutput());
ifStep.setName(ifThenElseStep.getName());
ifStep.bNew = true;
ifStep.hasChanged = true;
// Add new jIf step to parent
DatabaseObject parentDbo = ifThenElseStep.getParent();
parentDbo.add(ifStep);
// Set correct order
if (parentDbo instanceof StepWithExpressions)
((StepWithExpressions) parentDbo).insertAtOrder(ifStep, ifThenElseStep.priority);
else if (parentDbo instanceof Sequence)
((Sequence) parentDbo).insertAtOrder(ifStep, ifThenElseStep.priority);
// Add new jIf step in Tree
StepTreeObject stepTreeObject = new StepTreeObject(explorerView.viewer, ifStep);
treeParent.addChild(stepTreeObject);
// Cut/Paste steps under jIf step
if (selectedPaths.length > 0) {
new ClipboardAction(ConvertigoPlugin.clipboardManagerDND).cut(explorerView, selectedPaths, ProjectExplorerView.TREE_OBJECT_TYPE_DBO_STEP);
for (int i = 0; i < ConvertigoPlugin.clipboardManagerDND.objects.length; i++) {
ConvertigoPlugin.clipboardManagerDND.cutAndPaste(ConvertigoPlugin.clipboardManagerDND.objects[i], stepTreeObject);
}
ConvertigoPlugin.clipboardManagerDND.reset();
}
// Delete IfThenElse step
long oldPriority = ifThenElseStep.priority;
// Save oldName
String oldName = ifThenElseStep.getName();
// Now delete
ifThenElseStep.delete();
// Set name after deletion
ifStep.setName(oldName);
// Simulate move of IfThenElse to If
ifStep.getSequence().fireStepMoved(new StepEvent(ifStep, String.valueOf(oldPriority)));
parentTreeObject.hasBeenModified(true);
explorerView.reloadTreeObject(parentTreeObject);
explorerView.setSelectedTreeObject(explorerView.findTreeObjectByUserObject(ifStep));
}
}
}
// For IfExist step
if ((databaseObject != null) && (databaseObject instanceof IfExistStep)) {
IfExistStep ifExistStep = (IfExistStep) databaseObject;
List<Step> list = ifExistStep.getSteps();
TreePath[] selectedPaths = new TreePath[list.size()];
for (int i = 0; i < list.size(); i++) {
StepTreeObject stepTreeObject = (StepTreeObject) explorerView.findTreeObjectByUserObject(list.get(i));
selectedPaths[i] = new TreePath(stepTreeObject);
}
TreeParent treeParent = treeObject.getParent();
DatabaseObjectTreeObject parentTreeObject = null;
if (treeParent instanceof DatabaseObjectTreeObject)
parentTreeObject = (DatabaseObjectTreeObject) treeParent;
else
parentTreeObject = (DatabaseObjectTreeObject) treeParent.getParent();
if (parentTreeObject != null) {
// New jIf step
IsInStep ifStep = new IsInStep();
// Set properties
ifStep.setSourceDefinition(ifExistStep.getSourceDefinition());
ifStep.setComment(ifExistStep.getComment());
ifStep.setCondition(ifExistStep.getCondition());
ifStep.setEnabled(ifExistStep.isEnabled());
ifStep.setOutput(ifExistStep.isOutput());
ifStep.setName(ifExistStep.getName());
ifStep.bNew = true;
ifStep.hasChanged = true;
// Add new jIf step to parent
DatabaseObject parentDbo = ifExistStep.getParent();
parentDbo.add(ifStep);
// Set correct order
if (parentDbo instanceof StepWithExpressions)
((StepWithExpressions) parentDbo).insertAtOrder(ifStep, ifExistStep.priority);
else if (parentDbo instanceof Sequence)
((Sequence) parentDbo).insertAtOrder(ifStep, ifExistStep.priority);
// Add new jIf step in Tree
StepTreeObject stepTreeObject = new StepTreeObject(explorerView.viewer, ifStep);
treeParent.addChild(stepTreeObject);
// Cut/Paste steps under jIf step
if (selectedPaths.length > 0) {
new ClipboardAction(ConvertigoPlugin.clipboardManagerDND).cut(explorerView, selectedPaths, ProjectExplorerView.TREE_OBJECT_TYPE_DBO_STEP);
for (int i = 0; i < ConvertigoPlugin.clipboardManagerDND.objects.length; i++) {
ConvertigoPlugin.clipboardManagerDND.cutAndPaste(ConvertigoPlugin.clipboardManagerDND.objects[i], stepTreeObject);
}
ConvertigoPlugin.clipboardManagerDND.reset();
}
// Delete IfThenElse step
long oldPriority = ifExistStep.priority;
// Save oldName
String oldName = ifExistStep.getName();
// Now delete
ifExistStep.delete();
// Set name after deletion
ifStep.setName(oldName);
// Simulate move of IfThenElse to If
ifStep.getSequence().fireStepMoved(new StepEvent(ifStep, String.valueOf(oldPriority)));
parentTreeObject.hasBeenModified(true);
explorerView.reloadTreeObject(parentTreeObject);
explorerView.setSelectedTreeObject(explorerView.findTreeObjectByUserObject(ifStep));
}
}
}
} catch (Throwable e) {
ConvertigoPlugin.logException(e, "Unable to change step to IsIn step!");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject in project convertigo by convertigo.
the class ChangeToMultiValuedVariableAction 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();
TreeParent treeParent = treeObject.getParent();
DatabaseObjectTreeObject parentTreeObject = null;
if (treeParent instanceof DatabaseObjectTreeObject)
parentTreeObject = (DatabaseObjectTreeObject) treeParent;
else
parentTreeObject = (DatabaseObjectTreeObject) treeParent.getParent();
if (parentTreeObject != null) {
Object databaseObject = treeObject.getObject();
if (databaseObject != null) {
Variable simple = (Variable) databaseObject;
Variable multi = null;
if (databaseObject instanceof TestCaseVariable)
multi = new TestCaseMultiValuedVariable();
if (databaseObject instanceof StepVariable)
multi = new StepMultiValuedVariable();
if (databaseObject instanceof RequestableVariable)
multi = new RequestableMultiValuedVariable();
if (databaseObject instanceof RequestableHttpVariable)
multi = new RequestableHttpMultiValuedVariable();
if (databaseObject instanceof HttpStatementVariable)
multi = new HttpStatementMultiValuedVariable();
if (multi != null) {
if (multi instanceof StepVariable) {
((StepVariable) multi).setSourceDefinition(((StepVariable) simple).getSourceDefinition());
}
if (multi instanceof RequestableVariable) {
((RequestableVariable) multi).setXmlTypeAffectation(((RequestableVariable) simple).getXmlTypeAffectation());
}
if (multi instanceof RequestableHttpVariable) {
// HttpName
((RequestableHttpVariable) multi).setHttpName(((RequestableHttpVariable) simple).getHttpName());
// HttpMethod
((RequestableHttpVariable) multi).setHttpMethod(((RequestableHttpVariable) simple).getHttpMethod());
}
Object value = simple.getValueOrNull();
multi.setValueOrNull(value);
multi.setVisibility(simple.getVisibility());
// Comment
multi.setComment(simple.getComment());
// Description
multi.setDescription(simple.getDescription());
// Required
multi.setRequired(simple.isRequired());
multi.bNew = true;
multi.hasChanged = true;
// Add new variable to parent
DatabaseObject parentDbo = simple.getParent();
parentDbo.add(multi);
// Set correct order
if (parentDbo instanceof TestCase)
((TestCase) parentDbo).insertAtOrder(multi, simple.priority);
if (parentDbo instanceof RequestableStep)
((RequestableStep) parentDbo).insertAtOrder(multi, simple.priority);
if (parentDbo instanceof Sequence)
((Sequence) parentDbo).insertAtOrder(multi, simple.priority);
if (parentDbo instanceof TransactionWithVariables)
((TransactionWithVariables) parentDbo).insertAtOrder(multi, simple.priority);
if (parentDbo instanceof HTTPStatement)
((HTTPStatement) parentDbo).insertAtOrder(multi, simple.priority);
// Add new variable in Tree
VariableTreeObject2 varTreeObject = new VariableTreeObject2(explorerView.viewer, multi);
treeParent.addChild(varTreeObject);
// Delete simple variable
simple.delete();
// Set correct name
multi.setName(simple.getName());
parentTreeObject.hasBeenModified(true);
explorerView.reloadTreeObject(parentTreeObject);
explorerView.setSelectedTreeObject(explorerView.findTreeObjectByUserObject(multi));
}
}
}
}
} catch (Throwable e) {
ConvertigoPlugin.logException(e, "Unable to change simple variable to multi valuated variable!");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
Aggregations