X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src2%2Fnet%2Fmiginfocom%2Flayout%2FUnitValue.java;fp=src%2Fnet%2Fmiginfocom%2Flayout%2FUnitValue.java;h=70d8f722e83e4ad525536c22025ae5876a77ac64;hb=665d2c2f4c1310e6985b93b7c2c8a8eec2fa9086;hp=690f14a441b99a7439d9c7dba76f5ab673ef99c7;hpb=0e684f72690bd6532272a39ab6c188a27559fd09;p=jalview.git diff --git a/src/net/miginfocom/layout/UnitValue.java b/src2/net/miginfocom/layout/UnitValue.java similarity index 91% rename from src/net/miginfocom/layout/UnitValue.java rename to src2/net/miginfocom/layout/UnitValue.java index 690f14a..70d8f72 100644 --- a/src/net/miginfocom/layout/UnitValue.java +++ b/src2/net/miginfocom/layout/UnitValue.java @@ -33,10 +33,10 @@ package net.miginfocom.layout; * Date: 2006-sep-08 */ -//import java.beans.Encoder; -//import java.beans.Expression; -//import java.beans.PersistenceDelegate; -import java.io.Serializable; +import java.beans.Encoder; +import java.beans.Expression; +import java.beans.PersistenceDelegate; +import java.io.*; import java.util.ArrayList; import java.util.HashMap; @@ -648,44 +648,44 @@ public final class UnitValue implements Serializable PlatformDefaults.setDefaultVerticalUnit(unit); } -// static { -// if(LayoutUtil.HAS_BEANS){\ -// LayoutUtil.setDelegate(UnitValue.class, new PersistenceDelegate() { -// @Override -// protected Expression instantiate(Object oldInstance, Encoder out) -// { -// UnitValue uv = (UnitValue) oldInstance; -// String cs = uv.getConstraintString(); -// if (cs == null) -// throw new IllegalStateException("Design time must be on to use XML persistence. See LayoutUtil."); -// -// return new Expression(oldInstance, ConstraintParser.class, "parseUnitValueOrAlign", new Object[] { -// uv.getConstraintString(), (uv.isHorizontal() ? Boolean.TRUE : Boolean.FALSE), null -// }); -// } -// }); -// } -// } -// -// // ************************************************ -// // Persistence Delegate and Serializable combined. -// // ************************************************ -// -// private static final long serialVersionUID = 1L; -// -// private Object readResolve() throws ObjectStreamException -// { -// return LayoutUtil.getSerializedObject(this); -// } -// -// private void writeObject(ObjectOutputStream out) throws IOException -// { -// if (getClass() == UnitValue.class) -// LayoutUtil.writeAsXML(out, this); -// } -// -// private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException -// { -// LayoutUtil.setSerializedObject(this, LayoutUtil.readAsXML(in)); -// } + static { + if(LayoutUtil.HAS_BEANS){ + LayoutUtil.setDelegate(UnitValue.class, new PersistenceDelegate() { + @Override + protected Expression instantiate(Object oldInstance, Encoder out) + { + UnitValue uv = (UnitValue) oldInstance; + String cs = uv.getConstraintString(); + if (cs == null) + throw new IllegalStateException("Design time must be on to use XML persistence. See LayoutUtil."); + + return new Expression(oldInstance, ConstraintParser.class, "parseUnitValueOrAlign", new Object[] { + uv.getConstraintString(), (uv.isHorizontal() ? Boolean.TRUE : Boolean.FALSE), null + }); + } + }); + } + } + + // ************************************************ + // Persistence Delegate and Serializable combined. + // ************************************************ + + private static final long serialVersionUID = 1L; + + private Object readResolve() throws ObjectStreamException + { + return LayoutUtil.getSerializedObject(this); + } + + private void writeObject(ObjectOutputStream out) throws IOException + { + if (getClass() == UnitValue.class) + LayoutUtil.writeAsXML(out, this); + } + + private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException + { + LayoutUtil.setSerializedObject(this, LayoutUtil.readAsXML(in)); + } }