use of com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeParent in project convertigo by convertigo.
the class DatabaseObjectDecreasePriorityAction 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 {
treeNodesToUpdate = new ArrayList<TreeParent>();
ProjectExplorerView explorerView = getProjectExplorerView();
if (explorerView != null) {
TreeObject[] treeObjects = explorerView.getSelectedTreeObjects();
String[] selectedPaths = new String[treeObjects.length];
if (treeObjects != null) {
// Decrease priority
TreeObject treeObject = null;
for (int i = treeObjects.length - 1; i >= 0; i--) {
treeObject = treeObjects[i];
selectedPaths[i] = treeObject.getPath();
decreasePriority(treeObject);
}
// Updating the tree and the properties panel
Enumeration<TreeParent> enumeration = Collections.enumeration(treeNodesToUpdate);
TreeParent parentTreeObject = null;
while (enumeration.hasMoreElements()) {
parentTreeObject = enumeration.nextElement();
explorerView.reloadTreeObject(parentTreeObject);
}
// Restore selection
TreeObjectEvent treeObjectEvent;
for (int i = 0; i < selectedPaths.length; i++) {
String previousPath = selectedPaths[i];
treeObject = explorerView.findTreeObjectByPath(parentTreeObject, previousPath);
if (treeObject != null) {
treeObjects[i] = treeObject;
treeObjectEvent = new TreeObjectEvent(treeObject);
explorerView.fireTreeObjectPropertyChanged(treeObjectEvent);
}
}
explorerView.setSelectedTreeObjects(treeObjects);
}
}
} catch (Throwable e) {
ConvertigoPlugin.logException(e, "Unable to decrease priority!");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
use of com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeParent in project convertigo by convertigo.
the class DatabaseObjectDecreasePriorityAction method decreasePriority.
private void decreasePriority(TreeObject treeObject) throws EngineException {
int count = counter;
if (treeObject instanceof DatabaseObjectTreeObject) {
DatabaseObject databaseObject = (DatabaseObject) treeObject.getObject();
DatabaseObject parent = databaseObject.getParent();
if (parent != null && parent instanceof IContainerOrdered) {
IContainerOrdered containerOrdered = (IContainerOrdered) parent;
while (count-- > 0) {
containerOrdered.decreasePriority(databaseObject);
}
if (parent.hasChanged) {
DatabaseObjectTreeObject parentTreeObject = null;
TreeParent treeParent = treeObject.getParent();
if (treeParent instanceof FolderTreeObject) {
parentTreeObject = (DatabaseObjectTreeObject) treeParent.getParent();
} else {
parentTreeObject = (DatabaseObjectTreeObject) treeParent;
}
if (!treeNodesToUpdate.contains(parentTreeObject)) {
treeNodesToUpdate.add(parentTreeObject);
}
}
}
} else {
DatabaseObjectTreeObject databaseObjectTreeObject = null;
if (treeObject instanceof PropertyTableRowTreeObject) {
PropertyTableTreeObject propertyTableTreeObject = (PropertyTableTreeObject) treeObject.getParent();
while (count-- > 0) {
if ((treeObject = propertyTableTreeObject.moveRow((PropertyTableRowTreeObject) treeObject, false)) != null) {
databaseObjectTreeObject = (DatabaseObjectTreeObject) propertyTableTreeObject.getParent();
}
}
} else if (treeObject instanceof PropertyTableColumnTreeObject) {
PropertyTableRowTreeObject propertyTableRowTreeObject = (PropertyTableRowTreeObject) treeObject.getParent();
PropertyTableTreeObject propertyTableTreeObject = (PropertyTableTreeObject) propertyTableRowTreeObject.getParent();
while (count-- > 0) {
if ((treeObject = propertyTableRowTreeObject.moveColumn((PropertyTableColumnTreeObject) treeObject, false)) != null) {
databaseObjectTreeObject = (DatabaseObjectTreeObject) propertyTableTreeObject.getParent();
}
}
}
if (databaseObjectTreeObject != null) {
if (databaseObjectTreeObject.hasChanged()) {
DatabaseObjectTreeObject parentTreeObject = null;
TreeParent treeParent = databaseObjectTreeObject.getParent();
if (treeParent instanceof FolderTreeObject)
parentTreeObject = (DatabaseObjectTreeObject) treeParent.getParent();
else
parentTreeObject = (DatabaseObjectTreeObject) treeParent;
if (!treeNodesToUpdate.contains(parentTreeObject)) {
treeNodesToUpdate.add(parentTreeObject);
}
}
}
}
}
use of com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeParent in project convertigo by convertigo.
the class DatabaseObjectDeleteAction method delete.
private void delete(DatabaseObjectTreeObject treeObject) throws CoreException, ConvertigoException {
DatabaseObjectTreeObject parentTreeObject = null;
TreeParent treeParent = treeObject.getParent();
DatabaseObject databaseObject = (DatabaseObject) treeObject.getObject();
DatabaseObject parent = databaseObject.getParent();
while ((treeParent != null) && (!(treeParent instanceof DatabaseObjectTreeObject))) {
treeParent = treeParent.getParent();
}
if (treeParent != null) {
parentTreeObject = (DatabaseObjectTreeObject) treeParent;
}
delete(databaseObject, false);
// Do not save after a deletion anymore
if (parent != null) {
parentTreeObject.hasBeenModified(true);
}
if ((parentTreeObject != null) && !treeNodesToUpdate.contains(parentTreeObject)) {
treeNodesToUpdate.add(parentTreeObject);
}
}
Aggregations