use of com.twinsoft.convertigo.beans.steps.SimpleSourceStep in project convertigo by convertigo.
the class ChangeToSimpleSourceStepAction 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 SourceStep)) {
SourceStep jSourceStep = (SourceStep) databaseObject;
TreeParent treeParent = treeObject.getParent();
DatabaseObjectTreeObject parentTreeObject = null;
if (treeParent instanceof DatabaseObjectTreeObject)
parentTreeObject = (DatabaseObjectTreeObject) treeParent;
else
parentTreeObject = (DatabaseObjectTreeObject) treeParent.getParent();
if (parentTreeObject != null) {
// New jSimpleSource step
SimpleSourceStep jSimpleSourceStep = new SimpleSourceStep();
// Set properties
jSimpleSourceStep.setSourceDefinition(jSourceStep.getSourceDefinition());
jSimpleSourceStep.setComment(jSourceStep.getComment());
jSimpleSourceStep.setVariableName(jSourceStep.getVariableName());
jSimpleSourceStep.setEnabled(jSourceStep.isEnabled());
jSimpleSourceStep.setOutput(jSourceStep.isOutput());
jSimpleSourceStep.setName(jSourceStep.getName());
jSimpleSourceStep.bNew = true;
jSimpleSourceStep.hasChanged = true;
// Add new jSource step to parent
DatabaseObject parentDbo = jSourceStep.getParent();
parentDbo.add(jSimpleSourceStep);
// Set correct order
if (parentDbo instanceof StepWithExpressions)
((StepWithExpressions) parentDbo).insertAtOrder(jSimpleSourceStep, jSourceStep.priority);
else if (parentDbo instanceof Sequence)
((Sequence) parentDbo).insertAtOrder(jSimpleSourceStep, jSourceStep.priority);
// Add new jSimpleSource step in Tree
StepTreeObject stepTreeObject = new StepTreeObject(explorerView.viewer, jSimpleSourceStep);
treeParent.addChild(stepTreeObject);
// Delete jSource step
long oldPriority = jSourceStep.priority;
jSourceStep.delete();
// Simulate move of jSource to jSimpleSource step
jSimpleSourceStep.getSequence().fireStepMoved(new StepEvent(jSimpleSourceStep, String.valueOf(oldPriority)));
parentTreeObject.hasBeenModified(true);
explorerView.reloadTreeObject(parentTreeObject);
explorerView.setSelectedTreeObject(explorerView.findTreeObjectByUserObject(jSimpleSourceStep));
}
}
}
} catch (Throwable e) {
ConvertigoPlugin.logException(e, "Unable to change step to jSimpleSource step!");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
use of com.twinsoft.convertigo.beans.steps.SimpleSourceStep in project convertigo by convertigo.
the class ChangeToSourceStepAction 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 SimpleSourceStep)) {
SimpleSourceStep jSimpleSourceStep = (SimpleSourceStep) databaseObject;
TreeParent treeParent = treeObject.getParent();
DatabaseObjectTreeObject parentTreeObject = null;
if (treeParent instanceof DatabaseObjectTreeObject)
parentTreeObject = (DatabaseObjectTreeObject) treeParent;
else
parentTreeObject = (DatabaseObjectTreeObject) treeParent.getParent();
if (parentTreeObject != null) {
// New jSource step
SourceStep jSourceStep = new SourceStep();
// Set properties
jSourceStep.setSourceDefinition(jSimpleSourceStep.getSourceDefinition());
jSourceStep.setComment(jSimpleSourceStep.getComment());
jSourceStep.setVariableName(jSimpleSourceStep.getVariableName());
jSourceStep.setEnabled(jSimpleSourceStep.isEnabled());
jSourceStep.setOutput(jSimpleSourceStep.isOutput());
jSourceStep.setName(jSimpleSourceStep.getName());
jSourceStep.bNew = true;
jSourceStep.hasChanged = true;
// Add new jSource step to parent
DatabaseObject parentDbo = jSimpleSourceStep.getParent();
parentDbo.add(jSourceStep);
// Set correct order
if (parentDbo instanceof StepWithExpressions)
((StepWithExpressions) parentDbo).insertAtOrder(jSourceStep, jSimpleSourceStep.priority);
else if (parentDbo instanceof Sequence)
((Sequence) parentDbo).insertAtOrder(jSourceStep, jSimpleSourceStep.priority);
// Add new jSource step in Tree
StepTreeObject stepTreeObject = new StepTreeObject(explorerView.viewer, jSourceStep);
treeParent.addChild(stepTreeObject);
// Delete jSimpleSource step
long oldPriority = jSimpleSourceStep.priority;
jSimpleSourceStep.delete();
// Simulate move of jSimpleSource to jSource step
jSourceStep.getSequence().fireStepMoved(new StepEvent(jSourceStep, String.valueOf(oldPriority)));
parentTreeObject.hasBeenModified(true);
explorerView.reloadTreeObject(parentTreeObject);
explorerView.setSelectedTreeObject(explorerView.findTreeObjectByUserObject(jSourceStep));
}
}
}
} catch (Throwable e) {
ConvertigoPlugin.logException(e, "Unable to change step to jSource step!");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
Aggregations