use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject in project convertigo by convertigo.
the class UnloadedProjectDeleteAction method run.
public void run() {
Display display = Display.getDefault();
Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
Shell shell = getParentShell();
shell.setCursor(waitCursor);
MultipleDeletionDialog dialog;
try {
ProjectExplorerView explorerView = getProjectExplorerView();
if (explorerView != null) {
TreeObject[] treeObjects = explorerView.getSelectedTreeObjects();
if (treeObjects.length == 1) {
dialog = new MultipleDeletionDialog(shell, "Project Deletion", false);
} else {
dialog = new MultipleDeletionDialog(shell, "Project Deletion", true);
}
dialog.setToggle("Delete project content on disk (cannot be undone)", false);
if (treeObjects != null && treeObjects.length > 0) {
for (TreeObject treeObject : treeObjects) {
if (treeObject instanceof UnloadedProjectTreeObject) {
String projectName = ((UnloadedProjectTreeObject) treeObject).getName();
if (dialog.shouldBeDeleted("Do you really want to delete the project \"" + projectName + "\" and all its sub-objects?")) {
// Deleted project will be backup, car will be deleted to avoid its deployment at engine restart
// Engine.theApp.databaseObjectsManager.deleteProject(projectName);
Job rmProject = new Job("Remove '" + projectName + "' project") {
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
if (dialog.getToggleState()) {
Engine.theApp.databaseObjectsManager.deleteProjectAndCar(projectName);
}
ConvertigoPlugin.getDefault().deleteProjectPluginResource(dialog.getToggleState(), projectName);
} catch (Exception e) {
ConvertigoPlugin.logException(e, "Unable to delete the '" + projectName + "' project.");
return new MultiStatus(ConvertigoPlugin.PLUGIN_UNIQUE_ID, IStatus.ERROR, "Failed to remove the '" + projectName + "' project.", e);
}
return Status.OK_STATUS;
}
};
rmProject.schedule();
explorerView.removeProjectTreeObject(treeObject);
explorerView.fireTreeObjectRemoved(new TreeObjectEvent(treeObject));
}
}
}
}
}
} catch (Throwable e) {
ConvertigoPlugin.logException(e, "Unable to delete the project!");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject in project convertigo by convertigo.
the class UpdateXSDTypesAction method selectionChanged.
public void selectionChanged(IAction action, ISelection selection) {
try {
super.selectionChanged(action, selection);
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
TreeObject treeObject = (TreeObject) structuredSelection.getFirstElement();
DatabaseObject dbo = (DatabaseObject) treeObject.getObject();
ActionModel actionModel = DatabaseObjectsAction.selectionChanged(getClass().getName(), dbo);
action.setEnabled(actionModel.isEnabled);
} catch (Exception e) {
}
}
use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject in project convertigo by convertigo.
the class VariableGenerateFromXmlAndLinkAction 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) {
TreeObject treeObject = explorerView.getFirstSelectedTreeObject();
Object databaseObject = treeObject.getObject();
if ((databaseObject != null) && ((databaseObject instanceof StepVariable))) {
StepVariable stepVariable = (StepVariable) databaseObject;
RequestableStep requestableStep = (RequestableStep) stepVariable.getParent();
if (requestableStep != null) {
DatabaseObjectTreeObject parentDboTreeObject = ((DatabaseObjectTreeObject) treeObject).getParentDatabaseObjectTreeObject().getParentDatabaseObjectTreeObject();
RequestableObject requestableObject = null;
if (requestableStep instanceof SequenceStep) {
requestableObject = ((SequenceStep) requestableStep).getTargetSequence();
} else if (requestableStep instanceof TransactionStep) {
requestableObject = ((TransactionStep) requestableStep).getTargetTransaction();
}
if ((requestableObject != null) && (requestableObject instanceof IVariableContainer)) {
String variableName = stepVariable.getName();
IVariableContainer container = (IVariableContainer) requestableObject;
RequestableVariable variable = (RequestableVariable) container.getVariable(variableName);
// generate dom model
Document document = null;
try {
String description = variable.getDescription();
document = XMLUtils.parseDOMFromString(description);
} catch (Exception e) {
}
if (document != null) {
Element root = document.getDocumentElement();
if (root != null) {
// create step's structure from dom
DatabaseObject parentObject = requestableStep.getParent();
Step step = StepUtils.createStepFromXmlDomModel(parentObject, root);
// add step's structure to parent of requestableStep
if (parentObject instanceof Sequence) {
Sequence parentSequence = (Sequence) parentObject;
parentSequence.addStep(step);
parentSequence.insertAtOrder(step, requestableStep.priority);
} else {
StepWithExpressions parentSwe = (StepWithExpressions) parentObject;
parentSwe.addStep(step);
parentSwe.insertAtOrder(step, requestableStep.priority);
}
// set source definition of variable
XMLVector<String> sourceDefinition = new XMLVector<String>();
sourceDefinition.add(String.valueOf(step.priority));
sourceDefinition.add(".");
stepVariable.setSourceDefinition(sourceDefinition);
stepVariable.hasChanged = true;
// Reload parent dbo in tree
explorerView.reloadTreeObject(parentDboTreeObject);
// Select variable dbo in tree
explorerView.objectSelected(new CompositeEvent(databaseObject));
}
}
}
}
}
}
} catch (Throwable e) {
ConvertigoPlugin.logException(e, "Unable to generate and link variable!");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject in project convertigo by convertigo.
the class SetMobileRootPageAction method selectionChanged.
public void selectionChanged(IAction action, ISelection selection) {
super.selectionChanged(action, selection);
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
TreeObject treeObject = (TreeObject) structuredSelection.getFirstElement();
if (treeObject instanceof MobilePageComponentTreeObject) {
DatabaseObject dbo = (DatabaseObject) treeObject.getObject();
ActionModel actionModel = DatabaseObjectsAction.selectionChanged(getClass().getName(), dbo);
action.setChecked(actionModel.isChecked);
}
}
use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject in project convertigo by convertigo.
the class ShowStepInPickerAction 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) {
TreeObject treeObject = explorerView.getFirstSelectedTreeObject();
if (treeObject != null) {
if (treeObject instanceof DatabaseObjectTreeObject) {
DatabaseObject selectedDbo = ((DatabaseObjectTreeObject) treeObject).getObject();
if (selectedDbo != null) {
StepSourceEvent event = null;
if (showSource) {
if (selectedDbo instanceof Step) {
Step step = (Step) selectedDbo;
Set<StepSource> sources = step.getSources();
if (!sources.isEmpty()) {
event = new StepSourceEvent(sources.iterator().next());
} else {
throw new Exception("No Source defined");
}
}
} else {
event = new StepSourceEvent(selectedDbo);
}
if (event != null) {
SourcePickerView spv = ConvertigoPlugin.getDefault().getSourcePickerView();
if (spv == null) {
spv = (SourcePickerView) getActivePage().showView("com.twinsoft.convertigo.eclipse.views.sourcepicker.SourcePickerView");
}
if (spv != null) {
spv.sourceSelected(event);
}
}
}
}
}
}
} catch (Throwable e) {
ConvertigoPlugin.logException(e, "Unable to show object in Picker!");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
Aggregations