harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ton...@apache.org
Subject svn commit: r557923 - in /harmony/enhanced/classlib/trunk/modules/beans: META-INF/ src/main/java/java/beans/ src/test/java/org/apache/harmony/beans/tests/java/beans/
Date Fri, 20 Jul 2007 08:22:31 GMT
Author: tonywu
Date: Fri Jul 20 01:22:30 2007
New Revision: 557923

URL: http://svn.apache.org/viewvc?view=rev&rev=557923
Log:
Apply patch Harmony-4486 ([classlib][beans] Persistence delegate for swing classes are missing)

Added:
    harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/SwingAbstractButtonPersistenceDelegate.java
  (with props)
    harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/SwingBoxPersistenceDelegate.java
  (with props)
    harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/SwingDefaultComboBoxModelPersistenceDelegate.java
  (with props)
    harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/SwingJFramePersistenceDelegate.java
  (with props)
    harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/SwingJTabbedPanePersistenceDelegate.java
  (with props)
    harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/SwingToolTipManagerPersistenceDelegate.java
  (with props)
Modified:
    harmony/enhanced/classlib/trunk/modules/beans/META-INF/MANIFEST.MF
    harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/Encoder.java
    harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PersistenceDelegateTest.java

Modified: harmony/enhanced/classlib/trunk/modules/beans/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/META-INF/MANIFEST.MF?view=diff&rev=557923&r1=557922&r2=557923
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/META-INF/MANIFEST.MF (original)
+++ harmony/enhanced/classlib/trunk/modules/beans/META-INF/MANIFEST.MF Fri Jul 20 01:22:30
2007
@@ -28,6 +28,8 @@
  java.util.regex;resolution:=optional,
  javax.accessibility;resolution:=optional,
  javax.swing,
+ javax.swing.plaf.basic,
+ javax.swing.tree,
  javax.xml.parsers,
  org.apache.harmony.kernel.vm,
  org.apache.harmony.testframework.serialization;hy_usage=test;resolution:=optional,

Modified: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/Encoder.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/Encoder.java?view=diff&rev=557923&r1=557922&r2=557923
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/Encoder.java (original)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/Encoder.java Fri
Jul 20 01:22:30 2007
@@ -26,6 +26,8 @@
 import java.util.Map;
 import java.util.Hashtable;
 
+import javax.swing.*;
+
 import org.apache.harmony.beans.*;
 
 /**
@@ -101,6 +103,12 @@
         delegates.put(Rectangle.class, new AwtRectanglePersistenceDelegate());
         delegates.put(SystemColor.class, new AwtSystemColorPersistenceDelegate());
         delegates.put(TextAttribute.class, new AwtFontTextAttributePersistenceDelegate());
+        
+        delegates.put(Box.class, new SwingBoxPersistenceDelegate());
+        delegates.put(JFrame.class, new SwingJFramePersistenceDelegate());
+        delegates.put(JTabbedPane.class, new SwingJTabbedPanePersistenceDelegate());
+        delegates.put(DefaultComboBoxModel.class, new SwingDefaultComboBoxModelPersistenceDelegate());
+        delegates.put(ToolTipManager.class, new SwingToolTipManagerPersistenceDelegate());
         
 	}
 

Added: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/SwingAbstractButtonPersistenceDelegate.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/SwingAbstractButtonPersistenceDelegate.java?view=auto&rev=557923
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/SwingAbstractButtonPersistenceDelegate.java
(added)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/SwingAbstractButtonPersistenceDelegate.java
Fri Jul 20 01:22:30 2007
@@ -0,0 +1,86 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package java.beans;
+
+import javax.swing.JComponent;
+
+/**
+ * A special internal <code>PersistenceDelegate</code> for java.awt.JComponent
+ * class.
+ * 
+ */
+class SwingAbstractButtonPersistenceDelegate extends DefaultPersistenceDelegate{
+	protected void initialize(Class<?> type, Object oldInstance,
+            Object newInstance, Encoder enc) {
+        // Call the initialization of the super type
+        super.initialize(type, oldInstance, newInstance, enc);
+        // Continue only if initializing the "current" type
+        if (type != oldInstance.getClass()) {
+            return;
+        }
+        
+        
+        JComponent container = (JComponent) oldInstance;
+    	int count = container.getComponentCount();
+		for (int i = 0; i < count; i++) {
+			Expression getterExp = new Expression(container,
+					"getComponent", new Object[] { i });
+			try {
+                // Calculate the old value of the property
+                Object oldVal = getterExp.getValue();
+                // Write the getter expression to the encoder
+                enc.writeExpression(getterExp);
+                // Get the target value that exists in the new environment
+                Object targetVal = enc.get(oldVal);
+                // Get the current property value in the new environment
+                Object newVal = null;
+                try {
+                	JComponent newJComponent = (JComponent) newInstance;
+					newVal = new Expression(newJComponent.getComponent(i),
+							newJComponent, "getComponent",
+							new Object[] { i }).getValue();
+				} catch (ArrayIndexOutOfBoundsException ex) {
+					// The newInstance has no elements, so current property
+					// value remains null
+				}
+                /*
+				 * Make the target value and current property value equivalent
+				 * in the new environment
+				 */
+                if (null == targetVal) {
+                    if (null != newVal) {
+                        // Set to null
+                        Statement setterStm = new Statement(oldInstance, "add",
+								new Object[] { null });
+                        enc.writeStatement(setterStm);
+                    }
+                } else {
+                    PersistenceDelegate pd = enc
+                            .getPersistenceDelegate(targetVal.getClass());
+                    if (!pd.mutatesTo(targetVal, newVal)) {
+                        Statement setterStm = new Statement(oldInstance, "add",
+                                new Object[] { oldVal });
+                        enc.writeStatement(setterStm);
+                    }
+                }
+            } catch (Exception ex) {
+                enc.getExceptionListener().exceptionThrown(ex);
+            }
+		}
+	}
+}

