Index: topia/src/java/org/codelutin/topia/ui/swing/TopiaPanelPersistenceDelegate.java diff -u /dev/null topia/src/java/org/codelutin/topia/ui/swing/TopiaPanelPersistenceDelegate.java:1.1 --- /dev/null Mon Sep 20 15:33:54 2004 +++ topia/src/java/org/codelutin/topia/ui/swing/TopiaPanelPersistenceDelegate.java Mon Sep 20 15:33:49 2004 @@ -0,0 +1,62 @@ +/* *##% + * 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. + *##%*/ + +/* * + * TopiaPanelPersistenceDelegate.java + * + * Created: Sep 20, 2004 + * + * @author Benjamin Poussin + * Copyright Code Lutin + * @version $Revision: 1.1 $ + * + * Mise a jour: $Date: 2004/09/20 15:33:49 $ + * par : $Author: mazelier $ + */ + +package org.codelutin.topia.ui.swing; + +import java.beans.DefaultPersistenceDelegate; +import java.beans.Statement; +import java.beans.Encoder; + +public class TopiaPanelPersistenceDelegate extends DefaultPersistenceDelegate { // TopiaPanelPersistenceDelegate + + protected void initialize(Class type, Object oldInstance, Object newInstance, Encoder out) { + super.initialize(type, oldInstance, newInstance, out); + // Ignore the children of a JScrollPane. + // Pending(milne) find a better way to do this. + if (oldInstance instanceof javax.swing.JScrollPane) { + return; + } + java.awt.Container oldC = (java.awt.Container)oldInstance; + java.awt.Component[] oldChildren = oldC.getComponents(); + java.awt.Container newC = (java.awt.Container)newInstance; + //java.awt.Component[] newChildren = (newC == null) ? new java.awt.Component[0] : newC.getComponents(); + + System.out.println("********** old.size: "+ oldC.getComponents().length); + System.out.println("********** new.size: "+ newC.getComponents().length); + + for(int i = 0; i < oldChildren.length; i++) { + out.writeStatement(new Statement(oldInstance, "add", + new Object[]{oldChildren[i]})); + } + } + +} // TopiaPanelPersistenceDelegate +