Gridarta Editor
ShortcutsDialog.java
Go to the documentation of this file.
1 /*
2  * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games.
3  * Copyright (C) 2000-2023 The Gridarta Developers.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 package net.sf.gridarta.gui.dialog.shortcuts;
21 
22 import java.awt.Color;
23 import java.awt.Component;
24 import java.awt.Container;
25 import java.awt.Dimension;
26 import java.awt.GridBagConstraints;
27 import java.awt.GridBagLayout;
28 import java.awt.Insets;
29 import java.util.regex.Pattern;
30 import javax.swing.Action;
31 import javax.swing.Icon;
32 import javax.swing.JButton;
33 import javax.swing.JComponent;
34 import javax.swing.JDialog;
35 import javax.swing.JOptionPane;
36 import javax.swing.JPanel;
37 import javax.swing.JScrollPane;
38 import javax.swing.JTextArea;
39 import javax.swing.JTree;
40 import javax.swing.JViewport;
41 import javax.swing.ScrollPaneConstants;
42 import javax.swing.ToolTipManager;
43 import javax.swing.WindowConstants;
44 import javax.swing.border.LineBorder;
45 import javax.swing.border.TitledBorder;
46 import javax.swing.event.TreeSelectionListener;
47 import javax.swing.tree.DefaultMutableTreeNode;
48 import javax.swing.tree.DefaultTreeCellRenderer;
49 import javax.swing.tree.DefaultTreeModel;
50 import javax.swing.tree.MutableTreeNode;
51 import javax.swing.tree.TreeCellRenderer;
52 import javax.swing.tree.TreeNode;
53 import javax.swing.tree.TreeSelectionModel;
58 import net.sf.japi.swing.action.ActionBuilder;
59 import net.sf.japi.swing.action.ActionBuilderFactory;
60 import net.sf.japi.swing.action.ActionMethod;
61 import net.sf.japi.swing.action.IconManager;
62 import org.jetbrains.annotations.NotNull;
63 import org.jetbrains.annotations.Nullable;
64 
65 public class ShortcutsDialog extends JOptionPane {
66 
70  private static final long serialVersionUID = 1L;
71 
75  @NotNull
76  private static final String CATEGORY_PREFIX = "1";
77 
81  @NotNull
82  private static final String ACTION_PREFIX = "2";
83 
87  @NotNull
89 
93  @NotNull
94  private static final ActionBuilder ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder("net.sf.gridarta");
95 
99  @NotNull
100  private static final Pattern PATTERN_CATEGORIES = StringUtils.PATTERN_COMMA;
101 
105  @NotNull
106  private static final Pattern PATTERN_SUB_CATEGORIES = StringUtils.PATTERN_SLASH;
107 
112  @NotNull
113  private final JButton okButton = new JButton(ACTION_BUILDER.createAction(false, "shortcutsOkay", this));
114 
119  @NotNull
120  private final Action aSetShortcut = ACTION_BUILDER.createAction(false, "shortcutsSetShortcut", this);
121 
126  @NotNull
127  private final Action aUnsetShortcut = ACTION_BUILDER.createAction(false, "shortcutsUnsetShortcut", this);
128 
133  @NotNull
134  private final JDialog dialog;
135 
140  @NotNull
141  private final JTree actionsTree = new JTree() {
142 
146  private static final long serialVersionUID = 1L;
147 
148  @Override
149  public String convertValueToText(final Object value, final boolean selected, final boolean expanded, final boolean leaf, final int row, final boolean hasFocus) {
150  final Action action = getAction(value);
151  if (action != null) {
152  return ActionUtils.getActionName(action);
153  }
154 
155  return super.convertValueToText(value, selected, expanded, leaf, row, hasFocus);
156  }
157 
158  };
159 
164  @NotNull
165  private final JTextArea actionDescription = new JTextArea();
166 
171  @NotNull
172  private final JTextArea actionShortcut = new JTextArea();
173 
177  @Nullable
178  private Action selectedAction;
179 
185  public ShortcutsDialog(@NotNull final Component parentComponent, @NotNull final ShortcutsManager shortcutsManager) {
186  this.shortcutsManager = shortcutsManager;
187  okButton.setDefaultCapable(true);
188  final JButton defaultsButton = new JButton(ACTION_BUILDER.createAction(false, "shortcutsDefaults", this));
189  setOptions(new Object[] { okButton, defaultsButton });
190 
191  setMessage(createPanel());
192 
193  dialog = createDialog(parentComponent, ActionBuilderUtils.getString(ACTION_BUILDER, "shortcuts.title"));
194  dialog.setResizable(true);
195  dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
196  dialog.getRootPane().setDefaultButton(okButton);
197  dialog.setModal(true);
198 
199  dialog.setMinimumSize(new Dimension(400, 300));
200  dialog.setPreferredSize(new Dimension(800, 600));
201  dialog.pack();
202  }
203 
208  public void showDialog(@NotNull final Component parentComponent) {
209  dialog.setLocationRelativeTo(parentComponent);
210  dialog.setVisible(true);
211  setInitialValue(actionsTree);
212  actionsTree.setSelectionRow(0);
214  }
215 
220  @NotNull
221  private JPanel createPanel() {
222  final DefaultMutableTreeNode top = new DefaultMutableTreeNode(ActionBuilderUtils.getString(ACTION_BUILDER, "shortcuts.allActions"));
223  createNodes(top);
224 
225  actionsTree.setModel(new DefaultTreeModel(top, false));
226  actionsTree.setRootVisible(false);
227  actionsTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
228  final TreeSelectionListener treeSelectionListener = e -> setSelectedAction(getAction(actionsTree.getLastSelectedPathComponent()));
229  actionsTree.addTreeSelectionListener(treeSelectionListener);
230 
231  final Icon emptyIcon = IconManager.getDefaultIconManager().getIcon(ActionBuilderUtils.getString(ACTION_BUILDER, "shortcuts.defaultIcon"));
232  //noinspection RefusedBequest
233  final TreeCellRenderer treeCellRenderer = new DefaultTreeCellRenderer() {
234 
238  private static final long serialVersionUID = 1L;
239 
243  @Nullable
244  private Icon icon;
245 
246  @Override
247  public Component getTreeCellRendererComponent(final JTree tree, final Object value, final boolean sel, final boolean expanded, final boolean leaf, final int row, final boolean hasFocus) {
248  if (leaf) {
249  final Action action = getAction(value);
250  if (action == null) {
251  icon = emptyIcon;
252  } else {
253  final Icon tmpIcon = ActionUtils.getActionIcon(action);
254  icon = tmpIcon == null ? emptyIcon : tmpIcon;
255  setToolTipText(ActionUtils.getActionDescription(action));
256  }
257  } else {
258  icon = emptyIcon;
259  }
260  return super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
261  }
262 
263  @Override
264  public Icon getLeafIcon() {
265  return icon;
266  }
267 
268  };
269  actionsTree.setCellRenderer(treeCellRenderer);
270 
271  ToolTipManager.sharedInstance().registerComponent(actionsTree);
272 
273  final GridBagConstraints gbc = new GridBagConstraints();
274  gbc.insets = new Insets(2, 2, 2, 2);
275 
276  final JScrollPane actionsScrollPane = new JScrollPane();
277  actionsScrollPane.setViewportView(actionsTree);
278  actionsScrollPane.setBackground(actionsTree.getBackground());
279  actionsScrollPane.getViewport().add(actionsTree);
280  actionsScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
281  actionsScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
282  actionsScrollPane.getViewport().setScrollMode(JViewport.SIMPLE_SCROLL_MODE);
283  final JComponent actionsPanel = new JPanel(new GridBagLayout());
284  actionsPanel.setBorder(new TitledBorder(ActionBuilderUtils.getString(ACTION_BUILDER, "shortcuts.borderAllActions")));
285  gbc.gridx = 0;
286  gbc.gridy = 0;
287  gbc.fill = GridBagConstraints.BOTH;
288  gbc.weightx = 1.0;
289  gbc.weighty = 1.0;
290  actionsPanel.add(actionsScrollPane, gbc);
291 
292  actionDescription.setEditable(false);
293  actionDescription.setColumns(20);
294  actionDescription.setLineWrap(true);
295  actionDescription.setWrapStyleWord(true);
296  actionDescription.setBorder(new LineBorder(Color.black));
297  actionDescription.setFocusable(false);
298 
299  actionShortcut.setEditable(false);
300  actionShortcut.setColumns(20);
301  actionShortcut.setRows(3);
302  actionShortcut.setLineWrap(true);
303  actionShortcut.setWrapStyleWord(true);
304  actionShortcut.setBorder(new LineBorder(Color.black));
305  actionShortcut.setFocusable(false);
306 
307  final Container actionDescriptionPanel = new JPanel(new GridBagLayout());
308  gbc.gridx = 0;
309  gbc.gridy = 0;
310  gbc.fill = GridBagConstraints.HORIZONTAL;
311  gbc.weightx = 1.0;
312  gbc.weighty = 0.0;
313  actionDescriptionPanel.add(ActionBuilderUtils.newLabel(ACTION_BUILDER, "shortcuts.actionDescription"), gbc);
314  gbc.gridy++;
315  gbc.fill = GridBagConstraints.BOTH;
316  gbc.weighty = 1.0;
317  actionDescriptionPanel.add(actionDescription, gbc);
318 
319  final Container actionShortcutPanel = new JPanel(new GridBagLayout());
320  gbc.gridx = 0;
321  gbc.gridy = 0;
322  gbc.fill = GridBagConstraints.HORIZONTAL;
323  gbc.weightx = 1.0;
324  gbc.weighty = 0.0;
325  actionShortcutPanel.add(ActionBuilderUtils.newLabel(ACTION_BUILDER, "shortcuts.shortcut"), gbc);
326  gbc.gridy++;
327  actionShortcutPanel.add(actionShortcut, gbc);
328 
329  final Component addShortcutButton = new JButton(aSetShortcut);
330  final Component removeShortcutButton = new JButton(aUnsetShortcut);
331  final Container actionButtonsPanel = new JPanel();
332  actionButtonsPanel.setLayout(new GridBagLayout());
333  gbc.gridx = 0;
334  gbc.gridy = 0;
335  gbc.fill = GridBagConstraints.HORIZONTAL;
336  gbc.weightx = 1.0;
337  gbc.weighty = 0.0;
338  actionButtonsPanel.add(addShortcutButton, gbc);
339  gbc.gridy++;
340  actionButtonsPanel.add(removeShortcutButton, gbc);
341 
342  final JComponent selectedActionPanel = new JPanel();
343  selectedActionPanel.setLayout(new GridBagLayout());
344  selectedActionPanel.setBorder(new TitledBorder(ActionBuilderUtils.getString(ACTION_BUILDER, "shortcuts.selectedAction")));
345  gbc.gridx = 0;
346  gbc.gridy = 0;
347  gbc.fill = GridBagConstraints.BOTH;
348  gbc.weightx = 1.0;
349  gbc.weighty = 1.0;
350  selectedActionPanel.add(actionDescriptionPanel, gbc);
351  gbc.fill = GridBagConstraints.HORIZONTAL;
352  gbc.weighty = 0.0;
353  gbc.gridy++;
354  selectedActionPanel.add(actionShortcutPanel, gbc);
355  gbc.gridy++;
356  selectedActionPanel.add(actionButtonsPanel, gbc);
357 
358  final JPanel panel = new JPanel(new GridBagLayout());
359  gbc.gridx = 0;
360  gbc.gridy = 0;
361  gbc.fill = GridBagConstraints.BOTH;
362  gbc.weightx = 1.0;
363  gbc.weighty = 1.0;
364  panel.add(actionsPanel, gbc);
365  gbc.gridx++;
366  gbc.weightx = 0.0;
367  panel.add(selectedActionPanel, gbc);
368 
369  panel.setBorder(GUIConstants.DIALOG_BORDER);
370  return panel;
371  }
372 
376  @ActionMethod
377  public void shortcutsOkay() {
379  }
380 
384  @ActionMethod
385  public void shortcutsDefaults() {
386  if (ACTION_BUILDER.showQuestionDialog(dialog, "shortcutsRestoreDefaults")) {
390  }
391  }
392 
393  @Override
394  public void setValue(@Nullable final Object newValue) {
395  super.setValue(newValue);
396  if (newValue != UNINITIALIZED_VALUE) {
397  dialog.dispose();
398  }
399  }
400 
405  private void createNodes(@NotNull final DefaultMutableTreeNode root) {
406  for (final Action action : shortcutsManager) {
407  final String categories = ActionUtils.getActionCategory(action);
408  for (final String category : PATTERN_CATEGORIES.split(categories, -1)) {
409  addNode(root, category, action);
410  }
411  }
412  }
413 
420  private static void addNode(@NotNull final DefaultMutableTreeNode root, @NotNull final CharSequence category, @NotNull final Action action) {
421  final DefaultMutableTreeNode node = getOrCreateNodeForCategory(root, category);
422  final MutableTreeNode treeNode = new DefaultMutableTreeNode(action, false);
423  insertChildNode(node, treeNode);
424  }
425 
432  @NotNull
433  private static DefaultMutableTreeNode getOrCreateNodeForCategory(@NotNull final DefaultMutableTreeNode root, @NotNull final CharSequence category) {
434  DefaultMutableTreeNode node = root;
435  for (final String subCategory : PATTERN_SUB_CATEGORIES.split(category, -1)) {
436  node = getOrCreateChildNode(node, subCategory);
437  }
438  return node;
439  }
440 
447  @NotNull
448  private static DefaultMutableTreeNode getOrCreateChildNode(@NotNull final MutableTreeNode root, @NotNull final String subCategory) {
449  final int childCount = root.getChildCount();
450  for (int i = 0; i < childCount; i++) {
451  final TreeNode treeNode = root.getChildAt(i);
452  final String nodeTitle = getTitle(treeNode);
453  if (nodeTitle != null && nodeTitle.equals(CATEGORY_PREFIX + subCategory)) {
454  assert treeNode instanceof DefaultMutableTreeNode;
455  return (DefaultMutableTreeNode) treeNode;
456  }
457  }
458 
459  final DefaultMutableTreeNode treeNode = new DefaultMutableTreeNode(subCategory);
460  insertChildNode(root, treeNode);
461  return treeNode;
462  }
463 
469  private static void insertChildNode(@NotNull final MutableTreeNode branchNode, @NotNull final MutableTreeNode childNode) {
470  branchNode.insert(childNode, getInsertionIndex(branchNode, childNode));
471  }
472 
479  private static int getInsertionIndex(@NotNull final TreeNode parentNode, @NotNull final TreeNode childNode) {
480  final String childTitle = getTitle(childNode);
481  if (childTitle == null) {
482  throw new IllegalArgumentException("invalid child node: " + childNode);
483  }
484 
485  final int childCount = parentNode.getChildCount();
486  for (int i = 0; i < childCount; i++) {
487  final TreeNode treeNode = parentNode.getChildAt(i);
488  final String nodeTitle = getTitle(treeNode);
489  if (nodeTitle != null && nodeTitle.compareToIgnoreCase(childTitle) > 0) {
490  return i;
491  }
492  }
493 
494  return childCount;
495  }
496 
502  @Nullable
503  private static Action getAction(@Nullable final Object node) {
504  if (!(node instanceof DefaultMutableTreeNode)) {
505  return null;
506  }
507 
508  final DefaultMutableTreeNode defaultMutableTreeNode = (DefaultMutableTreeNode) node;
509  final Object userObject = defaultMutableTreeNode.getUserObject();
510  if (!(userObject instanceof Action)) {
511  return null;
512  }
513 
514  return (Action) userObject;
515  }
516 
522  @Nullable
523  private static String getTitle(@NotNull final TreeNode node) {
524  if (!(node instanceof DefaultMutableTreeNode)) {
525  return null;
526  }
527 
528  final DefaultMutableTreeNode defaultMutableTreeNode = (DefaultMutableTreeNode) node;
529  final Object userObject = defaultMutableTreeNode.getUserObject();
530  if (userObject == null) {
531  return null;
532  }
533 
534  if (userObject instanceof String) {
535  return CATEGORY_PREFIX + userObject;
536  }
537 
538  if (userObject instanceof Action) {
539  return ACTION_PREFIX + ActionUtils.getActionName((Action) userObject);
540  }
541 
542  return null;
543  }
544 
549  private void setSelectedAction(@Nullable final Action selectedAction) {
550  if (this.selectedAction == selectedAction) {
551  return;
552  }
553 
554  this.selectedAction = selectedAction;
556  }
557 
561  private void updateSelectedAction() {
563  actionShortcut.setText(selectedAction == null ? "" : ActionUtils.getShortcutDescription(selectedAction, Action.ACCELERATOR_KEY));
564  aSetShortcut.setEnabled(selectedAction != null);
565  aUnsetShortcut.setEnabled(getUnsetShortcutEnabled() != null);
566  }
567 
572  @Nullable
573  private Action getUnsetShortcutEnabled() {
574  final Action action = selectedAction;
575  return action != null && ActionUtils.getShortcut(action) != null ? action : null;
576  }
577 
581  @ActionMethod
582  public void shortcutsSetShortcut() {
583  final Action action = selectedAction;
584  if (action == null) {
585  return;
586  }
587 
588  final KeyStrokeDialog keyStrokeDialog = new KeyStrokeDialog(dialog, shortcutsManager, action);
589  if (keyStrokeDialog.showDialog(dialog)) {
590  ActionUtils.setActionShortcut(action, keyStrokeDialog.getKeyStroke());
593  }
594  }
595 
599  @ActionMethod
600  public void shortcutsUnsetShortcut() {
601  final Action action = getUnsetShortcutEnabled();
602  if (action != null) {
603  ActionUtils.setActionShortcut(action, null);
606  }
607  }
608 
609 }
net.sf.gridarta.gui.dialog.shortcuts.ShortcutsDialog.shortcutsManager
final ShortcutsManager shortcutsManager
The ShortcutsManager to affect.
Definition: ShortcutsDialog.java:88
net.sf.gridarta.gui.dialog.shortcuts.ShortcutsDialog.updateSelectedAction
void updateSelectedAction()
Updates the information shown for the selected action.
Definition: ShortcutsDialog.java:561
net.sf.gridarta.gui.dialog.shortcuts.ShortcutsDialog.ACTION_PREFIX
static final String ACTION_PREFIX
Prefix for internal action names.
Definition: ShortcutsDialog.java:82
net.sf.gridarta.gui.dialog.shortcuts.ShortcutsDialog.actionDescription
final JTextArea actionDescription
The description of the selected action.
Definition: ShortcutsDialog.java:165
net.sf.gridarta.gui.dialog.shortcuts.ShortcutsManager
Manager for shortcuts of all Actions in an {} instance.
Definition: ShortcutsManager.java:50
net.sf.gridarta.utils.StringUtils.PATTERN_SLASH
static final Pattern PATTERN_SLASH
The pattern that matches a single slash ("/").
Definition: StringUtils.java:79
net.sf.gridarta
Base package of all Gridarta classes.
net.sf.gridarta.gui.dialog.shortcuts.ShortcutsDialog.okButton
final JButton okButton
The JButton for ok.
Definition: ShortcutsDialog.java:113
net.sf.gridarta.gui.utils.GUIConstants
Defines common UI constants used in different dialogs.
Definition: GUIConstants.java:33
net.sf.gridarta.gui.dialog.shortcuts.ShortcutsDialog.createPanel
JPanel createPanel()
Creates the GUI.
Definition: ShortcutsDialog.java:221
net.sf.gridarta.gui.dialog.shortcuts.ShortcutsDialog.actionsTree
final JTree actionsTree
The JTree showing all actions.
Definition: ShortcutsDialog.java:141
net.sf.gridarta.gui.dialog.shortcuts.ShortcutsDialog.serialVersionUID
static final long serialVersionUID
The serial Version UID.
Definition: ShortcutsDialog.java:70
net.sf.gridarta.gui.dialog.shortcuts.ShortcutsManager.revertAll
void revertAll()
Reverts all shortcuts to their default values.
Definition: ShortcutsManager.java:223
net.sf
net.sf.gridarta.utils.ActionUtils.getActionDescription
static String getActionDescription(@NotNull final Action action)
Returns the description for an Action.
Definition: ActionUtils.java:104
net.sf.gridarta.gui.dialog.shortcuts.ShortcutsDialog.createNodes
void createNodes(@NotNull final DefaultMutableTreeNode root)
Creates nodes for all actions.
Definition: ShortcutsDialog.java:405
net.sf.gridarta.utils.ActionUtils.getActionName
static String getActionName(@NotNull final Action action)
Returns the name of an Action.
Definition: ActionUtils.java:72
net.sf.gridarta.utils.ActionUtils.getShortcutDescription
static String getShortcutDescription(@NotNull final Action action, @NotNull final String key)
Returns a description of the shortcut of an Action.
Definition: ActionUtils.java:163
net.sf.gridarta.gui.dialog.shortcuts.ShortcutsManager.saveShortcuts
void saveShortcuts()
Saves all shortcuts to the preferences.
Definition: ShortcutsManager.java:188
net.sf.gridarta.utils.ActionBuilderUtils.newLabel
static JLabel newLabel(@NotNull final ActionBuilder actionBuilder, @NotNull final String key)
Creates a new JLabel from a resource key.
Definition: ActionBuilderUtils.java:117
net.sf.gridarta.gui.dialog.shortcuts.ShortcutsDialog.dialog
final JDialog dialog
The JDialog instance.
Definition: ShortcutsDialog.java:134
net.sf.gridarta.utils.ActionUtils
Utility class implementing Action related functions.
Definition: ActionUtils.java:33
net.sf.gridarta.gui
Graphical User Interface of Gridarta.
net.sf.gridarta.gui.dialog.shortcuts.ShortcutsDialog.getOrCreateNodeForCategory
static DefaultMutableTreeNode getOrCreateNodeForCategory(@NotNull final DefaultMutableTreeNode root, @NotNull final CharSequence category)
Returns the branch DefaultMutableTreeNode for a given category.
Definition: ShortcutsDialog.java:433
net.sf.gridarta.gui.dialog.shortcuts.KeyStrokeDialog.getKeyStroke
KeyStroke getKeyStroke()
Returns the currently shown key stroke.
Definition: KeyStrokeDialog.java:252
net.sf.gridarta.gui.dialog.shortcuts.ShortcutsDialog.setValue
void setValue(@Nullable final Object newValue)
Definition: ShortcutsDialog.java:394
net.sf.gridarta.utils.ActionUtils.getActionCategory
static String getActionCategory(@NotNull final Action action)
Returns an Action's category.
Definition: ActionUtils.java:235
net
net.sf.gridarta.gui.dialog.shortcuts.ShortcutsDialog.shortcutsOkay
void shortcutsOkay()
Action method for okay.
Definition: ShortcutsDialog.java:377
net.sf.gridarta.gui.dialog.shortcuts.ShortcutsDialog.selectedAction
Action selectedAction
The selected Action or.
Definition: ShortcutsDialog.java:178
net.sf.gridarta.utils.ActionUtils.getShortcut
static KeyStroke getShortcut(@NotNull final Action action)
Returns the shortcut of an Action.
Definition: ActionUtils.java:120
net.sf.gridarta.gui.dialog.shortcuts.ShortcutsDialog.shortcutsDefaults
void shortcutsDefaults()
Action method for restore to defaults.
Definition: ShortcutsDialog.java:385
net.sf.gridarta.gui.dialog.shortcuts.ShortcutsDialog.setSelectedAction
void setSelectedAction(@Nullable final Action selectedAction)
Updates the selected action.
Definition: ShortcutsDialog.java:549
net.sf.gridarta.utils.ActionUtils.setActionShortcut
static void setActionShortcut(@NotNull final Action action, @Nullable final KeyStroke shortcut)
Sets the shortcut of an Action.
Definition: ActionUtils.java:151
net.sf.gridarta.utils.ActionBuilderUtils.getString
static String getString(@NotNull final ActionBuilder actionBuilder, @NotNull final String key, @NotNull final String defaultValue)
Returns the value of a key.
Definition: ActionBuilderUtils.java:71
net.sf.gridarta.gui.dialog.shortcuts.ShortcutsDialog.showDialog
void showDialog(@NotNull final Component parentComponent)
Opens the dialog.
Definition: ShortcutsDialog.java:208
net.sf.gridarta.gui.dialog.shortcuts.ShortcutsDialog.PATTERN_SUB_CATEGORIES
static final Pattern PATTERN_SUB_CATEGORIES
The Pattern to split a category into sub-categories.
Definition: ShortcutsDialog.java:106
net.sf.gridarta.utils.StringUtils
Utility class for string manipulation.
Definition: StringUtils.java:31
net.sf.gridarta.gui.dialog.shortcuts.ShortcutsDialog.getAction
static Action getAction(@Nullable final Object node)
Returns the Action for a node in the action tree.
Definition: ShortcutsDialog.java:503
net.sf.gridarta.gui.dialog.shortcuts.KeyStrokeDialog
A dialog that asks for a KeyStroke.
Definition: KeyStrokeDialog.java:48
net.sf.gridarta.gui.dialog.shortcuts.ShortcutsDialog.insertChildNode
static void insertChildNode(@NotNull final MutableTreeNode branchNode, @NotNull final MutableTreeNode childNode)
Inserts a new child node into a branch node.
Definition: ShortcutsDialog.java:469
net.sf.gridarta.utils.StringUtils.PATTERN_COMMA
static final Pattern PATTERN_COMMA
The pattern that matches a single comma (",").
Definition: StringUtils.java:97
net.sf.gridarta.gui.dialog.shortcuts.ShortcutsDialog.shortcutsSetShortcut
void shortcutsSetShortcut()
The action method for the "set shortcut" button.
Definition: ShortcutsDialog.java:582
net.sf.gridarta.gui.dialog.shortcuts.ShortcutsDialog.getOrCreateChildNode
static DefaultMutableTreeNode getOrCreateChildNode(@NotNull final MutableTreeNode root, @NotNull final String subCategory)
Returns a child node by category name.
Definition: ShortcutsDialog.java:448
net.sf.gridarta.gui.dialog.shortcuts.ShortcutsDialog.PATTERN_CATEGORIES
static final Pattern PATTERN_CATEGORIES
The Pattern to split a list of action categories.
Definition: ShortcutsDialog.java:100
net.sf.gridarta.utils.ActionBuilderUtils
Utility class for ActionBuilder related functions.
Definition: ActionBuilderUtils.java:31
net.sf.gridarta.gui.dialog.shortcuts.KeyStrokeDialog.showDialog
boolean showDialog(@NotNull final Component parentComponent)
Opens the dialog.
Definition: KeyStrokeDialog.java:147
net.sf.gridarta.gui.utils
Definition: AnimationComponent.java:20
net.sf.gridarta.gui.dialog.shortcuts.ShortcutsDialog.aUnsetShortcut
final Action aUnsetShortcut
The Action for the "unset shortcut" button.
Definition: ShortcutsDialog.java:127
net.sf.gridarta.gui.dialog.shortcuts.ShortcutsDialog.ShortcutsDialog
ShortcutsDialog(@NotNull final Component parentComponent, @NotNull final ShortcutsManager shortcutsManager)
Creates a new instance.
Definition: ShortcutsDialog.java:185
net.sf.gridarta.gui.dialog.shortcuts.ShortcutsDialog.ACTION_BUILDER
static final ActionBuilder ACTION_BUILDER
The ActionBuilder.
Definition: ShortcutsDialog.java:94
net.sf.gridarta.gui.dialog.shortcuts.ShortcutsDialog.CATEGORY_PREFIX
static final String CATEGORY_PREFIX
Prefix for internal category names.
Definition: ShortcutsDialog.java:76
net.sf.gridarta.utils
Definition: ActionBuilderUtils.java:20
net.sf.gridarta.gui.dialog.shortcuts.ShortcutsDialog.actionShortcut
final JTextArea actionShortcut
The shortcut of the selected action.
Definition: ShortcutsDialog.java:172
net.sf.gridarta.gui.dialog.shortcuts.ShortcutsDialog
Definition: ShortcutsDialog.java:65
net.sf.gridarta.gui.dialog.shortcuts.ShortcutsDialog.getTitle
static String getTitle(@NotNull final TreeNode node)
Returns the category for a node in the action tree.
Definition: ShortcutsDialog.java:523
net.sf.gridarta.gui.dialog.shortcuts.ShortcutsDialog.getUnsetShortcutEnabled
Action getUnsetShortcutEnabled()
Returns whether "unset shortcut" is enabled.
Definition: ShortcutsDialog.java:573
net.sf.gridarta.gui.dialog.shortcuts.ShortcutsDialog.addNode
static void addNode(@NotNull final DefaultMutableTreeNode root, @NotNull final CharSequence category, @NotNull final Action action)
Adds an Action to a branch node.
Definition: ShortcutsDialog.java:420
net.sf.gridarta.gui.utils.GUIConstants.DIALOG_BORDER
Border DIALOG_BORDER
The Border object to be used when creating dialogs.
Definition: GUIConstants.java:38
net.sf.gridarta.utils.ActionUtils.getActionIcon
static Icon getActionIcon(@NotNull final Action action)
Returns an Icon associated with the action.
Definition: ActionUtils.java:174
net.sf.gridarta.gui.dialog.shortcuts.ShortcutsDialog.getInsertionIndex
static int getInsertionIndex(@NotNull final TreeNode parentNode, @NotNull final TreeNode childNode)
Returns the index to insert a new child node into a parent node.
Definition: ShortcutsDialog.java:479
net.sf.gridarta.gui.dialog.shortcuts.ShortcutsDialog.shortcutsUnsetShortcut
void shortcutsUnsetShortcut()
The action method for the "set shortcut" button.
Definition: ShortcutsDialog.java:600
net.sf.gridarta.gui.dialog.shortcuts.ShortcutsDialog.aSetShortcut
final Action aSetShortcut
The Action for the "set shortcut" button.
Definition: ShortcutsDialog.java:120