@Override
 public void actionPerformed(final ActionEvent e) {
   if (FilterPanelAction.REMOVE.name().equals(e.getActionCommand())) {
     gui.remove(getThis());
     gui.addEmpty();
     refilter();
   }
   if (FilterPanelAction.FILTER.name().equals(e.getActionCommand())) {
     processFilterAction(e);
   }
   if (FilterPanelAction.FILTER_TIMER.name().equals(e.getActionCommand())) {
     if (!Settings.get().isFilterOnEnter()) {
       processFilterAction(e);
     }
   }
 }
  FilterPanel(final FilterGui<E> gui, final FilterControl<E> filterControl) {
    this.gui = gui;
    this.filterControl = filterControl;

    ListenerClass listener = new ListenerClass();

    allColumns = new ArrayList<EnumTableColumn<E>>();
    allColumns.add(new AllColumn<E>());
    allColumns.addAll(filterControl.getColumns());

    numericColumns = new ArrayList<EnumTableColumn<E>>();
    for (EnumTableColumn<E> object : filterControl.getColumns()) {
      if (filterControl.isNumeric(object)) {
        numericColumns.add(object);
      }
    }

    dateColumns = new ArrayList<EnumTableColumn<E>>();
    for (EnumTableColumn<E> object : filterControl.getColumns()) {
      if (filterControl.isDate(object)) {
        dateColumns.add(object);
      }
    }

    jEnabled = new JCheckBox();
    jEnabled.setSelected(true);
    jEnabled.addActionListener(listener);
    jEnabled.setActionCommand(FilterPanelAction.FILTER.name());

    jLogic = new JComboBox<LogicType>(LogicType.values());
    jLogic.setPrototypeDisplayValue(LogicType.AND);
    jLogic.addActionListener(listener);
    jLogic.setActionCommand(FilterPanelAction.FILTER.name());

    JComboBox<String> jComboBox = new JComboBox<String>();
    FontMetrics fontMetrics = jComboBox.getFontMetrics(jComboBox.getFont());
    EnumTableColumn<E> longestColumn = null;
    for (EnumTableColumn<E> column : allColumns) {
      if (longestColumn == null
          || fontMetrics.stringWidth(longestColumn.getColumnName())
              < fontMetrics.stringWidth(column.getColumnName())) {
        longestColumn = column;
      }
    }

    jColumn =
        new JComboBox<EnumTableColumn<E>>(new ListComboBoxModel<EnumTableColumn<E>>(allColumns));
    jColumn.setPrototypeDisplayValue(longestColumn);
    jColumn.addActionListener(listener);
    jColumn.setActionCommand(FilterPanelAction.FILTER.name());

    jCompare = new JComboBox<CompareType>();
    jCompare.setPrototypeDisplayValue(CompareType.CONTAINS_NOT_COLUMN);
    jCompare.addActionListener(listener);
    jCompare.setActionCommand(FilterPanelAction.FILTER.name());

    jText = new JTextField();
    jText.getDocument().addDocumentListener(listener);
    jText.addKeyListener(listener);

    jCompareColumn = new JComboBox<EnumTableColumn<E>>();
    jCompareColumn.setPrototypeDisplayValue(longestColumn);
    jCompareColumn.addActionListener(listener);
    jCompareColumn.setActionCommand(FilterPanelAction.FILTER.name());

    jDate = new JDateChooser(false);
    jDate.addDateChangeListener(listener);

    jSpacing = new JLabel();

    jRemove = new JButton();
    jRemove.setIcon(Images.EDIT_DELETE.getIcon());
    jRemove.addActionListener(listener);
    jRemove.setActionCommand(FilterPanelAction.REMOVE.name());

    timer = new Timer(500, listener);
    timer.setActionCommand(FilterPanelAction.FILTER_TIMER.name());

    jPanel = new JPanel();

    layout = new GroupLayout(jPanel);
    jPanel.setLayout(layout);
    layout.setAutoCreateGaps(true);
    layout.setAutoCreateContainerGaps(false);

    layout.setHorizontalGroup(
        layout
            .createSequentialGroup()
            .addComponent(jEnabled, 30, 30, 30)
            .addComponent(
                jLogic,
                GroupLayout.PREFERRED_SIZE,
                GroupLayout.PREFERRED_SIZE,
                GroupLayout.PREFERRED_SIZE)
            .addComponent(
                jColumn,
                GroupLayout.PREFERRED_SIZE,
                GroupLayout.PREFERRED_SIZE,
                GroupLayout.PREFERRED_SIZE)
            .addComponent(
                jCompare,
                GroupLayout.PREFERRED_SIZE,
                GroupLayout.PREFERRED_SIZE,
                GroupLayout.PREFERRED_SIZE)
            .addComponent(jText, 100, 100, Integer.MAX_VALUE)
            .addComponent(
                jCompareColumn,
                GroupLayout.PREFERRED_SIZE,
                GroupLayout.PREFERRED_SIZE,
                GroupLayout.PREFERRED_SIZE)
            .addComponent(
                jDate,
                GroupLayout.PREFERRED_SIZE,
                GroupLayout.PREFERRED_SIZE,
                GroupLayout.PREFERRED_SIZE)
            .addComponent(jSpacing, 0, 0, Integer.MAX_VALUE)
            .addComponent(jRemove, 30, 30, 30));
    layout.setVerticalGroup(
        layout
            .createParallelGroup()
            .addComponent(
                jEnabled,
                Program.getButtonsHeight(),
                Program.getButtonsHeight(),
                Program.getButtonsHeight())
            .addComponent(
                jLogic,
                Program.getButtonsHeight(),
                Program.getButtonsHeight(),
                Program.getButtonsHeight())
            .addComponent(
                jColumn,
                Program.getButtonsHeight(),
                Program.getButtonsHeight(),
                Program.getButtonsHeight())
            .addComponent(
                jCompare,
                Program.getButtonsHeight(),
                Program.getButtonsHeight(),
                Program.getButtonsHeight())
            .addComponent(
                jText,
                Program.getButtonsHeight(),
                Program.getButtonsHeight(),
                Program.getButtonsHeight())
            .addComponent(
                jCompareColumn,
                Program.getButtonsHeight(),
                Program.getButtonsHeight(),
                Program.getButtonsHeight())
            .addComponent(
                jDate,
                Program.getButtonsHeight(),
                Program.getButtonsHeight(),
                Program.getButtonsHeight())
            .addComponent(
                jSpacing,
                Program.getButtonsHeight(),
                Program.getButtonsHeight(),
                Program.getButtonsHeight())
            .addComponent(
                jRemove,
                Program.getButtonsHeight(),
                Program.getButtonsHeight(),
                Program.getButtonsHeight()));
    updateNumeric(false);
  }