Two-column bookmark manager with connect-on-startup
Replace the modal add/edit form with a master/detail dialog: bookmark list on the left, the selected bookmark's settings on the right. Edits are flushed back into the bookmark when the selection changes or the dialog closes. Bookmarks gain a "connect on startup" flag (only one at a time, since the client holds a single connection); MainFrame connects to it once the window is up. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -17,16 +17,16 @@ final class IdentityChooser extends JComboBox<Object> {
|
||||
|
||||
private static final String USE_DEFAULT = "‹Default identity›";
|
||||
|
||||
private final IdentityStore identities;
|
||||
private final boolean allowDefault;
|
||||
|
||||
IdentityChooser(IdentityStore identities, boolean allowDefault, String selectedId) {
|
||||
this.identities = identities;
|
||||
this.allowDefault = allowDefault;
|
||||
if (allowDefault) addItem(USE_DEFAULT);
|
||||
for (IdentityEntry e : identities.all()) addItem(e);
|
||||
|
||||
IdentityEntry selected = identities.byId(selectedId);
|
||||
if (selected != null) {
|
||||
setSelectedItem(selected);
|
||||
} else if (allowDefault) {
|
||||
setSelectedItem(USE_DEFAULT);
|
||||
}
|
||||
setSelectedIdentityId(selectedId);
|
||||
|
||||
setRenderer(new DefaultListCellRenderer() {
|
||||
@Override
|
||||
@@ -45,4 +45,14 @@ final class IdentityChooser extends JComboBox<Object> {
|
||||
Object v = getSelectedItem();
|
||||
return v instanceof IdentityEntry ? ((IdentityEntry) v).getId() : "";
|
||||
}
|
||||
|
||||
/** Selects the identity with the given id, falling back to the default entry. */
|
||||
void setSelectedIdentityId(String id) {
|
||||
IdentityEntry selected = identities.byId(id);
|
||||
if (selected != null) {
|
||||
setSelectedItem(selected);
|
||||
} else if (allowDefault) {
|
||||
setSelectedItem(USE_DEFAULT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user