Index: Controller.java =================================================================== RCS file: /cvs/core/output2/src/org/netbeans/core/output2/Controller.java,v retrieving revision 1.28 diff -u -r1.28 Controller.java --- Controller.java 14 Oct 2004 12:22:57 -0000 1.28 +++ Controller.java 19 Oct 2004 12:33:04 -0000 @@ -75,6 +75,8 @@ private static final int ACTION_POSTMENU = 10; private static final int ACTION_FINDPREVIOUS = 11; private static final int ACTION_CLEAR = 12; + private static final int ACTION_NEXTTAB = 13; + private static final int ACTION_PREVTAB = 14; //Package private for unit tests Action copyAction = new ControllerAction (ACTION_COPY, @@ -102,6 +104,10 @@ Action postMenuAction = new ControllerAction (ACTION_POSTMENU, "postMenu", //NOI18N KeyStroke.getKeyStroke(KeyEvent.VK_F10, KeyEvent.SHIFT_DOWN_MASK)); Action clearAction = new ControllerAction (ACTION_CLEAR, "ACTION_CLEAR"); + Action nextTabAction = new ControllerAction (ACTION_NEXTTAB, "nextTab", //NOI18N + KeyStroke.getKeyStroke(KeyEvent.VK_N, KeyEvent.ALT_DOWN_MASK)); + Action prevTabAction = new ControllerAction (ACTION_PREVTAB, "prevTab", //NOI18N + KeyStroke.getKeyStroke(KeyEvent.VK_P, KeyEvent.ALT_DOWN_MASK)); private Object[] popupItems = new Object[] { copyAction, new JSeparator(), findAction, findNextAction, @@ -112,7 +118,7 @@ private Action[] kbdActions = new Action[] { copyAction, selectAllAction, findAction, findNextAction, findPreviousAction, wrapAction, saveAsAction, closeAction, - navToLineAction, postMenuAction, clearAction, + navToLineAction, postMenuAction, clearAction, nextTabAction, prevTabAction, }; Controller() {} @@ -357,6 +363,14 @@ case ACTION_POSTMENU : if (log) log ("Action POSTMENU received"); postPopupMenu(win, tab, new Point(0,0), tab); + break; + case ACTION_NEXTTAB : + if (log) log ("Action NEXTTAB received"); + win.selectNextTab(tab); + break; + case ACTION_PREVTAB : + if (log) log ("Action PREVTAB received"); + win.selectPreviousTab(tab); break; case ACTION_CLEAR : if (log) log ("Action CLEAR receieved"); Index: ui/AbstractOutputWindow.java =================================================================== RCS file: /cvs/core/output2/src/org/netbeans/core/output2/ui/AbstractOutputWindow.java,v retrieving revision 1.7 diff -u -r1.7 AbstractOutputWindow.java --- ui/AbstractOutputWindow.java 18 Aug 2004 02:59:28 -0000 1.7 +++ ui/AbstractOutputWindow.java 19 Oct 2004 12:33:04 -0000 @@ -125,6 +125,49 @@ return result; } + /** + * Set next tab relatively to the given tab. If the give tab is the last one + * the first is selected. + * + * @param tab relative tab + */ + public final void selectNextTab(AbstractOutputTab tab) { + AbstractOutputTab[] tabs = this.getTabs(); + if (tabs.length > 1) { + int nextTabIndex = getSelectedTabIndex(tabs, tab) + 1; + if (nextTabIndex > (tabs.length - 1)) { + nextTabIndex = 0; + } + this.setSelectedTab(tabs[nextTabIndex]); + } + } + + /** + * Set previous tab relatively to the given tab. If the give tab is the + * first one the last is selected. + * + * @param tab relative tab + */ + public final void selectPreviousTab(AbstractOutputTab tab) { + AbstractOutputTab[] tabs = this.getTabs(); + if (tabs.length > 1) { + int prevTabIndex = getSelectedTabIndex(tabs, tab) - 1; + if (prevTabIndex < 0) { + prevTabIndex = tabs.length - 1; + } + this.setSelectedTab(tabs[prevTabIndex]); + } + } + + private int getSelectedTabIndex(AbstractOutputTab[] tabs, AbstractOutputTab tab) { + for (int i = 0; i < tabs.length; i++) { + if (tabs[i] == tab) { + return i; + } + } + return -1; + } + public void remove (Component c) { AbstractOutputTab removedSelectedView = null;