1 19 20 package org.apache.excalibur.instrument.client; 21 22 import javax.swing.ImageIcon ; 23 import javax.swing.JMenuItem ; 24 import javax.swing.JPopupMenu ; 25 26 29 abstract class NodeData 30 { 31 protected static final String MEDIA_PATH = "org/apache/excalibur/instrument/client/media/"; 32 protected static final JMenuItem [] EMPTY_MENU_ITEM_ARRAY = new JMenuItem [0]; 33 34 private String m_name; 35 private String m_description; 36 private int m_stateVersion; 37 38 41 protected NodeData() 42 { 43 } 44 45 48 String getName() 49 { 50 return m_name; 51 } 52 53 String getDescription() 54 { 55 return m_description; 56 } 57 58 void setDescription( String description ) 59 { 60 m_description = description; 61 } 62 63 int getStateVersion() 64 { 65 return m_stateVersion; 66 } 67 68 73 abstract ImageIcon getIcon(); 74 75 80 abstract String getToolTipText(); 81 82 87 public JPopupMenu getPopupMenu() 88 { 89 JPopupMenu popup; 90 JMenuItem [] menuItems = getCommonMenuItems(); 91 if ( menuItems.length == 0 ) 92 { 93 popup = null; 94 } 95 else 96 { 97 popup = new JPopupMenu ( getDescription() ); 98 for ( int i = 0; i < menuItems.length; i++ ) 99 { 100 popup.add( menuItems[i] ); 101 } 102 } 103 104 return popup; 105 } 106 107 113 public JMenuItem [] getCommonMenuItems() 114 { 115 return EMPTY_MENU_ITEM_ARRAY; 116 } 117 118 121 void select() 122 { 123 } 124 125 126 boolean update( String name, String description, int stateVersion ) 127 { 128 boolean changed = false; 129 130 changed |= name.equals( m_name ); 131 m_name = name; 132 133 changed |= description.equals( m_description ); 134 m_description = description; 135 136 changed |= stateVersion == m_stateVersion; 137 m_stateVersion = stateVersion; 138 139 return changed; 140 } 141 142 public String toString() 143 { 144 return m_description; 145 } 146 } 147 | Popular Tags |