Revision: 3721
Author: [email protected]
Date: Tue Jul 13 10:25:39 2010
Log: Added a hotkey (ctrl-tab) to quickly cycle through tabs.
http://code.google.com/p/power-architect/source/detail?r=3721
Modified:
/trunk/src/main/java/ca/sqlpower/architect/swingui/ArchitectFrame.java
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/ArchitectFrame.java
Tue Jul 13 07:41:54 2010
+++ /trunk/src/main/java/ca/sqlpower/architect/swingui/ArchitectFrame.java
Tue Jul 13 10:25:39 2010
@@ -469,6 +469,8 @@
private JMenuItem newWindowMenu;
+ private AbstractAction cycleTabAction;
+
/**
* Sets up a new ArchitectFrame, which represents a window containing
one or
* more {...@link ArchitectSwingSession}s. It will not become visible
until
@@ -679,6 +681,24 @@
closeProjectAction = new CloseProjectAction(this);
+ cycleTabAction = new AbstractAction() {
+ public void actionPerformed(ActionEvent e) {
+ int index = stackedTabPane.getSelectedIndex();
+ int max = stackedTabPane.getTabCount();
+ if ((e.getModifiers() & ActionEvent.SHIFT_MASK) == 0) {
+ index++;
+ } else {
+ index--;
+ }
+ index = (index+max)%max;
+ stackedTabPane.setSelectedIndex(index);
+ }
+ };
+ // Before you ask, yes, I did mean to use control and not the
+ // accelerator key. This is in use in major browsers.
+ cycleTabAction.putValue(AbstractAction.ACCELERATOR_KEY,
+ KeyStroke.getKeyStroke(KeyEvent.VK_TAB,
ActionEvent.CTRL_MASK));
+
prefAction = new PreferencesAction(this);
projectSettingsAction = new ProjectSettingsAction(this);
printAction = new PrintAction(this);
@@ -1047,6 +1067,10 @@
helpMenu.add(checkForUpdateAction);
menuBar.add(helpMenu);
+ menuBar.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB,
ActionEvent.CTRL_MASK), "cycleTabAction");
+ menuBar.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB,
ActionEvent.CTRL_MASK+ActionEvent.SHIFT_MASK), "cycleTabAction");
+ menuBar.getActionMap().put("cycleTabAction", cycleTabAction);
+
return menuBar;
}