OpenJDK / jdk / jdk10
changeset 26024:854e6eab0174
6521727: DefaultTreeCellEditor doesn't implement Serializable
Reviewed-by: azvegint, alexsch
author | serb |
---|---|
date | Tue, 05 Aug 2014 13:59:50 +0400 |
parents | bdcfc40fbce5 |
children | 7b31d014cae6 |
files | jdk/src/share/classes/javax/swing/tree/DefaultTreeCellEditor.java |
diffstat | 1 files changed, 4 insertions(+), 50 deletions(-) [+] |
line wrap: on
line diff
--- a/jdk/src/share/classes/javax/swing/tree/DefaultTreeCellEditor.java Fri Aug 01 16:26:17 2014 +0100 +++ b/jdk/src/share/classes/javax/swing/tree/DefaultTreeCellEditor.java Tue Aug 05 13:59:50 2014 +0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,10 +31,7 @@ import javax.swing.plaf.FontUIResource; import java.awt.*; import java.awt.event.*; -import java.beans.*; -import java.io.*; import java.util.EventObject; -import java.util.Vector; /** * A <code>TreeCellEditor</code>. You need to supply an @@ -60,7 +57,6 @@ * * @author Scott Violet */ -@SuppressWarnings("serial") // Same-version serialization only public class DefaultTreeCellEditor implements ActionListener, TreeCellEditor, TreeSelectionListener { /** Editor handling the editing. */ @@ -532,6 +528,7 @@ */ protected TreeCellEditor createTreeCellEditor() { Border aBorder = UIManager.getBorder("Tree.editorBorder"); + @SuppressWarnings("serial") // Safe: outer class is non-serializable DefaultCellEditor editor = new DefaultCellEditor (new DefaultTextField(aBorder)) { public boolean shouldSelectCell(EventObject event) { @@ -556,51 +553,6 @@ editingComponent = null; } - // Serialization support. - private void writeObject(ObjectOutputStream s) throws IOException { - Vector<Object> values = new Vector<Object>(); - - s.defaultWriteObject(); - // Save the realEditor, if its Serializable. - if(realEditor != null && realEditor instanceof Serializable) { - values.addElement("realEditor"); - values.addElement(realEditor); - } - s.writeObject(values); - } - - private void readObject(ObjectInputStream s) - throws IOException, ClassNotFoundException { - ObjectInputStream.GetField f = s.readFields(); - - renderer = (DefaultTreeCellRenderer) f.get("renderer", null); - Container newEditingContainer = (Container) f.get("editingContainer", null); - if (newEditingContainer == null) { - throw new InvalidObjectException("Null editingContainer"); - } - editingContainer = newEditingContainer; - canEdit = f.get("canEdit", false); - borderSelectionColor = (Color) f.get("borderSelectionColor", null); - font = (Font) f.get("font", null); - - - Vector<?> values = (Vector)s.readObject(); - int indexCounter = 0; - int maxCounter = values.size(); - - if(indexCounter < maxCounter && values.elementAt(indexCounter). - equals("realEditor")) { - TreeCellEditor newRealEditor = - (TreeCellEditor)values.elementAt(++indexCounter); - if (newRealEditor == null) { - throw new InvalidObjectException("Null realEditor"); - } - realEditor = newRealEditor; - indexCounter++; - } - } - - /** * <code>TextField</code> used when no editor is supplied. * This textfield locks into the border it is constructed with. @@ -608,6 +560,7 @@ * renderer is not <code>null</code> and no font * has been specified the preferred height is that of the renderer. */ + @SuppressWarnings("serial") // Safe: outer class is non-serializable public class DefaultTextField extends JTextField { /** Border to use. */ protected Border border; @@ -689,6 +642,7 @@ /** * Container responsible for placing the <code>editingComponent</code>. */ + @SuppressWarnings("serial") // Safe: outer class is non-serializable public class EditorContainer extends Container { /** * Constructs an <code>EditorContainer</code> object.