Skip to content

Commit 3371883

Browse files
committed
feat: Focus on username field if server url is not empty in 'Connect to Confluence' dialog.
1 parent 19597ed commit 3371883

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

plugins/confluence/src/main/java/com/github/vogoltsov/vp/plugins/confluence/dialog/ConfluenceServerConnectionDialog.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,9 @@ public boolean verify(JComponent input) {
8787
}
8888
});
8989
this.confluenceServerUrlField.getDocument().addDocumentListener(
90-
(DocumentListenerAdapter) e -> {
91-
this.connectButton.setEnabled(!this.confluenceServerUrlField.getText().isEmpty());
92-
}
90+
(DocumentListenerAdapter) e -> this.connectButton.setEnabled(!this.confluenceServerUrlField.getText().isEmpty())
9391
);
94-
this.confluenceServerUrlField.addActionListener(e -> this.usernameField.requestFocus());
92+
this.confluenceServerUrlField.addActionListener(e -> this.usernameField.requestFocusInWindow());
9593
contentsPanel.add(this.confluenceServerUrlField, gbc);
9694
}
9795
// new row
@@ -140,7 +138,7 @@ public boolean verify(JComponent input) {
140138
this.usernameField.getDocument().addDocumentListener(
141139
(DocumentListenerAdapter) e -> this.passwordField.setEnabled(!this.usernameField.getText().isEmpty())
142140
);
143-
this.usernameField.addActionListener(e -> this.passwordField.requestFocus());
141+
this.usernameField.addActionListener(e -> this.passwordField.requestFocusInWindow());
144142
contentsPanel.add(this.usernameField, gbc);
145143
}
146144
// new row
@@ -187,6 +185,15 @@ protected void load() {
187185
.ifPresent(this.passwordField::setText);
188186
}
189187

188+
@Override
189+
public void shown() {
190+
if (!this.confluenceServerUrlField.getText().isEmpty()) {
191+
this.usernameField.requestFocusInWindow();
192+
} else {
193+
this.confluenceServerUrlField.requestFocusInWindow();
194+
}
195+
}
196+
190197
private void connect() {
191198
try {
192199
ConfluenceClient client = new ConfluenceClient();

0 commit comments

Comments
 (0)