Propchange: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/SwingAbstractButtonPersistenceDelegate.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/SwingBoxPersistenceDelegate.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/SwingBoxPersistenceDelegate.java?view=auto&rev=557923
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/SwingBoxPersistenceDelegate.java
(added)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/SwingBoxPersistenceDelegate.java
Fri Jul 20 01:22:30 2007
@@ -0,0 +1,69 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package java.beans;
+
+import javax.swing.Box;
+
+class SwingBoxPersistenceDelegate extends PersistenceDelegate {
+	protected Expression instantiate(Object oldInstance, Encoder enc) {
+		return new Expression(oldInstance, oldInstance.getClass(),
+				"createVerticalBox", null);
+	}
+
+	protected void initialize(Class<?> type, Object oldInstance,
+			Object newInstance, Encoder enc) {
+		Box box = (Box) oldInstance;
+		Expression getterExp = new Expression(box.getAlignmentX(), box,
+				"getAlignmentX", null);
+		try {
+			// Calculate the old value of the property
+			Object oldVal = getterExp.getValue();
+			// Write the getter expression to the encoder
+			enc.writeExpression(getterExp);
+			// Get the target value that exists in the new environment
+			Object targetVal = enc.get(oldVal);
+			// Get the current property value in the new environment
+			Object newVal = null;
+			Box newBox = (Box) newInstance;
+			newVal = new Expression(newBox.getAlignmentX(), newBox,
+					"AlignmentX", null).getValue();
+			/*
+			 * Make the target value and current property value equivalent in
+			 * the new environment
+			 */
+			if (null == targetVal) {
+				if (null != newVal) {
+					// Set to null
+					Statement setterStm = new Statement(oldInstance, "setAlignmentX",
+							new Object[] { null });
+					enc.writeStatement(setterStm);
+				}
+			} else {
+				PersistenceDelegate pd = enc.getPersistenceDelegate(targetVal
+						.getClass());
+				if (!pd.mutatesTo(targetVal, newVal)) {
+					Statement setterStm = new Statement(oldInstance,
+							"setAlignmentX", new Object[] { oldVal });
+					enc.writeStatement(setterStm);
+				}
+			}
+		} catch (Exception ex) {
+			enc.getExceptionListener().exceptionThrown(ex);
+		}
+	}
+}

