From 40493ca049f6226deccca2d75cdc5fa2ea8740e7 Mon Sep 17 00:00:00 2001 From: lucab Date: Tue, 9 May 2023 16:00:35 +0200 Subject: [PATCH] Added correct labeling, added message box in case of no found matches in find function --- resources/messages.properties | 1 + src/net/azib/ipscan/gui/FindDialog.java | 7 ++++--- src/net/azib/ipscan/gui/actions/GotoMenuActions.java | 10 +++++++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/resources/messages.properties b/resources/messages.properties index 18ff05c2..65b76cd3 100644 --- a/resources/messages.properties +++ b/resources/messages.properties @@ -120,6 +120,7 @@ text.hostsSelected=\u00A0hosts selected text.favorite.add=Enter the name of the new favorite text.favorite.edit=Below you can rearrange or delete favorites text.find=Enter the text to search for +text.found=matches were found text.find.notFound=End of the list reached without matches. text.find.restart=Restart from the beginning? text.comment.edit=Comment diff --git a/src/net/azib/ipscan/gui/FindDialog.java b/src/net/azib/ipscan/gui/FindDialog.java index 512fa261..44a0c3e8 100644 --- a/src/net/azib/ipscan/gui/FindDialog.java +++ b/src/net/azib/ipscan/gui/FindDialog.java @@ -1,5 +1,6 @@ package net.azib.ipscan.gui; +import net.azib.ipscan.config.Labels; import net.azib.ipscan.gui.util.LayoutHelper; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.FormAttachment; @@ -32,15 +33,15 @@ public class FindDialog extends AbstractModalDialog{ indexLabel.setLayoutData(LayoutHelper.formData(new FormAttachment(0), null, new FormAttachment(messageLabel), null)); previousButton = new Button(shell, SWT.NONE); - previousButton.setText("<"); + previousButton.setText(Labels.getLabel("button.left")); previousButton.setLayoutData(LayoutHelper.formData(new FormAttachment(messageLabel), null, new FormAttachment(messageLabel), null)); nextButton = new Button(shell, SWT.NONE); - nextButton.setText(">"); + nextButton.setText(Labels.getLabel("button.right")); nextButton.setLayoutData(LayoutHelper.formData(new FormAttachment(previousButton), null, new FormAttachment(messageLabel), null)); closeButton = new Button(shell, SWT.NONE); - closeButton.setText("close"); + closeButton.setText(Labels.getLabel("button.close")); closeButton.setLayoutData(LayoutHelper.formData(new FormAttachment(nextButton), null, new FormAttachment(messageLabel), null)); nextButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() { diff --git a/src/net/azib/ipscan/gui/actions/GotoMenuActions.java b/src/net/azib/ipscan/gui/actions/GotoMenuActions.java index e92904d7..80eeb3af 100644 --- a/src/net/azib/ipscan/gui/actions/GotoMenuActions.java +++ b/src/net/azib/ipscan/gui/actions/GotoMenuActions.java @@ -145,8 +145,16 @@ public class GotoMenuActions { ArrayList foundMatches = findMatches(text); int selectionIndex = 0; + if(foundMatches.size() == 0){ + MessageBox messageBox = new MessageBox(statusBar.getShell(), SWT.OK | SWT.ICON_INFORMATION); + messageBox.setText(Labels.getLabel("title.find")); + messageBox.setMessage(Labels.getLabel("text.find.notFound")); + messageBox.open(); + return; + } + while(true){ - FindDialog find = new FindDialog("Find", foundMatches.size() + " matches were found"); + FindDialog find = new FindDialog(Labels.getLabel("title.find"), foundMatches.size() + " " + Labels.getLabel("text.found")); resultTable.setSelection(selectionIndex); resultTable.setFocus(); int flag = find.open(selectionIndex + 1, foundMatches.size());