Clear grand exchange selection on clear button press
Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
This commit is contained in:
@@ -103,6 +103,7 @@ class GrandExchangeSearchPanel extends JPanel
|
|||||||
searchBar.setBackground(ColorScheme.DARKER_GRAY_COLOR);
|
searchBar.setBackground(ColorScheme.DARKER_GRAY_COLOR);
|
||||||
searchBar.setHoverBackgroundColor(ColorScheme.DARK_GRAY_HOVER_COLOR);
|
searchBar.setHoverBackgroundColor(ColorScheme.DARK_GRAY_HOVER_COLOR);
|
||||||
searchBar.addActionListener(e -> executor.execute(() -> priceLookup(false)));
|
searchBar.addActionListener(e -> executor.execute(() -> priceLookup(false)));
|
||||||
|
searchBar.addClearListener(e -> updateSearch());
|
||||||
|
|
||||||
searchItemsPanel.setLayout(new GridBagLayout());
|
searchItemsPanel.setLayout(new GridBagLayout());
|
||||||
searchItemsPanel.setBackground(ColorScheme.DARK_GRAY_COLOR);
|
searchItemsPanel.setBackground(ColorScheme.DARK_GRAY_COLOR);
|
||||||
@@ -149,7 +150,7 @@ class GrandExchangeSearchPanel extends JPanel
|
|||||||
executor.execute(() -> priceLookup(true));
|
executor.execute(() -> priceLookup(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void priceLookup(boolean exactMatch)
|
private boolean updateSearch()
|
||||||
{
|
{
|
||||||
String lookup = searchBar.getText();
|
String lookup = searchBar.getText();
|
||||||
|
|
||||||
@@ -157,7 +158,7 @@ class GrandExchangeSearchPanel extends JPanel
|
|||||||
{
|
{
|
||||||
searchItemsPanel.removeAll();
|
searchItemsPanel.removeAll();
|
||||||
SwingUtilities.invokeLater(searchItemsPanel::updateUI);
|
SwingUtilities.invokeLater(searchItemsPanel::updateUI);
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Input is not empty, add searching label
|
// Input is not empty, add searching label
|
||||||
@@ -165,8 +166,17 @@ class GrandExchangeSearchPanel extends JPanel
|
|||||||
searchBar.setBackground(ColorScheme.DARKER_GRAY_COLOR);
|
searchBar.setBackground(ColorScheme.DARKER_GRAY_COLOR);
|
||||||
searchBar.setEditable(false);
|
searchBar.setEditable(false);
|
||||||
searchBar.setIcon(IconTextField.Icon.LOADING);
|
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())
|
if (result.isEmpty())
|
||||||
{
|
{
|
||||||
searchBar.setIcon(IconTextField.Icon.ERROR);
|
searchBar.setIcon(IconTextField.Icon.ERROR);
|
||||||
@@ -177,7 +187,7 @@ class GrandExchangeSearchPanel extends JPanel
|
|||||||
}
|
}
|
||||||
|
|
||||||
// move to client thread to lookup item composition
|
// 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)
|
private void processResult(List<ItemPrice> result, String lookup, boolean exactMatch)
|
||||||
|
|||||||
Reference in New Issue
Block a user