1 package org.enhydra.shark.corbaclient.workflowadmin; 2 3 import java.awt.*; 4 5 import javax.swing.*; 6 import javax.swing.tree.*; 7 8 import org.omg.WorkflowModel.*; 9 import org.enhydra.shark.corbaclient.*; 10 11 15 public class EngineTreeRenderer extends DefaultTreeCellRenderer { 16 17 public Component getTreeCellRendererComponent( 18 JTree tree, 19 Object value, 20 boolean sel, 21 boolean expanded, 22 boolean leaf, 23 int row, 24 boolean hasFocus) { 25 26 super.getTreeCellRendererComponent( 27 tree, value, sel, 28 expanded, leaf, row, 29 hasFocus); 30 31 int type=getUserObjectType(value); 32 33 switch (type) { 34 case 0: 35 try { 36 javax.swing.Icon image = new ImageIcon( 37 ResourceManager.getResource("openedpackagesTreeImage")); 38 setIcon(image); 39 } catch (Throwable t) { 40 setIcon(null); 41 } 42 break; 43 case 1: 44 try { 45 javax.swing.Icon image = new ImageIcon( 46 ResourceManager.getResource("packageTreeImage")); 47 setIcon(image); 48 } catch (Throwable t) { 49 setIcon(null); 50 } finally { 51 org.enhydra.jawe.xml.elements.Package pkg= 52 (org.enhydra.jawe.xml.elements.Package) 53 ((DefaultMutableTreeNode)value).getUserObject(); 54 String disp=ResourceManager. 55 getLanguageDependentString("PackageKey")+"-"+pkg.toString(); 56 setText(disp); 57 setToolTipText(disp); 58 } 59 break; 60 case 2: 61 try { 62 javax.swing.Icon image = new ImageIcon( 63 ResourceManager.getResource("managerTreeImage")); 64 setIcon(image); 65 } catch (Throwable t) { 66 setIcon(null); 67 } finally { 68 WfProcessMgr mgr=(WfProcessMgr)((DefaultMutableTreeNode)value).getUserObject(); 69 String name; 70 try { 71 name=SharkAdmin.getAdminMiscUtilities().getProcessMgrProcDefName(mgr.name()); 72 } catch (Exception ex) { 73 name=ResourceManager.getLanguageDependentString("UnknownKey"); 74 } 75 String disp=ResourceManager. 76 getLanguageDependentString("ProcessDefinitionKey")+"-"+name; 77 setText(disp); 78 setToolTipText(disp); 79 } 80 break; 81 case 3: 82 try { 83 javax.swing.Icon image = new ImageIcon( 84 ResourceManager.getResource("processTreeImage")); 85 setIcon(image); 86 } catch (Throwable t) { 87 setIcon(null); 88 } finally { 89 WfProcess pr=(WfProcess)((DefaultMutableTreeNode)value).getUserObject(); 90 String name; 91 try { 92 name=pr.key(); 93 } catch (Exception ex) { 94 name=ResourceManager.getLanguageDependentString("UnknownKey"); 95 } 96 String disp=ResourceManager. 97 getLanguageDependentString("InstantiatedProcessKey")+"-"+name; 98 setText(disp); 99 setToolTipText(disp); 100 } 101 break; 102 } 103 return this; 104 } 105 106 protected int getUserObjectType (Object value) { 107 DefaultMutableTreeNode node = (DefaultMutableTreeNode)value; 108 Object userObj = node.getUserObject(); 109 if (userObj instanceof org.enhydra.jawe.xml.elements.Package) { 110 return 1; 111 } else if (userObj instanceof WfProcessMgr) { 112 return 2; 113 } else if (userObj instanceof WfProcess) { 114 return 3; 115 } else { 116 return 0; 117 } 118 } 119 120 } 121 | Popular Tags |