001/**
002 * 
003 */
004package icy.gui.inspector;
005
006import icy.gui.frame.ActionFrame;
007import icy.preferences.XMLPreferences;
008
009import java.awt.BorderLayout;
010import java.awt.Dimension;
011import java.awt.event.ActionEvent;
012import java.awt.event.ActionListener;
013
014/**
015 * Frame to change ROI table settings.
016 * 
017 * @author Stephane
018 */
019public class RoiSettingFrame extends ActionFrame
020{
021    final RoiSettingPanel settingPanel;
022
023    public RoiSettingFrame(XMLPreferences viewPreferences, XMLPreferences exportPreferences, final Runnable onValidate)
024    {
025        super("ROI table setting", true);
026
027        settingPanel = new RoiSettingPanel(viewPreferences, exportPreferences);
028        getMainPanel().add(settingPanel, BorderLayout.CENTER);
029
030        setPreferredSize(new Dimension(520, 480));
031        setOkAction(new ActionListener()
032        {
033            @Override
034            public void actionPerformed(ActionEvent e)
035            {
036                // save setting
037                settingPanel.save();
038                // call callback
039                if (onValidate != null)
040                    onValidate.run();
041            }
042        });
043
044        pack();
045        addToDesktopPane();
046        setVisible(true);
047        center();
048        requestFocus();
049    }
050}