2024-10-09 22:21:57 +03:00
|
|
|
package _VisualDVM.ProjectData.Project.UI;
|
2024-10-11 00:00:30 +03:00
|
|
|
import Common.Visual.UI_;
|
2024-10-09 22:01:19 +03:00
|
|
|
import _VisualDVM.Current;
|
2024-10-07 00:58:29 +03:00
|
|
|
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;
|
2024-10-09 20:35:18 +03:00
|
|
|
import Common.Visual.Trees.StyledTreeCellRenderer;
|
2024-10-09 22:21:57 +03:00
|
|
|
import _VisualDVM.ProjectData.Project.db_project_info;
|
2023-09-17 22:13:42 +03:00
|
|
|
|
|
|
|
|
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-11 00:00:30 +03:00
|
|
|
setFont(UI_.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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
));
|
|
|
|
|
*/
|
|
|
|
|
}
|