Index: buix/src/java/org/codelutin/buix/layoutinfo/GridBagLayoutInfo.java diff -u buix/src/java/org/codelutin/buix/layoutinfo/GridBagLayoutInfo.java:1.8 buix/src/java/org/codelutin/buix/layoutinfo/GridBagLayoutInfo.java:1.9 --- buix/src/java/org/codelutin/buix/layoutinfo/GridBagLayoutInfo.java:1.8 Tue Jun 29 15:57:56 2004 +++ buix/src/java/org/codelutin/buix/layoutinfo/GridBagLayoutInfo.java Thu Aug 12 12:42:48 2004 @@ -23,9 +23,9 @@ * * @author Aurelie Mazelier * Copyright Code Lutin - * @version $Revision: 1.8 $ + * @version $Revision: 1.9 $ * - * Mise a jour: $Date: 2004/06/29 15:57:56 $ + * Mise a jour: $Date: 2004/08/12 12:42:48 $ * par : $Author: mazelier $ */ @@ -33,6 +33,7 @@ /** * Classe LayoutInfo du GridBagLayout +* todo il manque la propriete Insets */ public class GridBagLayoutInfo extends AbstractLayoutInfo { // GridBagLayoutInfo @@ -41,35 +42,39 @@ public PropertyChildDescriptor[] getPropertyChildDescriptors() { - PropertyChildDescriptor[] propsChild = new PropertyChildDescriptor[9]; + PropertyChildDescriptor[] propsChild = new PropertyChildDescriptor[10]; - GridBagLayoutCellXPropertyChildDescriptor cellX = new GridBagLayoutCellXPropertyChildDescriptor("cellX","cellX",null,Integer.TYPE); + GridBagLayoutPropertyChildDescriptor gridx = new GridBagLayoutPropertyChildDescriptor("gridx","gridx",null,Integer.TYPE); - GridBagLayoutCellYPropertyChildDescriptor cellY = new GridBagLayoutCellYPropertyChildDescriptor("cellY","cellY",null,Integer.TYPE); + GridBagLayoutPropertyChildDescriptor gridy = new GridBagLayoutPropertyChildDescriptor("gridy","gridy",null,Integer.TYPE); - GridBagLayoutRowSpanPropertyChildDescriptor rowSpan = new GridBagLayoutRowSpanPropertyChildDescriptor("rowSpan","rowSpan",null,Integer.TYPE); + GridBagLayoutPropertyChildDescriptor gridwidth = new GridBagLayoutPropertyChildDescriptor("gridwidth","gridwidth",null,Integer.TYPE); - GridBagLayoutColSpanPropertyChildDescriptor colSpan = new GridBagLayoutColSpanPropertyChildDescriptor("colSpan","colSpan",null,Integer.TYPE); + GridBagLayoutPropertyChildDescriptor gridheight = new GridBagLayoutPropertyChildDescriptor("gridheight","gridheight",null,Integer.TYPE); - GridBagLayoutHPaddingPropertyChildDescriptor hPadding = new GridBagLayoutHPaddingPropertyChildDescriptor("hPadding","hPadding",null,Integer.TYPE); + GridBagLayoutPropertyChildDescriptor weightx = new GridBagLayoutPropertyChildDescriptor("weightx","weightx",null,Double.TYPE); - GridBagLayoutVPaddingPropertyChildDescriptor vPadding = new GridBagLayoutVPaddingPropertyChildDescriptor("vPadding","vPadding",null,Integer.TYPE); + GridBagLayoutPropertyChildDescriptor weighty = new GridBagLayoutPropertyChildDescriptor("weighty","weighty",null,Double.TYPE); - GridBagLayoutFillPropertyChildDescriptor fill = new GridBagLayoutFillPropertyChildDescriptor("fill","fill",null,String.class); + GridBagLayoutPropertyChildDescriptor anchor = new GridBagLayoutPropertyChildDescriptor("anchor","anchor",null,Integer.TYPE); - GridBagLayoutWeightXPropertyChildDescriptor weightx = new GridBagLayoutWeightXPropertyChildDescriptor("weightx","weightx",null,Double.TYPE); + GridBagLayoutPropertyChildDescriptor fill = new GridBagLayoutPropertyChildDescriptor("fill","fill",null,String.class); - GridBagLayoutWeightYPropertyChildDescriptor weighty = new GridBagLayoutWeightYPropertyChildDescriptor("weighty","weighty",null,Double.TYPE); + GridBagLayoutPropertyChildDescriptor ipadx = new GridBagLayoutPropertyChildDescriptor("ipadx","ipadx",null,Integer.TYPE); + + GridBagLayoutPropertyChildDescriptor ipady = new GridBagLayoutPropertyChildDescriptor("ipady","ipady",null,Integer.TYPE); + + propsChild[0]=gridx; + propsChild[1]=gridy; + propsChild[2]=gridwidth; + propsChild[3]=gridheight; + propsChild[4]=weightx; + propsChild[5]=weighty; + propsChild[6]=anchor; + propsChild[7]=fill; + propsChild[8]=ipadx; + propsChild[9]=ipady; - propsChild[0]=cellX; - propsChild[1]=cellY; - propsChild[2]=rowSpan; - propsChild[3]=colSpan; - propsChild[4]=hPadding; - propsChild[5]=vPadding; - propsChild[6]=fill; - propsChild[7]=weightx; - propsChild[8]=weighty; return propsChild; } Index: buix/src/java/org/codelutin/buix/layoutinfo/LayoutInfo.java diff -u buix/src/java/org/codelutin/buix/layoutinfo/LayoutInfo.java:1.7 buix/src/java/org/codelutin/buix/layoutinfo/LayoutInfo.java:1.8 --- buix/src/java/org/codelutin/buix/layoutinfo/LayoutInfo.java:1.7 Wed Aug 11 16:30:23 2004 +++ buix/src/java/org/codelutin/buix/layoutinfo/LayoutInfo.java Thu Aug 12 12:42:48 2004 @@ -23,9 +23,9 @@ * * @author Aurelie Mazelier * Copyright Code Lutin - * @version $Revision: 1.7 $ + * @version $Revision: 1.8 $ * - * Mise a jour: $Date: 2004/08/11 16:30:23 $ + * Mise a jour: $Date: 2004/08/12 12:42:48 $ * par : $Author: mazelier $ */ @@ -44,7 +44,14 @@ * Interface des LayoutInfos */ public interface LayoutInfo { // LayoutInfo + + /*** + * Gets the icon + * @param iconKind Description of the Parameter + * @return The icon value + */ public Image getIcon(int iconKind); + /** * Methode qui retourne l'ensemble des PropertyDescriptor pour ce layout */ Index: buix/src/java/org/codelutin/buix/layoutinfo/PropertyChildDescriptor.java diff -u buix/src/java/org/codelutin/buix/layoutinfo/PropertyChildDescriptor.java:1.6 buix/src/java/org/codelutin/buix/layoutinfo/PropertyChildDescriptor.java:1.7 --- buix/src/java/org/codelutin/buix/layoutinfo/PropertyChildDescriptor.java:1.6 Fri May 28 15:11:38 2004 +++ buix/src/java/org/codelutin/buix/layoutinfo/PropertyChildDescriptor.java Thu Aug 12 12:42:48 2004 @@ -23,9 +23,9 @@ * * @author Aurelie Mazelier * Copyright Code Lutin - * @version $Revision: 1.6 $ + * @version $Revision: 1.7 $ * - * Mise a jour: $Date: 2004/05/28 15:11:38 $ + * Mise a jour: $Date: 2004/08/12 12:42:48 $ * par : $Author: mazelier $ */ @@ -39,10 +39,10 @@ */ public abstract class PropertyChildDescriptor { // PropertyChildDescriptor - private String name; - private String displayName; - private Class propertyEditorClass; - private Class propertyType; + protected String name; + protected String displayName; + protected Class propertyEditorClass; + protected Class propertyType; public PropertyChildDescriptor(String name, String displayName, Class editor, Class type){ Index: buix/src/java/org/codelutin/buix/layoutinfo/GridBagLayoutPropertyChildDescriptor.java diff -u /dev/null buix/src/java/org/codelutin/buix/layoutinfo/GridBagLayoutPropertyChildDescriptor.java:1.1 --- /dev/null Thu Aug 12 12:42:54 2004 +++ buix/src/java/org/codelutin/buix/layoutinfo/GridBagLayoutPropertyChildDescriptor.java Thu Aug 12 12:42:48 2004 @@ -0,0 +1,105 @@ +/* *##% + * Copyright (C) 2002, 2003 Code Lutin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * 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 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. + *##%*/ + +/* * + * GridBagLayoutPropertyChildDescriptor.java + * + * Created: May 13, 2004 + * + * @author Aurelie Mazelier + * Copyright Code Lutin + * @version $Revision: 1.1 $ + * + * Mise a jour: $Date: 2004/08/12 12:42:48 $ + * par : $Author: mazelier $ + */ + +package org.codelutin.buix.layoutinfo; + +import org.codelutin.buix.BuixException; + +import java.lang.reflect.Field; + +import java.awt.GridBagLayout; +import java.awt.GridBagConstraints; +import java.awt.Container; +import java.awt.Component; +import java.lang.NoSuchFieldException; +import java.lang.IllegalAccessException; +import java.util.logging.Logger; +import java.util.logging.Level; + +/** +* property child descriptor (proprietes du layout pour les +* enfants du container) +*/ +public class GridBagLayoutPropertyChildDescriptor extends PropertyChildDescriptor{ // GridBagLayoutPropertyChildDescriptor + + + public GridBagLayoutPropertyChildDescriptor(String name, String displayName, Class editor, Class type){ + super(name, displayName, editor, type); + } + + public Object getValue(Object comp) throws BuixException{ + try{ + Container container = ((Component)comp).getParent(); + GridBagLayout layout = (GridBagLayout)container.getLayout(); + GridBagConstraints constraint = layout.getConstraints((Component)comp); + Field f = constraint.getClass().getDeclaredField(name); + return f.get(constraint); + }catch(NoSuchFieldException eee){ + Logger.getLogger("GridBagLayoutPropertyChildDescriptor.getValue(Object comp)").log(Level.WARNING, "Impossible de trouver ce field : "+ name); + }catch(IllegalAccessException eee){ + Logger.getLogger("GridBagLayoutPropertyChildDescriptor.getValue(Object comp)").log(Level.WARNING, "Impossible d'acceder a ce field : "+ name); + } + throw new BuixException("Impossible d'acceder au composant"); + + } + + public void setValue(Object comp, Object newValue) throws BuixException{ + try{ + Container container = ((Component)comp).getParent(); + GridBagLayout layout = (GridBagLayout)container.getLayout(); + GridBagConstraints constraint = layout.getConstraints((Component)comp); + Field f = constraint.getClass().getDeclaredField(name); + + GridBagConstraints newConstraint = new GridBagConstraints(constraint.gridx, constraint.gridy, constraint.gridwidth, constraint.gridheight, constraint.weightx, constraint.weighty, constraint.anchor, constraint.fill, constraint.insets, constraint.ipadx, constraint.ipady); + + if (propertyType == Integer.TYPE){ + Integer value = new Integer((String)newValue); + f.set(newConstraint, value); + }else if (propertyType == Double.TYPE){ + Double value = new Double((String)newValue); + f.set(newConstraint, value); + }else{ + f.set(newConstraint, newValue); + } + + layout.setConstraints((Component)comp, newConstraint); + + + }catch(NoSuchFieldException eee){ + Logger.getLogger("GridBagLayoutPropertyChildDescriptor.setValue(Object comp, Object newValue)").log(Level.WARNING, "Impossible de trouver ce field : "+ name); + }catch(IllegalAccessException eee){ + Logger.getLogger("GridBagLayoutPropertyChildDescriptor.getValue(Object comp, Object newValue)").log(Level.WARNING, "Impossible d'acceder a ce field : "+ name); + } + } + + +} // GridBagLayoutPropertyChildDescriptor +