Initial version. Tests and docs will follow (hopefully) soon.
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/enode/build.xml Sun Apr 27 21:18:40 2003 +0000
1.3 @@ -0,0 +1,108 @@
1.4 +<?xml version="1.0" encoding="UTF-8"?>
1.5 +<!--
1.6 + Sun Public License Notice
1.7 +
1.8 +The contents of this file are subject to the Sun Public License
1.9 +Version 1.0 (the "License"). You may not use this file except in
1.10 +compliance with the License. A copy of the License is available at
1.11 +http://www.sun.com/
1.12 +
1.13 +The Original Code is NetBeans. The Initial Developer of the Original
1.14 +Code is Nokia. Portions Copyright 2003 Nokia.
1.15 +All Rights Reserved.
1.16 +-->
1.17 +
1.18 +<project name="enode" default="netbeans" basedir=".">
1.19 +
1.20 + <property name="nb_all" value="../.."/>
1.21 +
1.22 + <property name="nbm_alias" value="nb_ide"/>
1.23 + <property name="homepage.base" value="netbeans.org"/>
1.24 + <property name="dist.base" value="www.netbeans.org/download/nbms/40"/>
1.25 + <property name="license.file" location="${nb_all}/nbbuild/standard-nbm-license.txt"/>
1.26 +
1.27 + <taskdef name="makenbm" classname="org.netbeans.nbbuild.MakeNBM" classpath="${nb_all}/nbbuild/nbantext.jar"/>
1.28 + <taskdef name="genlist" classname="org.netbeans.nbbuild.MakeListOfNBM" classpath="${nb_all}/nbbuild/nbantext.jar"/>
1.29 + <taskdef name="locjar" classname="org.netbeans.nbbuild.LocalizedJar" classpath="${nb_all}/nbbuild/nbantext.jar"/>
1.30 +
1.31 + <target name="compile">
1.32 + <javac srcdir="src" destdir="src" deprecation="${build.compiler.deprecation}" debug="${build.compiler.debug}">
1.33 + <classpath refid="cp"/>
1.34 + </javac>
1.35 + </target>
1.36 +
1.37 + <target name="jars" depends="compile">
1.38 + <mkdir dir="netbeans/modules/autoload"/>
1.39 + <filter token="BUILD_NUMBER_SUBST" value="${buildnumber}"/>
1.40 + <copy file="manifest.mf" tofile="manifest-subst.mf" filtering="on"/>
1.41 + <locjar jarfile="netbeans/modules/autoload/enode.jar"
1.42 + basedir="src"
1.43 + manifest="manifest-subst.mf"
1.44 + excludesfile="${nb_all}/nbbuild/standard-jar-excludes.txt"
1.45 + compress="false">
1.46 + </locjar>
1.47 + </target>
1.48 +
1.49 + <target name="netbeans" depends="jars">
1.50 + <genlist targetname="nbm" outputfiledir="netbeans"/>
1.51 + </target>
1.52 +
1.53 + <target name="nbm" depends="netbeans">
1.54 + <makenbm file="enode.nbm"
1.55 + topdir="."
1.56 + module="netbeans/modules/autoload/enode.jar"
1.57 + homepage="http://openidex.${homepage.base}/"
1.58 + distribution="http://${dist.base}/enode.nbm">
1.59 + <signature keystore="${keystore}" storepass="${storepass}" alias="${nbm_alias}"/>
1.60 + </makenbm>
1.61 + </target>
1.62 +
1.63 + <target name="test-build" depends="jars">
1.64 + <mkdir dir="reload/ext"/>
1.65 + <copy file="netbeans/modules/autoload/enode.jar" tofile="reload/enode.jar"/>
1.66 + </target>
1.67 + <target name="test" depends="test-build">
1.68 + <nbinstaller module="reload/enode.jar" action="reinstall"/>
1.69 + </target>
1.70 +
1.71 + <target name="clean" description="Clean build products.">
1.72 + <delete>
1.73 + <fileset dir="src">
1.74 + <include name="**/*.class"/>
1.75 + </fileset>
1.76 + </delete>
1.77 + <!-- workaround for issue 20745 -->
1.78 + <delete dir="netbeans/lib"/>
1.79 + <delete>
1.80 + <fileset dir=".">
1.81 + <include name="*.nbm"/>
1.82 + </fileset>
1.83 + </delete>
1.84 + <delete dir="Info"/>
1.85 + <delete file="manifest-subst.mf"/>
1.86 + <delete dir="javadoc"/>
1.87 + </target>
1.88 +
1.89 + <target name="real-clean" depends="clean">
1.90 + <delete dir="reload"/>
1.91 + </target>
1.92 +
1.93 + <path id="cp">
1.94 + <pathelement location="${nb_all}/openide/openide-13javac-workaround.jar"/>
1.95 + <pathelement location="${nb_all}/openide/netbeans/lib/openide.jar"/>
1.96 + <pathelement location="${nb_all}/core/naming/netbeans/modules/autoload/naming.jar"/>
1.97 + </path>
1.98 +
1.99 + <target name="javadoc" description="Build Javadoc.">
1.100 + <!-- Ant 1.4 bug workaround: <property refid="..."/> does not work inside <ant> -->
1.101 + <property name="_cp" refid="cp"/>
1.102 + <ant dir="${nb_all}/nbbuild/javadoctools" antfile="template.xml" target="javadoc">
1.103 + <property name="javadoc.base" location="."/>
1.104 + <property name="javadoc.name" value="EnodeAPI"/>
1.105 + <property name="javadoc.title" value="Extensible Node API"/>
1.106 + <property name="javadoc.packages" value="org.netbeans.api.enode,org.netbeans.spi.enode"/>
1.107 + <property name="javadoc.classpath" value="${_cp}"/>
1.108 + </ant>
1.109 + </target>
1.110 +
1.111 +</project>
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/enode/manifest.mf Sun Apr 27 21:18:40 2003 +0000
2.3 @@ -0,0 +1,9 @@
2.4 +Manifest-Version: 1.0
2.5 +OpenIDE-Module: org.netbeans.modules.enode/1
2.6 +OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/enode/Bundle.properties
2.7 +OpenIDE-Module-Specification-Version: 0.9
2.8 +OpenIDE-Module-Implementation-Version: @BUILD_NUMBER_SUBST@
2.9 +OpenIDE-Module-IDE-Dependencies: IDE/1 > 3.42
2.10 +OpenIDE-Module-Module-Dependencies: org.netbeans.core.naming/1
2.11 +OpenIDE-Module-Public-Packages: org.netbeans.api.enode.**, org.netbeans.spi.enode.**
2.12 +
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/enode/src/org/netbeans/api/enode/ExtensibleNode.java Sun Apr 27 21:18:40 2003 +0000
3.3 @@ -0,0 +1,222 @@
3.4 +/*
3.5 + * Sun Public License Notice
3.6 + *
3.7 + * The contents of this file are subject to the Sun Public License
3.8 + * Version 1.0 (the "License"). You may not use this file except in
3.9 + * compliance with the License. A copy of the License is available at
3.10 + * http://www.sun.com/
3.11 + *
3.12 + * The Original Code is NetBeans. The Initial Developer of the Original
3.13 + * Code is Nokia. Portions Copyright 2003 Nokia.
3.14 + * All Rights Reserved.
3.15 + */
3.16 +
3.17 +package org.netbeans.api.enode;
3.18 +
3.19 +import java.util.ArrayList;
3.20 +import javax.swing.Action;
3.21 +
3.22 +import org.openide.nodes.AbstractNode;
3.23 +import org.openide.nodes.Children;
3.24 +import org.openide.util.Lookup;
3.25 +
3.26 +import org.netbeans.modules.enode.ExtensibleNodeActions;
3.27 +import org.netbeans.modules.enode.ExtensibleNodeLookup;
3.28 +
3.29 +/**
3.30 + * A node capable of reading the list of actions from
3.31 + * the system file system. The content of its lookup can also be
3.32 + * specified declaratively.
3.33 + * @author David Strupl
3.34 + */
3.35 +public class ExtensibleNode extends AbstractNode {
3.36 +
3.37 + /** Folder on the system filesystem (context in the naming (JNDI, Registry)
3.38 + * where actions for extensible nodes are stored.
3.39 + */
3.40 + public static final String E_NODE_ACTIONS = "/ExtensibleNode/Actions/"; // NOI18N
3.41 +
3.42 + /** Folder on the system filesystem (context in the naming (JNDI, Registry)
3.43 + * where lookup objects for extensible nodes are stored.
3.44 + */
3.45 + public static final String E_NODE_LOOKUP = "/ExtensibleNode/Lookup/"; // NOI18N
3.46 +
3.47 + /**
3.48 + * Our JNDI context paths.
3.49 + */
3.50 + private String[] paths;
3.51 +
3.52 + /**
3.53 + * Reference the implementation of the actions finder.
3.54 + */
3.55 + private ExtensibleNodeActions actionManager;
3.56 +
3.57 + /**
3.58 + * Creates a new instance of ExtensibleNode. The paths
3.59 + * parameter is used as a base directory for finding
3.60 + * actions, lookup objects and icon.
3.61 + * @param path folder path on the system file system
3.62 + * @param useHierarchicalPath whether the content of parent folders
3.63 + * up to the root for a given entity (actions, lookup) is to be
3.64 + * taken into account when searching for the objects
3.65 + */
3.66 + public ExtensibleNode(String path, boolean useHierarchicalPath) {
3.67 + this(useHierarchicalPath ?
3.68 + computeHierarchicalPaths(path) :
3.69 + new String[] { path }
3.70 + );
3.71 + }
3.72 +
3.73 + /**
3.74 + * Creates a new instance of ExtensibleNode. The paths
3.75 + * parameter is used as a base directory for finding
3.76 + * actions, lookup objects and icon.
3.77 + * @param path folder path on the system file system
3.78 + */
3.79 + public ExtensibleNode(String[] paths) {
3.80 + this(Children.LEAF, paths);
3.81 + }
3.82 +
3.83 + /**
3.84 + * Creates a new instance of ExtensibleNode. The paths
3.85 + * parameter is used as a base directory for finding
3.86 + * actions, lookup objects and icon.
3.87 + * @param ch children of the node
3.88 + * @param path folder path on the system file system
3.89 + * @param useHierarchicalPath whether the content of parent folders
3.90 + * up to the root for a given entity (actions, lookup) is to be
3.91 + * taken into account when searching for the objects
3.92 + */
3.93 + public ExtensibleNode(Children ch, String path, boolean useHierarchicalPath) {
3.94 + this(ch, useHierarchicalPath ?
3.95 + computeHierarchicalPaths(path) :
3.96 + new String[] { path }
3.97 + );
3.98 + }
3.99 +
3.100 + /**
3.101 + * Creates a new instance of ExtensibleNode. The paths
3.102 + * parameter is used as a base directory for finding
3.103 + * actions, lookup objects and icon.
3.104 + * @param ch children of the node
3.105 + * @param path folder path on the system file system
3.106 + */
3.107 + public ExtensibleNode(Children ch, String[] paths) {
3.108 + this(ch, paths, new ExtensibleNodeLookup());
3.109 + }
3.110 +
3.111 + /**
3.112 + * Creates a new instance of ExtensibleNode. The paths
3.113 + * parameter is used as a base directory for finding
3.114 + * actions and icon. <EM> Warning:</EM> By using this constructor
3.115 + * you are responsible for creating the lookup for this node. The
3.116 + * extensible lookup is NOT used in this case.
3.117 + * @param ch children of the node
3.118 + * @param path folder path on the system file system
3.119 + * @param Lookup l used as a lookup for this node.
3.120 + * <EM> Warning:</EM> By using this constructor
3.121 + * you are responsible for creating the lookup for this node. The
3.122 + * extensible lookup is NOT used in this case.
3.123 + * @param useHierarchicalPath whether the content of parent folders
3.124 + * up to the root for a given entity (actions, lookup) is to be
3.125 + * taken into account when searching for the objects
3.126 + */
3.127 + public ExtensibleNode(Children ch, Lookup l, String path, boolean useHierarchicalPath) {
3.128 + this(ch, l, useHierarchicalPath ?
3.129 + computeHierarchicalPaths(path) :
3.130 + new String[] { path }
3.131 + );
3.132 + }
3.133 +
3.134 + /**
3.135 + * Creates a new instance of ExtensibleNode. The paths
3.136 + * parameter is used as a base directory for finding
3.137 + * actions and icon. <EM> Warning:</EM> By using this constructor
3.138 + * you are responsible for creating the lookup for this node. The
3.139 + * extensible lookup is NOT used in this case.
3.140 + * @param ch children of the node
3.141 + * @param path folder path on the system file system
3.142 + * @param Lookup l used as a lookup for this node.
3.143 + * <EM> Warning:</EM> By using this constructor
3.144 + * you are responsible for creating the lookup for this node. The
3.145 + * extensible lookup is NOT used in this case.
3.146 + */
3.147 + public ExtensibleNode(Children ch, Lookup l, String[] paths) {
3.148 + super(ch, l);
3.149 + this.paths = paths;
3.150 +
3.151 + // !!! PENDING XXX TODO:
3.152 + setIconBase(paths[0]);
3.153 + }
3.154 +
3.155 + /**
3.156 + * Private constructor taking the lookup argument. The lookup is
3.157 + * not fully initialized until the call to <code>setExtensibleNode</code>.
3.158 + */
3.159 + private ExtensibleNode(Children ch, String[] paths, ExtensibleNodeLookup l) {
3.160 + super(ch, l);
3.161 + this.paths = paths;
3.162 + l.setExtensibleNode(this);
3.163 +
3.164 + // !!! PENDING XXX TODO:
3.165 + setIconBase(paths[0]);
3.166 + }
3.167 +
3.168 + /**
3.169 + * Overriding superclass method. This implementaion can call
3.170 + * super.getActions or reads the actions list from the system file system
3.171 + * (layer files, JNDI, Registry).
3.172 + * @param context please see <code>AbstractNode.getActions(boolean)</code>
3.173 + * for details regarding this argument
3.174 + */
3.175 + public Action[] getActions (boolean context) {
3.176 + if (context) {
3.177 + return super.getActions(context);
3.178 + }
3.179 + return getActionManager().getActions();
3.180 + }
3.181 +
3.182 + /**
3.183 + * Lazy initialization of the actions manager
3.184 + */
3.185 + private ExtensibleNodeActions getActionManager() {
3.186 + if (actionManager == null) {
3.187 + actionManager = new ExtensibleNodeActions(this);
3.188 + }
3.189 + return actionManager;
3.190 + }
3.191 +
3.192 + /**
3.193 + * Getter for the paths on the system file system (JNDI).
3.194 + * @return String[] the entries in the resulting array do not contain
3.195 + * the prefix E_NODE_ACTIONS, E_NODE_LOOKUP. So the returned paths are
3.196 + * not absolute but relative (the same paths as are passed to one of the
3.197 + * constructors)
3.198 + */
3.199 + public final String[] getPaths() {
3.200 + return paths;
3.201 + }
3.202 +
3.203 + /**
3.204 + * For one folder returns an array containing the folder and
3.205 + * all of its parents. Uses '/' as the folder delimiter.
3.206 + * @return String[] For "a/b/c" returns { "a/b/c", "a/b", "a", "" }
3.207 + */
3.208 + private static String[] computeHierarchicalPaths(String path) {
3.209 + if (path == null) {
3.210 + return new String[0];
3.211 + }
3.212 + String tmp = path;
3.213 + ArrayList list = new ArrayList();
3.214 + while (tmp.length() > 0) {
3.215 + list.add(tmp);
3.216 + if (tmp.lastIndexOf('/') >= 0) {
3.217 + tmp = tmp.substring(0, tmp.lastIndexOf('/'));
3.218 + } else {
3.219 + tmp = "";
3.220 + }
3.221 + }
3.222 + list.add(tmp); // add also the last ""
3.223 + return (String[])list.toArray(new String[list.size()]);
3.224 + }
3.225 +}
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/enode/src/org/netbeans/modules/enode/Bundle.properties Sun Apr 27 21:18:40 2003 +0000
4.3 @@ -0,0 +1,16 @@
4.4 +# Sun Public License Notice
4.5 +#
4.6 +# The contents of this file are subject to the Sun Public License
4.7 +# Version 1.0 (the "License"). You may not use this file except in
4.8 +# compliance with the License. A copy of the License is available at
4.9 +# http://www.sun.com/
4.10 +#
4.11 +# The Original Code is NetBeans. The Initial Developer of the Original
4.12 +# Code is Nokia. Portions Copyright 2003 Nokia.
4.13 +# All Rights Reserved.
4.14 +
4.15 +# manifest.mf
4.16 +OpenIDE-Module-Name=Extensible Node
4.17 +OpenIDE-Module-Display-Category=Infrastructure
4.18 +OpenIDE-Module-Short-Description=Small extension to Nodes API.
4.19 +OpenIDE-Module-Long-Description=Provides implementation of Extensible node. Actions and content of this node's lookup can be specified declaratively in the module's layer file.
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/enode/src/org/netbeans/modules/enode/FactoryWrapper.java Sun Apr 27 21:18:40 2003 +0000
5.3 @@ -0,0 +1,170 @@
5.4 +/*
5.5 + * Sun Public License Notice
5.6 + *
5.7 + * The contents of this file are subject to the Sun Public License
5.8 + * Version 1.0 (the "License"). You may not use this file except in
5.9 + * compliance with the License. A copy of the License is available at
5.10 + * http://www.sun.com/
5.11 + *
5.12 + * The Original Code is NetBeans. The Initial Developer of the Original
5.13 + * Code is Nokia. Portions Copyright 2003 Nokia.
5.14 + * All Rights Reserved.
5.15 + */
5.16 +
5.17 +package org.netbeans.modules.enode;
5.18 +
5.19 +import java.util.ArrayList;
5.20 +import java.util.List;
5.21 +import java.util.StringTokenizer;
5.22 +
5.23 +import org.openide.ErrorManager;
5.24 +import org.openide.filesystems.FileObject;
5.25 +import org.openide.nodes.Node;
5.26 +import org.openide.util.Lookup;
5.27 +import org.openide.util.Lookup.Template;
5.28 +
5.29 +import org.netbeans.spi.enode.LookupContentFactory;
5.30 +
5.31 +/** Wrapper object for delaying of loading classes of the attached
5.32 + * objects. Reads the file attributes needed for this optimalization.
5.33 + * @author David Strupl
5.34 + */
5.35 +public class FactoryWrapper implements LookupContentFactory {
5.36 +
5.37 + /**
5.38 + * File object on the system filesystem. The attributes of this
5.39 + * file object are used to determine the class of the result.
5.40 + */
5.41 + private FileObject f;
5.42 +
5.43 + /**
5.44 + * The result of call to the <code> instantiate </code> method.
5.45 + */
5.46 + private Object obj;
5.47 +
5.48 + /** Just remembers the parameter.*/
5.49 + public FactoryWrapper(FileObject f) {
5.50 + this.f = f;
5.51 + }
5.52 +
5.53 + /**
5.54 + * Method from the LookupContentFactory interface. This method
5.55 + * passes the <code>target</code> argument to the delegated
5.56 + * LookupContentFactory.
5.57 + */
5.58 + public Object create(Node target) {
5.59 + if (obj == null) {
5.60 + obj = instantiate();
5.61 + }
5.62 + if (obj instanceof LookupContentFactory) {
5.63 + LookupContentFactory lcf = (LookupContentFactory)obj;
5.64 + return lcf.create(target);
5.65 + }
5.66 + return obj;
5.67 + }
5.68 +
5.69 + /**
5.70 + * Method from the LookupContentFactory interface. This method
5.71 + * passes the <code>target</code> argument to the delegated
5.72 + * LookupContentFactory.
5.73 + */
5.74 + public Lookup createLookup(Node target) {
5.75 + if (obj == null) {
5.76 + obj = instantiate();
5.77 + }
5.78 + if (obj instanceof LookupContentFactory) {
5.79 + LookupContentFactory lcf = (LookupContentFactory)obj;
5.80 + return lcf.createLookup(target);
5.81 + }
5.82 + return null;
5.83 + }
5.84 +
5.85 + /**
5.86 + * Checks whether we can match the template. If the resulting object
5.87 + * has been computed we just use its class or if it has not the file
5.88 + * object is examined for the "implements" attribute.
5.89 + */
5.90 + boolean matches(Template template) {
5.91 + if (template.getType() != null) {
5.92 + if (obj != null) {
5.93 + return template.getType().isAssignableFrom(obj.getClass());
5.94 + }
5.95 + if (! resultImplements().contains(template.getType().getName())) {
5.96 + return false;
5.97 + }
5.98 + }
5.99 + return true;
5.100 + }
5.101 +
5.102 + /**
5.103 + * Parses the value of attribute "implements"
5.104 + * @return List of String with names of classes/interfaces
5.105 + * implemented by the resulting object
5.106 + */
5.107 + private List resultImplements() {
5.108 + String classAttr = (String)f.getAttribute("implements"); // NOI18N
5.109 + ArrayList res = new ArrayList();
5.110 + StringTokenizer t = new StringTokenizer(classAttr, ",");
5.111 + while (t.hasMoreElements()) {
5.112 + res.add(t.nextElement());
5.113 + }
5.114 + return res;
5.115 + }
5.116 +
5.117 + /**
5.118 + * We use the system classloader for resolving the class specified
5.119 + * in the file attribute.
5.120 + * @return Class of the resulting object. If the object has not
5.121 + * been created yet the attribute "factoryClass" is consulted
5.122 + * @throws IllegalStateException if something went wrong
5.123 + */
5.124 + private Class clazz() {
5.125 + if (obj != null) {
5.126 + return obj.getClass();
5.127 + }
5.128 + try {
5.129 + String classAttr = (String)f.getAttribute("factoryClass"); // NOI18N
5.130 + ClassLoader cl = (ClassLoader)Lookup.getDefault().lookup(ClassLoader.class);
5.131 + if (classAttr != null) {
5.132 + Class c = Class.forName(classAttr, true, cl);
5.133 + return c;
5.134 + } else {
5.135 + throw new IllegalStateException("Attribute factoryClass not specified for " + f); // NOI18N
5.136 + }
5.137 + } catch (ClassNotFoundException cnfe) {
5.138 + IllegalStateException ise = new IllegalStateException();
5.139 + ErrorManager.getDefault().annotate(ise, cnfe);
5.140 + throw ise;
5.141 + }
5.142 + }
5.143 +
5.144 + /**
5.145 + * After calling the clazz method newInstance of the resulting
5.146 + * class is returned.
5.147 + * @throws IllegalStateException if something went wrong
5.148 + */
5.149 + private Object instantiate() {
5.150 + try {
5.151 + return clazz().newInstance();
5.152 + } catch (InstantiationException is) {
5.153 + IllegalStateException ise = new IllegalStateException();
5.154 + ErrorManager.getDefault().annotate(ise, is);
5.155 + throw ise;
5.156 + } catch (IllegalAccessException iae) {
5.157 + IllegalStateException ise = new IllegalStateException();
5.158 + ErrorManager.getDefault().annotate(ise, iae);
5.159 + throw ise;
5.160 + }
5.161 + }
5.162 +
5.163 + /**
5.164 + * @return Human readable description of the wrapper object.
5.165 + */
5.166 + public String toString() {
5.167 + if (obj != null) {
5.168 + return "FactoryWrapper[" + clazz().getName() + "]"; // NOI18N
5.169 + }
5.170 + return "FactoryWrapper[" + f.getAttribute("factoryClass") + "]"; // NOI18N
5.171 + }
5.172 +
5.173 +}
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
6.2 +++ b/enode/src/org/netbeans/spi/enode/LookupContentFactory.java Sun Apr 27 21:18:40 2003 +0000
6.3 @@ -0,0 +1,43 @@
6.4 +/*
6.5 + * Sun Public License Notice
6.6 + *
6.7 + * The contents of this file are subject to the Sun Public License
6.8 + * Version 1.0 (the "License"). You may not use this file except in
6.9 + * compliance with the License. A copy of the License is available at
6.10 + * http://www.sun.com/
6.11 + *
6.12 + * The Original Code is NetBeans. The Initial Developer of the Original
6.13 + * Code is Nokia. Portions Copyright 2003 Nokia.
6.14 + * All Rights Reserved.
6.15 + */
6.16 +
6.17 +package org.netbeans.spi.enode;
6.18 +
6.19 +import org.openide.nodes.Node;
6.20 +import org.openide.util.Lookup;
6.21 +
6.22 +/**
6.23 + * LookupContentFactories are registered for each content prefix
6.24 + * to provide content of lookups bound to individual Nodes.
6.25 + * @author David Strupl
6.26 + */
6.27 +public interface LookupContentFactory {
6.28 +
6.29 + /**
6.30 + * The create method is asked to create an object
6.31 + * returned by lookup bound to the Node n.
6.32 + * @param Node n
6.33 + * @returns Object it is the instance returned
6.34 + * by the lookup obtained as <code> n.getLookup() </code>
6.35 + */
6.36 + public Object create(Node n);
6.37 +
6.38 + /**
6.39 + * The createLookup method is asked to create a lookup
6.40 + * that is merged with the lookup of the node n.
6.41 + * @param Node n
6.42 + * @returns Lookup which will be merged with other
6.43 + * lookups provided by other modules
6.44 + */
6.45 + public Lookup createLookup(Node n);
6.46 +}
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
7.2 +++ b/enode/src/org/netbeans/spi/enode/LookupContentFactoryManager.java Sun Apr 27 21:18:40 2003 +0000
7.3 @@ -0,0 +1,53 @@
7.4 +/*
7.5 + * Sun Public License Notice
7.6 + *
7.7 + * The contents of this file are subject to the Sun Public License
7.8 + * Version 1.0 (the "License"). You may not use this file except in
7.9 + * compliance with the License. A copy of the License is available at
7.10 + * http://www.sun.com/
7.11 + *
7.12 + * The Original Code is NetBeans. The Initial Developer of the Original
7.13 + * Code is Nokia. Portions Copyright 2003 Nokia.
7.14 + * All Rights Reserved.
7.15 + */
7.16 +
7.17 +package org.netbeans.spi.enode;
7.18 +
7.19 +import org.openide.filesystems.FileObject;
7.20 +
7.21 +/**
7.22 + * Utility class with a static factory method. The factory
7.23 + * method should be called from the layer.
7.24 + * @author David Strupl
7.25 + */
7.26 +public final class LookupContentFactoryManager {
7.27 +
7.28 + /**
7.29 + * No instances of this class should be created.
7.30 + */
7.31 + private LookupContentFactoryManager() {
7.32 + }
7.33 +
7.34 + /**
7.35 + * This method is intended to be called from the layer
7.36 + * by means of the methodvalue file attribute. <UL>The following
7.37 + * attributes of the file object are examined:
7.38 + * <LI><EM>"implements"</EM> - comma delimited list of interfaces/classes
7.39 + * that the resulting object implements. These are the
7.40 + * only classes that are examined when someone asks the
7.41 + * lookup</LI>
7.42 + * <LI><EM>"factoryClass"</EM> - class on which the method <code>newInstance</code>
7.43 + * is called to create the resulting object or lookup</LI></UL>
7.44 + * @param FileObject must be from the system file system
7.45 + * @return LookupContentFactory usually wrapped in an utility wrapper
7.46 + * that is used for passing the node argument in methods of LookupContentFactory
7.47 + * and also as a performance optimalization in following sense: the class
7.48 + * specified by the "factoryClass" attribute is not loaded until
7.49 + * someone calls a lookup with argument containing a class from the list
7.50 + * specified in the "implements" list
7.51 + */
7.52 + public static LookupContentFactory create(FileObject f) {
7.53 + return new org.netbeans.modules.enode.FactoryWrapper(f);
7.54 + }
7.55 +
7.56 +}