/* ========================
* 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-2008, by :
* Corporate:
* EADS Astrium SAS
* EADS CRC
* Individual:
* Claude Cazenave
*
* $Id: EmitterPropertiesPanel.java,v 1.2 2008/10/24 15:49:58 ogor Exp $
*
* Changes
* -------
* 7 oct. 2008 : Initial public release (CC);
*
*/
package jsynoptic.plugins.circuit.ui;
import java.util.ResourceBundle;
import javax.swing.JDialog;
import simtools.ui.DynamicColorPanel;
import simtools.ui.ResourceFinder;
import jsynoptic.builtin.ui.PropertiesPanel2D;
import jsynoptic.plugins.circuit.CircuitPlugin;
import jsynoptic.plugins.circuit.boxes.Emitter.EmitterPropertiesNames;
/**
*
* @author zxpletran007
*
*/
public class EmitterPropertiesPanel extends PropertiesPanel2D {
protected DynamicColorPanel emitterPanel;
public static ResourceBundle resources = ResourceFinder.get(CircuitPlugin.class);
public EmitterPropertiesPanel(String shapeName) {
super(true, true, true, true, shapeName);
emitterPanel = new DynamicColorPanel(this.getOwner(), resources.getString("emitterColorMapper"), true);
addOnCurrentRow(emitterPanel, 2, true, true, true);
}
/* (non-Javadoc)
* @see simtools.ui.JPropertiesPanel#setOwner(javax.swing.JDialog)
*/
public void setOwner(JDialog owner) {
emitterPanel.setOwner(owner);
super.setOwner(owner);
}
public String[] getPropertyNames() {
if (_propertyNames == null) {
_propertyNames = new EmitterPropertiesNames().getPropertyNames();
}
return _propertyNames;
}
/*
* (non-Javadoc)
*
* @see simtools.ui.JPropertiesPanel#getPropertyValue(java.lang.String)
*/
public Object getPropertyValue(String name) {
Object res = super.getPropertyValue(name);
if (name.equalsIgnoreCase("EMITTER_MAPPER_SOURCE")) {
res = emitterPanel.getPropertyValue(DynamicColorPanel.DYNAMIC_COLOR_SOURCE);
} else if (name.equalsIgnoreCase("EMITTER_MAPPER")) {
res = emitterPanel.getPropertyValue(DynamicColorPanel.DYNAMIC_COLOR_MAPPER);
}
return res;
}
/*
* (non-Javadoc)
*
* @see simtools.ui.JPropertiesPanel#setPropertyValue(java.lang.String,
* java.lang.Object)
*/
public void setPropertyValue(String name, Object value) {
super.setPropertyValue(name, value);
if (name.equalsIgnoreCase("EMITTER_MAPPER")) {
emitterPanel.setPropertyValue(DynamicColorPanel.DYNAMIC_COLOR_MAPPER, value);
} else if (name.equalsIgnoreCase("EMITTER_MAPPER_SOURCE")) {
emitterPanel.setPropertyValue(DynamicColorPanel.DYNAMIC_COLOR_SOURCE, value);
}
}
public boolean updateWarnings(){
boolean res = emitterPanel.updateWarnings();
if (!res){
res = super.updateWarnings();
}
return res;
}
}