Index: openidex/manifest.mf
===================================================================
RCS file: /cvs/openidex/manifest.mf,v
retrieving revision 1.27
diff -u -r1.27 manifest.mf
--- openidex/manifest.mf 14 Mar 2003 23:29:53 -0000 1.27
+++ openidex/manifest.mf 19 Mar 2004 16:15:52 -0000
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
-OpenIDE-Module: org.openidex.util/2
+OpenIDE-Module: org.openidex.util/3
OpenIDE-Module-Localizing-Bundle: org/openidex/Bundle.properties
-OpenIDE-Module-Specification-Version: 2.7
+OpenIDE-Module-Specification-Version: 3.1
OpenIDE-Module-Implementation-Version: @BUILD_NUMBER_SUBST@
OpenIDE-Module-Layer: org/openidex/resources/mf-layer.xml
OpenIDE-Module-IDE-Dependencies: IDE/1 > 3.17
Index: openidex/looks/.cvsignore
===================================================================
RCS file: openidex/looks/.cvsignore
diff -N openidex/looks/.cvsignore
--- openidex/looks/.cvsignore 21 Jun 2002 12:23:50 -0000 1.4
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,7 +0,0 @@
-netbeans
-looks.nbm
-manifest-subst.mf
-Info
-LooksAPIs
-LooksAPIs.zip
-javadoc
Index: openidex/looks/build.xml
===================================================================
RCS file: openidex/looks/build.xml
diff -N openidex/looks/build.xml
--- openidex/looks/build.xml 10 Mar 2004 11:02:05 -0000 1.18
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,147 +0,0 @@
-
-
-
- This document lists changes made to the Looks
-API. Please ask on the The supplied dates indicate when the API change was made, on the CVS
-trunk. From this you can generally tell whether the change should be
-present in a given build or not; for trunk builds, simply whether it
-was made before or after the change; for builds on a stabilization
-branch, whether the branch was made before or after the given date. In
-some cases corresponding API changes have been made both in the trunk
-and in an in-progress stabilization branch, if they were needed for a
-bug fix; this ought to be marked in this list. Fuller descriptions of all changes can be found below (follow links). Not all deprecations are listed here, assuming that the deprecated
- APIs continue to essentially work. For a full deprecation list, please
- consult the
- Javadoc.
- These API specification versions may be used to indicate that a module
- requires a certain API feature in order to function. For example, if you
- see here a feature you need which is labelled 1.2, your
- manifest should contain in its main attributes the line:
- NodeSubstitute
.
- Look.createAttachedData
,
- it allows a convenient access to the Object
returned from that method.
- Look
subclasses are now advised to use this method to obtain data
- returned during initialization from createAttachedData
- NodeSubstitute
- NodeSubstitute
.
- It should be overriden rather than Look.attachTo
, which is
- declared final
in some SPI classes.
- Subclasses are advised to override this method to return data to be attachedÿ
- to the NodeSubstitute
. They may retrieve the data later using
- getAttachedData
.
- createAttachedData
in the
- default implementation.createAttachedData
- rather than attachTo
. This method was changed to delegate to
- the createAttachedData
for convenience.
- NodeSubstitute.getAttachedData
was made package private
- Look.getAttachedData
instead.
- NodeSubstitute
s from their delegateTo
- method. This is achieved by another less restrictive means.
- Introduction
-
-nbdev@netbeans.org
mailing list
-if you have any questions about the details of a
-change, or are wondering how to convert existing code to be compatible.What do the Dates Mean?
-
-
-
-
-
-
-
- release33
branch was made on Nov 23 '01 for use in
-the NetBeans 3.3.1 release, and later for development of Forte for Java (codename Orion).Index of APIs
- Incompatible changes by date
- All changes by date
- Changes by version
- OpenIDE-Module-Module-Dependencies: org.netbeans.modules.looks > 1.2
- Changes by affected class
- Details of all changes by API and date
-
- * Notice the difference between the methods which take the parameter of - * type NodeSubstitute and the methods which don't. The first methods are - * those which implement the functionality of the look. The second are methods - * which represent properties of the Look itself. - *
- *
- * @author Petr Hrebejk
- */
-public abstract class Look implements Node.Cookie, java.io.Serializable {
- /** Look that works with Node. If the represented object
- * is Node
the look takes its name, actions, properties, etc.
- * Very useful for bridging to already written nodes.
- */
- public static final Look NODES = new NodeProxyLook ();
-
- /** Look that finds the correct look by the type of the
- * represented object. It searches naming space of "Looks/Types/"
- * @see NamespaceLook
- */
- public static final Look DEFAULT = new TypesLook ();
-
- /** Look that presents an object as a JavaBean. Uses java.beans.Introspector
- * to get the properties and delegates to the object all other methods.
- */
- public static final Look BEANS = new BeanLook ();
-
- /** lock to synchronize access to substitute variable.
- */
- private static final String NLOCK = "NLock";
-
- /** reference to the NodeSubstitute link list. Lists all substitutes this
- * look is attached to.
- */
- private NLink substitutes;
-
- // Methods of look itself --------------------------------------------------
-
- /** Returns name of the look. This name should identify the look.
- * @return Name of the look.
- */
- public abstract String getName();
-
- /** The human presentable name of the look.
- * @return human presentable name
- */
- public abstract String getDisplayName ();
-
- // General methods ---------------------------------------------------------
-
- /**
- * Called on the current look when node is newly created or the look is
- * set on the Node. Overriding this
- * method allows to register listners on represented objects and asociate
- * them with the node.
- *
- * Implementors may not wait for any other threads at it may be potentially called - * from LookNode's lock. - *
- * The look can return an instance of any object in order to store its
- * own data with the substitute. The data can then be obtained by calling
- * Look.NodeSubstitute.getAttachedData.
- *
- * @param substitute The Look.NodeSubstitute
of the which was created.
- * @return the object that contains data of the look associated with the
- * substitute or null
if no such data are needed
- */
- protected Object attachTo( Look.NodeSubstitute substitute ) {
- return createAttachedData(substitute);
- }
-
- /**
- * This method is called during the process of attaching a Look to a
- * NodeSubstitute. Subclasses can override this method to attach
- * custom data to the NodeSubstitute instance so they can retrieve it
- * later.
- * @param substitute The Look.NodeSubstitute
of the which was created.
- * @return the object that contains data of the look associated with the
- * substitute or null
if no such data are needed
- */
- protected Object createAttachedData(Look.NodeSubstitute subst) {
- return null;
- }
-
- /**
- * Retrieves the data, previously attached to the NodeSubstitute.
- * The method returns null, if this Look is no longer selected one for the
- * NodeSubstitute
or createAttachedData returned
- * null.
- * @see #createAttachedData
- * @param substitute The Look.NodeSubstitute
of the node to operate on.
- * @return The instance previously returned from createAttachedData
- * or null if there was no data, or the Look is not selected on the Node
- */
- protected Object getAttachedData(Look.NodeSubstitute subst) {
- if (subst == null)
- return null;
- return subst.getAttachedData(this);
- }
-
- /** Creates lookup object with additional "cookies" for the LookNode using
- * the provided node substitute. The LookNode attaches calls this method just
- * once and attaches listener to the returned lookup so all changes in it
- * will result in PROP_COOKIE change in the LookNode.
- *
- *
- * @param substitute The Look.NodeSubstitute
of the node to operate on.
- * @return the lookup to be used by the LookNode or null if no additional cookies are
- * provided
- */
- public abstract Lookup createLookup (Look.NodeSubstitute substitute);
-
- /** A list of possible looks this look can be replaced with.
- * This list depends on the look itself and should contain looks
- * a user might find meaningful to use instead of this one.
- *
- * @param substitute substitute to find modes for
- * @return the array of looks or null if the no switching is available
- */
- public abstract Look[] availableLooks ( Look.NodeSubstitute substitute );
-
- // Methods for STYLE -------------------------------------------------------
-
- /** Gets localized name of given Node. This name will be showed in the
- * visual representation of the node.
- * @param substitute The Look.NodeSubstitute
of the node to operate on.
- * @return Localized name of the node. Implementation of {@link LookNode}
- * defaults this to the programmatic name of the node.
- */
- public abstract String getDisplayName( Look.NodeSubstitute substitute );
-
- /** Gets the progammatic name of given node. This name can be used for
- * operations on node paths in the node hierarchy and thus shouldn't be
- * localized.
- * @param substitute The Look.NodeSubstitute
of the node to operate on.
- * @return Programmatic name of the node.
- */
- public abstract String getName( Look.NodeSubstitute substitute );
-
- /** This method is clalled when the user renames the node using inplace
- * editing in the view.
- * @param substitute The Look.NodeSubstitute
of the renamed node.
- * @param newName The new name set by the user.
- */
- public abstract void setName( Look.NodeSubstitute substitute, String newName );
-
- /** Gets short description of given node. The short description is usually
- * visualized as a tooltip, but may have another forms as well.
- * @param substitute The Look.NodeSubstitute
of the node to operate on.
- * @return A localized short description associated with the node.
- * Implementation of {@link LookNode} defaults this to display name
- * of the node.
- */
- public abstract String getShortDescription( Look.NodeSubstitute substitute );
-
- /** Find an icon for this node (in the closed state).
- * @param substitute The Look.NodeSubstitute
of the node to operate on.
- * @param type Constant from {@link java.beans.BeanInfo}
- * @return Icon to use to represent the node in the closed state.
- * Implementation of {@link LookNode} provides default icon for nodes.
- */
- public abstract Image getIcon( Look.NodeSubstitute substitute, int type );
-
- /** Find an icon for this node (in the open state).
- * This icon is used when the node may have children and is expanded.
- * @param substitute The Look.NodeSubstitute
of the node to operate on.
- * @param type Constant from {@link java.beans.BeanInfo}
- * @return Icon to use to represent the node in the open state.
- * Implementation of {@link LookNode} defaults this to the closed
- * state icon.
- */
- public abstract Image getOpenedIcon( Look.NodeSubstitute substitute, int type );
-
- /** Get context help associated with this node.
- * @param substitute The Look.NodeSubstitute
of the node to operate on.
- * @return The context help object (could be null
or
- * {@link HelpCtx#DEFAULT_HELP})
- */
- public abstract HelpCtx getHelpCtx( Look.NodeSubstitute substitute );
-
- // Methods for CHILDREN ----------------------------------------------------
-
- /** Gets objects which are children of object represented by the node in the
- * hierarchy represented by this Look.
- * @param substitute The Look.NodeSubstitute
of the node to operate on.
- * @return Array of objects which should be represend as node children of
- * the node, can return null
that is equivalant to empty array
- */
- public abstract Object[] getChildObjects( Look.NodeSubstitute substitute );
-
- // Methods for ACTIONS & NEW TYPES -----------------------------------------
-
- /** Get the new types that can be created in given node.
- * For example, a node representing a Java package will permit classes to
- * be added.
- * @param substitute The Look.NodeSubstitute
of the node to operate on.
- * @return Array of new type operations that are allowed,
- * can return null
that is equivalant to empty array
- */
- public abstract NewType[] getNewTypes( Look.NodeSubstitute substitute );
-
- /** Get the set of actions associated with the node.
- * This may be used e.g. in constructing a {@link #getContextMenu context menu}.
- *
- * If the look returns null, the implementation {@ling LookNode} returns
- * the actions in {@link NodeOp#getDefaultActions} obtained by the super call.
- * @param substitute The Look.NodeSubstitute
of the node to operate on.
- * @return Array of the Actions applicable to the node or null
- * if actions in {@link NodeOp#getDefaultActions} should be used.
- */
- public abstract Action[] getActions( Look.NodeSubstitute substitute );
-
- /** Get a special set of actions for situations when this node is displayed
- * as a context.
- * @see org.openide.nodes.Node#getContextActions For more detailed description.
- * @param substitute The Look.NodeSubstitute
of the The node to operate on.
- * @return Actions for a context. In the LookNode implementation,
- * same as {@link #getActions}.
- *
- */
- public abstract Action[] getContextActions( Look.NodeSubstitute substitute );
-
- /** Get the default action for this node.
- * This action can but need not be one from the list returned
- * from {@link #getActions}. If so, the popup menu returned from
- * {@link #getContextMenu} is encouraged to highlight the action.
- * @param substitute The Look.NodeSubstitute
of the node to operate on.
- * @return Default action, or null
if there should be none.
- */
- public abstract Action getDefaultAction( Look.NodeSubstitute substitute );
-
- // Methods for PROPERTIES AND CUSTOMIZER -----------------------------------
-
- /** Get the list of property sets for given node. E.g. typically there
- * may be one for normal Bean properties, one for expert
- * properties, and one for hidden properties.
- * @param substitute The Look.NodeSubstitute
of the The node to operate on.
- * @return Property sets for the node, can return null
that is equivalant to empty array
- */
- public abstract Node.PropertySet[] getPropertySets( Look.NodeSubstitute substitute );
-
- /** Is the customizer for represented object available? If so, the method
- * getCustomizer should return non-null value.
- *
- * @param substitute The Look.NodeSubstitute
of the node to operate on.
- * @return true if the customizer is available, false otherwise
- */
- public abstract boolean hasCustomizer( Look.NodeSubstitute substitute );
-
- /** Get the customizer for represented object if available.
- * @param substitute The Look.NodeSubstitute
of the node to operate on.
- * @return The component, or null
if there is no customizer.
- */
- public abstract java.awt.Component getCustomizer( Look.NodeSubstitute substitute );
-
- // public boolean hasCustomizer (); Not necesary
-
- // Methods for CLIPBOARD OPERATIONS ----------------------------------------
-
- /** Test whether this node can be renamed.
- * If true, {@link #setName} will be called when the user changes the name
- * of the node.
- * @param substitute The Look.NodeSubstitute
of the node to operate on.
- * @return true
if the node can be renamed.
- */
- public abstract boolean canRename( Look.NodeSubstitute substitute );
-
- /** Test whether this node can be deleted.
- * @param substitute The Look.NodeSubstitute
of the node to operate on.
- * @return True
if can be deleted.
- */
- public abstract boolean canDestroy( Look.NodeSubstitute substitute );
-
- /** Test whether this node permits copying.
- * @param substitute The Look.NodeSubstitute
of the node to operate on.
- * @return True
if so.
- */
- public abstract boolean canCopy( Look.NodeSubstitute substitute );
-
- /** Test whether this node permits cutting.
- * @param substitute The Look.NodeSubstitute
of the node to operate on.
- * @return True
if so.
- */
- public abstract boolean canCut( Look.NodeSubstitute substitute );
-
- /** Determine which paste operations are allowed when a given
- * transferable is in the clipboard. For example, a node representing a
- * Java package will permit classes to be pasted into it.
- * @param substitute The Look.NodeSubstitute
of the node to operate on.
- * @param t The transferable in the clipboard.
- * @return Array of operations that are allowed, can return null
that is equivalant to empty array
- */
- public abstract PasteType[] getPasteTypes( Look.NodeSubstitute substitute, Transferable t);
-
- /** Determine if there is a paste operation that can be performed
- * on provided transferable. Used by drag'n'drop code to check
- * whether the drop is possible.
- * @param substitute The Look.NodeSubstitute
of the node to operate on.
- * @param t The transferable.
- * @param action The drag'n'drop action to do DnDConstants.ACTION_MOVE,
- * ACTION_COPY, ACTION_LINK.
- * @param index Index between children the drop occured at or -1 if not specified.
- * @return Null
if the transferable cannot be accepted or the paste type
- * to execute when the drop occures.
- */
- public abstract PasteType getDropType( Look.NodeSubstitute substitute, Transferable t, int action, int index);
-
- /** Called when a node is to be copied to the clipboard.
- * @param substitute The Look.NodeSubstitute
of the node Copy was invoked on.
- * @return The transferable object representing the content of the clipboard.
- * @throws IOException When the copy cannot be performed.
- */
- public abstract Transferable clipboardCopy( Look.NodeSubstitute substitute ) throws IOException;
-
- /** Called when the node is to be cut to the clipboard.
- * @param substitute The Look.NodeSubstitute
of the node to be cutted.
- * @return The transferable object representing the content of the clipboard.
- * @throws IOException When the copy cannot be performed.
- */
- public abstract Transferable clipboardCut( Look.NodeSubstitute substitute ) throws IOException;
-
- /** Called when a drag is started with this node.
- * The node can attach a transfer listener to ExTransferable and
- * will be then notified about progress of the drag (accept/reject).
- * @param substitute The Look.NodeSubstitute
of the node which was dragged.
- * @return Transferable to represent this node during a drag.
- * @throws IOException If a drag cannot be started.
- */
- public abstract Transferable drag( Look.NodeSubstitute substitute ) throws IOException;
-
- /** Called when node was destroyed.
- * @param substitute Look.NodeSubstitute of the destroyed ndoe.
- */
- public abstract void destroy( Look.NodeSubstitute substitute ) throws IOException;
-
- /** List of all NodeSubstitutes that use this look. Is useful when the look
- * changes some of its properties and needs to update all substitutes.
- *
- * @return enumeration of NodeSubstitute
- */
- protected final Enumeration nodeSubstitutes () {
- Enumeration en = new Enumeration () {
- private NLink current = substitutes;
-
- public boolean hasMoreElements () {
- return current != null;
- }
-
- public Object nextElement () {
- synchronized (NLOCK) {
- if (current == null) {
- throw new NoSuchElementException ();
- }
-
- Object o = current;
- current = current.next;
- return o;
- }
- }
- };
-
- AlterEnumeration alt = new AlterEnumeration (en) {
- private NLink previous;
-
- public Object alter (Object o) {
- NLink n = (NLink)o;
- if (n == null) {
- return null;
- }
-
- synchronized (NLOCK) {
- NodeSubstitute subst = (NodeSubstitute)n.get ();
- if (subst == null || subst.getLook () != Look.this) {
- // need to exclude this object from the list
-
- if (previous == null) {
- // we need to change looks first substitute
- Look.this.substitutes = n.next;
- } else {
- // need to skip this one from the previous
- previous.next = n.next;
- }
-
- // anyway we will not accept the object
- return null;
- }
-
- return subst;
- }
- }
- };
-
- // exclude nulls
- return new FilterEnumeration (alt);
- }
-
-
- // Innerclasses ------------------------------------------------------------
-
- /** Class passed to the Look methods as parameter. Each LookNode contains
- * exactly one instance of this class. Metods of the class allow access
- * to the properties and methods od the node needed for the Look.
- * @version 0.2
- */
- public static abstract class NodeSubstitute {
- /** the look this substitute is attached to or null */
- private Look look;
- /** data of the look attached to this substitute */
- private Object data;
-
- /** Attaches the substitute to a provided look. Does nothing if
- * the previously attached look is the same as the provided one.
- * If it is different, the substitute is detached from a look and
- * attached to the new one.
- *
- *
- * Method attachTo is called on the look to let it know about this
- * substitute and to let it store additional data getAttachedData
- * with this NodeSubstitute.
- *
- * @param look look to attach to or null if we should detach
- */
- protected final void attachTo (Look look) {
- synchronized (NLOCK) {
- if (look == this.look) {
- // ok no change
- return;
- }
-
- this.look = look;
- if (look == null) {
- // clear all values
- data = null;
- return;
- }
-
-
- NLink l = look.substitutes;
- look.substitutes = new NLink (this, l);
-
- this.data = look.attachTo (this);
- }
- }
-
- /** Access to the look this substitute is attached to.
- * @return the look we are attached to or null if not attached at all
- */
- public final Look getLook () {
- return look;
- }
-
-
- /** Fire a property change event on the associated node.
- * @param name name of changed property (from {@link #getPropertySets})
- * @param o old value
- * @param n new value
- */
- abstract public void firePropertyChange( String name, Object o, Object n );
-
- /** Fires the Event notificationg about name change.
- */
- abstract public void fireNameChange( String o, String n );
-
- /** Fires the Event notificationg about display name change.
- */
- abstract public void fireDisplayNameChange( String o, String n );
-
- /** Fires the Event notificationg about short description change.
- */
- abstract public void fireShortDescriptionChange(String o, String n);
-
- /** Fire a change event for {@link org.openide.nodes.Node#PROP_ICON} on
- * associated node.
- */
- abstract public void fireIconChange();
-
- /** Fire a change event for {@link org.openide.nodes.Node#PROP_OPENED_ICON} on
- * associated node.
- */
- abstract public void fireOpenedIconChange();
-
- /** Fires a (Bean) property change event (for
- * {@link org.openide.node.Node#PROP_PROPERTY_SETS}).
- * @param o the old set
- * @param n the new set
- */
- abstract public void firePropertySetsChange( Node.PropertySet[] o, Node.PropertySet[] n );
-
- /** To all node listeners fire node destroyed notification.
- */
- abstract public void fireNodeDestroyed();
-
- /** Tells the node that the children have to be refreshed.
- */
- abstract public void refreshChildren();
-
-
- //
- // Informations for the Look
- //
-
- /** Returns the object represented by the node
- * @return Object represented by the node this interior belongs to.
- */
- public abstract Object getRepresentedObject();
-
- /** Returns the data associated with the substitute by the Look
- * Made package-private from version 0.2. Use Look.getAttachedData
- * instead.
- * @see Look.createAttachedData
- * @return the object provided by Look.createAttachedData
- */
- final Object getAttachedData(Look look) {
- synchronized (NLOCK) {
- if (getLook() != look)
- return null;
- }
- return data;
- }
- } // end of NodeSubstitute
-
- /** NodeSubstitute linked list with weak references.
- */
- private static final class NLink extends WeakReference {
- /** link to next NLink or null */
- public NLink next;
-
- public NLink (NodeSubstitute substitute, NLink next) {
- super (substitute);
- this.next = next;
- }
- } // end of NLink
-}
Index: openidex/looks/src/org/netbeans/api/looks/LookChildren.java
===================================================================
RCS file: openidex/looks/src/org/netbeans/api/looks/LookChildren.java
diff -N openidex/looks/src/org/netbeans/api/looks/LookChildren.java
--- openidex/looks/src/org/netbeans/api/looks/LookChildren.java 3 Dec 2002 14:12:19 -0000 1.6
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,95 +0,0 @@
-/*
- * 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-2000 Sun
- * Microsystems, Inc. All Rights Reserved.
- */
-
-package org.netbeans.api.looks;
-
-import java.util.*;
-
-import org.openide.nodes.*;
-
-/** WARNING - This API is not finished and is subject to change
- * Please don't use this API for other purposes than testing.
- *
- * Temporary implementation of Children of a LookNode. The class contains
- * only code wich is necessary for testing looks and may be extended later.
- *
- * @author Petr Hrebejk
- */
-final class LookChildren extends Children.Keys {
- /** Use this constant for returning empty KeySets. */
- private static final Object[] NO_KEYS = {};
-
- /** @param brutal needs clean */
- void refreshChildren( boolean brutal ) {
- if (brutal) {
- setKeys (Collections.EMPTY_LIST);
- }
-
- final Object[] keys = getKeys();
- MUTEX.postWriteRequest(new Runnable() {
- public void run() {
- setKeys( keys );
- }
- });
- }
-
- protected void addNotify() {
- setKeys( getKeys() );
- }
-
- protected void removeNotify() {
- setKeys( Collections.EMPTY_LIST );
- }
-
- protected Node[] createNodes( Object key ) {
- if (key == null) return new Node[0];
-
- Node n = getNode ();
- if (! (n instanceof LookNode)) {
- Look l = (Look)n.getCookie (Look.class);
-
- if (l == null) {
- l = Look.DEFAULT;
- }
-
- return new Node[] { new LookNode (key, l) };
- }
-
- LookNode ln = (LookNode)n;
- LookNode node = new LookNode (key, ln.getBaseLook ());
-
- // is not there a better look?
- Look l = ln.findLookForChild (node);
- if (l != null && node.getLook () != l) {
- node.setLook (l);
- }
-
- return new Node[] { node };
- }
-
-
- // Private methods ---------------------------------------------------------
-
- private Object[] getKeys() {
-
- Object[] keys = ((LookNode)getNode ()).getChildObjects ();
- if ( keys == null ) {
- return NO_KEYS;
- }
- else {
- return keys;
- }
-
- }
-
-}
Index: openidex/looks/src/org/netbeans/api/looks/LookNode.java
===================================================================
RCS file: openidex/looks/src/org/netbeans/api/looks/LookNode.java
diff -N openidex/looks/src/org/netbeans/api/looks/LookNode.java
--- openidex/looks/src/org/netbeans/api/looks/LookNode.java 3 Dec 2002 14:12:19 -0000 1.7
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,925 +0,0 @@
-/*
- * 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-2000 Sun
- * Microsystems, Inc. All Rights Reserved.
- */
-
-package org.netbeans.api.looks;
-
-import java.beans.*;
-import java.awt.Image;
-import java.awt.datatransfer.Transferable;
-import java.io.IOException;
-import java.util.Map;
-import javax.swing.Action;
-
-import org.openide.nodes.*;
-
-import org.openide.util.HelpCtx;
-import org.openide.util.Utilities;
-import org.openide.util.actions.SystemAction;
-import org.openide.util.datatransfer.NewType;
-import org.openide.util.datatransfer.PasteType;
-import org.openide.util.Lookup;
-import org.openide.util.LookupEvent;
-import org.openide.util.LookupListener;
-import org.openide.util.Mutex;
-import org.openide.util.MutexException;
-import java.util.HashMap;
-import java.util.Iterator;
-
-import org.netbeans.spi.looks.ProxyLook;
-
-/**
- * Node that represents an object using Looks.
- *
- * @author Petr Hrebejk
- */
-public final class LookNode extends Node implements Node.Cookie {
- /** it is our private lock changes of delegates for given nodes */
- private final Mutex MUTEX = new Mutex ();
-
- /** Use this constant for returning no Actions. */
- private static final SystemAction[] NO_SYSTEM_ACTIONS = {};
-
- /** Use this constant for returning empty NewTypes. */
- private static final NewType[] NO_NEW_TYPES = {};
-
- /** Use this constant for returning empty PasteTypes. */
- private static final PasteType[] NO_PASTE_TYPES = {};
-
- /** Use this constant for returning empty PropertySets. */
- private static final Node.PropertySet[] NO_PROPERTY_SETS = {};
-
- /** Name of the default icon 16x16 */
- private static final String DEFAULT_ICON_16_NAME =
- "org/netbeans/modules/looks/resources/defaultNode.gif"; // NOI18N
-
- /** Name of the default icon 32x32 */
- private static final String DEFAULT_ICON_32_NAME =
- "org/netbeans/modules/looks/resources/defaultNode32.gif"; //NOI18N
-
- /** Maximum of looks that is kept in memory. This should not be
- * infihite, but it also should be adjusted to the user experience -
- * how many selections are important to the user!?
- */
- private static final int MAX_MEMORY = 30;
-
- /** the base look associated with this node */
- private Look base;
-
- /** the actual look associated with this node */
- private Look look;
-
- /** Object represented (delegeted) by interior */
- private SubstituteImpl substitute;
-
- /** represented object */
- private Object representedObject;
-
- /** mapping from names of nodes to names of looks. Each node can have
- * such mapping - it will influence the persistence of selected objects
- *
- * Map with
- * Utility class for creating a SheetSet for switching looks.
- *
- * @author Petr Hrebejk
- */
-class LookProperties extends Object {
-
- private static final ResourceBundle bundle = NbBundle.getBundle( LookProperties.class );
-
- public static final String LOOK_SHEET_SET_NAME = "Look"; // NOI18N
-
- /** Name of the default look. I.e. when the look on the node is null*/
- private static final String DEFAULT = bundle.getString( "CTL_Default" ); //NOI18N
-
- public static Sheet.Set getLookPropertySet( LookNode node ) {
-
- Sheet.Set set = new Sheet.Set();
- set.setName( LOOK_SHEET_SET_NAME ); // NOI18N
- set.setDisplayName( bundle.getString( "CTL_LookSheetSetName" ) ); //NOI18N
- set.put( new LookProperty( node ) );
- return set;
- }
-
- public static SystemAction getSetLookAction () {
- return SystemAction.get (SetLookAction.class);
- }
-
- // INNER CLASSES -----------------------------------------------------------
-
- /** The property for changing look
- */
- static class LookProperty extends PropertySupport.ReadWrite {
-
- private final LookNode lookNode;
-
- LookProperty( LookNode lookNode ) {
- super( bundle.getString( "CTL_LookProperty" ), // NOI18N
- Look.class,
- bundle.getString( "CTL_LookProperty" ), // NOI18N
- bundle.getString( "CTL_LookPropertyShortDescription" ) // NOI18N
- );
- this.lookNode = lookNode;
- }
-
-
- public Object getValue() {
- return lookNode.getLook ();
- }
-
- public void setValue( Object value ) {
- lookNode.setLook( (Look) value );
- }
-
- public PropertyEditor getPropertyEditor () {
- return new LookEditor( lookNode );
- }
-
- }
-
- /** Editor for choosing looks */
- static class LookEditor extends PropertyEditorSupport {
-
- /** The node */
- LookNode lookNode = null;
-
- /** Current value */
- private Look look = null;
-
- /** Creates new editor */
- public LookEditor ( LookNode lookNode ) {
- this.lookNode = lookNode;
- }
-
- /**
- * @return The property value as a human editable string.
- * Returns null if the value can't be expressed as an editable string.
- * If a non-null value is returned, then the PropertyEditor should
- * be prepared to parse that string back in setAsText().
- */
- public String getAsText () {
- if ( getValue() == null ) {
- return DEFAULT;
- }
- return ((Look)getValue()).getDisplayName ();
- }
-
- /**
- * Set the property value by parsing a given String.
- * @param text The string to be parsed.
- */
- public void setAsText ( String string ) throws IllegalArgumentException {
- if ( string.equals( DEFAULT ) ) {
- setValue( null );
- }
-
- ArrayList list = new ArrayList ();
- collectLooks (lookNode.getSubstitute(), lookNode.getBaseLook (), list);
- Iterator it = list.iterator ();
-
- while (it.hasNext ()) {
- Look l = (Look)it.next ();
-
- if (l.getDisplayName ().equals (string)) {
- setValue (l);
- return;
- }
- }
- throw new IllegalArgumentException( "No such look - " + string ); // NOI18N
- }
-
- /**
- * @return A fragment of Java code representing an initializer for the
- * current value.
- */
- public String getJavaInitializationString () {
- return (getValue() == null) ? "" : look.getName(); // NOI18N
- }
-
- /**
- * @return The tag values for this property.
- */
- public String[] getTags () {
- ArrayList list = new ArrayList ();
- collectLooks (lookNode.getSubstitute (), lookNode.getBaseLook (), list);
-
- String names[] = new String [list.size ()];
- for ( int i = 0; i < names.length ; i++ ) {
- Look l = (Look)list.get (i);
-
- names[i] = l.getDisplayName ();
- }
- return names;
- }
-
- static void collectLooks (Look.NodeSubstitute subst, Look look, ArrayList list) {
- if (list.contains (look)) return;
-
- list.add (look);
-
- Look[] arr = look.availableLooks (subst);
- if (arr == null) return;
-
- for (int i = 0; i < arr.length; i++) {
- list.add (arr[i]);
- }
- }
- }
-
- /** Popupmenu action for choosing looks
- */
- static class SetLookAction extends NodeAction {
- /** name of property of last selected object */
- public static final String PROP_LAST = "last";
-
- /** reference to the last LookNode */
- private Reference last;
-
- public java.lang.String getName() {
- return bundle.getString( "ACT_SetLook" ); //NOI18N
- }
-
- public org.openide.util.HelpCtx getHelpCtx() {
- return org.openide.util.HelpCtx.DEFAULT_HELP;
- }
-
- /* Returns a submneu that will present this action in a PopupMenu.
- * @return the JMenuItem representation for this action
- */
- public JMenuItem getPopupPresenter() {
- JMenu mainItem = new MenuView.Menu (Ch.globalNode ());
- Actions.connect (mainItem, this, true);
-// HelpCtx.setHelpIDString (mainItem, SetLookAction.class.getName ());
- return mainItem;
- }
-
- /** Presentation in menu */
- public JMenuItem getMenuPresenter () {
- JMenu mainItem = new MenuView.Menu (Ch.globalNode ());
- Actions.connect (mainItem, this, false);
-
- return mainItem;
- }
-
- /** Presentation in toolbar */
- public Component getToolbarPresenter () {
- isEnabled ();
-
- ExplorerPanel ep = new ExplorerPanel ();
- ep.add (new ChoiceView ());
- ep.getExplorerManager().setRootContext (Ch.globalNode ());
-
- return ep;
- }
-
- /** Getter for the last selected item.
- */
- public LookNode getLast () {
- Reference l = last;
- if (l != null) {
- return (LookNode)l.get ();
- } else {
- return null;
- }
- }
-
- protected boolean enable(org.openide.nodes.Node[] node) {
- if (node.length != 1) return false;
-
- LookNode n = (LookNode)node[0].getCookie (LookNode.class);
-
- if (n != getLast ()) {
- // update the last reference
- if (n == null) {
- last = null;
- } else {
- last = new WeakReference (n);
- }
-
- firePropertyChange (PROP_LAST, null, null);
- }
-
- return n != null;
- }
-
- protected void performAction(org.openide.nodes.Node[] node) {
- // called when a node presenting look is selected
- for (int i = 0; i < node.length; i++) {
- Object l = node[i].getValue ("look"); // NOI18N
- Object n = node[i].getValue ("node"); // NOI18N
- if (l instanceof Look && n instanceof LookNode) {
- ((LookNode)n).setLook ((Look)l);
- }
- }
- }
- }
-
- /** Children that for a look display nodes for all its sublooks.
- */
- private static final class Ch extends Children.Keys
- implements PropertyChangeListener {
- /** global node */
- private static Reference globalNode;
-
- private LookNode node;
- private Look look;
- private boolean active;
-
- public Ch (LookNode node, Look l) {
- this.node = node;
- this.look = l;
- }
-
-
-
- protected void addNotify () {
- active = true;
-
- update ();
- }
-
- protected void removeNotify () {
- setKeys (Collections.EMPTY_LIST);
-
- active = false;
- }
-
- protected Collection initCollection() {
- return Collections.singleton (create (node, look, false));
- }
-
-
- protected Node[] createNodes(Object key) {
- Look l = (Look)key;
- return new Node[] { create (node, l, true) };
- }
-
- public void propertyChange(java.beans.PropertyChangeEvent ev) {
- if (SetLookAction.PROP_LAST == ev.getPropertyName()) {
- update ();
- }
- }
-
- /** Updates the state acording to current selected node.
- */
- public void update () {
- LookNode n = null;
- Look l = null;
- SetLookAction set = (SetLookAction)SystemAction.get (SetLookAction.class);
- if (node != null && node.equals (set.getLast())) {
- n = node;
- l = look;
- }
- else {
- n = set.getLast ();
- l = n == null ? null : n.getBaseLook ();
- node = n;
- look = l;
- }
-
- if (active) {
- // refresh
- if (l != null && n != null) {
- setKeys (Collections.EMPTY_LIST);
- setKeys (l.availableLooks (n.getSubstitute ()));
- } else {
- setKeys (Collections.EMPTY_LIST);
- }
- }
- }
-
- /** Creates node that represents global state of the system.
- */
- public static synchronized Node globalNode () {
- if (globalNode != null) {
- Node n = (Node)globalNode.get ();
-
- if (n != null) {
- ((Ch)n.getChildren ()).update ();
- return n;
- }
- }
-
- Ch ch = new Ch (null, null);
-
- // attach listener to last selected node
- SystemAction action = SystemAction.get (SetLookAction.class);
- action.addPropertyChangeListener(
- WeakListener.propertyChange (ch, action)
- );
-
- Node n = new AbstractNode (ch);
- globalNode = new SoftReference (n);
- return n;
- }
-
- /** Creates new node for a look presentation.
- */
- private static Node create (LookNode subst, Look l, boolean submenu) {
-
- AbstractNode n;
- Look[] arr = l.availableLooks (subst.getSubstitute());
- if (submenu && arr != null && arr.length != 0) {
- n = new AbstractNode (new Ch (subst, l));
- } else {
- n = new AbstractNode (Children.LEAF);
- }
-
- n.setName (l.getName ());
- n.setDisplayName (l.getDisplayName ());
- n.setDefaultAction (SystemAction.get (SetLookAction.class));
- n.setValue("look", l); // NOI18N
- n.setValue("node", subst); // NOI18N
- return n;
- }
- }
-}
-
Index: openidex/looks/src/org/netbeans/api/looks/NodeProxyLook.java
===================================================================
RCS file: openidex/looks/src/org/netbeans/api/looks/NodeProxyLook.java
diff -N openidex/looks/src/org/netbeans/api/looks/NodeProxyLook.java
--- openidex/looks/src/org/netbeans/api/looks/NodeProxyLook.java 3 Dec 2002 14:12:19 -0000 1.4
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,539 +0,0 @@
-/*
- * 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 Forte for Java, Community Edition. The Initial
- * Developer of the Original Code is Sun Microsystems, Inc. Portions
- * Copyright 1997-2000 Sun Microsystems, Inc. All Rights Reserved.
- */
-
-package org.netbeans.api.looks;
-
-import java.util.Collection;
-import java.awt.Image;
-import java.awt.datatransfer.Transferable;
-import java.io.IOException;
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeEvent;
-import java.util.ArrayList;
-
-import javax.swing.Action;
-
-import org.openide.nodes.*;
-import org.openide.util.HelpCtx;
-import org.openide.util.datatransfer.NewType;
-import org.openide.util.datatransfer.PasteType;
-import org.openide.util.Lookup;
-import org.openide.util.WeakSet;
-import org.openide.util.lookup.InstanceContent;
-import org.openide.util.lookup.AbstractLookup;
-
-
-import org.netbeans.spi.looks.*;
-import org.openide.util.NbBundle;
-
-/**
- * Utility Class which allows to use LookNodes on existing Nodes.
- * The class assumes that represented object is a Node. If there is
- * Node.Interior representing other object than a ndoe the look delegates
- * to {DefaultLook#INSTANCE} i.e. returns neutral values.
- * Some methods are linked together to make it easier for subclasses to
- * implement reasonable functionality (iconBase, actionBase), etc.
- *
- * @author Jaroslav Tulach
- */
-public abstract class DefaultLook extends Look {
- /** messages to create a resource identification for each type of
- * icon from the base name for the icon.
- */
- private static final MessageFormat[] icons = {
- // color 16x16
- new MessageFormat ("{0}.gif"), // NOI18N
- // color 32x32
- new MessageFormat ("{0}32.gif"), // NOI18N
- // mono 16x16
- new MessageFormat ("{0}.gif"), // NOI18N
- // mono 32x32
- new MessageFormat ("{0}32.gif"), // NOI18N
- // opened color 16x16
- new MessageFormat ("{0}Open.gif"), // NOI18N
- // opened color 32x32
- new MessageFormat ("{0}Open32.gif"), // NOI18N
- // opened mono 16x16
- new MessageFormat ("{0}Open.gif"), // NOI18N
- // opened mono 32x32
- new MessageFormat ("{0}Open32.gif"), // NOI18N
- };
- /** To index normal icon from previous array use
- * + ICON_BASE.
- */
- private static final int ICON_BASE = -1;
- /** for indexing opened icons */
- private static final int OPENED_ICON_BASE = 3;
-
- /** name of the look */
- private String name;
-
- /** Creates new instance of look does no work.
- * @param name the name to assign to the look
- * @see getName
- */
- public DefaultLook(String name) {
- this.name = name;
- }
-
-
- /** The human presentable name of the look. The default implementation
- * calls
- * Warning: If you expect to have subclasses, override this method with
- * better implementation!
- *
- * @return human presentable name
- */
- public String getDisplayName() {
- return NbBundle.getMessage (getClass (), "LAB_" + name); // NOI18N
- }
-
- /** Returns name of the look as provided in constructor.
- * @return Name of the look.
- */
- public String getName() {
- return name;
- }
-
- // General methods ---------------------------------------------------------
-
- /** Does neutral behaviour (doing nothing, returning null)
- */
- public Lookup createLookup (Look.NodeSubstitute substitute) {
- return null;
- }
-
-
- /** Does neutral behaviour (doing nothing, returning null)
- */
- public Look[] availableLooks (Look.NodeSubstitute substitute) {
- return null;
- }
-
- // Methods for STYLE -------------------------------------------------------
-
- /** Does neutral behaviour (doing nothing, returning null)
- */
- public String getDisplayName( Look.NodeSubstitute substitute ) {
- return null;
- }
-
- /** Does neutral behaviour (doing nothing, returning null)
- */
- public String getName( Look.NodeSubstitute substitute ) {
- return null;
- }
-
- /** Does neutral behaviour (doing nothing, returning null)
- */
- public void setName(Look.NodeSubstitute substitute, String newName) {
- }
-
- /** Does neutral behaviour (doing nothing, returning null)
- */
- public String getShortDescription ( Look.NodeSubstitute substitute ) {
- return null;
- }
-
- /** Finds icon using the value returned from iconBase
- * @return an icon or null if not found
- */
- public Image getIcon( Look.NodeSubstitute substitute, int type ) {
- return findIcon (substitute, type, ICON_BASE);
- }
-
- /** Finds icon using the value returned from iconBase
- * @return an icon or null if not found
- */
- public Image getOpenedIcon( Look.NodeSubstitute substitute, int type ) {
- return findIcon (substitute, type, OPENED_ICON_BASE);
- }
-
- /** Does neutral behaviour (doing nothing, returning null)
- */
- public HelpCtx getHelpCtx( Look.NodeSubstitute substitute ) {
- return null;
- }
-
- // Methods for CHILDREN ----------------------------------------------------
-
- /** Does neutral behaviour (doing nothing, returning null)
- */
- public Object[] getChildObjects( Look.NodeSubstitute substitute ) {
- return null;
- }
-
- // Methods for ACTIONS & NEW TYPES -----------------------------------------
-
- /** Does neutral behaviour (doing nothing, returning null)
- */
- public NewType[] getNewTypes( Look.NodeSubstitute substitute ) {
- return null;
- }
-
- /** Calls actionBase (substitute, false) and extracts actions
- * from that context.
- *
- * @return the actions at the context or null
- */
- public Action[] getActions( Look.NodeSubstitute substitute ) {
- return actionsForContext (actionBase (substitute, false));
- }
-
- /** Calls actionBase (substitute, true) and extracts actions
- * from that context.
- *
- * @return the actions at the context or null
- */
- public Action[] getContextActions( Look.NodeSubstitute substitute ) {
- return actionsForContext (actionBase (substitute, true));
- }
-
- /** Extracts the first action from getActions, if any.
- * @return the action or null
- */
- public Action getDefaultAction( Look.NodeSubstitute substitute ) {
- Action[] arr = getActions (substitute);
- return arr != null && arr.length > 0 ? arr[0] : null;
- }
-
- // Methods for PROPERTIES AND CUSTOMIZER -----------------------------------
-
- /** Does neutral behaviour (doing nothing, returning null)
- */
- public Node.PropertySet[] getPropertySets( Look.NodeSubstitute substitute ) {
- return null;
- }
-
- /** Is the customizer for represented object available? Checks whether
- * getCustomizer (substitute) returns non-null value
- *
- * @param substitute The For example, if the returned base is
- * The default implementation returns null.
- *
- * @param subst the substitute to locate icon for
- * @return the base for icon search (no initial slash) or By default the method returns name of this class (separated by slashes)
- * with a prefix Looks/Actions. So for a class
- * The LookNode interior is hold by a WeakReference so the Node can be
- * garbage collected even if the represented object still exists.
- * Helper methods allow automatic changes of Icon, Name and DisplayName
- * if some properies are changed.
- */
-public abstract class EventTranslator extends WeakReference {
-
- /** Queue with all weak references */
- private static ReferenceQueue QUEUE = new ReferenceQueue ();
- /** How often clean */
- private static int CLEANER_TIME = 25000;
- /** Clearner task */
- private static RequestProcessor.Task CLEANER_TASK = RequestProcessor.postRequest(
- new Cleaner (), CLEANER_TIME, Thread.MIN_PRIORITY
- );
-
- /** Fake instance to fire event on when the node was garbage collected. */
- private static Look.NodeSubstitute NULL_SUBSTITUTE;
-
- /** Creates new EventTranslator for given LookNode.Interior
- * @param LookNode.Interior the node to fire events on.
- */
- public EventTranslator ( Look.NodeSubstitute substitute ) {
- super( substitute, QUEUE );
- }
-
- /** This method is called when the node was garbage collected. You shoud
- * unregister from all objects where this object was registered as a
- * listener.
- */
- protected abstract void unregister();
-
- /** Gets the substitute to fire on
- */
- protected Look.NodeSubstitute getSubstitute() {
- Look.NodeSubstitute substitute = (Look.NodeSubstitute)get();
-
- if ( substitute == null || substitute.getRepresentedObject() == null ) {
- unregister();
-
- if ( NULL_SUBSTITUTE == null ) {
- NULL_SUBSTITUTE = new NullNodeSubstitute();
- }
- return NULL_SUBSTITUTE;
- }
- else {
- return substitute;
- }
- }
-
-
- // Innerclasses ------------------------------------------------------------
-
- /** Class that periodically runs cleaning of the queue.
- */
- private static final class Cleaner extends Object implements Runnable {
- public void run () {
- for (;;) {
- EventTranslator et = (EventTranslator)QUEUE.poll();
- if (et == null)
- break;
- et.unregister();
- }
-
- CLEANER_TASK.schedule (CLEANER_TIME);
- }
- }
-
- /** Empty Look.NodeSubstitute which does not fire any events
- */
- private static final class NullNodeSubstitute extends Look.NodeSubstitute {
- public NullNodeSubstitute () {
- }
-
- public Object getRepresentedObject() {
- return null;
- };
-
- public void firePropertyChange( String name, Object o, Object n ) {
- }
-
- public void fireNameChange( String o, String n ) {
- }
-
- public void fireDisplayNameChange( String o, String n ) {
- }
-
- public void fireShortDescriptionChange(String o, String n) {
- }
-
- public void fireIconChange() {
- }
-
- public void fireOpenedIconChange() {
- }
-
- public void firePropertySetsChange( Node.PropertySet[] o, Node.PropertySet[] n ) {
- }
-
- public void fireNodeDestroyed() {
- }
-
- public void refreshChildren() {
- }
- }
-
-}
\ No newline at end of file
Index: openidex/looks/src/org/netbeans/spi/looks/FilterLook.java
===================================================================
RCS file: openidex/looks/src/org/netbeans/spi/looks/FilterLook.java
diff -N openidex/looks/src/org/netbeans/spi/looks/FilterLook.java
--- openidex/looks/src/org/netbeans/spi/looks/FilterLook.java 3 Dec 2002 14:12:21 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,128 +0,0 @@
-/*
- * 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 Forte for Java, Community Edition. The Initial
- * Developer of the Original Code is Sun Microsystems, Inc. Portions
- * Copyright 1997-2000 Sun Microsystems, Inc. All Rights Reserved.
- */
-
-package org.netbeans.spi.looks;
-
-
-
-import org.openide.nodes.*;
-
-import org.netbeans.api.looks.*;
-import org.openide.util.NbBundle;
-
-/**
- * This is base class for delegating to other looks or nodes. All methods
- * delegate to the delegate, unless they are masked.
- *
- * All the methods contain simple deleagation to the {@link Look}
- * passed as parameter into the constructor, if the mask contains flag
- * for the method.
- * Use the methods: {@link #setLookMask}, {@link #lookMask}, {@link #lookMask},
- * {@link #lookUnmask} for work with the mask.
- * The default implementation ignores the context and just checks
- * the mask which can be modified by lookMask, lookUnmask
- * methods.
- *
- * Subclasses might override
- * this method with implementation that bases its decision on different criteria.
- *
- * @param method one of the constants defined here that identifies the method
- * we want to delegate to
- * @param substitute the substitute that the method will be called with or
- * null if we are in notification of changes and we have no substitute
- * @return either the delegate look or null
- */
- protected final Look[] delegateTo (long method, NodeSubstitute substitute) {
- return ( mask & method ) > 0 ? delegate : null;
- }
-
- // Methods of look itself -------------------------------------------------
-
- /** Sets mask for this look. Only methods contained in the mask
- * will be delegated. Other methods will return neutral values.
- * @param mask The mask to be set.
- */
- protected final void setLookMask( long mask ) {
- this.mask = mask;
- }
-
- /** Returns the current mask for this filter look.
- * @return Current mask.
- */
- protected final long getLookMask( ) {
- return mask;
- }
-
- /** Masks given methods. Removes given methods from given mask.
- * The masked methods will be no longer delegated.
- * @param methods Logical
- * Subclasses are allowed to provide different implementation which can
- * base the naming based on for example public ID
- * for
- * The Look.DEFAULT uses the this class and returns enumeration
- * of all superclasses and superinterfaces for provided object.
- *
- * @param obj the represented object
- * @return enumeration of String
- * @see Look.DEFAULT
- * @since Made non abstract in version 0.2
- */
- protected Enumeration namesFor (Object obj) {
- return obj == null ? EmptyEnumeration.EMPTY : forClass (obj.getClass ());
- }
-
- /** Offers all looks available in the namespace. Takes input from
- * namesFor and finds all looks that represent some name in enumeration.
- *
- * @param subst substitute to find looks for
- * @return array of available looks
- */
- public Look[] availableLooks (NodeSubstitute subst) {
- Enumeration en = namesFor (subst.getRepresentedObject ());
- ArrayList looks = new ArrayList ();
-
- // collects all looks into array list looks
- findLook (prefix, en, looks);
-
- return (Look[])looks.toArray (new Look[0]);
- }
-
-
- /** Finds look(s) for a class.
- * @param prefix prefix string to add to each name or null
- * @param names list of Strings to check their names (c1/c2/name)
- * @param looks list where to add all found looks or null if just find one
- * @return look found or null
- */
- private static Look findLook (String prefix, Enumeration names, List looks) {
- if (context == null) {
- try {
- context = org.netbeans.api.naming.NamingSupport.createSFSInitialContext();
- } catch (NamingException ex) {
- context = ex;
- }
- }
-
- if (context instanceof Context) {
- return findLook ((Context)context, prefix, names, looks);
- } else {
- return null;
- }
- }
-
- /** Searches for a look in given namespace and in the order specified by
- * given names.
- *
- * @param namespace the root context to search from
- * @param prefix prefix string to add to each name or null
- * @param names list of Strings to check their names (c1/c2/name)
- * @param toAdd list where to add all found looks
- * @return the look or null
- */
- private static Look findLook (
- Context namespace, String prefix, Enumeration names, List toAdd
- ) {
- java.util.Collection checks = new java.util.HashSet();
- while (names.hasMoreElements ()) {
- try {
- String check = (String)names.nextElement ();
- if (!checks.add(check))
- continue;
- if (prefix != null) {
- check = prefix + check;
- }
-
- NamingEnumeration en = namespace.listBindings (check);
- while (en.hasMoreElements ()) {
- Binding b = (Binding)en.next ();
- Object o = b.getObject ();
- if (o instanceof Look) {
- if (toAdd != null) {
- // we are searching for all looks
- toAdd.add (o);
- } else {
- // we need just one
- return (Look)o;
- }
- }
- }
- } catch (NamingException ex) {
- }
- }
- return null;
- }
-
- /** Enumeration for a java class.
- * @param c class
- * @return enumeration of names of implemented/extended classes in form suitable
- * for findLook
- */
- private static Enumeration forClass (Class c) {
- QueueEnumeration en = new QueueEnumeration () {
- protected void process (Object o) {
- Class x = (Class)o;
- Class s = x.getSuperclass();
- put (x.getInterfaces ());
- if (s != null && s != Object.class) {
- // if not object process all interfaces and super classes
- put (s);
- }
- }
- };
- if (c != Object.class) {
- en.put (c);
- }
-
- AlterEnumeration alter = new AlterEnumeration (en) {
- protected Object alter (Object clazz) {
- Class c = (Class)clazz;
- return c.getName ().replace ('.', '/');
- }
- };
-
- return new SequenceEnumeration (alter, new SingletonEnumeration ("java/lang/Object")); // NOI18N
- }
-}
Index: openidex/looks/src/org/netbeans/spi/looks/ProxyLook.java
===================================================================
RCS file: openidex/looks/src/org/netbeans/spi/looks/ProxyLook.java
diff -N openidex/looks/src/org/netbeans/spi/looks/ProxyLook.java
--- openidex/looks/src/org/netbeans/spi/looks/ProxyLook.java 3 Dec 2002 14:12:21 -0000 1.5
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,1073 +0,0 @@
-/*
- * 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 Forte for Java, Community Edition. The Initial
- * Developer of the Original Code is Sun Microsystems, Inc. Portions
- * Copyright 1997-2000 Sun Microsystems, Inc. All Rights Reserved.
- */
-
-package org.netbeans.spi.looks;
-
-import java.awt.Image;
-import java.awt.datatransfer.Transferable;
-import java.io.IOException;
-
-import javax.swing.Action;
-
-import org.openide.nodes.*;
-import org.openide.util.HelpCtx;
-import org.openide.util.Lookup;
-import org.openide.util.datatransfer.NewType;
-import org.openide.util.datatransfer.PasteType;
-
-import org.netbeans.api.looks.*;
-import java.util.ArrayList;
-import org.openide.util.lookup.ProxyLookup;
-import java.util.Arrays;
-import java.util.HashMap;
-
-/**
- * This is base class for delegating to other looks. All methods are
- * enumerated by numeric constants and by overriding delegateTo
- * subclasses can easily decide which methods and where delegate.
- *
- * It is safe to assume that some of the functionality will be delegated
- * and some of it will not, but it is desirable to delegate the
- * ATTACH_TO to all looks because it allows the proxied looks
- * to store information needed later. On the other hand not delegating
- * this call is possible if it is known that the proxied to look will
- * not need such informations later.
- *
- * Also it is not suggested to switch the looks that is being delegated to
- * during different calls, because it can also result in calls to a look
- * that has not have been attached by calling attachTo.
- *
- * It is also possible to change the represented object for a looks
- * those are being delegated to (see method delegateObject)
- * but again it is necessary to allow delegation of ATTACH_TO.
- *
- * @author Jaroslav Tulach
- */
-public abstract class ProxyLook extends Look {
- /** Mask for enabling (unmasking) all methods */
- public static final long ALL_METHODS = Long.MAX_VALUE;
- /** Mask for disabling (masking) all methods */
- public static final long NO_METHODS = 0;
- /** Mask for the method {@link #getCookie}. */
- public static final long CREATE_LOOKUP = 1;
- /** Mask for the method {@link #getHandle}. */
-// public static final long GET_HANDLE = CREATE_LOOKUP << 1;
- /** Mask for the method {@link #getDisplayName}. */
- public static final long GET_DISPLAY_NAME = CREATE_LOOKUP << 1;
- /** Mask for the method {@link #getName}. */
- public static final long GET_NAME = GET_DISPLAY_NAME << 1;
- /** Mask for the method {@link #setName}. */
- public static final long SET_NAME = GET_NAME << 1;
- /** Mask for the method {@link #getShortDescription}. */
- public static final long GET_SHORT_DESCRIPTION = SET_NAME << 1;
- /** Mask for the method {@link #getIcon}. */
- public static final long GET_ICON = GET_SHORT_DESCRIPTION << 1;
- /** Mask for the method {@link #getOpenedIcon}. */
- public static final long GET_OPENED_ICON = GET_ICON << 1;
- /** Mask for the method {@link #getHelpCtx}. */
- public static final long GET_HELP_CTX = GET_OPENED_ICON << 1;
- /** Mask for the method {@link #getChildObjects}. */
- public static final long GET_CHILD_OBJECTS = GET_HELP_CTX << 1;
- /** Mask for the method {@link #getNewTypes}. */
- public static final long GET_NEW_TYPES = GET_CHILD_OBJECTS << 1;
- /** Mask for the method {@link #getActions}. */
- public static final long GET_ACTIONS = GET_NEW_TYPES << 1;
- /** Mask for the method {@link #getContextActions}. */
- public static final long GET_CONTEXT_ACTIONS = GET_ACTIONS << 1;
- /** Mask for the method {@link #getDefaultAction}. */
- public static final long GET_DEFAULT_ACTION = GET_CONTEXT_ACTIONS << 1;
- /** Mask for the method {@link #getPropertySets}. */
- public static final long GET_PROPERTY_SETS = GET_DEFAULT_ACTION << 1;
- /** Mask for the method {@link #getCustomizer}. */
- public static final long GET_CUSTOMIZER = GET_PROPERTY_SETS << 1;
- /** Mask for the method {@link #canRename}. */
- public static final long CAN_RENAME = GET_CUSTOMIZER << 1;
- /** Mask for the method {@link #canDestroy}. */
- public static final long CAN_DESTROY = CAN_RENAME << 1;
- /** Mask for the method {@link #canCopy}. */
- public static final long CAN_COPY = CAN_DESTROY << 1;
- /** Mask for the method {@link #canCut}. */
- public static final long CAN_CUT = CAN_COPY << 1;
- /** Mask for the method {@link #getPasteTypes}. */
- public static final long GET_PASTE_TYPES = CAN_CUT << 1;
- /** Mask for the method {@link #getDropType}. */
- public static final long GET_DROP_TYPE = GET_PASTE_TYPES << 1;
- /** Mask for the method {@link #clipboardCopy}. */
- public static final long CLIPBOARD_COPY = GET_DROP_TYPE << 1;
- /** Mask for the method {@link #clipboardCut}. */
- public static final long CLIPBOARD_CUT = CLIPBOARD_COPY << 1;
- /** Mask for the method {@link #drag}. */
- public static final long DRAG = CLIPBOARD_CUT << 1;
- /** Mask for the method {@link #destroy}. */
- public static final long DESTROY = DRAG << 1;
- /** Mask for the method {@link #hasCustomizer}. */
- public static final long HAS_CUSTOMIZER = DESTROY << 1;
-
- /** Creates new instance of look does no work.
- */
- public ProxyLook() {
- }
-
- /** A heart of this class -
- * method that can decide where to delegate approriate call.
- *
- *
- * The default implementation ignores all parameters and just returns null
- * so no action is ever done.
- * Subclasses might override
- * this method with implementation that bases its decision on different criteria.
- *
- * @param method one of the constants defined here that identifies the method
- * we want to delegate to
- * @param substitute the substitute which method will be called with
- * @return the array of looks that we want to delegate to (may contain nulls on
- * places of looks we do not want to delegate to) or null if no delegation needed
- *
- * @warning the caller should maintain the delegates' positions in the returned
- * array and rather pass a null at some position, if the Look should not be delegated to,
- * instead of compacting of the array. The ProxyLook takes performance advantage from the
- * fact, that delegate positions are mostly the same.
- */
- protected Look[] delegateTo (long method, NodeSubstitute substitute) {
- return null;
- }
-
- /** Controls whether we delegate to all looks provided by delegateTo
- * method or just the first one that returns a value. Useful for methods that
- * return an array of objects.
- *
- *
- * The default implementation return true to signal that we delegate to all.
- *
- * @param method one of the constants defined here that identifies the method
- * we want to delegate to
- * @param substitute the substitute which method will be called with
- * @return true of false
- */
- protected boolean delegateAll (long method, NodeSubstitute substitute) {
- return true;
- }
-
- /** Extracts represented object for provided substitute.
- *
- * Default implementation just calls substitute.getRepresentedObject (), but
- * subclasses might use this method to change the represented object
- * for the look they delegate to.
- *
- * @param substitute the substitute to find represented object for
- * @return the represented object for the substitute (not null)
- */
- protected Object delegateObject (NodeSubstitute substitute) {
- return substitute.getRepresentedObject ();
- }
-
- // General methods ---------------------------------------------------------
-
- /** Performs specialized setup for the ProxyLook. Subclasses may receive
- * attach notification when they override {@link #proxyAttachTo} instead of
- * this method.
- * @return opaque data needed by the ProxyLook implementation.
- */
- protected final Object attachTo(Look.NodeSubstitute substitute) {
- // Cannot be overriden because it performs important action of
- // creating substitute S, without it the look we delegate to will
- // not work correctly
- Object o = super.attachTo(substitute);
- return new Object[] {
- new Object[0], o
- };
- }
-
- /**
- * Retrieves the data attached to the particular NodeSubstitute for the
- * ProxyLook itself.
- * @return the attached data Object, or null if no data was attached.
- */
- protected final Object getAttachedData(Look.NodeSubstitute subst) {
- Object o = super.getAttachedData(subst);
- if (!(o instanceof Object[])) {
- return null;
- }
-
- Object[] a = (Object[])o;
- if (a.length > 1) {
- return a[1];
- } else
- return null;
- }
-
- /** Delegates to delegate or does neutral behaviour (doing nothing, returning null)
- */
- public Lookup createLookup (Look.NodeSubstitute substitute) {
- Look[] delegate = delegateTo (CREATE_LOOKUP, substitute);
- if (delegate != null && delegate.length > 0) {
- if (delegate.length == 1) {
- return delegate[0] == null ? null : delegate[0].createLookup (s (substitute, delegate[0], 0));
- } else {
- ArrayList ll = new ArrayList (delegate.length);
- for (int i = 0; i < delegate.length; i++) {
- Lookup lookup = delegate[i] == null ? null : delegate[i].createLookup (s (substitute, delegate[i], i));
- if (lookup != null) {
- ll.add (lookup);
- }
- }
-
- if (ll.size () > 0) {
- Lookup[] arr = new Lookup[ll.size ()];
- ll.toArray (arr);
- return new ProxyLookup (arr);
- } else {
- return null;
- }
- }
- } else {
- return null;
- }
- }
-
- /** Delegates to delegate or does neutral behaviour (doing nothing, returning null)
- */
- public Look[] availableLooks(Look.NodeSubstitute substitute) {
- return null;
- }
-
- // Methods for STYLE -------------------------------------------------------
-
- /** Delegates to delegate or does neutral behaviour (doing nothing, returning null)
- */
- public String getDisplayName( Look.NodeSubstitute substitute ) {
- Look[] delegate = delegateTo (GET_DISPLAY_NAME, substitute);
- if (delegate != null) {
- for (int i = 0; i < delegate.length; i++) {
- if (delegate[i] != null) {
- String h = delegate[i].getDisplayName (s (substitute, delegate[i], i));
- if (h != null) {
- return h;
- }
- }
- }
- }
- return null;
- }
-
- /** Delegates to delegate or does neutral behaviour (doing nothing, returning null)
- */
- public String getName( Look.NodeSubstitute substitute ) {
- Look[] delegate = delegateTo (GET_NAME, substitute);
- if (delegate != null) {
- for (int i = 0; i < delegate.length; i++) {
- if (delegate[i] != null) {
- String h = delegate[i].getName (s (substitute, delegate[i], i));
- if (h != null) {
- return h;
- }
- }
- }
- }
- return null;
- }
-
- /** Delegates to delegate or does neutral behaviour (doing nothing, returning null)
- */
- public void setName(Look.NodeSubstitute substitute, String newName) {
- Look[] delegate = delegateTo (SET_NAME, substitute);
- if (delegate != null) {
- for (int i = 0; i < delegate.length; i++) {
- if (delegate[i] != null) {
- delegate[i].setName (s (substitute, delegate[i], i), newName);
- }
- }
- }
- }
-
- /** Delegates to delegate or does neutral behaviour (doing nothing, returning null)
- */
- public String getShortDescription ( Look.NodeSubstitute substitute ) {
- Look[] delegate = delegateTo (GET_SHORT_DESCRIPTION, substitute);
- if (delegate != null) {
- for (int i = 0; i < delegate.length; i++) {
- if (delegate[i] != null) {
- String h = delegate[i].getShortDescription (s (substitute, delegate[i], i));
- if (h != null) {
- return h;
- }
- }
- }
- }
- return null;
- }
-
- /** Delegates to delegate or does neutral behaviour (doing nothing, returning null)
- */
- public Image getIcon( Look.NodeSubstitute substitute, int type ) {
- Look[] delegate = delegateTo (GET_ICON, substitute);
- if (delegate != null) {
- for (int i = 0; i < delegate.length; i++) {
- if (delegate[i] != null) {
- Image h = delegate[i].getIcon (s (substitute, delegate[i], i), type);
- if (h != null) {
- return h;
- }
- }
- }
- }
- return null;
- }
-
- /** Delegates to delegate or does neutral behaviour (doing nothing, returning null)
- */
- public Image getOpenedIcon( Look.NodeSubstitute substitute, int type ) {
- Look[] delegate = delegateTo (GET_OPENED_ICON, substitute);
- if (delegate != null) {
- for (int i = 0; i < delegate.length; i++) {
- if (delegate[i] != null) {
- Image h = delegate[i].getOpenedIcon (s (substitute, delegate[i], i), type);
- if (h != null) {
- return h;
- }
- }
- }
- }
- return null;
- }
-
- /** Delegates to delegate or does neutral behaviour (doing nothing, returning null)
- */
- public HelpCtx getHelpCtx( Look.NodeSubstitute substitute ) {
- Look[] delegate = delegateTo (GET_HELP_CTX, substitute);
- if (delegate != null) {
- for (int i = 0; i < delegate.length; i++) {
- if (delegate[i] != null) {
- HelpCtx h = delegate[i].getHelpCtx (s (substitute, delegate[i], i));
- if (h != null) {
- return h;
- }
- }
- }
- }
- return null;
- }
-
- // Methods for CHILDREN ----------------------------------------------------
-
- /** Delegates to delegate or does neutral behaviour (doing nothing, returning null)
- */
- public Object[] getChildObjects( Look.NodeSubstitute substitute ) {
- Look[] delegate = delegateTo (GET_CHILD_OBJECTS, substitute);
-
- if (delegate == null) {
- return null;
- }
-
- boolean merge = delegateAll (GET_CHILD_OBJECTS, substitute);
-
- Object arrays = null;
-
- // Create list of subarrays
- for (int i = 0; i < delegate.length; i++) {
- Look look = delegate[i];
- if (look == null) {
- continue;
- }
-
- Object data[] = look.getChildObjects (s (substitute, delegate[i], i));
- if (data == null || data.length == 0 ) {
- continue;
- }
-
- if (!merge) {
- // we are not merging and need keys just by one look
- return data;
- }
-
- // add all those objects into array
- if (arrays == null) {
- arrays = data;
- } else {
- ArrayList l;
- if (arrays instanceof Object[]) {
- // arrays contains Object[] convert to ArrayList
- Object[] arr = (Object[])arrays;
- l = new ArrayList (arr.length * 2);
- l.addAll (Arrays.asList (arr));
- arrays = l;
- } else {
- l = (ArrayList)arrays;
- }
- l.addAll (Arrays.asList (data));
- }
- }
-
- if (arrays == null) {
- // Return if there is nothing to merge
- return null;
- }
-
- return arrays instanceof Object[] ? (Object[])arrays : ((ArrayList)arrays).toArray ();
- }
-
- // Methods for ACTIONS & NEW TYPES -----------------------------------------
-
- /** Delegates to delegate or does neutral behaviour (doing nothing, returning null)
- */
- public NewType[] getNewTypes( Look.NodeSubstitute substitute ) {
- Look[] delegate = delegateTo (GET_NEW_TYPES, substitute);
-
- if (delegate == null) {
- return null;
- }
-
- boolean merge = delegateAll (GET_NEW_TYPES, substitute);
-
- Object arrays = null;
-
- // Create list of subarrays
- for (int i = 0; i < delegate.length; i++) {
- Look look = delegate[i];
- if (look == null) {
- continue;
- }
-
- NewType[] data = look.getNewTypes (s (substitute, delegate[i], i));
- if (data == null || data.length == 0 ) {
- continue;
- }
-
- if (!merge) {
- // we are not merging and need keys just by one look
- return data;
- }
-
- // add all those objects into array
- if (arrays == null) {
- arrays = data;
- } else {
- ArrayList l;
- if (arrays instanceof Object[]) {
- // arrays contains Object[] convert to ArrayList
- Object[] arr = (Object[])arrays;
- l = new ArrayList (arr.length * 2);
- l.addAll (Arrays.asList (arr));
- arrays = l;
- } else {
- l = (ArrayList)arrays;
- }
- l.addAll (Arrays.asList (data));
- }
- }
-
- if (arrays == null) {
- // Return if there is nothing to merge
- return null;
- }
-
- return arrays instanceof NewType[] ? (NewType[])arrays : (NewType[])((ArrayList)arrays).toArray (new NewType[0]);
- }
-
- /** Delegates to delegate or does neutral behaviour (doing nothing, returning null)
- */
- public Action[] getActions( Look.NodeSubstitute substitute ) {
- Look[] delegate = delegateTo (GET_ACTIONS, substitute);
-
- if (delegate == null) {
- return null;
- }
-
- boolean merge = delegateAll (GET_ACTIONS, substitute);
-
- Object arrays = null;
-
- // Create list of subarrays
- for (int i = 0; i < delegate.length; i++) {
- Look look = delegate[i];
- if (look == null) {
- continue;
- }
-
- Action[] data = look.getActions (s (substitute, delegate[i], i));
- if (data == null || data.length == 0 ) {
- continue;
- }
-
- if (!merge) {
- // we are not merging and need keys just by one look
- return data;
- }
-
- // add all those objects into array
- if (arrays == null) {
- arrays = data;
- } else {
- ArrayList l;
- if (arrays instanceof Object[]) {
- // arrays contains Object[] convert to ArrayList
- Object[] arr = (Object[])arrays;
- l = new ArrayList (arr.length * 2);
- l.addAll (Arrays.asList (arr));
- arrays = l;
- } else {
- l = (ArrayList)arrays;
- }
- l.addAll (Arrays.asList (data));
- }
- }
-
- if (arrays == null) {
- // Return if there is nothing to merge
- return null;
- }
-
- return arrays instanceof Action[] ? (Action[])arrays : (Action[])((ArrayList)arrays).toArray (new Action[0]);
- }
-
- /** Delegates to delegate or does neutral behaviour (doing nothing, returning null)
- */
- public Action[] getContextActions( Look.NodeSubstitute substitute ) {
- Look[] delegate = delegateTo (GET_CONTEXT_ACTIONS, substitute);
-
- if (delegate == null) {
- return null;
- }
-
- boolean merge = delegateAll (GET_CONTEXT_ACTIONS, substitute);
-
- Object arrays = null;
-
- // Create list of subarrays
- for (int i = 0; i < delegate.length; i++) {
- Look look = delegate[i];
- if (look == null) {
- continue;
- }
-
- Action[] data = look.getContextActions (s (substitute, delegate[i], i));
- if (data == null || data.length == 0 ) {
- continue;
- }
-
- if (!merge) {
- // we are not merging and need keys just by one look
- return data;
- }
-
- // add all those objects into array
- if (arrays == null) {
- arrays = data;
- } else {
- ArrayList l;
- if (arrays instanceof Object[]) {
- // arrays contains Object[] convert to ArrayList
- Object[] arr = (Object[])arrays;
- l = new ArrayList (arr.length * 2);
- l.addAll (Arrays.asList (arr));
- arrays = l;
- } else {
- l = (ArrayList)arrays;
- }
- l.addAll (Arrays.asList (data));
- }
- }
-
- if (arrays == null) {
- // Return if there is nothing to merge
- return null;
- }
-
- return arrays instanceof Action[] ? (Action[])arrays : (Action[])((ArrayList)arrays).toArray (new Action[0]);
- }
-
- /** Delegates to delegate or does neutral behaviour (doing nothing, returning null)
- */
- public Action getDefaultAction( Look.NodeSubstitute substitute ) {
- Look[] delegate = delegateTo (GET_DEFAULT_ACTION, substitute);
- if (delegate != null) {
- for (int i = 0; i < delegate.length; i++) {
- if (delegate[i] != null) {
- Action h = delegate[i].getDefaultAction (s (substitute, delegate[i], i));
- if (h != null) {
- return h;
- }
- }
- }
- }
- return null;
- }
-
- // Methods for PROPERTIES AND CUSTOMIZER -----------------------------------
-
- /** Delegates to delegate or does neutral behaviour (doing nothing, returning null)
- */
- public Node.PropertySet[] getPropertySets( Look.NodeSubstitute substitute ) {
- Look[] delegate = delegateTo (GET_PROPERTY_SETS, substitute);
- if (delegate == null) {
- return null;
- }
-
- boolean merge = delegateAll (GET_PROPERTY_SETS, substitute);
-
- ArrayList setsList = null;
- HashMap nameMap = null;
-
- // Create list of property sets and the name map
- for (int index = 0; index < delegate.length; index++) {
- Look look = delegate[index];
- if (look == null) {
- continue;
- }
-
- Node.PropertySet[] sets = look.getPropertySets( s (substitute, delegate[index], index) );
- if ( sets == null || sets.length == 0 ) {
- continue; // Look does not provide any properties
- }
-
- if (!merge) {
- // no need to do merging, return the first reasonable value
- return sets;
- }
-
- if (setsList == null) {
- if (index + 1 == delegate.length) {
- // I am the last look in the raw, no need to do merging
- return sets;
- }
- setsList = new ArrayList ();
- nameMap = new HashMap (37);
- }
-
-
- // Merge the property sets. We use sheet sets for
- // more comfortable work with propertySets
- for ( int i = 0; i < sets.length; i++ ) {
- if ( sets[i].getName() == null ) {
- continue; // Ignore unnamed lists
- }
- Sheet.Set es = (Sheet.Set)nameMap.get( sets[i].getName() );
- if ( es == null ) { //Such sheet does not exist yet
- es = new Sheet.Set( );
- es.setName( sets[i].getName() );
- es.setDisplayName( sets[i].getDisplayName() );
- es.setShortDescription( sets[i].getShortDescription() );
- es.put( sets[i].getProperties() );
- setsList.add( es );
- nameMap.put( sets[i].getName(), es );
- }
- else { // Sheet exists => merge properties
- Node.Property[] props = sets[i].getProperties();
- if ( props == null || props.length == 0 ) {
- continue;
- }
- else {
- es.put( sets[i].getProperties() );
- }
- }
- }
- }
-
- if ( setsList == null || setsList.size() == 0 ) {
- return null;
- }
- else {
- Node.PropertySet[] result = new Node.PropertySet[ setsList.size() ];
- setsList.toArray( result );
- return result;
- }
- }
-
- /** Delegates to delegate or does neutral behaviour (doing nothing, returning null)
- */
- public java.awt.Component getCustomizer( Look.NodeSubstitute substitute ) {
- Look[] delegate = delegateTo (GET_CUSTOMIZER, substitute);
- if (delegate != null) {
- for (int i = 0; i < delegate.length; i++) {
- if (delegate[i] != null) {
- java.awt.Component h = delegate[i].getCustomizer (s (substitute, delegate[i], i));
- if (h != null) {
- return h;
- }
- }
- }
- }
- return null;
- }
-
- /** Delegates to delegate or does neutral behaviour (doing nothing, returning null)
- */
- public boolean hasCustomizer( Look.NodeSubstitute substitute ) {
- Look[] delegate = delegateTo (HAS_CUSTOMIZER, substitute);
- if (delegate != null) {
- for (int i = 0; i < delegate.length; i++) {
- if (delegate[i] != null) {
- if (delegate[i].hasCustomizer (s (substitute, delegate[i], i))) {
- return true;
- }
- }
- }
- }
- return false;
- }
- // Methods for CLIPBOARD OPERATIONS ----------------------------------------
-
- /** Delegates to delegate or does neutral behaviour (doing nothing, returning false)
- */
- public boolean canRename( Look.NodeSubstitute substitute ) {
- Look[] delegate = delegateTo (CAN_RENAME, substitute);
- if (delegate != null) {
- for (int i = 0; i < delegate.length; i++) {
- if (delegate[i] != null) {
- boolean b = delegate[i].canRename (s (substitute, delegate[i], i));
- if (b) {
- return true;
- }
- }
- }
- }
- return false;
- }
-
- /** Delegates to delegate or does neutral behaviour (doing nothing, returning false)
- */
- public boolean canDestroy( Look.NodeSubstitute substitute ) {
- Look[] delegate = delegateTo (CAN_DESTROY, substitute);
- if (delegate != null) {
- for (int i = 0; i < delegate.length; i++) {
- if (delegate[i] != null) {
- boolean b = delegate[i].canDestroy (s (substitute, delegate[i], i));
- if (b) {
- return true;
- }
- }
- }
- }
- return false;
- }
-
- /** Delegates to delegate or does neutral behaviour (doing nothing, returning false)
- */
- public boolean canCopy( Look.NodeSubstitute substitute ) {
- Look[] delegate = delegateTo (CAN_COPY, substitute);
- if (delegate != null) {
- for (int i = 0; i < delegate.length; i++) {
- if (delegate[i] != null) {
- boolean b = delegate[i].canCopy (s (substitute, delegate[i], i));
- if (b) {
- return true;
- }
- }
- }
- }
- return false;
- }
-
- /** Delegates to delegate or does neutral behaviour (doing nothing, returning false)
- */
- public boolean canCut( Look.NodeSubstitute substitute ) {
- Look[] delegate = delegateTo (CAN_CUT, substitute);
- if (delegate != null) {
- for (int i = 0; i < delegate.length; i++) {
- if (delegate[i] != null) {
- boolean b = delegate[i].canCut (s (substitute, delegate[i], i));
- if (b) {
- return true;
- }
- }
- }
- }
- return false;
- }
-
- /** Delegates to delegate or does neutral behaviour (doing nothing, returning null)
- */
- public PasteType[] getPasteTypes( Look.NodeSubstitute substitute, Transferable t) {
- Look[] delegate = delegateTo (GET_PASTE_TYPES, substitute);
-
- if (delegate == null) {
- return null;
- }
-
- boolean merge = delegateAll (GET_PASTE_TYPES, substitute);
-
- Object arrays = null;
-
- // Create list of subarrays
- for (int i = 0; i < delegate.length; i++) {
- Look look = delegate[i];
- if (look == null) {
- continue;
- }
-
- PasteType[] data = look.getPasteTypes (s (substitute, delegate[i], i), t);
- if (data == null || data.length == 0 ) {
- continue;
- }
-
- if (!merge) {
- // we are not merging and need keys just by one look
- return data;
- }
-
- // add all those objects into array
- if (arrays == null) {
- arrays = data;
- } else {
- ArrayList l;
- if (arrays instanceof Object[]) {
- // arrays contains Object[] convert to ArrayList
- Object[] arr = (Object[])arrays;
- l = new ArrayList (arr.length * 2);
- l.addAll (Arrays.asList (arr));
- arrays = l;
- } else {
- l = (ArrayList)arrays;
- }
- l.addAll (Arrays.asList (data));
- }
- }
-
- if (arrays == null) {
- // Return if there is nothing to merge
- return null;
- }
-
- return arrays instanceof PasteType[] ? (PasteType[])arrays : (PasteType[])((ArrayList)arrays).toArray (new PasteType[0]);
- }
-
- /** Delegates to delegate or does neutral behaviour (doing nothing, returning null)
- */
- public PasteType getDropType( Look.NodeSubstitute substitute, Transferable t, int action, int index) {
- Look[] delegate = delegateTo (GET_DROP_TYPE, substitute);
- if (delegate != null) {
- for (int i = 0; i < delegate.length; i++) {
- if (delegate[i] != null) {
- PasteType b = delegate[i].getDropType (s (substitute, delegate[i], i), t, action, index);
- if (b != null) {
- return b;
- }
- }
- }
- }
- return null;
- }
-
- /** Delegates to delegate or does neutral behaviour (doing nothing, returning null)
- */
- public Transferable clipboardCopy( Look.NodeSubstitute substitute ) throws IOException {
- Look[] delegate = delegateTo (CLIPBOARD_COPY, substitute);
- if (delegate != null) {
- for (int i = 0; i < delegate.length; i++) {
- if (delegate[i] != null) {
- Transferable b = delegate[i].clipboardCopy (s (substitute, delegate[i], i));
- if (b != null) {
- return b;
- }
- }
- }
- }
- return null;
- }
-
- /** Delegates to delegate or does neutral behaviour (doing nothing, returning null)
- */
- public Transferable clipboardCut( Look.NodeSubstitute substitute ) throws IOException {
- Look[] delegate = delegateTo (CLIPBOARD_CUT, substitute);
- if (delegate != null) {
- for (int i = 0; i < delegate.length; i++) {
- if (delegate[i] != null) {
- Transferable b = delegate[i].clipboardCut (s (substitute, delegate[i], i));
- if (b != null) {
- return b;
- }
- }
- }
- }
- return null;
- }
-
- /** Delegates to delegate or does neutral behaviour (doing nothing, returning null)
- */
- public Transferable drag( Look.NodeSubstitute substitute ) throws IOException {
- Look[] delegate = delegateTo (DRAG, substitute);
- if (delegate != null) {
- for (int i = 0; i < delegate.length; i++) {
- if (delegate[i] != null) {
- Transferable b = delegate[i].drag (s (substitute, delegate[i], i));
- if (b != null) {
- return b;
- }
- }
- }
- }
- return null;
- }
-
- /** Delegates to delegate or does neutral behaviour (doing nothing, returning null)
- */
- public void destroy(Look.NodeSubstitute substitute) throws IOException {
- Look[] delegate = delegateTo (DESTROY, substitute);
- if (delegate != null) {
- for (int i = 0; i < delegate.length; i++) {
- if (delegate[i] != null) {
- delegate[i].destroy (s (substitute, delegate[i], i));
- }
- }
- }
- }
-
- /** Method that tries to get the right substitute S from given substitute.
- */
- private Look.NodeSubstitute s (Look.NodeSubstitute subst, Look l, int index) {
- Object[] holder = (Object[])ProxyLook.super.getAttachedData(subst);
- synchronized (holder) {
- Object[] arr = (Object[])holder[0];
- if (index < arr.length) {
- Look.NodeSubstitute ns = (Look.NodeSubstitute)arr[index];
- if (ns != null && ns.getLook() == l ) {
- // we already have seen/initialized this Look.
- return ns;
- }
- } else {
- Object[] newSubst = new Object[index + 1];
- System.arraycopy(arr, 0, newSubst, 0, arr.length);
- holder[0] = arr = newSubst;
- }
- S s = new S (l, subst);
- arr[index] = s;
- return s;
- }
- }
-
- // Innerclasses ------------------------------------------------------------
-
- /** Our special substitute to filter events fired from the underlaying look
- * and also to store its special attached data.
- */
- final class S extends Look.NodeSubstitute {
- /** substitute we represent it will contain reference to us in getAttachedData */
- private Look.NodeSubstitute substitute;
-
- S (Look look, Look.NodeSubstitute substitute) {
- this.substitute = substitute;
-
- super.attachTo (look);
- }
-
- /** Returns the object represented by the node
- * @return Object represented by the node this interior belongs to.
- */
- public Object getRepresentedObject() {
- return delegateObject (substitute);
- }
-
- /** Fires a (Bean) property change event (for
- * {@link org.openide.node.Node#PROP_PROPERTY_SETS}).
- * @param o the old set
- * @param n the new set
- */
- public void firePropertySetsChange(Node.PropertySet[] o, Node.PropertySet[] n) {
- Look[] delegate = delegateTo (GET_PROPERTY_SETS, this) ;
- if (doFire (delegate)) {
- substitute.firePropertySetsChange( o, n );
- }
- }
-
- /** Fires the Event notificationg about name change.
- */
- public void fireNameChange(String o, String n) {
- Look[] delegate = delegateTo (GET_NAME, this) ;
- if (doFire (delegate)) {
- substitute.fireNameChange( o, n );
- }
- }
-
- /** Fires the Event notificationg about display name change.
- */
- public void fireDisplayNameChange(String o, String n) {
- Look[] delegate = delegateTo (GET_DISPLAY_NAME, this) ;
- if (doFire (delegate)) {
- substitute.fireDisplayNameChange( o, n );
- }
- }
-
- /** Tells the node that the children have to be refreshed.
- */
- public void refreshChildren() {
- Look[] delegate = delegateTo (GET_CHILD_OBJECTS, this) ;
- if (doFire (delegate)) {
- substitute.refreshChildren( );
- }
- }
-
- /** Fire a change event for {@link org.openide.nodes.Node#PROP_OPENED_ICON} on
- * associated node.
- */
- public void fireOpenedIconChange() {
- Look[] delegate = delegateTo (GET_OPENED_ICON, this) ;
- if (doFire (delegate)) {
- substitute.fireOpenedIconChange();
- }
- }
-
- /** To all node listeners fire node destroyed notification.
- */
- public void fireNodeDestroyed() {
- Look[] delegate = delegateTo (DESTROY, this) ;
- if (doFire (delegate)) {
- substitute.fireNodeDestroyed();
- }
- }
-
- /** Fire a change event for {@link org.openide.nodes.Node#PROP_ICON} on
- * associated node.
- */
- public void fireIconChange() {
- Look[] delegate = delegateTo (GET_ICON, this) ;
- if (doFire (delegate)) {
- substitute.fireIconChange();
- }
- }
-
- /** Fires the Event notificationg about short description change.
- */
- public void fireShortDescriptionChange(String o, String n) {
- Look[] delegate = delegateTo (GET_SHORT_DESCRIPTION, this) ;
- if (doFire (delegate)) {
- substitute.fireShortDescriptionChange( o, n );
- }
- }
-
- /** Fire a property change event on the associated node.
- * @param name name of changed property (from {@link #getPropertySets})
- * @param o old value
- * @param n new value
- */
- public void firePropertyChange(String name, Object o, Object n) {
- Look[] delegate = delegateTo (GET_PROPERTY_SETS, this) ;
- if (doFire (delegate)) {
- substitute.firePropertyChange( name, o, n );
- }
- }
-
- /** Do fire.
- */
- private boolean doFire (Look[] arr) {
- if (arr == null) return false;
-
- for (int i = 0; i < arr.length; i++) {
- if (arr[i] != null) return true;
- }
- return false;
- }
-
- } // end of S
-
-
-}
Index: openidex/looks/test/.cvsignore
===================================================================
RCS file: openidex/looks/test/.cvsignore
diff -N openidex/looks/test/.cvsignore
--- openidex/looks/test/.cvsignore 5 Feb 2002 17:46:16 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,4 +0,0 @@
-CVS
-lib
-results
-work
Index: openidex/looks/test/build.xml
===================================================================
RCS file: openidex/looks/test/build.xml
diff -N openidex/looks/test/build.xml
--- openidex/looks/test/build.xml 22 Feb 2002 13:03:55 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,249 +0,0 @@
-
-
-
-
- * Notice: There is no extra Javadoc for the methods now. All behave as
- * described
- *
- * @author Petr Hrebejk
- */
-public abstract class AcceptorLook extends FilterLook {
-
-
- /** Creates new Acceptor
- * @param delegate The Look to delegate to when the node was accepted.
- */
- public AcceptorLook(Look delegate) {
- super( delegate );
- }
-
- /** Override this method for enabling the Look for some
- * type of nodes.
- *
- * @node Node which is asking
- * @return True if Node should be accepted false otherwise.
- */
- protected abstract boolean accept( Look.NodeSubstitute substitute );
-
- // Methods of look itself --------------------------------------------------
-
- public boolean isLookStandalone( Object representedObject ) {
- return delegate.isLookStandalone( representedObject );
- }
-
- // General methods ---------------------------------------------------------
-
- public void attachTo( Look.NodeSubstitute substitute ) {
- if ( accept( substitute ) ) {
- super.attachTo( substitute );
- }
- }
-
- public Node.Cookie getCookie( Look.NodeSubstitute substitute, Class type) {
- if ( accept( substitute ) ) {
- return super.getCookie( substitute, type );
- }
- else {
- return DefaultLook.INSTANCE.getCookie( substitute, type );
- }
- }
-
- public Node.Handle getHandle( Look.NodeSubstitute substitute ) {
- if ( accept( substitute ) ) {
- return super.getHandle( substitute );
- }
- else {
- return DefaultLook.INSTANCE.getHandle( substitute );
- }
- }
-
- // Methods for STYLE -------------------------------------------------------
-
- public String getDisplayName( Look.NodeSubstitute substitute ) {
- if ( accept( substitute ) ) {
- return super.getDisplayName( substitute );
- }
- else {
- return DefaultLook.INSTANCE.getDisplayName( substitute );
- }
- }
-
- public String getName( Look.NodeSubstitute substitute ) {
- if ( accept( substitute ) ) {
- return super.getName( substitute );
- }
- else {
- return DefaultLook.INSTANCE.getName( substitute );
- }
- }
-
- public void setName( Look.NodeSubstitute substitute, String newName ) {
- if ( accept( substitute ) ) {
- super.setName( substitute, newName );
- }
- else {
- DefaultLook.INSTANCE.setName( substitute, newName );
- }
- }
-
- public String getShortDescription ( Look.NodeSubstitute substitute ) {
- if ( accept( substitute ) ) {
- return super.getShortDescription( substitute );
- }
- else {
- return DefaultLook.INSTANCE.getShortDescription( substitute );
- }
- }
-
- public Image getIcon( Look.NodeSubstitute substitute, int type ) {
- if ( accept( substitute ) ) {
- return super.getIcon( substitute, type );
- }
- else {
- return DefaultLook.INSTANCE.getIcon( substitute, type );
- }
- }
-
- public Image getOpenedIcon( Look.NodeSubstitute substitute, int type ) {
- if ( accept( substitute ) ) {
- return super.getOpenedIcon( substitute, type );
- }
- else {
- return DefaultLook.INSTANCE.getOpenedIcon( substitute, type );
- }
- }
-
- public HelpCtx getHelpCtx( Look.NodeSubstitute substitute ) {
- if ( accept( substitute ) ) {
- return super.getHelpCtx( substitute );
- }
- else {
- return DefaultLook.INSTANCE.getHelpCtx( substitute );
- }
- }
-
- // Methods for CHILDREN ----------------------------------------------------
-
- public Object[] getChildObjects( Look.NodeSubstitute substitute ) {
- if ( accept( substitute ) ) {
- return super.getChildObjects( substitute );
- }
- else {
- return DefaultLook.INSTANCE.getChildObjects( substitute );
- }
- }
-
- // Methods for ACTIONS & NEW TYPES -----------------------------------------
-
- public NewType[] getNewTypes( Look.NodeSubstitute substitute ) {
- if ( accept( substitute ) ) {
- return super.getNewTypes( substitute );
- }
- else {
- return DefaultLook.INSTANCE.getNewTypes( substitute );
- }
- }
-
- public SystemAction[] getActions( Look.NodeSubstitute substitute ) {
- if ( accept( substitute ) ) {
- return super.getActions( substitute );
- }
- else {
- return DefaultLook.INSTANCE.getActions( substitute );
- }
- }
-
- public SystemAction[] getContextActions( Look.NodeSubstitute substitute ) {
- if ( accept( substitute ) ) {
- return super.getContextActions( substitute );
- }
- else {
- return DefaultLook.INSTANCE.getContextActions( substitute );
- }
- }
-
- public SystemAction getDefaultAction( Look.NodeSubstitute substitute ) {
- if ( accept( substitute ) ) {
- return super.getDefaultAction( substitute );
- }
- else {
- return DefaultLook.INSTANCE.getDefaultAction( substitute );
- }
- }
-
- // Methods for PROPERTIES AND CUSTOMIZER -----------------------------------
-
- public Node.PropertySet[] getPropertySets( Look.NodeSubstitute substitute ) {
- if ( accept( substitute ) ) {
- return super.getPropertySets( substitute );
- }
- else {
- return DefaultLook.INSTANCE.getPropertySets( substitute );
- }
- }
-
- public java.awt.Component getCustomizer( Look.NodeSubstitute substitute ) {
- if ( accept( substitute ) ) {
- return super.getCustomizer( substitute );
- }
- else {
- return DefaultLook.INSTANCE.getCustomizer( substitute );
- }
- }
-
- // Methods for CLIPBOARD OPERATIONS ----------------------------------------
-
- public boolean canRename( Look.NodeSubstitute substitute ) {
- if ( accept( substitute ) ) {
- return super.canRename( substitute );
- }
- else {
- return DefaultLook.INSTANCE.canRename( substitute );
- }
- }
-
- public boolean canDestroy( Look.NodeSubstitute substitute ) {
- if ( accept( substitute ) ) {
- return super.canDestroy( substitute );
- }
- else {
- return DefaultLook.INSTANCE.canDestroy( substitute );
- }
- }
-
- public boolean canCopy( Look.NodeSubstitute substitute ) {
- if ( accept( substitute ) ) {
- return super.canCopy( substitute );
- }
- else {
- return DefaultLook.INSTANCE.canCopy( substitute );
- }
- }
-
- public boolean canCut( Look.NodeSubstitute substitute ) {
- if ( accept( substitute ) ) {
- return super.canCut( substitute );
- }
- else {
- return DefaultLook.INSTANCE.canCut( substitute );
- }
- }
-
- public PasteType[] getPasteTypes( Look.NodeSubstitute substitute, Transferable t) {
- if ( accept( substitute ) ) {
- return super.getPasteTypes( substitute, t );
- }
- else {
- return DefaultLook.INSTANCE.getPasteTypes( substitute, t );
- }
- }
-
- public PasteType getDropType( Look.NodeSubstitute substitute, Transferable t, int action, int index) {
- if ( accept( substitute ) ) {
- return super.getDropType( substitute, t, action, index );
- }
- else {
- return DefaultLook.INSTANCE.getDropType( substitute, t, action, index );
- }
- }
-
- public Transferable clipboardCopy( Look.NodeSubstitute substitute ) throws IOException {
- if ( accept( substitute ) ) {
- return super.clipboardCopy( substitute );
- }
- else {
- return DefaultLook.INSTANCE.clipboardCopy( substitute );
- }
- }
-
- public Transferable clipboardCut( Look.NodeSubstitute substitute ) throws IOException {
- if ( accept( substitute ) ) {
- return super.clipboardCut( substitute );
- }
- else {
- return DefaultLook.INSTANCE.clipboardCut( substitute );
- }
- }
-
- public Transferable drag( Look.NodeSubstitute substitute ) throws IOException {
- if ( accept( substitute ) ) {
- return super.drag( substitute );
- }
- else {
- return DefaultLook.INSTANCE.drag( substitute );
- }
- }
-
- public void destroy( Look.NodeSubstitute substitute ) throws IOException {
- if ( accept( substitute ) ) {
- super.destroy( substitute );
- }
- else {
- DefaultLook.INSTANCE.destroy( substitute );
- }
- }
-
- public static abstract class Type extends AcceptorLook {
- /** Class which has to be accepted */
- private Class type;
-
- /** Should also superclasses be accepted? Default is false */
- private boolean subclasses;
-
-
- /** Creates new TypeAcceptor where subclasses are accepted.
- * @param delegate The look to delegate to.
- * @param type Class of represented object which has to be accepted.
- */
- public Type( Look delegate, Class type ) {
- this( delegate, type, true);
- }
-
- /** Creates new TypeAcceptor where user can specify whether subclasses
- * should be accepted or not.
- * @param delegate The look to delegate to.
- * @param type Class of represented object which has to be accepted.
- * @param superclasses True if also subclasses should be accepted.
- */
- public Type( Look delegate, Class type, boolean subclasses ) {
- super( delegate );
- this.type = type;
- this.subclasses = subclasses;
- }
-
- /** Accepts only if represented object is of given type.
- * @node Node about which should be decided.
- * @return True if the node represents object of given type false otherwise.
- */
- protected boolean accept( Look.NodeSubstitute substitute ) {
-
- if ( type == null ) {
- return false;
- }
-
- if ( subclasses ) {
- return type.isInstance( substitute.getRepresentedObject() );
- }
- else {
- return type == substitute.getRepresentedObject().getClass();
- }
- }
- }
-
-}
Index: openidex/src/org/openidex/nodes/looks/Bundle.properties
===================================================================
RCS file: openidex/src/org/openidex/nodes/looks/Bundle.properties
diff -N openidex/src/org/openidex/nodes/looks/Bundle.properties
--- openidex/src/org/openidex/nodes/looks/Bundle.properties 27 Aug 2001 12:20:31 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,29 +0,0 @@
-# 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-2000 Sun
-# Microsystems, Inc. All Rights Reserved.
-
-### Resource bundle for package org.openide.nodes.looks
-
-#Name of the Look property sheet.
-CTL_LookSheetSetName=Look
-
-#Name of the Look property.
-CTL_LookProperty=Look
-
-#Short description of the look property
-CTL_LookPropertyShortDescription=Sets the look on the node.
-
-#Name of the Default look.
-CTL_Default=Default
-
-
-
-#Name of the SetLook Action
-ACT_SetLook=Set Look
Index: openidex/src/org/openidex/nodes/looks/CompositeLook.java
===================================================================
RCS file: openidex/src/org/openidex/nodes/looks/CompositeLook.java
diff -N openidex/src/org/openidex/nodes/looks/CompositeLook.java
--- openidex/src/org/openidex/nodes/looks/CompositeLook.java 4 Apr 2002 13:49:02 -0000 1.4
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,871 +0,0 @@
-/*
- * 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 Forte for Java, Community Edition. The Initial
- * Developer of the Original Code is Sun Microsystems, Inc. Portions
- * Copyright 1997-2000 Sun Microsystems, Inc. All Rights Reserved.
- */
-
-package org.openidex.nodes.looks;
-
-import java.util.*;
-import java.awt.Image;
-import java.awt.datatransfer.Transferable;
-import java.io.IOException;
-
-import org.w3c.dom.NodeList;
-import org.w3c.dom.Element;
-
-import org.openide.nodes.*;
-import org.openide.loaders.XMLDataObject;
-import org.openide.util.actions.SystemAction;
-import org.openide.util.HelpCtx;
-import org.openide.util.Lookup;
-import org.openide.util.datatransfer.NewType;
-import org.openide.util.datatransfer.PasteType;
-
-/** WARNING - This API is not finished and is subject to change
- * Look which combines more looks together. The attributes of Node are divided
- * into two groups for purposes of the CompositeLook: singlevalued
- * and multivalued. If value for a singlevalued attribute is determined the
- * first look which returns a non-neutral value from the method wins and the
- * value is used on the node. For multivalued attributes the values are merged
- * the merging strategy may vary for different attributes.
- *
- * @author Petr Hrebejk
- */
-public class CompositeLook extends Look {
-
- /** Sublook element used in the XML descrition */
- public static final String TAG_SUBLOOK = "Sublook"; // NOI18N
-
- /** Attribute name for the defined sublook */
- public static final String ATTR_LOOKID = "lookid"; //NOI18N
-
- /** MergeLast element used in the XML descrition */
- public static final String TAG_MERGE_LAST = "MergeLast"; //NOI18N
-
-
-
-
- /** ArrayList of looks */
- private ArrayList looks;
-
- /** The mergeLast flag for the multivalued attributes */
- private boolean mergeLast = true;
-
- /** This array is filled on the readPropertiesFromXML call.
- * It is later transoformed into sublloks when needed
- */
- private NodeList sublooksTags;
-
- /** Creates new Composite Look.
- */
- public CompositeLook() {
- }
-
- /** Adds a sublook at given index
- * @param index The index to add the Look at.
- * @param look The look which has to be added.
- */
- public void setLook( Look[] looksArray ) {
-
- looks = new ArrayList( looksArray.length );
-
- if( looksArray != null ){
- for( int i = 0; i < looksArray.length; i++){
- looks.add( looksArray[i] );
- }
- }
- }
-
- /** Adds a sublook at the end of the list of sublooks.
- * @param look The shublook which has to be added.
- */
- public void setLook( Collection look ) {
- if( look != null )
- looks.add( look );
- }
-
- /** Removes the given sublook.
- * @param look The sublook to remove.
- */
- public void removeLook( Look[] look ) {
- looks.remove( Arrays.asList(look) );
- }
-
- /** Removes the sublook
- * @param index The index of sublook which has to be removed.
- */
- public void removeLook( Collection look ) {
- looks.remove( look );
- }
-
- /** Gets iterator of all contained sublooks.
- * @return Iterator containing all sublooks.
- */
- public Iterator iterator() {
-
- if ( looks == null ) {
-
- if ( sublooksTags != null && sublooksTags.getLength() > 0 ) {
- // Transform tags to looks
- Lookup.Template t = new Lookup.Template( Look.class );
- Lookup.Result r = Lookup.getDefault().lookup( t );
- Collection lc = r.allInstances();
-
- looks = new ArrayList( sublooksTags.getLength() );
-
- for( int i = 0; i < sublooksTags.getLength(); i++ ) {
- if ( sublooksTags.item( i ).getNodeType() != org.w3c.dom.Node.ELEMENT_NODE ) {
- continue;
- }
- Element e = (Element)sublooksTags.item( i );
- String lookName = e.getAttribute( ATTR_LOOKID );
- int nameIndex = lookName.indexOf('$');
- lookName = lookName.substring( nameIndex + 1 );
-
-
- for ( Iterator it = lc.iterator(); it.hasNext(); ) {
- Look look = (Look)it.next();
- if ( look.getName().equals( lookName ) ) {
- looks.add( look );
- break;
- }
- }
- }
- }
- else {
- return java.util.Collections.EMPTY_LIST.iterator();
- }
- }
-
- return looks.iterator();
-
- }
-
- /** Tells the look whether the multivalued properties from last sublook
- * should be merged or not. Default value is true.
- * @param merge Value for the merge to be set.
- */
- public void setMergeLast( boolean mergeLast ) {
- this.mergeLast = mergeLast;
- }
-
- /** Does the look merge the multivalued attributes from the last?
- * sublook? Default value is true.
- * @return Current value of the merge flag.
- */
- public boolean getMergeLast() {
- return mergeLast;
- }
-
- /** Reads the Look options from the XMLDataObject. If you override this
- * method you'll
- * probably want to call super.readPropertiesFromXML( xdo );
- */
- public void readPropertiesFromXML(XMLDataObject xdo) {
-
- // Read the name
- super.readPropertiesFromXML( xdo );
-
- try {
- Element de = xdo.getDocument().getDocumentElement();
-
- // Read the sublooks
- sublooksTags = de.getElementsByTagName( TAG_SUBLOOK );
-
- // Set the looks to null;
- looks = null;
-
- // Read the MergeLast tag
- NodeList ml = de.getElementsByTagName( TAG_MERGE_LAST );
-
- if ( ml.getLength() > 0 ) {
- org.w3c.dom.Node n = ml.item( ml.getLength() - 1 );
- org.w3c.dom.Node nc = n.getFirstChild();
- String value = nc.getNodeValue();
- if ( value != null && value.toLowerCase().equals( "false" ) ) { // NOI18N
- mergeLast = false;
- }
- }
-
- }
- catch ( java.io.IOException e ) {
- e.printStackTrace();
- System.out.println( e );
- // Do nothing
- }
- catch ( org.xml.sax.SAXException e ) {
- e.printStackTrace();
- System.out.println( e );
- // Do nothing
- }
- }
-
- // Methods of look itself --------------------------------------------------
-
-
- // General methods ---------------------------------------------------------
-
- /** Notifyies all sublooks about node creation.
- * @param node The node to operate on.
- */
- public void attachTo(Look.NodeSubstitute substitute) {
- for ( Iterator it = iterator(); it.hasNext(); ) {
- Look look = (Look)it.next();
- look.attachTo( substitute );
- }
- }
-
- /** Finds cookie for the node betwen the sblooks.
- * @param node The node to operate on.
- * @param type Type of the desired cookie.
- * @return First cookie returned from the sublooks.
- */
- public Node.Cookie getCookie( Look.NodeSubstitute substitute, Class type) {
- for ( Iterator it = iterator(); it.hasNext(); ) {
- Look look = (Look)it.next();
-
- Node.Cookie cookie = look.getCookie( substitute, type );
- if ( cookie != null ) {
- return cookie;
- }
- }
- return null;
- }
-
- /** Finds a handle for given node among sublooks.
- * @param node The node to operate on.
- * @return First handle found among the sublooks.
- */
- public Node.Handle getHandle( Look.NodeSubstitute substitute ) {
- for ( Iterator it = iterator(); it.hasNext(); ) {
- Look look = (Look)it.next();
-
- Node.Handle handle = look.getHandle( substitute );
- if ( handle != null ) {
- return handle;
- }
- }
- return null;
- }
-
- public String toString() {
- String result = getName() + " [ \n"; //NOI18N
-
- for ( Iterator it = iterator(); it.hasNext(); ) {
- result = result + " " + ((Look)it.next()).getName() + "\n"; //NOI18N
- }
-
- return result + "]\nMergeLast = " + mergeLast + "\n"; // NOI18N
- }
-
- // Methods for STYLE -------------------------------------------------------
-
- /** Finds the display name for given node among the sublooks.
- * @param node The node to operate on.
- * @return The first displayname found.
- */
- public String getDisplayName( Look.NodeSubstitute substitute ) {
- for ( Iterator it = iterator(); it.hasNext(); ) {
- Look look = (Look)it.next();
-
- String displayName = look.getDisplayName( substitute );
- if ( displayName != null ) {
- return displayName;
- }
- }
- return null;
- }
-
- /** Finds the programmatic name for the node among the sblooks.
- * @param node The node to operate on.
- * @return The first name found.
- */
- public String getName( Look.NodeSubstitute substitute ) {
- for ( Iterator it = iterator(); it.hasNext(); ) {
- Object o = it.next();
- Look look = (Look)o;
-
- String name = look.getName( substitute );
- if ( name != null ) {
- return name;
- }
- }
- return null;
- }
-
- /** Calls
- * Adaptor class which returns neutral values from all methods.
- *
- * This class can be either subclassed or calls may be delegated to the
- * {@link #INSTANCE}.
- *
- * @author Petr Hrebejk
- */
-public class DefaultLook extends Look {
-
- /** Default instance of
- * Utility class which allows to fire events on the LookNode according
- * to events of the represented object. This class should be used as a base
- * class for EventListener registered to represented objects.
- *
- * The LookNode interior is hold by a WeakReference so the Node can be
- * garbage collected even if the represented object still exists.
- * Helper methods allow automatic changes of Icon, Name and DisplayName
- * if some properies are changed.
- */
-public abstract class EventTranslator extends WeakReference {
-
- /** Queue with all weak references */
- private static ReferenceQueue QUEUE = new ReferenceQueue ();
- /** How often clean */
- private static int CLEANER_TIME = 25000;
- /** Clearner task */
- private static RequestProcessor.Task CLEANER_TASK = RequestProcessor.postRequest(
- new Cleaner (), CLEANER_TIME, Thread.MIN_PRIORITY
- );
-
- /** Fake instance to fire event on when the node was garbage collected. */
- private static final LookNode NULL_NODE = new LookNode( null );
-
- /** Creates new EventTranslator for given LookNode.Interior
- * @param LookNode.Interior the node to fire events on.
- */
- public EventTranslator ( Look.NodeSubstitute substitute ) {
- super( substitute, QUEUE );
- }
-
- /** This method is called when the node was garbage colledted. You shoud
- * unregister from all objects where this object was registered as a
- * listener.
- */
- protected abstract void unregister();
-
- /** Gets the substitute to fire on
- */
- protected Look.NodeSubstitute getSubstitute() {
- Look.NodeSubstitute substitute = (Look.NodeSubstitute)get();
- if ( substitute == null ) {
- unregister();
- return NULL_NODE.getSubstitute();
- }
- else {
- return substitute;
- }
- }
-
-
- // Innerclasses ------------------------------------------------------------
-
- /** Class that periodically runs cleaning of the queue.
- */
- private static final class Cleaner extends Object implements Runnable {
- public void run () {
- for (;;) {
- EventTranslator et = (EventTranslator)QUEUE.poll();
- if (et == null)
- break;
- et.unregister();
- }
-
- CLEANER_TASK.schedule (CLEANER_TIME);
- }
- }
-
-}
\ No newline at end of file
Index: openidex/src/org/openidex/nodes/looks/FilterLook.java
===================================================================
RCS file: openidex/src/org/openidex/nodes/looks/FilterLook.java
diff -N openidex/src/org/openidex/nodes/looks/FilterLook.java
--- openidex/src/org/openidex/nodes/looks/FilterLook.java 3 Dec 2002 14:12:23 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,534 +0,0 @@
-/*
- * 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 Forte for Java, Community Edition. The Initial
- * Developer of the Original Code is Sun Microsystems, Inc. Portions
- * Copyright 1997-2000 Sun Microsystems, Inc. All Rights Reserved.
- */
-
-package org.openidex.nodes.looks;
-
-import java.awt.Image;
-import java.awt.datatransfer.Transferable;
-import java.io.IOException;
-
-import org.openide.nodes.*;
-import org.openide.util.actions.SystemAction;
-import org.openide.util.HelpCtx;
-import org.openide.util.datatransfer.NewType;
-import org.openide.util.datatransfer.PasteType;
-
-/** WARNING - This API is not finished and is subject to change
- * This is base class for delegating to other looks. All methods
- * delegate to the delegate, unless they are masked.
- *
- * All the methods contain simple deleagation to the {@link Look}
- * passed as parameter into the constructor, if the mask contains flag
- * for the method.
- * Use the methods: {@link #setLookMask}, {@link #lookMask}, {@link #lookMask},
- * {@link #lookUnmask} for work with the mask.
- * Searches for a look in JNDI namespace given name of context to search in
- * and a a possible set of names that should be checked.
- *
- * @author Jaroslav Tulach
- */
-final class JndiLook extends Object {
- private static Object context;
-
- /** Finds look for a class.
- * @param c clazz to search for
- * @return look found or null
- */
- public static Look findLook (Class c) {
- if (context == null) {
- try {
- context = new InitialContext ().lookup ("Looks/Types"); // NOI18N
- } catch (NamingException ex) {
- context = ex;
- }
- }
-
- if (context instanceof Context) {
- return findLook ((Context)context, forClass (c));
- } else {
- return null;
- }
- }
-
- /** Searches for a look in given namespace and in the order specified by
- * given names.
- *
- * @param namespace the root context to search from
- * @param names list of Strings to check their names (c1/c2/name)
- * @return the look or null
- */
- private static Look findLook (Context namespace, Enumeration names) {
- while (names.hasMoreElements ()) {
- try {
- String check = (String)names.nextElement ();
- NamingEnumeration en = namespace.listBindings (check);
- while (en.hasMoreElements ()) {
- Binding b = (Binding)en.next ();
- Object o = b.getObject ();
- if (o instanceof Look) {
- return (Look)o;
- }
- }
- } catch (NamingException ex) {
- }
- }
- return null;
- }
-
- /** Enumeration for a java class.
- * @param c class
- * @return enumeration of names of implemented/extended classes in form suitable
- * for findLook
- */
- private static Enumeration forClass (Class c) {
- QueueEnumeration en = new QueueEnumeration () {
- protected void process (Object o) {
- Class x = (Class)o;
- Class s = x.getSuperclass();
- if (s != null) {
- // if not object process all interfaces and super classes
- put (s);
- put (x.getInterfaces ());
- }
- }
- };
- en.put (c);
-
- return new AlterEnumeration (en) {
- protected Object alter (Object clazz) {
- Class c2 = (Class)clazz;
- return c2.getName ().replace ('.', '/');
- }
- };
- }
-}
Index: openidex/src/org/openidex/nodes/looks/Look.java
===================================================================
RCS file: openidex/src/org/openidex/nodes/looks/Look.java
diff -N openidex/src/org/openidex/nodes/looks/Look.java
--- openidex/src/org/openidex/nodes/looks/Look.java 10 Feb 2003 19:48:52 -0000 1.8
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,480 +0,0 @@
-/*
- * 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-2003 Sun
- * Microsystems, Inc. All Rights Reserved.
- */
-
-package org.openidex.nodes.looks;
-
-import java.util.ArrayList;
-import java.awt.Image;
-import java.awt.datatransfer.Transferable;
-import java.io.IOException;
-
-import org.w3c.dom.NodeList;
-import org.w3c.dom.Element;
-
-import org.openide.nodes.*;
-import org.openide.loaders.XMLDataObject;
-import org.openide.util.actions.SystemAction;
-import org.openide.util.HelpCtx;
-import org.openide.util.Lookup;
-import org.openide.util.datatransfer.NewType;
-import org.openide.util.datatransfer.PasteType;
-
-/** Base class for all looks. This class handles basic reading of properties
- * from XML description.
- *
- * Notice the difference between the methods which take the parameter of
- * type NodeSubstitute and the methods which don't. The first methods are
- * those which implement the functionality of the look. The second are methods
- * which represent properties of the Look itself.
- *
- *
- * @author Petr Hrebejk
- */
-public abstract class Look implements Node.Cookie, java.io.Serializable {
-
- /** Use this constant for returning no Actions. */
- public static final SystemAction[] NO_SYSTEM_ACTIONS = {};
-
- /** Use this constant for returning empty NewTypes. */
- public static final NewType[] NO_NEW_TYPES = {};
-
- /** Use this constant for returning empty PasteTypes. */
- public static final PasteType[] NO_PASTE_TYPES = {};
-
- /** Use this constant for returning empty PropertySets. */
- public static final Node.PropertySet[] NO_PROPERTY_SETS = {};
-
- /** Use this constant for returning empty KeySets. */
- public static final Object[] NO_KEYS = {};
-
- /** Name of XML attrubute describing name */
- public static final String ATTR_NAME = "name"; // NOI18N
-
- /** Name of the XML tag for standalone; value="Standalone". */
- private static final String TAG_STANDALONE = "Standalone"; // NOI18N
-
- /** Name of the XML tag for standalone; value="class". */
- private static final String ATTR_CLASS = "class"; // NOI18N
-
- /** Name of the look */
- private String name;
-
- /** The XML data object for the look */
- protected XMLDataObject lookDataObject;
-
- /** Classes for which this look is standalone */
- ArrayList standaloneClasses;
-
-
- // Methods of look itself --------------------------------------------------
-
- /** Returns name of the look.
- * @return Name of the look.
- */
- public String getName() {
- return name;
- }
-
- /** Sets name of the Look
- * @param name Name of the look.
- */
- public void setName( String name ) {
- this.name = name;
- }
-
- /** Determines whether the Look can be used as standalone Look for given node.
- * E.g. Should be an item in the list of possible looks for the node.
- * The default implementation works with the information gathered from the
- * XML data object - tag
- * Implementors may not wait for any other threads at it may be potentially called
- * from LookNode's lock.
- * @param substitute The
- * If the look returns null, the implementation {@ling LookNode} returns
- * the actions in {@link NodeOp#getDefaultActions} obtained by the super call.
- * @param substitute The
- * Temporary implementation of Children of a LookNode. The class contains
- * only code wich is necessary for testing looks and may be extended later.
- *
- * @author Petr Hrebejk
- */
-class LookChildren extends Children.Keys {
-
- void refreshChildren( ) {
- setKeys( getKeys() );
- }
-
- protected void addNotify() {
- setKeys( getKeys() );
- }
-
- protected void removeNotify() {
- setKeys( Collections.EMPTY_LIST );
- }
-
- protected Node[] createNodes( Object key ) {
-
- Look look = (Look)getNode().getCookie( Look.class );
-
- if ( key == null ) {
- return new Node[0];
-// } else if (key instanceof LookNode) {
-// return new Node[] {new FilterNode((Node)key)}; // ??? what if it has to derive look from parent?
- }
- else {
- LookNode node = new LookNode( key );
- look.attachTo( node.getSubstitute() );
- return new Node[] { node };
- }
-
- }
-
-
- // Private methods ---------------------------------------------------------
-
- private Object[] getKeys() {
-
- Look look = (Look)getNode().getCookie( Look.class );
-
- Object[] keys = look.getChildObjects( ((LookNode)getNode()).getSubstitute() );
- if ( keys == null ) {
- return new Object [0];
- }
- else {
- return keys;
- }
-
- }
-
-}
Index: openidex/src/org/openidex/nodes/looks/LookEnvironmentProvider.java
===================================================================
RCS file: openidex/src/org/openidex/nodes/looks/LookEnvironmentProvider.java
diff -N openidex/src/org/openidex/nodes/looks/LookEnvironmentProvider.java
--- openidex/src/org/openidex/nodes/looks/LookEnvironmentProvider.java 10 Feb 2003 19:49:00 -0000 1.5
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,229 +0,0 @@
-/*
- * 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 Forte for Java, Community Edition. The Initial
- * Developer of the Original Code is Sun Microsystems, Inc. Portions
- * Copyright 1997-2003 Sun Microsystems, Inc. All Rights Reserved.
- */
-
-package org.openidex.nodes.looks;
-
-import org.w3c.dom.*;
-
-import org.openide.cookies.InstanceCookie;
-import org.openide.loaders.XMLDataObject;
-import org.openide.loaders.DataObject;
-import org.openide.loaders.Environment;
-import org.openide.util.Lookup;
-import org.openide.util.lookup.AbstractLookup;
-import org.openide.util.lookup.InstanceContent;
-import org.openide.nodes.BeanNode;
-
-import org.openidex.nodes.looks.Look;
-
-/** Class which allowes to store the Looks into the XML layer.
- *
- * @author Petr Hrebejk
- */
-public class LookEnvironmentProvider implements Environment.Provider {
-
- /** DataObject for given look */
- private DataObject dobj;
- private AbstractLookup lookup;
-
- /** Charater used to delimit the Look name and the look class in
- * the name of the XML file describing the Look; value = '$'.
- */
- public static final char NAME_DELIMITER = '$'; // NOI18N
-
- /** Charater used to delimit the package names in
- * the name of the XML file describing the Look; value = '-'.
- */
- public static final char PACKAGE_DELIMITER = '-'; // NOI18N
-
- /** Class name delimiter */
- private static final char DOT = '.'; //NOI18N
-
- /** The node convertor */
- private static NodeConvertor nodeConvertor = new NodeConvertor();
-
- // Implementation of EnvronmentProvider ------------------------------------
-
- /** Returns a lookup that represents environment.
- * @return the lookup
- */
- public Lookup getEnvironment(DataObject obj) {
- dobj = obj;
-
- InstanceContent ic = new InstanceContent();
- lookup = new AbstractLookup( ic );
- LookInstanceCookie lic;
-
- ic.add( lic = new LookInstanceCookie( dobj ) );
-
- ic.add( lic, nodeConvertor );
-
- return lookup;
- }
-
- // Innerclasses ------------------------------------------------------------
-
- /** Class for postponing creation of the Look node */
- public static class NodeConvertor implements InstanceContent.Convertor {
-
- /** Convert obj to other object. There is no need to implement
- * cache mechanism. It is provided by InstanceLookup.Item.getInstance().
- * Method should be called more than once because Lookup holds
- * just weak reference.
- *
- * @param obj the registered object
- * @return the object converted from this object
- */
- public Object convert(Object obj) {
- try {
- BeanNode bn = new BeanNode( ((LookInstanceCookie)obj).instanceCreate() );
- bn.setName( ((LookInstanceCookie)obj).instanceName() );
- bn.setIconBase( "org/openidex/nodes/looks/resources/Look" ); // NOI18N
- return bn;
- }
- catch ( java.io.IOException e ) {
- return null;
- }
- catch ( ClassNotFoundException e ) {
- return null;
- }
- catch ( java.beans.IntrospectionException e ) {
- return null;
- }
- }
-
- /** Computes the ID of the resulted object.
- * @param obj the registered object
- * @return the ID for the object
- */
- public String id(Object obj) {
- return ((LookInstanceCookie)obj).instanceName();
- }
-
- /** Return type of converted object.
- * @param obj the registered object
- * @return the class that will be produced from this object (class or
- * superclass of convert (obj))
- */
- public Class type(Object obj) {
- return BeanNode.class;
- }
-
- /** The human presentable name for the object.
- * @param obj the registered object
- * @return the name representing the object for the user
- */
- public String displayName(Object obj) {
- return ((LookInstanceCookie)obj).instanceName();
- }
-
- }
-
-
- /** InstanceCookie for creation of Instances of the Look
- */
- private class LookInstanceCookie implements InstanceCookie {
-
- /** DataObject where the Look is created from */
- private DataObject dobj;
-
- private String lookName;
-
- // Holds the look when already created
- private Look look;
-
- /** Creates new LookInstanceCookie for given data object
- */
- LookInstanceCookie( DataObject dobj ) {
- this.dobj = dobj;
- }
-
- /** The name of {@link #instanceClass}.
- * @return the instance class name
- */
- public String instanceName() {
- return getLookName();
- }
-
- /** Create an instance.
- * @return the instance of type {@link #instanceClass} (or a subclass)
- * @exception IOException if an I/O error occured
- * @exception ClassNotFoundException if a class was not found
- */
- public Object instanceCreate() throws java.io.IOException, ClassNotFoundException {
- Class clazz = instanceClass();
-
- if ( look == null ) {
- try {
- java.lang.reflect.Constructor constructor = clazz.getConstructor( new Class[] {} );
- look = (Look)constructor.newInstance( new Object[] {} );
- //System.out.println("Creating instance" + dobj.getName() ); // NOI18N
- look.readPropertiesFromXML( (XMLDataObject)dobj );
- //return look;
- }
- catch ( InstantiationException e ) {
- throw new ClassNotFoundException( e.toString() );
- }
- catch ( IllegalAccessException e ) {
- throw new ClassNotFoundException( e.toString() );
- }
- catch ( NoSuchMethodException e ) {
- throw new ClassNotFoundException( e.toString() );
- }
- catch ( java.lang.reflect.InvocationTargetException e ) {
- throw new ClassNotFoundException( e.toString() );
- }
- }
- return look;
- }
-
- /** The representation type that may be created as instances.
- * Can be used to test whether the instance is of an appropriate
- * class without actually creating it.
- *
- * @return the representation class of the instance
- * @exception IOException if an I/O error occurred
- * @exception ClassNotFoundException if a class was not found
- */
- public Class instanceClass() throws java.io.IOException, ClassNotFoundException {
- return getLookClass();
- }
-
- // Private Methods ---------------------------------------------------------
-
- /** Returns the class of the instance, based on name of the file
- */
- private Class getLookClass() throws ClassNotFoundException {
-
- String objName = dobj.getName();
- int nameIndex = objName.indexOf( NAME_DELIMITER );
- String className = nameIndex == -1 ?
- objName.replace( PACKAGE_DELIMITER, DOT ) :
- objName.substring(0, nameIndex ).replace( PACKAGE_DELIMITER, DOT );
- ClassLoader l = (ClassLoader)Lookup.getDefault().lookup(ClassLoader.class);
- return Class.forName( className, false, l);
- }
-
- /** Returns the look name
- */
- private String getLookName() {
-
- if ( lookName == null ) {
- String objName = dobj.getName();
- int nameIndex = objName.indexOf( NAME_DELIMITER );
- lookName = objName.substring( nameIndex + 1 );
- }
- return lookName;
- }
- }
-}
\ No newline at end of file
Index: openidex/src/org/openidex/nodes/looks/LookNode.java
===================================================================
RCS file: openidex/src/org/openidex/nodes/looks/LookNode.java
diff -N openidex/src/org/openidex/nodes/looks/LookNode.java
--- openidex/src/org/openidex/nodes/looks/LookNode.java 3 Dec 2002 14:12:23 -0000 1.12
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,593 +0,0 @@
-/*
- * 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-2000 Sun
- * Microsystems, Inc. All Rights Reserved.
- */
-
-package org.openidex.nodes.looks;
-
-import java.beans.*;
-import java.awt.Image;
-import java.awt.datatransfer.Transferable;
-import java.io.IOException;
-import javax.swing.event.ChangeListener;
-import javax.swing.event.ChangeEvent;
-
-import org.openide.nodes.*;
-
-import org.openide.util.HelpCtx;
-import org.openide.util.Utilities;
-import org.openide.util.actions.SystemAction;
-import org.openide.util.datatransfer.NewType;
-import org.openide.util.datatransfer.PasteType;
-
-
-/** WARNING - This API is not finished and is subject to change
- * Node which can be used with Looks.
- *
- * @author Petr Hrebejk
- */
-public final class LookNode extends Node implements Node.Cookie {
-
- /** Default Icon 16x16 */
- private static Image DEFAULT_ICON_16;
-
- /** Default Icon 32x32 */
- private static Image DEFAULT_ICON_32;
-
- /** Name of the default icon 16x16 */
- private static final String DEFAULT_ICON_16_NAME =
- "org/openidex/nodes/looks/resources/defaultNode.gif"; // NOI18N
-
- /** Name of the default icon 32x32 */
- private static final String DEFAULT_ICON_32_NAME =
- "org/openidex/nodes/looks/resources/defaultNode32.gif"; //NOI18N
-
- /** Object represented (delegeted) by interior */
- private SubstituteImpl substitute = null;
-
- // it is our private lock guarding look and lookCandidate fields
- private final String lock = "LookNode.lock";
-
- /** Look set and attached on this node or null if derived. */
- private Look look = null;
-
- // A look prepared for attaching (to become a hard look). It is used if it is added as a child of
- // a node that is not instance of LookNode and therefore actual look cannot
- // be derived from the new parent node look.
- private Look lookCandidate = null;
-
- /** CookieSet for this node */
- private CookieSet cookieSet = null;
-
- /** Creates new LookNode.
- * @param representedObject The object which the node will represent.
- */
- public LookNode( Object representedObject ) {
- this( representedObject, null );
- }
-
- /** Creates new LookNode.
- * @param representedObject The object which the node will represent.
- * @param look explicit look that will be set
- */
- public LookNode( Object representedObject, Look look ) {
- super( new LookChildren( ) );
- // Create the interior
- substitute = new SubstituteImpl(representedObject);
- // set hard look (or null)
- this.look = look;
- if (look != null) look.attachTo(substitute);
- }
-
-
- // Additional methods for LookNode -----------------------------------------
-
- /** Used to get Substitute of this LookNode
- * @return NodeSubstitute
- */
- Look.NodeSubstitute getSubstitute(){
- return substitute;
- }
-
- /** Returns represented object which this LookNode represents.
- * @return The object represented by this node.
- */
- public Object getRepresentedObject() {
- return substitute.getRepresentedObject();
- }
-
- /** Sets look for this node. After changing the Look several property
- * changes are fired:
- *
- * Utility class for creating a SheetSet for switching looks.
- *
- * @author Petr Hrebejk
- */
-class LookProperties extends Object {
-
- private static final ResourceBundle bundle = NbBundle.getBundle( LookProperties.class );
-
- public static final String LOOK_SHEET_SET_NAME = "Look"; // NOI18N
-
- /** Name of the default look. I.e. when the look on the node is null*/
- private static final String DEFAULT = bundle.getString( "CTL_Default" ); //NOI18N
-
- public static SystemAction getSetLookAction( LookNode node ) {
- SetLookAction setLookAction = (SetLookAction)SystemAction.get( SetLookAction.class );
- setLookAction.setLookNode( node );
- return setLookAction;
- }
-
- public static Sheet.Set getLookPropertySet( LookNode node ) {
-
- Sheet.Set set = new Sheet.Set();
- set.setName( LOOK_SHEET_SET_NAME ); // NOI18N
- set.setDisplayName( bundle.getString( "CTL_LookSheetSetName" ) ); //NOI18N
- set.put( new LookProperty( node ) );
- return set;
- }
-
- // INNER CLASSES -----------------------------------------------------------
-
- /** The property for changing look
- */
- static class LookProperty extends PropertySupport.ReadWrite {
-
- private final LookNode lookNode;
-
- LookProperty( LookNode lookNode ) {
- super( bundle.getString( "CTL_LookProperty" ), // NOI18N
- Look.class,
- bundle.getString( "CTL_LookProperty" ), // NOI18N
- bundle.getString( "CTL_LookPropertyShortDescription" ) // NOI18N
- );
- this.lookNode = lookNode;
- }
-
-
- public Object getValue() {
- return lookNode.getHardLook();
- }
-
- public void setValue( Object value ) {
- lookNode.setLook( (Look) value );
- }
-
- public PropertyEditor getPropertyEditor () {
- return new LookEditor( lookNode );
- }
-
- }
-
- /** Editor for choosing looks */
- static class LookEditor extends PropertyEditorSupport {
-
- /** The node */
- LookNode lookNode = null;
-
- /** Current value */
- private Look look = null;
-
- /** Creates new editor */
- public LookEditor ( LookNode lookNode ) {
- this.lookNode = lookNode;
- }
-
- /**
- * @return The property value as a human editable string.
- * Returns null if the value can't be expressed as an editable string.
- * If a non-null value is returned, then the PropertyEditor should
- * be prepared to parse that string back in setAsText().
- */
- public String getAsText () {
- if ( getValue() == null ) {
- return DEFAULT;
- }
- return ((Look)getValue()).getName();
- }
-
- /**
- * Set the property value by parsing a given String.
- * @param text The string to be parsed.
- */
- public void setAsText ( String string ) throws IllegalArgumentException {
- if ( string.equals( DEFAULT ) ) {
- setValue( null );
- }
- Look[] allLooks = getAllLooks( lookNode );
- for( int i = 0; i < allLooks.length; i++ ) {
- if ( allLooks[i].getName().equals( string ) ) {
- setValue( allLooks[i] );
- return;
- }
- }
- throw new IllegalArgumentException( "No such look - " + string ); // NOI18N
- }
-
- /**
- * @return A fragment of Java code representing an initializer for the
- * current value.
- */
- public String getJavaInitializationString () {
- return (getValue() == null) ? "" : look.getName(); // NOI18N
- }
-
- /**
- * @return The tag values for this property.
- */
- public String[] getTags () {
-
- Look[] allLooks = getAllLooks( lookNode );
- String names[];
-
- int offset = 0;
- if (lookNode.hasLookNodeParent()) {
- names = new String[ allLooks.length + 1];
- names[0] = DEFAULT;
- offset = 1;
- } else {
- names = new String[ allLooks.length];
- }
-
- for ( int i = 0; i < allLooks.length ; i++ ) {
- names[ i+ offset] = allLooks[i].getName();
- }
- return names;
- }
-
- static Look[] getAllLooks( LookNode lookNode ) {
- Lookup.Template t = new Lookup.Template( Look.class );
-
- Lookup.Result r = Lookup.getDefault().lookup( t );
- Collection lc = r.allInstances();
-
- ArrayList looks = new ArrayList( lc.size() );
- int i = 0;
- for ( Iterator it = lc.iterator(); it.hasNext(); i++ ) {
- Look look = (Look)it.next();
- if ( look.isLookStandalone( lookNode.getRepresentedObject() ) ) {
- looks.add( look );
- }
- }
-
- return (Look[])looks.toArray( new Look[0] );
- }
- }
-
- /** Popupmenu action for choosing looks
- */
- public static class SetLookAction extends NodeAction {
-
- private LookNode lookNode = null;
-
- public java.lang.String getName() {
- return bundle.getString( "ACT_SetLook" ); //NOI18N
- }
-
- public org.openide.util.HelpCtx getHelpCtx() {
- return org.openide.util.HelpCtx.DEFAULT_HELP;
- }
-
- public void setLookNode(LookNode lookNode){
- this.lookNode = lookNode;
- }
-
- /* Returns a submneu that will present this action in a PopupMenu.
- * @return the JMenuItem representation for this action
- */
- public JMenuItem getPopupPresenter() {
- JMenu mainItem = new JMenuPlus();
- Actions.setMenuText(mainItem, getName(), true);
- HelpCtx.setHelpIDString (mainItem, SetLookAction.class.getName ());
- mainItem.addMenuListener(new MainItemListener(lookNode));
- return mainItem;
- }
-
- protected boolean enable(org.openide.nodes.Node[] node) {
- if( node.length == 1 )
- return true;
- return false;
- }
-
- protected void performAction(org.openide.nodes.Node[] node) {
- //do nothing
- }
-
- }
-
- /** Listens to selecting of main item and expands it to the
- * submenu of exiting and new modes
- */
- private static final class MainItemListener implements MenuListener {
-
- /** Source of the events */
- private JMenu menu;
-
- private LookNode lookNode;
-
- public MainItemListener(LookNode lookNode){
- this.lookNode = lookNode;
- }
-
- public void menuCanceled (MenuEvent e) {
- }
-
- public void menuDeselected (MenuEvent e) {
- JMenu menu = (JMenu)e.getSource();
- menu.removeAll();
- }
-
- public void menuSelected (MenuEvent e) {
- this.menu = (JMenu)e.getSource();
-
- if (lookNode.hasLookNodeParent()) {
- menu.add(createMenuItem(lookNode, null));
- }
- // create look list
- if( lookNode != null ){
- Look[] looks = LookProperties.LookEditor.getAllLooks( lookNode );
- for( int i = 0; i < looks.length; i++ ){
- menu.add(createMenuItem(lookNode, looks[i]));
- }
- }
- }
-
- /**Creates menu item for existing mode. If mode has split TCC then use menu
- * instead of menu item. Adds listener to menu item.
- */
- private JMenuItem createMenuItem(LookNode lookNode, Look look) {
- JMenuItem curMenu = new JMenuItem();
- if( look == null ){
- Actions.setMenuText(curMenu, DEFAULT , true); // NOI18N
- curMenu.addActionListener(new LookItemListener(lookNode, null));
- }
- else {
- Actions.setMenuText(curMenu, look.getName(), true);
- curMenu.addActionListener(new LookItemListener(lookNode, look));
- }
-
- return curMenu;
- }
- } // end of MainItemListener inner class
-
- private static final class LookItemListener implements ActionListener {
- private LookNode lookNode;
- private Look look;
- LookItemListener(LookNode lookNode, Look look){
- this.lookNode = lookNode;
- this.look = look;
- }
-
- public void actionPerformed(ActionEvent evt) {
- lookNode.setLook(look);
- }
- }
-}
-
Index: openidex/src/org/openidex/nodes/looks/NodeProxyLook.java
===================================================================
RCS file: openidex/src/org/openidex/nodes/looks/NodeProxyLook.java
diff -N openidex/src/org/openidex/nodes/looks/NodeProxyLook.java
--- openidex/src/org/openidex/nodes/looks/NodeProxyLook.java 3 Dec 2002 14:12:24 -0000 1.8
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,467 +0,0 @@
-/*
- * 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 Forte for Java, Community Edition. The Initial
- * Developer of the Original Code is Sun Microsystems, Inc. Portions
- * Copyright 1997-2000 Sun Microsystems, Inc. All Rights Reserved.
- */
-
-package org.openidex.nodes.looks;
-
-import java.awt.Image;
-import java.awt.datatransfer.Transferable;
-import java.io.IOException;
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeEvent;
-
-import org.openide.nodes.*;
-import org.openide.util.actions.SystemAction;
-import org.openide.util.HelpCtx;
-import org.openide.util.datatransfer.NewType;
-import org.openide.util.datatransfer.PasteType;
-
-/** WARNING - This API is not finished and is subject to change
- * Utility Class which allows to use LookNodes on existing Nodes.
- * The class assumes that represented object is a Node. If there is
- * Node.Interior representing other object than a ndoe the look delegates
- * to {DefaultLook#INSTANCE} i.e. returns neutral values.PROP_COOKIE, PROP_NAME, PROP_NAME, PROP_DISPLAY_NAME, PROP_ICON,
- * PROP_OPENED_ICON
and children are refresehed.
- * @look New look of the node.
- */
- public void setLook( final Look look ) {
- String name = look.getName ();
-
- MUTEX.writeAccess (new Runnable () {
- public void run () {
- LookNode.this.look = look; // new current look
-
- substitute.clean (); // not used anymore
- SubstituteImpl newsubst = new SubstituteImpl (LookNode.this, look);
-
- substitute = newsubst;
-
- // commented out as hotfix of #24424
- //recordLook (this, base, name);
- }
- });
- // fire possible change notifications
-
- fireCookieChange();
- refreshChildren(true);
- fireNameChange( null, null );
- fireDisplayNameChange( null, null );
- fireIconChange();
- fireOpenedIconChange();
- }
-
- /** Refreshes children on the node */
- void refreshChildren(boolean brutal) {
- ((LookChildren)getChildren()).refreshChildren(brutal);
- }
-
- // methods to track the state of the tree
-
- /** Stores the name of the selected look.
- * @param node node to store the name for
- * @param nameLook look that should be used to create node's names
- * @param look the name of the look
- */
- private static void recordLook (LookNode node, Look nameLook, String look) {
- StringBuffer buf = new StringBuffer (512);
-
- for (;;) {
- Node parent = node.getParentNode();
- if (parent == null) break;
-
- parent = (LookNode)parent.getCookie (LookNode.class);
- if (parent == null) break;
-
- node = (LookNode)parent;
- buf.insert (0, nameLook.getName (node.getSubstitute ()));
- }
-
- synchronized (node) {
- if (node.map == null) {
- node.map = new HashMap ();
- }
-
- if (node.map.size () > MAX_MEMORY) {
-
- int rand = (int)(Math.random() * MAX_MEMORY);
-
- Iterator it = node.map.entrySet ().iterator();
- while (rand-- > 0) {
- it.next ();
- }
- it.remove();
- }
-
- node.map.put (buf.toString ().intern(), look);
- }
- }
-
-
- /** Finds proposed look in storage (if any) for this node.
- * @return name of suggested look for our current state or null
- */
- Look findLookForChild (LookNode child) {
- String name = child.getName ();
- LookNode node = this;
-
- StringBuffer buf = new StringBuffer (512);
- buf.append (name);
-
- for (;;) {
- if (node == null) {
- return null;
- }
-
- if (node.map != null) {
- name = (String)node.map.get (buf.toString ());
-
- if (name != null) {
- // found a name now find the look
- return child.lookByName (child.getBaseLook(), name);
- }
-
- }
-
- buf.insert (0, node.getName ());
-
-
- Node p = node.getParentNode ();
- if (p == null) {
- break;
- }
-
- node = (LookNode)p.getCookie(LookNode.class);
- if (node == null) {
- return null;
- }
- }
-
- return null;
- }
-
- /** Finds a look by name.
- * @param look the look to search in
- * @param name name to find
- * @return the look or null
- */
- private final Look lookByName (Look base, String name) {
- if (name.equals (base.getName ())) {
- return base;
- }
-
- Look[] arr = base.availableLooks (getSubstitute ());
- for (int i = 0; i < arr.length; i++) {
- base = lookByName (arr[i], name);
- if (base != null) {
- return base;
- }
- }
- return null;
- }
-
- // General methods ---------------------------------------------------------
-
- /**
- * Gets the actual look set on this node.
- * @return Look set on this Node
- *
- */
- public Look getLook() {
- return look;
- }
-
- /** Getter for the base look.
- */
- final Look getBaseLook () {
- return base;
- }
-
- /** Gets Cookie of given type. The set of Cookies is determined by the
- * Look. Look of the node can allways be asked using getCookie(
- * Look.class )
and the LookNode self can be asked by
- * getCookie( LookNode.class )
.
- * @param type the representation class of the cookie
- * @return a cookie assignable to that class, or null
- * the Look does not provide such cookie.
- */
- public Node.Cookie getCookie (Class type) {
- if ( type == Look.class ) {
- // Look is available in cookies
- return getLook();
- } else if ( type == LookNode.class ) {
- return this;
- } else {
- // Ask the Looks for additional cookies
- Object c = getSubstitute ().getCookie (type);
-
- return c instanceof Node.Cookie ? (Node.Cookie)c : null;
- }
- }
-
- /** Determines Handle by querying the Look.
- * @return the handle, or null
if this node is not persistable
- */
- public Node.Handle getHandle() {
- if (map != null) {
- return new H (map, getRepresentedObject ());
- } else {
- return DefaultHandle.createHandle (this);
- }
- }
-
- /**
- * Returns a node representing the same object as the original node. Looks
- * passed in constructor and in setLook method are copied as well.
- *
- * @return LookNode representing the same object.
- */
- public Node cloneNode () {
- return new LookNode( getRepresentedObject(), base, look);
- }
-
-
- // Methods for STYLE -------------------------------------------------------
-
- /** Determines displayName by querying the Look.
- * @return DisplayName provided by the Look or result
- * of {@link #getName()}.
- */
- public String getDisplayName() {
- return (String) MUTEX.readAccess (new Mutex.Action () {
- public Object run () {
- String displayName = getLook().getDisplayName( substitute );
-
- if ( displayName == null ) {
- return getName();
- } else {
- return displayName;
- }
- }
- });
- }
-
- /** Empty method, setting displayName
on the
- * LookNode
has no efect. The displayName
should
- * be determined by associated Look
.
- * @param name Parameter is ignored.
- */
- public void setDisplayName( String name ) {
- }
-
- /** Determines name by querying the Look.
- * @return Name provided by the Look or null
.
- */
- public String getName() {
- return (String) MUTEX.readAccess (new Operation (ProxyLook.GET_NAME));
- }
-
- /** Invoking this method on LookNode invokes method {@link Look#setName(
- * Look.NodeSubstitute, String )}. Look is responsible for handling the call.
- */
- public void setName( String s ) {
- MUTEX.readAccess (new Operation (ProxyLook.SET_NAME, s));
- }
-
- /** Empty method, setting shortDescription
on the
- * LookNode
has no efect. The shortDescription
- * should be determined by associated Look
.
- * @param shortDescription Parameter is ignored.
- */
- public void setShortDescription( String shortDescription ) {
- }
-
- /** Determines shortDescription by querying the Look.
- * @return Name provided by the Look or result of {@link getDisplayName()}.
- */
- public String getShortDescription() {
- return (String) MUTEX.readAccess (new Mutex.Action () {
- public Object run () {
- String shortDescription = getLook().getShortDescription( substitute );
-
- if ( shortDescription == null ) {
- return getDisplayName();
- } else {
- return shortDescription;
- }
- }
- });
- }
-
- /** Determines icon for closed state by querying the Look.
- * @return Icon provided by the Look
- */
- public Image getIcon( int type ) {
- Image icon = (Image) MUTEX.readAccess (new Operation (ProxyLook.GET_ICON, new Integer (type)));
-
- if ( icon == null ) {
- if ( type == BeanInfo.ICON_COLOR_32x32 || type == BeanInfo.ICON_MONO_32x32 ) {
- return Utilities.loadImage( DEFAULT_ICON_32_NAME );
- }
- return Utilities.loadImage( DEFAULT_ICON_16_NAME );
- }
- else {
- return icon;
- }
- }
-
- /** Determines icon for opened state by querying the Look.
- * @return Icon provided by the Look or the result of
- * {@link getIcon()}.
- */
- public Image getOpenedIcon( final int type ) {
- return (Image) MUTEX.readAccess (new Mutex.Action () {
- public Object run () {
- Image icon = getLook().getOpenedIcon( substitute, type );
-
- if ( icon == null ) {
- return getIcon( type );
- } else {
- return icon;
- }
- }
- });
- }
-
- /** Determines HelpCtx for opened state by querying the Look.
- * @return HelpCtx provided by the Look.
- */
- public HelpCtx getHelpCtx () {
- return (HelpCtx) MUTEX.readAccess (new Operation (ProxyLook.GET_HELP_CTX));
- }
-
- // Methods for ACTIONS & NEW TYPES -----------------------------------------
-
- /** Determines NewTypes for opened state by querying the Look.
- * @return NewTypes provided by the Look.
- */
- public NewType[] getNewTypes() {
- NewType arr [] = (NewType []) MUTEX.readAccess (new Operation (ProxyLook.GET_NEW_TYPES));
- return arr == null ? NO_NEW_TYPES : arr;
- }
-
- public SystemAction[] getActions() {
- return toSA (getCommands ());
- }
-
- /** Implementation of the getActions command with the expected signature
- * of a method that will be used in future
- *
- * @return the actions supported by this node
- */
- private Action[] getCommands () {
- Action[] systemActions;
- Action[] mergedActions;
-
- systemActions = (Action[]) MUTEX.readAccess (new Operation (ProxyLook.GET_ACTIONS));
-
- if (systemActions == null) {
- systemActions = super.getActions();
- }
-
- int actlen = systemActions.length;
- mergedActions = new Action[actlen + 2];
- System.arraycopy( systemActions, 0, mergedActions, 0, actlen );
- Action sla = LookProperties.getSetLookAction ();
-
- System.arraycopy( new Action[]{
- null,
- sla
- }, 0, mergedActions, actlen, 2 );
-
- return mergedActions;
-
- }
-
-
- public SystemAction [] getContextActions() {
- Action[] arr = (Action[]) MUTEX.readAccess (new Operation (ProxyLook.GET_CONTEXT_ACTIONS));
- return arr != null ? toSA (arr) : NO_SYSTEM_ACTIONS;
- }
-
- public SystemAction getDefaultAction() {
- Action a = (Action) MUTEX.readAccess (new Operation (ProxyLook.GET_DEFAULT_ACTION));
- return a instanceof SystemAction ? (SystemAction)a : null;
- }
-
- /** A convertor that takes array of Actions and return array of SystemActions
- * @param arr array of Action
- * @return array of SystemActions
- */
- private static SystemAction[] toSA (Action[] arr) {
- SystemAction[] sa = new SystemAction[arr.length];
-
- for (int i = 0; i < arr.length; i++) {
- if (arr[i] instanceof SystemAction) {
- sa[i] = (SystemAction)arr[i];
- }
- }
-
- return sa;
- }
-
-
-
- // Methods for PROPERTIES AND CUSTOMIZER -----------------------------------
-
- public Node.PropertySet[] getPropertySets() {
- Node.PropertySet[] sets = (Node.PropertySet[]) MUTEX.readAccess (new Operation (ProxyLook.GET_PROPERTY_SETS));
- if (sets == null) {
- sets = NO_PROPERTY_SETS;
- }
-
- Node.PropertySet[] all = new Node.PropertySet[ sets.length + 1 ];
- System.arraycopy( sets, 0, all, 0, sets.length );
-
- Sheet.Set set = LookProperties.getLookPropertySet( this );
- /*
- set.setName( LookProperties.LOOK_SHEET_SET_NAME );
- set.setDisplayName( LookProperties.LOOK_SHEET_SET_NAME );
- set.put( new LookProperties.LookProperty( this ) );
- */
-
- all[ all.length - 1] = set;
-
- return all;
- }
-
- public java.awt.Component getCustomizer() {
- return (java.awt.Component) MUTEX.readAccess (new Operation (ProxyLook.GET_CUSTOMIZER));
- }
-
- public boolean hasCustomizer () {
- return ((Boolean) MUTEX.readAccess (new Operation (ProxyLook.HAS_CUSTOMIZER))).booleanValue();
- }
-
- // Methods for CLIPBOARD OPERATIONS ----------------------------------------
-
- public boolean canRename() {
- return ((Boolean) MUTEX.readAccess (new Operation (ProxyLook.CAN_RENAME))).booleanValue();
- }
-
- public boolean canDestroy() {
- return ((Boolean) MUTEX.readAccess (new Operation (ProxyLook.CAN_DESTROY))).booleanValue();
- }
-
- public boolean canCopy() {
- return ((Boolean) MUTEX.readAccess (new Operation (ProxyLook.CAN_COPY))).booleanValue();
- }
-
- public boolean canCut() {
- return ((Boolean) MUTEX.readAccess (new Operation (ProxyLook.CAN_CUT))).booleanValue();
- }
-
- public PasteType[] getPasteTypes( Transferable t) {
- PasteType[] arr = (PasteType[]) MUTEX.readAccess (new Operation (ProxyLook.GET_PASTE_TYPES, t));
- return arr != null ? arr : NO_PASTE_TYPES;
- }
-
- public PasteType getDropType( Transferable t, int action, int index) {
- return (PasteType) MUTEX.readAccess (new Operation (
- ProxyLook.GET_DROP_TYPE, t, new Integer (action), new Integer (index)));
- }
-
- public Transferable clipboardCopy() throws IOException {
- try {
- return (Transferable) MUTEX.readAccess (new OperationException (ProxyLook.CLIPBOARD_COPY));
- } catch (MutexException e) {
- throw (IOException) e.getException ();
- }
- }
-
- public Transferable clipboardCut() throws IOException {
- try {
- return (Transferable) MUTEX.readAccess (new OperationException (ProxyLook.CLIPBOARD_CUT));
- } catch (MutexException e) {
- throw (IOException) e.getException ();
- }
- }
-
- public Transferable drag() throws IOException {
- try {
- return (Transferable) MUTEX.readAccess (new OperationException (ProxyLook.DRAG));
- } catch (MutexException e) {
- throw (IOException) e.getException ();
- }
- }
-
- public void destroy () throws IOException {
- try {
- MUTEX.readAccess (new OperationException (ProxyLook.DESTROY));
- } catch (MutexException e) {
- throw (IOException) e.getException ();
- }
- super.destroy();
- }
-
-/*
- boolean hasLookNodeParent() {
- Node parent = getParentNode();
- return parent != null && parent instanceof LookNode;
- }
-*/
- // Operation innerclass -----------------------------------------------------
-
- private final class Operation implements Mutex.Action {
- private long method = 0;
- private Object param1 = null;
- private Object param2 = null;
- private Object param3 = null;
-
- public Operation (long method) {
- this (method, null);
- }
-
- public Operation (long method, Object param1) {
- this (method, param1, null, null);
- }
-
- public Operation (long method, Object param1, Object param2, Object param3) {
- this.method = method;
- this.param1 = param1;
- this.param2 = param2;
- this.param3 = param3;
- }
-
- public Object run () {
- if (method == ProxyLook.GET_CHILD_OBJECTS) {
- return getLook ().getChildObjects (substitute);
- } else if (method == ProxyLook.GET_NAME) {
- return getLook ().getName (substitute);
- } else if (method == ProxyLook.SET_NAME) {
- getLook ().setName (substitute, (String) param1);
- return null;
- } else if (method == ProxyLook.GET_ICON) {
- return getLook ().getIcon (substitute, ((Integer) param1).intValue());
- } else if (method == ProxyLook.GET_HELP_CTX) {
- return getLook ().getHelpCtx (substitute);
- } else if (method == ProxyLook.GET_NEW_TYPES) {
- return getLook ().getNewTypes (substitute);
- } else if (method == ProxyLook.GET_ACTIONS) {
- return getLook ().getActions (substitute);
- } else if (method == ProxyLook.GET_CONTEXT_ACTIONS) {
- return getLook ().getContextActions (substitute);
- } else if (method == ProxyLook.GET_DEFAULT_ACTION) {
- return getLook ().getDefaultAction (substitute);
- } else if (method == ProxyLook.GET_PROPERTY_SETS) {
- return getLook ().getPropertySets (substitute);
- } else if (method == ProxyLook.GET_CUSTOMIZER) {
- return getLook ().getCustomizer (substitute);
- } else if (method == ProxyLook.HAS_CUSTOMIZER) {
- return getLook ().hasCustomizer (substitute) ? Boolean.TRUE : Boolean.FALSE;
- } else if (method == ProxyLook.CAN_RENAME) {
- return getLook ().canRename (substitute) ? Boolean.TRUE : Boolean.FALSE;
- } else if (method == ProxyLook.CAN_DESTROY) {
- return getLook ().canDestroy (substitute) ? Boolean.TRUE : Boolean.FALSE;
- } else if (method == ProxyLook.CAN_COPY) {
- return getLook ().canCopy (substitute) ? Boolean.TRUE : Boolean.FALSE;
- } else if (method == ProxyLook.CAN_CUT) {
- return getLook ().canCut (substitute) ? Boolean.TRUE : Boolean.FALSE;
- } else if (method == ProxyLook.GET_PASTE_TYPES) {
- return getLook ().getPasteTypes (substitute, (Transferable) param1);
- } else if (method == ProxyLook.GET_DROP_TYPE) {
- return getLook ().getDropType (substitute, (Transferable) param1, ((Integer) param2).intValue(), ((Integer) param2).intValue());
- }
-
- throw new IllegalStateException ("Invalid method id " + method); //NOI18N
- }
- }
-
- private final class OperationException implements Mutex.ExceptionAction {
- private long method = 0;
-
- public OperationException (long method) {
- this.method = method;
- }
-
- public Object run () throws IOException {
- if (method == ProxyLook.CLIPBOARD_COPY) {
- return getLook ().clipboardCopy (substitute);
- } else if (method == ProxyLook.CLIPBOARD_CUT) {
- return getLook ().clipboardCut (substitute);
- } else if (method == ProxyLook.DRAG) {
- return getLook ().drag (substitute);
- } else if (method == ProxyLook.DESTROY) {
- getLook ().destroy (substitute);
- return null;
- }
-
- throw new IllegalStateException ("Invalid method id " + method); //NOI18N
- }
- }
-
- // Interior innerclass -----------------------------------------------------
-
- /** Class passed to the Look methods as parameter. Each LookNode contains
- * exactly one instance of this class. Metods of the class allow access
- * to the properties and methods od the node needed for the Look.
- */
- static final class SubstituteImpl extends Look.NodeSubstitute
- implements LookupListener {
- /** node we are attached to */
- private LookNode lookNode;
- /** lookup for this substitute */
- private Lookup lookup;
- /** all objects in the lookup, hold to prevent the result
- * to be garbage collected */
- private Lookup.Result result;
- /** selected id for this impl */
- private String id;
-
- /** The constructor of the interior is private to prevent other classes
- * than LookNode and Look from firing events on the node
- */
- SubstituteImpl(LookNode lookNode, Look look) {
- // initializes the lookNode
- this.lookNode = lookNode;
-
- // attaches to the look
- this.attachTo (look);
-
- // initializes the lookup
- this.lookup = look.createLookup (this);
- if (lookup != null) {
- // attach a listener
- result = lookup.lookup (
- new Lookup.Template (Object.class)
- );
- result.addLookupListener (this);
- }
- }
-
- /** Called when this substitute is not needed anymore
- */
- public void clean () {
- lookNode = null;
- }
-
- /** Method to access the lookup.
- */
- public LookNode getLookNode () {
- return lookNode;
- }
-
- /** Queries the lookup.
- */
- Object getCookie (Class clazz) {
- if (lookup == null) {
- return null;
- } else {
- if (result == null) {
- // attache a listener
- result = lookup.lookup (new Lookup.Template (Object.class));
- result.addLookupListener (this);
- }
- return lookup.lookup (clazz);
- }
- }
-
-
-
-
- /** Returns the object represented by the node
- * @return Object represented by the node this interior belongs to.
- */
- public Object getRepresentedObject(){
- LookNode l = lookNode;
- return l == null ? null : l.getRepresentedObject ();
- }
-
- /** Fire a property change event on the associated node.
- * @param name name of changed property (from {@link #getPropertySets})
- * @param o old value
- * @param n new value
- */
- public final void firePropertyChange( String name, Object o, Object n ) {
- LookNode l = lookNode;
- if (l != null) {
- l.firePropertyChange( name, o, n );
- }
- }
-
- /** Fires the Event notificationg about name change.
- */
- public final void fireNameChange( String o, String n ) {
- LookNode l = lookNode;
- if (l != null) {
- l.fireNameChange( o, n );
- }
- }
-
- /** Fires the Event notificationg about display name change.
- */
- public final void fireDisplayNameChange( String o, String n ) {
- LookNode l = lookNode;
- if (l != null) {
- l.fireDisplayNameChange( o, n );
- }
- }
-
- /** Fires the Event notificationg about short description change.
- */
- public final void fireShortDescriptionChange(String o, String n) {
- LookNode l = lookNode;
- if (l != null) {
- l.fireShortDescriptionChange( o, n );
- }
- }
-
- /** Fire a change event for {@link org.openide.nodes.Node#PROP_ICON} on
- * associated node.
- */
- public final void fireIconChange() {
- LookNode l = lookNode;
- if (l != null) {
- l.fireIconChange();
- }
- }
-
- /** Fire a change event for {@link org.openide.nodes.Node#PROP_OPENED_ICON} on
- * associated node.
- */
- public final void fireOpenedIconChange() {
- LookNode l = lookNode;
- if (l != null) {
- l.fireOpenedIconChange();
- }
- }
-
- /** Fires a (Bean) property change event (for
- * {@link org.openide.node.Node#PROP_PROPERTY_SETS}).
- * @param o the old set
- * @param n the new set
- */
- public final void firePropertySetsChange( PropertySet[] o, PropertySet[] n ) {
- LookNode l = lookNode;
- if (l != null) {
- l.firePropertySetsChange( o, n );
- }
- }
-
- /** Fires a change event for {@link org.openode.nodes.Node#PROP_COOKIE}.
- * The old and new values are set to null.
- */
- public final void resultChanged (LookupEvent ev) {
- LookNode l = lookNode;
- if (l != null) {
- l.fireCookieChange();
- }
- }
-
- /** To all node listeners fire node destroyed notification.
- */
- public final void fireNodeDestroyed() {
- LookNode l = lookNode;
- if (l != null) {
- l.fireNodeDestroyed();
- }
- }
-
- /** Tells the node that the children have to be refreshed.
- */
- public final void refreshChildren() {
- LookNode l = lookNode;
- if (l != null) {
- l.refreshChildren(false);
- }
- }
-
- public final String getRepresentationId() {
- return id;
- }
-
- } // end of SubstituteImpl
-
- /** Handle that stores the map of names to look names and
- * creates look node after then.
- */
- private static final class H implements Node.Handle {
- static final long serialVersionUID = -435781367432893214L;
-
- private Map map;
- private Object repr;
-
- public H (Map map, Object repr) {
- this.map = map;
- this.repr = repr;
- }
-
- public Node getNode () throws IOException {
- LookNode node = new LookNode (repr);
- node.map = map;
- return node;
- }
- }
-}
Index: openidex/looks/src/org/netbeans/api/looks/LookProperties.java
===================================================================
RCS file: openidex/looks/src/org/netbeans/api/looks/LookProperties.java
diff -N openidex/looks/src/org/netbeans/api/looks/LookProperties.java
--- openidex/looks/src/org/netbeans/api/looks/LookProperties.java 3 Dec 2002 14:12:19 -0000 1.5
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,396 +0,0 @@
-/*
- * 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-2000 Sun
- * Microsystems, Inc. All Rights Reserved.
- */
-
-package org.netbeans.api.looks;
-
-import java.util.*;
-import java.beans.PropertyEditor;
-import java.beans.PropertyEditorSupport;
-import javax.swing.JMenuItem;
-import javax.swing.JMenu;
-
-
-import org.openide.nodes.*;
-import org.openide.util.NbBundle;
-import org.openide.util.actions.*;
-import org.openide.awt.Actions;
-import java.beans.PropertyChangeListener;
-import java.lang.ref.Reference;
-import java.awt.Component;
-import org.openide.explorer.view.MenuView;
-import org.openide.explorer.ExplorerPanel;
-import org.openide.explorer.view.ChoiceView;
-import java.lang.ref.WeakReference;
-import java.lang.ref.SoftReference;
-import org.openide.util.WeakListener;
-
-
-/** WARNING - This API is not finished and is subject to change
- * Please don't use this API for other purposes than testing.
- *
- * Recomended usage of this class is to be used as delegatee.
- *
- * public class MyNodeLook extends AcceptorLook {
- *
- * public MyNodeLook() {
- * super( new NodeProxyLook(), MyNode.Class );
- * // set mask or do other initializations
- * }
- * }
- *
- *
- * @author Petr Hrebejk
- */
-final class NodeProxyLook extends Look {
-
- /** Creates new NodeProxySupport */
- public NodeProxyLook() {
- }
-
- // Methods of look itself --------------------------------------------------
-
- /** Specifies the node to which the Look delegates. The default
- * implementation returns substitute.getRepresentedObject()
- * casted to Node in case the represented object is a Node in other cases
- * it returns null. If you override this method you can provide delegation
- * nodes for different types of object. (E.g. by calling
- * dataObject.getNodeDelegate() ).
- */
- protected Node getNodeDelegate( Look.NodeSubstitute substitute ) {
-
- if ( substitute.getRepresentedObject() instanceof Node ) {
- return (Node)substitute.getRepresentedObject();
- }
- else {
- return null;
- }
- }
-
- // General methods ---------------------------------------------------------
-
- public Object attachTo (Look.NodeSubstitute substitute) {
- Node dn = getNodeDelegate( substitute );
- if ( dn == null ) {
- return null;
- } else {
- // Register listener to the node to pass events forward
- NodeEventTranslator nt = new NodeEventTranslator(substitute, dn);
- dn.addNodeListener (nt);
- dn.addPropertyChangeListener (new NodePropertyChangeTranslator (substitute, dn));
- return nt;
- }
- }
-
- public Lookup createLookup(Look.NodeSubstitute substitute) {
- // lookup has been created in attachTo method
- Object obj = getAttachedData (substitute);
- if (obj instanceof NodeEventTranslator) {
- NodeEventTranslator nt = (NodeEventTranslator)obj;
- return nt.lookup;
- }
- return null;
- }
-
- public Look[] availableLooks(Look.NodeSubstitute substitute) {
- Node dn = getNodeDelegate( substitute );
-// if (dn == null) {
- return null;
-// } else {
-// return dn.getHandle();
-// }
- }
-
- // Methods for STYLE -------------------------------------------------------
-
- public String getDisplayName( Look.NodeSubstitute substitute ) {
- Node dn = getNodeDelegate( substitute );
- if (dn == null) {
- return null;
- } else {
- return dn.getDisplayName();
- }
- }
-
- public String getName( Look.NodeSubstitute substitute ) {
- Node dn = getNodeDelegate( substitute );
- if (dn == null) {
- return null;
- } else {
- return dn.getName();
- }
- }
-
- public void setName( Look.NodeSubstitute substitute, String newName ) {
- Node dn = getNodeDelegate( substitute );
- if (dn != null) {
- dn.setName( newName );
- }
- }
-
- public String getShortDescription ( Look.NodeSubstitute substitute ) {
- Node dn = getNodeDelegate( substitute );
- if (dn == null) {
- return null;
- } else {
- return dn.getShortDescription();
- }
- }
-
- public Image getIcon( Look.NodeSubstitute substitute, int type ) {
- Node dn = getNodeDelegate( substitute );
- if (dn == null) {
- return null;
- } else {
- return dn.getIcon( type );
- }
- }
-
- public Image getOpenedIcon( Look.NodeSubstitute substitute, int type ) {
- Node dn = getNodeDelegate( substitute );
- if (dn == null) {
- return null;
- } else {
- return dn.getOpenedIcon( type );
- }
- }
-
- public HelpCtx getHelpCtx( Look.NodeSubstitute substitute ) {
- Node dn = getNodeDelegate( substitute );
- if (dn == null) {
- return null;
- } else {
- return dn.getHelpCtx();
- }
- }
-
- // Methods for CHILDREN ----------------------------------------------------
-
- public Object[] getChildObjects( Look.NodeSubstitute substitute ) {
- Node dn = getNodeDelegate( substitute );
- if (dn == null) {
- return null;
- } else {
- return dn.getChildren().getNodes();
- }
- }
-
- // Methods for ACTIONS & NEW TYPES -----------------------------------------
-
- public NewType[] getNewTypes( Look.NodeSubstitute substitute ) {
- Node dn = getNodeDelegate( substitute );
- if ( dn == null ) {
- return null;
- }
- else {
- return dn.getNewTypes();
- }
- }
-
- public Action[] getActions(Look.NodeSubstitute substitute) {
- Node dn = getNodeDelegate( substitute );
- if ( dn == null ) {
- return null;
- }
- else {
- return dn.getActions();
- }
- }
-
- public Action[] getContextActions(Look.NodeSubstitute substitute) {
- Node dn = getNodeDelegate( substitute );
- if ( dn == null ) {
- return null;
- }
- else {
- return dn.getContextActions();
- }
- }
-
- public Action getDefaultAction(Look.NodeSubstitute substitute) {
- Node dn = getNodeDelegate( substitute );
- if ( dn == null ) {
- return null;
- }
- else {
- return dn.getDefaultAction();
- }
- }
-
- // Methods for PROPERTIES AND CUSTOMIZER -----------------------------------
-
- public Node.PropertySet[] getPropertySets( Look.NodeSubstitute substitute ) {
- Node dn = getNodeDelegate( substitute );
- if ( dn == null ) {
- return null;
- }
- else {
- return dn.getPropertySets();
- }
- }
-
- public java.awt.Component getCustomizer( Look.NodeSubstitute substitute ) {
- Node dn = getNodeDelegate( substitute );
- if ( dn == null || !dn.hasCustomizer() ) {
- return null;
- }
- else {
- return dn.getCustomizer();
- }
- }
-
- public boolean hasCustomizer( Look.NodeSubstitute substitute ) {
- Node dn = getNodeDelegate( substitute );
- return dn != null && dn.hasCustomizer ();
- }
-
- // Methods for CLIPBOARD OPERATIONS ----------------------------------------
-
- public boolean canRename( Look.NodeSubstitute substitute ) {
- Node dn = getNodeDelegate( substitute );
- if ( dn == null ) {
- return false;
- }
- else {
- return dn.canRename();
- }
- }
-
- public boolean canDestroy( Look.NodeSubstitute substitute ) {
- Node dn = getNodeDelegate( substitute );
- if ( dn == null ) {
- return false;
- }
- else {
- return dn.canDestroy();
- }
- }
-
- public boolean canCopy( Look.NodeSubstitute substitute ) {
- Node dn = getNodeDelegate( substitute );
- if ( dn == null ) {
- return false;
- }
- else {
- return dn.canCopy();
- }
- }
-
- public boolean canCut( Look.NodeSubstitute substitute ) {
- Node dn = getNodeDelegate( substitute );
- if ( dn == null ) {
- return false;
- }
- else {
- return dn.canCut();
- }
- }
-
- public PasteType[] getPasteTypes( Look.NodeSubstitute substitute, Transferable t) {
- Node dn = getNodeDelegate( substitute );
- if ( dn == null ) {
- return null;
- }
- else {
- return dn.getPasteTypes( t );
- }
- }
-
- public PasteType getDropType( Look.NodeSubstitute substitute, Transferable t, int action, int index) {
- Node dn = getNodeDelegate( substitute );
- if ( dn == null ) {
- return null;
- }
- else {
- return dn.getDropType( t, action, index );
- }
- }
-
- public Transferable clipboardCopy( Look.NodeSubstitute substitute ) throws IOException {
- Node dn = getNodeDelegate( substitute );
- if ( dn == null ) {
- return null;
- }
- else {
- return dn.clipboardCopy();
- }
- }
-
- public Transferable clipboardCut( Look.NodeSubstitute substitute ) throws IOException {
- Node dn = getNodeDelegate( substitute );
- if ( dn == null ) {
- return null;
- }
- else {
- return dn.clipboardCut();
- }
- }
-
- public Transferable drag( Look.NodeSubstitute substitute ) throws IOException {
- Node dn = getNodeDelegate( substitute );
- if ( dn == null ) {
- return null;
- }
- else {
- return dn.drag();
- }
- }
-
- public void destroy( Look.NodeSubstitute substitute ) throws IOException {
- Node dn = getNodeDelegate( substitute );
- if ( dn != null ) {
- dn.destroy();
- }
- }
-
- /** The human presentable name of the look.
- * @return human presentable name
- */
- public String getDisplayName() {
- return NbBundle.getMessage (NodeProxyLook.class, "LAB_NodeProxyLook"); // NOI18N
- }
-
- /** Returns name of the look. This name should identify the look.
- * @return Name of the look.
- */
- public String getName() {
- return "Nodes"; // NOI18N
- }
-
- // Innerclasses ------------------------------------------------------------
-
- private static class NodeEventTranslator
- extends EventTranslator implements NodeListener {
-
- private Node node;
- private NodeLookup lookup;
-
- NodeEventTranslator( Look.NodeSubstitute substitute, Node node) {
- super( substitute );
- this.node = node;
- this.lookup = new NodeLookup (node);
- }
-
- public void unregister() {
- node.removeNodeListener( this );
- }
-
-
- public void childrenAdded( NodeMemberEvent e ) {
- getSubstitute().refreshChildren();
- }
-
- public void childrenRemoved( NodeMemberEvent e ) {
- getSubstitute().refreshChildren();
- }
-
- public void childrenReordered( NodeReorderEvent e ) {
- getSubstitute().refreshChildren();
- }
-
- public void nodeDestroyed( NodeEvent e ) {
- getSubstitute().fireNodeDestroyed();
- }
-
- public void propertyChange( PropertyChangeEvent e ) {
-
- if ( Node.PROP_NAME.equals( e.getPropertyName() ) ) {
- getSubstitute().fireNameChange( (String)e.getOldValue(), (String)e.getNewValue() );
- }
- else if ( Node.PROP_DISPLAY_NAME.equals( e.getPropertyName() ) ) {
- getSubstitute().fireDisplayNameChange( (String)e.getOldValue(), (String)e.getNewValue() );
- }
- else if ( Node.PROP_SHORT_DESCRIPTION.equals( e.getPropertyName() ) ) {
- getSubstitute().fireShortDescriptionChange( (String)e.getOldValue(), (String)e.getNewValue() );
- }
- else if ( Node.PROP_ICON.equals( e.getPropertyName() ) ) {
- getSubstitute().fireIconChange();
- }
- else if ( Node.PROP_OPENED_ICON.equals( e.getPropertyName() ) ) {
- getSubstitute().fireOpenedIconChange();
- }
- /*
- else if ( Node.PROP_PARENT_NODE.equals( e.getPropertyName() ) ) {
- property
- }
- */
- else if ( Node.PROP_PROPERTY_SETS.equals( e.getPropertyName() ) ) {
- getSubstitute().firePropertySetsChange( (Node.PropertySet[])e.getOldValue(),
- (Node.PropertySet[])e.getNewValue() );
- }
- else if ( Node.PROP_COOKIE.equals( e.getPropertyName() ) ) {
- lookup.cookieChanged ();
- }
- }
- }
-
- private static class NodePropertyChangeTranslator
- extends EventTranslator implements PropertyChangeListener {
-
- private Node node;
-
- NodePropertyChangeTranslator( Look.NodeSubstitute substitute, Node node) {
- super( substitute );
- this.node = node;
- }
-
- public void unregister() {
- node.removePropertyChangeListener( this );
- }
-
- public void propertyChange( PropertyChangeEvent e ) {
- getSubstitute().firePropertyChange( e.getPropertyName(), e.getOldValue(), e.getNewValue() );
- }
- }
-
- /** A lookup to delegate to the node */
- static final class NodeLookup extends AbstractLookup {
- /** node template to query for all registered nodes */
- private static Template TEMPL_NODE = new Template (Node.class);
-
- /** instance content to add new objects into */
- private InstanceContent ic;
- /** Set of Classes that we have already queried Look
and by default does nothing and returns neutral
- * values (nulls, false) from all its methods.
- * NbBundle.getMessage (getClass (), "LAB_" + getName ()
- * to simplify the work. That means one should put the token
- *
- * LAB_myname=localized name
- *
- * into the Bundle.properties
file defined in the same package
- * as this class (where myname is the name provided into the constructor).
- * Look.NodeSubstitute
of the node to operate on.
- * @return true if the customizer is available, false otherwise
- */
- public boolean hasCustomizer(Look.NodeSubstitute substitute) {
- return getCustomizer (substitute) != null;
- }
-
- /** Does neutral behaviour (doing nothing, returning null)
- */
- public java.awt.Component getCustomizer( Look.NodeSubstitute substitute ) {
- return null;
- }
-
- // Methods for CLIPBOARD OPERATIONS ----------------------------------------
-
- /** Does neutral behaviour (doing nothing, returning false)
- */
- public boolean canRename( Look.NodeSubstitute substitute ) {
- return false;
- }
-
- /** Does neutral behaviour (doing nothing, returning false)
- */
- public boolean canDestroy( Look.NodeSubstitute substitute ) {
- return false;
- }
-
- /** Does neutral behaviour (doing nothing, returning false)
- */
- public boolean canCopy( Look.NodeSubstitute substitute ) {
- return false;
- }
-
- /** Does neutral behaviour (doing nothing, returning false)
- */
- public boolean canCut( Look.NodeSubstitute substitute ) {
- return false;
- }
-
- /** Does neutral behaviour (doing nothing, returning null)
- */
- public PasteType[] getPasteTypes( Look.NodeSubstitute substitute, Transferable t) {
- return null;
- }
-
- /** Does neutral behaviour (doing nothing, returning null)
- */
- public PasteType getDropType( Look.NodeSubstitute substitute, Transferable t, int action, int index) {
- return null;
- }
-
- /** Does neutral behaviour (doing nothing, returning null)
- */
- public Transferable clipboardCopy( Look.NodeSubstitute substitute ) throws IOException {
- return null;
- }
-
- /** Does neutral behaviour (doing nothing, returning null)
- */
- public Transferable clipboardCut( Look.NodeSubstitute substitute ) throws IOException {
- return null;
- }
-
- /** Does neutral behaviour (doing nothing, returning null)
- */
- public Transferable drag( Look.NodeSubstitute substitute ) throws IOException {
- return null;
- }
-
- /** Does neutral behaviour (doing nothing, returning null)
- */
- public void destroy(Look.NodeSubstitute substitute) throws IOException {
- }
-
-
- //
- // Icon management
- //
-
- /** Allows subclasses to specify an icon in easier way without need to
- * load the actual objects.
- *
- * /resource/MyIcon
, the
- * following images may be used according to the icon state and
- * {@link java.beans.BeanInfo#getIcon presentation type}:
- *
- *
- *
- * resource/MyIcon.gif
resource/MyIconOpen.gif
- * resource/MyIcon32.gif
resource/MyIconOpen32.gif
null
if this look does not provide an icon
- */
- protected String iconBase (NodeSubstitute subst) {
- return null;
- }
-
- /** Allows subclasses to specify actions in a easy way - by providing a
- * name of a JNDI context name where to find the javax.swing.Action objects.
- *
- * org.nb.mymod.MyLook
- * the default action context is Looks/Actions/org/nb/mymod/MyLook.
- * As a result it is not necessary to override this method in many cases.
- *
- * @param subst the substitute to locate actions for
- * @param context false if getActions
was called,
- * true if getContextActions
was called
- * @return the name of a context
- */
- protected String actionBase (NodeSubstitute subst, boolean context) {
- return "Looks/Actions/" + getClass ().getName ().replace ('.', '/');
- }
-
- /** Reads actions from a JNDI context.
- * @param name of the context.
- * @return array of actions
- */
- private static Action[] actionsForContext (String name) {
- try {
- NamingEnumeration en = org.netbeans.api.naming.NamingSupport.createSFSInitialContext().listBindings (name);
- if (!en.hasMoreElements ()) {
- return null;
- }
-
- ArrayList arr = new ArrayList ();
- while (en.hasMoreElements()) {
- Binding b = (Binding)en.nextElement ();
- arr.add (b.getObject());
- }
-
- return (Action[])arr.toArray (new Action[arr.size ()]);
- } catch (NamingException ex) {
- return null;
- }
- }
-
- /** Tries to find the right icon for the iconbase.
- * @param type type of icon (from BeanInfo constants)
- * @param ib base where to scan in the array
- * @return icon or null
- */
- private Image findIcon (NodeSubstitute subst, int type, int ib) {
- String[] base = { iconBase (subst) };
- if (base[0] == null) {
- return null;
- }
-
- String res = icons[type + ib].format (base);
- Image im = Utilities.loadImage (res);
-
- if (im != null) return im;
-
- // try the first icon
- res = icons[java.beans.BeanInfo.ICON_COLOR_16x16 + ib].format (base);
-
- im = Utilities.loadImage (res);
-
- if (im != null) return im;
-
- if (ib == OPENED_ICON_BASE) {
- // try closed icon also
- return findIcon (subst, type, ICON_BASE);
- }
-
- // if still not found return default icon
- return null;
- }
-
-}
Index: openidex/looks/src/org/netbeans/spi/looks/EventTranslator.java
===================================================================
RCS file: openidex/looks/src/org/netbeans/spi/looks/EventTranslator.java
diff -N openidex/looks/src/org/netbeans/spi/looks/EventTranslator.java
--- openidex/looks/src/org/netbeans/spi/looks/EventTranslator.java 3 Dec 2002 14:12:21 -0000 1.4
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,139 +0,0 @@
-/*
- * 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 Forte for Java, Community Edition. The Initial
- * Developer of the Original Code is Sun Microsystems, Inc. Portions
- * Copyright 1997-2000 Sun Microsystems, Inc. All Rights Reserved.
- */
-
-package org.netbeans.spi.looks;
-
-import java.lang.ref.WeakReference;
-import java.lang.ref.ReferenceQueue;
-
-import org.openide.nodes.Node;
-import org.openide.util.RequestProcessor;
-
-import org.netbeans.api.looks.*;
-
-/**
- * Utility class which allows to fire events on the LookNode according
- * to events of the represented object. This class should be used as a base
- * class for EventListener registered to represented objects.
- *
- * If you really want the node is not garbage collected while the
- * represented object exists then hardreference the Node.Interior
- * from the subclass.
- *
- * The default state is to delegate all methods (i.e. the mask is set to
- * {@link #ALL_METHODS}.)
- *
- * @author Petr Hrebejk
- */
-public class FilterLook extends ProxyLook {
- /** Contains current mask of the node */
- private long mask;
-
- /** Contains the Look to delegate to. Array of one member */
- private Look[] delegate;
-
- /** Creates new filter and delegates all methods to the provided delegate
- * @param delegate The Look to delegate to.
- */
- public FilterLook (Look delegate) {
- this (delegate, ALL_METHODS);
- }
-
- /** Creates new filter look and sets its filtering
- * @param delegate look to delegate to
- * @param mask the mask to use (one of method contants)
- */
- public FilterLook (Look delegate, long mask) {
- this.delegate = new Look[] { delegate };
- this.mask = mask;
- }
-
- /** Name of the look. Composed from the name of the delegate.
- */
- public String getName () {
- return "Filter[" + delegate[0].getName ();
- }
-
- /** Display name of the look. Composed from the name of the delegate.
- */
- public String getDisplayName () {
- return NbBundle.getMessage (FilterLook.class, "LAB_Filter", delegate[0].getDisplayName ());
- }
-
- /** A method that checks whether given method should be delegated to
- * the look provided in constructor or not.
- * OR
of methods which have to be masked.
- * @return Current mask.
- */
- protected final long lookMask( long methods ) {
- mask |= methods;
- return mask;
- }
-
- /** Unmasks given methods. Adds given methods from given mask.
- * The masked methods will start to be delegated.
- * @param methods Logical OR
of methods which have to be unmasked.
- * @return Current mask.
- */
- protected final long lookUnmask( long methods ) {
- mask &= ~methods;
- return mask;
- }
-}
Index: openidex/looks/src/org/netbeans/spi/looks/NamespaceLook.java
===================================================================
RCS file: openidex/looks/src/org/netbeans/spi/looks/NamespaceLook.java
diff -N openidex/looks/src/org/netbeans/spi/looks/NamespaceLook.java
--- openidex/looks/src/org/netbeans/spi/looks/NamespaceLook.java 4 Dec 2002 09:46:03 -0000 1.8
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,196 +0,0 @@
-/*
- * 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 Forte for Java, Community Edition. The Initial
- * Developer of the Original Code is Sun Microsystems, Inc. Portions
- * Copyright 1997-2002 Sun Microsystems, Inc. All Rights Reserved.
- */
-
-package org.netbeans.spi.looks;
-
-import java.util.List;
-import java.util.Enumeration;
-
-import javax.naming.*;
-
-import org.openide.nodes.*;
-import org.openide.util.enum.*;
-
-import org.netbeans.api.looks.*;
-import java.util.ArrayList;
-
-/**
- * Searches for a look in namespace given name of context to search in
- * and a a possible set of names that should be checked.
- *
- * @author Jaroslav Tulach
- * @version 0.2
- */
-public abstract class NamespaceLook extends ProxyLook {
- /** InitialContext or NamingException depending on how we succeded to find the correct look */
- private static Object context;
-
- /** Prefix to prepend to all namespace names */
- private String prefix;
-
- /** Constructs new namespace looks with provided subspace to search
- *
- * @param prefix prefix to search, e.g. namesFor
method.
- *
- * @param method ignored
- * @param substitute the substitute which method will be called with or
- * null if we are in notification of changes and we have no substitute
- * @return the look to delegate to or null
- */
- protected final Look[] delegateTo (long method, NodeSubstitute substitute) {
- return new Look[] { findLook (
- prefix, namesFor (substitute.getRepresentedObject ()), null
- ) };
- }
-
- /** Defines the list of names that should be searched for a given
- * represented object.
- *
- *
- * org.w3c.dom.Document
.
- *
- * DefaultLooks
. You can delegate
- * to {@link #INSTANCE} instead.
- */
- public SampleLook1Hid() {
- }
-
- // Additional methods for testing ------------------------------------------
-
- public boolean getAttachToCalled() {
- boolean r = attachToCalled;
- attachToCalled = false;
- return r;
- }
-
- public boolean getSetNameCalled() {
- boolean r = setNameCalled;
- setNameCalled = false;
- return r;
- }
-
-
- public boolean getDestroyCalled() {
- boolean r = destroyCalled;
- destroyCalled = false;
- return r;
- }
-
- /*Look.NodeSubstitute getSubstituteForNode( LookNode node ) {
- return (Look.NodeSubstitute) nodes2Substitutes.get( node );
- }*/
-
- void setKeys( String[] val ) {
- keys = val;
- }
-
- // Private helper methods --------------------------------------------------
-
- private LookNode getNodeFromSubstitute( LookNode.SubstituteImpl subst ) {
- return subst.getLookNode ();
- }
-
- // Methods of look itself --------------------------------------------------
-
-
- // General methods ---------------------------------------------------------
-
- /** Sets the flag to be able to test wether the method was called. It
- * also stores the Look.NodeSubstitutes in a hash table (indexed by the
- * node to provide them by the getNodeSubstitute( Node node ) method.
- */
- public Object attachTo(Look.NodeSubstitute substitute) {
- attachToCalled = true;
- /*
- if (this.substitute != null) {
- throw new IllegalStateException ("Attaching to the same look for second time");
- }
- */
- this.substitute = substitute;
- /*
- if ( substitute instanceof LookNode.SubstituteImpl ) {
- LookNode lookNode = getNodeFromSubstitute( (LookNode.SubstituteImpl )substitute );
- nodes2Substitutes.put( lookNode, substitute );
- }
- */
-
- return null;
- }
-
- public Lookup createLookup (Look.NodeSubstitute substitute) {
- return VAL_LOOKUP;
- }
-
-
- /** A list of possible modes this look can be switched into.
- *
- * @param substitute substitute to find modes for
- * @return the Mode or null if the switching is not available
- */
- public Look[] availableLooks(Look.NodeSubstitute substitute) {
- return VAL_LOOKS;
- }
-
- // Methods for STYLE -------------------------------------------------------
-
- public String getDisplayName( Look.NodeSubstitute substitute ) {
- return VAL_DISPLAY_NAME;
- }
-
- public String getName( Look.NodeSubstitute substitute ) {
- return VAL_NAME;
- }
-
- public void setName(Look.NodeSubstitute substitute, String newName ) {
- setNameCalled = true;
- }
-
- public String getShortDescription ( Look.NodeSubstitute substitute ) {
- return VAL_SHORT_DESCRIPTION;
- }
-
- public Image getIcon( Look.NodeSubstitute substitute, int type ) {
- return VAL_ICON;
- }
-
- public Image getOpenedIcon( Look.NodeSubstitute substitute, int type ) {
- return VAL_OPENED_ICON;
- }
-
- public HelpCtx getHelpCtx( Look.NodeSubstitute substitute ) {
- return VAL_HELP_CTX;
- }
-
- // Methods for CHILDREN ----------------------------------------------------
-
- public Object[] getChildObjects(Look.NodeSubstitute substitute) {
- return keys;
- }
-
- // Methods for ACTIONS & NEW TYPES -----------------------------------------
-
- public NewType[] getNewTypes( Look.NodeSubstitute substitute ) {
- return VAL_NEW_TYPES;
- }
-
- public Action[] getActions( Look.NodeSubstitute substitute ) {
- return VAL_ACTIONS;
- }
-
- public Action[] getContextActions( Look.NodeSubstitute substitute ) {
- return VAL_CONTEXT_ACTIONS;
- }
-
- public Action getDefaultAction( Look.NodeSubstitute substitute ) {
- return VAL_DEFAULT_ACTION;
- }
-
- // Methods for PROPERTIES AND CUSTOMIZER -----------------------------------
-
- public Node.PropertySet[] getPropertySets( Look.NodeSubstitute substitute ) {
- return VAL_PROPERTY_SETS;
- }
-
- public java.awt.Component getCustomizer( Look.NodeSubstitute substitute ) {
- return VAL_CUSTOMIZER;
- }
-
- public boolean hasCustomizer( Look.NodeSubstitute substitute ) {
- return VAL_CUSTOMIZER != null;
- }
-
- // Methods for CLIPBOARD OPERATIONS ----------------------------------------
-
- public boolean canRename( Look.NodeSubstitute substitute ) {
- return true;
- }
-
- public boolean canDestroy( Look.NodeSubstitute substitute ) {
- return true;
- }
-
- public boolean canCopy( Look.NodeSubstitute substitute ) {
- return true;
- }
-
- public boolean canCut( Look.NodeSubstitute substitute ) {
- return true;
- }
-
- public PasteType[] getPasteTypes( Look.NodeSubstitute substitute, Transferable t) {
- return VAL_PASTE_TYPES;
- }
-
- public PasteType getDropType( Look.NodeSubstitute substitute, Transferable t, int action, int index) {
- return VAL_DROP_TYPE;
- }
-
- public Transferable clipboardCopy( Look.NodeSubstitute substitute ) throws IOException {
- return VAL_CLIPBOARD_COPY;
- }
-
- public Transferable clipboardCut( Look.NodeSubstitute substitute ) throws IOException {
- return VAL_CLIPBOARD_CUT;
- }
-
- public Transferable drag( Look.NodeSubstitute substitute ) throws IOException {
- return VAL_DRAG;
- }
-
- public void destroy(Look.NodeSubstitute substitute) throws IOException {
- destroyCalled = true;
- }
-
- /** The human presentable name of the look.
- * @return human presentable name
- */
- public String getDisplayName() {
- return "Disp1";
- }
-
- /** Returns name of the look. This name should identify the look.
- * @return Name of the look.
- */
- public String getName() {
- return "Name1";
- }
-
- /*
- public static class NodeSubstitute extends Look.NodeSubstitute {
-
- public Object getRepresentedObject() { return null; }
-
- public void firePropertyChange( String name, Object o, Object n ) {}
-
- public void fireNameChange( String o, String n ) {}
-
- public void fireDisplayNameChange( String o, String n ) {}
-
- public void fireShortDescriptionChange(String o, String n) {}
-
- public void fireIconChange() {}
-
- public void fireOpenedIconChange() {}
-
- public void firePropertySetsChange( Node.PropertySet[] o, Node.PropertySet[] n ) {}
-
- public void fireCookieChange() {}
-
- public void fireNodeDestroyed() {}
-
- public void refreshChildren() {}
-
- public Object getAttachedData() {
- return null;
- }
-
- }
- */
-
- private static class TestingAction extends CallableSystemAction {
-
- private String name;
-
- TestingAction( String name ) {
- super();
- this.name = name;
- }
-
- public HelpCtx getHelpCtx() {
- return null;
- }
-
- public String getName() {
- return name;
- }
-
- public void performAction() {
- }
-
- }
-
- private static class TestingAction1 extends TestingAction {
- TestingAction1( String name ) {
- super( name );
- }
- }
-
- private static class TestingAction2 extends TestingAction {
- TestingAction2( String name ) {
- super( name );
- }
- }
-
- private static class TestingAction3 extends TestingAction {
- TestingAction3( String name ) {
- super( name );
- }
- }
-
- private static class TestingAction4 extends TestingAction {
- TestingAction4( String name ) {
- super( name );
- }
- }
-
- private static class TestingAction5 extends TestingAction {
- TestingAction5( String name ) {
- super( name );
- }
- }
-}
Index: openidex/looks/test/unit/src/org/netbeans/api/looks/SampleLook2Hid.java
===================================================================
RCS file: openidex/looks/test/unit/src/org/netbeans/api/looks/SampleLook2Hid.java
diff -N openidex/looks/test/unit/src/org/netbeans/api/looks/SampleLook2Hid.java
--- openidex/looks/test/unit/src/org/netbeans/api/looks/SampleLook2Hid.java 22 Feb 2002 13:03:55 -0000 1.4
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,465 +0,0 @@
-/*
- * 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 Forte for Java, Community Edition. The Initial
- * Developer of the Original Code is Sun Microsystems, Inc. Portions
- * Copyright 1997-2000 Sun Microsystems, Inc. All Rights Reserved.
- */
-
-package org.netbeans.api.looks;
-
-import java.util.List;
-import java.awt.Image;
-import java.awt.image.BufferedImage;
-import java.awt.datatransfer.Transferable;
-import java.awt.datatransfer.StringSelection;
-import java.io.IOException;
-import java.lang.reflect.*;
-import java.util.Hashtable;
-import javax.swing.JPanel;
-import javax.swing.Action;
-
-import org.openide.nodes.*;
-import org.openide.loaders.XMLDataObject;
-import org.openide.util.actions.SystemAction;
-import org.openide.util.actions.CallableSystemAction;
-import org.openide.util.HelpCtx;
-import org.openide.util.datatransfer.NewType;
-import org.openide.util.datatransfer.PasteType;
-import org.openide.util.Lookup;
-import org.openide.util.lookup.InstanceContent;
-import org.openide.util.lookup.AbstractLookup;
-
-/** Class used for testing. Every method returns some value. Usefull for testing
- * FilterLook.
- *
- * @author Petr Hrebejk
- */
-public class SampleLook2Hid extends Look {
-
- // Flags for method calls which do not return any value.
- boolean attachToCalled = false;
- boolean setNameCalled = false;
- boolean destroyCalled = false;
-
- // The values which are returned from this Look
- static final Node.Cookie VAL_COOKIE = new Node.Cookie() {};
-
- static final Look[] VAL_LOOKS = new Look[0];
-
- static final String VAL_NAME = "Node.Name";
-
- static final String VAL_DISPLAY_NAME = "Node.DisplayName";
-
- static final String VAL_SHORT_DESCRIPTION = "Node.ShortDescription";
-
- static final String[] VAL_KEYS = new String[] {
- "Child.1",
- "Child.2"
- };
-
- static final String[] VAL_KEYS_ADDED = new String[] {
- VAL_KEYS[0],
- "Child.1.a",
- VAL_KEYS[1]
- };
-
- static final String[] VAL_KEYS_REMOVED = new String[] {
- VAL_KEYS[0],
- };
-
- static final String[] VAL_KEYS_REORDERED = new String[] {
- VAL_KEYS[1],
- VAL_KEYS[0]
- };
-
- static final String[] VAL_KEYS_NO_CHANGE = new String[] {
- VAL_KEYS[0],
- VAL_KEYS[1]
- };
-
- static final Image VAL_ICON = new BufferedImage( 16, 16, BufferedImage.TYPE_INT_RGB );
-
- static final Image VAL_OPENED_ICON = new BufferedImage( 16, 16, BufferedImage.TYPE_INT_RGB );
-
- static final HelpCtx VAL_HELP_CTX = new HelpCtx( SampleLook1Hid.class );
-
- static final SystemAction[] VAL_ACTIONS = new SystemAction[] {
- new TestingAction1( "SystemAction1" ),
- new TestingAction2( "SystemAction2" )
- };
-
- static final SystemAction[] VAL_CONTEXT_ACTIONS = new SystemAction[] {
- new TestingAction3( "ContextAction1" ),
- new TestingAction4( "ContextAction2" )
- };
-
- static final SystemAction VAL_DEFAULT_ACTION = new TestingAction5( "DefaultAction" );
-
- static final JPanel VAL_CUSTOMIZER = new JPanel();
-
- static final Node.PropertySet[] VAL_PROPERTY_SETS = new Node.PropertySet[] {
- new Sheet.Set(),
- new Sheet.Set()
- };
-
- static final NewType[] VAL_NEW_TYPES = new NewType[] {
- new NewType() {
- public void create() { }
- },
-
- new NewType() {
- public void create() { }
- }
- };
-
- static final PasteType[] VAL_PASTE_TYPES = new PasteType[] {
- new PasteType() {
- public Transferable paste() { return null; }
- },
-
- new PasteType() {
- public Transferable paste() { return null; }
- }
- };
-
- static final PasteType VAL_DROP_TYPE = new PasteType() {
- public Transferable paste() { return null; }
- };
-
- static final Transferable VAL_CLIPBOARD_COPY = new StringSelection( "ClipboardCopy" );
-
- static final Transferable VAL_CLIPBOARD_CUT = new StringSelection( "ClipboardCut" );
-
- static final Transferable VAL_DRAG = new StringSelection( "Drag" );
-
- // Hashtable which holds the relation Node - NodeSubstitute
- private Hashtable nodes2Substitutes = new Hashtable();
-
- // The value of keys which has to be returned
- private String[] keys = VAL_KEYS;
-
- /** Name of the look.
- */
- private String name;
-
- static {
- VAL_PROPERTY_SETS[0].setName("SetC");
- VAL_PROPERTY_SETS[1].setName("SetD");
- Node n = new AbstractNode(Children.LEAF);
- ((Sheet.Set)VAL_PROPERTY_SETS[0]).put(new Node.Property[] {
- new PropertySupport.ReadOnly("PropC-1", String.class, "PropertyC-1",
- "Property 1 from sheet C") {
- public Object getValue() {
- return "";
- }
- }
- });
- ((Sheet.Set)VAL_PROPERTY_SETS[0]).put(new Node.Property[] {
- new PropertySupport.ReadOnly("PropC-2", String.class, "PropertyC-2",
- "Property 2 from sheet C") {
- public Object getValue() {
- return "";
- }
- }
- });
- ((Sheet.Set)VAL_PROPERTY_SETS[1]).put(new Node.Property[] {
- new PropertySupport.ReadOnly("PropD-1", String.class, "PropertyD-1",
- "Property 1 from sheet D") {
- public Object getValue() {
- return "";
- }
- }
- });
- ((Sheet.Set)VAL_PROPERTY_SETS[1]).put(new Node.Property[] {
- new PropertySupport.ReadOnly("PropD-2", String.class, "PropertyD-2",
- "Property 1 from sheet D") {
- public Object getValue() {
- return "";
- }
- }
- });
- }
-
- /** Creates new DefaultLook. The costructor is protected, there should
- * be no need for creating new DefaultLooks
. You can delegate
- * to {@link #INSTANCE} instead.
- */
- public SampleLook2Hid() {
- }
-
- // Additional methods for testing ------------------------------------------
-
- boolean getAttachToCalled() {
- boolean r = attachToCalled;
- attachToCalled = false;
- return r;
- }
-
- boolean getSetNameCalled() {
- boolean r = setNameCalled;
- setNameCalled = false;
- return r;
- }
-
-
- boolean getDestroyCalled() {
- boolean r = destroyCalled;
- destroyCalled = false;
- return r;
- }
-
- void setKeys( String[] val ) {
- keys = val;
- }
-
- // Private helper methods --------------------------------------------------
-
- private LookNode getNodeFromSubstitute( LookNode.SubstituteImpl subst ) {
- return subst.getLookNode ();
- }
-
- // Methods of look itself --------------------------------------------------
-
-
- // General methods ---------------------------------------------------------
-
- /** Sets the flag to be able to test wether the method was called. It
- * also stores the Look.NodeSubstitutes in a hash table (indexed by the
- * node to provide them by the getNodeSubstitute( Node node ) method.
- */
- public Object attachTo(Look.NodeSubstitute substitute) {
- attachToCalled = true;
- return null;
- }
-
- public Lookup createLookup (Look.NodeSubstitute substitute) {
- InstanceContent ic = new InstanceContent ();
- AbstractLookup lookup = new AbstractLookup (ic);
- ic.add (VAL_COOKIE);
- return lookup;
- }
-
- /** A list of possible modes this look can be switched into.
- *
- * @param substitute substitute to find modes for
- * @return the Mode or null if the switching is not available
- */
- public Look[] availableLooks(Look.NodeSubstitute substitute) {
- return VAL_LOOKS;
- }
-
- // Methods for STYLE -------------------------------------------------------
-
- public String getDisplayName( Look.NodeSubstitute substitute ) {
- return VAL_DISPLAY_NAME;
- }
-
- public String getName( Look.NodeSubstitute substitute ) {
- return VAL_NAME;
- }
-
- public void setName(Look.NodeSubstitute substitute, String newName ) {
- setNameCalled = true;
- }
-
- public String getShortDescription ( Look.NodeSubstitute substitute ) {
- return VAL_SHORT_DESCRIPTION;
- }
-
- public Image getIcon( Look.NodeSubstitute substitute, int type ) {
- return VAL_ICON;
- }
-
- public Image getOpenedIcon( Look.NodeSubstitute substitute, int type ) {
- return VAL_OPENED_ICON;
- }
-
- public HelpCtx getHelpCtx( Look.NodeSubstitute substitute ) {
- return VAL_HELP_CTX;
- }
-
- // Methods for CHILDREN ----------------------------------------------------
-
- public Object[] getChildObjects(Look.NodeSubstitute substitute) {
- return keys;
- }
-
- // Methods for ACTIONS & NEW TYPES -----------------------------------------
-
- public NewType[] getNewTypes( Look.NodeSubstitute substitute ) {
- return VAL_NEW_TYPES;
- }
-
- public Action[] getActions(Look.NodeSubstitute substitute) {
- return VAL_ACTIONS;
- }
-
- public Action[] getContextActions(Look.NodeSubstitute substitute) {
- return VAL_CONTEXT_ACTIONS;
- }
-
- public
- Action getDefaultAction(Look.NodeSubstitute substitute) {
- return VAL_DEFAULT_ACTION;
- }
-
- // Methods for PROPERTIES AND CUSTOMIZER -----------------------------------
-
- public Node.PropertySet[] getPropertySets( Look.NodeSubstitute substitute ) {
- return VAL_PROPERTY_SETS;
- }
-
- public java.awt.Component getCustomizer( Look.NodeSubstitute substitute ) {
- return VAL_CUSTOMIZER;
- }
-
- public boolean hasCustomizer( Look.NodeSubstitute substitute ) {
- return VAL_CUSTOMIZER != null;
- }
-
- // Methods for CLIPBOARD OPERATIONS ----------------------------------------
-
- public boolean canRename( Look.NodeSubstitute substitute ) {
- return true;
- }
-
- public boolean canDestroy( Look.NodeSubstitute substitute ) {
- return true;
- }
-
- public boolean canCopy( Look.NodeSubstitute substitute ) {
- return true;
- }
-
- public boolean canCut( Look.NodeSubstitute substitute ) {
- return true;
- }
-
- public PasteType[] getPasteTypes( Look.NodeSubstitute substitute, Transferable t) {
- return VAL_PASTE_TYPES;
- }
-
- public PasteType getDropType( Look.NodeSubstitute substitute, Transferable t, int action, int index) {
- return VAL_DROP_TYPE;
- }
-
- public Transferable clipboardCopy( Look.NodeSubstitute substitute ) throws IOException {
- return VAL_CLIPBOARD_COPY;
- }
-
- public Transferable clipboardCut( Look.NodeSubstitute substitute ) throws IOException {
- return VAL_CLIPBOARD_CUT;
- }
-
- public Transferable drag( Look.NodeSubstitute substitute ) throws IOException {
- return VAL_DRAG;
- }
-
- public void destroy(Look.NodeSubstitute substitute) throws IOException {
- destroyCalled = true;
- }
-
- /** The human presentable name of the look.
- * @return human presentable name
- */
- public String getDisplayName() {
- return "Disp1";
- }
-
- /** Returns name of the look. This name should identify the look.
- * @return Name of the look.
- */
- public String getName() {
- return "Name1";
- }
-
- /*
- public static class NodeSubstitute extends Look.NodeSubstitute {
-
- public Object getRepresentedObject() { return null; }
-
- public void firePropertyChange( String name, Object o, Object n ) {}
-
- public void fireNameChange( String o, String n ) {}
-
- public void fireDisplayNameChange( String o, String n ) {}
-
- public void fireShortDescriptionChange(String o, String n) {}
-
- public void fireIconChange() {}
-
- public void fireOpenedIconChange() {}
-
- public void firePropertySetsChange( Node.PropertySet[] o, Node.PropertySet[] n ) {}
-
- public void fireCookieChange() {}
-
- public void fireNodeDestroyed() {}
-
- public void refreshChildren() {}
-
- public Object getAttachedData() {
- return null;
- }
-
- }*/
-
-
- private static class TestingAction extends CallableSystemAction {
-
- private String name;
-
- TestingAction( String name ) {
- super();
- this.name = name;
- }
-
- public HelpCtx getHelpCtx() {
- return null;
- }
-
- public String getName() {
- return name;
- }
-
- public void performAction() {
- }
-
- }
-
- private static class TestingAction1 extends TestingAction {
- TestingAction1( String name ) {
- super( name );
- }
- }
-
- private static class TestingAction2 extends TestingAction {
- TestingAction2( String name ) {
- super( name );
- }
- }
-
- private static class TestingAction3 extends TestingAction {
- TestingAction3( String name ) {
- super( name );
- }
- }
-
- private static class TestingAction4 extends TestingAction {
- TestingAction4( String name ) {
- super( name );
- }
- }
-
- private static class TestingAction5 extends TestingAction {
- TestingAction5( String name ) {
- super( name );
- }
- }
-}
Index: openidex/looks/test/unit/src/org/netbeans/api/looks/SubstituteAccessTest.java
===================================================================
RCS file: openidex/looks/test/unit/src/org/netbeans/api/looks/SubstituteAccessTest.java
diff -N openidex/looks/test/unit/src/org/netbeans/api/looks/SubstituteAccessTest.java
--- openidex/looks/test/unit/src/org/netbeans/api/looks/SubstituteAccessTest.java 5 Feb 2002 17:46:16 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,211 +0,0 @@
-/*
- * 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-2000 Sun
- * Microsystems, Inc. All Rights Reserved.
- */
-
-package org.netbeans.api.looks;
-
-import java.lang.ref.*;
-import java.util.*;
-
-//import junit.framework.*;
-import org.netbeans.junit.*;
-
-import java.util.List;
-import java.awt.Image;
-import java.awt.datatransfer.Transferable;
-import java.io.IOException;
-import javax.swing.Action;
-
-
-import org.openide.nodes.*;
-import org.openide.loaders.XMLDataObject;
-import org.openide.util.actions.SystemAction;
-import org.openide.util.HelpCtx;
-import org.openide.util.datatransfer.NewType;
-import org.openide.util.datatransfer.PasteType;
-
-import org.netbeans.api.looks.*;
-import org.netbeans.spi.looks.*;
-
-
-
-
-public class SubstituteAccessTest extends NbTestCase {
- public SubstituteAccessTest(java.lang.String testName) {
- super(testName);
- }
-
- public static void main(java.lang.String[] args) {
- junit.textui.TestRunner.run(new NbTestSuite (SubstituteAccessTest.class));
- }
-
- /** Checks whether substitutes are garbage collected when not needed
- * anymore.
- */
- public void testLifeCycleOfSubstitutes () {
- MyLook look = new MyLook ();
-
- for (int cnt = 0; cnt < 5; cnt++) {
-
- MySubst s1 = new MySubst (look);
- MySubst s2 = new MySubst (look);
- MySubst s3 = new MySubst (look);
-
- HashSet all = new HashSet ();
- all.add (s1);
- all.add (s2);
- all.add (s3);
-
- HashSet temp = readEnum (3, look.allSubsts ());
- assertEquals ("Both sets should be equal", all, temp);
- // empty all references
- temp.clear();
-
- // disappearing one in the middle
- WeakReference ref = new WeakReference (s2);
- all.remove (s2);
- s2 = null;
- assertGC ("Should disappear", ref);
-
- temp = readEnum (2, look.allSubsts ());
- assertEquals ("Should contain just two elements", all, temp);
- temp.clear ();
-
- ref = new WeakReference (s3);
- all.remove (s3);
- s3 = null;
- assertGC ("Should disappear II", ref);
-
- temp = readEnum (1, look.allSubsts ());
- assertEquals ("Just one element", all, temp);
- temp.clear ();
-
- ref = new WeakReference (s1);
- all.remove (s1);
- s1 = null;
- assertGC ("Should disappear III", ref);
-
- assertTrue ("Empty", !look.allSubsts ().hasMoreElements ());
- }
- }
-
- /** Tests whether substitutes are not listed when they change look.
- */
- public void testChangeOfLook () {
- MyLook one = new MyLook ();
- MyLook two = new MyLook ();
-
- MySubst s1 = new MySubst (one);
-
- assertEquals ("S1 is attached to look one", one.allSubsts ().nextElement (), s1);
- assertTrue ("look two is empty", !two.allSubsts ().hasMoreElements());
-
- s1.setLook (two);
-
- assertEquals ("S1 is attached to look two", two.allSubsts ().nextElement (), s1);
- assertTrue ("look one is empty", !one.allSubsts ().hasMoreElements());
-
- s1.setLook (one);
-
- assertEquals ("S1 is attached to look one", one.allSubsts ().nextElement (), s1);
- assertTrue ("look two is empty", !two.allSubsts ().hasMoreElements());
-
- s1.setLook (null);
-
- assertTrue ("look one is empty", !one.allSubsts ().hasMoreElements());
- assertTrue ("look two is empty", !two.allSubsts ().hasMoreElements());
- }
-
- /** Extracts content of enumeration to a set
- */
- private HashSet readEnum (int expectSize, Enumeration en) {
- HashSet set = new HashSet ();
-
- for (int i = 1; i <= expectSize; i++) {
- assertTrue ("Expecting " + i + "th element", en.hasMoreElements());
- set.add (en.nextElement ());
- }
-
- assertTrue ("There should be just " + expectSize + " elements", !en.hasMoreElements ());
-
- return set;
- }
-
- /** Do GC, waiting for ref to become null.
- */
- private void assertGC (String text, Reference ref) {
- for (int i = 0; i < 10; i++) {
- System.gc ();
- if (ref.get () == null) return;
- }
-
- assertNull (text, ref.get ());
- }
-
-
- private static final class MyLook extends DefaultLook {
-
- public MyLook () {
- super ("MyLook");
- }
-
- public String getDisplayName () {
- return "MyLook";
- }
-
- public Enumeration allSubsts () {
- return nodeSubstitutes ();
- }
- }
-
- private static final class MySubst extends Look.NodeSubstitute {
- public MySubst (Look look) {
- super.attachTo (look);
- }
-
- public void setLook (Look look) {
- super.attachTo (look);
- }
-
-
- public void fireDisplayNameChange(String o, String n) {
- }
-
- public void fireIconChange() {
- }
-
- public void fireNameChange(String o, String n) {
- }
-
- public void fireNodeDestroyed() {
- }
-
- public void fireOpenedIconChange() {
- }
-
- public void firePropertyChange(String name, Object o, Object n) {
- }
-
- public void firePropertySetsChange(Node.PropertySet[] o, Node.PropertySet[] n) {
- }
-
- public void fireShortDescriptionChange(String o, String n) {
- }
-
- public Object getRepresentedObject() {
- return null;
- }
-
- public void refreshChildren() {
- }
- }
-}
Index: openidex/looks/test/unit/src/org/netbeans/spi/looks/FilterLookTest.java
===================================================================
RCS file: openidex/looks/test/unit/src/org/netbeans/spi/looks/FilterLookTest.java
diff -N openidex/looks/test/unit/src/org/netbeans/spi/looks/FilterLookTest.java
--- openidex/looks/test/unit/src/org/netbeans/spi/looks/FilterLookTest.java 15 Sep 2002 20:23:44 -0000 1.4
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,653 +0,0 @@
-/*
- * 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 Forte for Java, Community Edition. The Initial
- * Developer of the Original Code is Sun Microsystems, Inc. Portions
- * Copyright 1997-2000 Sun Microsystems, Inc. All Rights Reserved.
- */
-
-package org.netbeans.spi.looks;
-
-import java.util.Collection;
-import java.util.List;
-import java.awt.Image;
-import java.awt.datatransfer.Transferable;
-import java.io.IOException;
-import javax.swing.Action;
-
-import org.openide.nodes.*;
-import org.openide.util.actions.SystemAction;
-import org.openide.util.HelpCtx;
-import org.openide.util.datatransfer.NewType;
-import org.openide.util.datatransfer.PasteType;
-
-import org.netbeans.api.looks.*;
-import org.netbeans.spi.looks.*;
-
-//import junit.framework.*;
-import org.netbeans.junit.*;
-
-public class FilterLookTest extends NbTestCase {
-
- private static final String MSSG_UNEXPECTED_EXCEPTION = "Unexpected exception caught : ";
-
- /** Array with masks and results */
- private TestingItem[] testingItems = new TestingItem[] {
-// new TestingItem( FilterLook.ATTACH_TO, "ATTACH_TO" ),
- new TestingItem( FilterLook.CREATE_LOOKUP, "CREATE_LOOKUP" ),
-// new TestingItem( FilterLook.GET_HANDLE, "GET_HANDLE" ),
- new TestingItem( FilterLook.GET_DISPLAY_NAME, "GET_DISPLAY_NAME" ),
- new TestingItem( FilterLook.GET_NAME, "GET_NAME" ),
- new TestingItem( FilterLook.SET_NAME, "SET_NAME" ),
- new TestingItem( FilterLook.GET_SHORT_DESCRIPTION, "GET_SHORT_DESCRIPTION" ),
- new TestingItem( FilterLook.GET_ICON, "GET_ICON" ),
- new TestingItem( FilterLook.GET_OPENED_ICON, "GET_OPENED_ICON" ),
- new TestingItem( FilterLook.GET_HELP_CTX, "GET_HELP_CTX" ),
- new TestingItem( FilterLook.GET_CHILD_OBJECTS, "GET_CHILD_OBJECTS" ),
- new TestingItem( FilterLook.GET_NEW_TYPES, "GET_NEW_TYPES" ),
- new TestingItem( FilterLook.GET_ACTIONS, "GET_ACTIONS" ),
- new TestingItem( FilterLook.GET_CONTEXT_ACTIONS, "GET_CONTEXT_ACTIONS" ),
- new TestingItem( FilterLook.GET_DEFAULT_ACTION, "GET_DEFAULT_ACTION" ),
- new TestingItem( FilterLook.GET_PROPERTY_SETS, "GET_PROPERTY_SETS" ),
- new TestingItem( FilterLook.GET_CUSTOMIZER, "GET_CUSTOMIZER" ),
- new TestingItem( FilterLook.CAN_RENAME, "CAN_RENAME" ),
- new TestingItem( FilterLook.CAN_DESTROY, "CAN_DESTROY" ),
- new TestingItem( FilterLook.CAN_COPY, "CAN_COPY" ),
- new TestingItem( FilterLook.CAN_CUT, "CAN_CUT" ),
- new TestingItem( FilterLook.GET_PASTE_TYPES, "GET_PASTE_TYPES" ),
- new TestingItem( FilterLook.GET_DROP_TYPE, "GET_DROP_TYPE" ),
- new TestingItem( FilterLook.CLIPBOARD_COPY, "CLIPBOARD_COPY" ),
- new TestingItem( FilterLook.CLIPBOARD_CUT, "CLIPBOARD_CUT" ),
- new TestingItem( FilterLook.DRAG, "DRAG" ),
- new TestingItem( FilterLook.DESTROY, "DESTROY" )
- };
-
- /** Filter look to test on */
- private FilterLook filterLook;
-
- /** Look which will be filtered */
- private SampleLook1Hid sampleLook;
-
- /** Node substitute to test on */
- private FilterLook.S substitute;
-
- /** Name to be set */
- private static final String NAME_TO_SET = "SomeName";
-
- int ICON_TYPE = 0;
-
- int OPENED_ICON_TYPE = 0;
-
- Transferable PASTE_TYPE = null;
-
- Transferable DROP_TYPE = null;
- int DROP_INDEX = 0;
- int DROP_ACTION = 0;
-
-
-
- public FilterLookTest(java.lang.String testName) {
- super(testName);
- }
-
- public static void main(java.lang.String[] args) {
- junit.textui.TestRunner.run(suite());
- }
-
- public static NbTest suite() {
- NbTestSuite suite = new NbTestSuite(FilterLookTest.class);
-
- return suite;
- }
-
- protected void setUp() throws Exception {
- super.setUp();
-
- // add specific setup code here
- sampleLook = new SampleLook1Hid();
- filterLook = new FilterLook( sampleLook );
-
-
- LookNode n = new LookNode (new Object (), sampleLook);
- assertNotNull("A substitute should be assigned", sampleLook.substitute);
-
- substitute = filterLook.new S (filterLook, sampleLook.substitute);
- }
-
- protected void tearDown() throws Exception {
- // add specific tear-down code here
- filterLook = null;
- substitute = null;
- sampleLook = null;
-
- super.tearDown();
- }
-
-
- /** Test of setLookMask method, of class org.openidex.nodes.looks.FilterLook. */
- /*
- public void testSetLookMask() {
- System.out.println("testSetLookMask");
-
- // Add your test code below by replacing the default call to fail.
- fail("The test case is empty.");
- }
- */
- /** Test of getLookMask method, of class org.openidex.nodes.looks.FilterLook. */
- /*
- public void testGetLookMask() {
- System.out.println("testGetLookMask");
-
- // Add your test code below by replacing the default call to fail.
- fail("The test case is empty.");
- }
- */
-
- /** Test of lookMask method, of class org.openidex.nodes.looks.FilterLook. */
- /*
- public void testLookMask() {
- System.out.println("testLookMask");
-
- // Add your test code below by replacing the default call to fail.
- fail("The test case is empty.");
- }
- */
-
- /** Test of lookUnmask method, of class org.openidex.nodes.looks.FilterLook. */
- /*
- public void testLookUnmask() {
- System.out.println("testLookUnmask");
-
- // Add your test code below by replacing the default call to fail.
- fail("The test case is empty.");
- }
- */
- /** Test of attachTo method, of class org.openidex.nodes.looks.FilterLook. */
- /*
- public void testAttachTo() {
- System.out.println("testAttachTo");
-
- // Add your test code below by replacing the default call to fail.
- fail("The test case is empty.");
- }
- */
-
- /** Tests whether the constants defined in the right order and whether
- * there is no owerflow.
- */
- public void testMaskOrder() {
- System.out.println("testMaskOrder");
-
- // Add your test code below by replacing the default call to fail.
-
- for ( int i = 0, j = 1; i < testingItems.length; i++ ) {
- if ( testingItems[i].mask != j ) {
- fail("Ordering failed : " + i );
- }
- j *= 2;
- }
- }
-/*
- public void test_ATTACH_TO() {
- System.out.println("test_ATTACH_TO");
-
- // Add your test code below by replacing the default call to fail.
- int failIndex = doTestingWithMask( FilterLook.ATTACH_TO );
- if ( failIndex > -1 ) {
- fail( getFailMessage( failIndex) );
- }
- }
-*/
- public void test_CREATE_LOOKUP () {
- System.out.println("test_GET_COOKIE");
-
- // Add your test code below by replacing the default call to fail.
- int failIndex = doTestingWithMask( FilterLook.CREATE_LOOKUP );
- if ( failIndex > -1 ) {
- fail( getFailMessage( failIndex ) );
- }
- }
-/*
- public void test_GET_HANDLE() {
- System.out.println("test_GET_HANDLE");
-
- // Add your test code below by replacing the default call to fail.
- int failIndex = doTestingWithMask( FilterLook.GET_HANDLE );
- if ( failIndex > -1 ) {
- fail( getFailMessage( failIndex ) );
- }
- }
-*/
- public void test_GET_DISPLAY_NAME() {
- System.out.println("test_GET_DISPLAY_NAME");
-
- // Add your test code below by replacing the default call to fail.
- int failIndex = doTestingWithMask( FilterLook.GET_DISPLAY_NAME );
- if ( failIndex > -1 ) {
- fail( getFailMessage( failIndex ) );
- }
- }
-
- public void test_GET_NAME() {
- System.out.println("test_GET_NAME");
-
- // Add your test code below by replacing the default call to fail.
- int failIndex = doTestingWithMask( FilterLook.GET_NAME );
- if ( failIndex > -1 ) {
- fail( getFailMessage( failIndex ) );
- }
- }
-
- public void test_SET_NAME() {
- System.out.println("test_SET_NAME");
-
- // Add your test code below by replacing the default call to fail.
- int failIndex = doTestingWithMask( FilterLook.SET_NAME );
- if ( failIndex > -1 ) {
- fail( getFailMessage( failIndex ) );
- }
- }
-
- public void test_GET_SHORT_DESCRIPTION () {
- System.out.println("test_GET_SHORT_DESCRIPTION");
-
- // Add your test code below by replacing the default call to fail.
- int failIndex = doTestingWithMask( FilterLook.GET_SHORT_DESCRIPTION );
- if ( failIndex > -1 ) {
- fail( getFailMessage( failIndex ) );
- }
- }
-
- public void test_GET_ICON() {
- System.out.println("test_GET_ICON");
-
- // Add your test code below by replacing the default call to fail.
- int failIndex = doTestingWithMask( FilterLook.GET_ICON );
- if ( failIndex > -1 ) {
- fail( getFailMessage( failIndex ) );
- }
- }
- public void test_GET_OPENED_ICON () {
- System.out.println("test_GET_OPENED_ICON");
-
- // Add your test code below by replacing the default call to fail.
- int failIndex = doTestingWithMask( FilterLook.GET_OPENED_ICON );
- if ( failIndex > -1 ) {
- fail( getFailMessage( failIndex ) );
- }
- }
- public void test_GET_HELP_CTX () {
- System.out.println("test_GET_HELP_CTX");
-
- // Add your test code below by replacing the default call to fail.
- int failIndex = doTestingWithMask( FilterLook.GET_HELP_CTX );
- if ( failIndex > -1 ) {
- fail( getFailMessage( failIndex ) );
- }
- }
-
- public void test_GET_CHILD_OBJECTS () {
- System.out.println("test_GET_CHILD_OBJECTS");
-
- // Add your test code below by replacing the default call to fail.
- int failIndex = doTestingWithMask( FilterLook.GET_CHILD_OBJECTS );
- if ( failIndex > -1 ) {
- fail( getFailMessage( failIndex ) );
- }
- }
-
- public void test_GET_NEW_TYPES () {
- System.out.println("test_GET_NEW_TYPES");
-
- // Add your test code below by replacing the default call to fail.
- int failIndex = doTestingWithMask( FilterLook.GET_NEW_TYPES );
- if ( failIndex > -1 ) {
- fail( getFailMessage( failIndex ) );
- }
- }
-
- public void test_GET_ACTIONS () {
- System.out.println("test_GET_ACTIONS");
-
- // Add your test code below by replacing the default call to fail.
- int failIndex = doTestingWithMask( FilterLook.GET_ACTIONS );
- if ( failIndex > -1 ) {
- fail( getFailMessage( failIndex ) );
- }
- }
-
- public void test_GET_CONTEXT_ACTIONS () {
- System.out.println("test_GET_CONTEXT_ACTIONS");
-
- // Add your test code below by replacing the default call to fail.
- int failIndex = doTestingWithMask( FilterLook.GET_CONTEXT_ACTIONS );
- if ( failIndex > -1 ) {
- fail( getFailMessage( failIndex ) );
- }
- }
-
- public void test_GET_DEFAULT_ACTION () {
- System.out.println("test_GET_DEFAULT_ACTION");
-
- // Add your test code below by replacing the default call to fail.
- int failIndex = doTestingWithMask( FilterLook.GET_DEFAULT_ACTION );
- if ( failIndex > -1 ) {
- fail( getFailMessage( failIndex ) );
- }
- }
-
- public void test_GET_PROPERTY_SETS () {
- System.out.println("test_GET_PROPERTY_SETS");
-
- // Add your test code below by replacing the default call to fail.
- int failIndex = doTestingWithMask( FilterLook.GET_PROPERTY_SETS );
- if ( failIndex > -1 ) {
- fail( getFailMessage( failIndex ) );
- }
- }
-
- public void test_GET_CUSTOMIZER () {
- System.out.println("test_GET_CUSTOMIZER");
-
- // Add your test code below by replacing the default call to fail.
- int failIndex = doTestingWithMask( FilterLook.GET_CUSTOMIZER );
- if ( failIndex > -1 ) {
- fail( getFailMessage( failIndex ) );
- }
- }
-
- public void test_CAN_RENAME () {
- System.out.println("test_CAN_RENAME");
-
- // Add your test code below by replacing the default call to fail.
- int failIndex = doTestingWithMask( FilterLook.CAN_RENAME );
- if ( failIndex > -1 ) {
- fail( getFailMessage( failIndex ) );
- }
- }
-
- public void test_CAN_DESTROY () {
- System.out.println("test_CAN_DESTROY");
-
- // Add your test code below by replacing the default call to fail.
- int failIndex = doTestingWithMask( FilterLook.CAN_DESTROY );
- if ( failIndex > -1 ) {
- fail( "Failed on method index : " + failIndex + " : " + testingItems[ failIndex ].value );
- }
- }
-
- public void test_CAN_COPY () {
- System.out.println("test_CAN_COPY");
-
- // Add your test code below by replacing the default call to fail.
- int failIndex = doTestingWithMask( FilterLook.CAN_COPY );
- if ( failIndex > -1 ) {
- fail( "Failed on method index : " + failIndex + " : " + testingItems[ failIndex ].value );
- }
- }
-
- public void test_CAN_CUT () {
- System.out.println("test_CAN_CUT");
-
- // Add your test code below by replacing the default call to fail.
- int failIndex = doTestingWithMask( FilterLook.CAN_CUT );
- if ( failIndex > -1 ) {
- fail( "Failed on method index : " + failIndex + " : " + testingItems[ failIndex ].value );
- }
- }
-
- public void test_GET_PASTE_TYPES () {
- System.out.println("test_GET_PASTE_TYPES");
-
- // Add your test code below by replacing the default call to fail.
- int failIndex = doTestingWithMask( FilterLook.GET_PASTE_TYPES );
- if ( failIndex > -1 ) {
- fail( "Failed on method index : " + failIndex + " : " + testingItems[ failIndex ].value );
- }
- }
-
- public void test_GET_DROP_TYPE () {
- System.out.println("test_GET_DROP_TYPE");
-
- // Add your test code below by replacing the default call to fail.
- int failIndex = doTestingWithMask( FilterLook.GET_DROP_TYPE );
- if ( failIndex > -1 ) {
- fail( "Failed on method index : " + failIndex + " : " + testingItems[ failIndex ].value );
- }
- }
-
- public void test_CLIPBOARD_COPY () {
- System.out.println("test_CLIPBOARD_COPY");
-
- // Add your test code below by replacing the default call to fail.
- int failIndex = doTestingWithMask( FilterLook.CLIPBOARD_COPY );
- if ( failIndex > -1 ) {
- fail( getFailMessage( failIndex ) );
- }
- }
-
- public void test_CLIPBOARD_CUT () {
- System.out.println("test_CLIPBOARD_CUT");
-
- // Add your test code below by replacing the default call to fail.
- int failIndex = doTestingWithMask( FilterLook.CLIPBOARD_CUT );
- if ( failIndex > -1 ) {
- fail( getFailMessage( failIndex ) );
- }
- }
-
- public void test_DRAG () {
- System.out.println("test_DRAG");
-
- // Add your test code below by replacing the default call to fail.
- int failIndex = doTestingWithMask( FilterLook.DRAG );
- if ( failIndex > -1 ) {
- fail( getFailMessage( failIndex ));
- }
- }
-
- public void test_DESTROY () {
- System.out.println("test_DESTROY");
-
- // Add your test code below by replacing the default call to fail.
- int failIndex = doTestingWithMask( FilterLook.DESTROY );
- if ( failIndex > -1 ) {
- fail( getFailMessage( failIndex ) );
- }
- }
-
- // Private methods ---------------------------------------------------------
-
- private int doTestingWithMask( long mask ) {
- filterLook.setLookMask( mask );
- clearTestArray();
- fillTestArray();
-
- for( int i = 0; i < testingItems.length; i ++ ) {
- if ( ( ( testingItems[i].mask & mask ) > 0 && testingItems[i].value == null ) ||
- ( ( testingItems[i].mask & mask ) == 0 && testingItems[i].value != null )) {
- return i;
- }
- }
-
- return -1;
- }
-
- private void clearTestArray() {
- for ( int i = 0; i < testingItems.length; i++ ) {
- testingItems[i].value = null;
- }
- }
-
- private void fillTestArray() {
-
- int i = 0;
-
-
- filterLook.attachTo( substitute );
- Boolean attachTo = sampleLook.getAttachToCalled( ) ? Boolean.TRUE : null;
-
- org.openide.util.Lookup lookup = filterLook.createLookup ( substitute );
-
- Object handle = filterLook.availableLooks ( substitute );
-
- String displayName = filterLook.getDisplayName( substitute );
-
- String name = filterLook.getName( substitute );
-
- filterLook.setName(substitute, NAME_TO_SET );
- String setName = sampleLook.getSetNameCalled() ? NAME_TO_SET : null;
-
- String shortDescription = filterLook.getShortDescription( substitute );
-
- Image icon = filterLook.getIcon( substitute, ICON_TYPE );
-
- Image openedIcon = filterLook.getOpenedIcon( substitute, OPENED_ICON_TYPE );
-
- HelpCtx helpCtx = filterLook.getHelpCtx( substitute );
-
- Object[] children = filterLook.getChildObjects( substitute );
-
- NewType[] newTypes = filterLook.getNewTypes( substitute );
-
- Action[] systemActions = filterLook.getActions( substitute );
-
- Action[] contextActions = filterLook.getContextActions( substitute );
-
- Action defaultAction = filterLook.getDefaultAction( substitute );
-
- Node.PropertySet[] propertySets = filterLook.getPropertySets( substitute );
-
- java.awt.Component customizer = filterLook.getCustomizer( substitute );
-
- Boolean canRename = filterLook.canRename( substitute ) ? Boolean.TRUE : null;
-
- Boolean canDestroy = filterLook.canDestroy( substitute )? Boolean.TRUE : null;
-
- Boolean canCopy = filterLook.canCopy( substitute )? Boolean.TRUE : null;
-
- Boolean canCut = filterLook.canCut( substitute )? Boolean.TRUE : null;
-
- PasteType[] pasteTypes = filterLook.getPasteTypes( substitute, PASTE_TYPE );
-
- PasteType dropType = filterLook.getDropType( substitute, DROP_TYPE, DROP_ACTION, DROP_INDEX );
- Transferable copy = null;
- try {
- copy = filterLook.clipboardCopy( substitute );
- }
- catch ( java.io.IOException e ) {
- fail( MSSG_UNEXPECTED_EXCEPTION + e );
- }
- Transferable cut = null;
- try {
- cut = filterLook.clipboardCut( substitute );
- }
- catch ( java.io.IOException e ) {
- fail( MSSG_UNEXPECTED_EXCEPTION + e );
- }
- Transferable drag = null;
- try {
- drag = filterLook.drag( substitute );
- }
- catch ( java.io.IOException e ) {
- fail( MSSG_UNEXPECTED_EXCEPTION + e );
- }
- Boolean destroy = null;
- try {
- filterLook.destroy( substitute );
- destroy = sampleLook.getDestroyCalled() ? Boolean.TRUE : null;
- }
- catch ( java.io.IOException e ) {
- fail( MSSG_UNEXPECTED_EXCEPTION + e );
- }
-
-
-// testingItems[i].value = attachTo;
-// i++;
- testingItems[i].value = lookup;
- i++;
-// testingItems[i].value = handle;
-// i++;
- testingItems[i].value = displayName;
- i++;
- testingItems[i].value = name;
- i++;
- testingItems[i].value = setName;
- i++;
- testingItems[i].value = shortDescription;
- i++;
- testingItems[i].value = icon;
- i++;
- testingItems[i].value = openedIcon;
- i++;
- testingItems[i].value = helpCtx;
- i++;
- testingItems[i].value = children;
- i++;
- testingItems[i].value = newTypes;
- i++;
- testingItems[i].value = systemActions;
- i++;
- testingItems[i].value = contextActions;
- i++;
- testingItems[i].value = defaultAction;
- i++;
- testingItems[i].value = propertySets;
- i++;
- testingItems[i].value = customizer;
- i++;
- testingItems[i].value = canRename;
- i++;
- testingItems[i].value = canDestroy;
- i++;
- testingItems[i].value = canCopy;
- i++;
- testingItems[i].value = canCut;
- i++;
- testingItems[i].value = pasteTypes;
- i++;
- testingItems[i].value = dropType;
- i++;
- testingItems[i].value = copy;
- i++;
- testingItems[i].value = cut;
- i++;
- testingItems[i].value = drag;
- i++;
- testingItems[i].value = destroy;
- i++;
-
- }
-
- private String getFailMessage( int failIndex ) {
- return "Failed on method index : " + failIndex + " : " +
- testingItems[ failIndex ].name + " = " +
- testingItems[ failIndex ].value;
- }
-
- // Innerclasses ------------------------------------------------------------
-
- /** Represents one item in the test array.
- */
- private class TestingItem {
-
- private long mask;
-
- private Object value;
-
- private String name;
-
-
- TestingItem( long mask, String name ) {
- this.mask = mask;
- this.name = name;
- }
-
- }
-
-}
Index: openidex/looks/test/unit/src/org/netbeans/spi/looks/NamespaceLookTest.java
===================================================================
RCS file: openidex/looks/test/unit/src/org/netbeans/spi/looks/NamespaceLookTest.java
diff -N openidex/looks/test/unit/src/org/netbeans/spi/looks/NamespaceLookTest.java
--- openidex/looks/test/unit/src/org/netbeans/spi/looks/NamespaceLookTest.java 5 Mar 2002 07:51:25 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,122 +0,0 @@
-/*
- * 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 Forte for Java, Community Edition. The Initial
- * Developer of the Original Code is Sun Microsystems, Inc. Portions
- * Copyright 1997-2000 Sun Microsystems, Inc. All Rights Reserved.
- */
-
-package org.netbeans.spi.looks;
-
-import java.lang.reflect.*;
-import java.util.*;
-import java.awt.*;
-import java.awt.datatransfer.Transferable;
-import java.io.IOException;
-import javax.swing.Action;
-
-import org.openide.nodes.*;
-import org.openide.util.actions.SystemAction;
-import org.openide.util.HelpCtx;
-import org.openide.util.datatransfer.NewType;
-import org.openide.util.datatransfer.PasteType;
-import org.openide.util.Lookup;
-
-import org.netbeans.api.looks.*;
-import org.netbeans.spi.looks.*;
-
-import org.netbeans.junit.*;
-import java.beans.PropertyChangeListener;
-
-/**
- *
- * @author Jaroslav Tulach
- */
-public class NamespaceLookTest extends NbTestCase {
-
- public NamespaceLookTest (java.lang.String testName) {
- super(testName);
- }
-
- public static void main(java.lang.String[] args) {
- junit.textui.TestRunner.run(new NbTestSuite (NamespaceLookTest.class));
- }
-
- /** For object an object is found.
- */
- public void testObjectIsFound () {
- Enumeration en = new L ().names (new Object ());
- assertClass ("Object is found", Object.class, en.nextElement ());
- assertTrue ("No more items", !en.hasMoreElements());
- }
-
- /** Test that the default namespace look works correctly on a hierarchy
- * of objects.
- */
- public void testInterfaceBeforeObject () {
- class O extends Object implements Runnable {
- public void run () {};
- }
-
- Enumeration en = new L ().names (new O ());
- assertClass ("Actual class is allways first", O.class, en.nextElement ());
- assertClass ("Interface takes precedence", Runnable.class, en.nextElement());
- assertClass ("Object is the last fallback", Object.class, en.nextElement ());
- assertTrue ("No more items", !en.hasMoreElements());
- }
-
- /** All interfaces are introspected.
- */
- public void testAllInterfacesAreChecked () {
- // Action is a interface that extends another interface
- class O extends Object implements javax.swing.Action {
- public void actionPerformed (java.awt.event.ActionEvent ev) {}
- public Object getValue (String s) { return null; }
- public void putValue (String s, Object o) {}
- public void setEnabled (boolean b) {}
- public boolean isEnabled () { return false; }
- public void addPropertyChangeListener (PropertyChangeListener l) {}
- public void removePropertyChangeListener (PropertyChangeListener l) {}
- }
-
- Enumeration en = new L ().names (new O ());
- assertClass ("Actual class is always first", O.class, en.nextElement ());
- assertClass ("It implements Action interface", javax.swing.Action.class, en.nextElement ());
- assertClass ("And the interfaces extends ActionListener", java.awt.event.ActionListener.class, en.nextElement ());
- assertClass ("ActionListener is a listener", java.util.EventListener.class, en.nextElement ());
- assertClass ("Last is as usually Object", Object.class, en.nextElement ());
- assertTrue ("And we are done", !en.hasMoreElements ());
-
- }
-
- /** Asserts name of class with a name in a namespace
- */
- private static final void assertClass (String txt, Class c, Object obj) {
- assertEquals (txt, c.getName ().replace ('.', '/'), obj);
- }
-
-
- /** Innerclass to get access to namesFor method */
- private static final class L extends NamespaceLook {
- public L () {
- super ("");
- }
-
- public String getName () {
- return "";
- }
- public String getDisplayName () {
- return "";
- }
-
- public Enumeration names (Object obj) {
- return namesFor (obj);
- }
-
- }
-}
Index: openidex/looks/test/unit/src/org/netbeans/spi/looks/ProxyLookTest.java
===================================================================
RCS file: openidex/looks/test/unit/src/org/netbeans/spi/looks/ProxyLookTest.java
diff -N openidex/looks/test/unit/src/org/netbeans/spi/looks/ProxyLookTest.java
--- openidex/looks/test/unit/src/org/netbeans/spi/looks/ProxyLookTest.java 22 Feb 2002 13:03:55 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,980 +0,0 @@
-/*
- * 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 Forte for Java, Community Edition. The Initial
- * Developer of the Original Code is Sun Microsystems, Inc. Portions
- * Copyright 1997-2000 Sun Microsystems, Inc. All Rights Reserved.
- */
-
-package org.netbeans.spi.looks;
-
-import java.lang.reflect.*;
-import java.util.*;
-import java.awt.*;
-import java.awt.datatransfer.Transferable;
-import java.io.IOException;
-import javax.swing.Action;
-
-import org.openide.nodes.*;
-import org.openide.util.actions.SystemAction;
-import org.openide.util.HelpCtx;
-import org.openide.util.datatransfer.NewType;
-import org.openide.util.datatransfer.PasteType;
-import org.openide.util.Lookup;
-
-import org.netbeans.api.looks.*;
-import org.netbeans.spi.looks.*;
-
-import org.netbeans.junit.*;
-/**
- *
- * @author Svata Dedic
- */
-public class ProxyLookTest extends NbTestCase {
- static final Object DATA = new Object();
-
- /**
- * The Look being tested
- */
- Prx look;
-
- MySubst mySubst;
-
- Look.NodeSubstitute proxySubst;
-
- ProxyDel[] maskDelegates;
-
- Object[] customData;
-
- Object[] actualDelegateData;
-
- Look.NodeSubstitute[] delegateSubsts;
-
- int delegateCount;
- /**
- * Delegates, which will be returned from delegateTo
- */
- Look[] forceDelegates;
-
- Method substAccessor;
-
- int testedMethodIndex = -1;
-
- String fakeName;
-
- static final int FAKE = 39;
-
- /** Creates a new instance of ProxyLookTest */
- public ProxyLookTest(String n) {
- super(n);
- }
-
- public String name() {
- if (fakeName != null)
- return fakeName;
- else
- return super.name();
- }
-
- public void setUp() {
- look = new Prx();
- setupDelegates();
- }
-
- public void tearDown() {
- }
-
- public static void main(java.lang.String[] args) {
- junit.textui.TestRunner.run(suite());
- }
-
- public static NbTest suite() {
- NbTestSuite suite = new NbTestSuite(ProxyLookTest.class);
- return suite;
- }
-
- private void setupDelegates() {
- maskDelegates = new ProxyDel[40];
- customData = new Object[40];
- delegateSubsts = new Look.NodeSubstitute[40];
- int count = 0;
- Look del = new SampleLook1Hid();
- for (int i = 1; i <= ProxyLook.HAS_CUSTOMIZER; i <<= 1, count++) {
- maskDelegates[count] = new ProxyDel(del, count, 1 << count, customData[count] = new Object());
- }
- delegateCount = count;
- mySubst = new MySubst(look);
- }
-
- /**
- * Tests whether the createData was called
- */
- public void testProxySubstitute() {
- assertSame("Incorrect substitute on the proxy look", mySubst, proxySubst);
- }
-
- /**
- * Tests whether the createData was called
- */
- public void testCreateData() {
- if (!look.createCalled) {
- fail("Create was not called");
- }
- }
-
- /**
- * Checks whether there are correct data attached to the Look.
- */
- public void testOwnAttachedData() {
- if (look.getAttachedData(mySubst) != DATA) {
- fail("ProxyLook got incorrect attached data");
- }
- }
-
- public void testDelegateSubstitutes() {
- forceDelegates = maskDelegates;
- look.delAll = true;
- Object[] children = look.getChildObjects(mySubst);
- for (int i = 0; i < delegateCount; i++) {
- assertNotNull("Delegate " + maskDelegates[i] + " reported null substitute",
- delegateSubsts[i]);
- // check the substitute the ProxyLook knows is
- // the same as reported by the delegate
- assertSame("ProxyLook recorded incorrect substitute for " + maskDelegates[i],
- getSubstitute(mySubst, maskDelegates[i], i), delegateSubsts[i]);
- }
- }
-
- public void testDelegateAttachedData() {
- forceDelegates = maskDelegates;
- actualDelegateData = new Object[delegateCount];
- look.delAll = true;
- Object[] x = look.getChildObjects(mySubst);
- for (int i = 0; i < delegateCount; i++) {
- assertSame("Attached data mismatch for delegate " + maskDelegates[i],
- actualDelegateData[i], customData[i]);
- }
- }
-
- public void testCanCopy() {
- ProxyDel del = createDelegate(ProxyLook.CAN_COPY);
- boolean b = look.canCopy(mySubst);
- assertTrue("Incorrect value", b);
- ensureQueried(ProxyLook.CAN_COPY, getIndex(ProxyLook.CAN_COPY));
- assertTrue("Fake delegate queried", del.queried == 0);
- }
-
- public void testCanCut() {
- ProxyDel del = createDelegate(ProxyLook.CAN_CUT);
- boolean b = look.canCut(mySubst);
- assertTrue("Incorrect value", b);
- ensureQueried(ProxyLook.CAN_CUT, getIndex(ProxyLook.CAN_CUT));
- assertTrue("Fake delegate queried", del.queried == 0);
- }
-
- public void testCanDestroy() {
- ProxyDel del = createDelegate(ProxyLook.CAN_DESTROY);
- boolean b = look.canDestroy(mySubst);
- assertTrue("Incorrect value", b);
- ensureQueried(ProxyLook.CAN_DESTROY, getIndex(ProxyLook.CAN_DESTROY));
- assertTrue("Fake delegate queried", del.queried == 0);
- }
-
- public void testCanRename() {
- ProxyDel del = createDelegate(ProxyLook.CAN_RENAME);
- boolean b = look.canRename(mySubst);
- assertTrue("Incorrect value", b);
- ensureQueried(ProxyLook.CAN_RENAME, getIndex(ProxyLook.CAN_RENAME));
- assertTrue("Fake delegate queried", del.queried == 0);
- }
-
- public void testClipboardCut() {
- ProxyDel del = createDelegate(ProxyLook.CLIPBOARD_CUT);
- try {
- Transferable t = look.clipboardCut(mySubst);
- int index = getIndex(ProxyLook.CLIPBOARD_CUT);
- assertSame("Incorrect transferable: ", t,
- maskDelegates[index].clipboardCut(delegateSubsts[index]));
- ensureQueried(ProxyLook.CLIPBOARD_CUT, index);
- assertTrue("Fake delegate queried", del.queried == 0);
- } catch (IOException ex) {
- fail(ex.getMessage());
- }
- }
-
- public void testDrag() {
- ProxyDel del = createDelegate(ProxyLook.DRAG);
- try {
- Transferable t = look.drag(mySubst);
- int index = getIndex(ProxyLook.DRAG);
- assertSame("Incorrect transferable: ", t,
- maskDelegates[index].drag(delegateSubsts[index]));
- ensureQueried(ProxyLook.DRAG, index);
- assertTrue("Fake delegate queried", del.queried == 0);
- } catch (IOException ex) {
- fail(ex.getMessage());
- }
- }
-
- public void testClipboardCopy() {
- ProxyDel del = createDelegate(ProxyLook.CLIPBOARD_COPY);
- try {
- Transferable t = look.clipboardCopy(mySubst);
- int index = getIndex(ProxyLook.CLIPBOARD_COPY);
- assertSame("Incorrect transferable: ", t,
- maskDelegates[index].clipboardCopy(delegateSubsts[index]));
- ensureQueried(ProxyLook.CLIPBOARD_COPY, index);
- assertTrue("Fake delegate queried", del.queried == 0);
- } catch (IOException ex) {
- fail(ex.getMessage());
- }
- }
-
- public void testGetCustomizer() {
- ProxyDel del = createDelegate(ProxyLook.GET_CUSTOMIZER);
- Component c = look.getCustomizer(mySubst);
- int index = getIndex(ProxyLook.GET_CUSTOMIZER);
- assertSame("Incorrect customizer", c,
- maskDelegates[index].getCustomizer(delegateSubsts[index]));
- ensureQueried(ProxyLook.GET_CUSTOMIZER, index);
- assertTrue("Fake delegate queried", del.queried == 0);
- }
-
- public void testGetDefaultAction() {
- ProxyDel del = createDelegate(ProxyLook.GET_DEFAULT_ACTION);
- Object n = look.getDefaultAction(mySubst);
- int index = getIndex(ProxyLook.GET_DEFAULT_ACTION);
- assertSame(maskDelegates[index].getDefaultAction(delegateSubsts[index]), n);
- assertTrue("Fake delegate queried", del.queried == 0);
- }
-
- public void testGetName() {
- ProxyDel del = createDelegate(ProxyLook.GET_NAME);
- String n = look.getName(mySubst);
- int index = getIndex(ProxyLook.GET_NAME);
- assertEquals(maskDelegates[index].getName(delegateSubsts[index]), n);
- assertTrue("Fake delegate queried", del.queried == 0);
- }
-
- public void testGetDisplayName() {
- ProxyDel del = createDelegate(ProxyLook.GET_DISPLAY_NAME);
- String n = look.getDisplayName(mySubst);
- int index = getIndex(ProxyLook.GET_DISPLAY_NAME);
- assertEquals(maskDelegates[index].getDisplayName(delegateSubsts[index]), n);
- assertTrue("Fake delegate queried", del.queried == 0);
- }
-
- public void testGetShortDescription() {
- ProxyDel del = createDelegate(ProxyLook.GET_SHORT_DESCRIPTION);
- String n = look.getShortDescription(mySubst);
- int index = getIndex(ProxyLook.GET_SHORT_DESCRIPTION);
- assertEquals(maskDelegates[index].getShortDescription(delegateSubsts[index]), n);
- assertTrue("Fake delegate queried", del.queried == 0);
- }
-
- public void testGetDropType() {
- ProxyDel del = createDelegate(ProxyLook.GET_DROP_TYPE);
- PasteType t = look.getDropType(mySubst, null, 0, 0);
- int index = getIndex(ProxyLook.GET_DROP_TYPE);
- assertSame(maskDelegates[index].getDropType(delegateSubsts[index], null, 0, 0),
- t);
- assertTrue("Fake delegate queried", del.queried == 0);
- }
-
- public void testGetIcon() {
- ProxyDel del = createDelegate(ProxyLook.GET_ICON);
- int index = getIndex(ProxyLook.GET_ICON);
- assertSame(maskDelegates[index].getIcon(delegateSubsts[index], 0), look.getIcon(mySubst, 0));
- assertTrue("Fake delegate queried", del.queried == 0);
- }
-
- public void testGetOpenedIcon() {
- ProxyDel del = createDelegate(ProxyLook.GET_OPENED_ICON);
- int index = getIndex(ProxyLook.GET_OPENED_ICON);
- assertSame(maskDelegates[index].getOpenedIcon(delegateSubsts[index], 0), look.getOpenedIcon(mySubst, 0));
- assertTrue("Fake delegate queried", del.queried == 0);
- }
-
- public void testDestroy() {
- try {
- look.destroy(mySubst);
- for (int i = 0; i < delegateCount; i++) {
- assertTrue("Destroy not called on #" + i,
- (maskDelegates[i].queried & ProxyLook.DESTROY) > 0);
- }
- } catch (IOException ex) {
- fail(ex.getMessage());
- }
- }
-
- public void testGetActions() {
- int index = getIndex(ProxyLook.GET_ACTIONS);
- ProxyDel del;
- ProxyDel first = maskDelegates[index];
- Object[] result;
-
- maskDelegates[index] = null;
- result = look.getActions(mySubst);
- assertNull(result);
- maskDelegates[index] = first;
-
- del = createDelegate(ProxyLook.GET_ACTIONS);
- result = look.getActions(mySubst);
- Object[] expected = first.getActions(delegateSubsts[index]);
- assertEquals(Arrays.asList(expected), Arrays.asList(result));
- }
-
- public void testGetAllActions() {
- int index = getIndex(ProxyLook.GET_ACTIONS);
- look.delAll = true;
-
- // check that no response will yield an empty array:
- ProxyDel del;
- Object[] result;
-
- del = maskDelegates[index];
- maskDelegates[index] = null;
- result = look.getActions(mySubst);
- assertNull(result);
- maskDelegates[index] = del;
-
- result = look.getActions(mySubst);
- Object[] expected1 = del.getActions(delegateSubsts[index]);
- // exactly one Look providing an action
- assertEquals(expected1.length, result.length);
- assertEquals(Arrays.asList(expected1), Arrays.asList(result));
- ensureQueried(ProxyLook.GET_ACTIONS, delegateCount);
-
- // test merge from two Looks
- del = createDelegate(ProxyLook.GET_ACTIONS);
-
- ProxyDel first = maskDelegates[index];
- result = look.getActions(mySubst);
- expected1 = first.getActions(delegateSubsts[index]);
- Object[] expected2 = del.getActions(delegateSubsts[delegateCount]);
- assertEquals(expected1.length
- + expected2.length,
- result.length);
- Collection c = new ArrayList(Arrays.asList(expected1));
- c.addAll(Arrays.asList(expected2));
- assertEquals(c, Arrays.asList(result));
- }
-
- public void testGetChildObjects() {
- int index = getIndex(ProxyLook.GET_CHILD_OBJECTS);
- ProxyDel del;
- ProxyDel first = maskDelegates[index];
- Object[] result;
-
- maskDelegates[index] = null;
- result = look.getChildObjects(mySubst);
- assertNull(result);
- maskDelegates[index] = first;
-
- del = createDelegate(ProxyLook.GET_CHILD_OBJECTS);
- result = look.getChildObjects(mySubst);
- Object[] expected = first.getChildObjects(delegateSubsts[index]);
- assertEquals(Arrays.asList(expected), Arrays.asList(result));
- }
-
- public void testGetAllChildObjects() {
- int index = getIndex(ProxyLook.GET_CHILD_OBJECTS);
- look.delAll = true;
-
- // check that no response will yield an empty array:
- ProxyDel del;
- Object[] result;
-
- del = maskDelegates[index];
- maskDelegates[index] = null;
- result = look.getChildObjects(mySubst);
- assertNull(result);
- maskDelegates[index] = del;
-
- result = look.getChildObjects(mySubst);
- Object[] expected1 = del.getChildObjects(delegateSubsts[index]);
- // exactly one Look providing an action
- assertEquals(expected1.length, result.length);
- assertEquals(Arrays.asList(expected1), Arrays.asList(result));
- ensureQueried(ProxyLook.GET_CHILD_OBJECTS, delegateCount);
-
- // test merge from two Looks
- del = createDelegate(ProxyLook.GET_CHILD_OBJECTS);
-
- ProxyDel first = maskDelegates[index];
- result = look.getChildObjects(mySubst);
- expected1 = first.getChildObjects(delegateSubsts[index]);
- Object[] expected2 = del.getChildObjects(delegateSubsts[delegateCount]);
- assertEquals(expected1.length
- + expected2.length,
- result.length);
- Collection c = new ArrayList(Arrays.asList(expected1));
- c.addAll(Arrays.asList(expected2));
- assertEquals(c, Arrays.asList(result));
- }
-
- public void testGetContextActions() {
- int index = getIndex(ProxyLook.GET_CONTEXT_ACTIONS);
- ProxyDel del;
- ProxyDel first = maskDelegates[index];
- Object[] result;
-
- maskDelegates[index] = null;
- result = look.getContextActions(mySubst);
- assertNull(result);
- maskDelegates[index] = first;
-
- del = createDelegate(ProxyLook.GET_CONTEXT_ACTIONS);
- result = look.getContextActions(mySubst);
- Object[] expected = first.getContextActions(delegateSubsts[index]);
- assertEquals(Arrays.asList(expected), Arrays.asList(result));
- }
-
- public void testGetAllContextActions() {
- int index = getIndex(ProxyLook.GET_CONTEXT_ACTIONS);
- look.delAll = true;
-
- // check that no response will yield an empty array:
- ProxyDel del;
- Object[] result;
-
- del = maskDelegates[index];
- maskDelegates[index] = null;
- result = look.getContextActions(mySubst);
- assertNull(result);
- maskDelegates[index] = del;
-
- result = look.getContextActions(mySubst);
- Object[] expected1 = del.getContextActions(delegateSubsts[index]);
- // exactly one Look providing an action
- assertEquals(expected1.length, result.length);
- assertEquals(Arrays.asList(expected1), Arrays.asList(result));
- ensureQueried(ProxyLook.GET_CONTEXT_ACTIONS, delegateCount);
-
- // test merge from two Looks
- del = createDelegate(ProxyLook.GET_CONTEXT_ACTIONS);
-
- ProxyDel first = maskDelegates[index];
- result = look.getContextActions(mySubst);
- expected1 = first.getContextActions(delegateSubsts[index]);
- Object[] expected2 = del.getContextActions(delegateSubsts[delegateCount]);
- assertEquals(expected1.length
- + expected2.length,
- result.length);
- Collection c = new ArrayList(Arrays.asList(expected1));
- c.addAll(Arrays.asList(expected2));
- assertEquals(c, Arrays.asList(result));
- }
-
- public void testGetPasteTypes() {
- int index = getIndex(ProxyLook.GET_PASTE_TYPES);
- ProxyDel del;
- ProxyDel first = maskDelegates[index];
- Object[] result;
-
- maskDelegates[index] = null;
- result = look.getPasteTypes(mySubst, null);
- assertNull(result);
- maskDelegates[index] = first;
-
- del = createDelegate(ProxyLook.GET_PASTE_TYPES);
- result = look.getPasteTypes(mySubst, null);
- Object[] expected = first.getPasteTypes(delegateSubsts[index], null);
- assertEquals(Arrays.asList(expected), Arrays.asList(result));
- }
-
- public void testGetAllPasteTypes() {
- int index = getIndex(ProxyLook.GET_PASTE_TYPES);
- look.delAll = true;
-
- // check that no response will yield an empty array:
- ProxyDel del;
- Object[] result;
-
- del = maskDelegates[index];
- maskDelegates[index] = null;
- result = look.getPasteTypes(mySubst, null);
- assertNull(result);
- maskDelegates[index] = del;
-
- result = look.getPasteTypes(mySubst, null);
- Object[] expected1 = del.getPasteTypes(delegateSubsts[index], null);
- // exactly one Look providing an action
- assertEquals(expected1.length, result.length);
- assertEquals(Arrays.asList(expected1), Arrays.asList(result));
- ensureQueried(ProxyLook.GET_PASTE_TYPES, delegateCount);
-
- // test merge from two Looks
- del = createDelegate(ProxyLook.GET_PASTE_TYPES);
-
- ProxyDel first = maskDelegates[index];
- result = look.getPasteTypes(mySubst, null);
- expected1 = first.getPasteTypes(delegateSubsts[index], null);
- Object[] expected2 = del.getPasteTypes(delegateSubsts[delegateCount], null);
- assertEquals(expected1.length
- + expected2.length,
- result.length);
- Collection c = new ArrayList(Arrays.asList(expected1));
- c.addAll(Arrays.asList(expected2));
- assertEquals(c, Arrays.asList(result));
- }
-
-
- public void testGetNewTypes() {
- int index = getIndex(ProxyLook.GET_NEW_TYPES);
- ProxyDel del;
- ProxyDel first = maskDelegates[index];
- Object[] result;
-
- maskDelegates[index] = null;
- result = look.getNewTypes(mySubst);
- assertNull(result);
- maskDelegates[index] = first;
-
- del = createDelegate(ProxyLook.GET_NEW_TYPES);
- result = look.getNewTypes(mySubst);
- Object[] expected = first.getNewTypes(delegateSubsts[index]);
- assertEquals(Arrays.asList(expected), Arrays.asList(result));
- }
-
- public void testGetAllNewTypes() {
- int index = getIndex(ProxyLook.GET_NEW_TYPES);
- look.delAll = true;
-
- // check that no response will yield an empty array:
- ProxyDel del;
- Object[] result;
-
- del = maskDelegates[index];
- maskDelegates[index] = null;
- result = look.getNewTypes(mySubst);
- assertNull(result);
- maskDelegates[index] = del;
-
- result = look.getNewTypes(mySubst);
- Object[] expected1 = del.getNewTypes(delegateSubsts[index]);
- // exactly one Look providing an action
- assertEquals(expected1.length, result.length);
- assertEquals(Arrays.asList(expected1), Arrays.asList(result));
- ensureQueried(ProxyLook.GET_NEW_TYPES, delegateCount);
-
- // test merge from two Looks
- del = createDelegate(ProxyLook.GET_NEW_TYPES);
-
- ProxyDel first = maskDelegates[index];
- result = look.getNewTypes(mySubst);
- expected1 = first.getNewTypes(delegateSubsts[index]);
- Object[] expected2 = del.getNewTypes(delegateSubsts[delegateCount]);
- assertEquals(expected1.length
- + expected2.length,
- result.length);
- Collection c = new ArrayList(Arrays.asList(expected1));
- c.addAll(Arrays.asList(expected2));
- assertEquals(c, Arrays.asList(result));
- }
-
- public void testGetPropertySets() {
- int index = getIndex(ProxyLook.GET_PROPERTY_SETS);
- ProxyDel del;
- ProxyDel first = maskDelegates[index];
- Object[] result;
-
- maskDelegates[index] = null;
- result = look.getPropertySets(mySubst);
- assertNull(result);
- maskDelegates[index] = first;
-
- del = createDelegate(ProxyLook.GET_PROPERTY_SETS);
- result = look.getPropertySets(mySubst);
- Object[] expected = first.getPropertySets(delegateSubsts[index]);
- assertEquals(Arrays.asList(expected), Arrays.asList(result));
- }
-
- public void testGetAllPropertySets() {
- int index = getIndex(ProxyLook.GET_PROPERTY_SETS);
- look.delAll = true;
-
- // check that no response will yield an empty array:
- ProxyDel del;
- Object[] result;
-
- del = maskDelegates[index];
- maskDelegates[index] = null;
- result = look.getPropertySets(mySubst);
- assertNull(result);
- maskDelegates[index] = del;
-
- result = look.getPropertySets(mySubst);
- Object[] expected1 = del.getPropertySets(delegateSubsts[index]);
- // exactly one Look providing an action
- assertEquals(expected1.length, result.length);
- assertEquals(Arrays.asList(expected1), Arrays.asList(result));
- ensureQueried(ProxyLook.GET_PROPERTY_SETS, delegateCount);
-
- // test merge from two Looks
- del = createDelegate(ProxyLook.GET_PROPERTY_SETS);
-
- ProxyDel first = maskDelegates[index];
- result = look.getPropertySets(mySubst);
- expected1 = first.getPropertySets(delegateSubsts[index]);
- Object[] expected2 = del.getPropertySets(delegateSubsts[delegateCount]);
- assertEquals(expected1.length
- + expected2.length,
- result.length);
- Collection c = new ArrayList(Arrays.asList(expected1));
- c.addAll(Arrays.asList(expected2));
- assertEquals(c, Arrays.asList(result));
- }
-
- public void testGetDuplicatePropertySets() {
- int index = getIndex(ProxyLook.GET_PROPERTY_SETS);
- look.delAll = true;
-
- // check that no response will yield an empty array:
- ProxyDel del;
- Object[] result;
- Object[] expected1;
-
- maskDelegates[0] = maskDelegates[index];
-
- // test merge from two Looks
- del = createDelegate(ProxyLook.GET_PROPERTY_SETS);
-
- ProxyDel first = maskDelegates[index];
- result = look.getPropertySets(mySubst);
- expected1 = first.getPropertySets(delegateSubsts[index]);
- Object[] expected2 = del.getPropertySets(delegateSubsts[delegateCount]);
- assertEquals(expected1.length
- + expected2.length,
- result.length);
- Collection c = new ArrayList(Arrays.asList(expected1));
- c.addAll(Arrays.asList(expected2));
- assertEquals(c, Arrays.asList(result));
-}
-
- private void ensureQueried(long mask, int lastIndex) {
- int end = lastIndex == -1 ? maskDelegates.length : lastIndex;
- for (int index = 0; index <= end; index++) {
- if (maskDelegates[index] == null)
- continue;
- assertTrue("Delegate #" + index + " not queried",
- (maskDelegates[index].queried & mask) > 0);
- }
- }
-
- private int getIndex(long mask) {
- int i = 0;
- while (mask > 1) {
- mask >>= 1;
- i++;
- }
- return i;
- }
-
- private ProxyDel createDelegate(long mask) {
- Look del = new SampleLook2Hid();
- ProxyDel p = new ProxyDel(del, delegateCount, mask, null);
- maskDelegates[delegateCount] = p;
- return p;
- }
-
- Look.NodeSubstitute getSubstitute(Look.NodeSubstitute s, Look l, int index) {
- try {
- if (substAccessor == null) {
- substAccessor = ProxyLook.class.getDeclaredMethod(
- "s", new Class[] {
- Look.NodeSubstitute.class, Look.class, Integer.TYPE
- });
- substAccessor.setAccessible(true);
- }
- return (Look.NodeSubstitute)substAccessor.invoke(look, new Object[] {
- s, l, new Integer(index)
- });
- } catch (Exception ex) {
- fail("Unexpected exception: " + ex.getMessage());
- return null;
- }
- }
-
- class ProxyDel extends Look {
- long mask;
- Look del;
- int index;
- NodeSubstitute substitute;
- Object data;
- long queried;
-
- ProxyDel(Look delegate, int index, long mask, Object data) {
- this.index = index;
- this.mask = mask;
- this.del = delegate;
- this.data = data;
- }
-
- protected Object createAttachedData(NodeSubstitute s) {
- if (s == null) {
- assertNotNull(s);
- }
- delegateSubsts[index] = s;
- return data;
- }
-
- boolean isEnabled(long action) {
- return (mask & action) > 0;
- }
-
- public boolean canCopy(Look.NodeSubstitute substitute) {
- queried |= ProxyLook.CAN_COPY;
- return isEnabled(ProxyLook.CAN_COPY) ?
- del.canCopy(substitute) : false;
- }
-
- public boolean canCut(Look.NodeSubstitute substitute) {
- queried |= ProxyLook.CAN_CUT;
- return isEnabled(ProxyLook.CAN_CUT) ?
- del.canCut(substitute) : false;
- }
-
- public boolean canDestroy(Look.NodeSubstitute substitute) {
- queried |= ProxyLook.CAN_DESTROY;
- return isEnabled(ProxyLook.CAN_DESTROY) ?
- del.canDestroy(substitute) : false;
- }
-
- public boolean canRename(Look.NodeSubstitute substitute) {
- queried |= ProxyLook.CAN_RENAME;
- return isEnabled(ProxyLook.CAN_RENAME) ?
- del.canRename(substitute) : false;
- }
-
- public Transferable clipboardCopy(Look.NodeSubstitute substitute) throws IOException {
- queried |= ProxyLook.CLIPBOARD_COPY;
- return isEnabled(ProxyLook.CLIPBOARD_COPY) ?
- del.clipboardCopy(substitute) : null;
- }
-
- public Transferable clipboardCut(Look.NodeSubstitute substitute) throws IOException {
- queried |= ProxyLook.CLIPBOARD_CUT;
- return isEnabled(ProxyLook.CLIPBOARD_CUT) ?
- del.clipboardCut(substitute) : null;
- }
-
- public Lookup createLookup(Look.NodeSubstitute substitute) {
- queried |= ProxyLook.CREATE_LOOKUP;
- return isEnabled(ProxyLook.CREATE_LOOKUP) ?
- del.createLookup(substitute) : null;
- }
-
- public void destroy(Look.NodeSubstitute substitute) throws IOException {
- queried |= ProxyLook.DESTROY;
- if (isEnabled(ProxyLook.DESTROY))
- del.destroy(substitute);
- }
-
- public Transferable drag(Look.NodeSubstitute substitute) throws IOException {
- queried |= ProxyLook.DRAG;
- return isEnabled(ProxyLook.DRAG) ?
- del.drag(substitute) : null;
- }
-
- public Action[] getActions(Look.NodeSubstitute substitute) {
- queried |= ProxyLook.GET_ACTIONS;
- return isEnabled(ProxyLook.GET_ACTIONS) ?
- del.getActions(substitute) : null;
- }
-
- public Object[] getChildObjects(Look.NodeSubstitute substitute) {
- queried |= ProxyLook.GET_CHILD_OBJECTS;
- // for testing purposes --
- if (actualDelegateData != null) {
- actualDelegateData[index] = getAttachedData(substitute);
- }
- return isEnabled(ProxyLook.GET_CHILD_OBJECTS) ?
- del.getChildObjects(substitute) : null;
- }
-
- public Action[] getContextActions(Look.NodeSubstitute substitute) {
- queried |= ProxyLook.GET_CONTEXT_ACTIONS;
- return isEnabled(ProxyLook.GET_CONTEXT_ACTIONS) ?
- del.getContextActions(substitute) : null;
- }
-
- public java.awt.Component getCustomizer(Look.NodeSubstitute substitute) {
- queried |= ProxyLook.GET_CUSTOMIZER;
- return isEnabled(ProxyLook.GET_CUSTOMIZER) ?
- del.getCustomizer(substitute) : null;
- }
-
- public Action getDefaultAction(Look.NodeSubstitute substitute) {
- queried |= ProxyLook.GET_DEFAULT_ACTION;
- return isEnabled(ProxyLook.GET_DEFAULT_ACTION) ?
- del.getDefaultAction(substitute) : null;
- }
-
- public String getDisplayName() {
- return "Proxy Delegate (" + mask + ")";
- }
-
- public String getDisplayName(Look.NodeSubstitute substitute) {
- queried |= ProxyLook.GET_DISPLAY_NAME;
- return isEnabled(ProxyLook.GET_DISPLAY_NAME) ?
- del.getDisplayName(substitute) : null;
- }
-
- public PasteType getDropType(Look.NodeSubstitute substitute, Transferable t, int action, int index) {
- queried |= ProxyLook.GET_DROP_TYPE;
- return isEnabled(ProxyLook.GET_DROP_TYPE) ?
- del.getDropType(substitute, t, action, index) : null;
- }
-
- public HelpCtx getHelpCtx(Look.NodeSubstitute substitute) {
- queried |= ProxyLook.GET_HELP_CTX;
- return isEnabled(ProxyLook.GET_HELP_CTX) ?
- del.getHelpCtx(substitute) : null;
- }
-
- public Image getIcon(Look.NodeSubstitute substitute, int type) {
- queried |= ProxyLook.GET_ICON;
- return isEnabled(ProxyLook.GET_ICON) ?
- del.getIcon(substitute, type) : null;
- }
-
- public String getName() {
- return "ProxyDelegate(" + mask + ")";
- }
-
- public String getName(Look.NodeSubstitute substitute) {
- queried |= ProxyLook.GET_NAME;
- return isEnabled(ProxyLook.GET_NAME) ?
- del.getName(substitute) : null;
- }
-
- public NewType[] getNewTypes(Look.NodeSubstitute substitute) {
- queried |= ProxyLook.GET_NEW_TYPES;
- return isEnabled(ProxyLook.GET_NEW_TYPES) ?
- del.getNewTypes(substitute) : null;
- }
-
- public Image getOpenedIcon(Look.NodeSubstitute substitute, int type) {
- queried |= ProxyLook.GET_OPENED_ICON;
- return isEnabled(ProxyLook.GET_OPENED_ICON) ?
- del.getOpenedIcon(substitute, type) : null;
- }
-
- public PasteType[] getPasteTypes(Look.NodeSubstitute substitute, Transferable t) {
- queried |= ProxyLook.GET_PASTE_TYPES;
- return isEnabled(ProxyLook.GET_PASTE_TYPES) ?
- del.getPasteTypes(substitute, t) : null;
- }
-
- public Node.PropertySet[] getPropertySets(Look.NodeSubstitute substitute) {
- queried |= ProxyLook.GET_PROPERTY_SETS;
- return isEnabled(ProxyLook.GET_PROPERTY_SETS) ?
- del.getPropertySets(substitute) : null;
- }
-
- public String getShortDescription(Look.NodeSubstitute substitute) {
- queried |= ProxyLook.GET_SHORT_DESCRIPTION;
- return isEnabled(ProxyLook.GET_SHORT_DESCRIPTION) ?
- del.getShortDescription(substitute) : null;
- }
-
- public boolean hasCustomizer(Look.NodeSubstitute substitute) {
- queried |= ProxyLook.HAS_CUSTOMIZER;
- return isEnabled(ProxyLook.HAS_CUSTOMIZER) ?
- del.hasCustomizer(substitute) : false;
- }
-
- public void setName(Look.NodeSubstitute substitute, String newName) {
- queried |= ProxyLook.SET_NAME;
- if (isEnabled(ProxyLook.SET_NAME))
- del.setName(substitute, newName);
- }
-
- public Look[] availableLooks(Look.NodeSubstitute substitute) {
- return null;
- }
-
- public String toString() {
- return Integer.toString(index);
- }
- }
-
- class Prx extends ProxyLook {
- boolean createCalled = false;
- long delegateMask;
- boolean delAll;
-
- protected Object createAttachedData(NodeSubstitute s) {
- proxySubst = s;
- createCalled = true;
- return DATA;
- }
-
- protected boolean delegateAll(long mask, NodeSubstitute s) {
- return delAll;
- }
-
- public String getDisplayName() {
- return "Test look";
- }
-
- public String getName() {
- return "TestName";
- }
-
- public Look[] delegateTo(long method, NodeSubstitute s) {
- delegateMask |= method;
- if (forceDelegates != null)
- return forceDelegates;
- return maskDelegates;
- }
- }
-
- private static final class MySubst extends Look.NodeSubstitute {
- public MySubst(Look look) {
- super.attachTo(look);
- }
-
- public void setLook(Look look) {
- super.attachTo(look);
- }
-
-
- public void fireDisplayNameChange(String o, String n) {
- }
-
- public void fireIconChange() {
- }
-
- public void fireNameChange(String o, String n) {
- }
-
- public void fireNodeDestroyed() {
- }
-
- public void fireOpenedIconChange() {
- }
-
- public void firePropertyChange(String name, Object o, Object n) {
- }
-
- public void firePropertySetsChange(Node.PropertySet[] o, Node.PropertySet[] n) {
- }
-
- public void fireShortDescriptionChange(String o, String n) {
- }
-
- public Object getRepresentedObject() {
- return null;
- }
-
- public void refreshChildren() {
- }
- }
-}
Index: openidex/src/org/openidex/nodes/looks/AcceptorLook.java
===================================================================
RCS file: openidex/src/org/openidex/nodes/looks/AcceptorLook.java
diff -N openidex/src/org/openidex/nodes/looks/AcceptorLook.java
--- openidex/src/org/openidex/nodes/looks/AcceptorLook.java 3 Dec 2002 14:12:22 -0000 1.5
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,360 +0,0 @@
-/*
- * 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 Forte for Java, Community Edition. The Initial
- * Developer of the Original Code is Sun Microsystems, Inc. Portions
- * Copyright 1997-2000 Sun Microsystems, Inc. All Rights Reserved.
- */
-
-package org.openidex.nodes.looks;
-
-import java.awt.Image;
-import java.awt.datatransfer.Transferable;
-import java.io.IOException;
-
-import org.openide.nodes.*;
-import org.openide.util.actions.SystemAction;
-import org.openide.util.HelpCtx;
-import org.openide.util.datatransfer.NewType;
-import org.openide.util.datatransfer.PasteType;
-
-/** Helper class to provide values only for some type of nodes.
- * If the method boolean accept( Node node ) returns true the call
- * is delegated to the delegate Look. If not the call is delegated to
- * {@link DefaultLook#ISTANCE} interface returns a netutral value.
- *
- *
- * Please don't use this API for other purposes than testing.
- * setName()
on all sblooks.
- * @param node The node to operate on.
- */
- public void setName(Look.NodeSubstitute substitute, String newName) {
- for ( Iterator it = iterator(); it.hasNext(); ) {
- Look look = (Look)it.next();
- look.setName( substitute, newName );
- }
- }
-
-
- /** Finds the short description for given node among the sublooks.
- * @param node The node to operate on.
- * @return Fisrt shortdescriprion found.
- */
- public String getShortDescription ( Look.NodeSubstitute substitute ) {
- for ( Iterator it = iterator(); it.hasNext(); ) {
- Look look = (Look)it.next();
-
- String shortDescription = look.getShortDescription( substitute );
- if ( shortDescription != null ) {
- return shortDescription;
- }
- }
- return null;
- }
-
- /** Finds closed state icon among the sublooks.
- * @param node The node to operate on.
- * @param type Type of the icon as specified in BeanInfo
- * @return The first closed state icon found.
- */
- public Image getIcon( Look.NodeSubstitute substitute, int type ) {
- for ( Iterator it = iterator(); it.hasNext(); ) {
- Look look = (Look)it.next();
-
- Image icon = look.getIcon( substitute, type );
- if ( icon != null ) {
- return icon;
- }
- }
- return null;
- }
-
- /** Finds opened state icon among the sublooks.
- * @param node The node to operate on.
- * @param type Type of the icon as specified in BeanInfo
- * @return The first closed state icon found.
- */
- public Image getOpenedIcon( Look.NodeSubstitute substitute, int type ) {
- for ( Iterator it = iterator(); it.hasNext(); ) {
- Look look = (Look)it.next();
-
- Image openedIcon = look.getOpenedIcon( substitute, type );
- if ( openedIcon != null ) {
- return openedIcon;
- }
- }
- return null;
- }
-
- /** Finds the HelpCtx for given node among the sublooks.
- * @param node The node to operate on.
- * @return The first HelpCtx found.
- */
- public HelpCtx getHelpCtx( Look.NodeSubstitute substitute ) {
- for ( Iterator it = iterator(); it.hasNext(); ) {
- Look look = (Look)it.next();
-
- HelpCtx helpCtx = look.getHelpCtx( substitute );
- if ( helpCtx != null ) {
- return helpCtx;
- }
- }
- return null;
- }
-
- // Methods for CHILDREN ----------------------------------------------------
-
- /** Acxcumulated child objects for given node. The objects are merged from
- * all the sublooks. The ordering is the same as ordering of the sublooks.
- * @param node The node to operate on.
- * @return Merged array of all child objects of the node (of object
- * represented by the node).
- */
- public Object[] getChildObjects(Look.NodeSubstitute substitute) {
- ArrayList arrays = new ArrayList();
- int count = 0;
-
- // Create list of subarrays
- for( Iterator it = iterator(); it.hasNext(); ) {
- Look look = (Look)it.next();
-
- Object childKeys[] = look.getChildObjects( substitute );
- if ( childKeys.length == 0 ) {
- continue;
- }
- else if ( !mergeLast && !it.hasNext() && count > 0 ) {
- break; // if we don't merge stop if this is last look
- }
- else {
- count += childKeys.length;
- arrays.add( childKeys );
- }
- }
-
- if ( count == 0 ) {
- // Return if there is nothing to merge
- return Look.NO_KEYS;
- }
-
- // Merge the result and return it
- Object allChildKeys[] = new Object[ count ];
- int i = 0;
- for( Iterator it = arrays.iterator(); it.hasNext(); ) {
- Object[] array = (Object[])it.next();
- System.arraycopy( array, 0,
- allChildKeys, i, array.length );
- i += array.length;
- }
-
- return allChildKeys;
- }
-
- /* Not implemented yet
-
- public Ordering getOrdering( Look.NodeSubstitute substitute ) {
- return null;
- }
-
- public Filter getFilter( Look.NodeSubstitute substitute ) {
- return null;
- }
-
- public Grouping getGrouping( Look.NodeSubstitute substitute ) {
- return null;
- }
-
- */
-
- // Methods for ACTIONS & NEW TYPES -----------------------------------------
-
- /** Merges all possible NewTypes from the sublooks. The ordering is the same
- * as ordering of the sublooks.
- * @param node The node to operate on.
- * @return Merged array of NewTypes.
- */
- public NewType[] getNewTypes( Look.NodeSubstitute substitute ) {
- ArrayList arrays = new ArrayList();
- int count = 0;
-
- // Create list of subarrays
- for( Iterator it = iterator(); it.hasNext(); ) {
- Look look = (Look)it.next();
-
- NewType newTypes[] = look.getNewTypes( substitute );
- if ( newTypes.length == 0 ) {
- continue;
- }
- else if ( !mergeLast && !it.hasNext() && count > 0 ) {
- break; // We don't want to merge the last sublook
- }
- else {
- count += newTypes.length;
- arrays.add( newTypes );
- }
- }
-
- if ( count == 0 ) {
- // Return if there is nothing to merge
- return Look.NO_NEW_TYPES;
- }
-
- // Merge the result and return it
- NewType allNewTypes[] = new NewType[ count ];
- int i = 0;
- for( Iterator it = arrays.iterator(); it.hasNext(); ) {
- NewType[] array = (NewType[]) it.next();
- System.arraycopy( array, 0,
- allNewTypes, i, array.length );
- i += array.length;
- }
- return allNewTypes;
- }
-
- /** Merges all actions applicable to the node ffrom all subloks. The
- * ordering is the same as ordering of the sublooks.
- * @param node The node to operate on.
- * @return Merged array of all actions.
- */
- public SystemAction[] getActions( Look.NodeSubstitute substitute ) {
- ArrayList arrays = new ArrayList();
- int count = 0;
-
- // Create list of subarrays
- for( Iterator it = iterator(); it.hasNext(); ) {
- Look look = (Look)it.next();
-
- SystemAction actions[] = look.getActions( substitute );
- if ( actions.length == 0 ) {
- continue;
- }
- else if ( !mergeLast && !it.hasNext() && count > 0 ) {
- break; // We don't want to merge the last sublook
- }
- else {
- count += actions.length;
- arrays.add( actions );
- }
- }
-
- if ( count == 0 ) {
- // Return if there is nothing to merge
- return Look.NO_SYSTEM_ACTIONS;
- }
-
- // Merge the result and return it
- SystemAction allActions[] = new SystemAction[ count ];
- int i = 0;
- for( Iterator it = arrays.iterator(); it.hasNext(); ) {
- SystemAction[] array = (SystemAction[]) it.next();
- System.arraycopy( array, 0,
- allActions, i, array.length );
- i += array.length;
- }
- return allActions;
- }
-
- /** Merges all context actionss from the sublooks. The ordering is the same
- * as ordering of the sublooks.
- * @param node The node to operate on.
- * @return Merged array of context actions.
- */
- public SystemAction[] getContextActions( Look.NodeSubstitute substitute ) {
- ArrayList arrays = new ArrayList();
- int count = 0;
-
- // Create list of subarrays
- for( Iterator it = iterator(); it.hasNext(); ) {
- Look look = (Look)it.next();
-
- SystemAction contextActions[] = look.getContextActions( substitute );
- if ( contextActions.length == 0 ) {
- continue;
- }
- else if ( !mergeLast && !it.hasNext() && count > 0 ) {
- break; // We don't want to merge the last sublook
- }
- count += contextActions.length;
- arrays.add( contextActions );
- }
-
- if ( count == 0 ) {
- // Return if there is nothing to merge
- return Look.NO_SYSTEM_ACTIONS;
- }
-
- // Merge the result and return it
- SystemAction allContextActions[] = new SystemAction[ count ];
- int i = 0;
- for( Iterator it = arrays.iterator(); it.hasNext(); ) {
- SystemAction[] array = (SystemAction[]) it.next();
- System.arraycopy( array, 0,
- allContextActions, i, array.length );
- i += array.length;
- }
- return allContextActions;
- }
-
- /** Finds default action for given node among the sublooks.
- * @param node The node to operate on.
- * @return The first default action found.
- */
- public SystemAction getDefaultAction( Look.NodeSubstitute substitute ) {
- for ( Iterator it = iterator(); it.hasNext(); ) {
- Look look = (Look)it.next();
-
- SystemAction systemAction = look.getDefaultAction( substitute );
- if ( systemAction != null ) {
- return systemAction;
- }
- }
- return null;
- }
-
- // Methods for PROPERTIES AND CUSTOMIZER -----------------------------------
-
- /** Merged property sets. The sets are mered in the order as they ar found
- * among the sublooks. If there is more than one set with the same name then
- * properties in that set are merged with respect to the ordering of the
- * sublooks.
- * @param node The node to operate on.
- * @return Merged property sets.
- */
- public Node.PropertySet[] getPropertySets( Look.NodeSubstitute substitute ) {
-
- ArrayList setsList = new ArrayList();
- Hashtable nameMap = new Hashtable();
-
- // Create list of property sets and the name map
- for( Iterator it = iterator(); it.hasNext(); ) {
- Look look = (Look)it.next();
-
- Node.PropertySet[] sets = look.getPropertySets( substitute );
- if ( sets.length == 0 ) {
- continue; // Look does not provide any properties
- }
- else if ( !mergeLast && !it.hasNext() && setsList.size() > 0 ) { // if we don't merge stop after first look
- break; // we don't want to merge the last look
- }
-
-
- // Merge the property sets. We use sheet sets for
- // more comfortable work with propertySets
- for ( int i = 0; i < sets.length; i++ ) {
- if ( sets[i].getName() == null ) {
- continue; // Ignore unnamed lists
- }
- Sheet.Set es = (Sheet.Set)nameMap.get( sets[i].getName() );
- if ( es == null ) { //Such sheet does not exist yet
- es = new Sheet.Set( );
- es.setName( sets[i].getName() );
- es.setDisplayName( sets[i].getDisplayName() );
- es.setShortDescription( sets[i].getShortDescription() );
- es.put( sets[i].getProperties() );
- Enumeration en = sets[i].attributeNames ();
- while (en.hasMoreElements ()) {
- String attr = (String)en.nextElement ();
- es.setValue (attr, sets[i].getValue (attr));
- }
- setsList.add( es );
- nameMap.put( sets[i].getName(), es );
- }
- else { // Sheet exists => merge properties
- Node.Property[] props = sets[i].getProperties();
- if ( props == null || props.length == 0 ) {
- continue;
- }
- else {
- es.put( sets[i].getProperties() );
- }
- }
- }
- }
-
- if ( setsList.size() == 0 ) {
- return Look.NO_PROPERTY_SETS;
- }
- else {
- Node.PropertySet[] result = new Node.PropertySet[ setsList.size() ];
- setsList.toArray( result );
- return result;
- }
-
- }
-
- /** Finds the customizer among the sublooks.
- * @param node The node to operate on.
- * @return First customizer found among the sublooks.
- */
- public java.awt.Component getCustomizer( Look.NodeSubstitute substitute ) {
- for ( Iterator it = iterator(); it.hasNext(); ) {
- Look look = (Look)it.next();
-
- java.awt.Component customizer = look.getCustomizer( substitute );
- if ( customizer != null ) {
- return customizer;
- }
- }
- return null;
- }
-
- // Methods for CLIPBOARD OPERATIONS ----------------------------------------
-
- /** Figures out whether some look is capable of renaming given node.
- * @param node The node to operate on.
- * @return False if all sublooks return false, true otherwise.
- */
- public boolean canRename( Look.NodeSubstitute substitute ) {
- for ( Iterator it = iterator(); it.hasNext(); ) {
- Look look = (Look)it.next();
-
- if ( look.canRename( substitute ) ) {
- return true;
- }
- }
- return false;
- }
-
- /** Figures out whether some look is capable of destroying given node.
- * @param node The node to operate on.
- * @return False if all sublooks return false, true otherwise.
- */
- public boolean canDestroy( Look.NodeSubstitute substitute ) {
- for ( Iterator it = iterator(); it.hasNext(); ) {
- Look look = (Look)it.next();
-
- if ( look.canDestroy( substitute ) ) {
- return true;
- }
- }
- return false;
- }
-
- /** Figures out whether some look is capable of copying given node.
- * @param node The node to operate on.
- * @return False if all sublooks return false, true otherwise.
- */
- public boolean canCopy( Look.NodeSubstitute substitute ) {
- for ( Iterator it = iterator(); it.hasNext(); ) {
- Look look = (Look)it.next();
-
- if ( look.canCopy( substitute ) ) {
- return true;
- }
- }
- return false;
- }
-
- /** Figures out whether some look is capable of cutting given node.
- * @param node The node to operate on.
- * @return False if all sublooks return false, true otherwise.
- */
- public boolean canCut( Look.NodeSubstitute substitute ) {
- for ( Iterator it = iterator(); it.hasNext(); ) {
- Look look = (Look)it.next();
-
- if ( look.canCut( substitute ) ) {
- return true;
- }
- }
- return false;
- }
-
- /** Merges all pastetypes for given node.
- * @param node The node to operate on.
- * @param t The tranferable
- * @return Merged array of paste types.
- */
- public PasteType[] getPasteTypes( Look.NodeSubstitute substitute, Transferable t) {
- ArrayList arrays = new ArrayList();
- int count = 0;
-
- // Create list of subarrays
- for( Iterator it = iterator(); it.hasNext(); ) {
- Look look = (Look)it.next();
-
- PasteType pasteTypes[] = look.getPasteTypes( substitute, t );
- if ( pasteTypes.length == 0 ) {
- continue;
- }
- else if ( !mergeLast && !it.hasNext() && count > 0 ) { // if we don't merge stop after first look
- break; // We don't want to merge the last sublook
- }
- else {
- count += pasteTypes.length;
- arrays.add( pasteTypes );
- }
- }
-
- if ( count == 0 ) {
- // Return if there is nothing to merge
- return Look.NO_PASTE_TYPES;
- }
-
- // Merge the result and return it
- PasteType allPasteTypes[] = new PasteType[ count ];
- int i = 0;
- for( Iterator it = arrays.iterator(); it.hasNext(); ) {
- PasteType[] array = (PasteType[]) it.next();
- System.arraycopy( array, 0,
- allPasteTypes, i, array.length );
- i += array.length;
- }
- return allPasteTypes;
- }
-
- /** Determine if there is a look capable of the paste operation that can
- * be performed on provided transferable. Used by drag'n'drop code to
- * check whether the drop is possible.
- * @param node The node to operate on.
- * @param t The transferable.
- * @param action The drag'n'drop action to do DnDConstants.ACTION_MOVE,
- * ACTION_COPY, ACTION_LINK.
- * @param index Index between children the drop occured at or -1 if not specified.
- * @return Null
if no look can accept the transferable or the paste type
- * to execute when the drop occures.
- */
- public PasteType getDropType( Look.NodeSubstitute substitute, Transferable t, int action, int index) {
- for ( Iterator it = iterator(); it.hasNext(); ) {
- Look look = (Look)it.next();
-
- PasteType pasteType = look.getDropType( substitute, t, action, index );
- if ( pasteType != null ) {
- return pasteType;
- }
- }
- return null;
- }
-
- /** Notifies all sublooks that the node was copyied to the clipboard until
- * some look does not return a tranfrable.
- * @param node The node to operate on.
- * @return The transferable object representing the content of the clipboard.
- * @throws IOException When the copy cannot be performed.
- */
- public Transferable clipboardCopy( Look.NodeSubstitute substitute ) throws IOException {
- for ( Iterator it = iterator(); it.hasNext(); ) {
- Look look = (Look)it.next();
-
- Transferable transferable = look.clipboardCopy( substitute );
- if ( transferable != null ) {
- return transferable;
- }
- }
- return null;
- }
-
- /** Notifies all sublooks that the node was cutted to the clipboard until
- * some look does not return a tranfrable.
- * @param node The node to operate on.
- * @throws IOException When the cut cannot be performed.
- * @return The transferable object representing the content of the clipboard.
- */
- public Transferable clipboardCut( Look.NodeSubstitute substitute ) throws IOException {
- for ( Iterator it = iterator(); it.hasNext(); ) {
- Look look = (Look)it.next();
-
- Transferable transferable = look.clipboardCut( substitute );
- if ( transferable != null ) {
- return transferable;
- }
- }
- return null;
- }
-
- /** Notifies all sublooks that the node was dragged until some look does not
- * return a tranfrable.
- * @param node The node to operate on.
- * @throws IOException If a drag cannot be started.
- * @return Transferable to represent this node during a drag.
- */
- public Transferable drag( Look.NodeSubstitute substitute ) throws IOException {
- for ( Iterator it = iterator(); it.hasNext(); ) {
- Look look = (Look)it.next();
-
- Transferable transferable = look.drag( substitute );
- if ( transferable != null ) {
- return transferable;
- }
- }
- return null;
- }
-
- /** Calls destroy()
on all sublooks.
- * @param substitute Node.Interior of the destroyed ndoe.
- */
- public void destroy(Look.NodeSubstitute substitute) throws IOException{
- for ( Iterator it = iterator(); it.hasNext(); ) {
- Look look = (Look)it.next();
-
- look.destroy( substitute );
- }
- }
-
-}
Index: openidex/src/org/openidex/nodes/looks/DefaultLook.java
===================================================================
RCS file: openidex/src/org/openidex/nodes/looks/DefaultLook.java
diff -N openidex/src/org/openidex/nodes/looks/DefaultLook.java
--- openidex/src/org/openidex/nodes/looks/DefaultLook.java 3 Dec 2002 14:12:22 -0000 1.5
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,289 +0,0 @@
-/*
- * 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 Forte for Java, Community Edition. The Initial
- * Developer of the Original Code is Sun Microsystems, Inc. Portions
- * Copyright 1997-2000 Sun Microsystems, Inc. All Rights Reserved.
- */
-
-package org.openidex.nodes.looks;
-
-import java.awt.Image;
-import java.awt.datatransfer.Transferable;
-import java.io.IOException;
-
-import org.openide.nodes.*;
-import org.openide.util.actions.SystemAction;
-import org.openide.util.HelpCtx;
-import org.openide.util.datatransfer.NewType;
-import org.openide.util.datatransfer.PasteType;
-
-/** WARNING - This API is not finished and is subject to change
- * Please don't use this API for other purposes than testing.
- * DefaultLook
. This
- * instance can be used to delegate to.
- */
- public static final DefaultLook INSTANCE = new DefaultLook();
-
- /** Creates new DefaultLook. The costructor is protected, there should
- * be no need for creating new DefaultLook
s. You can delegate
- * to {@link #INSTANCE} instead.
- */
- protected DefaultLook() {
- }
-
- // Methods of look itself --------------------------------------------------
-
-
- // General methods ---------------------------------------------------------
-
- /** Empty - simply returns.
- * @param substitute The parameter is ignored.
- */
- public void attachTo(Look.NodeSubstitute substitute) {
- }
-
- /** Returns neutral value.
- * @param substitute The parameter is ignored.
- * @param substitute The parameter is ignored.
- * @return Neutral value - null
.
- */
- public Node.Cookie getCookie( Look.NodeSubstitute substitute, Class type) {
- return null;
- }
-
- /** Returns neutral value.
- * @param substitute The parameter is ignored.
- * @return Neutral value - null
.
- */
- public Node.Handle getHandle( Look.NodeSubstitute substitute ) {
- return null;
- }
-
- // Methods for STYLE -------------------------------------------------------
-
- /** Returns neutral value.
- * @param substitute The parameter is ignored.
- * @return Neutral value - null
.
- */
- public String getDisplayName( Look.NodeSubstitute substitute ) {
- return null;
- }
-
- /** Returns neutral value.
- * @param substitute The parameter is ignored.
- * @return Neutral value - null
.
- */
- public String getName( Look.NodeSubstitute substitute ) {
- return null;
- }
-
- /** Does nothing - empty implementation.
- * @param substitute The parameter is ignored.
- * @param newName The parameter is ignored.
- */
- public void setName(Look.NodeSubstitute substitute, String newName ) {
- }
-
- /** Returns neutral value.
- * @param substitute The parameter is ignored.
- * @return Neutral value - null
.
- */
- public String getShortDescription ( Look.NodeSubstitute substitute ) {
- return null;
- }
-
- /** Returns neutral value.
- * @param substitute The parameter is ignored.
- * @param substitute The parameter is ignored.
- * @return Neutral value - null
.
- */
- public Image getIcon( Look.NodeSubstitute substitute, int type ) {
- return null;
- }
-
- /** Returns neutral value.
- * @param substitute The parameter is ignored.
- * @param substitute The parameter is ignored.
- * @return Neutral value - null
.
- */
- public Image getOpenedIcon( Look.NodeSubstitute substitute, int type ) {
- return null;
- }
-
- /** Returns neutral value.
- * @param substitute The parameter is ignored.
- * @return Neutral value - null
.
- */
- public HelpCtx getHelpCtx( Look.NodeSubstitute substitute ) {
- return null;
- }
-
- // Methods for CHILDREN ----------------------------------------------------
-
- /** Returns neutral value.
- * @param substitute The parameter is ignored.
- * @return Neutral value - {@link Look#NO_KEYS}.
- */
- public Object[] getChildObjects(Look.NodeSubstitute substitute) {
- return Look.NO_KEYS;
- }
-
- // Methods for ACTIONS & NEW TYPES -----------------------------------------
-
- /** Returns neutral value.
- * @param substitute The parameter is ignored.
- * @return Neutral value - {@link Look#NO_NEW_TYPES}.
- */
- public NewType[] getNewTypes( Look.NodeSubstitute substitute ) {
- return Look.NO_NEW_TYPES;
- }
-
- /** Returns neutral value.
- * @param substitute The parameter is ignored.
- * @return Neutral value - {@link Look#NO_SYSTEM_ACTIONS}.
- */
- public SystemAction[] getActions( Look.NodeSubstitute substitute ) {
- return Look.NO_SYSTEM_ACTIONS;
- }
-
- /** Returns neutral value.
- * @param substitute The parameter is ignored.
- * @return Neutral value - {@link Look#NO_SYSTEM_ACTIONS}.
- */
- public SystemAction[] getContextActions( Look.NodeSubstitute substitute ) {
- return Look.NO_SYSTEM_ACTIONS;
- }
-
- /** Returns neutral value.
- * @param substitute The parameter is ignored.
- * @return Neutral value - null
.
- */
- public SystemAction getDefaultAction( Look.NodeSubstitute substitute ) {
- return null;
- }
-
- // Methods for PROPERTIES AND CUSTOMIZER -----------------------------------
-
- /** Returns neutral value.
- * @param substitute The parameter is ignored.
- * @return Neutral value - {@link Look#NO_PROPERTY_SETS}.
- */
- public Node.PropertySet[] getPropertySets( Look.NodeSubstitute substitute ) {
- return Look.NO_PROPERTY_SETS;
- }
-
- /** Returns neutral value.
- * @param substitute The parameter is ignored.
- * @return Neutral value - null
.
- */
- public java.awt.Component getCustomizer( Look.NodeSubstitute substitute ) {
- return null;
- }
-
- // Methods for CLIPBOARD OPERATIONS ----------------------------------------
-
- /** Returns neutral value.
- * @param substitute The parameter is ignored.
- * @return Neutral value - false
.
- */
- public boolean canRename( Look.NodeSubstitute substitute ) {
- return false;
- }
-
- /** Returns neutral value.
- * @param substitute The parameter is ignored.
- * @return Neutral value - false
.
- */
- public boolean canDestroy( Look.NodeSubstitute substitute ) {
- return false;
- }
-
- /** Returns neutral value.
- * @param substitute The parameter is ignored.
- * @return Neutral value - false
.
- */
- public boolean canCopy( Look.NodeSubstitute substitute ) {
- return false;
- }
-
- /** Returns neutral value.
- * @param substitute The parameter is ignored.
- * @return Neutral value - false
.
- */
- public boolean canCut( Look.NodeSubstitute substitute ) {
- return false;
- }
-
- /** Returns neutral value.
- * @param substitute The parameter is ignored.
- * @param t The parameter is ignored.
- * @return Neutral value - {@link Look#NO_PASTE_TYPES}.
- */
- public PasteType[] getPasteTypes( Look.NodeSubstitute substitute, Transferable t) {
- return Look.NO_PASTE_TYPES;
- }
-
- /** Returns neutral value.
- * @param substitute The parameter is ignored.
- * @param t The parameter is ignored.
- * @param action The parameter is ignored.
- * @param index The parameter is ignored.
- * @return Neutral value - null
.
- */
- public PasteType getDropType( Look.NodeSubstitute substitute, Transferable t, int action, int index) {
- return null;
- }
-
- /** Returns neutral value.
- * @param substitute The parameter is ignored.
- * @throws IOException The exception is never thrown.
- * @return Neutral value - null
.
- */
- public Transferable clipboardCopy( Look.NodeSubstitute substitute ) throws IOException {
- return null;
- }
-
- /** Returns neutral value.
- * @param substitute The parameter is ignored.
- * @throws IOException The exception is never thrown.
- * @return Neutral value - null
.
- */
- public Transferable clipboardCut( Look.NodeSubstitute substitute ) throws IOException {
- return null;
- }
-
- /** Returns neutral value.
- * @param substitute The parameter is ignored.
- * @throws IOException The exception is never thrown.
- * @return Neutral value - null
.
- */
- public Transferable drag( Look.NodeSubstitute substitute ) throws IOException {
- return null;
- }
-
- /** Does nothing - empty implementation.
- * @param substitute The parameter is ignored.
- * @throws IOException The exception is never thrown.
- */
- public void destroy(Look.NodeSubstitute substitute) throws IOException {
- }
-
-
-
-}
Index: openidex/src/org/openidex/nodes/looks/EventTranslator.java
===================================================================
RCS file: openidex/src/org/openidex/nodes/looks/EventTranslator.java
diff -N openidex/src/org/openidex/nodes/looks/EventTranslator.java
--- openidex/src/org/openidex/nodes/looks/EventTranslator.java 3 Dec 2002 14:12:23 -0000 1.4
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,95 +0,0 @@
-/*
- * 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 Forte for Java, Community Edition. The Initial
- * Developer of the Original Code is Sun Microsystems, Inc. Portions
- * Copyright 1997-2000 Sun Microsystems, Inc. All Rights Reserved.
- */
-
-package org.openidex.nodes.looks;
-
-import java.lang.ref.WeakReference;
-import java.lang.ref.ReferenceQueue;
-
-import org.openide.util.RequestProcessor;
-
-/** WARNING - This API is not finished and is subject to change
- * Please don't use this API for other purposes than testing.
- *
- * If you really want the node is not garbage collected while the
- * represented object exists then hardreference the Node.Interior
- * from the subclass.
- *
- * Please don't use this API for other purposes than testing.
- *
- * The default state is to delegate all methods (i.e. the mask is set to
- * {@link #ALL_METHODS}.)
- *
- * @author Petr Hrebejk
- */
-public class FilterLook extends DefaultLook {
-
- /** Mask for enabling (unmasking) all methods */
- public static final long ALL_METHODS = Integer.MAX_VALUE;
- /** Mask for disabling (masking) all methods */
- public static final long NO_METHODS = 0;
- /** Mask for the method {@link #attachTo}. */
- public static final long ATTACH_TO = 1;
- /** Mask for the method {@link #getCookie}. */
- public static final long GET_COOKIE = ATTACH_TO << 1;
- /** Mask for the method {@link #getHandle}. */
- public static final long GET_HANDLE = GET_COOKIE << 1;
- /** Mask for the method {@link #getDisplayName}. */
- public static final long GET_DISPLAY_NAME = GET_HANDLE << 1;
- /** Mask for the method {@link #getName}. */
- public static final long GET_NAME = GET_DISPLAY_NAME << 1;
- /** Mask for the method {@link #setName}. */
- public static final long SET_NAME = GET_NAME << 1;
- /** Mask for the method {@link #getShortDescription}. */
- public static final long GET_SHORT_DESCRIPTION = SET_NAME << 1;
- /** Mask for the method {@link #getIcon}. */
- public static final long GET_ICON = GET_SHORT_DESCRIPTION << 1;
- /** Mask for the method {@link #getOpenedIcon}. */
- public static final long GET_OPENED_ICON = GET_ICON << 1;
- /** Mask for the method {@link #getHelpCtx}. */
- public static final long GET_HELP_CTX = GET_OPENED_ICON << 1;
- /** Mask for the method {@link #getChildObjects}. */
- public static final long GET_CHILD_OBJECTS = GET_HELP_CTX << 1;
- /** Mask for the method {@link #getNewTypes}. */
- public static final long GET_NEW_TYPES = GET_CHILD_OBJECTS << 1;
- /** Mask for the method {@link #getActions}. */
- public static final long GET_ACTIONS = GET_NEW_TYPES << 1;
- /** Mask for the method {@link #getContextActions}. */
- public static final long GET_CONTEXT_ACTIONS = GET_ACTIONS << 1;
- /** Mask for the method {@link #getDefaultAction}. */
- public static final long GET_DEFAULT_ACTION = GET_CONTEXT_ACTIONS << 1;
- /** Mask for the method {@link #getPropertySets}. */
- public static final long GET_PROPERTY_SETS = GET_DEFAULT_ACTION << 1;
- /** Mask for the method {@link #getCustomizer}. */
- public static final long GET_CUSTOMIZER = GET_PROPERTY_SETS << 1;
- /** Mask for the method {@link #canRename}. */
- public static final long CAN_RENAME = GET_CUSTOMIZER << 1;
- /** Mask for the method {@link #canDestroy}. */
- public static final long CAN_DESTROY = CAN_RENAME << 1;
- /** Mask for the method {@link #canCopy}. */
- public static final long CAN_COPY = CAN_DESTROY << 1;
- /** Mask for the method {@link #canCut}. */
- public static final long CAN_CUT = CAN_COPY << 1;
- /** Mask for the method {@link #getPasteTypes}. */
- public static final long GET_PASTE_TYPES = CAN_CUT << 1;
- /** Mask for the method {@link #getDropType}. */
- public static final long GET_DROP_TYPE = GET_PASTE_TYPES << 1;
- /** Mask for the method {@link #clipboardCopy}. */
- public static final long CLIPBOARD_COPY = GET_DROP_TYPE << 1;
- /** Mask for the method {@link #clipboardCut}. */
- public static final long CLIPBOARD_CUT = CLIPBOARD_COPY << 1;
- /** Mask for the method {@link #drag}. */
- public static final long DRAG = CLIPBOARD_CUT << 1;
- /** Mask for the method {@link #destroy}. */
- public static final long DESTROY = DRAG << 1;
-
- /** Contains current mask of the node */
- protected long mask = ALL_METHODS;
-
- /** Contains the Look to delegate to. */
- protected Look delegate;
-
- /** Creates new Delegating look
- * @param delegate The Look to delegate to.
- */
- public FilterLook(Look delegate) {
- this.delegate = delegate;
- }
-
- private boolean filterMethod( long method ) {
- return ( mask & method ) > 0;
- }
-
- // Methods of look itself -------------------------------------------------
-
- public boolean isLookStandalone( Object representedObject ) {
- return delegate.isLookStandalone( representedObject );
- }
-
- /** Sets mask for this look. Only methods contained in the mask
- * will be delegated. Other methods will return neutral values.
- * @param mask The mask to be set.
- */
- public void setLookMask( long mask ) {
- this.mask = mask;
- }
-
- /** Returns the current mask for this filter look.
- * @return Current mask.
- */
- public long getLookMask( ) {
- return mask;
- }
-
- /** Masks given methods. Removes given methods from given mask.
- * The masked methods will be no longer delegated.
- * @param methods Logical OR
of methods which have to be masked.
- * @return Current mask.
- */
- public long lookMask( long methods ) {
- mask |= methods;
- return mask;
- }
-
- /** Unmasks given methods. Adds given methods from given mask.
- * The masked methods will start to be delegated.
- * @param methods Logical OR
of methods which have to be unmasked.
- * @return Current mask.
- */
- public long lookUnmask( long methods ) {
- mask &= ~methods;
- return mask;
- }
-
- // General methods ---------------------------------------------------------
-
- public void attachTo( Look.NodeSubstitute substitute ) {
- if ( filterMethod( ATTACH_TO ) ) {
- delegate.attachTo( new FilterNodeSubstitute( substitute, this ) );
- }
- else {
- super.attachTo( substitute );
- }
- }
-
- public Node.Cookie getCookie( Look.NodeSubstitute substitute, Class type) {
- if ( filterMethod( GET_COOKIE ) ) {
- return delegate.getCookie( substitute, type );
- }
- else {
- return super.getCookie( substitute, type );
- }
- }
-
- public Node.Handle getHandle( Look.NodeSubstitute substitute ) {
- if ( filterMethod( GET_HANDLE ) ) {
- return delegate.getHandle( substitute );
- }
- else {
- return super.getHandle( substitute );
- }
- }
-
- // Methods for STYLE -------------------------------------------------------
-
- public String getDisplayName( Look.NodeSubstitute substitute ) {
- if ( filterMethod( GET_DISPLAY_NAME ) ) {
- return delegate.getDisplayName( substitute );
- }
- else {
- return super.getDisplayName( substitute );
- }
- }
-
- public String getName( Look.NodeSubstitute substitute ) {
- if ( filterMethod( GET_NAME ) ) {
- return delegate.getName( substitute );
- }
- else {
- return super.getName( substitute );
- }
- }
-
- public void setName(Look.NodeSubstitute substitute, String newName) {
- if ( filterMethod( SET_NAME ) ) {
- delegate.setName( substitute, newName );
- }
- else {
- super.setName( substitute, newName );
- }
- }
-
- public String getShortDescription ( Look.NodeSubstitute substitute ) {
- if ( filterMethod( GET_SHORT_DESCRIPTION ) ) {
- return delegate.getShortDescription( substitute );
- }
- else {
- return super.getShortDescription( substitute );
- }
- }
-
- public Image getIcon( Look.NodeSubstitute substitute, int type ) {
- if ( filterMethod( GET_ICON ) ) {
- return delegate.getIcon( substitute, type );
- }
- else {
- return super.getIcon( substitute, type );
- }
- }
-
- public Image getOpenedIcon( Look.NodeSubstitute substitute, int type ) {
- if ( filterMethod( GET_OPENED_ICON ) ) {
- return delegate.getOpenedIcon( substitute, type );
- }
- else {
- return super.getOpenedIcon( substitute, type );
- }
- }
-
- public HelpCtx getHelpCtx( Look.NodeSubstitute substitute ) {
- if ( filterMethod( GET_HELP_CTX ) ) {
- return delegate.getHelpCtx( substitute );
- }
- else {
- return super.getHelpCtx( substitute );
- }
- }
-
- // Methods for CHILDREN ----------------------------------------------------
-
- public Object[] getChildObjects( Look.NodeSubstitute substitute ) {
- if ( filterMethod( GET_CHILD_OBJECTS ) ) {
- return delegate.getChildObjects( substitute );
- }
- else {
- return super.getChildObjects( substitute );
- }
- }
-
- // Methods for ACTIONS & NEW TYPES -----------------------------------------
-
- public NewType[] getNewTypes( Look.NodeSubstitute substitute ) {
- if ( filterMethod( GET_NEW_TYPES ) ) {
- return delegate.getNewTypes( substitute );
- }
- else {
- return super.getNewTypes( substitute );
- }
- }
-
- public SystemAction[] getActions( Look.NodeSubstitute substitute ) {
- if ( filterMethod( GET_ACTIONS ) ) {
- return delegate.getActions( substitute );
- }
- else {
- return super.getActions( substitute );
- }
- }
-
- public SystemAction[] getContextActions( Look.NodeSubstitute substitute ) {
- if ( filterMethod( GET_CONTEXT_ACTIONS ) ) {
- return delegate.getContextActions( substitute );
- }
- else {
- return super.getContextActions( substitute );
- }
- }
-
- public SystemAction getDefaultAction( Look.NodeSubstitute substitute ) {
- if ( filterMethod( GET_DEFAULT_ACTION ) ) {
- return delegate.getDefaultAction( substitute );
- }
- else {
- return super.getDefaultAction( substitute );
- }
- }
-
- // Methods for PROPERTIES AND CUSTOMIZER -----------------------------------
-
- public Node.PropertySet[] getPropertySets( Look.NodeSubstitute substitute ) {
- if ( filterMethod( GET_PROPERTY_SETS ) ) {
- return delegate.getPropertySets( substitute );
- }
- else {
- return super.getPropertySets( substitute );
- }
- }
-
- public java.awt.Component getCustomizer( Look.NodeSubstitute substitute ) {
- if ( filterMethod( GET_CUSTOMIZER ) ) {
- return delegate.getCustomizer( substitute );
- }
- else {
- return super.getCustomizer( substitute );
- }
- }
-
- // Methods for CLIPBOARD OPERATIONS ----------------------------------------
-
- public boolean canRename( Look.NodeSubstitute substitute ) {
- if ( filterMethod( CAN_RENAME ) ) {
- return delegate.canRename( substitute );
- }
- else {
- return super.canRename( substitute );
- }
- }
-
- public boolean canDestroy( Look.NodeSubstitute substitute ) {
- if ( filterMethod( CAN_DESTROY ) ) {
- return delegate.canDestroy( substitute );
- }
- else {
- return super.canDestroy( substitute );
- }
- }
-
- public boolean canCopy( Look.NodeSubstitute substitute ) {
- if ( filterMethod( CAN_COPY ) ) {
- return delegate.canCopy( substitute );
- }
- else {
- return super.canCopy( substitute );
- }
- }
-
- public boolean canCut( Look.NodeSubstitute substitute ) {
- if ( filterMethod( CAN_CUT ) ) {
- return delegate.canCut( substitute );
- }
- else {
- return super.canCut( substitute );
- }
- }
-
- public PasteType[] getPasteTypes( Look.NodeSubstitute substitute, Transferable t) {
- if ( filterMethod( GET_PASTE_TYPES ) ) {
- return delegate.getPasteTypes( substitute, t );
- }
- else {
- return super.getPasteTypes( substitute, t );
- }
- }
-
- public PasteType getDropType( Look.NodeSubstitute substitute, Transferable t, int action, int index) {
- if ( filterMethod( GET_DROP_TYPE ) ) {
- return delegate.getDropType( substitute, t, action, index );
- }
- else {
- return super.getDropType( substitute, t, action, index );
- }
- }
-
- public Transferable clipboardCopy( Look.NodeSubstitute substitute ) throws IOException {
- if ( filterMethod( CLIPBOARD_COPY ) ) {
- return delegate.clipboardCopy( substitute );
- }
- else {
- return super.clipboardCopy( substitute );
- }
- }
-
- public Transferable clipboardCut( Look.NodeSubstitute substitute ) throws IOException {
- if ( filterMethod( CLIPBOARD_CUT ) ) {
- return delegate.clipboardCut( substitute );
- }
- else {
- return super.clipboardCut( substitute );
- }
- }
-
- public Transferable drag( Look.NodeSubstitute substitute ) throws IOException {
- if ( filterMethod( DRAG ) ) {
- return delegate.drag( substitute );
- }
- else {
- return super.drag( substitute );
- }
- }
-
- public void destroy(Look.NodeSubstitute substitute) throws IOException {
- if ( filterMethod( DESTROY ) ) {
- delegate.destroy( substitute );
- }
- else {
- super.destroy( substitute );
- }
- }
-
- // Innerclasses ------------------------------------------------------------
-
- static class FilterNodeSubstitute extends Look.NodeSubstitute {
-
- private FilterLook filterLook;
- private Look.NodeSubstitute substitute;
-
- FilterNodeSubstitute( Look.NodeSubstitute substitute, FilterLook filterLook ) {
- this.substitute = substitute;
- this.filterLook = filterLook;
- }
-
- /** Returns the object represented by the node
- * @return Object represented by the node this interior belongs to.
- */
- public Object getRepresentedObject() {
- return substitute.getRepresentedObject();
- }
-
- /** Fires a (Bean) property change event (for
- * {@link org.openide.node.Node#PROP_PROPERTY_SETS}).
- * @param o the old set
- * @param n the new set
- */
- public void firePropertySetsChange(Node.PropertySet[] o, Node.PropertySet[] n) {
- if ( filterLook.filterMethod( GET_PROPERTY_SETS ) ) {
- substitute.firePropertySetsChange( o, n );
- }
- }
-
- /** Fires the Event notificationg about name change.
- */
- public void fireNameChange(String o, String n) {
- if ( filterLook.filterMethod( GET_NAME ) ) {
- substitute.fireNameChange( o, n );
- }
- }
-
- /** Fires a change event for {@link org.openode.nodes.Node#PROP_COOKIE}.
- * The old and new values are set to null.
- */
- public void fireCookieChange() {
- if ( filterLook.filterMethod( GET_COOKIE ) ) {
- substitute.fireCookieChange( );
- }
- }
-
- /** Fires the Event notificationg about display name change.
- */
- public void fireDisplayNameChange(String o, String n) {
- if ( filterLook.filterMethod( GET_DISPLAY_NAME ) ) {
- substitute.fireDisplayNameChange( o, n );
- }
- }
-
- /** Tells the node that the children have to be refreshed.
- */
- public void refreshChildren() {
- if ( filterLook.filterMethod( GET_CHILD_OBJECTS ) ) {
- substitute.refreshChildren( );
- }
- }
-
- /** Fire a change event for {@link org.openide.nodes.Node#PROP_OPENED_ICON} on
- * associated node.
- */
- public void fireOpenedIconChange() {
- if ( filterLook.filterMethod( GET_OPENED_ICON ) ) {
- substitute.fireOpenedIconChange();
- }
- }
-
- /** To all node listeners fire node destroyed notification.
- */
- public void fireNodeDestroyed() {
- if ( filterLook.filterMethod( DESTROY ) ) {
- substitute.fireNodeDestroyed();
- }
- }
-
- /** Fire a change event for {@link org.openide.nodes.Node#PROP_ICON} on
- * associated node.
- */
- public void fireIconChange() {
- if ( filterLook.filterMethod( GET_ICON ) ) {
- substitute.fireIconChange();
- }
- }
-
- /** Fires the Event notificationg about short description change.
- */
- public void fireShortDescriptionChange(String o, String n) {
- if ( filterLook.filterMethod( GET_SHORT_DESCRIPTION ) ) {
- substitute.fireShortDescriptionChange( o, n );
- }
- }
-
- /** Fire a property change event on the associated node.
- * @param name name of changed property (from {@link #getPropertySets})
- * @param o old value
- * @param n new value
- */
- public void firePropertyChange(String name, Object o, Object n) {
- if ( filterLook.filterMethod( GET_PROPERTY_SETS ) ) {
- substitute.firePropertyChange( name, o, n );
- }
- }
-
- /** Allowes to store Cookies for given node. This method could be
- *
- */
- public CookieSet getCookieSet() {
- return substitute.getCookieSet();
- }
-
- }
-
-
-}
Index: openidex/src/org/openidex/nodes/looks/JndiLook.java
===================================================================
RCS file: openidex/src/org/openidex/nodes/looks/JndiLook.java
diff -N openidex/src/org/openidex/nodes/looks/JndiLook.java
--- openidex/src/org/openidex/nodes/looks/JndiLook.java 3 Dec 2002 14:12:23 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,105 +0,0 @@
-/*
- * 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 Forte for Java, Community Edition. The Initial
- * Developer of the Original Code is Sun Microsystems, Inc. Portions
- * Copyright 1997-2001 Sun Microsystems, Inc. All Rights Reserved.
- */
-
-package org.openidex.nodes.looks;
-
-
-import javax.naming.*;
-
-import org.openide.nodes.*;
-import org.openide.util.enum.*;
-import java.util.Enumeration;
-
-/** WARNING - This API is not finished and is subject to change
- * Please don't use this API for other purposes than testing.
- * Standalone
.
- * @param object Object represented by the node.
- * @return true
if user should be allowed to switch to this look on given node.
- */
- public boolean isLookStandalone( Object representedObject ) {
-
- if ( standaloneClasses == null ) {
- // We have to prepare the list
- if ( lookDataObject == null ) {
- standaloneClasses = new ArrayList( 0 );
- }
- else {
- try {
- Element de = lookDataObject.getDocument().getDocumentElement();
- NodeList standaloneTags = de.getElementsByTagName( TAG_STANDALONE );
- standaloneClasses = new ArrayList( standaloneTags.getLength() );
-
- for( int i = 0; i < standaloneTags.getLength(); i++ ) {
- if ( standaloneTags.item( i ).getNodeType() != org.w3c.dom.Node.ELEMENT_NODE ) {
- continue;
- }
- Element e = (Element)standaloneTags.item( i );
- String className = e.getAttribute( ATTR_CLASS );
- ClassLoader l = (ClassLoader)Lookup.getDefault().lookup(ClassLoader.class);
- standaloneClasses.add( Class.forName( className, true, l) );
- }
- }
- catch ( java.io.IOException e ) {
- System.out.println( name + e );
- return false;
- }
- catch ( ClassNotFoundException e ) {
- System.out.println( name + e );
- return false;
- }
- catch ( org.xml.sax.SAXException e ) {
- System.out.println( name + e );
- return false;
- }
- }
- }
-
- for ( int i = 0; i < standaloneClasses.size(); i++ ) {
- if ( ((Class)standaloneClasses.get( i )).isInstance ( representedObject ) ) {
- return true;
- }
- }
-
- return false;
- }
-
- /** Reads the Look options from the XMLDataObject. If you override this
- * method you'll probably want to call super.readPropertiesFromXML( xdo );
- * Implementation of the method in the Look class handles the look name
- * tag and the tags standalone.
- * @param xdo The XMLDataObject
which contains configuration of
- * the look.
- */
- public void readPropertiesFromXML( XMLDataObject xdo ) {
- lookDataObject = xdo;
- String xdoName = xdo.getName();
- int nameIndex = xdoName.indexOf('$');
- setName( xdoName.substring( nameIndex + 1 ) );
- }
-
- // General methods ---------------------------------------------------------
-
- /**
- * Called on the current look when node is newly created or the look is
- * set on the Node. Overriding this
- * method allows to register listners on represented objects and asociate
- * them with the node.
- * Look.NodeSubstitute
of the which was created.
- */
- public abstract void attachTo( Look.NodeSubstitute substitute );
-
- /** Get additional cookie for the node. This method should be used to return
- * cookies from represented object.
- * @param substitute The Look.NodeSubstitute
of the node to operate on.
- * @param type the representation class of the cookie
- * @return a cookie assignable to that class, or null
if this
- * node has no such cookie
- */
- public abstract Node.Cookie getCookie( Look.NodeSubstitute substitute, Class type);
-
- /** Obtain handle for this node (for serialization).
- * The handle can be serialized and {@link Handle#getNode} used after
- * deserialization to obtain the original node.
- * @param substitute The Look.NodeSubstitute
of the node to operate on.
- * @return the handle, or null
if this node is not persistable.
- */
- public abstract Node.Handle getHandle( Look.NodeSubstitute substitute );
-
- // Methods for STYLE -------------------------------------------------------
-
- /** Gets localized name of given Node. This name will be showed in the
- * visual representation of the node.
- * @param substitute The Look.NodeSubstitute
of the node to operate on.
- * @return Localized name of the node. Implementation of {@link LookNode}
- * defaults this to the programmatic name of the node.
- */
- public abstract String getDisplayName( Look.NodeSubstitute substitute );
-
- /** Gets the progammatic name of given node. This name can be used for
- * operations on node paths in the node hierarchy and thus shouldn't be
- * localized.
- * @param substitute The Look.NodeSubstitute
of the node to operate on.
- * @return Programmatic name of the node.
- */
- public abstract String getName( Look.NodeSubstitute substitute );
-
- /** This method is clalled when the user renames the node using inplace
- * editing in the view.
- * @param substitute The Look.NodeSubstitute
of the renamed node.
- * @param newName The new name set by the user.
- */
- public abstract void setName( Look.NodeSubstitute substitute, String newName );
-
- /** Gets short description of given node. The short description is usually
- * visualized as a tooltip, but may have another forms as well.
- * @param substitute The Look.NodeSubstitute
of the node to operate on.
- * @return A localized short description associated with the node.
- * Implementation of {@link LookNode} defaults this to display name
- * of the node.
- */
- public abstract String getShortDescription( Look.NodeSubstitute substitute );
-
- /** Find an icon for this node (in the closed state).
- * @param substitute The Look.NodeSubstitute
of the node to operate on.
- * @param type Constant from {@link java.beans.BeanInfo}
- * @return Icon to use to represent the node in the closed state.
- * Implementation of {@link LookNode} provides default icon for nodes.
- */
- public abstract Image getIcon( Look.NodeSubstitute substitute, int type );
-
- /** Find an icon for this node (in the open state).
- * This icon is used when the node may have children and is expanded.
- * @param substitute The Look.NodeSubstitute
of the node to operate on.
- * @param type Constant from {@link java.beans.BeanInfo}
- * @return Icon to use to represent the node in the open state.
- * Implementation of {@link LookNode} defaults this to the closed
- * state icon.
- */
- public abstract Image getOpenedIcon( Look.NodeSubstitute substitute, int type );
-
- /** Get context help associated with this node.
- * @param substitute The Look.NodeSubstitute
of the node to operate on.
- * @return The context help object (could be null
or
- * {@link HelpCtx#DEFAULT_HELP})
- */
- public abstract HelpCtx getHelpCtx( Look.NodeSubstitute substitute );
-
- // Methods for CHILDREN ----------------------------------------------------
-
- /** Gets objects which are children of object represented by the node in the
- * hierarchy represented by this Look.
- * @param substitute The Look.NodeSubstitute
of the node to operate on.
- * @return Array of objects which should be represend as node children of
- * the node.
- */
- public abstract Object[] getChildObjects( Look.NodeSubstitute substitute );
-
- // Methods for ACTIONS & NEW TYPES -----------------------------------------
-
- /** Get the new types that can be created in given node.
- * For example, a node representing a Java package will permit classes to
- * be added.
- * @param substitute The Look.NodeSubstitute
of the node to operate on.
- * @return Array of new type operations that are allowed.
- */
- public abstract NewType[] getNewTypes( Look.NodeSubstitute substitute );
-
- /** Get the set of actions associated with the node.
- * This may be used e.g. in constructing a {@link #getContextMenu context menu}.
- * Look.NodeSubstitute
of the node to operate on.
- * @return Array of the Actions applicable to the node or null
- * if actions in {@link NodeOp#getDefaultActions} should be used.
- */
- public abstract SystemAction[] getActions( Look.NodeSubstitute substitute );
-
- /** Get a special set of actions for situations when this node is displayed
- * as a context.
- * @see org.openide.nodes.Node#getContextActions For more detailed description.
- * @param substitute The Look.NodeSubstitute
of the The node to operate on.
- * @return Actions for a context. In the LookNode implementation,
- * same as {@link #getActions}.
- *
- */
- public abstract SystemAction[] getContextActions( Look.NodeSubstitute substitute );
-
- /** Get the default action for this node.
- * This action can but need not be one from the list returned
- * from {@link #getActions}. If so, the popup menu returned from
- * {@link #getContextMenu} is encouraged to highlight the action.
- * @param substitute The Look.NodeSubstitute
of the node to operate on.
- * @return Default action, or null
if there should be none.
- */
- public abstract SystemAction getDefaultAction( Look.NodeSubstitute substitute );
-
- // Methods for PROPERTIES AND CUSTOMIZER -----------------------------------
-
- /** Get the list of property sets for given node. E.g. typically there
- * may be one for normal Bean properties, one for expert
- * properties, and one for hidden properties.
- * @param substitute The Look.NodeSubstitute
of the The node to operate on.
- * @return Property sets for the node.
- */
- public abstract Node.PropertySet[] getPropertySets( Look.NodeSubstitute substitute );
-
- /** Get the customizer for represented object if available.
- * @param substitute The Look.NodeSubstitute
of the node to operate on.
- * @return The component, or null
if there is no customizer.
- */
- public abstract java.awt.Component getCustomizer( Look.NodeSubstitute substitute );
-
- /**
- * Test whether there is a customizer for this node. If true,
- * the customizer can be obtained via {@link #getCustomizer}.
- * @return true
if there is a customizer
- *
- *
- */
- public boolean hasCustomizer (Look.NodeSubstitute substitute) {
- return getCustomizer(substitute) != null;
- }
-
- // Methods for CLIPBOARD OPERATIONS ----------------------------------------
-
- /** Test whether this node can be renamed.
- * If true, {@link #setName} will be called when the user changes the name
- * of the node.
- * @param substitute The Look.NodeSubstitute
of the node to operate on.
- * @return true
if the node can be renamed.
- */
- public abstract boolean canRename( Look.NodeSubstitute substitute );
-
- /** Test whether this node can be deleted.
- * @param substitute The Look.NodeSubstitute
of the node to operate on.
- * @return True
if can be deleted.
- */
- public abstract boolean canDestroy( Look.NodeSubstitute substitute );
-
- /** Test whether this node permits copying.
- * @param substitute The Look.NodeSubstitute
of the node to operate on.
- * @return True
if so.
- */
- public abstract boolean canCopy( Look.NodeSubstitute substitute );
-
- /** Test whether this node permits cutting.
- * @param substitute The Look.NodeSubstitute
of the node to operate on.
- * @return True
if so.
- */
- public abstract boolean canCut( Look.NodeSubstitute substitute );
-
- /** Determine which paste operations are allowed when a given
- * transferable is in the clipboard. For example, a node representing a
- * Java package will permit classes to be pasted into it.
- * @param substitute The Look.NodeSubstitute
of the node to operate on.
- * @param t The transferable in the clipboard.
- * @return Array of operations that are allowed
- */
- public abstract PasteType[] getPasteTypes( Look.NodeSubstitute substitute, Transferable t);
-
- /** Determine if there is a paste operation that can be performed
- * on provided transferable. Used by drag'n'drop code to check
- * whether the drop is possible.
- * @param substitute The Look.NodeSubstitute
of the node to operate on.
- * @param t The transferable.
- * @param action The drag'n'drop action to do DnDConstants.ACTION_MOVE,
- * ACTION_COPY, ACTION_LINK.
- * @param index Index between children the drop occured at or -1 if not specified.
- * @return Null
if the transferable cannot be accepted or the paste type
- * to execute when the drop occures.
- */
- public abstract PasteType getDropType( Look.NodeSubstitute substitute, Transferable t, int action, int index);
-
- /** Called when a node is to be copied to the clipboard.
- * @param substitute The Look.NodeSubstitute
of the node Copy was invoked on.
- * @return The transferable object representing the content of the clipboard.
- * @throws IOException When the copy cannot be performed.
- */
- public abstract Transferable clipboardCopy( Look.NodeSubstitute substitute ) throws IOException;
-
- /** Called when the node is to be cut to the clipboard.
- * @param substitute The Look.NodeSubstitute
of the node to be cutted.
- * @return The transferable object representing the content of the clipboard.
- * @throws IOException When the copy cannot be performed.
- */
- public abstract Transferable clipboardCut( Look.NodeSubstitute substitute ) throws IOException;
-
- /** Called when a drag is started with this node.
- * The node can attach a transfer listener to ExTransferable and
- * will be then notified about progress of the drag (accept/reject).
- * @param substitute The Look.NodeSubstitute
of the node which was dragged.
- * @return Transferable to represent this node during a drag.
- * @throws IOException If a drag cannot be started.
- */
- public abstract Transferable drag( Look.NodeSubstitute substitute ) throws IOException;
-
- /** Called when node was destroyed.
- * @param substitute Look.NodeSubstitute of the destroyed ndoe.
- */
- public abstract void destroy( Look.NodeSubstitute substitute ) throws IOException;
-
- // Innerclasses ------------------------------------------------------------
-
- /** Class passed to the Look methods as parameter. Each LookNode contains
- * exactly one instance of this class. Metods of the class allow access
- * to the properties and methods od the node needed for the Look.
- */
- public static abstract class NodeSubstitute {
-
-
- /** Returns the object represented by the node
- * @return Object represented by the node this interior belongs to.
- */
- abstract public Object getRepresentedObject();
-
- /** Fire a property change event on the associated node.
- * @param name name of changed property (from {@link #getPropertySets})
- * @param o old value
- * @param n new value
- */
- abstract public void firePropertyChange( String name, Object o, Object n );
-
- /** Fires the Event notificationg about name change.
- */
- abstract public void fireNameChange( String o, String n );
-
- /** Fires the Event notificationg about display name change.
- */
- abstract public void fireDisplayNameChange( String o, String n );
-
- /** Fires the Event notificationg about short description change.
- */
- abstract public void fireShortDescriptionChange(String o, String n);
-
- /** Fire a change event for {@link org.openide.nodes.Node#PROP_ICON} on
- * associated node.
- */
- abstract public void fireIconChange();
-
- /** Fire a change event for {@link org.openide.nodes.Node#PROP_OPENED_ICON} on
- * associated node.
- */
- abstract public void fireOpenedIconChange();
-
- /** Fires a (Bean) property change event (for
- * {@link org.openide.node.Node#PROP_PROPERTY_SETS}).
- * @param o the old set
- * @param n the new set
- */
- abstract public void firePropertySetsChange( Node.PropertySet[] o, Node.PropertySet[] n );
-
- /** Fires a change event for {@link org.openode.nodes.Node#PROP_COOKIE}.
- * The old and new values are set to null.
- */
- abstract public void fireCookieChange();
-
- /** To all node listeners fire node destroyed notification.
- */
- abstract public void fireNodeDestroyed();
-
- /** Tells the node that the children have to be refreshed.
- */
- abstract public void refreshChildren();
-
- /** Allowes to store Cookies for given node. This method might be
- * replaced by getLookup later.
- * @return CookieSet for this NodeSubstitute.
- */
- abstract public CookieSet getCookieSet();
-
- }
-
-
-}
Index: openidex/src/org/openidex/nodes/looks/LookChildren.java
===================================================================
RCS file: openidex/src/org/openidex/nodes/looks/LookChildren.java
diff -N openidex/src/org/openidex/nodes/looks/LookChildren.java
--- openidex/src/org/openidex/nodes/looks/LookChildren.java 25 Oct 2001 14:32:29 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,77 +0,0 @@
-/*
- * 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-2000 Sun
- * Microsystems, Inc. All Rights Reserved.
- */
-
-package org.openidex.nodes.looks;
-
-import java.util.*;
-
-import org.openide.nodes.Children;
-import org.openide.nodes.*;
-
-/** WARNING - This API is not finished and is subject to change
- * Please don't use this API for other purposes than testing.
- *
- * Please don't use this API for other purposes than testing.
- * PROP_COOKIE, PROP_NAME, PROP_NAME, PROP_DISPLAY_NAME, PROP_ICON,
- * PROP_OPENED_ICON
and children are refresehed.
- * @look New look of the node.
- */
- public void setLook( Look look ) {
-
- this.lookCandidate = look;
- this.look = look; // make it hard look immediatelly
- getLook().attachTo( getSubstitute( ) );
-
- // fire possible change notifications
-
- fireCookieChange();
- refreshChildren();
- fireNameChange( null, null );
- fireDisplayNameChange( null, null );
- fireIconChange();
- fireOpenedIconChange();
- }
-
- /** Returns cookie set on this node
- */
- private CookieSet getCookieSet() {
- CookieSet cs = cookieSet;
- if (cs != null) {
- return cs;
- }
-
- synchronized (this) {
- if (cookieSet != null) {
- return cookieSet;
- }
-
- // sets empty sheet and adds a listener to it
- cookieSet = new CookieSet();
- cookieSet.addChangeListener( new ChangeListener() {
- public void stateChanged (ChangeEvent ev) {
- LookNode.this.fireCookieChange ();
- }
- } );
- return cookieSet;
- }
- }
-
- /** Refreshes children on the node */
- void refreshChildren() {
- ((LookChildren)getChildren()).refreshChildren();
- }
-
- // General methods ---------------------------------------------------------
-
- /**
- * Gets look set on this node.
- * @return Look set on this Node. Or Look set on the nearest parent Node of
- * this Node with some Look set. If no such node exists this method returns
- * (i.e. this is a root node or some of the parent nodes is not a LookNode)
- * {@link DefaultLook#INSTANCE} unless the node represents a cloned LookNode
.
- * In such case a look of original is returned instead.
- *
- */
- public Look getLook() {
-
- // do we have a hard set look
-
- if ( look != null ) return look;
-
- // get parent or candidate look (while making it hard look)
-
- Node parentNode = getParentNode();
-
- if ( parentNode == null || (parentNode instanceof LookNode) == false ) {
-
- // If it is a LookNode clone then use original look as a look cannot
- // be derived from parent node otherwise use DefaultLook
-
- if (lookCandidate != null) {
- look = lookCandidate;
- look.attachTo(substitute);
- return look;
- } else {
- return DefaultLook.INSTANCE;
- }
-
- } else {
- // softly "set" look
- return ((LookNode)parentNode).getLook();
- }
-
- }
-
- /**
- * @return Look that is set hardly or null
if look will be get from parents
- * of hard look candidate.
- */
- final Look getHardLook() {
-// synchronized (lock) { // no sync neccessary IMO
- return look;
-// }
- }
-
- /** Gets Cookie of given type. The set of Cookies is determined by the
- * Look. Look of the node can allways be asked using getCookie(
- * Look.class )
and the LookNode self can be asked by
- * getCookie( LookNode.class )
.
- * @param type the representation class of the cookie
- * @return a cookie assignable to that class, or null
- * the Look does not provide such cookie.
- */
- public Node.Cookie getCookie( Class type ) {
- if ( type == Look.class ) {
- // Look is available in cookies
- return getLook();
- }
- else if ( type == LookNode.class ) {
- return this;
- }
- else {
- Node.Cookie cookie = getCookieSet().getCookie( type );
-
- if ( cookie == null ) {
- // Ask the Looks for additional cookies
- return getLook().getCookie( substitute, type );
- }
- else {
- // Return found cookie
- return cookie;
- }
- }
- }
-
- /** Determines Handle by querying the Look.
- * @return the handle, or null
if this node is not persistable
- */
- public Node.Handle getHandle() {
- return getLook().getHandle( substitute );
- }
-
- /**
- * Returns a node representing the same object as the original node. The Look
- * of the original node becomes look candidate.
- *
- * @return LookNode representing the same object.
- */
- public Node cloneNode () {
-
- LookNode clone = new LookNode( getRepresentedObject() );
- clone.lookCandidate = look != null ? look : lookCandidate; // survive double cloning
-
-// new RuntimeException("LookNode " + this + " cloned to " + clone + ".").printStackTrace();
- return clone;
- }
-
-
- // Methods for STYLE -------------------------------------------------------
-
- /** Determines displayName by querying the Look.
- * @return DisplayName provided by the Look or result
- * of {@link #getName()}.
- */
- public String getDisplayName() {
- String displayName = getLook().getDisplayName( substitute );
-
- if ( displayName == null ) {
- return getName();
- }
- else
- return displayName;
- }
-
- /** Empty method, setting displayName
on the
- * LookNode
has no efect. The displayName
should
- * be determined by associated Look
.
- * @param name Parameter is ignored.
- */
- public void setDisplayName( String name ) {
- }
-
- /** Determines name by querying the Look.
- * @return Name provided by the Look or null
.
- */
- public String getName() {
- return getLook().getName( substitute );
- }
-
- /** Invoking this method on LookNode invokes method {@link Look#setName(
- * Look.NodeSubstitute, String )}. Look is responsible for handling the call.
- */
- public void setName( String s ) {
- getLook().setName( substitute, s );
- }
-
- /** Empty method, setting shortDescription
on the
- * LookNode
has no efect. The shortDescription
- * should be determined by associated Look
.
- * @param shortDescription Parameter is ignored.
- */
- public void setShortDescription( String shortDescription ) {
- }
-
- /** Determines shortDescription by querying the Look.
- * @return Name provided by the Look or result of {@link getDisplayName()}.
- */
- public String getShortDescription() {
- String shortDescription = getLook().getShortDescription( substitute );
- if ( shortDescription == null ) {
- return getDisplayName();
- }
- else {
- return shortDescription;
- }
- }
-
- /** Determines icon for closed state by querying the Look.
- * @return Icon provided by the Look or the icon which can be found on:
- * org/netbeans/modules/freestyle/nodes/resources/defaultNode(32).gif
- */
- public Image getIcon( int type ) {
- Image icon = getLook().getIcon( substitute, type );
-
- if ( icon == null ) {
- if ( type == BeanInfo.ICON_COLOR_32x32 || type == BeanInfo.ICON_MONO_32x32 ) {
- if ( DEFAULT_ICON_32 == null ) {
- DEFAULT_ICON_32 = Utilities.loadImage( DEFAULT_ICON_32_NAME );
- }
- return DEFAULT_ICON_32;
- }
- if ( DEFAULT_ICON_16 == null ) {
- DEFAULT_ICON_16 = Utilities.loadImage( DEFAULT_ICON_16_NAME );
- }
- return DEFAULT_ICON_16;
- }
- else {
- return icon;
- }
- }
-
- /** Determines icon for opened state by querying the Look.
- * @return Icon provided by the Look or the result of
- * {@link getIcon()}.
- */
- public Image getOpenedIcon( int type ) {
- Image icon = getLook().getOpenedIcon( substitute, type );
-
- if ( icon == null ) {
- return getIcon( type );
- }
- else {
- return icon;
- }
- }
-
- /** Determines HelpCtx for opened state by querying the Look.
- * @return HelpCtx provided by the Look.
- */
- public HelpCtx getHelpCtx () {
- return getLook().getHelpCtx( substitute );
- }
-
- // Methods for ACTIONS & NEW TYPES -----------------------------------------
-
- /** Determines NewTypes for opened state by querying the Look.
- * @return NewTypes provided by the Look.
- */
- public NewType[] getNewTypes() {
- return getLook().getNewTypes( substitute );
- }
-
- public SystemAction[] getActions() {
- SystemAction[] systemActions = getLook().getActions( substitute );
- SystemAction[] mergedActions;
-
- if ( systemActions == null ) {
- systemActions = super.getActions();
- }
-
- int actlen = systemActions.length;
- mergedActions = new SystemAction[actlen + 2];
- System.arraycopy( systemActions, 0, mergedActions, 0, actlen );
- SystemAction sla = LookProperties.getSetLookAction( this );
-
- System.arraycopy( new SystemAction[]{
- null,
- sla
- }, 0, mergedActions, actlen, 2 );
- return mergedActions;
-
- }
-
- public SystemAction[] getContextActions() {
- return getLook().getContextActions( substitute );
- }
-
- public SystemAction getDefaultAction() {
- return getLook().getDefaultAction( substitute );
- }
-
- // Methods for PROPERTIES AND CUSTOMIZER -----------------------------------
-
- public Node.PropertySet[] getPropertySets() {
- Node.PropertySet[] sets = getLook().getPropertySets( substitute );
-
- Node.PropertySet[] all = new Node.PropertySet[ sets.length + 1 ];
- System.arraycopy( sets, 0, all, 0, sets.length );
-
- Sheet.Set set = LookProperties.getLookPropertySet( this );
- /*
- set.setName( LookProperties.LOOK_SHEET_SET_NAME );
- set.setDisplayName( LookProperties.LOOK_SHEET_SET_NAME );
- set.put( new LookProperties.LookProperty( this ) );
- */
-
- all[ all.length - 1] = set;
-
- return all;
- }
-
- public java.awt.Component getCustomizer() {
- return getLook().getCustomizer( substitute );
- }
-
- public boolean hasCustomizer () {
- return getLook().hasCustomizer( substitute );
- }
-
- // Methods for CLIPBOARD OPERATIONS ----------------------------------------
-
- public boolean canRename() {
- return getLook().canRename( substitute );
- }
-
- public boolean canDestroy() {
- return getLook().canDestroy( substitute );
- }
-
- public boolean canCopy() {
- return getLook().canCopy( substitute );
- }
-
- public boolean canCut() {
- return getLook().canCut( substitute );
- }
-
- public PasteType[] getPasteTypes( Transferable t) {
- return getLook().getPasteTypes( substitute, t );
- }
-
- public PasteType getDropType( Transferable t, int action, int index) {
- return getLook().getDropType( substitute, t, action, index );
- }
-
- public Transferable clipboardCopy() throws IOException {
- return getLook().clipboardCopy( substitute );
- }
-
- public Transferable clipboardCut() throws IOException {
- return getLook().clipboardCut( substitute );
- }
-
- public Transferable drag() throws IOException {
- return getLook().drag( substitute );
- }
-
- public void destroy () throws IOException {
- getLook().destroy( substitute );
- super.destroy();
- }
-
- boolean hasLookNodeParent() {
- Node parent = getParentNode();
- return parent != null && parent instanceof LookNode;
- }
-
- // Interior innerclass -----------------------------------------------------
-
- /** Class passed to the Look methods as parameter. Each LookNode contains
- * exactly one instance of this class. Metods of the class allow access
- * to the properties and methods od the node needed for the Look.
- */
- class SubstituteImpl extends Look.NodeSubstitute {
-
- private Object representedObject;
-
- private CookieSet cookieSet; // a cache
-
-
- /** The constructor of the interior is private to prevent other classes
- * then LookNode and Look from firing events on the node
- */
- private SubstituteImpl(Object representedObject ){
- this.representedObject = representedObject;
- }
-
-
- /** Returns the object represented by the node
- * @return Object represented by the node this interior belongs to.
- */
- public Object getRepresentedObject(){
- return representedObject;
- }
-
- /** Fire a property change event on the associated node.
- * @param name name of changed property (from {@link #getPropertySets})
- * @param o old value
- * @param n new value
- */
- public final void firePropertyChange( String name, Object o, Object n ) {
- LookNode.this.firePropertyChange( name, o, n );
- }
-
- /** Fires the Event notificationg about name change.
- */
- public final void fireNameChange( String o, String n ) {
- LookNode.this.fireNameChange( o, n );
- }
-
- /** Fires the Event notificationg about display name change.
- */
- public final void fireDisplayNameChange( String o, String n ) {
- LookNode.this.fireDisplayNameChange( o, n );
- }
-
- /** Fires the Event notificationg about short description change.
- */
- public final void fireShortDescriptionChange(String o, String n) {
- LookNode.this.fireShortDescriptionChange( o, n );
- }
-
- /** Fire a change event for {@link org.openide.nodes.Node#PROP_ICON} on
- * associated node.
- */
- public final void fireIconChange() {
- LookNode.this.fireIconChange();
- }
-
- /** Fire a change event for {@link org.openide.nodes.Node#PROP_OPENED_ICON} on
- * associated node.
- */
- public final void fireOpenedIconChange() {
- LookNode.this.fireOpenedIconChange();
- }
-
- /** Fires a (Bean) property change event (for
- * {@link org.openide.node.Node#PROP_PROPERTY_SETS}).
- * @param o the old set
- * @param n the new set
- */
- public final void firePropertySetsChange( PropertySet[] o, PropertySet[] n ) {
- LookNode.this.firePropertySetsChange( o, n );
- }
-
- /** Fires a change event for {@link org.openode.nodes.Node#PROP_COOKIE}.
- * The old and new values are set to null.
- */
- public final void fireCookieChange() {
- LookNode.this.fireCookieChange();
- }
-
- /** To all node listeners fire node destroyed notification.
- */
- public final void fireNodeDestroyed() {
- LookNode.this.fireNodeDestroyed();
- }
-
- /** Tells the node that the children have to be refreshed.
- */
- public final void refreshChildren() {
- LookNode.this.refreshChildren();
- }
-
- /** Allowes to store Cookies for given node. This method could be
- *
- */
- public CookieSet getCookieSet() {
- if ( cookieSet == null ) {
- cookieSet = new CookieSet();
- }
- return cookieSet;
- }
-
- }
-
-
-}
Index: openidex/src/org/openidex/nodes/looks/LookProperties.java
===================================================================
RCS file: openidex/src/org/openidex/nodes/looks/LookProperties.java
diff -N openidex/src/org/openidex/nodes/looks/LookProperties.java
--- openidex/src/org/openidex/nodes/looks/LookProperties.java 5 Nov 2001 18:11:19 -0000 1.6
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,303 +0,0 @@
-/*
- * 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-2000 Sun
- * Microsystems, Inc. All Rights Reserved.
- */
-
-package org.openidex.nodes.looks;
-
-import java.util.*;
-import java.beans.PropertyEditor;
-import java.beans.PropertyEditorSupport;
-import java.awt.event.ActionListener;
-import java.awt.event.ActionEvent;
-import javax.swing.JMenuItem;
-import javax.swing.JMenu;
-import javax.swing.event.MenuListener;
-import javax.swing.event.MenuEvent;
-
-
-import org.openide.nodes.*;
-import org.openide.util.NbBundle;
-import org.openide.util.Lookup;
-import org.openide.util.HelpCtx;
-import org.openide.util.actions.*;
-import org.openide.awt.JMenuPlus;
-import org.openide.awt.Actions;
-
-
-/** WARNING - This API is not finished and is subject to change
- * Please don't use this API for other purposes than testing.
- *
- * Please don't use this API for other purposes than testing.
- *
- * Recomended usage of this class is to be used as delegatee.
- *
- * public class MyNodeLook extends AcceptorLook {
- *
- * public MyNodeLook() {
- * super( new NodeProxyLook(), MyNode.Class );
- * // set mask or do other initializations
- * }
- * }
- *
- *
- * @author Petr Hrebejk
- */
-public class NodeProxyLook extends Look {
-
- /** Creates new NodeProxySupport */
- public NodeProxyLook() {
- }
-
- // Methods of look itself --------------------------------------------------
-
- /** Specifies the node to which the Look delegates. The default
- * implementation returns substitute.getRepresentedObject()
- * casted to Node in case the represented object is a Node in other cases
- * it returns null. If you override this method you can provide delegation
- * nodes for different types of object. (E.g. by calling
- * dataObject.getNodeDelegate() ).
- */
- protected Node getNodeDelegate( Look.NodeSubstitute substitute ) {
-
- if ( substitute.getRepresentedObject() instanceof Node ) {
- return (Node)substitute.getRepresentedObject();
- }
- else {
- return null;
- }
- }
-
- // General methods ---------------------------------------------------------
-
- public void attachTo(Look.NodeSubstitute substitute) {
- Node dn = getNodeDelegate( substitute );
- if ( dn == null ) {
- DefaultLook.INSTANCE.attachTo( substitute );
- }
- else {
- // Register listener to the node to pass events forward
- dn.addNodeListener( new NodeEventTranslator( substitute, dn ) );
- dn.addPropertyChangeListener( new NodePropertyChangeTranslator( substitute, dn ) );
- }
- }
-
- public Node.Cookie getCookie( Look.NodeSubstitute substitute, Class type) {
- Node dn = getNodeDelegate( substitute );
- if ( dn == null ) {
- return DefaultLook.INSTANCE.getCookie( substitute, type );
- }
- else {
- return dn.getCookie( type );
- }
- }
-
- public Node.Handle getHandle( Look.NodeSubstitute substitute ) {
- Node dn = getNodeDelegate( substitute );
- if ( dn == null ) {
- return DefaultLook.INSTANCE.getHandle( substitute );
- }
- else {
- return dn.getHandle();
- }
- }
-
- // Methods for STYLE -------------------------------------------------------
-
- public String getDisplayName( Look.NodeSubstitute substitute ) {
- Node dn = getNodeDelegate( substitute );
- if ( dn == null ) {
- return DefaultLook.INSTANCE.getDisplayName( substitute );
- }
- else {
- return dn.getDisplayName();
- }
- }
-
- public String getName( Look.NodeSubstitute substitute ) {
- Node dn = getNodeDelegate( substitute );
- if ( dn == null ) {
- return DefaultLook.INSTANCE.getName( substitute );
- }
- else {
- return dn.getName();
- }
- }
-
- public void setName( Look.NodeSubstitute substitute, String newName ) {
- Node dn = getNodeDelegate( substitute );
- if ( dn == null ) {
- DefaultLook.INSTANCE.setName( substitute, newName );
- }
- else {
- dn.setName( newName );
- }
- }
-
- public String getShortDescription ( Look.NodeSubstitute substitute ) {
- Node dn = getNodeDelegate( substitute );
- if ( dn == null ) {
- return DefaultLook.INSTANCE.getShortDescription( substitute );
- }
- else {
- return dn.getShortDescription();
- }
- }
-
- public Image getIcon( Look.NodeSubstitute substitute, int type ) {
- Node dn = getNodeDelegate( substitute );
- if ( dn == null ) {
- return DefaultLook.INSTANCE.getIcon( substitute, type );
- }
- else {
- return dn.getIcon( type );
- }
- }
-
- public Image getOpenedIcon( Look.NodeSubstitute substitute, int type ) {
- Node dn = getNodeDelegate( substitute );
- if ( dn == null ) {
- return DefaultLook.INSTANCE.getOpenedIcon( substitute, type );
- }
- else {
- return dn.getOpenedIcon( type );
- }
- }
-
- public HelpCtx getHelpCtx( Look.NodeSubstitute substitute ) {
- Node dn = getNodeDelegate( substitute );
- if ( dn == null ) {
- return DefaultLook.INSTANCE.getHelpCtx( substitute );
- }
- else {
- return dn.getHelpCtx();
- }
- }
-
- // Methods for CHILDREN ----------------------------------------------------
-
- public Object[] getChildObjects( Look.NodeSubstitute substitute ) {
- Node dn = getNodeDelegate( substitute );
- if ( dn == null ) {
- return DefaultLook.INSTANCE.getChildObjects( substitute );
- }
- else {
- return dn.getChildren().getNodes();
- }
- }
-
- /* Not implemented yet
-
- public Ordering getOrdering( Look.NodeSubstitute substitute ) {
- return null;
- }
-
- public Filter getFilter( Look.NodeSubstitute substitute ) {
- return null;
- }
-
- public Grouping getGrouping( Look.NodeSubstitute substitute ) {
- return null;
- }
-
- */
-
- // Methods for ACTIONS & NEW TYPES -----------------------------------------
-
- public NewType[] getNewTypes( Look.NodeSubstitute substitute ) {
- Node dn = getNodeDelegate( substitute );
- if ( dn == null ) {
- return DefaultLook.INSTANCE.getNewTypes( substitute );
- }
- else {
- return dn.getNewTypes();
- }
- }
-
- public SystemAction[] getActions( Look.NodeSubstitute substitute ) {
- Node dn = getNodeDelegate( substitute );
- if ( dn == null ) {
- return DefaultLook.INSTANCE.getActions( substitute );
- }
- else {
- return dn.getActions();
- }
- }
-
- public SystemAction[] getContextActions( Look.NodeSubstitute substitute ) {
- Node dn = getNodeDelegate( substitute );
- if ( dn == null ) {
- return DefaultLook.INSTANCE.getContextActions( substitute );
- }
- else {
- return dn.getContextActions();
- }
- }
-
- public SystemAction getDefaultAction( Look.NodeSubstitute substitute ) {
- Node dn = getNodeDelegate( substitute );
- if ( dn == null ) {
- return DefaultLook.INSTANCE.getDefaultAction( substitute );
- }
- else {
- return dn.getDefaultAction();
- }
- }
-
- // Methods for PROPERTIES AND CUSTOMIZER -----------------------------------
-
- public Node.PropertySet[] getPropertySets( Look.NodeSubstitute substitute ) {
- Node dn = getNodeDelegate( substitute );
- if ( dn == null ) {
- return DefaultLook.INSTANCE.getPropertySets( substitute );
- }
- else {
- return dn.getPropertySets();
- }
- }
-
- public java.awt.Component getCustomizer( Look.NodeSubstitute substitute ) {
- Node dn = getNodeDelegate( substitute );
- if ( dn == null || !dn.hasCustomizer() ) {
- return DefaultLook.INSTANCE.getCustomizer( substitute );
- }
- else {
- return dn.getCustomizer();
- }
- }
-
- public boolean hasCustomizer( Look.NodeSubstitute substitute ) {
- Node dn = getNodeDelegate( substitute );
- if (dn == null) {
- return DefaultLook.INSTANCE.hasCustomizer( substitute );
- } else {
- return dn.hasCustomizer();
- }
-
- }
-
- // Methods for CLIPBOARD OPERATIONS ----------------------------------------
-
- public boolean canRename( Look.NodeSubstitute substitute ) {
- Node dn = getNodeDelegate( substitute );
- if ( dn == null ) {
- return DefaultLook.INSTANCE.canRename( substitute );
- }
- else {
- return dn.canRename();
- }
- }
-
- public boolean canDestroy( Look.NodeSubstitute substitute ) {
- Node dn = getNodeDelegate( substitute );
- if ( dn == null ) {
- return DefaultLook.INSTANCE.canDestroy( substitute );
- }
- else {
- return dn.canDestroy();
- }
- }
-
- public boolean canCopy( Look.NodeSubstitute substitute ) {
- Node dn = getNodeDelegate( substitute );
- if ( dn == null ) {
- return DefaultLook.INSTANCE.canCopy( substitute );
- }
- else {
- return dn.canCopy();
- }
- }
-
- public boolean canCut( Look.NodeSubstitute substitute ) {
- Node dn = getNodeDelegate( substitute );
- if ( dn == null ) {
- return DefaultLook.INSTANCE.canCut( substitute );
- }
- else {
- return dn.canCut();
- }
- }
-
- public PasteType[] getPasteTypes( Look.NodeSubstitute substitute, Transferable t) {
- Node dn = getNodeDelegate( substitute );
- if ( dn == null ) {
- return DefaultLook.INSTANCE.getPasteTypes( substitute, t );
- }
- else {
- return dn.getPasteTypes( t );
- }
- }
-
- public PasteType getDropType( Look.NodeSubstitute substitute, Transferable t, int action, int index) {
- Node dn = getNodeDelegate( substitute );
- if ( dn == null ) {
- return DefaultLook.INSTANCE.getDropType( substitute, t, action, index );
- }
- else {
- return dn.getDropType( t, action, index );
- }
- }
-
- public Transferable clipboardCopy( Look.NodeSubstitute substitute ) throws IOException {
- Node dn = getNodeDelegate( substitute );
- if ( dn == null ) {
- return DefaultLook.INSTANCE.clipboardCopy( substitute );
- }
- else {
- return dn.clipboardCopy();
- }
- }
-
- public Transferable clipboardCut( Look.NodeSubstitute substitute ) throws IOException {
- Node dn = getNodeDelegate( substitute );
- if ( dn == null ) {
- return DefaultLook.INSTANCE.clipboardCut( substitute );
- }
- else {
- return dn.clipboardCut();
- }
- }
-
- public Transferable drag( Look.NodeSubstitute substitute ) throws IOException {
- Node dn = getNodeDelegate( substitute );
- if ( dn == null ) {
- return DefaultLook.INSTANCE.drag( substitute );
- }
- else {
- return dn.drag();
- }
- }
-
- public void destroy( Look.NodeSubstitute substitute ) throws IOException {
- Node dn = getNodeDelegate( substitute );
- if ( dn == null ) {
- DefaultLook.INSTANCE.destroy( substitute );
- }
- else {
- dn.destroy();
- }
- }
-
-
- // Innerclasses ------------------------------------------------------------
-
- public static class NodeEventTranslator
- extends EventTranslator implements NodeListener {
-
- private Node node;
-
- NodeEventTranslator( Look.NodeSubstitute substitute, Node node) {
- super( substitute );
- this.node = node;
- }
-
- public void unregister() {
- node.removeNodeListener( this );
- }
-
- public void childrenAdded( NodeMemberEvent e ) {
- getSubstitute().refreshChildren();
- }
-
- public void childrenRemoved( NodeMemberEvent e ) {
- getSubstitute().refreshChildren();
- }
-
- public void childrenReordered( NodeReorderEvent e ) {
- getSubstitute().refreshChildren();
- }
-
- public void nodeDestroyed( NodeEvent e ) {
- getSubstitute().fireNodeDestroyed();
- }
-
- public void propertyChange( PropertyChangeEvent e ) {
-
- if ( Node.PROP_NAME.equals( e.getPropertyName() ) ) {
- getSubstitute().fireNameChange( (String)e.getOldValue(), (String)e.getNewValue() );
- }
- else if ( Node.PROP_DISPLAY_NAME.equals( e.getPropertyName() ) ) {
- getSubstitute().fireDisplayNameChange( (String)e.getOldValue(), (String)e.getNewValue() );
- }
- else if ( Node.PROP_SHORT_DESCRIPTION.equals( e.getPropertyName() ) ) {
- getSubstitute().fireShortDescriptionChange( (String)e.getOldValue(), (String)e.getNewValue() );
- }
- else if ( Node.PROP_ICON.equals( e.getPropertyName() ) ) {
- getSubstitute().fireIconChange();
- }
- else if ( Node.PROP_OPENED_ICON.equals( e.getPropertyName() ) ) {
- getSubstitute().fireOpenedIconChange();
- }
- /*
- else if ( Node.PROP_PARENT_NODE.equals( e.getPropertyName() ) ) {
- property
- }
- */
- else if ( Node.PROP_PROPERTY_SETS.equals( e.getPropertyName() ) ) {
- getSubstitute().firePropertySetsChange( (Node.PropertySet[])e.getOldValue(),
- (Node.PropertySet[])e.getNewValue() );
- }
- else if ( Node.PROP_COOKIE.equals( e.getPropertyName() ) ) {
- getSubstitute().fireCookieChange();
- }
- }
- }
-
- public static class NodePropertyChangeTranslator
- extends EventTranslator implements PropertyChangeListener {
-
- private Node node;
-
- NodePropertyChangeTranslator( Look.NodeSubstitute substitute, Node node) {
- super( substitute );
- this.node = node;
- }
-
- public void unregister() {
- node.removePropertyChangeListener( this );
- }
-
- public void propertyChange( PropertyChangeEvent e ) {
- getSubstitute().firePropertyChange( e.getPropertyName(), e.getOldValue(), e.getNewValue() );
- }
- }
-
-}
Index: openidex/src/org/openidex/nodes/looks/resources/Look.gif
===================================================================
RCS file: openidex/src/org/openidex/nodes/looks/resources/Look.gif
diff -N openidex/src/org/openidex/nodes/looks/resources/Look.gif
Binary files /tmp/cvsb.ayrR and /dev/null differ
Index: openidex/src/org/openidex/nodes/looks/resources/LookFolder.gif
===================================================================
RCS file: openidex/src/org/openidex/nodes/looks/resources/LookFolder.gif
diff -N openidex/src/org/openidex/nodes/looks/resources/LookFolder.gif
Binary files /tmp/cvsc.ayrR and /dev/null differ
Index: openidex/src/org/openidex/nodes/looks/resources/defaultNode.gif
===================================================================
RCS file: openidex/src/org/openidex/nodes/looks/resources/defaultNode.gif
diff -N openidex/src/org/openidex/nodes/looks/resources/defaultNode.gif
Binary files /tmp/cvsd.ayrR and /dev/null differ
Index: openidex/src/org/openidex/nodes/looks/resources/defaultNode32.gif
===================================================================
RCS file: openidex/src/org/openidex/nodes/looks/resources/defaultNode32.gif
diff -N openidex/src/org/openidex/nodes/looks/resources/defaultNode32.gif
Binary files /tmp/cvse.ayrR and /dev/null differ
Index: openidex/src/org/openidex/nodes/looks/resources/look.dtd
===================================================================
RCS file: openidex/src/org/openidex/nodes/looks/resources/look.dtd
diff -N openidex/src/org/openidex/nodes/looks/resources/look.dtd
--- openidex/src/org/openidex/nodes/looks/resources/look.dtd 28 Aug 2001 15:55:37 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,4 +0,0 @@
-
-
-
-
Index: openidex/test/unit/src/org/openidex/nodes/looks/DefaultLookTest.java
===================================================================
RCS file: openidex/test/unit/src/org/openidex/nodes/looks/DefaultLookTest.java
diff -N openidex/test/unit/src/org/openidex/nodes/looks/DefaultLookTest.java
--- openidex/test/unit/src/org/openidex/nodes/looks/DefaultLookTest.java 9 Oct 2001 12:28:42 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,418 +0,0 @@
-/*
- * 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-2000 Sun
- * Microsystems, Inc. All Rights Reserved.
- */
-
-package org.openidex.nodes.looks;
-
-import java.lang.ref.*;
-import java.util.*;
-
-//import junit.framework.*;
-import org.netbeans.junit.*;
-
-import java.util.List;
-import java.awt.Image;
-import java.awt.datatransfer.Transferable;
-import java.io.IOException;
-import org.openide.nodes.*;
-import org.openide.loaders.XMLDataObject;
-import org.openide.util.actions.SystemAction;
-import org.openide.util.HelpCtx;
-import org.openide.util.datatransfer.NewType;
-import org.openide.util.datatransfer.PasteType;
-
-//import org.openide.ErrorManager;
-
-
-
-public class DefaultLookTest extends NbTestCase {
-
- /** Instance of tested DefaultLook */
- private DefaultLook defaultLook;
-
- /** Message for unexpected value */
- private static final String MSSG_UNEXPECTED_VALUE_RETURNED =
- "Unexpected value returned : ";
-
- private static final String MSSG_EXCEPTION_THROWN =
- "Exception thrown.";
-
- public DefaultLookTest(java.lang.String testName) {
- super(testName);
- }
-
- public static void main(java.lang.String[] args) {
- junit.textui.TestRunner.run(suite());
- }
-
- public static NbTest suite() {
- NbTestSuite suite = new NbTestSuite(DefaultLookTest.class);
-
- return suite;
- }
-
- protected void setUp() throws Exception {
- super.setUp();
-
- // add specific setup code here
- defaultLook = new DefaultLook();
- }
-
- protected void tearDown() throws Exception {
- // add specific tear-down code here
- defaultLook = null;
-
- super.tearDown();
- }
-
-
- /** Test of attachTo method, of class org.openidex.nodes.looks.DefaultLook. */
- // Nothing to test
- /*
- public void testAttachTo() {
- System.out.println("testAttachTo");
-
- // Add your test code below by replacing the default call to fail.
- fail("The test case is empty.");
- }
- */
-
- /** Test of getCookie method, of class org.openidex.nodes.looks.DefaultLook. */
- /*
- public void testGetCookie() {
- System.out.println("testGetCookie");
-
- // Add your test code below by replacing the default call to fail.
-
- Node.Cookie cookie = defaultLook.getCookie( null, null );
-
- if ( cookie != null ) {
- fail( MSSG_UNEXPECTED_VALUE_RETURNED + cookie );
- }
- }
- */
-
- /** Test of getHandle method, of class org.openidex.nodes.looks.DefaultLook. */
- public void testGetHandle() {
- System.out.println("testGetHandle");
-
- // Add your test code below by replacing the default call to fail.
- Node.Handle handle = defaultLook.getHandle( null );
-
- if ( handle != null ) {
- fail( MSSG_UNEXPECTED_VALUE_RETURNED + handle );
- }
- }
-
- /** Test of getDisplayName method, of class org.openidex.nodes.looks.DefaultLook. */
- public void testGetDisplayName() {
- System.out.println("testGetDisplayName");
-
- // Add your test code below by replacing the default call to fail.
- String displayName = defaultLook.getDisplayName( null );
-
- if ( displayName != null ) {
- fail( MSSG_UNEXPECTED_VALUE_RETURNED + displayName );
- }
- }
-
- /** Test of getName method, of class org.openidex.nodes.looks.DefaultLook. */
- public void testGetName() {
- System.out.println("testGetName");
-
- // Add your test code below by replacing the default call to fail.
- String name = defaultLook.getName( null );
-
- if ( name != null ) {
- fail( MSSG_UNEXPECTED_VALUE_RETURNED + name );
- }
- }
-
- /** Test of setName method, of class org.openidex.nodes.looks.DefaultLook. */
- // Nothing to test
- /*
- public void testSetName() {
- System.out.println("testSetName");
-
- // Add your test code below by replacing the default call to fail.
- fail("The test case is empty.");
- }
- */
-
- /** Test of getShortDescription method, of class org.openidex.nodes.looks.DefaultLook. */
- public void testGetShortDescription() {
- System.out.println("testGetShortDescription");
-
- // Add your test code below by replacing the default call to fail.
- String shortDescription = defaultLook.getShortDescription( null );
-
- if ( shortDescription != null ) {
- fail( MSSG_UNEXPECTED_VALUE_RETURNED + shortDescription );
- }
- }
-
- /** Test of getIcon method, of class org.openidex.nodes.looks.DefaultLook. */
- public void testGetIcon() {
- System.out.println("testGetIcon");
-
- // Add your test code below by replacing the default call to fail.
- Image icon = defaultLook.getIcon( null, 0 );
-
- if ( icon != null ) {
- fail( MSSG_UNEXPECTED_VALUE_RETURNED + icon );
- }
- }
-
- /** Test of getOpenedIcon method, of class org.openidex.nodes.looks.DefaultLook. */
- public void testGetOpenedIcon() {
- System.out.println("testGetOpenedIcon");
-
- // Add your test code below by replacing the default call to fail.
- Image openedIcon = defaultLook.getOpenedIcon( null, 0 );
-
- if ( openedIcon != null ) {
- fail( MSSG_UNEXPECTED_VALUE_RETURNED + openedIcon );
- }
- }
-
- /** Test of getHelpCtx method, of class org.openidex.nodes.looks.DefaultLook. */
- public void testGetHelpCtx() {
- System.out.println("testGetHelpCtx");
-
- // Add your test code below by replacing the default call to fail.
- HelpCtx helpCtx = defaultLook.getHelpCtx( null );
-
- if ( helpCtx != null ) {
- fail( MSSG_UNEXPECTED_VALUE_RETURNED + helpCtx );
- }
- }
-
- /** Test of getChildObjects method, of class org.openidex.nodes.looks.DefaultLook. */
- public void testGetChildObjects() {
- System.out.println("testGetChildObjects");
-
- // Add your test code below by replacing the default call to fail.
- Object[] children = defaultLook.getChildObjects( null );
-
- if ( children != DefaultLook.INSTANCE.NO_KEYS ) {
- fail( MSSG_UNEXPECTED_VALUE_RETURNED + children );
- }
- }
-
- /** Test of getNewTypes method, of class org.openidex.nodes.looks.DefaultLook. */
- public void testGetNewTypes() {
- System.out.println("testGetNewTypes");
-
- // Add your test code below by replacing the default call to fail.
- NewType[] newTypes = defaultLook.getNewTypes( null );
-
- if ( newTypes != DefaultLook.INSTANCE.NO_NEW_TYPES ) {
- fail( MSSG_UNEXPECTED_VALUE_RETURNED + newTypes );
- }
- }
-
- /** Test of getActions method, of class org.openidex.nodes.looks.DefaultLook. */
- public void testGetActions() {
- System.out.println("testGetActions");
-
- // Add your test code below by replacing the default call to fail.
- SystemAction[] actions = defaultLook.getActions( null );
-
- if ( actions != DefaultLook.INSTANCE.NO_SYSTEM_ACTIONS ) {
- fail( MSSG_UNEXPECTED_VALUE_RETURNED + actions );
- }
- }
-
- /** Test of getContextActions method, of class org.openidex.nodes.looks.DefaultLook. */
- public void testGetContextActions() {
- System.out.println("testGetContextActions");
-
- // Add your test code below by replacing the default call to fail.
- SystemAction[] contextActions = defaultLook.getContextActions( null );
-
- if ( contextActions != DefaultLook.INSTANCE.NO_SYSTEM_ACTIONS ) {
- fail( MSSG_UNEXPECTED_VALUE_RETURNED + contextActions );
- }
- }
-
- /** Test of getDefaultAction method, of class org.openidex.nodes.looks.DefaultLook. */
- public void testGetDefaultAction() {
- System.out.println("testGetDefaultAction");
-
- // Add your test code below by replacing the default call to fail.
- SystemAction defaultAction = defaultLook.getDefaultAction( null );
-
- if ( defaultAction != null ) {
- fail( MSSG_UNEXPECTED_VALUE_RETURNED + defaultAction );
- }
- }
-
- /** Test of getPropertySets method, of class org.openidex.nodes.looks.DefaultLook. */
- public void testGetPropertySets() {
- System.out.println("testGetPropertySets");
-
- // Add your test code below by replacing the default call to fail.
- Node.PropertySet[] propertySets = defaultLook.getPropertySets( null );
-
- if ( propertySets != DefaultLook.INSTANCE.NO_PROPERTY_SETS ) {
- fail( MSSG_UNEXPECTED_VALUE_RETURNED + propertySets );
- }
- }
-
- /** Test of getCustomizer method, of class org.openidex.nodes.looks.DefaultLook. */
- public void testGetCustomizer() {
- System.out.println("testGetCustomizer");
-
- // Add your test code below by replacing the default call to fail.
- java.awt.Component customizer = defaultLook.getCustomizer( null );
-
- if ( customizer != null ) {
- fail( MSSG_UNEXPECTED_VALUE_RETURNED + customizer );
- }
- }
-
- /** Test of canRename method, of class org.openidex.nodes.looks.DefaultLook. */
- public void testCanRename() {
- System.out.println("testCanRename");
-
- // Add your test code below by replacing the default call to fail.
- boolean canRename = defaultLook.canRename( null );
-
- if ( canRename != false ) {
- fail( MSSG_UNEXPECTED_VALUE_RETURNED + canRename );
- }
- }
-
- /** Test of canDestroy method, of class org.openidex.nodes.looks.DefaultLook. */
- public void testCanDestroy() {
- System.out.println("testCanDestroy");
-
- // Add your test code below by replacing the default call to fail.
- boolean canDestroy = defaultLook.canDestroy( null );
-
- if ( canDestroy != false ) {
- fail( MSSG_UNEXPECTED_VALUE_RETURNED + canDestroy );
- }
- }
-
- /** Test of canCopy method, of class org.openidex.nodes.looks.DefaultLook. */
- public void testCanCopy() {
- System.out.println("testCanCopy");
-
- // Add your test code below by replacing the default call to fail.
- boolean canCopy = defaultLook.canCopy( null );
-
- if ( canCopy != false ) {
- fail( MSSG_UNEXPECTED_VALUE_RETURNED + canCopy );
- }
- }
-
- /** Test of canCut method, of class org.openidex.nodes.looks.DefaultLook. */
- public void testCanCut() {
- System.out.println("testCanCut");
-
- // Add your test code below by replacing the default call to fail.
- boolean canCut = defaultLook.canCut( null );
-
- if ( canCut != false ) {
- fail( MSSG_UNEXPECTED_VALUE_RETURNED + canCut );
- }
- }
-
- /** Test of getPasteTypes method, of class org.openidex.nodes.looks.DefaultLook. */
- public void testGetPasteTypes() {
- System.out.println("testGetPasteTypes");
-
- // Add your test code below by replacing the default call to fail.
- PasteType pasteTypes[] = defaultLook.getPasteTypes( null, null );
-
- if ( pasteTypes != DefaultLook.INSTANCE.NO_PASTE_TYPES ) {
- fail( MSSG_UNEXPECTED_VALUE_RETURNED + pasteTypes );
- }
- }
-
- /** Test of getDropType method, of class org.openidex.nodes.looks.DefaultLook. */
- public void testGetDropType() {
- System.out.println("testGetDropType");
-
- // Add your test code below by replacing the default call to fail.
- PasteType dropType = defaultLook.getDropType( null, null, 0, 0 );
-
- if ( dropType != null ) {
- fail( MSSG_UNEXPECTED_VALUE_RETURNED + dropType );
- }
- }
-
- /** Test of clipboardCopy method, of class org.openidex.nodes.looks.DefaultLook. */
- public void testClipboardCopy() {
- System.out.println("testClipboardCopy");
-
- // Add your test code below by replacing the default call to fail.
- try {
- Transferable transferable = defaultLook.clipboardCopy( null );
-
- if ( transferable != null ) {
- fail( MSSG_UNEXPECTED_VALUE_RETURNED + transferable );
- }
- }
- catch ( java.io.IOException e ) {
- fail ( MSSG_EXCEPTION_THROWN );
- }
- }
-
- /** Test of clipboardCut method, of class org.openidex.nodes.looks.DefaultLook. */
- public void testClipboardCut() {
- System.out.println("testClipboardCut");
-
- // Add your test code below by replacing the default call to fail.
- try {
- Transferable transferable = defaultLook.clipboardCut( null );
-
- if ( transferable != null ) {
- fail( MSSG_UNEXPECTED_VALUE_RETURNED + transferable );
- }
- }
- catch ( java.io.IOException e ) {
- fail ( MSSG_EXCEPTION_THROWN );
- }
-
- }
-
- /** Test of drag method, of class org.openidex.nodes.looks.DefaultLook. */
- public void testDrag() {
- System.out.println("testDrag");
-
- // Add your test code below by replacing the default call to fail.
- try {
- Transferable transferable = defaultLook.drag( null );
-
- if ( transferable != null ) {
- fail( MSSG_UNEXPECTED_VALUE_RETURNED + transferable );
- }
- }
- catch ( java.io.IOException e ) {
- fail ( MSSG_EXCEPTION_THROWN );
- }
- }
-
- /** Test of destroy method, of class org.openidex.nodes.looks.DefaultLook. */
- // Nothing to test
- /*
- public void testDestroy() {
- System.out.println("testDestroy");
-
- // Add your test code below by replacing the default call to fail.
- fail("The test case is empty.");
- }
- */
-
-}
Index: openidex/test/unit/src/org/openidex/nodes/looks/FilterLookTest.java
===================================================================
RCS file: openidex/test/unit/src/org/openidex/nodes/looks/FilterLookTest.java
diff -N openidex/test/unit/src/org/openidex/nodes/looks/FilterLookTest.java
--- openidex/test/unit/src/org/openidex/nodes/looks/FilterLookTest.java 15 Sep 2002 20:23:45 -0000 1.5
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,653 +0,0 @@
-/*
- * 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 Forte for Java, Community Edition. The Initial
- * Developer of the Original Code is Sun Microsystems, Inc. Portions
- * Copyright 1997-2000 Sun Microsystems, Inc. All Rights Reserved.
- */
-
-package org.openidex.nodes.looks;
-
-import java.util.Collection;
-import java.util.List;
-import java.awt.Image;
-import java.awt.datatransfer.Transferable;
-import java.io.IOException;
-import org.openide.nodes.*;
-import org.openide.util.actions.SystemAction;
-import org.openide.util.HelpCtx;
-import org.openide.util.datatransfer.NewType;
-import org.openide.util.datatransfer.PasteType;
-//import junit.framework.*;
-import org.netbeans.junit.*;
-
-public class FilterLookTest extends NbTestCase {
-
- private static final String MSSG_UNEXPECTED_EXCEPTION = "Unexpected exception caught : ";
-
- /** Array with masks and results */
- private TestingItem[] testingItems = new TestingItem[] {
- new TestingItem( FilterLook.ATTACH_TO, "ATTACH_TO" ),
- new TestingItem( FilterLook.GET_COOKIE, "GET_COOKIE" ),
- new TestingItem( FilterLook.GET_HANDLE, "GET_HANDLE" ),
- new TestingItem( FilterLook.GET_DISPLAY_NAME, "GET_DISPLAY_NAME" ),
- new TestingItem( FilterLook.GET_NAME, "GET_NAME" ),
- new TestingItem( FilterLook.SET_NAME, "SET_NAME" ),
- new TestingItem( FilterLook.GET_SHORT_DESCRIPTION, "GET_SHORT_DESCRIPTION" ),
- new TestingItem( FilterLook.GET_ICON, "GET_ICON" ),
- new TestingItem( FilterLook.GET_OPENED_ICON, "GET_OPENED_ICON" ),
- new TestingItem( FilterLook.GET_HELP_CTX, "GET_HELP_CTX" ),
- new TestingItem( FilterLook.GET_CHILD_OBJECTS, "GET_CHILD_OBJECTS" ),
- new TestingItem( FilterLook.GET_NEW_TYPES, "GET_NEW_TYPES" ),
- new TestingItem( FilterLook.GET_ACTIONS, "GET_ACTIONS" ),
- new TestingItem( FilterLook.GET_CONTEXT_ACTIONS, "GET_CONTEXT_ACTIONS" ),
- new TestingItem( FilterLook.GET_DEFAULT_ACTION, "GET_DEFAULT_ACTION" ),
- new TestingItem( FilterLook.GET_PROPERTY_SETS, "GET_PROPERTY_SETS" ),
- new TestingItem( FilterLook.GET_CUSTOMIZER, "GET_CUSTOMIZER" ),
- new TestingItem( FilterLook.CAN_RENAME, "CAN_RENAME" ),
- new TestingItem( FilterLook.CAN_DESTROY, "CAN_DESTROY" ),
- new TestingItem( FilterLook.CAN_COPY, "CAN_COPY" ),
- new TestingItem( FilterLook.CAN_CUT, "CAN_CUT" ),
- new TestingItem( FilterLook.GET_PASTE_TYPES, "GET_PASTE_TYPES" ),
- new TestingItem( FilterLook.GET_DROP_TYPE, "GET_DROP_TYPE" ),
- new TestingItem( FilterLook.CLIPBOARD_COPY, "CLIPBOARD_COPY" ),
- new TestingItem( FilterLook.CLIPBOARD_CUT, "CLIPBOARD_CUT" ),
- new TestingItem( FilterLook.DRAG, "DRAG" ),
- new TestingItem( FilterLook.DESTROY, "DESTROY" )
- };
-
- /** Filter look to test on */
- private FilterLook filterLook;
-
- /** Look which will be filtered */
- private SampleLook1Hid sampleLook;
-
- /** Node substitute to test on */
- private FilterLook.FilterNodeSubstitute substitute;
-
- /** Name to be set */
- private static final String NAME_TO_SET = "SomeName";
-
- Class COOKIE = Object.class;
-
- int ICON_TYPE = 0;
-
- int OPENED_ICON_TYPE = 0;
-
- Transferable PASTE_TYPE = null;
-
- Transferable DROP_TYPE = null;
- int DROP_INDEX = 0;
- int DROP_ACTION = 0;
-
-
-
- public FilterLookTest(java.lang.String testName) {
- super(testName);
- }
-
- public static void main(java.lang.String[] args) {
- junit.textui.TestRunner.run(suite());
- }
-
- public static NbTest suite() {
- NbTestSuite suite = new NbTestSuite(FilterLookTest.class);
-
- return suite;
- }
-
- protected void setUp() throws Exception {
- super.setUp();
-
- // add specific setup code here
- sampleLook = new SampleLook1Hid();
- filterLook = new FilterLook( sampleLook );
-
- substitute = new FilterLook.FilterNodeSubstitute(
- new SampleLook1Hid.NodeSubstitute(),
- filterLook );
- }
-
- protected void tearDown() throws Exception {
- // add specific tear-down code here
- filterLook = null;
- substitute = null;
- sampleLook = null;
-
- super.tearDown();
- }
-
-
- /** Test of setLookMask method, of class org.openidex.nodes.looks.FilterLook. */
- /*
- public void testSetLookMask() {
- System.out.println("testSetLookMask");
-
- // Add your test code below by replacing the default call to fail.
- fail("The test case is empty.");
- }
- */
- /** Test of getLookMask method, of class org.openidex.nodes.looks.FilterLook. */
- /*
- public void testGetLookMask() {
- System.out.println("testGetLookMask");
-
- // Add your test code below by replacing the default call to fail.
- fail("The test case is empty.");
- }
- */
-
- /** Test of lookMask method, of class org.openidex.nodes.looks.FilterLook. */
- /*
- public void testLookMask() {
- System.out.println("testLookMask");
-
- // Add your test code below by replacing the default call to fail.
- fail("The test case is empty.");
- }
- */
-
- /** Test of lookUnmask method, of class org.openidex.nodes.looks.FilterLook. */
- /*
- public void testLookUnmask() {
- System.out.println("testLookUnmask");
-
- // Add your test code below by replacing the default call to fail.
- fail("The test case is empty.");
- }
- */
- /** Test of attachTo method, of class org.openidex.nodes.looks.FilterLook. */
- /*
- public void testAttachTo() {
- System.out.println("testAttachTo");
-
- // Add your test code below by replacing the default call to fail.
- fail("The test case is empty.");
- }
- */
-
- /** Tests whether the constants defined in the right order and whether
- * there is no owerflow.
- */
- public void testMaskOrder() {
- System.out.println("testMaskOrder");
-
- // Add your test code below by replacing the default call to fail.
-
- for ( int i = 0, j = 1; i < testingItems.length; i++ ) {
- if ( testingItems[i].mask != j ) {
- fail("Ordering failed : " + i );
- }
- j *= 2;
- }
- }
-
- public void test_ATTACH_TO() {
- System.out.println("test_ATTACH_TO");
-
- // Add your test code below by replacing the default call to fail.
- int failIndex = doTestingWithMask( FilterLook.ATTACH_TO );
- if ( failIndex > -1 ) {
- fail( getFailMessage( failIndex) );
- }
- }
-
- public void test_GET_COOKIE() {
- System.out.println("test_GET_COOKIE");
-
- // Add your test code below by replacing the default call to fail.
- int failIndex = doTestingWithMask( FilterLook.GET_COOKIE );
- if ( failIndex > -1 ) {
- fail( getFailMessage( failIndex ) );
- }
- }
-
- public void test_GET_HANDLE() {
- System.out.println("test_GET_HANDLE");
-
- // Add your test code below by replacing the default call to fail.
- int failIndex = doTestingWithMask( FilterLook.GET_HANDLE );
- if ( failIndex > -1 ) {
- fail( getFailMessage( failIndex ) );
- }
- }
-
- public void test_GET_DISPLAY_NAME() {
- System.out.println("test_GET_DISPLAY_NAME");
-
- // Add your test code below by replacing the default call to fail.
- int failIndex = doTestingWithMask( FilterLook.GET_DISPLAY_NAME );
- if ( failIndex > -1 ) {
- fail( getFailMessage( failIndex ) );
- }
- }
-
- public void test_GET_NAME() {
- System.out.println("test_GET_NAME");
-
- // Add your test code below by replacing the default call to fail.
- int failIndex = doTestingWithMask( FilterLook.GET_NAME );
- if ( failIndex > -1 ) {
- fail( getFailMessage( failIndex ) );
- }
- }
-
- public void test_SET_NAME() {
- System.out.println("test_SET_NAME");
-
- // Add your test code below by replacing the default call to fail.
- int failIndex = doTestingWithMask( FilterLook.SET_NAME );
- if ( failIndex > -1 ) {
- fail( getFailMessage( failIndex ) );
- }
- }
-
- public void test_GET_SHORT_DESCRIPTION () {
- System.out.println("test_GET_SHORT_DESCRIPTION");
-
- // Add your test code below by replacing the default call to fail.
- int failIndex = doTestingWithMask( FilterLook.GET_SHORT_DESCRIPTION );
- if ( failIndex > -1 ) {
- fail( getFailMessage( failIndex ) );
- }
- }
-
- public void test_GET_ICON() {
- System.out.println("test_GET_ICON");
-
- // Add your test code below by replacing the default call to fail.
- int failIndex = doTestingWithMask( FilterLook.GET_ICON );
- if ( failIndex > -1 ) {
- fail( getFailMessage( failIndex ) );
- }
- }
- public void test_GET_OPENED_ICON () {
- System.out.println("test_GET_OPENED_ICON");
-
- // Add your test code below by replacing the default call to fail.
- int failIndex = doTestingWithMask( FilterLook.GET_OPENED_ICON );
- if ( failIndex > -1 ) {
- fail( getFailMessage( failIndex ) );
- }
- }
- public void test_GET_HELP_CTX () {
- System.out.println("test_GET_HELP_CTX");
-
- // Add your test code below by replacing the default call to fail.
- int failIndex = doTestingWithMask( FilterLook.GET_HELP_CTX );
- if ( failIndex > -1 ) {
- fail( getFailMessage( failIndex ) );
- }
- }
-
- public void test_GET_CHILD_OBJECTS () {
- System.out.println("test_GET_CHILD_OBJECTS");
-
- // Add your test code below by replacing the default call to fail.
- int failIndex = doTestingWithMask( FilterLook.GET_CHILD_OBJECTS );
- if ( failIndex > -1 ) {
- fail( getFailMessage( failIndex ) );
- }
- }
-
- public void test_GET_NEW_TYPES () {
- System.out.println("test_GET_NEW_TYPES");
-
- // Add your test code below by replacing the default call to fail.
- int failIndex = doTestingWithMask( FilterLook.GET_NEW_TYPES );
- if ( failIndex > -1 ) {
- fail( getFailMessage( failIndex ) );
- }
- }
-
- public void test_GET_ACTIONS () {
- System.out.println("test_GET_ACTIONS");
-
- // Add your test code below by replacing the default call to fail.
- int failIndex = doTestingWithMask( FilterLook.GET_ACTIONS );
- if ( failIndex > -1 ) {
- fail( getFailMessage( failIndex ) );
- }
- }
-
- public void test_GET_CONTEXT_ACTIONS () {
- System.out.println("test_GET_CONTEXT_ACTIONS");
-
- // Add your test code below by replacing the default call to fail.
- int failIndex = doTestingWithMask( FilterLook.GET_CONTEXT_ACTIONS );
- if ( failIndex > -1 ) {
- fail( getFailMessage( failIndex ) );
- }
- }
-
- public void test_GET_DEFAULT_ACTION () {
- System.out.println("test_GET_DEFAULT_ACTION");
-
- // Add your test code below by replacing the default call to fail.
- int failIndex = doTestingWithMask( FilterLook.GET_DEFAULT_ACTION );
- if ( failIndex > -1 ) {
- fail( getFailMessage( failIndex ) );
- }
- }
-
- public void test_GET_PROPERTY_SETS () {
- System.out.println("test_GET_PROPERTY_SETS");
-
- // Add your test code below by replacing the default call to fail.
- int failIndex = doTestingWithMask( FilterLook.GET_PROPERTY_SETS );
- if ( failIndex > -1 ) {
- fail( getFailMessage( failIndex ) );
- }
- }
-
- public void test_GET_CUSTOMIZER () {
- System.out.println("test_GET_CUSTOMIZER");
-
- // Add your test code below by replacing the default call to fail.
- int failIndex = doTestingWithMask( FilterLook.GET_CUSTOMIZER );
- if ( failIndex > -1 ) {
- fail( getFailMessage( failIndex ) );
- }
- }
-
- public void test_CAN_RENAME () {
- System.out.println("test_CAN_RENAME");
-
- // Add your test code below by replacing the default call to fail.
- int failIndex = doTestingWithMask( FilterLook.CAN_RENAME );
- if ( failIndex > -1 ) {
- fail( getFailMessage( failIndex ) );
- }
- }
-
- public void test_CAN_DESTROY () {
- System.out.println("test_CAN_DESTROY");
-
- // Add your test code below by replacing the default call to fail.
- int failIndex = doTestingWithMask( FilterLook.CAN_DESTROY );
- if ( failIndex > -1 ) {
- fail( "Failed on method index : " + failIndex + " : " + testingItems[ failIndex ].value );
- }
- }
-
- public void test_CAN_COPY () {
- System.out.println("test_CAN_COPY");
-
- // Add your test code below by replacing the default call to fail.
- int failIndex = doTestingWithMask( FilterLook.CAN_COPY );
- if ( failIndex > -1 ) {
- fail( "Failed on method index : " + failIndex + " : " + testingItems[ failIndex ].value );
- }
- }
-
- public void test_CAN_CUT () {
- System.out.println("test_CAN_CUT");
-
- // Add your test code below by replacing the default call to fail.
- int failIndex = doTestingWithMask( FilterLook.CAN_CUT );
- if ( failIndex > -1 ) {
- fail( "Failed on method index : " + failIndex + " : " + testingItems[ failIndex ].value );
- }
- }
-
- public void test_GET_PASTE_TYPES () {
- System.out.println("test_GET_PASTE_TYPES");
-
- // Add your test code below by replacing the default call to fail.
- int failIndex = doTestingWithMask( FilterLook.GET_PASTE_TYPES );
- if ( failIndex > -1 ) {
- fail( "Failed on method index : " + failIndex + " : " + testingItems[ failIndex ].value );
- }
- }
-
- public void test_GET_DROP_TYPE () {
- System.out.println("test_GET_DROP_TYPE");
-
- // Add your test code below by replacing the default call to fail.
- int failIndex = doTestingWithMask( FilterLook.GET_DROP_TYPE );
- if ( failIndex > -1 ) {
- fail( "Failed on method index : " + failIndex + " : " + testingItems[ failIndex ].value );
- }
- }
-
- public void test_CLIPBOARD_COPY () {
- System.out.println("test_CLIPBOARD_COPY");
-
- // Add your test code below by replacing the default call to fail.
- int failIndex = doTestingWithMask( FilterLook.CLIPBOARD_COPY );
- if ( failIndex > -1 ) {
- fail( getFailMessage( failIndex ) );
- }
- }
-
- public void test_CLIPBOARD_CUT () {
- System.out.println("test_CLIPBOARD_CUT");
-
- // Add your test code below by replacing the default call to fail.
- int failIndex = doTestingWithMask( FilterLook.CLIPBOARD_CUT );
- if ( failIndex > -1 ) {
- fail( getFailMessage( failIndex ) );
- }
- }
-
- public void test_DRAG () {
- System.out.println("test_DRAG");
-
- // Add your test code below by replacing the default call to fail.
- int failIndex = doTestingWithMask( FilterLook.DRAG );
- if ( failIndex > -1 ) {
- fail( getFailMessage( failIndex ));
- }
- }
-
- public void test_DESTROY () {
- System.out.println("test_DESTROY");
-
- // Add your test code below by replacing the default call to fail.
- int failIndex = doTestingWithMask( FilterLook.DESTROY );
- if ( failIndex > -1 ) {
- fail( getFailMessage( failIndex ) );
- }
- }
-
- // Private methods ---------------------------------------------------------
-
- private int doTestingWithMask( long mask ) {
- filterLook.setLookMask( mask );
- clearTestArray();
- fillTestArray();
-
- for( int i = 0; i < testingItems.length; i ++ ) {
- if ( ( ( testingItems[i].mask & mask ) > 0 && testingItems[i].value == null ) ||
- ( ( testingItems[i].mask & mask ) == 0 && testingItems[i].value != null )) {
- return i;
- }
- }
-
- return -1;
- }
-
- private void clearTestArray() {
- for ( int i = 0; i < testingItems.length; i++ ) {
- testingItems[i].value = null;
- }
- }
-
- private void fillTestArray() {
-
- int i = 0;
-
-
- filterLook.attachTo( substitute );
- Boolean attachTo = sampleLook.getAttachToCalled( ) ? Boolean.TRUE : null;
-
- Node.Cookie cookie = filterLook.getCookie( substitute, COOKIE );
-
- Node.Handle handle = filterLook.getHandle( substitute );
-
- String displayName = filterLook.getDisplayName( substitute );
-
- String name = filterLook.getName( substitute );
-
- filterLook.setName(substitute, NAME_TO_SET );
- String setName = sampleLook.getSetNameCalled() ? NAME_TO_SET : null;
-
- String shortDescription = filterLook.getShortDescription( substitute );
-
- Image icon = filterLook.getIcon( substitute, ICON_TYPE );
-
- Image openedIcon = filterLook.getOpenedIcon( substitute, OPENED_ICON_TYPE );
-
- HelpCtx helpCtx = filterLook.getHelpCtx( substitute );
-
- Object[] children = filterLook.getChildObjects( substitute );
- children = children == Look.NO_KEYS ? null : children;
-
- NewType[] newTypes = filterLook.getNewTypes( substitute );
- newTypes = newTypes == Look.NO_NEW_TYPES ? null : newTypes;
-
- SystemAction[] systemActions = filterLook.getActions( substitute );
- systemActions = systemActions == Look.NO_SYSTEM_ACTIONS ? null : systemActions;
-
- SystemAction[] contextActions = filterLook.getContextActions( substitute );
- contextActions = contextActions == Look.NO_SYSTEM_ACTIONS ? null : contextActions;
-
- SystemAction defaultAction = filterLook.getDefaultAction( substitute );
-
- Node.PropertySet[] propertySets = filterLook.getPropertySets( substitute );
- propertySets = propertySets == Look.NO_PROPERTY_SETS ? null : propertySets;
-
- java.awt.Component customizer = filterLook.getCustomizer( substitute );
-
- Boolean canRename = filterLook.canRename( substitute ) ? Boolean.TRUE : null;
-
- Boolean canDestroy = filterLook.canDestroy( substitute )? Boolean.TRUE : null;
-
- Boolean canCopy = filterLook.canCopy( substitute )? Boolean.TRUE : null;
-
- Boolean canCut = filterLook.canCut( substitute )? Boolean.TRUE : null;
-
- PasteType[] pasteTypes = filterLook.getPasteTypes( substitute, PASTE_TYPE );
- pasteTypes = pasteTypes == Look.NO_PASTE_TYPES ? null : pasteTypes;
-
- PasteType dropType = filterLook.getDropType( substitute, DROP_TYPE, DROP_ACTION, DROP_INDEX );
- Transferable copy = null;
- try {
- copy = filterLook.clipboardCopy( substitute );
- }
- catch ( java.io.IOException e ) {
- fail( MSSG_UNEXPECTED_EXCEPTION + e );
- }
- Transferable cut = null;
- try {
- cut = filterLook.clipboardCut( substitute );
- }
- catch ( java.io.IOException e ) {
- fail( MSSG_UNEXPECTED_EXCEPTION + e );
- }
- Transferable drag = null;
- try {
- drag = filterLook.drag( substitute );
- }
- catch ( java.io.IOException e ) {
- fail( MSSG_UNEXPECTED_EXCEPTION + e );
- }
- Boolean destroy = null;
- try {
- filterLook.destroy( substitute );
- destroy = sampleLook.getDestroyCalled() ? Boolean.TRUE : null;
- }
- catch ( java.io.IOException e ) {
- fail( MSSG_UNEXPECTED_EXCEPTION + e );
- }
-
-
- testingItems[i].value = attachTo;
- i++;
- testingItems[i].value = cookie;
- i++;
- testingItems[i].value = handle;
- i++;
- testingItems[i].value = displayName;
- i++;
- testingItems[i].value = name;
- i++;
- testingItems[i].value = setName;
- i++;
- testingItems[i].value = shortDescription;
- i++;
- testingItems[i].value = icon;
- i++;
- testingItems[i].value = openedIcon;
- i++;
- testingItems[i].value = helpCtx;
- i++;
- testingItems[i].value = children;
- i++;
- testingItems[i].value = newTypes;
- i++;
- testingItems[i].value = systemActions;
- i++;
- testingItems[i].value = contextActions;
- i++;
- testingItems[i].value = defaultAction;
- i++;
- testingItems[i].value = propertySets;
- i++;
- testingItems[i].value = customizer;
- i++;
- testingItems[i].value = canRename;
- i++;
- testingItems[i].value = canDestroy;
- i++;
- testingItems[i].value = canCopy;
- i++;
- testingItems[i].value = canCut;
- i++;
- testingItems[i].value = pasteTypes;
- i++;
- testingItems[i].value = dropType;
- i++;
- testingItems[i].value = copy;
- i++;
- testingItems[i].value = cut;
- i++;
- testingItems[i].value = drag;
- i++;
- testingItems[i].value = destroy;
- i++;
-
- }
-
- private String getFailMessage( int failIndex ) {
- return "Failed on method index : " + failIndex + " : " +
- testingItems[ failIndex ].name + " = " +
- testingItems[ failIndex ].value;
- }
-
- // Innerclasses ------------------------------------------------------------
-
- /** Represents one item in the test array.
- */
- private class TestingItem {
-
- private long mask;
-
- private Object value;
-
- private String name;
-
-
- TestingItem( long mask, String name ) {
- this.mask = mask;
- this.name = name;
- }
-
- }
-
-}
Index: openidex/test/unit/src/org/openidex/nodes/looks/LookNodeEventsTest.java
===================================================================
RCS file: openidex/test/unit/src/org/openidex/nodes/looks/LookNodeEventsTest.java
diff -N openidex/test/unit/src/org/openidex/nodes/looks/LookNodeEventsTest.java
--- openidex/test/unit/src/org/openidex/nodes/looks/LookNodeEventsTest.java 9 Oct 2001 12:28:42 -0000 1.4
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,535 +0,0 @@
-/*
- * 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 Forte for Java, Community Edition. The Initial
- * Developer of the Original Code is Sun Microsystems, Inc. Portions
- * Copyright 1997-2000 Sun Microsystems, Inc. All Rights Reserved.
- */
-
-
-package org.openidex.nodes.looks;
-
-import java.beans.*;
-import java.awt.Image;
-import java.awt.datatransfer.Transferable;
-import java.awt.event.ActionListener;
-import java.awt.event.ActionEvent;
-import java.io.IOException;
-import java.util.ArrayList;
-
-import javax.swing.event.ChangeListener;
-import javax.swing.event.ChangeEvent;
-import javax.swing.JMenuItem;
-import javax.swing.JMenu;
-import javax.swing.event.MenuListener;
-import javax.swing.event.MenuEvent;
-
-import org.openide.nodes.*;
-import org.openide.util.HelpCtx;
-import org.openide.util.NbBundle;
-import org.openide.util.actions.SystemAction;
-import org.openide.util.datatransfer.NewType;
-import org.openide.util.datatransfer.PasteType;
-import org.openide.awt.JMenuPlus;
-import org.openide.util.actions.CallableSystemAction;
-import org.openide.util.actions.Presenter;
-import org.openide.awt.Actions;
-import org.openide.util.HelpCtx;
-import org.openide.actions.SaveAllAction;
-import org.openide.util.actions.NodeAction;
-
-//import junit.framework.*;
-import org.netbeans.junit.*;
-
-public class LookNodeEventsTest extends NbTestCase {
-
- /** Sample look we test against */
- SampleLook1Hid sampleLook;
-
- /** The node to test on */
- LookNode lookNode;
-
- /** NodeSubstitute for the lookNode */
- Look.NodeSubstitute nodeSubstitute;
-
- /** Represented object of the tested node */
- String representedObject;
-
- /** The test listener used for the node */
- TestNodeListener testNodeListener;
-
- /** Property change listener */
- TestPropertyChangeListener testPcl;
-
- // Constants for testing
-
- String TEST_PROP_NAME = "TestPropName";
- String TEST_PROP_OLD = "TestPropOld";
- String TEST_PROP_NEW = "TestPropNew";
-
-
- String OLD_NAME = "OldName";
- String NEW_NAME = "NewName";
-
- String OLD_DISPLAY_NAME = "OldDisplayName";
- String NEW_DISPLAY_NAME = "NewDisplayName";
-
- String OLD_SHORT_DESCRIPTION = "OldShortDescription";
- String NEW_SHORT_DESCRIPTION = "NewShortDescription";
-
- static final Node.PropertySet[] OLD_PROPERTY_SETS = new Node.PropertySet[] {
- new Sheet.Set(),
- new Sheet.Set()
- };
-
- static final Node.PropertySet[] NEW_PROPERTY_SETS = new Node.PropertySet[] {
- new Sheet.Set(),
- new Sheet.Set()
- };
-
- public LookNodeEventsTest(java.lang.String testName) {
- super(testName);
- }
-
- public static void main(java.lang.String[] args) {
- junit.textui.TestRunner.run(suite());
- }
-
- public static NbTest suite() {
- NbTestSuite suite = new NbTestSuite(LookNodeEventsTest.class);
- //suite.addTest(SetLookActionTest.suite());
-
- return suite;
- }
-
- protected void setUp() throws Exception {
- super.setUp();
-
- // add specific setup code here
- sampleLook = new SampleLook1Hid();
- representedObject = "RepresentedObject";
- lookNode = new LookNode( representedObject, sampleLook );
- nodeSubstitute = sampleLook.getSubstituteForNode( lookNode );
- testNodeListener = new TestNodeListener();
- lookNode.addNodeListener( testNodeListener );
- testPcl = new TestPropertyChangeListener();
- lookNode.addPropertyChangeListener( testPcl );
- }
-
- protected void tearDown() throws Exception {
- // add specific tear-down code here
- nodeSubstitute = null;
- sampleLook = null;
- lookNode = null;
- representedObject = null;
-
- super.tearDown();
- }
-
-
- public void testGetRepresentedObject() {
- System.out.println("testGetRepresentedObject");
-
- // Add your test code below by replacing the default call to fail.
- if ( nodeSubstitute.getRepresentedObject() != representedObject ) {
- fail( "Bad represented object." );
- }
- }
-
-
- public void testFirePropertyChange() {
- System.out.println("testFirePropertyChange");
-
- // Add your test code below by replacing the default call to fail.
- testNodeListener.clearTestData();
- nodeSubstitute.firePropertyChange( TEST_PROP_NAME, TEST_PROP_OLD, TEST_PROP_NEW );
-
- ArrayList testData = testPcl.getTestData();
-
- if ( testData.size() != 1 ) {
- fail( "Bad number of events : " + testData.size() );
- }
-
- if ( !(testData.get( 0 ) instanceof PropertyChangeEvent ) ) {
- fail( "Bad event type : " + testData.get( 0 ).getClass() );
- }
-
- PropertyChangeEvent pev = (PropertyChangeEvent)testData.get( 0 );
- String evntEv = evaluatePropertyChangeEvent(
- pev, lookNode, TEST_PROP_NAME, TEST_PROP_OLD, TEST_PROP_NEW );
-
- if ( evntEv != null ) {
- fail( evntEv );
- }
- }
-
-
- public void testFireNameChange() {
- System.out.println("testFireNameChange");
-
- // Add your test code below by replacing the default call to fail.
- testNodeListener.clearTestData();
- nodeSubstitute.fireNameChange( OLD_NAME, NEW_NAME );
-
- ArrayList testData = testNodeListener.getTestData();
-
- if ( testData.size() != 1 ) {
- fail( "Bad number of events : " + testData.size() );
- }
-
- if ( !(testData.get( 0 ) instanceof PropertyChangeEvent ) ) {
- fail( "Bad event type : " + testData.get( 0 ).getClass() );
- }
-
- PropertyChangeEvent pev = (PropertyChangeEvent)testData.get( 0 );
- String evntEv = evaluatePropertyChangeEvent(
- pev, lookNode, Node.PROP_NAME, OLD_NAME, NEW_NAME );
-
- if ( evntEv != null ) {
- fail( evntEv );
- }
- }
-
- public void testFireDisplayNameChange() {
- System.out.println("testFireDisplayNameChange");
-
- // Add your test code below by replacing the default call to fail.
- testNodeListener.clearTestData();
- nodeSubstitute.fireDisplayNameChange( OLD_DISPLAY_NAME, NEW_DISPLAY_NAME );
-
- ArrayList testData = testNodeListener.getTestData();
-
- if ( testData.size() != 1 ) {
- fail( "Bad number of events : " + testData.size() );
- }
-
- if ( !(testData.get( 0 ) instanceof PropertyChangeEvent ) ) {
- fail( "Bad event type : " + testData.get( 0 ).getClass() );
- }
-
- PropertyChangeEvent pev = (PropertyChangeEvent)testData.get( 0 );
- String evntEv = evaluatePropertyChangeEvent(
- pev, lookNode, Node.PROP_DISPLAY_NAME, OLD_DISPLAY_NAME, NEW_DISPLAY_NAME );
-
- if ( evntEv != null ) {
- fail( evntEv );
- }
- }
-
- public void testFireShortDescriptionChange() {
- System.out.println("testFireShortDescriptionChange");
-
- // Add your test code below by replacing the default call to fail.
- testNodeListener.clearTestData();
- nodeSubstitute.fireShortDescriptionChange( OLD_SHORT_DESCRIPTION, NEW_SHORT_DESCRIPTION );
-
- ArrayList testData = testNodeListener.getTestData();
-
- if ( testData.size() != 1 ) {
- fail( "Bad number of events : " + testData.size() );
- }
-
- if ( !(testData.get( 0 ) instanceof PropertyChangeEvent ) ) {
- fail( "Bad event type : " + testData.get( 0 ).getClass() );
- }
-
- PropertyChangeEvent pev = (PropertyChangeEvent)testData.get( 0 );
- String evntEv = evaluatePropertyChangeEvent(
- pev, lookNode, Node.PROP_SHORT_DESCRIPTION, OLD_SHORT_DESCRIPTION, NEW_SHORT_DESCRIPTION );
-
- if ( evntEv != null ) {
- fail( evntEv );
- }
- }
-
- public void testFireIconChange() {
- System.out.println("testFireIconChange");
-
- // Add your test code below by replacing the default call to fail.
- testNodeListener.clearTestData();
- nodeSubstitute.fireIconChange();
-
- ArrayList testData = testNodeListener.getTestData();
-
- if ( testData.size() != 1 ) {
- fail( "Bad number of events : " + testData.size() );
- }
-
- if ( !(testData.get( 0 ) instanceof PropertyChangeEvent ) ) {
- fail( "Bad event type : " + testData.get( 0 ).getClass() );
- }
-
- PropertyChangeEvent pev = (PropertyChangeEvent)testData.get( 0 );
- String evntEv = evaluatePropertyChangeEvent(
- pev, lookNode, Node.PROP_ICON, null, null );
-
- if ( evntEv != null ) {
- fail( evntEv );
- }
- }
-
- public void testFireOpenedIconChange() {
- System.out.println("testFireOpenedIconChange");
-
- // Add your test code below by replacing the default call to fail.
- testNodeListener.clearTestData();
- nodeSubstitute.fireOpenedIconChange();
-
- ArrayList testData = testNodeListener.getTestData();
-
- if ( testData.size() != 1 ) {
- fail( "Bad number of events : " + testData.size() );
- }
-
- if ( !(testData.get( 0 ) instanceof PropertyChangeEvent ) ) {
- fail( "Bad event type : " + testData.get( 0 ).getClass() );
- }
-
- PropertyChangeEvent pev = (PropertyChangeEvent)testData.get( 0 );
- String evntEv = evaluatePropertyChangeEvent(
- pev, lookNode, Node.PROP_OPENED_ICON, null, null );
-
- if ( evntEv != null ) {
- fail( evntEv );
- }
- }
-
- public void testFirePropertySetsChange() {
- System.out.println("testFirePropertySetsChange");
-
- // Add your test code below by replacing the default call to fail.
- testNodeListener.clearTestData();
- nodeSubstitute.firePropertySetsChange( OLD_PROPERTY_SETS, NEW_PROPERTY_SETS );
-
- ArrayList testData = testNodeListener.getTestData();
-
- if ( testData.size() != 1 ) {
- fail( "Bad number of events : " + testData.size() );
- }
-
- if ( !(testData.get( 0 ) instanceof PropertyChangeEvent ) ) {
- fail( "Bad event type : " + testData.get( 0 ).getClass() );
- }
-
- PropertyChangeEvent pev = (PropertyChangeEvent)testData.get( 0 );
- String evntEv = evaluatePropertyChangeEvent(
- pev, lookNode, Node.PROP_PROPERTY_SETS, OLD_PROPERTY_SETS, NEW_PROPERTY_SETS );
-
- if ( evntEv != null ) {
- fail( evntEv );
- }
-
- }
-
- public void testFireCookieChange() {
- System.out.println("testFireCookieChange");
-
- // Add your test code below by replacing the default call to fail.
- testNodeListener.clearTestData();
- nodeSubstitute.fireCookieChange();
-
- ArrayList testData = testNodeListener.getTestData();
-
- if ( testData.size() != 1 ) {
- fail( "Bad number of events : " + testData.size() );
- }
-
- if ( !(testData.get( 0 ) instanceof PropertyChangeEvent ) ) {
- fail( "Bad event type : " + testData.get( 0 ).getClass() );
- }
-
- PropertyChangeEvent pev = (PropertyChangeEvent)testData.get( 0 );
- String evntEv = evaluatePropertyChangeEvent(
- pev, lookNode, Node.PROP_COOKIE, null, null );
-
- if ( evntEv != null ) {
- fail( evntEv );
- }
- }
-
- public void testFireNodeDestroyed() {
- System.out.println("testFireNodeDestroyed");
-
- // Add your test code below by replacing the default call to fail.
- testNodeListener.clearTestData();
- nodeSubstitute.fireNodeDestroyed();
-
- ArrayList testData = testNodeListener.getTestData();
-
- if ( testData.size() != 1 ) {
- fail( "Bad number of events : " + testData.size() );
- }
-
- if ( !(testData.get( 0 ) instanceof NodeEvent ) ) {
- fail( "Bad event type : " + testData.get( 0 ).getClass() );
- }
-
- NodeEvent nev = (NodeEvent)testData.get( 0 );
- if ( nev.getNode() != lookNode ) {
- fail( "bad node : " + nev.getNode() );
- }
- }
-
- public void testAddChildren() {
- System.out.println("testAddChildren");
-
- // Add your test code below by replacing the default call to fail.
- sampleLook.setKeys( SampleLook1Hid.VAL_KEYS );
- lookNode.getChildren().getNodes();
-
- testNodeListener.clearTestData();
- sampleLook.setKeys( SampleLook1Hid.VAL_KEYS_ADDED );
- nodeSubstitute.refreshChildren();
-
- ArrayList testData = testNodeListener.getTestData();
-
- if ( testData.size() != 1 ) {
- fail( "Bad number of events : " + testData.size() );
- }
-
- }
-
- public void testRemoveChildren() {
- System.out.println("testRemoveChildren");
-
- // Add your test code below by replacing the default call to fail.
- sampleLook.setKeys( SampleLook1Hid.VAL_KEYS_ADDED );
- lookNode.getChildren().getNodes();
-
- testNodeListener.clearTestData();
- sampleLook.setKeys( SampleLook1Hid.VAL_KEYS_REMOVED );
- nodeSubstitute.refreshChildren();
-
- ArrayList testData = testNodeListener.getTestData();
-
- if ( testData.size() != 1 ) {
- fail( "Bad number of events : " + testData.size() );
- }
- }
-
- public void testReorderChildren() {
- System.out.println("testReorderChildren");
-
- // Add your test code below by replacing the default call to fail.
- sampleLook.setKeys( SampleLook1Hid.VAL_KEYS );
- lookNode.getChildren().getNodes();
-
- testNodeListener.clearTestData();
- sampleLook.setKeys( SampleLook1Hid.VAL_KEYS_REORDERED );
- nodeSubstitute.refreshChildren();
-
- ArrayList testData = testNodeListener.getTestData();
-
- if ( testData.size() != 1 ) {
- fail( "Bad number of events : " + testData.size() );
- }
- }
-
- public void testNoChildrenChange() {
- System.out.println("testNoChildrenChange");
-
- // Add your test code below by replacing the default call to fail.
- sampleLook.setKeys( SampleLook1Hid.VAL_KEYS );
- lookNode.getChildren().getNodes();
-
- testNodeListener.clearTestData();
- sampleLook.setKeys( SampleLook1Hid.VAL_KEYS_NO_CHANGE );
- nodeSubstitute.refreshChildren();
-
- ArrayList testData = testNodeListener.getTestData();
-
- if ( testData.size() != 0 ) {
- fail( "Bad number of events : " + testData.size() );
- }
- }
-
- // private methods ---------------------------------------------------------
-
- private String evaluatePropertyChangeEvent( PropertyChangeEvent pev,
- Object source, String name, Object oldValue, Object newValue ) {
-
- if ( pev.getSource() != source ) {
- return "Bad event source : " + pev.getSource();
- }
- if ( pev.getPropertyName() != name ) {
- return "Bad propertyName : " + pev.getPropertyName();
- }
- if ( pev.getOldValue() != oldValue ) {
- return "Bad old name : " + pev.getOldValue();
- }
- if ( pev.getNewValue() != newValue ) {
- return "Bad new name : " + pev.getOldValue();
- }
-
- return null;
- }
-
- // private classes ---------------------------------------------------------
-
- private static class TestNodeListener implements NodeListener {
-
- private ArrayList eventsList;
-
- TestNodeListener() {
- clearTestData();
- }
-
- public void nodeDestroyed( NodeEvent ev ) {
- eventsList.add( ev );
- }
-
- public void childrenRemoved( NodeMemberEvent ev ) {
- eventsList.add( ev );
- }
-
- public void childrenReordered( NodeReorderEvent ev ) {
- eventsList.add( ev );
- }
-
- public void propertyChange( PropertyChangeEvent ev ) {
- eventsList.add( ev );
- }
-
- public void childrenAdded( NodeMemberEvent ev ) {
- eventsList.add( ev );
- }
-
- void clearTestData() {
- eventsList = new ArrayList();
- }
-
- ArrayList getTestData() {
- return eventsList;
- }
-
- }
-
-
- private static class TestPropertyChangeListener implements PropertyChangeListener {
-
- ArrayList eventsList;
-
- TestPropertyChangeListener() {
- clearTestData();
- }
-
- public void propertyChange(PropertyChangeEvent pce ) {
- eventsList.add( pce );
- }
-
- void clearTestData() {
- eventsList = new ArrayList();
- }
-
- ArrayList getTestData() {
- return eventsList;
- }
-
- }
-}
-
Index: openidex/test/unit/src/org/openidex/nodes/looks/LookNodeTest.java
===================================================================
RCS file: openidex/test/unit/src/org/openidex/nodes/looks/LookNodeTest.java
diff -N openidex/test/unit/src/org/openidex/nodes/looks/LookNodeTest.java
--- openidex/test/unit/src/org/openidex/nodes/looks/LookNodeTest.java 31 Oct 2001 10:30:29 -0000 1.7
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,507 +0,0 @@
-/*
- * 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 Forte for Java, Community Edition. The Initial
- * Developer of the Original Code is Sun Microsystems, Inc. Portions
- * Copyright 1997-2000 Sun Microsystems, Inc. All Rights Reserved.
- */
-
-package org.openidex.nodes.looks;
-
-import java.beans.*;
-import java.awt.Image;
-import java.awt.datatransfer.Transferable;
-import java.awt.event.ActionListener;
-import java.awt.event.ActionEvent;
-import java.io.IOException;
-import javax.swing.event.ChangeListener;
-import javax.swing.event.ChangeEvent;
-import javax.swing.JMenuItem;
-import javax.swing.JMenu;
-import javax.swing.event.MenuListener;
-import javax.swing.event.MenuEvent;
-import org.openide.nodes.*;
-import org.openide.util.HelpCtx;
-import org.openide.util.NbBundle;
-import org.openide.util.actions.SystemAction;
-import org.openide.util.datatransfer.NewType;
-import org.openide.util.datatransfer.PasteType;
-import org.openide.awt.JMenuPlus;
-import org.openide.util.actions.CallableSystemAction;
-import org.openide.util.actions.Presenter;
-import org.openide.awt.Actions;
-import org.openide.util.HelpCtx;
-import org.openide.actions.SaveAllAction;
-import org.openide.util.actions.NodeAction;
-//import junit.framework.*;
-import org.netbeans.junit.*;
-import org.openide.util.Utilities;
-import junit.framework.*;
-
-public class LookNodeTest extends NbTestCase {
-
- /** Sample look we test against */
- SampleLook1Hid sampleLook;
-
- /** Second sample look for testing */
- SampleLook2Hid sampleLook2;
-
- /** The node to test on */
- LookNode lookNode;
-
- /** Represented object of the tested node */
- String representedObject;
-
- public LookNodeTest(java.lang.String testName) {
- super(testName);
- }
-
- public static void main(java.lang.String[] args) {
- junit.textui.TestRunner.run(suite());
- }
-
- protected void setUp() throws Exception {
- super.setUp();
-
- // add specific setup code here
- sampleLook = new SampleLook1Hid();
- sampleLook2 = new SampleLook2Hid();
- representedObject = "RepresentedObject";
- lookNode = new LookNode( representedObject, sampleLook );
- //look is hard set by this contructor
- //assert("Too eager initialization!", lookNode.getHardLook() == null);
- }
-
- protected void tearDown() throws Exception {
- // add specific tear-down code here
- sampleLook = null;
- lookNode = null;
- representedObject = null;
-
- super.tearDown();
- }
-
- /** Test of getSubstitute method, of class org.openidex.nodes.looks.LookNode. */
- public void testGetSubstitute() {
- System.out.println("testGetSubstitute");
-
- // Add your test code below by replacing the default call to fail.
- Look.NodeSubstitute substitute = lookNode.getSubstitute( );
- if ( substitute != sampleLook.getSubstituteForNode( lookNode) ) {
- fail("Bad nodeSubstitute.");
- }
- }
-
-
- /** Test of getRepresentedObject method, of class org.openidex.nodes.looks.LookNode. */
-
- public void testGetRepresentedObject() {
- System.out.println("testGetRepresentedObject");
-
- // Add your test code below by replacing the default call to fail.
- String ro = (String)lookNode.getRepresentedObject( );
- if ( ro != representedObject ) {
- fail("Bad represented object.");
- }
- }
-
-
- /** Test of setLook method, of class org.openidex.nodes.looks.LookNode. */
- public void testSetLook() {
- System.out.println("testSetLook");
-
- // Add your test code below by replacing the default call to fail.
- lookNode.setLook( sampleLook2 );
- if ( lookNode.getLook() != sampleLook2 ) {
- fail( "look not set" );
- }
-
- lookNode.setLook( sampleLook );
- if ( lookNode.getLook() != sampleLook ) {
- fail( "look not set" );
- }
- }
-
-
- /** Test of refreshChildren method, of class org.openidex.nodes.looks.LookNode. */
- // Tested in LookNodeEventsTest
- /*
- public void testRefreshChildren() {
- System.out.println("testRefreshChildren");
-
- // Add your test code below by replacing the default call to fail.
- fail("The test case is empty.");
- }
- */
-
- /** Test of getLook method, of class org.openidex.nodes.looks.LookNode. */
- public void testGetLook() {
- System.out.println("testGetLook");
-
- // Add your test code below by replacing the default call to fail.
-
- Look look = lookNode.getLook();
- if ( look != sampleLook ) {
- fail("Look not returned.");
- }
- }
-
- /** Test of getCookie method, of class org.openidex.nodes.looks.LookNode. */
- public void testGetCookie() {
- System.out.println("testGetCookie");
-
- // Add your test code below by replacing the default call to fail.
- Node.Cookie cookie = lookNode.getCookie( Object.class );
- if ( cookie != SampleLook1Hid.VAL_COOKIE ) {
- fail("Bad cookie.");
- }
- }
-
- /** Test of getHandle method, of class org.openidex.nodes.looks.LookNode. */
- public void testGetHandle() {
- System.out.println("testGetHandle");
-
- // Add your test code below by replacing the default call to fail.
- Node.Handle handle = lookNode.getHandle( );
- if ( handle != SampleLook1Hid.VAL_HANDLE ) {
- fail("Bad handle.");
- }
- }
-
- /** Test of cloneNode method, of class org.openidex.nodes.looks.LookNode. */
- public void testCloneNode() {
- System.out.println("testCloneNode");
-
- // Add your test code below by replacing the default call to fail.
- Look look = sampleLook2;
- LookNode lookNode = new LookNode(new Object(), look);
-
- LookNode clonedNode = (LookNode)lookNode.cloneNode();
- LookNode secondLevelClone = (LookNode) clonedNode.cloneNode();
-
- assert("Cloned node must not be null!", clonedNode != null );
- assert("Cloned node must be a chameleon!", clonedNode.getHardLook() == null);
- assert("Second level clone has different hard look!", clonedNode.getHardLook() == secondLevelClone.getHardLook());
-// assert("Second level clone has different hard look candidate!", clonedNode.getHardLookCandidate() == secondLevelClone.getHardLookCandidate());
-
- // we do not have any parent node so we do not use chameleon look but rather hard look candidate
-
- assert("Both clones must result in same getLook()!", clonedNode.getLook() == secondLevelClone.getLook());
-
- }
-
-
- /** Test of getDisplayName method, of class org.openidex.nodes.looks.LookNode. */
- public void testGetDisplayName() {
- System.out.println("testGetDisplayName");
-
- // Add your test code below by replacing the default call to fail.
- String displayName = lookNode.getDisplayName( );
- if ( displayName != SampleLook1Hid.VAL_DISPLAY_NAME ) {
- fail("Bad displayName.");
- }
- }
-
- /** Test of setDisplayName method, of class org.openidex.nodes.looks.LookNode. */
- public void testSetDisplayName() {
- System.out.println("testSetDisplayName");
-
- // Add your test code below by replacing the default call to fail.
- // fail("The test case is empty.");
- }
-
- /** Test of getName method, of class org.openidex.nodes.looks.LookNode. */
- public void testGetName() {
- System.out.println("testGetName");
-
- // Add your test code below by replacing the default call to fail.
- String name = lookNode.getName( );
- if ( name != SampleLook1Hid.VAL_NAME ) {
- fail("Bad name.");
- }
- }
-
- /** Test of setName method, of class org.openidex.nodes.looks.LookNode. */
- public void testSetName() {
- System.out.println("testSetName");
-
- // Add your test code below by replacing the default call to fail.
- lookNode.setName( "Some name" );
- if ( !sampleLook.getSetNameCalled() ) {
- fail("setName not called.");
- }
- }
-
- /** Test of getShortDescription method, of class org.openidex.nodes.looks.LookNode. */
- public void testGetShortDescription() {
- System.out.println("testGetShortDescription");
-
- // Add your test code below by replacing the default call to fail.
- String shortDescription = lookNode.getShortDescription( );
- if ( shortDescription != SampleLook1Hid.VAL_SHORT_DESCRIPTION ) {
- fail("Bad shortDescription.");
- }
- }
-
- /** Test of getIcon method, of class org.openidex.nodes.looks.LookNode. */
- public void testGetIcon() {
- System.out.println("testGetIcon");
-
- // Add your test code below by replacing the default call to fail.
- Image icon = lookNode.getIcon( 0 );
- if ( icon != SampleLook1Hid.VAL_ICON ) {
- fail("Bad icon.");
- }
- }
-
- /** Test of getOpenedIcon method, of class org.openidex.nodes.looks.LookNode. */
- public void testGetOpenedIcon() {
- System.out.println("testGetOpenedIcon");
-
- // Add your test code below by replacing the default call to fail.
- Image openedIcon = lookNode.getOpenedIcon( 0 );
- if ( openedIcon != SampleLook1Hid.VAL_OPENED_ICON ) {
- fail("Bad openedIcon.");
- }
- }
-
- /** Test of getHelpCtx method, of class org.openidex.nodes.looks.LookNode. */
- public void testGetHelpCtx() {
- System.out.println("testGetHelpCtx");
-
- // Add your test code below by replacing the default call to fail.
- HelpCtx helpCtx = lookNode.getHelpCtx( );
- if ( helpCtx != SampleLook1Hid.VAL_HELP_CTX ) {
- fail("Bad helpCtx.");
- }
- }
-
- /** Test of getNewTypes method, of class org.openidex.nodes.looks.LookNode. */
- public void testGetNewTypes() {
- System.out.println("testGetNewTypes");
-
- // Add your test code below by replacing the default call to fail.
- NewType[] newTypes = lookNode.getNewTypes( );
- if ( newTypes != SampleLook1Hid.VAL_NEW_TYPES ) {
- fail("Bad newTypes.");
- }
- }
-
- /** Test of getActions method, of class org.openidex.nodes.looks.LookNode. */
- public void testGetActions() {
- System.out.println("testGetActions");
-
- // Add your test code below by replacing the default call to fail.
- SystemAction[] actions = lookNode.getActions( );
- if ( actions != SampleLook1Hid.VAL_ACTIONS ) {
- fail("Bad actions.");
- }
- }
-
- /** Test of getContextActions method, of class org.openidex.nodes.looks.LookNode. */
- public void testGetContextActions() {
- System.out.println("testGetContextActions");
-
- // Add your test code below by replacing the default call to fail.
- SystemAction[] contextActions = lookNode.getContextActions( );
- if ( contextActions != SampleLook1Hid.VAL_CONTEXT_ACTIONS ) {
- fail("Bad contextActions.");
- }
- }
-
- /** Test of getDefaultAction method, of class org.openidex.nodes.looks.LookNode. */
- public void testGetDefaultAction() {
- System.out.println("testGetDefaultAction");
-
- // Add your test code below by replacing the default call to fail.
- SystemAction defaultAction = lookNode.getDefaultAction( );
- if ( defaultAction != SampleLook1Hid.VAL_DEFAULT_ACTION ) {
- fail("Bad defaultAction.");
- }
- }
-
- /** Test of getPropertySets method, of class org.openidex.nodes.looks.LookNode. */
- public void testGetPropertySets() {
- System.out.println("testGetPropertySets");
-
- // Add your test code below by replacing the default call to fail.
- Node.PropertySet[] propertySets = lookNode.getPropertySets( );
- if ( propertySets != SampleLook1Hid.VAL_PROPERTY_SETS ) {
- fail("Bad propertySets.");
- }
- }
-
- /** Test of getCustomizer method, of class org.openidex.nodes.looks.LookNode. */
- public void testGetCustomizer() {
- System.out.println("testGetCustomizer");
-
- // Add your test code below by replacing the default call to fail.
- java.awt.Component customizer = lookNode.getCustomizer( );
- if ( customizer != SampleLook1Hid.VAL_CUSTOMIZER ) {
- fail("Bad customizer.");
- }
- }
-
- /** Test of hasCustomizer method, of class org.openidex.nodes.looks.LookNode. */
- public void testHasCustomizer() {
- System.out.println("testHasCustomizer");
-
- // Add your test code below by replacing the default call to fail.
- boolean hasCustomizer = lookNode.hasCustomizer();
- if ( hasCustomizer != true ) {
- fail("Bad hasCustomizedr value");
- }
-
- LookNode extraNode = new LookNode( representedObject, new DefaultLook() );
- hasCustomizer = extraNode.hasCustomizer();
- if ( hasCustomizer != false ) {
- fail("Bad hasCustomizedr value");
- }
- }
-
- /** Test of canRename method, of class org.openidex.nodes.looks.LookNode. */
- public void testCanRename() {
- System.out.println("testCanRename");
-
- // Add your test code below by replacing the default call to fail.
- boolean canRename = lookNode.canRename();
- if ( canRename != true ) {
- fail("Bad value canRename");
- }
- }
-
- /** Test of canDestroy method, of class org.openidex.nodes.looks.LookNode. */
- public void testCanDestroy() {
- System.out.println("testCanDestroy");
-
- // Add your test code below by replacing the default call to fail.
- boolean canDestroy = lookNode.canDestroy();
- if ( canDestroy != true ) {
- fail("Bad value canDestroy");
- }
- }
-
- /** Test of canCopy method, of class org.openidex.nodes.looks.LookNode. */
- public void testCanCopy() {
- System.out.println("testCanCopy");
-
- // Add your test code below by replacing the default call to fail.
- boolean canCopy = lookNode.canCopy();
- if ( canCopy != true ) {
- fail("Bad value canCopy");
- }
- }
-
- /** Test of canCut method, of class org.openidex.nodes.looks.LookNode. */
- public void testCanCut() {
- System.out.println("testCanCut");
-
- // Add your test code below by replacing the default call to fail.
- boolean canCut = lookNode.canCut();
- if ( canCut != true ) {
- fail("Bad value canCut");
- }
- }
-
- /** Test of getPasteTypes method, of class org.openidex.nodes.looks.LookNode. */
- public void testGetPasteTypes() {
- System.out.println("testGetPasteTypes");
-
- // Add your test code below by replacing the default call to fail.
- PasteType pasteTypes[] = lookNode.getPasteTypes( null );
- if ( pasteTypes != SampleLook1Hid.VAL_PASTE_TYPES ) {
- fail("Bad value pasteTypes");
- }
- }
-
- /** Test of getDropType method, of class org.openidex.nodes.looks.LookNode. */
- public void testGetDropType() {
- System.out.println("testGetDropType");
-
- // Add your test code below by replacing the default call to fail.
- PasteType dropType = lookNode.getDropType( null, 0, 0 );
- if ( dropType != SampleLook1Hid.VAL_DROP_TYPE ) {
- fail("Bad value dropType");
- }
- }
-
- /** Test of clipboardCopy method, of class org.openidex.nodes.looks.LookNode. */
- public void testClipboardCopy() {
- System.out.println("testClipboardCopy");
-
- // Add your test code below by replacing the default call to fail.
- try {
- Transferable clipboardCopy= lookNode.clipboardCopy( );
- if ( clipboardCopy != SampleLook1Hid.VAL_CLIPBOARD_COPY ) {
- fail("Bad value clipboardCopy");
- }
- }
- catch ( IOException e ) {
- fail("Exception thrown : " + e);
- }
- }
-
- /** Test of clipboardCut method, of class org.openidex.nodes.looks.LookNode. */
- public void testClipboardCut() {
- System.out.println("testClipboardCut");
-
- // Add your test code below by replacing the default call to fail.
- try {
- Transferable clipboardCut= lookNode.clipboardCut( );
- if ( clipboardCut != SampleLook1Hid.VAL_CLIPBOARD_CUT ) {
- fail("Bad value clipboardCut");
- }
- }
- catch ( IOException e ) {
- fail("Exception thrown : " + e);
- }
- }
-
- /** Test of drag method, of class org.openidex.nodes.looks.LookNode. */
- public void testDrag() {
- System.out.println("testDrag");
-
- // Add your test code below by replacing the default call to fail.
- try {
- Transferable drag = lookNode.drag( );
- if ( drag != SampleLook1Hid.VAL_DRAG ) {
- fail("Bad value drag");
- }
- }
- catch ( IOException e ) {
- fail("Exception thrown : " + e);
- }
- }
-
- /** Test of destroy method, of class org.openidex.nodes.looks.LookNode. */
- public void testDestroy() {
- System.out.println("testDestroy");
-
- // Add your test code below by replacing the default call to fail.
- try {
- lookNode.destroy();
- if ( !sampleLook.getDestroyCalled() ) {
- fail("Destroy not called.");
- }
- }
- catch ( IOException e ) {
- fail("Exception thrown : " + e);
- }
- }
-
- public static Test suite() {
- TestSuite suite = new NbTestSuite(LookNodeTest.class);
-
- return suite;
- }
-
-
-}
-
-
-
Index: openidex/test/unit/src/org/openidex/nodes/looks/SampleLook1Hid.java
===================================================================
RCS file: openidex/test/unit/src/org/openidex/nodes/looks/SampleLook1Hid.java
diff -N openidex/test/unit/src/org/openidex/nodes/looks/SampleLook1Hid.java
--- openidex/test/unit/src/org/openidex/nodes/looks/SampleLook1Hid.java 6 Sep 2001 15:53:33 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,421 +0,0 @@
-/*
- * 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 Forte for Java, Community Edition. The Initial
- * Developer of the Original Code is Sun Microsystems, Inc. Portions
- * Copyright 1997-2000 Sun Microsystems, Inc. All Rights Reserved.
- */
-
-package org.openidex.nodes.looks;
-
-import java.util.List;
-import java.awt.Image;
-import java.awt.image.BufferedImage;
-import java.awt.datatransfer.Transferable;
-import java.awt.datatransfer.StringSelection;
-import java.io.IOException;
-import java.lang.reflect.*;
-import java.util.Hashtable;
-import javax.swing.JPanel;
-
-import org.openide.nodes.*;
-import org.openide.loaders.XMLDataObject;
-import org.openide.util.actions.SystemAction;
-import org.openide.util.actions.CallableSystemAction;
-import org.openide.util.HelpCtx;
-import org.openide.util.datatransfer.NewType;
-import org.openide.util.datatransfer.PasteType;
-
-/** Class used for testing. Every method returns some value. Usefull for testing
- * FilterLook.
- *
- * @author Petr Hrebejk
- */
-class SampleLook1Hid extends Look {
-
- // Flags for method calls which do not return any value.
- boolean attachToCalled = false;
- boolean setNameCalled = false;
- boolean destroyCalled = false;
-
- // The values which are returned from this Look
- static final Node.Cookie VAL_COOKIE = new Node.Cookie() {};
-
- static final Node.Handle VAL_HANDLE = new Node.Handle() {
- public Node getNode() {
- return null;
- }
- };
-
- static final String VAL_NAME = "Node.Name";
-
- static final String VAL_DISPLAY_NAME = "Node.DisplayName";
-
- static final String VAL_SHORT_DESCRIPTION = "Node.ShortDescription";
-
- static final String[] VAL_KEYS = new String[] {
- "Child.1",
- "Child.2"
- };
-
- static final String[] VAL_KEYS_ADDED = new String[] {
- VAL_KEYS[0],
- "Child.1.a",
- VAL_KEYS[1]
- };
-
- static final String[] VAL_KEYS_REMOVED = new String[] {
- VAL_KEYS[0],
- };
-
- static final String[] VAL_KEYS_REORDERED = new String[] {
- VAL_KEYS[1],
- VAL_KEYS[0]
- };
-
- static final String[] VAL_KEYS_NO_CHANGE = new String[] {
- VAL_KEYS[0],
- VAL_KEYS[1]
- };
-
- static final Image VAL_ICON = new BufferedImage( 16, 16, BufferedImage.TYPE_INT_RGB );
-
- static final Image VAL_OPENED_ICON = new BufferedImage( 16, 16, BufferedImage.TYPE_INT_RGB );
-
- static final HelpCtx VAL_HELP_CTX = new HelpCtx( SampleLook1Hid.class );
-
- static final SystemAction[] VAL_ACTIONS = new SystemAction[] {
- new TestingAction1( "SystemAction1" ),
- new TestingAction2( "SystemAction2" )
- };
-
- static final SystemAction[] VAL_CONTEXT_ACTIONS = new SystemAction[] {
- new TestingAction3( "ContextAction1" ),
- new TestingAction4( "ContextAction2" )
- };
-
- static final SystemAction VAL_DEFAULT_ACTION = new TestingAction5( "DefaultAction" );
-
- static final JPanel VAL_CUSTOMIZER = new JPanel();
-
- static final Node.PropertySet[] VAL_PROPERTY_SETS = new Node.PropertySet[] {
- new Sheet.Set(),
- new Sheet.Set()
- };
-
- static final NewType[] VAL_NEW_TYPES = new NewType[] {
- new NewType() {
- public void create() { }
- },
-
- new NewType() {
- public void create() { }
- }
- };
-
- static final PasteType[] VAL_PASTE_TYPES = new PasteType[] {
- new PasteType() {
- public Transferable paste() { return null; }
- },
-
- new PasteType() {
- public Transferable paste() { return null; }
- }
- };
-
- static final PasteType VAL_DROP_TYPE = new PasteType() {
- public Transferable paste() { return null; }
- };
-
- static final Transferable VAL_CLIPBOARD_COPY = new StringSelection( "ClipboardCopy" );
-
- static final Transferable VAL_CLIPBOARD_CUT = new StringSelection( "ClipboardCut" );
-
- static final Transferable VAL_DRAG = new StringSelection( "Drag" );
-
- // Hashtable which holds the relation Node - NodeSubstitute
- private Hashtable nodes2Substitutes = new Hashtable();
-
- // The value of keys which has to be returned
- private String[] keys = VAL_KEYS;
-
- /** Name of the look.
- */
- private String name;
-
- /** Creates new DefaultLook. The costructor is protected, there should
- * be no need for creating new DefaultLooks
. You can delegate
- * to {@link #INSTANCE} instead.
- */
- protected SampleLook1Hid() {
- }
-
- // Additional methods for testing ------------------------------------------
-
- boolean getAttachToCalled() {
- boolean r = attachToCalled;
- attachToCalled = false;
- return r;
- }
-
- boolean getSetNameCalled() {
- boolean r = setNameCalled;
- setNameCalled = false;
- return r;
- }
-
-
- boolean getDestroyCalled() {
- boolean r = destroyCalled;
- destroyCalled = false;
- return r;
- }
-
- Look.NodeSubstitute getSubstituteForNode( LookNode node ) {
- return (Look.NodeSubstitute) nodes2Substitutes.get( node );
- }
-
- void setKeys( String[] val ) {
- keys = val;
- }
-
- // Private helper methods --------------------------------------------------
-
- private LookNode getNodeFromSubstitute( LookNode.SubstituteImpl subst ) {
- try {
- Class clazz = subst.getClass();
- Field outerClass = clazz.getDeclaredField ( "this$0" );
- outerClass.setAccessible( true );
- LookNode lookNode = (LookNode)outerClass.get( subst );
- outerClass.setAccessible( false );
- return lookNode;
- }
- catch ( NoSuchFieldException e ) {
- System.out.println( "OuterInstance not found : " + e );
- }
- catch ( IllegalAccessException e ) {
- System.out.println( "OuterInstance not found : " + e );
- }
-
- return null;
- }
-
- // Methods of look itself --------------------------------------------------
-
-
- // General methods ---------------------------------------------------------
-
- /** Sets the flag to be able to test wether the method was called. It
- * also stores the Look.NodeSubstitutes in a hash table (indexed by the
- * node to provide them by the getNodeSubstitute( Node node ) method.
- */
- public void attachTo(Look.NodeSubstitute substitute) {
- attachToCalled = true;
- if ( substitute instanceof LookNode.SubstituteImpl ) {
- LookNode lookNode = getNodeFromSubstitute( (LookNode.SubstituteImpl )substitute );
- nodes2Substitutes.put( lookNode, substitute );
- }
- }
-
- public Node.Cookie getCookie( Look.NodeSubstitute substitute, Class type) {
- return VAL_COOKIE;
- }
-
- public Node.Handle getHandle( Look.NodeSubstitute substitute ) {
- return VAL_HANDLE;
- }
-
- // Methods for STYLE -------------------------------------------------------
-
- public String getDisplayName( Look.NodeSubstitute substitute ) {
- return VAL_DISPLAY_NAME;
- }
-
- public String getName( Look.NodeSubstitute substitute ) {
- return VAL_NAME;
- }
-
- public void setName(Look.NodeSubstitute substitute, String newName ) {
- setNameCalled = true;
- }
-
- public String getShortDescription ( Look.NodeSubstitute substitute ) {
- return VAL_SHORT_DESCRIPTION;
- }
-
- public Image getIcon( Look.NodeSubstitute substitute, int type ) {
- return VAL_ICON;
- }
-
- public Image getOpenedIcon( Look.NodeSubstitute substitute, int type ) {
- return VAL_OPENED_ICON;
- }
-
- public HelpCtx getHelpCtx( Look.NodeSubstitute substitute ) {
- return VAL_HELP_CTX;
- }
-
- // Methods for CHILDREN ----------------------------------------------------
-
- public Object[] getChildObjects(Look.NodeSubstitute substitute) {
- return keys;
- }
-
- // Methods for ACTIONS & NEW TYPES -----------------------------------------
-
- public NewType[] getNewTypes( Look.NodeSubstitute substitute ) {
- return VAL_NEW_TYPES;
- }
-
- public SystemAction[] getActions( Look.NodeSubstitute substitute ) {
- return VAL_ACTIONS;
- }
-
- public SystemAction[] getContextActions( Look.NodeSubstitute substitute ) {
- return VAL_CONTEXT_ACTIONS;
- }
-
- public SystemAction getDefaultAction( Look.NodeSubstitute substitute ) {
- return VAL_DEFAULT_ACTION;
- }
-
- // Methods for PROPERTIES AND CUSTOMIZER -----------------------------------
-
- public Node.PropertySet[] getPropertySets( Look.NodeSubstitute substitute ) {
- return VAL_PROPERTY_SETS;
- }
-
- public java.awt.Component getCustomizer( Look.NodeSubstitute substitute ) {
- return VAL_CUSTOMIZER;
- }
-
- // Methods for CLIPBOARD OPERATIONS ----------------------------------------
-
- public boolean canRename( Look.NodeSubstitute substitute ) {
- return true;
- }
-
- public boolean canDestroy( Look.NodeSubstitute substitute ) {
- return true;
- }
-
- public boolean canCopy( Look.NodeSubstitute substitute ) {
- return true;
- }
-
- public boolean canCut( Look.NodeSubstitute substitute ) {
- return true;
- }
-
- public PasteType[] getPasteTypes( Look.NodeSubstitute substitute, Transferable t) {
- return VAL_PASTE_TYPES;
- }
-
- public PasteType getDropType( Look.NodeSubstitute substitute, Transferable t, int action, int index) {
- return VAL_DROP_TYPE;
- }
-
- public Transferable clipboardCopy( Look.NodeSubstitute substitute ) throws IOException {
- return VAL_CLIPBOARD_COPY;
- }
-
- public Transferable clipboardCut( Look.NodeSubstitute substitute ) throws IOException {
- return VAL_CLIPBOARD_CUT;
- }
-
- public Transferable drag( Look.NodeSubstitute substitute ) throws IOException {
- return VAL_DRAG;
- }
-
- public void destroy(Look.NodeSubstitute substitute) throws IOException {
- destroyCalled = true;
- }
-
- public static class NodeSubstitute extends Look.NodeSubstitute {
-
- public Object getRepresentedObject() { return null; }
-
- public void firePropertyChange( String name, Object o, Object n ) {}
-
- public void fireNameChange( String o, String n ) {}
-
- public void fireDisplayNameChange( String o, String n ) {}
-
- public void fireShortDescriptionChange(String o, String n) {}
-
- public void fireIconChange() {}
-
- public void fireOpenedIconChange() {}
-
- public void firePropertySetsChange( Node.PropertySet[] o, Node.PropertySet[] n ) {}
-
- public void fireCookieChange() {}
-
- public void fireNodeDestroyed() {}
-
- public void refreshChildren() {}
-
- public CookieSet getCookieSet() {
- return null;
- }
-
- }
-
-
- private static class TestingAction extends CallableSystemAction {
-
- private String name;
-
- TestingAction( String name ) {
- super();
- this.name = name;
- }
-
- public HelpCtx getHelpCtx() {
- return null;
- }
-
- public String getName() {
- return name;
- }
-
- public void performAction() {
- }
-
- }
-
- private static class TestingAction1 extends TestingAction {
- TestingAction1( String name ) {
- super( name );
- }
- }
-
- private static class TestingAction2 extends TestingAction {
- TestingAction2( String name ) {
- super( name );
- }
- }
-
- private static class TestingAction3 extends TestingAction {
- TestingAction3( String name ) {
- super( name );
- }
- }
-
- private static class TestingAction4 extends TestingAction {
- TestingAction4( String name ) {
- super( name );
- }
- }
-
- private static class TestingAction5 extends TestingAction {
- TestingAction5( String name ) {
- super( name );
- }
- }
-}
Index: openidex/test/unit/src/org/openidex/nodes/looks/SampleLook2Hid.java
===================================================================
RCS file: openidex/test/unit/src/org/openidex/nodes/looks/SampleLook2Hid.java
diff -N openidex/test/unit/src/org/openidex/nodes/looks/SampleLook2Hid.java
--- openidex/test/unit/src/org/openidex/nodes/looks/SampleLook2Hid.java 6 Sep 2001 15:53:33 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,421 +0,0 @@
-/*
- * 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 Forte for Java, Community Edition. The Initial
- * Developer of the Original Code is Sun Microsystems, Inc. Portions
- * Copyright 1997-2000 Sun Microsystems, Inc. All Rights Reserved.
- */
-
-package org.openidex.nodes.looks;
-
-import java.util.List;
-import java.awt.Image;
-import java.awt.image.BufferedImage;
-import java.awt.datatransfer.Transferable;
-import java.awt.datatransfer.StringSelection;
-import java.io.IOException;
-import java.lang.reflect.*;
-import java.util.Hashtable;
-import javax.swing.JPanel;
-
-import org.openide.nodes.*;
-import org.openide.loaders.XMLDataObject;
-import org.openide.util.actions.SystemAction;
-import org.openide.util.actions.CallableSystemAction;
-import org.openide.util.HelpCtx;
-import org.openide.util.datatransfer.NewType;
-import org.openide.util.datatransfer.PasteType;
-
-/** Class used for testing. Every method returns some value. Usefull for testing
- * FilterLook.
- *
- * @author Petr Hrebejk
- */
-class SampleLook2Hid extends Look {
-
- // Flags for method calls which do not return any value.
- boolean attachToCalled = false;
- boolean setNameCalled = false;
- boolean destroyCalled = false;
-
- // The values which are returned from this Look
- static final Node.Cookie VAL_COOKIE = new Node.Cookie() {};
-
- static final Node.Handle VAL_HANDLE = new Node.Handle() {
- public Node getNode() {
- return null;
- }
- };
-
- static final String VAL_NAME = "Node.Name";
-
- static final String VAL_DISPLAY_NAME = "Node.DisplayName";
-
- static final String VAL_SHORT_DESCRIPTION = "Node.ShortDescription";
-
- static final String[] VAL_KEYS = new String[] {
- "Child.1",
- "Child.2"
- };
-
- static final String[] VAL_KEYS_ADDED = new String[] {
- VAL_KEYS[0],
- "Child.1.a",
- VAL_KEYS[1]
- };
-
- static final String[] VAL_KEYS_REMOVED = new String[] {
- VAL_KEYS[0],
- };
-
- static final String[] VAL_KEYS_REORDERED = new String[] {
- VAL_KEYS[1],
- VAL_KEYS[0]
- };
-
- static final String[] VAL_KEYS_NO_CHANGE = new String[] {
- VAL_KEYS[0],
- VAL_KEYS[1]
- };
-
- static final Image VAL_ICON = new BufferedImage( 16, 16, BufferedImage.TYPE_INT_RGB );
-
- static final Image VAL_OPENED_ICON = new BufferedImage( 16, 16, BufferedImage.TYPE_INT_RGB );
-
- static final HelpCtx VAL_HELP_CTX = new HelpCtx( SampleLook1Hid.class );
-
- static final SystemAction[] VAL_ACTIONS = new SystemAction[] {
- new TestingAction1( "SystemAction1" ),
- new TestingAction2( "SystemAction2" )
- };
-
- static final SystemAction[] VAL_CONTEXT_ACTIONS = new SystemAction[] {
- new TestingAction3( "ContextAction1" ),
- new TestingAction4( "ContextAction2" )
- };
-
- static final SystemAction VAL_DEFAULT_ACTION = new TestingAction5( "DefaultAction" );
-
- static final JPanel VAL_CUSTOMIZER = new JPanel();
-
- static final Node.PropertySet[] VAL_PROPERTY_SETS = new Node.PropertySet[] {
- new Sheet.Set(),
- new Sheet.Set()
- };
-
- static final NewType[] VAL_NEW_TYPES = new NewType[] {
- new NewType() {
- public void create() { }
- },
-
- new NewType() {
- public void create() { }
- }
- };
-
- static final PasteType[] VAL_PASTE_TYPES = new PasteType[] {
- new PasteType() {
- public Transferable paste() { return null; }
- },
-
- new PasteType() {
- public Transferable paste() { return null; }
- }
- };
-
- static final PasteType VAL_DROP_TYPE = new PasteType() {
- public Transferable paste() { return null; }
- };
-
- static final Transferable VAL_CLIPBOARD_COPY = new StringSelection( "ClipboardCopy" );
-
- static final Transferable VAL_CLIPBOARD_CUT = new StringSelection( "ClipboardCut" );
-
- static final Transferable VAL_DRAG = new StringSelection( "Drag" );
-
- // Hashtable which holds the relation Node - NodeSubstitute
- private Hashtable nodes2Substitutes = new Hashtable();
-
- // The value of keys which has to be returned
- private String[] keys = VAL_KEYS;
-
- /** Name of the look.
- */
- private String name;
-
- /** Creates new DefaultLook. The costructor is protected, there should
- * be no need for creating new DefaultLooks
. You can delegate
- * to {@link #INSTANCE} instead.
- */
- protected SampleLook2Hid() {
- }
-
- // Additional methods for testing ------------------------------------------
-
- boolean getAttachToCalled() {
- boolean r = attachToCalled;
- attachToCalled = false;
- return r;
- }
-
- boolean getSetNameCalled() {
- boolean r = setNameCalled;
- setNameCalled = false;
- return r;
- }
-
-
- boolean getDestroyCalled() {
- boolean r = destroyCalled;
- destroyCalled = false;
- return r;
- }
-
- Look.NodeSubstitute getSubstituteForNode( LookNode node ) {
- return (Look.NodeSubstitute) nodes2Substitutes.get( node );
- }
-
- void setKeys( String[] val ) {
- keys = val;
- }
-
- // Private helper methods --------------------------------------------------
-
- private LookNode getNodeFromSubstitute( LookNode.SubstituteImpl subst ) {
- try {
- Class clazz = subst.getClass();
- Field outerClass = clazz.getDeclaredField ( "this$0" );
- outerClass.setAccessible( true );
- LookNode lookNode = (LookNode)outerClass.get( subst );
- outerClass.setAccessible( false );
- return lookNode;
- }
- catch ( NoSuchFieldException e ) {
- System.out.println( "OuterInstance not found : " + e );
- }
- catch ( IllegalAccessException e ) {
- System.out.println( "OuterInstance not found : " + e );
- }
-
- return null;
- }
-
- // Methods of look itself --------------------------------------------------
-
-
- // General methods ---------------------------------------------------------
-
- /** Sets the flag to be able to test wether the method was called. It
- * also stores the Look.NodeSubstitutes in a hash table (indexed by the
- * node to provide them by the getNodeSubstitute( Node node ) method.
- */
- public void attachTo(Look.NodeSubstitute substitute) {
- attachToCalled = true;
- if ( substitute instanceof LookNode.SubstituteImpl ) {
- LookNode lookNode = getNodeFromSubstitute( (LookNode.SubstituteImpl )substitute );
- nodes2Substitutes.put( lookNode, substitute );
- }
- }
-
- public Node.Cookie getCookie( Look.NodeSubstitute substitute, Class type) {
- return VAL_COOKIE;
- }
-
- public Node.Handle getHandle( Look.NodeSubstitute substitute ) {
- return VAL_HANDLE;
- }
-
- // Methods for STYLE -------------------------------------------------------
-
- public String getDisplayName( Look.NodeSubstitute substitute ) {
- return VAL_DISPLAY_NAME;
- }
-
- public String getName( Look.NodeSubstitute substitute ) {
- return VAL_NAME;
- }
-
- public void setName(Look.NodeSubstitute substitute, String newName ) {
- setNameCalled = true;
- }
-
- public String getShortDescription ( Look.NodeSubstitute substitute ) {
- return VAL_SHORT_DESCRIPTION;
- }
-
- public Image getIcon( Look.NodeSubstitute substitute, int type ) {
- return VAL_ICON;
- }
-
- public Image getOpenedIcon( Look.NodeSubstitute substitute, int type ) {
- return VAL_OPENED_ICON;
- }
-
- public HelpCtx getHelpCtx( Look.NodeSubstitute substitute ) {
- return VAL_HELP_CTX;
- }
-
- // Methods for CHILDREN ----------------------------------------------------
-
- public Object[] getChildObjects(Look.NodeSubstitute substitute) {
- return keys;
- }
-
- // Methods for ACTIONS & NEW TYPES -----------------------------------------
-
- public NewType[] getNewTypes( Look.NodeSubstitute substitute ) {
- return VAL_NEW_TYPES;
- }
-
- public SystemAction[] getActions( Look.NodeSubstitute substitute ) {
- return VAL_ACTIONS;
- }
-
- public SystemAction[] getContextActions( Look.NodeSubstitute substitute ) {
- return VAL_CONTEXT_ACTIONS;
- }
-
- public SystemAction getDefaultAction( Look.NodeSubstitute substitute ) {
- return VAL_DEFAULT_ACTION;
- }
-
- // Methods for PROPERTIES AND CUSTOMIZER -----------------------------------
-
- public Node.PropertySet[] getPropertySets( Look.NodeSubstitute substitute ) {
- return VAL_PROPERTY_SETS;
- }
-
- public java.awt.Component getCustomizer( Look.NodeSubstitute substitute ) {
- return VAL_CUSTOMIZER;
- }
-
- // Methods for CLIPBOARD OPERATIONS ----------------------------------------
-
- public boolean canRename( Look.NodeSubstitute substitute ) {
- return true;
- }
-
- public boolean canDestroy( Look.NodeSubstitute substitute ) {
- return true;
- }
-
- public boolean canCopy( Look.NodeSubstitute substitute ) {
- return true;
- }
-
- public boolean canCut( Look.NodeSubstitute substitute ) {
- return true;
- }
-
- public PasteType[] getPasteTypes( Look.NodeSubstitute substitute, Transferable t) {
- return VAL_PASTE_TYPES;
- }
-
- public PasteType getDropType( Look.NodeSubstitute substitute, Transferable t, int action, int index) {
- return VAL_DROP_TYPE;
- }
-
- public Transferable clipboardCopy( Look.NodeSubstitute substitute ) throws IOException {
- return VAL_CLIPBOARD_COPY;
- }
-
- public Transferable clipboardCut( Look.NodeSubstitute substitute ) throws IOException {
- return VAL_CLIPBOARD_CUT;
- }
-
- public Transferable drag( Look.NodeSubstitute substitute ) throws IOException {
- return VAL_DRAG;
- }
-
- public void destroy(Look.NodeSubstitute substitute) throws IOException {
- destroyCalled = true;
- }
-
- public static class NodeSubstitute extends Look.NodeSubstitute {
-
- public Object getRepresentedObject() { return null; }
-
- public void firePropertyChange( String name, Object o, Object n ) {}
-
- public void fireNameChange( String o, String n ) {}
-
- public void fireDisplayNameChange( String o, String n ) {}
-
- public void fireShortDescriptionChange(String o, String n) {}
-
- public void fireIconChange() {}
-
- public void fireOpenedIconChange() {}
-
- public void firePropertySetsChange( Node.PropertySet[] o, Node.PropertySet[] n ) {}
-
- public void fireCookieChange() {}
-
- public void fireNodeDestroyed() {}
-
- public void refreshChildren() {}
-
- public CookieSet getCookieSet() {
- return null;
- }
-
- }
-
-
- private static class TestingAction extends CallableSystemAction {
-
- private String name;
-
- TestingAction( String name ) {
- super();
- this.name = name;
- }
-
- public HelpCtx getHelpCtx() {
- return null;
- }
-
- public String getName() {
- return name;
- }
-
- public void performAction() {
- }
-
- }
-
- private static class TestingAction1 extends TestingAction {
- TestingAction1( String name ) {
- super( name );
- }
- }
-
- private static class TestingAction2 extends TestingAction {
- TestingAction2( String name ) {
- super( name );
- }
- }
-
- private static class TestingAction3 extends TestingAction {
- TestingAction3( String name ) {
- super( name );
- }
- }
-
- private static class TestingAction4 extends TestingAction {
- TestingAction4( String name ) {
- super( name );
- }
- }
-
- private static class TestingAction5 extends TestingAction {
- TestingAction5( String name ) {
- super( name );
- }
- }
-}
Index: utilities/manifest.mf
===================================================================
RCS file: /cvs/utilities/manifest.mf,v
retrieving revision 1.53
diff -u -r1.53 manifest.mf
--- utilities/manifest.mf 12 Jan 2004 12:25:38 -0000 1.53
+++ utilities/manifest.mf 19 Mar 2004 16:16:35 -0000
@@ -7,7 +7,7 @@
OpenIDE-Module-Layer: org/netbeans/modules/utilities/Layer.xml
OpenIDE-Module-IDE-Dependencies: IDE/1 > 4.20
OpenIDE-Module-Module-Dependencies:
- org.openidex.util/2,
+ org.openidex.util/2-3,
org.netbeans.modules.javahelp/1 > 1.2,
org.netbeans.modules.settings/1 > 1.0,
org.openide.io > 1.0,
Index: vcscore/manifest.mf
===================================================================
RCS file: /cvs/vcscore/manifest.mf,v
retrieving revision 1.40
diff -u -r1.40 manifest.mf
--- vcscore/manifest.mf 16 Mar 2004 15:37:24 -0000 1.40
+++ vcscore/manifest.mf 19 Mar 2004 16:16:35 -0000
@@ -5,6 +5,6 @@
OpenIDE-Module-Implementation-Version: @BUILD_NUMBER_SUBST@
OpenIDE-Module-Layer: org/netbeans/modules/vcscore/resources/mf-layer.xml
OpenIDE-Module-IDE-Dependencies: IDE/1 > 4.20
-OpenIDE-Module-Module-Dependencies: org.openidex.util/2, org.openide.io > 1.0, org.openide.execution > 1.2, org.openide.loaders > 4.11
+OpenIDE-Module-Module-Dependencies: org.openidex.util/2-3, org.openide.io > 1.0, org.openide.execution > 1.2, org.openide.loaders > 4.11
OpenIDE-Module-Requires: org.openide.windows.IOProvider
Index: web/advanced/manifest.mf
===================================================================
RCS file: /cvs/web/advanced/manifest.mf,v
retrieving revision 1.74
diff -u -r1.74 manifest.mf
--- web/advanced/manifest.mf 12 Jan 2004 17:50:09 -0000 1.74
+++ web/advanced/manifest.mf 19 Mar 2004 16:16:59 -0000
@@ -11,7 +11,7 @@
org.netbeans.modules.j2eeserver/3,
org.netbeans.modules.schema2beans/1,
org.netbeans.modules.html/1,
- org.openidex.util/2,
+ org.openidex.util/2-3,
org.netbeans.core/1 > 1.0,
org.openide.src > 1.0, org.openide.execution > 1.0,
org.netbeans.api.web.dd/1