Connect a left-clicked bookmark on the current tab
Middle-click still opens the server in a new tab. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -8,6 +8,10 @@ import javax.swing.JMenu;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.KeyStroke;
|
||||
import javax.swing.MenuSelectionManager;
|
||||
import javax.swing.SwingUtilities;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
/**
|
||||
* The main window's menu bar: Connections, Bookmarks, Self, Tools and Help.
|
||||
@@ -45,7 +49,8 @@ final class MainMenuBar extends JMenuBar {
|
||||
|
||||
void onShowAbout();
|
||||
|
||||
void onConnectBookmark(Bookmark bookmark);
|
||||
/** @param newTab open the server in a new tab instead of replacing the current one */
|
||||
void onConnectBookmark(Bookmark bookmark, boolean newTab);
|
||||
|
||||
void onAddCurrentServerBookmark();
|
||||
|
||||
@@ -141,7 +146,16 @@ final class MainMenuBar extends JMenuBar {
|
||||
bookmarksMenu.removeAll();
|
||||
for (Bookmark b : bookmarks.all()) {
|
||||
JMenuItem item = new JMenuItem(b.displayName(), Icons.of("SERVER_GREEN"));
|
||||
item.addActionListener(e -> listener.onConnectBookmark(b));
|
||||
item.setToolTipText("Connect here (middle-click to open a new tab)");
|
||||
item.addActionListener(e -> listener.onConnectBookmark(b, false));
|
||||
item.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
if (!SwingUtilities.isMiddleMouseButton(e)) return;
|
||||
MenuSelectionManager.defaultManager().clearSelectedPath();
|
||||
listener.onConnectBookmark(b, true);
|
||||
}
|
||||
});
|
||||
bookmarksMenu.add(item);
|
||||
}
|
||||
if (!bookmarks.all().isEmpty()) bookmarksMenu.addSeparator();
|
||||
|
||||
Reference in New Issue
Block a user