// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/kpdus/jad.html
// Decompiler options: packimports(3) fieldsfirst 
// Source File Name:   PropertySheet.java

package lt.ktu.gmj.propertySheet;

import java.awt.*;
import java.util.Vector;
import javax.swing.*;

// Referenced classes of package lt.ktu.gmj.propertySheet:
//			PropertyManager, Property, PropertyEditor

public class PropertySheet extends JScrollPane
	implements PropertyManager
{
	class PropertyPanel extends JPanel
		implements Scrollable
	{

		public Dimension getPreferredScrollableViewportSize()
		{
			return getPreferredSize();
		}

		public int getScrollableUnitIncrement(Rectangle rectangle, int i, int j)
		{
			Font font = getFont();
			return font == null ? 1 : font.getSize();
		}

		public int getScrollableBlockIncrement(Rectangle rectangle, int i, int j)
		{
			return i != 0 ? rectangle.height : rectangle.width;
		}

		public boolean getScrollableTracksViewportWidth()
		{
			return true;
		}

		public boolean getScrollableTracksViewportHeight()
		{
			return false;
		}

		public PropertyPanel()
		{
			super(bag);
		}
	}


	protected Vector properties;
	protected JPanel panel;
	GridBagLayout bag;

	public void removeAll()
	{
		properties.removeAllElements();
		panel.removeAll();
	}

	public void add(Property property)
	{
		GridBagConstraints gridbagconstraints = new GridBagConstraints();
		gridbagconstraints.insets = new Insets(3, 3, 2, 2);
		gridbagconstraints.gridy = properties.size();
		JComponent jcomponent = property.label();
		gridbagconstraints.weightx = 0.0D;
		gridbagconstraints.fill = 2;
		bag.setConstraints(jcomponent, gridbagconstraints);
		panel.add(jcomponent);
		JComponent jcomponent1 = property.editor().component();
		gridbagconstraints.weightx = 1.0D;
		gridbagconstraints.fill = 2;
		bag.setConstraints(jcomponent1, gridbagconstraints);
		panel.add(jcomponent1);
		properties.addElement(property);
	}

	public void complete()
	{
		panel.revalidate();
		revalidate();
		repaint();
	}

	public PropertySheet()
	{
		properties = new Vector();
		bag = new GridBagLayout();
		panel = new PropertyPanel();
		getViewport().setView(panel);
		setBackground(panel.getBackground());
		getViewport().setBackground(panel.getBackground());
	}
}
