001// License: GPL. For details, see LICENSE file.
002package org.openstreetmap.josm.gui.dialogs;
003
004import javax.swing.JLabel;
005import javax.swing.tree.DefaultMutableTreeNode;
006
007import org.openstreetmap.josm.command.PseudoCommand;
008
009/**
010 * MutableTreeNode implementation for Command list JTree
011 */
012public class CommandListMutableTreeNode extends DefaultMutableTreeNode {
013
014    protected final transient PseudoCommand cmd;
015    protected final int idx;
016
017    /**
018     * Constructs a new {@code CommandListMutableTreeNode}.
019     * @param cmd command
020     * @param idx index
021     */
022    public CommandListMutableTreeNode(PseudoCommand cmd, int idx) {
023        super(new JLabel(cmd.getDescriptionText(), cmd.getDescriptionIcon(), JLabel.HORIZONTAL));
024        this.cmd = cmd;
025        this.idx = idx;
026    }
027
028    /**
029     * Returns the command.
030     * @return the command
031     */
032    public PseudoCommand getCommand() {
033        return cmd;
034    }
035
036    /**
037     * Returns the index.
038     * @return the index
039     */
040    public int getIndex() {
041        return idx;
042    }
043}