Author: mvw
Date: 2008-07-07 08:47:29-0700
New Revision: 15191
Added:
trunk/src/argouml-app/src/org/argouml/ui/cmd/ActionWrapper.java
- copied, changed from r15164, /trunk/src/argouml-app/src/org/argouml/ui/cmd/Action.java
Removed:
trunk/src/argouml-app/src/org/argouml/ui/cmd/Action.java
Modified:
trunk/src/argouml-app/src/org/argouml/ui/cmd/SettingsTabShortcuts.java
trunk/src/argouml-app/src/org/argouml/ui/cmd/ShortcutMgr.java
Log:
First step for issue 5207: Make the code readable.
Removed: trunk/src/argouml-app/src/org/argouml/ui/cmd/Action.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/ui/cmd/Action.java?view=auto&rev=15190
Copied: trunk/src/argouml-app/src/org/argouml/ui/cmd/ActionWrapper.java (from r15164, /trunk/src/argouml-app/src/org/argouml/ui/cmd/Action.java)
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/ui/cmd/ActionWrapper.java?view=diff&rev=15191&p1=/trunk/src/argouml-app/src/org/argouml/ui/cmd/Action.java&p2=trunk/src/argouml-app/src/org/argouml/ui/cmd/ActionWrapper.java&r1=15164&r2=15191
==============================================================================
--- /trunk/src/argouml-app/src/org/argouml/ui/cmd/Action.java (original)
+++ trunk/src/argouml-app/src/org/argouml/ui/cmd/ActionWrapper.java 2008-07-07 08:47:29-0700
@@ -32,7 +32,7 @@
*
* @author [email protected]
*/
-public class Action {
+class ActionWrapper {
private KeyStroke defaultShortcut;
@@ -45,7 +45,7 @@
private String actionInstanceName;
/**
- * Constructor for Action class
+ * Constructor for ActionWrapper class
*
* @param actionKey
* the key of this action
@@ -58,7 +58,7 @@
* @param actionName
* the name of the action
*/
- protected Action(String actionKey, KeyStroke currentKeyStroke,
+ protected ActionWrapper(String actionKey, KeyStroke currentKeyStroke,
KeyStroke defaultKeyStroke, AbstractAction action,
String actionName) {
this.key = actionKey;
Modified: trunk/src/argouml-app/src/org/argouml/ui/cmd/SettingsTabShortcuts.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/ui/cmd/SettingsTabShortcuts.java?view=diff&rev=15191&p1=trunk/src/argouml-app/src/org/argouml/ui/cmd/SettingsTabShortcuts.java&p2=trunk/src/argouml-app/src/org/argouml/ui/cmd/SettingsTabShortcuts.java&r1=15190&r2=15191
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/ui/cmd/SettingsTabShortcuts.java (original)
+++ trunk/src/argouml-app/src/org/argouml/ui/cmd/SettingsTabShortcuts.java 2008-07-07 08:47:29-0700
@@ -1,5 +1,5 @@
// $Id$
-// Copyright (c) 2006-2007 The Regents of the University of California. All
+// Copyright (c) 2006-2008 The Regents of the University of California. All
// Rights Reserved. Permission to use, copy, modify, and distribute this
// software and its documentation without fee, and without a written
// agreement is hereby granted, provided that the above copyright notice
@@ -95,9 +95,9 @@
private JLabel warningLabel = new JLabel(" ");
- private Action target;
+ private ActionWrapper target;
- private Action[] actions = ShortcutMgr.getShortcuts();
+ private ActionWrapper[] actions = ShortcutMgr.getShortcuts();
private int lastRowSelected = -1;
@@ -233,7 +233,7 @@
* the new target
*/
private void setTarget(Object t) {
- target = (Action) t;
+ target = (ActionWrapper) t;
// let's enable the radiobuttons container
enableFields(true);
// updating the radiobuttons container's title
@@ -324,7 +324,7 @@
// if a shortcut has been select then we have to check if the actual
// action is in conflict with other ones
if (!noneButton.isSelected()) {
- Action oldAction = getActionAlreadyAssigned(ShortcutMgr
+ ActionWrapper oldAction = getActionAlreadyAssigned(ShortcutMgr
.decodeKeyStroke(shortcutField.getText()));
if (oldAction != null) {
// this shortcut was already been assigned to another action;
@@ -367,7 +367,7 @@
* the KeyStroke to be checked
* @return the Action that has already been assigned
*/
- public Action getActionAlreadyAssigned(KeyStroke keyStroke) {
+ public ActionWrapper getActionAlreadyAssigned(KeyStroke keyStroke) {
for (int i = 0; i < actions.length; i++) {
if (actions[i].getCurrentShortcut() != null
&& actions[i].getCurrentShortcut().equals(keyStroke)
@@ -459,7 +459,7 @@
* @param newKeyStroke the key stroke to be checked
*/
private void checkShortcutAlreadyAssigned(KeyStroke newKeyStroke) {
- Action oldAction = getActionAlreadyAssigned(newKeyStroke);
+ ActionWrapper oldAction = getActionAlreadyAssigned(newKeyStroke);
if (oldAction != null) {
// the shortcut has already been assigned to another action!
this.shortcutField.setBackground(Color.YELLOW);
@@ -474,7 +474,7 @@
}
/**
- * Table model for the table with modules.
+ * Table model for the table with actions and shortcuts.
*/
class ShortcutTableModel extends AbstractTableModel {
@@ -485,7 +485,7 @@
elements = new Object[actions.length][3];
for (int i = 0; i < elements.length; i++) {
- Action currentAction = actions[i];
+ ActionWrapper currentAction = actions[i];
elements[i][0] = currentAction.getActionName();
elements[i][1] = currentAction.getCurrentShortcut();
elements[i][2] = currentAction.getDefaultShortcut();
@@ -534,8 +534,8 @@
@Override
public void setValueAt(Object ob, int row, int col) {
// if the given object is a KeyStroke instance, then we ca
- if (ob instanceof Action) {
- Action newValueAction = (Action) ob;
+ if (ob instanceof ActionWrapper) {
+ ActionWrapper newValueAction = (ActionWrapper) ob;
for (int i = 0; i < elements.length; i++) {
if (elements[i][0].equals(newValueAction.getActionName())) {
elements[i][1] = newValueAction.getCurrentShortcut();
@@ -560,7 +560,8 @@
/*
* @see javax.swing.table.TableModel#getColumnClass(int)
*/
- public Class getColumnClass(int col) {
+ @Override
+ public Class<?> getColumnClass(int col) {
switch (col) {
case 0:
return String.class;
@@ -581,10 +582,6 @@
return false;
}
- /**
- * The UID.
- */
- private static final long serialVersionUID = -5970280716477119863L;
}
}
@@ -594,10 +591,6 @@
* @author [email protected]
*/
class KeyStrokeCellRenderer extends DefaultTableCellRenderer {
- /**
- * The UID.
- */
- private static final long serialVersionUID = -7086302679799095974L;
/**
* Construct a table cell rendered for key strokes.
Modified: trunk/src/argouml-app/src/org/argouml/ui/cmd/ShortcutMgr.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/ui/cmd/ShortcutMgr.java?view=diff&rev=15191&p1=trunk/src/argouml-app/src/org/argouml/ui/cmd/ShortcutMgr.java&p2=trunk/src/argouml-app/src/org/argouml/ui/cmd/ShortcutMgr.java&r1=15190&r2=15191
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/ui/cmd/ShortcutMgr.java (original)
+++ trunk/src/argouml-app/src/org/argouml/ui/cmd/ShortcutMgr.java 2008-07-07 08:47:29-0700
@@ -310,25 +310,27 @@
private static final int SHIFTED_DEFAULT_MASK = Toolkit.getDefaultToolkit()
.getMenuShortcutKeyMask() | KeyEvent.SHIFT_DOWN_MASK;
- private static HashMap shortcutHash = new HashMap(90);
+ private static HashMap<String, ActionWrapper> shortcutHash =
+ new HashMap<String, ActionWrapper>(90);
- private static HashMap duplicate = new HashMap(10);
+ private static HashMap<KeyStroke, KeyStroke> duplicate =
+ new HashMap<KeyStroke, KeyStroke>(10);
/**
- * Return the shortcuts as an Actions array
+ * Return the shortcuts as an ActionWrapper array
*
- * @return an array of Actions
+ * @return an array of ActionWrappers
*/
- public static Action[] getShortcuts() {
- Action[] actions = (Action[]) shortcutHash.values().toArray(
- new Action[shortcutHash.size()]);
- Arrays.sort(actions, new Comparator() {
- public int compare(Object o1, Object o2) {
- String name1 = ((Action) o1).getActionName();
+ static ActionWrapper[] getShortcuts() {
+ ActionWrapper[] actions = shortcutHash.values().toArray(
+ new ActionWrapper[shortcutHash.size()]);
+ Arrays.sort(actions, new Comparator<ActionWrapper>() {
+ public int compare(ActionWrapper o1, ActionWrapper o2) {
+ String name1 = o1.getActionName();
if (name1 == null) {
name1 = "";
}
- String name2 = ((Action) o2).getActionName();
+ String name2 = o2.getActionName();
if (name2 == null) {
name2 = "";
}
@@ -348,15 +350,14 @@
*/
public static void assignAccelerator(JMenuItem menuItem,
String shortcutKey) {
- Action shortcut = (Action) shortcutHash.get(shortcutKey);
+ ActionWrapper shortcut = shortcutHash.get(shortcutKey);
if (shortcut != null) {
KeyStroke keyStroke = shortcut.getCurrentShortcut();
if (keyStroke != null) {
menuItem.setAccelerator(keyStroke);
}
- KeyStroke alternativeKeyStroke = (KeyStroke) duplicate
- .get(keyStroke);
+ KeyStroke alternativeKeyStroke = duplicate.get(keyStroke);
if (alternativeKeyStroke != null) {
String actionName = (String) menuItem.getAction().getValue(
AbstractAction.NAME);
@@ -378,7 +379,7 @@
*/
public static void assignAccelerator(JPanel panel,
String shortcutKey) {
- Action shortcut = (Action) shortcutHash.get(shortcutKey);
+ ActionWrapper shortcut = shortcutHash.get(shortcutKey);
if (shortcut != null) {
KeyStroke keyStroke = shortcut.getCurrentShortcut();
@@ -386,8 +387,7 @@
panel.registerKeyboardAction(shortcut.getActionInstance(),
keyStroke, JComponent.WHEN_FOCUSED);
}
- KeyStroke alternativeKeyStroke = (KeyStroke) duplicate
- .get(keyStroke);
+ KeyStroke alternativeKeyStroke = duplicate.get(keyStroke);
if (alternativeKeyStroke != null) {
String actionName = (String)
shortcut.getActionInstance().getValue(AbstractAction.NAME);
@@ -406,8 +406,8 @@
* @param keyStroke the KeyStroke to search for
* @return the duplicate, or null if not present
*/
- public static KeyStroke getDuplicate(KeyStroke keyStroke) {
- return (KeyStroke) duplicate.get(keyStroke);
+ static KeyStroke getDuplicate(KeyStroke keyStroke) {
+ return duplicate.get(keyStroke);
}
/**
@@ -417,8 +417,8 @@
* the id of the action
* @return the given action, or null if the action is not found
*/
- public static Action getShortcut(String actionId) {
- return (Action) shortcutHash.get(actionId);
+ public static ActionWrapper getShortcut(String actionId) {
+ return shortcutHash.get(actionId);
}
private static void putDefaultShortcut(String shortcutKey,
@@ -445,7 +445,8 @@
currentKeyStroke = decodeKeyStroke(confCurrentShortcut);
}
- Action currentShortcut = new Action(shortcutKey, currentKeyStroke,
+ ActionWrapper currentShortcut =
+ new ActionWrapper(shortcutKey, currentKeyStroke,
defaultKeyStroke, action, actionName);
shortcutHash.put(shortcutKey, currentShortcut);
}
@@ -486,9 +487,9 @@
* @param newActions
* the actions array
*/
- public static void saveShortcuts(Action[] newActions) {
+ static void saveShortcuts(ActionWrapper[] newActions) {
for (int i = 0; i < newActions.length; i++) {
- Action oldAction = (Action) shortcutHash
+ ActionWrapper oldAction = shortcutHash
.get(newActions[i].getKey());
if (newActions[i].getCurrentShortcut() == null
&& newActions[i].getDefaultShortcut() != null) {
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.