站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > NetBeans API Javadoc 4.1.0

SystemOption (NetBeans APIs) - NetBeans API Javadoc 4.1.0


org.openide.options
Class SystemOption

java.lang.Object
  extended byorg.openide.util.SharedClassObject
      extended byorg.openide.options.SystemOption
All Implemented Interfaces:
Externalizable, HelpCtx.Provider, Serializable
Direct Known Subclasses:
ContextSystemOption, NbDocument.Colors, PropertySheetSettings, VetoSystemOption

public abstract class SystemOption
extends SharedClassObject
implements HelpCtx.Provider

Base class for all system options. Provides methods for adding and working with property change and guarantees that all instances of the same class will share these listeners.

When a new option is created, it should subclass SystemOption, add static variables to it that will hold the values of properties, and write non-static setters/getters that will notify all listeners about property changes via firePropertyChange(java.lang.String, java.lang.Object, java.lang.Object).

JavaBeans introspection is used to find the properties, so it is possible to use BeanInfo.

See Also:
Serialized Form

Constructor Summary
SystemOption()
          Default constructor.
 
Method Summary
protected  boolean clearSharedData()
          Indicate whether the shared data of the last existing instance of this class should be cleared when that instance is finalized.
abstract  String displayName()
          Get the display name of this system option.
protected  void firePropertyChange(String name, Object oldValue, Object newValue)
          Fire a property change event to all listeners.
 HelpCtx getHelpCtx()
          Get context help for this system option.
 String getName()
          Get the name of this system option.
protected  boolean isReadExternal()
          Allows subclasses to test whether the change of a property is invoked from readExternal method or by external change invoked by any other program.
protected  boolean isWriteExternal()
          Allows subclasses to test whether the getter of a property is invoked from writeExternal method or by any other part of the program.
 void readExternal(ObjectInput in)
          Read all properties of this object (or subclasses) from an object input.
protected  void reset()
          Implements the reset by setting back all properties that were modified.
 void writeExternal(ObjectOutput out)
          Write all properties of this object (or subclasses) to an object output.
 
Methods inherited from class org.openide.util.SharedClassObject
addNotify, addPropertyChangeListener, equals, finalize, findObject, findObject, getLock, getProperty, hashCode, initialize, putProperty, putProperty, removeNotify, removePropertyChangeListener, writeReplace
 
Methods inherited from class java.lang.Object
clone, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SystemOption

public SystemOption()
Default constructor.

Method Detail

firePropertyChange

protected void firePropertyChange(String name,
                                  Object oldValue,
                                  Object newValue)
Fire a property change event to all listeners. Delays this loading when readExternal is active till it finishes.

Overrides:
firePropertyChange in class SharedClassObject
Parameters:
name - the name of the property
oldValue - the old value
newValue - the new value

reset

protected void reset()
Implements the reset by setting back all properties that were modified. A modified property has fired a PropertyChangeEvent with non-null name and non-null old value. The name and value are remembered and this method sets them back to original value.

Subclasses are free to override this method and reimplement the reset by themselves.

Overrides:
reset in class SharedClassObject
Since:
4.46

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Write all properties of this object (or subclasses) to an object output.

Specified by:
writeExternal in interface Externalizable
Overrides:
writeExternal in class SharedClassObject
Parameters:
out - the output stream
Throws:
IOException - on error

readExternal

public void readExternal(ObjectInput in)
                  throws IOException,
                         ClassNotFoundException
Read all properties of this object (or subclasses) from an object input. If there is a problem setting the value of any property, that property will be ignored; other properties should still be set.

Specified by:
readExternal in interface Externalizable
Overrides:
readExternal in class SharedClassObject
Parameters:
in - the input stream
Throws:
IOException - on error
ClassNotFound - if a class used to restore the system option is not found
ClassNotFoundException

clearSharedData

protected boolean clearSharedData()
Description copied from class: SharedClassObject
Indicate whether the shared data of the last existing instance of this class should be cleared when that instance is finalized. Subclasses may perform additional tasks on finalization if desired. This method should be overridden in lieu of SharedClassObject.finalize().

The default implementation returns true. Classes which have precious shared data may want to return false, so that all instances may be finalized, after which new instances will pick up the same shared variables without requiring a recalculation.

Overrides:
clearSharedData in class SharedClassObject
Returns:
true if all shared data should be cleared, false if it should stay in memory

getName

public final String getName()
Get the name of this system option. The default implementation just uses the display name.

Returns:
the name

displayName

public abstract String displayName()
Get the display name of this system option.

Returns:
the display name

getHelpCtx

public HelpCtx getHelpCtx()
Get context help for this system option.

Specified by:
getHelpCtx in interface HelpCtx.Provider
Returns:
context help

isReadExternal

protected final boolean isReadExternal()
Allows subclasses to test whether the change of a property is invoked from readExternal method or by external change invoked by any other program.

Returns:
true if the readExternal method is in progress

isWriteExternal

protected final boolean isWriteExternal()
Allows subclasses to test whether the getter of a property is invoked from writeExternal method or by any other part of the program.

Returns:
true if the writeExternal method is in progress


Built on May 4 2005.  |  Portions Copyright 1997-2005 Sun Microsystems, Inc. All rights reserved.