use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject in project convertigo by convertigo.
the class ChangeToIfExistStepAction 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 IfExistThenElseStep
if ((databaseObject != null) && (databaseObject instanceof IfExistThenElseStep)) {
IfExistThenElseStep ifThenElseStep = (IfExistThenElseStep) 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
IfExistStep ifStep = new IfExistStep();
// Set properties
ifStep.setSourceDefinition(ifThenElseStep.getSourceDefinition());
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 IsInStep
if ((databaseObject != null) && (databaseObject instanceof IsInStep)) {
IsInStep isInStep = (IsInStep) databaseObject;
List<Step> list = isInStep.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
IfExistStep ifStep = new IfExistStep();
// Set properties
ifStep.setSourceDefinition(isInStep.getSourceDefinition());
ifStep.setComment(isInStep.getComment());
ifStep.setCondition(isInStep.getCondition());
ifStep.setEnabled(isInStep.isEnabled());
ifStep.setOutput(isInStep.isOutput());
ifStep.setName(isInStep.getName());
ifStep.bNew = true;
ifStep.hasChanged = true;
// Add new jIf step to parent
DatabaseObject parentDbo = isInStep.getParent();
parentDbo.add(ifStep);
// Set correct order
if (parentDbo instanceof StepWithExpressions)
((StepWithExpressions) parentDbo).insertAtOrder(ifStep, isInStep.priority);
else if (parentDbo instanceof Sequence)
((Sequence) parentDbo).insertAtOrder(ifStep, isInStep.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 IsIn step
long oldPriority = isInStep.priority;
// Save oldName
String oldName = isInStep.getName();
// Now delete
isInStep.delete();
// Set name after deletion
ifStep.setName(oldName);
// Simulate move of IsIn 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 IfExist step!");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject in project convertigo by convertigo.
the class ChangeToIfExistThenElseStepAction 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 IfExist step
if ((databaseObject != null) && (databaseObject instanceof IfExistStep)) {
IfExistStep ifStep = (IfExistStep) databaseObject;
List<Step> list = ifStep.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
IfExistThenElseStep ifThenElseStep = new IfExistThenElseStep();
// Set properties
ifThenElseStep.setSourceDefinition(ifStep.getSourceDefinition());
ifThenElseStep.setComment(ifStep.getComment());
ifThenElseStep.setCondition(ifStep.getCondition());
ifThenElseStep.setEnabled(ifStep.isEnabled());
ifThenElseStep.setOutput(ifStep.isOutput());
ifThenElseStep.setName(ifStep.getName());
ifThenElseStep.bNew = true;
ifThenElseStep.hasChanged = true;
// Add new IfThenElseStep step to parent
DatabaseObject parentDbo = ifStep.getParent();
parentDbo.add(ifThenElseStep);
// Set correct order
if (parentDbo instanceof StepWithExpressions)
((StepWithExpressions) parentDbo).insertAtOrder(ifThenElseStep, ifStep.priority);
else if (parentDbo instanceof Sequence)
((Sequence) parentDbo).insertAtOrder(ifThenElseStep, ifStep.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 = ifStep.priority;
// Save oldName
String oldName = ifStep.getName();
// Now delete
ifStep.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 IsInThenElse step
if ((databaseObject != null) && (databaseObject instanceof IsInThenElseStep)) {
IsInThenElseStep isInThenElseStep = (IsInThenElseStep) databaseObject;
if (isInThenElseStep.hasThenElseSteps()) {
TreeParent treeParent = treeObject.getParent();
DatabaseObjectTreeObject parentTreeObject = null;
if (treeParent instanceof DatabaseObjectTreeObject)
parentTreeObject = (DatabaseObjectTreeObject) treeParent;
else
parentTreeObject = (DatabaseObjectTreeObject) treeParent.getParent();
if (parentTreeObject != null) {
// New IfExistThenElse step
IfExistThenElseStep ifThenElseStep = new IfExistThenElseStep();
// Set properties
ifThenElseStep.setSourceDefinition(isInThenElseStep.getSourceDefinition());
ifThenElseStep.setComment(isInThenElseStep.getComment());
ifThenElseStep.setCondition(isInThenElseStep.getCondition());
ifThenElseStep.setEnabled(isInThenElseStep.isEnabled());
ifThenElseStep.setOutput(isInThenElseStep.isOutput());
ifThenElseStep.setName(isInThenElseStep.getName());
ifThenElseStep.bNew = true;
ifThenElseStep.hasChanged = true;
// Add new IfExistThenElse step to parent
DatabaseObject parentDbo = isInThenElseStep.getParent();
parentDbo.add(ifThenElseStep);
// Set correct order
if (parentDbo instanceof StepWithExpressions)
((StepWithExpressions) parentDbo).insertAtOrder(ifThenElseStep, isInThenElseStep.priority);
else if (parentDbo instanceof Sequence)
((Sequence) parentDbo).insertAtOrder(ifThenElseStep, isInThenElseStep.priority);
// Add Then/Else steps
ThenStep thenStep = isInThenElseStep.getThenStep();
ElseStep elseStep = isInThenElseStep.getElseStep();
thenStep.bNew = true;
elseStep.bNew = true;
ifThenElseStep.addStep(thenStep);
ifThenElseStep.addStep(elseStep);
// Add new IfExistThenElse step in Tree
StepTreeObject stepTreeObject = new StepTreeObject(explorerView.viewer, ifThenElseStep);
treeParent.addChild(stepTreeObject);
stepTreeObject.addChild(new StepTreeObject(explorerView.viewer, thenStep));
stepTreeObject.addChild(new StepTreeObject(explorerView.viewer, elseStep));
// Delete IsInThenElse step
long oldPriority = isInThenElseStep.priority;
// Save oldName
String oldName = isInThenElseStep.getName();
// Now delete
isInThenElseStep.delete();
// Set name after deletion
ifThenElseStep.setName(oldName);
// Simulate move of IsInThenElse to IfExistThenElse step
ifThenElseStep.getSequence().fireStepMoved(new StepEvent(ifThenElseStep, String.valueOf(oldPriority)));
parentTreeObject.hasBeenModified(true);
explorerView.reloadTreeObject(parentTreeObject);
explorerView.setSelectedTreeObject(explorerView.findTreeObjectByUserObject(ifThenElseStep));
}
}
}
}
} catch (Throwable e) {
ConvertigoPlugin.logException(e, "Unable to change step to IfExistThenElse step!");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject in project convertigo by convertigo.
the class ChangeToIfThenElseStatementAction 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 IfStatement)) {
IfStatement ifStatement = (IfStatement) databaseObject;
List<Statement> list = ifStatement.getStatements();
TreePath[] selectedPaths = new TreePath[list.size()];
for (int i = 0; i < list.size(); i++) {
StatementTreeObject statementTreeObject = (StatementTreeObject) explorerView.findTreeObjectByUserObject(list.get(i));
selectedPaths[i] = new TreePath(statementTreeObject);
}
TreeParent treeParent = treeObject.getParent();
DatabaseObjectTreeObject parentTreeObject = null;
if (treeParent instanceof DatabaseObjectTreeObject)
parentTreeObject = (DatabaseObjectTreeObject) treeParent;
else
parentTreeObject = (DatabaseObjectTreeObject) treeParent.getParent();
if (parentTreeObject != null) {
// New IfThenElseStatement statement
IfThenElseStatement ifThenElseStatement = new IfThenElseStatement(ifStatement.getCondition());
ifThenElseStatement.bNew = true;
ifThenElseStatement.hasChanged = true;
// Add new IfThenElseStatement statement to parent
DatabaseObject parentDbo = ifStatement.getParent();
parentDbo.add(ifThenElseStatement);
// Set correct order
if (parentDbo instanceof StatementWithExpressions) {
int index = ((StatementWithExpressions) parentDbo).getOrderedStatements().get(0).indexOf(ifStatement.priority);
((StatementWithExpressions) parentDbo).getOrderedStatements().get(0).add(index, ifThenElseStatement.priority);
}
// Add Then/Else statement
ThenStatement thenStatement = new ThenStatement();
thenStatement.bNew = true;
ifThenElseStatement.addStatement(thenStatement);
ElseStatement elseStatement = new ElseStatement();
elseStatement.bNew = true;
ifThenElseStatement.addStatement(elseStatement);
// Add new IfThenElseStep statement in Tree
StatementTreeObject statementTreeObject = new StatementTreeObject(explorerView.viewer, ifThenElseStatement);
treeParent.addChild(statementTreeObject);
StatementTreeObject thenTreeObject = new StatementTreeObject(explorerView.viewer, thenStatement);
statementTreeObject.addChild(thenTreeObject);
StatementTreeObject elseTreeObject = new StatementTreeObject(explorerView.viewer, elseStatement);
statementTreeObject.addChild(elseTreeObject);
// Cut/Paste steps under Then statement
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 statement
ifStatement.delete();
parentTreeObject.hasBeenModified(true);
explorerView.reloadTreeObject(parentTreeObject);
explorerView.setSelectedTreeObject(explorerView.findTreeObjectByUserObject(ifThenElseStatement));
}
}
}
} catch (Throwable e) {
ConvertigoPlugin.logException(e, "Unable to change statement to IfThenElse statement!");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject in project convertigo by convertigo.
the class CreateDocumentAction method selectionChanged.
public void selectionChanged(IAction action, ISelection selection) {
try {
boolean enable = true;
super.selectionChanged(action, selection);
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
TreeObject treeObject = (TreeObject) structuredSelection.getFirstElement();
if (treeObject instanceof ObjectsFolderTreeObject)
enable = ((ObjectsFolderTreeObject) treeObject).folderType == ObjectsFolderTreeObject.FOLDER_TYPE_DOCUMENTS;
else if (treeObject instanceof DatabaseObjectTreeObject) {
DatabaseObject dbo = (DatabaseObject) treeObject.getObject();
ActionModel actionModel = DatabaseObjectsAction.selectionChanged(getClass().getName(), dbo);
enable = actionModel.isEnabled;
}
action.setEnabled(enable);
} catch (Exception e) {
}
}
use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject in project convertigo by convertigo.
the class CreateIndexAction method selectionChanged.
public void selectionChanged(IAction action, ISelection selection) {
try {
boolean enable = true;
super.selectionChanged(action, selection);
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
TreeObject treeObject = (TreeObject) structuredSelection.getFirstElement();
if (treeObject instanceof ObjectsFolderTreeObject)
enable = ((ObjectsFolderTreeObject) treeObject).folderType == ObjectsFolderTreeObject.FOLDER_TYPE_INDEXES;
else if (treeObject instanceof DatabaseObjectTreeObject) {
DatabaseObject dbo = (DatabaseObject) treeObject.getObject();
ActionModel actionModel = DatabaseObjectsAction.selectionChanged(getClass().getName(), dbo);
enable = actionModel.isEnabled;
}
action.setEnabled(enable);
} catch (Exception e) {
}
}
Aggregations