Changeset 4795
- Timestamp:
- 06/09/08 07:20:38 (6 months ago)
- Location:
- incubator/widgets/menubar/src/com/itmill/toolkit/ui
- Files:
-
- 2 modified
-
MenuBar.java (modified) (14 diffs)
-
gwt/client/ui/IMenuBar.java (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
incubator/widgets/menubar/src/com/itmill/toolkit/ui/MenuBar.java
r4658 r4795 18 18 public class MenuBar extends AbstractComponent { 19 19 20 private List menuItems = new ArrayList(); // Items of the top-level menu 21 private static int numberOfItems = 0; // Number of items in this menu 20 // Items of the top-level menu 21 private List<MenuItem> menuItems = new ArrayList<MenuItem>(); 22 23 // Number of items in this menu 24 private static int numberOfItems = 0; 22 25 23 26 /** Tag is the UIDL element name for client-server communications. */ … … 29 32 public void paintContent(PaintTarget target) throws PaintException { 30 33 31 Stack iteratorStack = new Stack(); // Stack for list iterators 32 33 34 // Superclass writes any common attributes in the paint target. 35 super.paintContent(target); 36 37 // Stack for list iterators 38 Stack<Iterator<MenuItem>> iteratorStack = new Stack<Iterator<MenuItem>>(); 39 34 40 target.startTag("items"); 35 41 36 Iterator itr = menuItems.iterator();42 Iterator<MenuItem> itr = menuItems.iterator(); 37 43 38 44 // This generates the tree from the contents of the menu … … 52 58 target.addAttribute("command", false); 53 59 } 54 55 60 56 61 Resource icon = item.getIcon(); … … 61 66 if (item.hasChildren()) { 62 67 iteratorStack.push(itr); // For later use 63 itr = item.getChildren().iterator(); // Go through the children 68 69 // Go through the children 70 itr = item.getChildren().iterator(); 64 71 } else { 65 72 target.endTag("item"); // Item had no children, end description … … 67 74 68 75 if (!itr.hasNext() && !iteratorStack.empty()) { // The end submenu 69 itr = (Iterator ) iteratorStack.pop();76 itr = (Iterator<MenuItem>) iteratorStack.pop(); 70 77 target.endTag("item"); 71 78 } … … 78 85 /** Deserialize changes received from client. */ 79 86 public void changeVariables(Object source, Map variables) { 80 Stack items = new Stack();87 Stack<MenuItem> items = new Stack<MenuItem>(); 81 88 boolean found = false; 82 89 … … 84 91 85 92 Integer clickedId = (Integer) variables.get("clickedId"); 86 Iterator itr = this.getItems().iterator();93 Iterator<MenuItem> itr = this.getItems().iterator(); 87 94 while (itr.hasNext()) { 88 items.push( itr.next());95 items.push((MenuItem) itr.next()); 89 96 } 90 97 … … 137 144 * The menu items to be added 138 145 */ 139 public void addItems(java.util.List items) {146 public void addItems(java.util.List<MenuItem> items) { 140 147 if (items != null) { 141 Iterator itr = items.iterator();148 Iterator<MenuItem> itr = items.iterator(); 142 149 143 150 while (itr.hasNext()) { … … 153 160 * @return a list containing the MenuItem objects in the menubar 154 161 */ 155 public java.util.List getItems() {162 public java.util.List<MenuItem> getItems() { 156 163 return menuItems; 157 164 } … … 207 214 private MenuCommand itsCommand; 208 215 private String itsText; 209 private List itsChildren;216 private List<MenuItem> itsChildren; 210 217 private Resource itsIcon; 211 218 private MenuItem itsParent; … … 245 252 * A list of MenuItems to be added to the item 246 253 */ 247 public MenuItem(java.lang.String text, java.util.List children) {254 public MenuItem(java.lang.String text, java.util.List<MenuItem> children) { 248 255 itsId = ++numberOfItems; 249 256 itsText = text; … … 270 277 271 278 if (itsChildren == null) { 272 itsChildren = new ArrayList ();279 itsChildren = new ArrayList<MenuItem>(); 273 280 } 274 281 275 // The only place where the parent is set282 // The only place where the parent is set 276 283 item.setParent(this); 277 284 itsChildren.add(item); … … 286 293 * A list of menu items to be added. 287 294 */ 288 public void addItems(java.util.List items) {295 public void addItems(java.util.List<MenuItem> items) { 289 296 if (items != null) { 290 297 291 Iterator itr = items.iterator();298 Iterator<MenuItem> itr = items.iterator(); 292 299 while (itr.hasNext()) { 293 300 addItem((MenuItem) itr.next()); … … 330 337 * @return List of children items, or null if there are none 331 338 */ 332 public java.util.List getChildren() {339 public java.util.List<MenuItem> getChildren() { 333 340 return itsChildren; 334 341 } -
incubator/widgets/menubar/src/com/itmill/toolkit/ui/gwt/client/ui/IMenuBar.java
r4662 r4795 17 17 18 18 /** Component identifier in UIDL communications. */ 19 String uidlId;19 protected String uidlId; 20 20 21 21 /** Reference to the server connection object. */ 22 ApplicationConnection client;22 protected ApplicationConnection client; 23 23 24 24 /** A host reference for the Command objects */ 25 final IMenuBar hostReference = this;25 protected final IMenuBar hostReference = this; 26 26 27 27 /** … … 66 66 // Get tree received from server and actualize it in the GWT-MenuBar 67 67 UIDL items = uidl.getChildUIDL(0); 68 Iterator itr = items.getChildIterator(); 69 Stack iteratorStack = new Stack(); 68 Iterator<UIDL> itr = items.getChildIterator(); 69 Stack<Iterator<UIDL>> iteratorStack = new Stack<Iterator<UIDL>>(); 70 Stack<MenuBar> menuStack = new Stack<MenuBar>(); 70 71 MenuBar currentMenu = this; 71 MenuBar parentMenu = null;72 72 73 73 // Construct an empty command to be used when the item has no command … … 115 115 116 116 if (item.getChildCount() > 0) { 117 parentMenu = currentMenu;117 menuStack.push(currentMenu); 118 118 iteratorStack.push(itr); 119 119 itr = item.getChildIterator(); … … 123 123 124 124 if (!itr.hasNext() && !iteratorStack.empty()) { 125 itr = (Iterator ) iteratorStack.pop();126 currentMenu = parentMenu;125 itr = (Iterator<UIDL>) iteratorStack.pop(); 126 currentMenu = menuStack.pop(); 127 127 } 128 128 }// while
