Font font = super.getFont();
return font == null ? UIUtil.getTreeFont() : font;
}
public void customizeCellRenderer(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
BrowserTreeNode treeNode = (BrowserTreeNode) value;
setIcon(treeNode.getIcon(0));
boolean isLoading = false;
String displayName;
if (treeNode instanceof ModuleConnectionBundle) {
ModuleConnectionBundle connectionManager = (ModuleConnectionBundle) treeNode;
displayName = connectionManager.getModule().getName();
} else if (treeNode instanceof ProjectConnectionBundle) {
displayName = "PROJECT";
} else {
displayName = treeNode.getPresentableText();
}
if (treeNode instanceof DBObjectList) {
DBObjectList objectsList = (DBObjectList) treeNode;
boolean isEmpty = objectsList.getTreeChildCount() == 0;
isLoading = objectsList.isLoading();
SimpleTextAttributes textAttributes =
isLoading ? SimpleTextAttributes.GRAY_ITALIC_ATTRIBUTES :
isEmpty ? SimpleTextAttributes.REGULAR_ATTRIBUTES :
SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES;
append(displayName, textAttributes);
// todo display load error
/*
SimpleTextAttributes descriptionTA = objectsList.getErrorMessage() == null ?
SimpleTextAttributes.GRAY_ATTRIBUTES : SimpleTextAttributes.ERROR_ATTRIBUTES;
append(" " + displayDetails, descriptionTA);
if (objectsList.getErrorMessage() != null) {
String msg = "Could not load " + displayName + ". Cause: " + objectsList.getErrorMessage();
setToolTipText(msg);
} else {
setToolTipText(null);
}
*/
} else {
boolean showBold = false;
boolean isError = false;
if (treeNode instanceof DBObject) {
DBObject object = (DBObject) treeNode;
if (object.isOfType(DBObjectType.SCHEMA)) {
DBSchema schema = (DBSchema) object;
showBold = schema.isUserSchema();
}
isError = !object.isValid();
}
SimpleTextAttributes textAttributes =
isError ? SimpleTextAttributes.ERROR_ATTRIBUTES :
showBold ? SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES :
SimpleTextAttributes.REGULAR_ATTRIBUTES;
if (displayName == null) displayName = "displayName null!!";
append(displayName, textAttributes);
}
String displayDetails = treeNode.getPresentableTextDetails();
if (!StringUtil.isEmptyOrSpaces(displayDetails)) {
append(" " + displayDetails, isLoading ? SimpleTextAttributes.GRAY_ITALIC_ATTRIBUTES : SimpleTextAttributes.GRAY_ATTRIBUTES);
}
if (browserSettings.getGeneralSettings().getShowObjectDetails().value()) {
String conditionalDetails = treeNode.getPresentableTextConditionalDetails();
if (!StringUtil.isEmptyOrSpaces(conditionalDetails)) {
append(" - " + conditionalDetails, SimpleTextAttributes.GRAY_ATTRIBUTES);
}
}