alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

What this is

This file is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Other links

The source code

/*
 *                 Sun Public License Notice
 * 
 * The contents of this file are subject to the Sun Public License
 * Version 1.0 (the "License"). You may not use this file except in
 * compliance with the License. A copy of the License is available at
 * http://www.sun.com/
 * 
 * The Original Code is NetBeans. The Initial Developer of the Original
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2002 Sun
 * Microsystems, Inc. All Rights Reserved.
 */
package org.netbeans.modules.xml.editor;

import java.io.*;

import org.openide.windows.*;
import org.openide.explorer.ExplorerPanel;
import org.openide.text.*;
import org.openide.loaders.DataObject;
import org.openide.loaders.DataObjectNotFoundException;
import org.openide.cookies.OpenCookie;
import org.openide.util.io.SafeException;
import org.openide.filesystems.FileStateInvalidException;

import org.netbeans.modules.xml.core.XMLDataObjectLook;
import org.netbeans.modules.xml.tree.editor.TreeEditorSupport;
import org.netbeans.modules.xml.tree.editor.TreeEditorComponent;

/**
 * @deprecated Backward compatibility class for tree editor component.
 *
 * @author  Petr Kuzel
 * @author  Libor Kramolis
 * @version 0.2
 */
public final class XMLTopComponent extends ExplorerPanel implements Externalizable {
    /** Serial Version UID */
    private static final long serialVersionUID = -643830068955628059L;    

    /** */
    private TreeEditorSupport support = null;

    /** */
    public XMLTopComponent () {
        // externalization requires it
    }
    

    /**
     */
    private Object readResolve () throws ObjectStreamException {
        if ( support != null ) {
            return new TreeEditorComponent (support);
        } else {
            return null;
        }
    }                

    public void readExternal (ObjectInput in) throws IOException, ClassNotFoundException {
        try {
            super.readExternal (in);
            
            // see immediatelly that backward compatibility reading failed.
            setName ("FFJ 2.0 TreeEditorComponent"); // NOI18N
        
            Object obj = in.readObject();
        
            if ( ( obj instanceof XMLDataObjectLook ) &&
                 ( obj instanceof DataObject ) ) {
                
                XMLDataObjectLook doi = (XMLDataObjectLook) obj;

                if ( ((DataObject) doi).isValid() ) {
                    support = (TreeEditorSupport) doi.getCookie (OpenCookie.class);
                }
            }
        } catch (IOException ioExc) {
            Exception exc;
            if ( ioExc instanceof SafeException ) {
                exc = ((SafeException) ioExc).getException();
            } else {
                exc = ioExc;
            }
            if ( ( exc instanceof DataObjectNotFoundException ) ||
                 ( exc instanceof FileStateInvalidException ) ) {
                //!!! expected
            } else {
                throw ioExc;
            }
        }
    }
               
    /**
     */
    public void writeExternal (ObjectOutput objectOutput) throws IOException {
        throw new IOException ("This placeholder can not be written down."); // NOI18N
    }
    
}
... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.