- Timestamp:
- 2018-06-17T17:23:47+02:00 (6 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/dialogs
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/CommandListMutableTreeNode.java
r11048 r13943 13 13 14 14 protected final transient PseudoCommand cmd; 15 protected final int idx;16 15 17 16 /** 18 17 * Constructs a new {@code CommandListMutableTreeNode}. 19 18 * @param cmd command 20 * @param idx index21 19 */ 22 public CommandListMutableTreeNode(PseudoCommand cmd , int idx) {20 public CommandListMutableTreeNode(PseudoCommand cmd) { 23 21 super(new JLabel(cmd.getDescriptionText(), cmd.getDescriptionIcon(), JLabel.HORIZONTAL)); 24 22 this.cmd = cmd; 25 this.idx = idx;26 23 } 27 24 … … 39 36 */ 40 37 public int getIndex() { 41 return idx;38 return getParent().getIndex(this); 42 39 } 43 40 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/CommandStackDialog.java
r13824 r13943 273 273 undoRoot = new DefaultMutableTreeNode(); 274 274 for (int i = 0; i < undoCommands.size(); ++i) { 275 undoRoot.add(getNodeForCommand(undoCommands.get(i) , i));275 undoRoot.add(getNodeForCommand(undoCommands.get(i))); 276 276 } 277 277 undoTreeModel.setRoot(undoRoot); … … 282 282 redoRoot = new DefaultMutableTreeNode(); 283 283 for (int i = 0; i < redoCommands.size(); ++i) { 284 redoRoot.add(getNodeForCommand(redoCommands.get(i) , i));284 redoRoot.add(getNodeForCommand(redoCommands.get(i))); 285 285 } 286 286 redoTreeModel.setRoot(redoRoot); … … 330 330 * Recursively adds child commands. 331 331 * @param c the command 332 * @param idx index333 332 * @return the resulting node 334 333 */ 335 protected CommandListMutableTreeNode getNodeForCommand(PseudoCommand c , int idx) {336 CommandListMutableTreeNode node = new CommandListMutableTreeNode(c , idx);334 protected CommandListMutableTreeNode getNodeForCommand(PseudoCommand c) { 335 CommandListMutableTreeNode node = new CommandListMutableTreeNode(c); 337 336 if (c.getChildren() != null) { 338 337 List<PseudoCommand> children = new ArrayList<>(c.getChildren()); 339 338 for (int i = 0; i < children.size(); ++i) { 340 node.add(getNodeForCommand(children.get(i) , i));339 node.add(getNodeForCommand(children.get(i))); 341 340 } 342 341 } … … 371 370 public void commandAdded(CommandAddedEvent e) { 372 371 if (isVisible()) { 373 undoRoot.add(getNodeForCommand(e.getCommand() , undoRoot.getChildCount()));372 undoRoot.add(getNodeForCommand(e.getCommand())); 374 373 undoTreeModel.nodeStructureChanged(undoRoot); 375 374 ensureTreesConsistency();
Note:
See TracChangeset
for help on using the changeset viewer.