Package tvbrowser.core.filters

Examples of tvbrowser.core.filters.FilterComponent


    setProgramFilter(filter);

    // set channel group filter
    String channelGroupName = Settings.propLastUsedChannelGroup.getString();
    if (channelGroupName != null) {
      FilterComponent component = FilterComponentList.getInstance().getFilterComponentByName(channelGroupName);
      if (component != null && component instanceof ChannelFilterComponent) {
        setChannelGroup((ChannelFilterComponent) component);
      }
    }
View Full Code Here


    menuItemAdd.addActionListener(new ActionListener() {

      public void actionPerformed(ActionEvent e) {
        EditFilterComponentDlg dlg = new EditFilterComponentDlg(null, null,
            ChannelFilterComponent.class);
        FilterComponent rule = dlg.getFilterComponent();
        if ((rule != null) && (rule instanceof ChannelFilterComponent)) {
          FilterComponentList.getInstance().add(rule);
          FilterComponentList.getInstance().store();
          MainFrame.getInstance()
              .setChannelGroup((ChannelFilterComponent) rule);
        }
      }
    });
    menu.add(menuItemAdd);
    // edit channel group
    JMenuItem menuItemEdit = createMenuItem("channelGroupEdit",
        "Edit current channel group", null, true);
    menuItemEdit.addActionListener(new ActionListener() {

      public void actionPerformed(ActionEvent e) {
        FilterComponent rule = MainFrame.getInstance().getChannelGroup();
        if (rule != null) {
          // rule must be removed before editing it, otherwise the dialog doesn't save it
          FilterComponentList.getInstance().remove(rule.getName());
          EditFilterComponentDlg dlg = new EditFilterComponentDlg(null, rule);
          FilterComponent newRule = dlg.getFilterComponent();
          if (newRule == null) { // restore original rule
            newRule = rule;
          }
          FilterComponentList.getInstance().add(newRule);
          FilterComponentList.getInstance().store();
View Full Code Here

          }
        } else {
          JRadioButtonMenuItem filterItem = (JRadioButtonMenuItem) e
              .getSource();
          String filterName = filterItem.getText();
          final FilterComponent component = FilterComponentList.getInstance()
              .getFilterComponentByName(filterName);
          if (component != null && component instanceof ChannelFilterComponent) {
            setChannelGroup((ChannelFilterComponent) component);
          } else {
            setChannelGroup(null);
View Full Code Here

      time -= 60 * 24;
    }

    Channel[] channels = Plugin.getPluginManager().getSubscribedChannels();
    if ((mChannels != null) && (mChannels.getSelectedIndex() > 0)) {
      FilterComponent component = FilterComponentList.getInstance().getFilterComponentByName(mChannels.getSelectedItem().toString());
      if (component instanceof ChannelFilterComponent) {
        channels = ((ChannelFilterComponent) component).getChannels();
      }
    }

View Full Code Here

    mChannels.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        // user defined selection
        if (mChannels.getSelectedIndex() == mChannels.getItemCount()-1) {
          EditFilterComponentDlg dlg = new EditFilterComponentDlg(null, null, ChannelFilterComponent.class);
          FilterComponent rule = dlg.getFilterComponent();
          if (rule == null) {
            return;
          }
          if (! (rule instanceof ChannelFilterComponent)) {
            return;
          }
          FilterComponentList.getInstance().add(rule);
          FilterComponentList.getInstance().store();
          String filterName = rule.getName();
          mChannels.removeAllItems();
          mChannels.addItem(mLocalizer.msg("filterAll", "all channels"));
          for (String channel : FilterComponentList.getInstance().getChannelFilterNames()) {
            mChannels.addItem(channel);
          }
View Full Code Here

  }

  private void setFilterComponent(FilterComponent comp) {
    for (int i = 1; // index 0 does not contain a FilterComponent object
    i < mRuleCb.getItemCount(); i++) {
      FilterComponent c = (FilterComponent) mRuleCb.getItemAt(i);
      if (c.toString().equals(comp.toString())) {
        DefaultComboBoxModel model = (DefaultComboBoxModel) mRuleCb.getModel();
        model.removeElementAt(i);
        model.insertElementAt(comp, i);
        mRuleCb.setSelectedIndex(i);
        mNameTF.setText(comp.getName());
View Full Code Here

      if (mRulePanel != null) {
        mCenterPanel.remove(mRulePanel);
      }
      Object item = mRuleCb.getSelectedItem();
      if (item instanceof FilterComponent) {
        FilterComponent fItem = (FilterComponent) item;
        mRulePanel = fItem.getSettingsPanel();
        mRulePanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
        mCenterPanel.add(mRulePanel, BorderLayout.CENTER);
      }
      mContentPane.updateUI();
      updateOkBtn();

    } else if (o == mOkBtn) {

      String compName = mNameTF.getText();

      if (FilterComponentList.getInstance().exists(compName)) {

        JOptionPane.showMessageDialog(this, "Component '" + compName + "' already exists");
      } else {

        FilterComponent c = (FilterComponent) mRuleCb.getSelectedItem();
        c.saveSettings();
        mSelectedFilterComponent = c;
        mSelectedFilterComponent.setName(compName);
        mSelectedFilterComponent.setDescription(mDescTF.getText());
        setVisible(false);
      }
View Full Code Here

  public void actionPerformed(ActionEvent e) {

    Object o = e.getSource();
    if (o == mNewBtn) {
      EditFilterComponentDlg dlg = new EditFilterComponentDlg(mParent);
      FilterComponent rule = dlg.getFilterComponent();
      if (rule != null) {
        mComponentTableModel.addElement(rule);
        tvbrowser.core.filters.FilterComponentList.getInstance().add(rule);
        String text = mFilterRuleTF.getText();
        if (text.length() > 0) {
          text += " " + mFilterLocalizer.msg("or", "or") + " ";
        }
        text += rule.getName();
        mFilterRuleTF.setText(text);

      }
    } else if (o == mEditBtn) {
      int inx = mRuleTableBox.getSelectedRow();

      if(inx == -1) {
        return;
      }

      FilterComponent rule = mComponentTableModel.getElement(inx);
      FilterComponentList.getInstance().remove(rule.getName());
      mComponentTableModel.removeElement(rule);
      EditFilterComponentDlg dlg = new EditFilterComponentDlg(mParent, rule);
      FilterComponent newRule = dlg.getFilterComponent();
      if (newRule == null) {
        newRule = rule;
      }
      FilterComponentList.getInstance().add(newRule);
      mComponentTableModel.addElement(newRule);
      // mRuleListBox.repaint();
      updateBtns();

    } else if (o == mRuleTableBox) {
      updateBtns();
    } else if (o == mRemoveBtn) {
      boolean allowRemove = true;
      UserFilter[] userFilterArr = mFilterList.getUserFilterArr();
      FilterComponent fc = mComponentTableModel.getElement(mRuleTableBox.getSelectedRow());

      // Create the Filter based on the new Rule and check if the FC exists
      // there
      UserFilter testFilter = new UserFilter("test");

      try {
        testFilter.setRule(mFilterRuleTF.getText());

        if (testFilter.containsRuleComponent(fc.getName())) {
          allowRemove = false;
          JOptionPane.showMessageDialog(this, mLocalizer.msg("usedByAnotherFilter",
              "This filter component is used by filter '{0}'\nRemove the filter first.", mFilterNameTF.getText()));
        }
      } catch (Exception ex) {
        // Filter creation failed, assume the old one is correct
        if ((mFilter != null) && (mFilter.containsRuleComponent(fc.getName()))) {
          allowRemove = false;
          JOptionPane.showMessageDialog(this, mLocalizer.msg("usedByAnotherFilter",
              "This filter component is used by filter '{0}'\nRemove the filter first.", mFilterNameTF.getText()));
        }
      }

      for (int i = 0; i < userFilterArr.length && allowRemove; i++) {
        if ((userFilterArr[i] != mFilter) && userFilterArr[i].containsRuleComponent(fc.getName())) {
          allowRemove = false;
          JOptionPane.showMessageDialog(this, mLocalizer.msg("usedByAnotherFilter",
              "This filter component is used by filter '{0}'\nRemove the filter first.", userFilterArr[i].toString()));
        }
      }
      if (allowRemove) {
        FilterComponentList.getInstance().remove(fc.getName());
        mComponentTableModel.removeElement(mRuleTableBox.getSelectedRow());
        updateBtns();
      }

    } else if (o == mOkBtn) {
View Full Code Here

    }

    public Object getValueAt(int rowIndex, int columnIndex) {
      Object row = dataVector.get(rowIndex);
      if (row instanceof FilterComponent) {
        FilterComponent comp = (FilterComponent) row;

        if (columnIndex == 0) {
          return comp.getName();
        } else if (columnIndex == 1) {
          return comp.getDescription();
        }

      }
      return "?";
    }
View Full Code Here

TOP

Related Classes of tvbrowser.core.filters.FilterComponent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.