package org.helioviewer.jhv.plugins.swek.view;

import java.awt.BorderLayout;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.JPanel;
import javax.swing.JTree;

import org.helioviewer.jhv.plugins.swek.config.SWEKEventType;
import org.helioviewer.jhv.plugins.swek.download.SWEKDownloadManager;
import org.helioviewer.jhv.plugins.swek.model.EventTypePanelModel;
import org.helioviewer.jhv.plugins.swek.model.SWEKTreeModelEventType;

/**
 * Panel display one event type
 * 
 * @author Bram Bourgoignie (Bram.Bourgoignie@oma.be)
 * 
 */
public class EventPanel extends JPanel implements MouseListener {
    /** seriolVersionUID */
    private static final long serialVersionUID = 1057300852220893978L;

    /** The event type for which the event panel is created */
    private final SWEKEventType eventType;

    /** Tree containing the event type and it's sources. */
    private JTree eventTypeTree;

    /** The model for this panel */
    private final EventTypePanelModel eventPanelModel;

    /** Instance of the download manager */
    private final SWEKDownloadManager downloadManager;

    /**
     * Creates a event panel for a certain
     */
    public EventPanel(SWEKEventType eventType) {
        this.downloadManager = SWEKDownloadManager.getSingletonInstance();
        this.eventType = eventType;
        this.eventPanelModel = new EventTypePanelModel(new SWEKTreeModelEventType(this.eventType));
        this.eventPanelModel.addEventPanelModelListener(this.downloadManager);
        initVisisualComponents();
    }

    /**
     * Initializes the visual components
     */
    private void initVisisualComponents() {
        setLayout(new BorderLayout());
        this.eventTypeTree = new JTree(this.eventPanelModel);
        this.eventTypeTree.setShowsRootHandles(true);
        this.eventTypeTree.setSelectionModel(null);
        this.eventTypeTree.addMouseListener(this);
        this.eventTypeTree.addTreeExpansionListener(this.eventPanelModel);
        this.eventTypeTree.setCellRenderer(new SWEKEventTreeRenderer());
        add(this.eventTypeTree, BorderLayout.CENTER);
    }

    @Override
    public void mouseClicked(MouseEvent e) {
        int clickedOnRow = this.eventTypeTree.getRowForLocation(e.getX(), e.getY());
        this.eventPanelModel.rowClicked(clickedOnRow);
        this.eventTypeTree.revalidate();
        this.eventTypeTree.repaint();
    }

    @Override
    public void mouseEntered(MouseEvent e) {

    }

    @Override
    public void mouseExited(MouseEvent e) {

    }

    @Override
    public void mousePressed(MouseEvent e) {

    }

    @Override
    public void mouseReleased(MouseEvent e) {

    }

}

@@ -71,16 +71,67 @@
 Layout;%0A
+import java.awt.Color;%0Aimport java.awt.GridLayout;%0A
 import j
@@ -192,16 +192,39 @@
 istener;
+%0Aimport java.util.List;
 %0A%0Aimport
@@ -539,16 +539,161 @@
 entType;
+%0Aimport org.helioviewer.jhv.plugins.swek.view.filter.AbstractFilterPanel;%0Aimport org.helioviewer.jhv.plugins.swek.view.filter.FilterPanelFactory;
 %0A%0A/**%0A *
@@ -1463,21 +1463,16 @@
         
-this.
 download
@@ -1561,37 +1561,32 @@
 ntType;%0A        
-this.
 eventPanelModel 
@@ -1656,37 +1656,32 @@
 Type));%0A        
-this.
 eventPanelModel.
@@ -1707,21 +1707,16 @@
 istener(
-this.
 download
@@ -1906,37 +1906,32 @@
 out());%0A        
-this.
 eventTypeTree = 
@@ -1940,21 +1940,16 @@
 w JTree(
-this.
 eventPan
@@ -1958,37 +1958,32 @@
 Model);%0A        
-this.
 eventTypeTree.se
@@ -2007,37 +2007,32 @@
 (true);%0A        
-this.
 eventTypeTree.se
@@ -2054,37 +2054,32 @@
 (null);%0A        
-this.
 eventTypeTree.ad
@@ -2100,37 +2100,32 @@
 (this);%0A        
-this.
 eventTypeTree.ad
@@ -2147,21 +2147,16 @@
 istener(
-this.
 eventPan
@@ -2165,37 +2165,32 @@
 Model);%0A        
-this.
 eventTypeTree.se
@@ -2245,21 +2245,16 @@
     add(
-this.
 eventTyp
@@ -2282,16 +2282,462 @@
 ENTER);%0A
+        List%3CAbstractFilterPanel%3E filterPanels = FilterPanelFactory.createFilterPanel(eventType);%0A        JPanel filterPanel = new JPanel();%0A        filterPanel.setLayout(new GridLayout(filterPanels.size(), 1));%0A        filterPanel.setOpaque(false);%0A        filterPanel.setBackground(Color.white);%0A        for (AbstractFilterPanel afp : filterPanels) %7B%0A            filterPanel.add(afp);%0A        %7D%0A        add(filterPanel, BorderLayout.PAGE_END);%0A
     %7D%0A%0A 
@@ -2821,21 +2821,16 @@
 OnRow = 
-this.
 eventTyp
@@ -2878,29 +2878,24 @@
 ));%0A        
-this.
 eventPanelMo
@@ -2924,37 +2924,32 @@
 OnRow);%0A        
-this.
 eventTypeTree.re
@@ -2960,37 +2960,32 @@
 date();%0A        
-this.
 eventTypeTree.re

Add the filter panel to the swekplugin panel