Changeset 7398 in josm for trunk/src


Ignore:
Timestamp:
2014-08-15T15:07:27+02:00 (5 years ago)
Author:
Don-vip
Message:

fix #10320 - show undo/redo buffers state in "Command Stack" dialog

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/CommandStackDialog.java

    r7024 r7398  
    5151import org.openstreetmap.josm.tools.Shortcut;
    5252
     53/**
     54 * Dialog displaying list of all executed commands (undo/redo buffer).
     55 * @since 94
     56 */
    5357public class CommandStackDialog extends ToggleDialog implements CommandQueueListener {
    5458
    55     private DefaultTreeModel undoTreeModel = new DefaultTreeModel(new DefaultMutableTreeNode());
    56     private DefaultTreeModel redoTreeModel = new DefaultTreeModel(new DefaultMutableTreeNode());
    57 
    58     private JTree undoTree = new JTree(undoTreeModel);
    59     private JTree redoTree = new JTree(redoTreeModel);
     59    private final DefaultTreeModel undoTreeModel = new DefaultTreeModel(new DefaultMutableTreeNode());
     60    private final DefaultTreeModel redoTreeModel = new DefaultTreeModel(new DefaultMutableTreeNode());
     61
     62    private final JTree undoTree = new JTree(undoTreeModel);
     63    private final JTree redoTree = new JTree(redoTreeModel);
    6064
    6165    private UndoRedoSelectionListener undoSelectionListener;
     
    100104        redoSelectionListener = new UndoRedoSelectionListener(redoTree);
    101105        redoTree.getSelectionModel().addTreeSelectionListener(redoSelectionListener);
     106        InputMapUtils.unassignCtrlShiftUpDown(redoTree, JComponent.WHEN_FOCUSED);
    102107
    103108        JPanel treesPanel = new JPanel(new GridBagLayout());
     
    132137
    133138    private static class CommandCellRenderer extends DefaultTreeCellRenderer {
    134         @Override public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
     139        @Override
     140        public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
    135141            super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
    136142            DefaultMutableTreeNode v = (DefaultMutableTreeNode)value;
     
    144150    }
    145151
     152    private void updateTitle() {
     153        int undo = undoTreeModel.getChildCount(undoTreeModel.getRoot());
     154        int redo = redoTreeModel.getChildCount(redoTreeModel.getRoot());
     155        if (undo > 0 || redo > 0) {
     156            setTitle(tr("Command Stack: Undo: {0} / Redo: {1}", undo, redo));
     157        } else {
     158            setTitle(tr("Command Stack"));
     159        }
     160    }
     161
    146162    /**
    147163     * Selection listener for undo and redo area.
     
    179195
    180196    /**
    181      * Wires updater for enabled state to the events.
     197     * Wires updater for enabled state to the events. Also updates dialog title if needed.
    182198     */
    183199    protected void wireUpdateEnabledStateUpdater(final IEnabledStateUpdating updater, JTree tree) {
     
    195211            public void treeNodesChanged(TreeModelEvent e) {
    196212                updater.updateEnabledState();
     213                updateTitle();
    197214            }
    198215
     
    200217            public void treeNodesInserted(TreeModelEvent e) {
    201218                updater.updateEnabledState();
     219                updateTitle();
    202220            }
    203221
     
    205223            public void treeNodesRemoved(TreeModelEvent e) {
    206224                updater.updateEnabledState();
     225                updateTitle();
    207226            }
    208227
     
    210229            public void treeStructureChanged(TreeModelEvent e) {
    211230                updater.updateEnabledState();
     231                updateTitle();
    212232            }
    213233        });
     
    339359    }
    340360
     361    /**
     362     * Action that selects the objects that take part in a command.
     363     */
    341364    public class SelectAction extends AbstractAction implements IEnabledStateUpdating {
    342365
     
    372395    }
    373396
     397    /**
     398     * Action that selects the objects that take part in a command, then zoom to them.
     399     */
    374400    public class SelectAndZoomAction extends SelectAction {
    375401        /**
Note: See TracChangeset for help on using the changeset viewer.