use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableRowTreeObject in project convertigo by convertigo.
the class TreeObjectSorter method compare.
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
if ((e1 instanceof DatabaseObjectTreeObject) && (e2 instanceof DatabaseObjectTreeObject)) {
DatabaseObject d1 = ((DatabaseObjectTreeObject) e1).getObject();
DatabaseObject d2 = ((DatabaseObjectTreeObject) e2).getObject();
DatabaseObjectTreeObject p1 = ((DatabaseObjectTreeObject) e1).getOwnerDatabaseObjectTreeObject();
DatabaseObjectTreeObject p2 = ((DatabaseObjectTreeObject) e2).getOwnerDatabaseObjectTreeObject();
if (p1.equals(p2)) {
DatabaseObject p = (DatabaseObject) p1.getObject();
try {
Object o1 = p.getOrder(d1);
Object o2 = p.getOrder(d2);
if ((o1 instanceof Long) && (o2 instanceof Long)) {
long l1 = ((Long) o1).longValue();
long l2 = ((Long) o2).longValue();
int dp = (int) (l1 - l2);
if (dp != 0)
return dp;
}
} catch (EngineException e) {
ConvertigoPlugin.logException(e, "Error while sorting objects \"" + d1.getQName() + "\" and \"" + d2.getQName() + "\" in Tree.");
}
}
} else if ((e1 instanceof PropertyTableRowTreeObject) && (e2 instanceof PropertyTableRowTreeObject)) {
PropertyTableRowTreeObject r1 = (PropertyTableRowTreeObject) e1;
PropertyTableRowTreeObject r2 = (PropertyTableRowTreeObject) e2;
int i1 = r1.getParent().indexOf(r1);
int i2 = r2.getParent().indexOf(r2);
return i1 - i2;
} else if ((e1 instanceof PropertyTableColumnTreeObject) && (e2 instanceof PropertyTableColumnTreeObject)) {
PropertyTableColumnTreeObject c1 = (PropertyTableColumnTreeObject) e1;
PropertyTableColumnTreeObject c2 = (PropertyTableColumnTreeObject) e2;
int i1 = c1.getParent().indexOf(c1);
int i2 = c2.getParent().indexOf(c2);
return i1 - i2;
} else if ((e1 instanceof ObjectsFolderTreeObject) && !(e2 instanceof ObjectsFolderTreeObject)) {
return -1;
} else if (!(e1 instanceof ObjectsFolderTreeObject) && (e2 instanceof ObjectsFolderTreeObject)) {
return 1;
}
return super.compare(viewer, e1, e2);
}
use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableRowTreeObject 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.model.PropertyTableRowTreeObject in project convertigo by convertigo.
the class CreatePropertyTableColumnAction 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 PropertyTableRowTreeObject) {
action.setText(((PropertyTableRowTreeObject) treeObject).getColumnDefaultLabel());
}
}
use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableRowTreeObject in project convertigo by convertigo.
the class CreatePropertyTableColumnAction 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) {
PropertyTableRowTreeObject propertyTableRowTreeObject = (PropertyTableRowTreeObject) explorerView.getFirstSelectedTreeObject();
TreeParent owner = propertyTableRowTreeObject.getTreeObjectOwner();
IPropertyTreeObject pto = propertyTableRowTreeObject.addNewColumn();
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 column!");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableRowTreeObject in project convertigo by convertigo.
the class ViewImageProvider method getImageData.
/**
* Dispose all loaded images
*/
/*public static void dispose() {
String imageName = null;
Image image = null;
for (Enumeration e = imagesCache.keys(); e.hasMoreElements(); ) {
imageName = (String) e.nextElement();
if (imageName != null) {
image = (Image) imagesCache.get(imageName);
imagesCache.put(imageName, null);
}
if (image != null)
image.dispose();
}
}*/
private static ImageData getImageData(Image image, Object object) {
ImageData imageData = image.getImageData();
DatabaseObjectTreeObject databaseObjectTreeObject = null;
if (object instanceof DatabaseObjectTreeObject) {
databaseObjectTreeObject = (DatabaseObjectTreeObject) object;
} else if (object instanceof PropertyTableTreeObject) {
PropertyTableTreeObject table = (PropertyTableTreeObject) object;
if (table != null) {
databaseObjectTreeObject = (DatabaseObjectTreeObject) table.getTreeObjectOwner();
}
} else if (object instanceof PropertyTableRowTreeObject) {
PropertyTableTreeObject table = ((PropertyTableRowTreeObject) object).getParentTable();
if (table != null) {
databaseObjectTreeObject = (DatabaseObjectTreeObject) table.getTreeObjectOwner();
}
} else if (object instanceof PropertyTableColumnTreeObject) {
PropertyTableTreeObject table = ((PropertyTableColumnTreeObject) object).getParentTable();
if (table != null) {
databaseObjectTreeObject = (DatabaseObjectTreeObject) table.getTreeObjectOwner();
}
} else if (object instanceof FolderTreeObject) {
FolderTreeObject t_folder = (FolderTreeObject) object;
if (t_folder.getParent() instanceof DatabaseObjectTreeObject) {
databaseObjectTreeObject = (DatabaseObjectTreeObject) t_folder.getParent();
}
} else if (object instanceof DesignDocumentViewTreeObject) {
DesignDocumentViewTreeObject ddvto = (DesignDocumentViewTreeObject) object;
if (ddvto != null) {
databaseObjectTreeObject = (DatabaseObjectTreeObject) ddvto.getTreeObjectOwner();
}
} else if (object instanceof DesignDocumentFunctionTreeObject) {
DesignDocumentFunctionTreeObject ddfto = (DesignDocumentFunctionTreeObject) object;
if (ddfto != null) {
databaseObjectTreeObject = (DatabaseObjectTreeObject) ddfto.getTreeObjectOwner();
}
}
if (databaseObjectTreeObject != null) {
// GIF style
if (imageData.palette.colors != null) {
for (int i = 0; i < imageData.palette.colors.length; i++) {
if (i != imageData.transparentPixel) {
RGB rgb = imageData.palette.colors[i];
imageData.palette.colors[i] = changeHue(rgb, databaseObjectTreeObject);
}
}
} else // PNG style and Linux
{
for (int i = 0; i < imageData.height; i++) {
for (int j = 0; j < imageData.width; j++) {
RGB rgb = imageData.palette.getRGB(imageData.getPixel(j, i));
imageData.setPixel(j, i, imageData.palette.getPixel(changeHue(rgb, databaseObjectTreeObject)));
}
}
}
}
return imageData;
}
Aggregations