private void updateCheckboxes(List<SearchEngine> engines) {
   for (SearchEngine se : engines) {
     JCheckBox cBox = engineCheckboxes.get(se);
     if (cBox != null) {
       if (cBox.isEnabled() && !cBox.isSelected() && se.isEnabled()) {
         continue;
       }
       cBox.setSelected(se.isEnabled());
       cBox.setEnabled(se.isEnabled());
     }
   }
 }
 public void updateFiltersPanel() {
   generalFilter =
       new GeneralResultFilter(resultPanel, sliderSeeds, sliderSize, textFieldKeywords);
   updateCheckboxes(SearchEngine.getEngines());
   resultPanel.filterChanged(new SearchEngineFilter(engineCheckboxes), 0);
   resultPanel.filterChanged(generalFilter, 1);
 }
 private JComponent createSearchEnginesFilter() {
   JPanel panel = new JPanel();
   panel.setLayout(new MigLayout("insets 3, wrap 2"));
   List<SearchEngine> searchEngines = SearchEngine.getEngines();
   setupCheckboxes(searchEngines, panel);
   return panel;
 }
Example #4
0
 public void search(String str, int filter) {
   // this.contentPane.removeAll();
   // this.contentPane.add(topMenu);
   // this.contentPane.add(panel);
   // this.contentPane.add(resultPanel);
   // mainWindow.messageBox.showMessage("Error Opening", "There was trouble opening this node..\n
   // contact sanjay verma");
   this.resultPanel.removeAll();
   this.button.setEnabled(false);
   this.textField.setEnabled(false);
   this.comboBox.setEnabled(false);
   this.btnCancel.setEnabled(true);
   updateResultLabel(0, 0);
   this.repaint();
   layoutCount = 0;
   SearchEngine se = new SearchEngine();
   se.setData(str, filter, this);
   th = new Thread(se);
   th.start();
   // se.search(str,this);
 }
  private void setupCheckboxes(List<SearchEngine> searchEngines, JPanel parent) {

    final Map<JCheckBox, BooleanSetting> cBoxes = new HashMap<JCheckBox, BooleanSetting>();

    ItemListener listener =
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            if (areAll(false)) {
              ((JCheckBox) e.getItemSelectable()).setSelected(true);
            }

            if (resultPanel != null) {
              resultPanel.filterChanged(new SearchEngineFilter(engineCheckboxes), 0);
            }
          }
        };

    for (SearchEngine se : searchEngines) {
      JCheckBox cBox = new JCheckBox(se.getName());
      cBox.setSelected(se.isEnabled());
      cBox.setEnabled(se.isEnabled());

      if (!cBox.isEnabled()) {
        cBox.setToolTipText(
            se.getName()
                + " "
                + I18n.tr(
                    "has been disabled on your FrostWire Search Options. (Go to Tools > Options > Search to enable)"));
      }

      parent.add(cBox);

      cBoxes.put(cBox, se.getEnabledSetting());
      cBox.addItemListener(listener);

      engineCheckboxes.put(se, cBox);
    }
  }