Package jsynoptic.builtin.ui

Source Code of jsynoptic.builtin.ui.BarPropertiesPanel

package jsynoptic.builtin.ui;

import java.util.ResourceBundle;

import javax.swing.JComponent;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;

import jsynoptic.builtin.BarShape;
import jsynoptic.builtin.BarShape.BarShapePropertiesNames;
import simtools.data.DataInfo;
import simtools.data.DataSource;
import simtools.ui.FilteredSourceTree;
import simtools.ui.GridBagPanel;
import simtools.ui.ResourceFinder;

public class BarPropertiesPanel  extends PropertiesPanel2D {
   
    public static ResourceBundle resources = ResourceFinder.get(BarShape.class);
   
    protected AxePropertiesPanel axeProp;
    protected FilteredSourceTree dstreeProg;

    public BarPropertiesPanel(String shapeName) {
        super(true, false, true, false,shapeName);

        addOnCurrentRow(createDataSourceSelectionContent(), 1, true, true, true);
        addOnCurrentRow( axeProp = new AxePropertiesPanel(resources.getString("axeProperties"), "barAxis", false, shapeName), 1, true, false, true);

        updateWarnings();
    }

    protected JComponent createDataSourceSelectionContent() {
        GridBagPanel dsSelPanel = new GridBagPanel(resources.getString("selectDataSource"));

        dstreeProg = FilteredSourceTree.getFromPool("PropertiesPanel0");
        dstreeProg.getSourceTree().addTreeSelectionListener(new TreeSelectionListener() {
            public void valueChanged(TreeSelectionEvent e) {
                updateWarnings();

                if ((dstreeProg.getSelectedSourceOrCollection() instanceof DataSource)) {
                    axeProp.setLabel( DataInfo.getLabel(dstreeProg.getSelectedSourceOrCollection()) );
                }

                axeProp.setEnabled((dstreeProg.getSelectedSourceOrCollection() instanceof DataSource));
            }
        });

        dsSelPanel.addOnCurrentRow(dstreeProg, 1, true, true, true);
        return dsSelPanel;
    }

   
    /*
     * (non-Javadoc)
     *
     * @see jsynoptic.builtin.ui.PropertiesPanel1D#updateWarnings()
     */
    public boolean updateWarnings() {
        boolean res;
       
        if (!(dstreeProg.getSelectedSourceOrCollection() instanceof DataSource)) {
            displayWarning(resources.getString("selectADataSource"));
            res = true;
           
        } else {
            res = super.updateWarnings();
        }
       
        return res;
    }

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

    public void setPropertyValue(String name, Object value) {
        super.setPropertyValue(name, value);
       
        if (name.equalsIgnoreCase("PROGRESS_SOURCE")) {
            dstreeProg.setSelectedValue(value);
            axeProp.setEnabled(value instanceof DataSource);
        }
       
        axeProp.setPropertyValue(name, value);
    }

    public Object getPropertyValue(String name) {
        Object res = super.getPropertyValue(name);

        if (res == null){
            res = axeProp.getPropertyValue(name);

            if (res == null){
                if (name.equalsIgnoreCase("PROGRESS_SOURCE")) {
                    res = dstreeProg.getSelectedSourceOrCollection();
                }
            }  
        }
        return res;
    }
}
TOP

Related Classes of jsynoptic.builtin.ui.BarPropertiesPanel

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.