/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
* This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. 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 General Public License for more details. *
* You should have received a copy of the GNU 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. *
* For the text or an alternative of this public license, you may reach us *
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
* or via info@compiere.org or http://www.compiere.org/license.html *
*****************************************************************************/
package org.compiere.install.util;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Insets;
import java.awt.LayoutManager;
import java.awt.LayoutManager2;
import java.util.Arrays;
import java.util.Iterator;
/**
* Application Layout Manager.
*
* panel.setLayout(new ALayout());
* panel.add(field11, new ALayoutConstraint(0,0));
* panel.add(field12, null);
* panel.add(field13, null);
* panel.add(field14, null);
* panel.add(field21, new ALayoutConstraint(1,0));
*
*
* @author Jorg Janke
* @version $Id: ALayout.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $
*/
public class ALayout implements LayoutManager2
{
/**
* Default Constructor with spacing of 2 and columns filled
*/
public ALayout()
{
this (2,4, true);
} // ALayout
/**
* Detail Constructor
* @param spaceH horizontal space (top, between rows, button)
* @param spaceV vertical space (left, between columns, right)
* @param colFill fields are fully filled (rather then preferred size)
*/
public ALayout(int spaceH, int spaceV, boolean colFill)
{
setSpaceH(spaceH);
setSpaceV(spaceV);
m_colFill = colFill;
} // ALayout
/** Data Storage */
private ALayoutCollection m_data = new ALayoutCollection();
/** Horizontal Space */
private int m_spaceH;
/** Vertical Space */
private int m_spaceV;
/** Column Fill */
private boolean m_colFill;
/**
* Add To Layout with NULL constraint
*
* @param name the string to be associated with the component - ignored
* @param comp the component to be added
*/
public void addLayoutComponent(String name, Component comp)
{
addLayoutComponent (comp, null);
} // addLayoutComponent
/**
* Adds the specified component to the layout, using the specified
* constraint object. If the constraint is not a ALayoutConstraint
* the component is added with a NULL constraint.
*
* Components with a NULL constraint are added as the next column to the last row
*
* @param component the component to be added
* @param constraint where/how the component is added to the layout.
* @see ALayoutConstraint
*/
public void addLayoutComponent(Component component, Object constraint)
{
ALayoutConstraint con = null;
if (constraint instanceof ALayoutConstraint)
con = (ALayoutConstraint)constraint;
//
m_data.put(con, component);
} // addLayoutComponent
/**
* Removes the specified component from the layout.
* @param comp the component to be removed
*/
public void removeLayoutComponent(Component comp)
{
if (!m_data.containsValue(comp))
return;
Iterator