mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-11 01:32:08 +10:00
optimize the code
This commit is contained in:
+2
-2
@@ -72,7 +72,7 @@ public class CloudBrowserFrame extends JFrame {
|
|||||||
@Override
|
@Override
|
||||||
public void setVisible(boolean b) {
|
public void setVisible(boolean b) {
|
||||||
super.setVisible(b);
|
super.setVisible(b);
|
||||||
if (b) {
|
if (b && !getSearchHeaderPanel().isInitialized()) {
|
||||||
executeBackgroundTask(new ITask<Pair<String[], String[]>>() {
|
executeBackgroundTask(new ITask<Pair<String[], String[]>>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -88,7 +88,7 @@ public class CloudBrowserFrame extends JFrame {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void complete(Pair<String[], String[]> result) {
|
public void complete(Pair<String[], String[]> result) {
|
||||||
getSearchHeaderPanel().updateLists(result.getFirst(), result.getSecond());
|
getSearchHeaderPanel().initializeLists(result.getFirst(), result.getSecond());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-5
@@ -23,6 +23,8 @@ public class SearchHeaderPanel extends JPanel {
|
|||||||
private JComboBox sortBox;
|
private JComboBox sortBox;
|
||||||
private JButton goButton;
|
private JButton goButton;
|
||||||
|
|
||||||
|
private boolean initialized = false;
|
||||||
|
|
||||||
public SearchHeaderPanel() {
|
public SearchHeaderPanel() {
|
||||||
setLayout(new GridBagLayout());
|
setLayout(new GridBagLayout());
|
||||||
|
|
||||||
@@ -65,13 +67,14 @@ public class SearchHeaderPanel extends JPanel {
|
|||||||
getSearchField().requestFocusInWindow();
|
getSearchField().requestFocusInWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateLists(String[] categories, String[] sortings) {
|
public void initializeLists(String[] categories, String[] sortings) {
|
||||||
Object selectedCategory = getCategoryBox().getSelectedItem();
|
|
||||||
Object selectedSorting = getSortBox().getSelectedItem();
|
|
||||||
getCategoryBox().setModel(new DefaultComboBoxModel(categories));
|
getCategoryBox().setModel(new DefaultComboBoxModel(categories));
|
||||||
getSortBox().setModel(new DefaultComboBoxModel(sortings));
|
getSortBox().setModel(new DefaultComboBoxModel(sortings));
|
||||||
getCategoryBox().setSelectedItem(selectedCategory);
|
initialized = true;
|
||||||
getSortBox().setSelectedItem(selectedSorting);
|
}
|
||||||
|
|
||||||
|
public boolean isInitialized() {
|
||||||
|
return initialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
private JTextField getSearchField() {
|
private JTextField getSearchField() {
|
||||||
|
|||||||
Reference in New Issue
Block a user