Clear grand exchange selection on clear button press

Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
This commit is contained in:
Tomas Slusny
2019-11-10 21:15:37 +01:00
committed by Adam
parent 5614104900
commit 639006997c

View File

@@ -103,6 +103,7 @@ class GrandExchangeSearchPanel extends JPanel
searchBar.setBackground(ColorScheme.DARKER_GRAY_COLOR);
searchBar.setHoverBackgroundColor(ColorScheme.DARK_GRAY_HOVER_COLOR);
searchBar.addActionListener(e -> executor.execute(() -> priceLookup(false)));
searchBar.addClearListener(e -> updateSearch());
searchItemsPanel.setLayout(new GridBagLayout());
searchItemsPanel.setBackground(ColorScheme.DARK_GRAY_COLOR);
@@ -149,7 +150,7 @@ class GrandExchangeSearchPanel extends JPanel
executor.execute(() -> priceLookup(true));
}
private void priceLookup(boolean exactMatch)
private boolean updateSearch()
{
String lookup = searchBar.getText();
@@ -157,7 +158,7 @@ class GrandExchangeSearchPanel extends JPanel
{
searchItemsPanel.removeAll();
SwingUtilities.invokeLater(searchItemsPanel::updateUI);
return;
return false;
}
// Input is not empty, add searching label
@@ -165,8 +166,17 @@ class GrandExchangeSearchPanel extends JPanel
searchBar.setBackground(ColorScheme.DARKER_GRAY_COLOR);
searchBar.setEditable(false);
searchBar.setIcon(IconTextField.Icon.LOADING);
return true;
}
List<ItemPrice> result = itemManager.search(lookup);
private void priceLookup(boolean exactMatch)
{
if (!updateSearch())
{
return;
}
List<ItemPrice> result = itemManager.search(searchBar.getText());
if (result.isEmpty())
{
searchBar.setIcon(IconTextField.Icon.ERROR);
@@ -177,7 +187,7 @@ class GrandExchangeSearchPanel extends JPanel
}
// move to client thread to lookup item composition
clientThread.invokeLater(() -> processResult(result, lookup, exactMatch));
clientThread.invokeLater(() -> processResult(result, searchBar.getText(), exactMatch));
}
private void processResult(List<ItemPrice> result, String lookup, boolean exactMatch)