use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject in project convertigo by convertigo.
the class ChangeToQueryParameterAction 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();
Object databaseObject = treeObject.getObject();
if ((databaseObject != null) && (databaseObject instanceof UrlMappingParameter)) {
UrlMappingParameter parameter = (UrlMappingParameter) databaseObject;
TreeParent treeParent = treeObject.getParent();
DatabaseObjectTreeObject parentTreeObject = null;
if (treeParent instanceof DatabaseObjectTreeObject)
parentTreeObject = (DatabaseObjectTreeObject) treeParent;
else
parentTreeObject = (DatabaseObjectTreeObject) treeParent.getParent();
if (parentTreeObject != null) {
// Create new Query parameter
QueryParameter queryParameter = new QueryParameter();
if (DatabaseObjectsManager.acceptDatabaseObjects(parameter.getParent(), queryParameter)) {
queryParameter.setComment(parameter.getComment());
queryParameter.setInputType(parameter.getInputType());
queryParameter.setArray(parameter.isArray());
queryParameter.setExposed(parameter.isExposed());
queryParameter.setMultiValued(parameter.isMultiValued());
queryParameter.setRequired(parameter.isRequired());
queryParameter.setValueOrNull(parameter.getValueOrNull());
queryParameter.setMappedVariableName(parameter.getMappedVariableName());
queryParameter.bNew = true;
queryParameter.hasChanged = true;
// Add new parameter to parent operation
UrlMappingOperation operation = (UrlMappingOperation) parameter.getParent();
operation.changeTo(queryParameter);
// Add new parameter in Tree
UrlMappingParameterTreeObject parameterTreeObject = new UrlMappingParameterTreeObject(explorerView.viewer, queryParameter);
treeParent.addChild(parameterTreeObject);
// Delete old parameter
parameter.delete();
// Rename new parameter
queryParameter.setName(parameter.getName());
// Reload in tree
parentTreeObject.hasBeenModified(true);
explorerView.reloadTreeObject(parentTreeObject);
explorerView.setSelectedTreeObject(explorerView.findTreeObjectByUserObject(queryParameter));
} else {
throw new EngineException("You cannot paste to a " + parameter.getParent().getClass().getSimpleName() + " a database object of type " + queryParameter.getClass().getSimpleName());
}
}
}
}
} catch (Throwable e) {
ConvertigoPlugin.logException(e, "Unable to change to Query parameter!");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject 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();
}
}
use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject in project convertigo by convertigo.
the class ChangeToAttributeStepAction 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();
// XMLAttribute
if ((databaseObject != null) && (databaseObject instanceof XMLAttributeStep)) {
XMLAttributeStep xmlAttributeStep = (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 Attribute step
AttributeStep attributeStep = new AttributeStep();
if (DatabaseObjectsManager.acceptDatabaseObjects(xmlAttributeStep.getParent(), attributeStep)) {
// Set properties
attributeStep.setOutput(xmlAttributeStep.isOutput());
attributeStep.setEnabled(xmlAttributeStep.isEnabled());
attributeStep.setComment(xmlAttributeStep.getComment());
// attributeStep.setExpression(elementStep.getExpression());
attributeStep.setNodeText(xmlAttributeStep.getNodeText());
attributeStep.setNodeName(xmlAttributeStep.getNodeName());
attributeStep.bNew = true;
attributeStep.hasChanged = true;
// Add new Attribute step to parent
DatabaseObject parentDbo = xmlAttributeStep.getParent();
parentDbo.add(attributeStep);
// Set correct order
if (parentDbo instanceof StepWithExpressions)
((StepWithExpressions) parentDbo).insertAtOrder(attributeStep, xmlAttributeStep.priority);
else if (parentDbo instanceof Sequence)
((Sequence) parentDbo).insertAtOrder(attributeStep, xmlAttributeStep.priority);
// Add new Attribute step in Tree
StepTreeObject stepTreeObject = new StepTreeObject(explorerView.viewer, xmlAttributeStep);
treeParent.addChild(stepTreeObject);
// Delete Element step
long oldPriority = xmlAttributeStep.priority;
xmlAttributeStep.delete();
attributeStep.getSequence().fireStepMoved(new StepEvent(attributeStep, String.valueOf(oldPriority)));
parentTreeObject.hasBeenModified(true);
explorerView.reloadTreeObject(parentTreeObject);
explorerView.setSelectedTreeObject(explorerView.findTreeObjectByUserObject(attributeStep));
} else {
throw new EngineException("You cannot paste to a " + xmlAttributeStep.getParent().getClass().getSimpleName() + " a database object of type " + attributeStep.getClass().getSimpleName());
}
}
}
// Element
if ((databaseObject != null) && (databaseObject instanceof ElementStep)) {
ElementStep elementStep = (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 Attribute step
AttributeStep attributeStep = new AttributeStep();
if (DatabaseObjectsManager.acceptDatabaseObjects(elementStep.getParent(), attributeStep)) {
// Set properties
attributeStep.setOutput(elementStep.isOutput());
attributeStep.setEnabled(elementStep.isEnabled());
attributeStep.setComment(elementStep.getComment());
attributeStep.setExpression(elementStep.getExpression());
attributeStep.setNodeText(elementStep.getNodeText());
attributeStep.setNodeName(elementStep.getNodeName());
attributeStep.bNew = true;
attributeStep.hasChanged = true;
// Add new Attribute step to parent
DatabaseObject parentDbo = elementStep.getParent();
parentDbo.add(attributeStep);
// Set correct order
if (parentDbo instanceof StepWithExpressions)
((StepWithExpressions) parentDbo).insertAtOrder(attributeStep, elementStep.priority);
else if (parentDbo instanceof Sequence)
((Sequence) parentDbo).insertAtOrder(attributeStep, elementStep.priority);
// Add new Attribute step in Tree
StepTreeObject stepTreeObject = new StepTreeObject(explorerView.viewer, elementStep);
treeParent.addChild(stepTreeObject);
// Delete Element step
long oldPriority = elementStep.priority;
elementStep.delete();
attributeStep.getSequence().fireStepMoved(new StepEvent(attributeStep, String.valueOf(oldPriority)));
parentTreeObject.hasBeenModified(true);
explorerView.reloadTreeObject(parentTreeObject);
explorerView.setSelectedTreeObject(explorerView.findTreeObjectByUserObject(attributeStep));
} else {
throw new EngineException("You cannot paste to a " + elementStep.getParent().getClass().getSimpleName() + " a database object of type " + attributeStep.getClass().getSimpleName());
}
}
}
}
} catch (Throwable e) {
ConvertigoPlugin.logException(e, "Unable to change to Attribute step!");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject in project convertigo by convertigo.
the class ChangeToBodyParameterAction 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();
Object databaseObject = treeObject.getObject();
if ((databaseObject != null) && (databaseObject instanceof UrlMappingParameter)) {
UrlMappingParameter parameter = (UrlMappingParameter) databaseObject;
TreeParent treeParent = treeObject.getParent();
DatabaseObjectTreeObject parentTreeObject = null;
if (treeParent instanceof DatabaseObjectTreeObject)
parentTreeObject = (DatabaseObjectTreeObject) treeParent;
else
parentTreeObject = (DatabaseObjectTreeObject) treeParent.getParent();
if (parentTreeObject != null) {
// Create new Body parameter
BodyParameter bodyParameter = new BodyParameter();
if (DatabaseObjectsManager.acceptDatabaseObjects(parameter.getParent(), bodyParameter)) {
bodyParameter.setComment(parameter.getComment());
bodyParameter.setArray(false);
bodyParameter.setExposed(parameter.isExposed());
bodyParameter.setMultiValued(false);
bodyParameter.setRequired(parameter.isRequired());
bodyParameter.setMappedVariableName(parameter.getMappedVariableName());
bodyParameter.bNew = true;
bodyParameter.hasChanged = true;
// Add new parameter to parent operation
UrlMappingOperation operation = (UrlMappingOperation) parameter.getParent();
operation.changeTo(bodyParameter);
// Add new parameter in Tree
UrlMappingParameterTreeObject parameterTreeObject = new UrlMappingParameterTreeObject(explorerView.viewer, bodyParameter);
treeParent.addChild(parameterTreeObject);
// Delete old parameter
parameter.delete();
// Rename new parameter
bodyParameter.setName(parameter.getName());
// Reload in tree
parentTreeObject.hasBeenModified(true);
explorerView.reloadTreeObject(parentTreeObject);
explorerView.setSelectedTreeObject(explorerView.findTreeObjectByUserObject(bodyParameter));
} else {
throw new EngineException("You cannot paste to a " + parameter.getParent().getClass().getSimpleName() + " a database object of type " + bodyParameter.getClass().getSimpleName());
}
}
}
}
} catch (Throwable e) {
ConvertigoPlugin.logException(e, "Unable to change to Body parameter!");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject in project convertigo by convertigo.
the class ChangeToElementStepAction method selectionChanged.
public void selectionChanged(IAction action, ISelection selection) {
try {
boolean enable = false;
super.selectionChanged(action, selection);
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
TreeObject treeObject = (TreeObject) structuredSelection.getFirstElement();
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