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-2004 Sun
 * Microsystems, Inc. All Rights Reserved.
 */

package org.netbeans.core.execution;

import java.io.ObjectOutput;
import java.io.ObjectInput;
import java.io.IOException;

import org.openide.options.SystemOption;
import org.openide.util.HelpCtx;

/** Settings for Execution
*
* @author Ales Novak
* @deprecated No longer used.
*/
public class ExecutionSettings extends SystemOption {
    /** generated Serialized Version UID */
    static final long serialVersionUID = 4261950851983665892L;

    /** Property name of the reuse property */
    public static final String PROP_TAB_HANDLER = "handler"; // NOI18N
    
    // old props
    private static final String PROP_REUSE = "reuse"; // NOI18N
    private static final String PROP_CLEAR = "clear"; // NOI18N
    
    static final int NONE = 0;
    static final int REUSE = 1;
    static final int REUSE_AND_CLEAR = 2;

    private transient int tabHandler = REUSE_AND_CLEAR;
    
    /** @return the display name of Execution Settings */
    public String displayName () {
        return ProcessNode.getBundle().getString("CTL_Execution_option");
    }

    public HelpCtx getHelpCtx () {
        return new HelpCtx (ExecutionSettings.class);
    }

    /** Getter for tab handler */
    public int getTabHandler() {
        return tabHandler;
    }
    
    /** Setter for tab handler */
    public void setTabHandler(int nval) {
        int old = tabHandler;
        tabHandler = nval;
        if (old != tabHandler) {
            firePropertyChange(PROP_TAB_HANDLER, new Integer(old), new Integer(nval));
        }
    }
    
    private static final String version11 = "version 1.1"; // NOI18N
    private static final String version12 = "version 1.2"; // NOI18N
    private static final String version13 = "version 1.3"; // NOI18N
    
    public void writeExternal(ObjectOutput oo) throws IOException {
        oo.writeObject(version13);
        oo.writeInt(getTabHandler());
    }
    
    public void readExternal(ObjectInput oi) throws IOException, ClassNotFoundException {
        String read = (String) ((java.io.ObjectInputStream) oi).readObject();
        
        if (version13.equals(read)) {
            read13(oi);
        } else if (version12.equals(read)) {
            read12(oi);
        } else if (version11.equals(read)) {
            read11(oi);
        } else {
            read10(oi, read);
        }
    }
    
    void read10(ObjectInput oi, String read) throws IOException, ClassNotFoundException {
        Object val;
        Object preread;
        Object useMethod;
        boolean inClear = false;
        do {
            val = oi.readObject();
            
            if (read.equals(PROP_REUSE)) {
                if (! inClear) {
                    tabHandler = REUSE;
                }
            } else if (read.equals(PROP_CLEAR)) {
                inClear = true;
                tabHandler = REUSE_AND_CLEAR;
            } // else ignore old PROP_WORKSPACE
             
            useMethod = oi.readObject();
            if (useMethod instanceof String) {
                read = (String) useMethod;
            } else if (useMethod == null) {
                break;
            } else {
                read = (String) oi.readObject();
                if (read == null) {
                    break;
                }
            }
        } while (true);
    }
    
    void read11(ObjectInput oi) throws IOException, ClassNotFoundException {
        oi.readUTF(); // ignore the workspace property
        oi.readBoolean(); // ignore runCompilation property
        setTabHandler(oi.readInt());
    }

    void read12(ObjectInput oi) throws IOException, ClassNotFoundException {
        oi.readBoolean(); // ignore runCompilation property
        setTabHandler(oi.readInt());
    }

    void read13(ObjectInput oi) throws IOException, ClassNotFoundException {
        setTabHandler(oi.readInt());
    }
    
}
... 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.