Files
VisualSapfor/src/ProjectData/Project/UI/VersionsTreeCellRenderer.java

76 lines
3.1 KiB
Java
Raw Normal View History

2023-09-17 22:13:42 +03:00
package ProjectData.Project.UI;
2024-10-08 22:33:49 +03:00
import Common.Visual.CommonUI;
import Common_old.Current;
import _VisualDVM.Global;
2024-10-07 17:46:38 +03:00
import Common.Visual.Selectable;
2024-10-08 22:33:49 +03:00
import Common.Visual.Fonts.VisualiserFonts;
import Common_old.UI.Trees.StyledTreeCellRenderer;
2023-09-17 22:13:42 +03:00
import ProjectData.Project.db_project_info;
import javax.swing.*;
import javax.swing.tree.DefaultMutableTreeNode;
import java.net.URL;
//https://docs.oracle.com/javase/7/docs/api/javax/swing/tree/DefaultMutableTreeNode.html
//https://java.hotexamples.com/ru/examples/java.awt/JTree/-/java-jtree-class-examples.html
public class VersionsTreeCellRenderer extends StyledTreeCellRenderer {
public java.awt.Component getTreeCellRendererComponent(
JTree tree, Object value,
boolean selected, boolean expanded,
boolean leaf, int row, boolean hasFocus) {
super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
Object o = ((DefaultMutableTreeNode) value).getUserObject();
db_project_info version = (db_project_info) o;
if (Global.versions_multiselection) {
setIcon(((Selectable) o).GetSelectionIcon());
} else {
URL imageUrl = null;
boolean current = Current.HasProject() && version.Home.equals(Current.getProject().Home);
String type_image_key = "";
if (version.Home.equals(Current.getRoot().Home))
type_image_key = "Root";
else if (version.IsMCopy())
type_image_key = "M";
else
type_image_key = "Version";
if (current)
type_image_key = "current" + type_image_key;
imageUrl = getClass().getResource("/icons/versions/" +
type_image_key +
".png");
if (imageUrl != null) {
setIcon(new ImageIcon(imageUrl));
}
}
setForeground(tree.getForeground());
2024-10-08 22:33:49 +03:00
setFont(CommonUI.getTheme().Fonts.get(
2023-09-17 22:13:42 +03:00
version.isNew ? VisualiserFonts.NewVersion : VisualiserFonts.TreePlain));
setText(version.getTitle());
return this;
}
/*
Fonts.put(VisualiserFonts.Version, new Font(
new HashMap<TextAttribute, Object>() {
{
put(TextAttribute.FAMILY, "Times New Roman");
put(TextAttribute.FOREGROUND, Color.BLACK);
put(TextAttribute.BACKGROUND, Color.WHITE);
put(TextAttribute.SIZE, 14);
}
}
));
Fonts.put(VisualiserFonts.NewVersion, new Font(
new HashMap<TextAttribute, Object>() {
{
put(TextAttribute.FAMILY, "Times New Roman");
put(TextAttribute.FOREGROUND, Color.BLACK);
put(TextAttribute.BACKGROUND, Color.YELLOW);
put(TextAttribute.SIZE, 14);
}
}
));
*/
}