/*
 * Copyright (c) 2006-2011 DMDirc Developers
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

package com.dmdirc.addons.ui_swing.dialogs.channellist;

import com.dmdirc.lists.GroupListManager;
import com.dmdirc.lists.GroupListObserver;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

import net.miginfocom.swing.MigLayout;

/** Gathers input for a group list search and begins the search. */
public class SearchTermsPanel extends JPanel implements ActionListener, GroupListObserver {

    /** Serial version UID. */
    private static final long serialVersionUID = 1L;
    /** Group list manager to perform searches on. */
    private GroupListManager manager;
    /** Search terms input field. */
    private JTextField searchTerms;
    /** Search button. */
    private JButton search;

    /**
     * Creates a new panel to gather input for a group list search.
     *
     * @param manager Group list manager to perform search with
     */
    public SearchTermsPanel(final GroupListManager manager) {
        this.manager = manager;
        searchTerms = new JTextField();
        layoutComponents();
        manager.addGroupListObserver(this);
    }

    /** Lays out the components in the panel. */
    private void layoutComponents() {
        search = new JButton("Search");
        search.addActionListener(this);
        setLayout(new MigLayout("fill, hidemode 3, ins 0"));
        add(new JLabel("Search terms: "), "align label");
        add(searchTerms, "growx, pushx");
        add(search, "");
    }

    /**
     * {@inheritDoc}
     *
     * @param e Action event
     */
    @Override
    public void actionPerformed(final ActionEvent e) {
        manager.startSearch(searchTerms.getText());
        search.setEnabled(false);
    }

    /** {@inheritDoc} */
    @Override
    public void onGroupListStarted() {
        //Ignore
    }

    /** {@inheritDoc} */
    @Override
    public void onGroupListFinished() {
        if (search != null) {
            search.setEnabled(true);
        }
    }
}

@@ -1452,16 +1452,50 @@
 Field;%0A%0A
+import lombok.AutoGenMethodStub;%0A%0A
 import n
@@ -1525,16 +1525,16 @@
 Layout;%0A
-
 %0A/** Gat
@@ -1594,16 +1594,35 @@
 rch. */%0A
+@AutoGenMethodStub%0A
 public c
@@ -1684,16 +1684,24 @@
 istener,
+%0A       
  GroupLi
@@ -2549,24 +2549,69 @@
 ener(this);%0A
+        searchTerms.addActionListener(this);%0A
         setL
@@ -3030,110 +3030,8 @@
  %7D%0A%0A
-    /** %7B@inheritDoc%7D */%0A    @Override%0A    public void onGroupListStarted() %7B%0A        //Ignore%0A    %7D%0A%0A
     

Add support for enter pressing in the text field. Add lombok craziness.