Propchange: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/SwingBoxPersistenceDelegate.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/SwingDefaultComboBoxModelPersistenceDelegate.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/SwingDefaultComboBoxModelPersistenceDelegate.java?view=auto&rev=557923
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/SwingDefaultComboBoxModelPersistenceDelegate.java
(added)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/SwingDefaultComboBoxModelPersistenceDelegate.java
Fri Jul 20 01:22:30 2007
@@ -0,0 +1,77 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package java.beans;
+
+import javax.swing.DefaultComboBoxModel;
+
+
+class SwingDefaultComboBoxModelPersistenceDelegate extends
+		DefaultPersistenceDelegate {
+	protected void initialize(Class<?> type, Object oldInstance,
+			Object newInstance, Encoder enc) {
+		super.initialize(type, oldInstance, newInstance, enc);
+
+		DefaultComboBoxModel model = (DefaultComboBoxModel) oldInstance;
+
+		int count = model.getSize();
+		Expression getterExp = null;
+		for (int i = 0; i < count; i++) {
+			getterExp = new Expression(model, "getElementAt", new Object[] { i });
+			try {
+				// Calculate the old value of the property
+				Object oldVal = getterExp.getValue();
+				// Write the getter expression to the encoder
+				enc.writeExpression(getterExp);
+				// Get the target value that exists in the new environment
+				Object targetVal = enc.get(oldVal);
+				// Get the current property value in the new environment
+				Object newVal = null;
+				try {
+					newVal = new Expression(((DefaultComboBoxModel) newInstance), "getElementAt",
+							new Object[] { i }).getValue();
+				} catch (IndexOutOfBoundsException ex) {
+					// The newInstance has no elements, so current property
+					// value remains null
+				}
+				/*
+				 * Make the target value and current property value equivalent
+				 * in the new environment
+				 */
+				Statement setterStm = null;
+				if (null == targetVal) {
+					if (null != newVal) {
+						// Set to null
+						setterStm = new Statement(oldInstance, "addElement",
+								new Object[] { null });
+						enc.writeStatement(setterStm);
+					}
+				} else {
+					PersistenceDelegate pd = enc
+							.getPersistenceDelegate(targetVal.getClass());
+					if (!pd.mutatesTo(targetVal, newVal)) {
+						setterStm = new Statement(oldInstance, "addElement",
+								new Object[] { oldVal });
+						enc.writeStatement(setterStm);
+					}
+				}
+			} catch (Exception ex) {
+				enc.getExceptionListener().exceptionThrown(ex);
+			}
+		}
+	}
+}

Propchange: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/SwingDefaultComboBoxModelPersistenceDelegate.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/SwingJFramePersistenceDelegate.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/SwingJFramePersistenceDelegate.java?view=auto&rev=557923
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/SwingJFramePersistenceDelegate.java
(added)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/SwingJFramePersistenceDelegate.java
Fri Jul 20 01:22:30 2007
@@ -0,0 +1,78 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package java.beans;
+
+import java.awt.Container;
+
+import javax.swing.JFrame;
+
+class SwingJFramePersistenceDelegate extends DefaultPersistenceDelegate {
+	protected void initialize(Class<?> type, Object oldInstance,
+            Object newInstance, Encoder enc) {
+        // Call the initialization of the super type
+        super.initialize(type, oldInstance, newInstance, enc);
+        // Continue only if initializing the "current" type
+        if (type != oldInstance.getClass()) {
+            return;
+        }
+        
+        
+        JFrame frame = (JFrame) oldInstance;
+        Container container = frame.getContentPane();
+    	int count = container.getComponentCount();
+    	if(count != 0) {
+    		Expression getterExp = new Expression(frame,
+					"getContentPane", null);
+    		try {
+                // Calculate the old value of the property
+                Object oldVal = getterExp.getValue();
+                // Write the getter expression to the encoder
+                enc.writeExpression(getterExp);
+                // Get the target value that exists in the new environment
+                Object targetVal = enc.get(oldVal);
+                // Get the current property value in the new environment
+                Object newVal = null;
+				JFrame newFrame = (JFrame) newInstance;
+				newVal = new Expression(newFrame.getContentPane(), newFrame,
+						"getContentPane", null).getValue();
+                /*
+				 * Make the target value and current property value equivalent
+				 * in the new environment
+				 */
+                if (null == targetVal) {
+                    if (null != newVal) {
+                        // Set to null
+                        Statement setterStm = new Statement(oldInstance, "setContentPane",
+								new Object[] { null });
+                        enc.writeStatement(setterStm);
+                    }
+                } else {
+                    PersistenceDelegate pd = enc
+                            .getPersistenceDelegate(targetVal.getClass());
+                    if (!pd.mutatesTo(targetVal, newVal)) {
+                        Statement setterStm = new Statement(oldInstance, "setContentPane",
+                                new Object[] { oldVal });
+                        enc.writeStatement(setterStm);
+                    }
+                }
+            } catch (Exception ex) {
+                enc.getExceptionListener().exceptionThrown(ex);
+            }
+    	}
+	}
+}

