Skip to content

Commit

Permalink
Adds 'Select Tab' popup menu entry
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanue1 committed Jul 1, 2015
1 parent 7e56f6d commit 3675930
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions app/src/main/groovy/jd/gui/view/component/panel/TabbedPanel.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import jd.gui.api.feature.PreferencesChangeListener
import jd.gui.api.feature.UriGettable
import jd.gui.service.platform.PlatformService

import javax.swing.AbstractAction
import javax.swing.JComponent
import javax.swing.JMenu
import javax.swing.JMenuItem
import javax.swing.JPopupMenu
import javax.swing.ToolTipManager
Expand All @@ -19,6 +21,7 @@ import java.awt.BorderLayout
import java.awt.CardLayout
import java.awt.Color
import java.awt.Component
import java.awt.Font
import java.awt.event.ActionEvent
import java.awt.event.ActionListener

Expand Down Expand Up @@ -179,6 +182,27 @@ class TabbedPanel extends JPanel implements PreferencesChangeListener {
})
add(menuItem)

// Add 'Select Tab' popup menu entry
if ((tabbedPane.tabCount > 1) && (PlatformService.instance.isMac || 'true'.equals(preferences.get(TAB_LAYOUT)))) {
addSeparator()
def menu = new JMenu('Select Tab')
int count = tabbedPane.tabCount

for (int i=0; i<count; i++) {
def subMenuItem = new JMenuItem(tabbedPane.getTitleAt(i), null)
subMenuItem.addActionListener(new ActionListener() {
final int index = i
void actionPerformed(ActionEvent e) { tabbedPane.setSelectedIndex(index) }
})
if (component == tabbedPane.getComponentAt(i)) {
subMenuItem.font = subMenuItem.font.deriveFont(Font.BOLD)
}
menu.add(subMenuItem)
}

add(menu)
}

// Add SPI popup menu entries
def actions = api.getContextualActions(component.entry, null)

Expand Down

0 comments on commit 3675930

Please sign in to comment.