package jsynoptic.plugins.circuit.ui;
import java.awt.BorderLayout;
import java.awt.Font;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import jsynoptic.plugins.circuit.GatedSvgShape;
import jsynoptic.plugins.svg.ui.SvgShapePropertiesPanel;
import jsynoptic.plugins.circuit.GatedSvgShape.GatedSvgShapePropertiesNames;
import simtools.ui.JPropertiesPanel;
import simtools.ui.MenuResourceBundle;
import simtools.ui.ResourceFinder;
public class GatedSvgShapePropertiesPanel extends JPropertiesPanel{
protected static MenuResourceBundle resources = (MenuResourceBundle)ResourceFinder.get(GatedSvgShape.class);
protected SvgShapePropertiesPanel svgShapeProperties;
protected GatesPropertiesPanel gatesProperties;
public GatedSvgShapePropertiesPanel(String shapeName) {
super(shapeName);
JTabbedPane plotPane = new JTabbedPane();
// SVG shape properties
JPanel sp = new JPanel (new BorderLayout());
JLabel shapeTitle = new JLabel(resources.getStringValue("shape"));
shapeTitle.setFont(new Font("Dialog", Font.PLAIN,18));
sp.add(shapeTitle, BorderLayout.NORTH);
svgShapeProperties = new SvgShapePropertiesPanel(shapeName);
sp.add(svgShapeProperties, BorderLayout.CENTER);
plotPane.addTab(resources.getStringValue("shape"), sp);
// Gates properties
JPanel gp = new JPanel (new BorderLayout());
JLabel gatesTitle = new JLabel(resources.getStringValue("gates"));
gatesTitle.setFont(new Font("Dialog", Font.PLAIN,18));
gp.add(gatesTitle, BorderLayout.NORTH);
gatesProperties = new GatesPropertiesPanel();
gp.add(gatesProperties, BorderLayout.CENTER);
plotPane.addTab(resources.getStringValue("gates"), gp);
add(plotPane);
}
/* (non-Javadoc)
* @see simtools.ui.JPropertiesPanel#updateWarnings()
*/
public boolean updateWarnings() {
boolean res = svgShapeProperties.updateWarnings();
if (!res){
res = gatesProperties.updateWarnings();
}
return res;
}
/* (non-Javadoc)
* @see simtools.ui.JPropertiesPanel#setOwner(javax.swing.JDialog)
*/
public void setOwner(JDialog owner) {
super.setOwner(owner);
svgShapeProperties.setOwner(owner);
gatesProperties.setOwner(owner);
}
/* (non-Javadoc)
* @see simtools.util.NamedProperties#getPropertyNames()
*/
public String[] getPropertyNames() {
if (_propertyNames == null) {
_propertyNames = new GatedSvgShapePropertiesNames().getPropertyNames();
}
return _propertyNames;
}
/* (non-Javadoc)
* @see simtools.util.NamedProperties#getPropertyValue(java.lang.String)
*/
public Object getPropertyValue(String name) {
Object res = svgShapeProperties.getPropertyValue(name);
if (res == null){
res = gatesProperties.getPropertyValue(name);
}
return res;
}
/* (non-Javadoc)
* @see simtools.util.NamedProperties#setPropertyValue(java.lang.String, java.lang.Object)
*/
public void setPropertyValue(String name, Object value) {
svgShapeProperties.setPropertyValue(name, value);
gatesProperties.setPropertyValue(name, value);
}
}