Propchange: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/SwingJFramePersistenceDelegate.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/SwingJTabbedPanePersistenceDelegate.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/SwingJTabbedPanePersistenceDelegate.java?view=auto&rev=557923
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/SwingJTabbedPanePersistenceDelegate.java
(added)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/SwingJTabbedPanePersistenceDelegate.java
Fri Jul 20 01:22:30 2007
@@ -0,0 +1,80 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package java.beans;
+
+import javax.swing.JTabbedPane;
+
+class SwingJTabbedPanePersistenceDelegate extends
+		DefaultPersistenceDelegate {
+	protected void initialize(Class<?> type, Object oldInstance,
+            Object newInstance, Encoder enc) {
+        // Call the initialization of the super type
+        super.initialize(type, oldInstance, newInstance, enc);
+        // Continue only if initializing the "current" type
+        if (type != oldInstance.getClass()) {
+            return;
+        }
+        
+        
+        JTabbedPane pane = (JTabbedPane) oldInstance;
+    	int count = pane.getTabCount();
+    	for (int i = 0; i < count; i++) {
+			Expression getterExp = new Expression(pane.getComponentAt(i), pane,
+					"getComponentAt", new Object[] { i });
+			try {
+                // Calculate the old value of the property
+                Object oldVal = getterExp.getValue();
+                // Write the getter expression to the encoder
+                enc.writeExpression(getterExp);
+                // Get the target value that exists in the new environment
+                Object targetVal = enc.get(oldVal);
+                // Get the current property value in the new environment
+                Object newVal = null;
+                try {
+                	JTabbedPane newJTabbedPane = (JTabbedPane) newInstance;
+					newVal = new Expression(newJTabbedPane.getComponent(i),
+							newJTabbedPane, "getComponentAt",
+							new Object[] { i }).getValue();
+				} catch (ArrayIndexOutOfBoundsException ex) {
+					// The newInstance has no elements, so current property
+					// value remains null
+				}
+                /*
+				 * Make the target value and current property value equivalent
+				 * in the new environment
+				 */
+                if (null == targetVal) {
+                    if (null != newVal) {
+                        // Set to null
+                    	Statement setterStm = new Statement(oldInstance, "addTab",
+                                new Object[] { pane.getTitleAt(i), oldVal });
+                        enc.writeStatement(setterStm);
+                    }
+                } else {
+                    PersistenceDelegate pd = enc
+                            .getPersistenceDelegate(targetVal.getClass());
+                    	Statement setterStm = new Statement(oldInstance, "addTab",
+                                new Object[] { pane.getTitleAt(i), oldVal });
+                        enc.writeStatement(setterStm);
+                }
+            } catch (Exception ex) {
+                enc.getExceptionListener().exceptionThrown(ex);
+            }
+		}
+	}
+}

Propchange: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/SwingJTabbedPanePersistenceDelegate.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/SwingToolTipManagerPersistenceDelegate.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/SwingToolTipManagerPersistenceDelegate.java?view=auto&rev=557923
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/SwingToolTipManagerPersistenceDelegate.java
(added)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/SwingToolTipManagerPersistenceDelegate.java
Fri Jul 20 01:22:30 2007
@@ -0,0 +1,28 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package java.beans;
+
+class SwingToolTipManagerPersistenceDelegate extends PersistenceDelegate {
+
+	@Override
+	protected Expression instantiate(Object oldInstance, Encoder enc) {
+		return new Expression(oldInstance, oldInstance.getClass(),
+				"sharedInstance", null);
+	}
+
+}

