Skip to content

Commit

Permalink
[BUGS#1225] fix: Bring Issues Panel to front on refresh (#834)
Browse files Browse the repository at this point in the history
* [BUGS#1225] fix: Bring Issues Panel to front on refresh

This commit introduces a change in the IssuesPanelController where the refreshData function is modified to bring the panel to the forefront each time it refreshes. This adjustment ensure that the refreshed panel remains visible and doesn't get hidden behind main window.
Resolved BUGS#1225

Signed-off-by: Hiroshi Miura <[email protected]>

* Update IssuesPanelController to prevent stealing focus

- Updates the IssuesPanelController to prevent the issues window from automatically requesting focus.
- Changes include removing the frame.toFront() call on refreshData() while adding it only when necessary, for instance when an entry is selected.
- An early return was added to prevent empty issue list processing.

Signed-off-by: Hiroshi Miura <[email protected]>

* refactor: IssuesPanelController

- Unify empty condition check

Signed-off-by: Hiroshi Miura <[email protected]>

---------

Signed-off-by: Hiroshi Miura <[email protected]>
  • Loading branch information
miurahr committed Dec 22, 2023
1 parent 690ed04 commit 7456c6e
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/org/omegat/gui/issues/IssuesPanelController.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ synchronized void init() {
}

frame = new JFrame(OStrings.getString("ISSUES_WINDOW_TITLE"));
frame.setAutoRequestFocus(false);
StaticUIUtils.setEscapeClosable(frame);
StaticUIUtils.setWindowIcon(frame);
if (Platform.isMacOSX()) {
Expand Down Expand Up @@ -594,7 +595,7 @@ protected void done() {
if (isCancelled()) {
return;
}
List<IIssue> allIssues = Collections.emptyList();
List<IIssue> allIssues;
try {
allIssues = get();
} catch (InterruptedException | ExecutionException e) {
Expand All @@ -607,10 +608,6 @@ protected void done() {
return;
}

if (allIssues.isEmpty()) {
panel.messageLabel.setText(OStrings.getString("ISSUES_NO_ISSUES_FOUND"));
}

panel.progressBar.setVisible(false);
StaticUIUtils.setHierarchyEnabled(panel, true);
panel.typeList.setModel(new TypeListModel(allIssues));
Expand All @@ -631,6 +628,10 @@ protected void done() {
}
colSizer.reset();
colSizer.adjustTableColumns();
if (allIssues.isEmpty()) {
panel.messageLabel.setText(OStrings.getString("ISSUES_NO_ISSUES_FOUND"));
return;
}
if (!jumpToTypes.isEmpty()) {
int[] indicies = ((TypeListModel) panel.typeList.getModel()).indiciesOfTypes(jumpToTypes);
if (indicies.length > 0) {
Expand All @@ -640,7 +641,11 @@ protected void done() {
if (jumpToEntry >= 0) {
IntStream.range(0, panel.table.getRowCount())
.filter(row -> (int) panel.table.getValueAt(row, IssueColumn.SEG_NUM.index) >= jumpToEntry)
.findFirst().ifPresent(jump -> panel.table.changeSelection(jump, 0, false, false));
.findFirst()
.ifPresent(jump -> {
panel.table.changeSelection(jump, 0, false, false);
frame.toFront();
});
}
panel.table.requestFocusInWindow();
}
Expand Down

0 comments on commit 7456c6e

Please sign in to comment.