Package jsynoptic.builtin.ui

Source Code of jsynoptic.builtin.ui.HistoryPropertiesPanel

/* ========================
* JSynoptic : a free Synoptic editor
* ========================
*
* Project Info:  http://jsynoptic.sourceforge.net/index.html
*
* This program is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* (C) Copyright 2001-2004, by :
*     Corporate:
*         EADS Astrium SAS
*         EADS CRC
*     Individual:
*         Nicolas Brodu
*        Jean-Baptiste Lièvremont
*
* $$Id: HistoryPropertiesPanel.java,v 1.14 2008/07/22 09:25:17 ogor Exp $$
*
* Changes
* -------
*
*/
package jsynoptic.builtin.ui;

import java.awt.Dimension;
import java.util.ResourceBundle;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSpinner;
import javax.swing.SpinnerNumberModel;

import jsynoptic.builtin.HistoryShape;
import simtools.ui.GridBagPanel;
import simtools.ui.ResourceFinder;

/**
* @author zxpletran007
* @deprecated see HistoryTExtPropertiesPanel
*
*/
public class HistoryPropertiesPanel extends TextArrayPropertiesPanel {
    public static ResourceBundle resources = ResourceFinder.get(HistoryShape.class);

    protected JPanel historyTextPanel;

    protected JSpinner spiHistSize;

    protected SpinnerNumberModel spiModelHistSize;

    // NumberField nfHistSize;
    public HistoryPropertiesPanel(String shapeName) {
        super(shapeName, false);
    }

    public void select(int index) {
        if (textPanels.size() > 0) {
            TextPropertiesPanel tpp = (TextPropertiesPanel) textPanels.get(0);
            tpp.updateSourceTree();
        }
    }

    protected JComponent createContents() {
        JLabel lhistorySize = new JLabel(resources.getString("HistorySize:"));
        spiModelHistSize = new SpinnerNumberModel();
        spiModelHistSize.setStepSize(new Integer(1));
        spiModelHistSize.setMinimum(new Integer(1));
        spiHistSize = new JSpinner(spiModelHistSize);
        spiHistSize.setPreferredSize(new Dimension(120, 20));
        historyTextPanel = new JPanel();
       
        // Create panel
        GridBagPanel historyPanel = new GridBagPanel();
        GridBagPanel historySizePanel = new GridBagPanel();
        historySizePanel.addOnCurrentRow(lhistorySize);
        historySizePanel.addOnCurrentRow(spiHistSize);
        historySizePanel.carriageReturn();
        historyPanel.addOnCurrentRow(historySizePanel, 1, true, false, true);
        historyPanel.addOnCurrentRow(historyTextPanel, 1, true, true, true);
        return historyPanel;
    }

    public String[] getPropertyNames() {
        if (_propertyNames == null) {
            _propertyNames = new HistoryShape.HistoryShapePropertiesNames().getPropertyNames();
        }
        return _propertyNames;
    }

    public void setPropertyValue(String name, Object value) {
        super.setPropertyValue(name, value);
        if (name.equalsIgnoreCase("HISTORY_SIZE")) {
            if (value instanceof Integer) {
                spiHistSize.setValue((value));
            }
        } else if (name.equalsIgnoreCase("TEXT_ARRAY_CELL_LIST")) {
            if (textPanels.size() > 0) {
                historyTextPanel.add((TextPropertiesPanel) textPanels.get(0));
            }
        }
    }

    public Object getPropertyValue(String name) {
        Object res = super.getPropertyValue(name);
        if (name.equalsIgnoreCase("HISTORY_SIZE")) {
            int size = ((Number) spiHistSize.getValue()).intValue();
            if (size < 1) {
                size = 1; // At least one cell
            }
            res = new Integer(size);
        }
        return res;
    }
}
TOP

Related Classes of jsynoptic.builtin.ui.HistoryPropertiesPanel

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.