Propchange: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/SwingToolTipManagerPersistenceDelegate.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PersistenceDelegateTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PersistenceDelegateTest.java?view=diff&rev=557923&r1=557922&r2=557923
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PersistenceDelegateTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PersistenceDelegateTest.java
Fri Jul 20 01:22:30 2007
@@ -27,6 +27,9 @@
 import java.util.*;
 
 import javax.swing.*;
+import javax.swing.plaf.basic.BasicComboBoxUI;
+import javax.swing.plaf.basic.BasicComboBoxUI.ListDataHandler;
+import javax.swing.tree.DefaultMutableTreeNode;
 
 import junit.framework.TestCase;
 
@@ -880,6 +883,95 @@
         assertEquals(hMap.size(), aHmap.size());
         assertEquals(hMap.get(1), aHmap.get(1));
         assertEquals("test", aHmap.get(2));
+    }
+    
+    public void test_writeObject_javax_swing_JFrame() {
+        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+        XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
+            byteArrayOutputStream));
+        
+        JFrame frame = new JFrame("JFrame"); 
+        frame.setAlwaysOnTop(true);
+        frame.setBounds(1, 1, 100, 100);
+        frame.add(new JMenu("JMenu"));
+        encoder.writeObject(frame);
+        encoder.close();
+        DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
+                byteArrayOutputStream.toByteArray()));
+        XMLDecoder decoder = new XMLDecoder(stream);
+        JFrame aFrame = (JFrame) decoder.readObject();
+        assertEquals(frame.getTitle(), aFrame.getTitle());
+        assertEquals(frame.getBounds(), aFrame.getBounds());
+    }
+
+    public void test_writeObject_javax_swing_DefaultListModel() {
+        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+        XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
+            byteArrayOutputStream));
+
+        DefaultListModel model = new DefaultListModel();
+        model.add(0, 1);
+        model.add(1, 2);
+        ListDataHandler listDataHandler = new BasicComboBoxUI().new ListDataHandler();
+        model.addListDataListener(listDataHandler);
+        
+        encoder.writeObject(model);
+        encoder.close();
+        DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
+                byteArrayOutputStream.toByteArray()));
+        XMLDecoder decoder = new XMLDecoder(stream);
+        DefaultListModel aModel = (DefaultListModel) decoder.readObject();
+        assertEquals(model.getSize(), aModel.getSize());
+    }
+
+    public void test_writeObject_javax_swing_DefaultComboBoxModel() {
+        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+        XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
+            byteArrayOutputStream));
+        Object a[] = {1, 2};
+        DefaultComboBoxModel model = new DefaultComboBoxModel(a);
+
+        encoder.writeObject(model);
+        encoder.close();
+        DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
+                byteArrayOutputStream.toByteArray()));
+        XMLDecoder decoder = new XMLDecoder(stream);
+        DefaultComboBoxModel aModel = (DefaultComboBoxModel) decoder.readObject();
+        assertEquals(model.getSize(), aModel.getSize());
+        assertEquals(model.getElementAt(0), aModel.getElementAt(0));
+        assertEquals(model.getElementAt(1), aModel.getElementAt(1));
+    }
+
+    public void test_writeObject_javax_swing_tree_DefaultMutableTreeNode() {
+        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+        XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
+            byteArrayOutputStream));
+        DefaultMutableTreeNode node = new DefaultMutableTreeNode(1);
+
+        encoder.writeObject(node);
+        encoder.close();
+        DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
+                byteArrayOutputStream.toByteArray()));
+        XMLDecoder decoder = new XMLDecoder(stream);
+        DefaultMutableTreeNode aNode = (DefaultMutableTreeNode) decoder.readObject();
+        assertEquals(node.getUserObject(), aNode.getUserObject());
+    }
+
+    public void test_writeObject_javax_swing_ToolTipManager() {
+        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+        XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
+            byteArrayOutputStream));
+        ToolTipManager manager = ToolTipManager.sharedInstance();
+        manager.setDismissDelay(10);
+
+        encoder.writeObject(manager);
+        encoder.close();
+        DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
+                byteArrayOutputStream.toByteArray()));
+        XMLDecoder decoder = new XMLDecoder(stream);
+        ToolTipManager aManager = (ToolTipManager) decoder.readObject();
+        assertEquals(manager, aManager);
+        assertEquals(manager.getDismissDelay(), aManager.getDismissDelay());
     }
 
     // <--



Mime
View raw message