14 |
14 |
import javax.swing.tree.TreeCellRenderer;
|
15 |
15 |
|
16 |
16 |
import es.unex.sextante.core.GeoAlgorithm;
|
|
17 |
import es.unex.sextante.gui.core.HasIcon;
|
17 |
18 |
import es.unex.sextante.gui.core.IAlgorithmProvider;
|
18 |
19 |
import es.unex.sextante.gui.core.NameAndIcon;
|
19 |
20 |
import es.unex.sextante.gui.core.SextanteGUI;
|
... | ... | |
35 |
36 |
}
|
36 |
37 |
|
37 |
38 |
|
38 |
|
protected Icon getCustomIcon(final Object value) {
|
|
39 |
protected Icon getCustomIcon(final Object value) {
|
39 |
40 |
|
40 |
|
final ArrayList<IAlgorithmProvider> providers = SextanteGUI.getAlgorithmProviders();
|
41 |
|
final HashMap<NameAndIcon, ArrayList<ToolboxAction>> allActions = SextanteGUI.getToolboxActions();
|
|
41 |
final ArrayList<IAlgorithmProvider> providers = SextanteGUI.getAlgorithmProviders();
|
|
42 |
final HashMap<NameAndIcon, ArrayList<ToolboxAction>> allActions = SextanteGUI.getToolboxActions();
|
42 |
43 |
|
43 |
|
final Object obj = ((DefaultMutableTreeNode) value).getUserObject();
|
|
44 |
final Object obj = ((DefaultMutableTreeNode) value).getUserObject();
|
44 |
45 |
|
45 |
|
if (obj instanceof GeoAlgorithm) {
|
46 |
|
return SextanteGUI.getAlgorithmIcon((GeoAlgorithm) obj);
|
47 |
|
}
|
48 |
|
else if (obj instanceof NameAndIcon) {
|
49 |
|
return ((NameAndIcon) obj).getIcon();
|
50 |
|
}
|
51 |
|
else if (obj instanceof ToolboxAction) {
|
52 |
|
final Set<NameAndIcon> set = allActions.keySet();
|
53 |
|
final Iterator<NameAndIcon> iter = set.iterator();
|
54 |
|
while (iter.hasNext()) {
|
55 |
|
final NameAndIcon nai = iter.next();
|
56 |
|
final ArrayList<ToolboxAction> actions = allActions.get(nai);
|
57 |
|
for (int i = 0; i < actions.size(); i++) {
|
58 |
|
if (obj.getClass().equals(actions.get(i).getClass())) {
|
59 |
|
return nai.getIcon();
|
60 |
|
}
|
|
46 |
if (obj instanceof HasIcon) {
|
|
47 |
return ((HasIcon) obj).getIcon();
|
|
48 |
}
|
|
49 |
if (obj instanceof GeoAlgorithm) {
|
|
50 |
return SextanteGUI.getAlgorithmIcon((GeoAlgorithm) obj);
|
|
51 |
}
|
|
52 |
// if (obj instanceof NameAndIcon) {
|
|
53 |
// return ((NameAndIcon) obj).getIcon();
|
|
54 |
// }
|
|
55 |
if (obj instanceof ToolboxAction) {
|
|
56 |
final Set<NameAndIcon> set = allActions.keySet();
|
|
57 |
final Iterator<NameAndIcon> iter = set.iterator();
|
|
58 |
while (iter.hasNext()) {
|
|
59 |
final NameAndIcon nai = iter.next();
|
|
60 |
final ArrayList<ToolboxAction> actions = allActions.get(nai);
|
|
61 |
for (int i = 0; i < actions.size(); i++) {
|
|
62 |
if (obj.getClass().equals(actions.get(i).getClass())) {
|
|
63 |
return nai.getIcon();
|
|
64 |
}
|
|
65 |
}
|
61 |
66 |
}
|
62 |
|
}
|
63 |
|
return null;
|
64 |
|
}
|
65 |
|
else {
|
66 |
|
for (int i = 0; i < providers.size(); i++) {
|
|
67 |
return null;
|
|
68 |
}
|
|
69 |
|
|
70 |
for (int i = 0; i < providers.size(); i++) {
|
67 |
71 |
if (value.toString().equals(providers.get(i).getName())) {
|
68 |
|
return providers.get(i).getIcon();
|
|
72 |
return providers.get(i).getIcon();
|
69 |
73 |
}
|
70 |
|
}
|
71 |
|
if (value.toString().equals("SEXTANTE")) {
|
|
74 |
}
|
|
75 |
if (value.toString().equals("SEXTANTE")) {
|
72 |
76 |
return SextanteGUI.SEXTANTE_ICON;
|
73 |
|
}
|
74 |
|
return null;
|
75 |
|
}
|
|
77 |
}
|
|
78 |
return null;
|
76 |
79 |
|
77 |
|
}
|
|
80 |
}
|
78 |
81 |
|
79 |
82 |
|
80 |
83 |
public Component getTreeCellRendererComponent(final JTree tree,
|