use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableTreeObject in project convertigo by convertigo.
the class ProjectExplorerView method findTreeObjectByPath.
// private void loadTrace(TreeParent parentTreeObject, File dir) {
// FolderTreeObject folderTreeObject = new FolderTreeObject(viewer, "Traces");
// parentTreeObject.addChild(folderTreeObject);
//
// if (!dir.exists()) {
// if (!dir.mkdir())
// return;
// }
// File[] files = dir.listFiles(new FilenameFilter() {
// public boolean accept(File dir, String name) {
// if (new File(dir, name).isFile() && (name.endsWith(".etr"))) return true;
// return false;
// }
// });
// if (files == null) return;
//
// File file;
// TraceTreeObject traceTreeObject;
// for (int i = 0; i < files.length; i++) {
// file = files[i];
// traceTreeObject = new TraceTreeObject(viewer, file);
// folderTreeObject.addChild(traceTreeObject);
// }
// }
public TreeObject findTreeObjectByPath(TreeParent treeParent, String path) {
TreeObject foundObject = null;
if (treeParent == null)
return null;
String treeParentPath = treeParent.getPath();
if (treeParentPath.length() > path.length())
return null;
if (treeParent instanceof DatabaseObjectTreeObject) {
if (((DatabaseObjectTreeObject) treeParent).isInherited)
return null;
}
if (treeParent instanceof PropertyTableTreeObject) {
if (((PropertyTableTreeObject) treeParent).isInherited())
return null;
}
if (treeParentPath.equals(path))
return treeParent;
for (TreeObject treeObject : treeParent.getChildren()) {
if (treeObject instanceof TreeParent) {
foundObject = findTreeObjectByPath((TreeParent) treeObject, path);
if (foundObject != null)
break;
} else if (treeObject.getPath().equals(path)) {
foundObject = treeObject;
break;
}
}
return foundObject;
}
use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableTreeObject 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;
}
use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableTreeObject in project convertigo by convertigo.
the class ViewLabelProvider method getImage.
@Override
public Image getImage(Object obj) {
try {
String iconName = "/com/twinsoft/convertigo/beans/core/images/default_color_16x16.png";
Image image = null;
if (obj instanceof UnloadedProjectTreeObject) {
String imageKey = org.eclipse.ui.ide.IDE.SharedImages.IMG_OBJ_PROJECT_CLOSED;
image = PlatformUI.getWorkbench().getSharedImages().getImage(imageKey);
} else if (obj instanceof ResourceTreeObject) {
ILabelProvider workbenchLabelProvider = WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider();
image = workbenchLabelProvider.getImage(obj);
} else if (obj instanceof FolderTreeObject) {
String imageKey = ISharedImages.IMG_OBJ_FOLDER;
image = PlatformUI.getWorkbench().getSharedImages().getImage(imageKey);
FolderTreeObject t_folder = (FolderTreeObject) obj;
if (t_folder.getParent() instanceof DatabaseObjectTreeObject) {
DatabaseObjectTreeObject parent = (DatabaseObjectTreeObject) t_folder.getParent();
if (!parent.isEnabled())
image = ViewImageProvider.getImageFromCache(imageKey + "_disable", image, obj);
else if (parent.hasAncestorDisabled())
image = ViewImageProvider.getImageFromCache(imageKey + "_unreachable", image, obj);
}
} else if (obj instanceof TemplateTreeObject) {
String imageKey = ISharedImages.IMG_OBJ_FILE;
image = PlatformUI.getWorkbench().getSharedImages().getImage(imageKey);
} else if (obj instanceof HandlersDeclarationTreeObject) {
String imageKey = ISharedImages.IMG_OBJ_ELEMENT;
image = PlatformUI.getWorkbench().getSharedImages().getImage(imageKey);
} else if (obj instanceof TraceTreeObject) {
String imageKey = ISharedImages.IMG_OBJ_ELEMENT;
image = PlatformUI.getWorkbench().getSharedImages().getImage(imageKey);
} else if (obj instanceof VariableTreeObject2) {
VariableTreeObject2 variableTreeObject = (VariableTreeObject2) obj;
iconName = MySimpleBeanInfo.getIconName(variableTreeObject.databaseObjectBeanInfo, BeanInfo.ICON_COLOR_16x16);
if (iconName == null) {
iconName = "/com/twinsoft/convertigo/beans/core/images/variable_color_16x16.png";
}
image = ViewImageProvider.getImageFromCache(iconName, variableTreeObject);
} else if (obj instanceof DatabaseObjectTreeObject) {
DatabaseObjectTreeObject databaseObjectTreeObject = (DatabaseObjectTreeObject) obj;
iconName = MySimpleBeanInfo.getIconName(databaseObjectTreeObject.getObject(), BeanInfo.ICON_COLOR_16x16);
image = ViewImageProvider.getImageFromCache(iconName, databaseObjectTreeObject);
} else if (obj instanceof PropertyTableTreeObject) {
iconName = "/com/twinsoft/convertigo/beans/core/images/bean_property_16x16.png";
image = ViewImageProvider.getImageFromCache(iconName, (PropertyTableTreeObject) obj);
} else if (obj instanceof PropertyTableRowTreeObject) {
iconName = "/com/twinsoft/convertigo/beans/core/images/bean_property_16x16.png";
image = ViewImageProvider.getImageFromCache(iconName, (PropertyTableRowTreeObject) obj);
} else if (obj instanceof PropertyTableColumnTreeObject) {
iconName = "/com/twinsoft/convertigo/beans/core/images/bean_property_16x16.png";
image = ViewImageProvider.getImageFromCache(iconName, (PropertyTableColumnTreeObject) obj);
} else if (obj instanceof DesignDocumentViewTreeObject) {
iconName = "/com/twinsoft/convertigo/beans/couchdb/images/view_color_16x16.png";
image = ViewImageProvider.getImageFromCache(iconName, (DesignDocumentViewTreeObject) obj);
} else if (obj instanceof DesignDocumentFunctionTreeObject) {
iconName = "/com/twinsoft/convertigo/beans/couchdb/images/function_color_16x16.png";
image = ViewImageProvider.getImageFromCache(iconName, (DesignDocumentFunctionTreeObject) obj);
} else {
throw new IllegalArgumentException("Unexpected tree item object");
}
return image;
} catch (Exception e) {
String message = "Error while getting tree view item image for object [" + obj.getClass().getName() + "] " + obj.toString();
ConvertigoPlugin.logException(e, message);
String imageKey = ISharedImages.IMG_OBJ_ELEMENT;
if (obj instanceof TreeParent) {
imageKey = ISharedImages.IMG_OBJ_FOLDER;
}
return PlatformUI.getWorkbench().getSharedImages().getImage(imageKey);
}
}
use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableTreeObject 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);
}
}
}
}
}
Aggregations