use of com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeParent in project convertigo by convertigo.
the class CreateDesignDocumentValidateAction 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) {
DesignDocumentTreeObject ddto = (DesignDocumentTreeObject) explorerView.getFirstSelectedTreeObject();
DesignDocumentValidateTreeObject ddvto = ddto.addNewValidate();
if (ddto.hasChanged()) {
TreeParent treeParent = ddto.getParent();
if (treeParent instanceof FolderTreeObject)
treeParent = treeParent.getParent();
explorerView.objectChanged(new CompositeEvent(treeParent.getObject(), ddvto.getPath()));
}
}
} catch (Throwable e) {
ConvertigoPlugin.logException(e, "Unable to create a new Validate!");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
use of com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeParent in project convertigo by convertigo.
the class CreatePropertyTableRowAction 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) {
PropertyTableTreeObject propertyTableTreeObject = (PropertyTableTreeObject) explorerView.getFirstSelectedTreeObject();
TreeParent owner = propertyTableTreeObject.getTreeObjectOwner();
IPropertyTreeObject pto = propertyTableTreeObject.addNewRow();
if (owner instanceof DatabaseObjectTreeObject) {
DatabaseObjectTreeObject databaseObjectTreeObject = (DatabaseObjectTreeObject) owner;
if (databaseObjectTreeObject.hasChanged()) {
TreeParent treeParent = databaseObjectTreeObject.getParent();
if (treeParent instanceof FolderTreeObject)
treeParent = treeParent.getParent();
// explorerView.reloadTreeObject(treeParent);
explorerView.objectChanged(new CompositeEvent(treeParent.getObject(), pto.getPath()));
}
} else
explorerView.refreshTreeObject(owner, true);
}
} catch (Throwable e) {
ConvertigoPlugin.logException(e, "Unable to create a new row!");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
use of com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeParent in project convertigo by convertigo.
the class DatabaseObjectFindDialog method getDatabaseObjects.
private void getDatabaseObjects(TreeParent treeObject) {
ProjectTreeObject projectTreeObject = ConvertigoPlugin.projectManager.currentProjectTreeObject;
TreeParent treeParent = treeObject;
if (treeObject == null) {
treeParent = projectTreeObject;
TreeObject treeSelected = ConvertigoPlugin.getDefault().getProjectExplorerView().getFirstSelectedTreeObject();
while (treeSelected != null && !(treeSelected instanceof TreeParent)) {
treeSelected = treeSelected.getParent();
}
if (treeSelected != null) {
treeParent = (TreeParent) treeSelected;
}
if (firstSelected == null) {
firstSelected = treeSelected;
}
}
List<? extends TreeObject> children = treeParent.getChildren();
children.sort(ConvertigoPlugin.getDefault().getProjectExplorerView().getViewerComparator());
for (TreeObject child : children) {
if (child instanceof DatabaseObjectTreeObject) {
DatabaseObjectTreeObject databaseObjectTreeObject = (DatabaseObjectTreeObject) child;
if (!databaseObjectTreeObject.isInherited) {
vDatabaseObjects.add(databaseObjectTreeObject);
getDatabaseObjects(databaseObjectTreeObject);
}
} else if (child instanceof TreeParent) {
getDatabaseObjects((TreeParent) child);
}
}
}
use of com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeParent in project convertigo by convertigo.
the class ChangeToIsInThenElseStepAction 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 IsInStep
if ((databaseObject != null) && (databaseObject instanceof IsInStep)) {
IsInStep isIn = (IsInStep) databaseObject;
List<Step> list = isIn.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 IfThenElseStep step
IsInThenElseStep ifThenElseStep = new IsInThenElseStep();
// Set properties
ifThenElseStep.setSourceDefinition(isIn.getSourceDefinition());
ifThenElseStep.setTestDefinition(isIn.getTestDefinition());
ifThenElseStep.setComment(isIn.getComment());
ifThenElseStep.setCondition(isIn.getCondition());
ifThenElseStep.setEnabled(isIn.isEnabled());
ifThenElseStep.setOutput(isIn.isOutput());
ifThenElseStep.setName(isIn.getName());
ifThenElseStep.bNew = true;
ifThenElseStep.hasChanged = true;
// Add new IfThenElseStep step to parent
DatabaseObject parentDbo = isIn.getParent();
parentDbo.add(ifThenElseStep);
// Set correct order
if (parentDbo instanceof StepWithExpressions)
((StepWithExpressions) parentDbo).insertAtOrder(ifThenElseStep, isIn.priority);
else if (parentDbo instanceof Sequence)
((Sequence) parentDbo).insertAtOrder(ifThenElseStep, isIn.priority);
// Add Then/Else steps
ThenStep thenStep = new ThenStep();
thenStep.bNew = true;
ifThenElseStep.addStep(thenStep);
ElseStep elseStep = new ElseStep();
elseStep.bNew = true;
ifThenElseStep.addStep(elseStep);
// Add new IfThenElseStep step in Tree
StepTreeObject stepTreeObject = new StepTreeObject(explorerView.viewer, ifThenElseStep);
treeParent.addChild(stepTreeObject);
StepTreeObject thenTreeObject = new StepTreeObject(explorerView.viewer, thenStep);
stepTreeObject.addChild(thenTreeObject);
StepTreeObject elseTreeObject = new StepTreeObject(explorerView.viewer, elseStep);
stepTreeObject.addChild(elseTreeObject);
// Cut/Paste steps under Then 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], thenTreeObject);
}
ConvertigoPlugin.clipboardManagerDND.reset();
}
// Delete If step
long oldPriority = isIn.priority;
// Save oldName
String oldName = isIn.getName();
// Now delete
isIn.delete();
// Set name after deletion
ifThenElseStep.setName(oldName);
// Simulate move of If to IfThenElse
ifThenElseStep.getSequence().fireStepMoved(new StepEvent(ifThenElseStep, String.valueOf(oldPriority)));
parentTreeObject.hasBeenModified(true);
explorerView.reloadTreeObject(parentTreeObject);
explorerView.setSelectedTreeObject(explorerView.findTreeObjectByUserObject(ifThenElseStep));
}
}
// For IfExistThenElse step
if ((databaseObject != null) && (databaseObject instanceof IfExistThenElseStep)) {
IfExistThenElseStep ifExistThenElse = (IfExistThenElseStep) databaseObject;
if (ifExistThenElse.hasThenElseSteps()) {
TreeParent treeParent = treeObject.getParent();
DatabaseObjectTreeObject parentTreeObject = null;
if (treeParent instanceof DatabaseObjectTreeObject)
parentTreeObject = (DatabaseObjectTreeObject) treeParent;
else
parentTreeObject = (DatabaseObjectTreeObject) treeParent.getParent();
if (parentTreeObject != null) {
// New IsInThenElse step
IsInThenElseStep isInThenElse = new IsInThenElseStep();
// Set properties
isInThenElse.setSourceDefinition(ifExistThenElse.getSourceDefinition());
isInThenElse.setComment(ifExistThenElse.getComment());
isInThenElse.setCondition(ifExistThenElse.getCondition());
isInThenElse.setEnabled(ifExistThenElse.isEnabled());
isInThenElse.setOutput(ifExistThenElse.isOutput());
isInThenElse.setName(ifExistThenElse.getName());
isInThenElse.bNew = true;
isInThenElse.hasChanged = true;
// Add new IsInThenElse step to parent
DatabaseObject parentDbo = ifExistThenElse.getParent();
parentDbo.add(isInThenElse);
// Set correct order
if (parentDbo instanceof StepWithExpressions)
((StepWithExpressions) parentDbo).insertAtOrder(isInThenElse, ifExistThenElse.priority);
else if (parentDbo instanceof Sequence)
((Sequence) parentDbo).insertAtOrder(isInThenElse, ifExistThenElse.priority);
// Add Then/Else steps
ThenStep thenStep = ifExistThenElse.getThenStep();
ElseStep elseStep = ifExistThenElse.getElseStep();
thenStep.bNew = true;
elseStep.bNew = true;
isInThenElse.addStep(thenStep);
isInThenElse.addStep(elseStep);
// Add new IsInThenElse step in Tree
StepTreeObject stepTreeObject = new StepTreeObject(explorerView.viewer, isInThenElse);
treeParent.addChild(new StepTreeObject(explorerView.viewer, isInThenElse));
stepTreeObject.addChild(new StepTreeObject(explorerView.viewer, thenStep));
stepTreeObject.addChild(new StepTreeObject(explorerView.viewer, elseStep));
// Delete ifExistThenElse step
long oldPriority = ifExistThenElse.priority;
// Save oldName
String oldName = ifExistThenElse.getName();
// Now delete
ifExistThenElse.delete();
// Set name after deletion
isInThenElse.setName(oldName);
// Simulate move of ifExistThenElse to IsInThenElse step
isInThenElse.getSequence().fireStepMoved(new StepEvent(isInThenElse, String.valueOf(oldPriority)));
parentTreeObject.hasBeenModified(true);
explorerView.reloadTreeObject(parentTreeObject);
explorerView.setSelectedTreeObject(explorerView.findTreeObjectByUserObject(isInThenElse));
}
}
}
}
} catch (Throwable e) {
ConvertigoPlugin.logException(e, "Unable to change step to IsInThenElse step!");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
use of com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeParent 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();
}
}
Aggregations