1 package net.sf.mmapps.applications.developer.project;
2
3 import java.awt.Component;
4
5 import javax.swing.*;
6 import javax.swing.tree.DefaultTreeCellRenderer;
7
8 public class ProjectCelRenderer extends DefaultTreeCellRenderer {
9 ImageIcon cloudListIcon;
10 ImageIcon contextIcon;
11 ImageIcon cloudIcon;
12 ImageIcon nodeIcon;
13 ImageIcon nodeManagerIcon;
14 ImageIcon relationIcon;
15 ImageIcon relationManagerIcon;
16 ImageIcon moduleIcon;
17
18 public ProjectCelRenderer() {
19 super();
20 cloudListIcon = new ImageIcon(ProjectCelRenderer.class.getResource("resources/cloudlist.gif"));
21 contextIcon = new ImageIcon(ProjectCelRenderer.class.getResource("resources/context.gif"));
22 cloudIcon = new ImageIcon(ProjectCelRenderer.class.getResource("resources/cloud.gif"));
23 nodeIcon = new ImageIcon(ProjectCelRenderer.class.getResource("resources/node.gif"));
24 nodeManagerIcon = new ImageIcon(ProjectCelRenderer.class.getResource("resources/nodeManager.gif"));
25 relationIcon = new ImageIcon(ProjectCelRenderer.class.getResource("resources/relation.gif"));
26 relationManagerIcon = new ImageIcon(ProjectCelRenderer.class.getResource("resources/relationManager.gif"));
27 moduleIcon = new ImageIcon(ProjectCelRenderer.class.getResource("resources/module.gif"));
28 }
29
30 public Component getTreeCellRendererComponent(
31 JTree tree,
32 Object value,
33 boolean sel,
34 boolean expanded,
35 boolean leaf,
36 int row,
37 boolean hasFocus) {
38
39 super.getTreeCellRendererComponent( tree, value, sel, expanded, leaf, row, hasFocus);
40
41 if (value instanceof ProjectMutableTreeNode){
42 ProjectMutableTreeNode myNode = (ProjectMutableTreeNode)value;
43 int type = myNode.getType();
44 if (type == ProjectMutableTreeNode.PROJECT_TYPE_NODEMANAGER){
45 setIcon(nodeManagerIcon);
46 } else if (type == ProjectMutableTreeNode.PROJECT_TYPE_APPLICATION){
47 setIcon(cloudIcon);
48 } else {
49
50 }
51 }
52 return this;
53 }
54 }