package hep.aida.ref.plotter.style.registry;

import java.awt.Component;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Vector;

import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.border.EtchedBorder;
import javax.swing.border.TitledBorder;

import org.freehep.util.FreeHEPLookup;
import org.openide.util.Lookup;

public class OpenStyleStorePanel extends JPanel {
    private Component parent;
    private String title;
    private JPanel thisPanel;
    private JComboBox storeList;
    private JButton update;
    private Vector list;
    private Map map;
    
    public OpenStyleStorePanel() {
        this("Open Style Store");
    }
    public OpenStyleStorePanel(Component parent) {
        this(parent, "Open Style Store");
    }
    public OpenStyleStorePanel(String title) {
        this(null, title);
    }
    public OpenStyleStorePanel(Component parent, String title) {
        super();
        this.parent = parent;
        this.title = title;
        thisPanel = this;
        initComponents();
    }
    
    private void initComponents() {
        list = new Vector();
        map = new HashMap();
        
        update = new JButton("Update");
        update.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ev) {
                updateAction();
            }
        });
        
        storeList = new JComboBox();
        this.setBorder(new TitledBorder(new EtchedBorder(), title));
        java.awt.GridBagConstraints gbc = new java.awt.GridBagConstraints();
        gbc.anchor = java.awt.GridBagConstraints.WEST;
        gbc.insets =  new java.awt.Insets(2, 2, 2, 2);
        
        this.setLayout(new java.awt.GridBagLayout());
        
        gbc.gridy=0; gbc.gridx=0;
        this.add(new JLabel(" Store: "), gbc);
        gbc.gridx=1;
        this.add(storeList, gbc);
        gbc.gridx=2;
        this.add(update, gbc);
        
        updateAction();
    }
    
    
    public void updateAction() {
         list.clear();
         map.clear();
         
         StyleRegistry registry = StyleRegistry.getStyleRegistry();
         String[] stores = registry.getAvailableStoreNames();
         if (stores != null) {
             for (int i=0; i 

Ads help maintain this website.