diff --git a/asm/src/org/netbeans/modules/asm/core/dataobjects/AsmDataObject.java b/asm/src/org/netbeans/modules/asm/core/dataobjects/AsmDataObject.java --- a/asm/src/org/netbeans/modules/asm/core/dataobjects/AsmDataObject.java +++ b/asm/src/org/netbeans/modules/asm/core/dataobjects/AsmDataObject.java @@ -55,6 +55,7 @@ import org.openide.nodes.Node; import org.openide.text.CloneableEditorSupport; import org.openide.text.DataEditorSupport; +import org.openide.util.Lookup; public class AsmDataObject extends MultiDataObject { @@ -99,7 +100,12 @@ @Override protected Node createNodeDelegate() { return new AsmDataNode(this); - } + } + + @Override + public Lookup getLookup() { + return getCookieSet().getLookup(); + } } diff --git a/bpel.core/src/org/netbeans/modules/bpel/core/BPELDataObject.java b/bpel.core/src/org/netbeans/modules/bpel/core/BPELDataObject.java --- a/bpel.core/src/org/netbeans/modules/bpel/core/BPELDataObject.java +++ b/bpel.core/src/org/netbeans/modules/bpel/core/BPELDataObject.java @@ -43,8 +43,6 @@ import java.awt.Image; import java.awt.event.ActionEvent; import java.io.IOException; -import java.util.LinkedList; -import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; @@ -73,7 +71,6 @@ import org.openide.util.HelpCtx; import org.openide.util.Lookup; import org.openide.util.NbBundle; -import org.openide.util.lookup.AbstractLookup; import org.openide.util.lookup.InstanceContent; import org.openide.util.lookup.Lookups; import org.openide.util.lookup.ProxyLookup; @@ -101,6 +98,11 @@ Source source = DataObjectAdapters.source(this); cookies.add(new TransformableSupport(source)); cookies.add(new AnnotationManagerProvider(this)); + + cookies.assign(SearchProvider.class, new SearchProvider(this)); + cookies.assign(BusinessProcessHelperImpl.class, new BusinessProcessHelperImpl(this)); + cookies.assign(XmlFileEncodingQueryImpl.class, XmlFileEncodingQueryImpl.singleton()); + } public HelpCtx getHelpCtx() { @@ -161,21 +163,6 @@ @Override public final Lookup getLookup() { if (myLookup.get() == null) { - - Lookup lookup; - List list = new LinkedList(); - - list.add(Lookups.fixed( new Object[]{ - super.getLookup(), - this , - getEditorSupport(), - new SearchProvider(this), - new BusinessProcessHelperImpl(this), - XmlFileEncodingQueryImpl.singleton() - })); - - list.add(getCookieSet().getLookup()); - // add lazy initialization InstanceContent.Convertor conv = new InstanceContent.Convertor() { private AtomicReference valControllerRef = new AtomicReference(); @@ -189,11 +176,6 @@ return valControllerRef.get(); } - - - - - return null; } @@ -209,12 +191,12 @@ return obj.getName(); } }; - list.add(Lookups.fixed( - new Class[] { BpelModel.class, - Controller.class - }, conv)); - lookup = new ProxyLookup(list.toArray(new Lookup[list.size()])); + Lookup lookup = new ProxyLookup( + Lookups.fixed(new Class[] { BpelModel.class, Controller.class }, conv), + // Do not call super.getLookup(), it is deadlock-prone! + getCookieSet().getLookup() + ); myLookup.compareAndSet(null, lookup); isLookupInit.compareAndSet( false, true ); diff --git a/compapp.casaeditor/src/org/netbeans/modules/compapp/casaeditor/CasaDataObject.java b/compapp.casaeditor/src/org/netbeans/modules/compapp/casaeditor/CasaDataObject.java --- a/compapp.casaeditor/src/org/netbeans/modules/compapp/casaeditor/CasaDataObject.java +++ b/compapp.casaeditor/src/org/netbeans/modules/compapp/casaeditor/CasaDataObject.java @@ -56,6 +56,7 @@ import org.openide.loaders.DataFolder; import org.openide.loaders.MultiFileLoader; import org.openide.util.HelpCtx; +import org.openide.util.Lookup; import org.openide.util.lookup.InstanceContent; /** @@ -96,6 +97,11 @@ @Override protected Node createNodeDelegate() { return new CasaDataNode(this); + } + + @Override + public Lookup getLookup() { + return getCookieSet().getLookup(); } @Override diff --git a/db.core/src/org/netbeans/modules/db/sql/loader/SQLDataObject.java b/db.core/src/org/netbeans/modules/db/sql/loader/SQLDataObject.java --- a/db.core/src/org/netbeans/modules/db/sql/loader/SQLDataObject.java +++ b/db.core/src/org/netbeans/modules/db/sql/loader/SQLDataObject.java @@ -51,8 +51,6 @@ import org.openide.nodes.CookieSet; import org.openide.nodes.Node; import org.openide.util.Lookup; -import org.openide.util.lookup.Lookups; -import org.openide.util.lookup.ProxyLookup; /** * @@ -66,17 +64,17 @@ super(primaryFile, loader); CookieSet cookies = getCookieSet(); cookies.add(new SQLEditorSupport(this)); + cookies.assign(FileEncodingQueryImpl.class, new FileEncodingQueryImpl()); } + @Override protected Node createNodeDelegate() { return new SQLNode(this); } - public synchronized Lookup getLookup() { - if (lookup == null) { - lookup = new ProxyLookup(getCookieSet().getLookup(), Lookups.singleton(new FileEncodingQueryImpl())); - } - return lookup; + @Override + public Lookup getLookup() { + return getCookieSet().getLookup(); } public boolean isConsole() { diff --git a/dbschema/src/org/netbeans/modules/dbschema/jdbcimpl/DBschemaDataObject.java b/dbschema/src/org/netbeans/modules/dbschema/jdbcimpl/DBschemaDataObject.java --- a/dbschema/src/org/netbeans/modules/dbschema/jdbcimpl/DBschemaDataObject.java +++ b/dbschema/src/org/netbeans/modules/dbschema/jdbcimpl/DBschemaDataObject.java @@ -56,6 +56,7 @@ import org.netbeans.modules.dbschema.SchemaElement; import org.netbeans.modules.dbschema.SchemaElementUtil; import org.netbeans.modules.dbschema.nodes.SchemaRootChildren; +import org.openide.util.Lookup; public class DBschemaDataObject extends MultiDataObject { @@ -122,13 +123,6 @@ addPropertyChangeListener(listener); } - public Node.Cookie getCookie (Class c) { - // Looks like a bug - why is it done this way? This inevitable leads to a ClassCastException - if (SchemaElement.class.isAssignableFrom(c)) - return getCookie(DBElementProvider.class); - return super.getCookie(c); - } - public SchemaElement getSchema() { if (schemaElement == null) setSchema(SchemaElementUtil.forName(getPrimaryFile())); @@ -162,4 +156,9 @@ return nodeDelegate; } + + @Override + public Lookup getLookup() { + return getCookieSet().getLookup(); + } } diff --git a/form/src/org/netbeans/modules/form/palette/PaletteItemDataObject.java b/form/src/org/netbeans/modules/form/palette/PaletteItemDataObject.java --- a/form/src/org/netbeans/modules/form/palette/PaletteItemDataObject.java +++ b/form/src/org/netbeans/modules/form/palette/PaletteItemDataObject.java @@ -45,6 +45,7 @@ import java.io.*; import java.beans.*; +import org.openide.util.Lookup; import org.xml.sax.*; import org.xml.sax.helpers.DefaultHandler; @@ -66,7 +67,7 @@ * @author Tomas Pavek */ -class PaletteItemDataObject extends MultiDataObject { +class PaletteItemDataObject extends MultiDataObject implements CookieSet.Factory { static final String XML_ROOT = "palette_item"; // NOI18N static final String ATTR_VERSION = "version"; // NOI18N @@ -111,6 +112,7 @@ throws DataObjectExistsException { super(fo, loader); + getCookieSet().add(PaletteItem.class, this); } boolean isFileRead() { @@ -151,14 +153,13 @@ return new ItemNode(); } - @Override - public T getCookie(Class cookieClass) { + public T createCookie(Class cookieClass) { if (PaletteItem.class.equals(cookieClass)) { if (!fileLoaded) loadFile(); return cookieClass.cast(paletteItem); } - return super.getCookie(cookieClass); + return null; } // ------- @@ -527,4 +528,8 @@ } } + @Override + public Lookup getLookup() { + return getCookieSet().getLookup(); + } } diff --git a/image/src/org/netbeans/modules/image/ImageDataObject.java b/image/src/org/netbeans/modules/image/ImageDataObject.java --- a/image/src/org/netbeans/modules/image/ImageDataObject.java +++ b/image/src/org/netbeans/modules/image/ImageDataObject.java @@ -62,6 +62,7 @@ import org.openide.loaders.*; import org.openide.nodes.*; import org.openide.ErrorManager; +import org.openide.util.Lookup; import org.openide.util.actions.SystemAction; import org.openide.util.HelpCtx; import org.openide.util.NbBundle; @@ -106,6 +107,10 @@ return getPrintSupport(); else return null; + } + + public Lookup getLookup() { + return getCookieSet().getLookup(); } /** Gets image open support. */ diff --git a/j2me.cdc.project/src/org/netbeans/modules/j2me/cdc/project/mbm/MBMDataObject.java b/j2me.cdc.project/src/org/netbeans/modules/j2me/cdc/project/mbm/MBMDataObject.java --- a/j2me.cdc.project/src/org/netbeans/modules/j2me/cdc/project/mbm/MBMDataObject.java +++ b/j2me.cdc.project/src/org/netbeans/modules/j2me/cdc/project/mbm/MBMDataObject.java @@ -68,6 +68,7 @@ import org.openide.nodes.*; import org.openide.ErrorManager; import org.openide.filesystems.FileUtil; +import org.openide.util.Lookup; import org.openide.util.actions.SystemAction; import org.openide.util.HelpCtx; import org.openide.util.NbBundle; @@ -115,6 +116,10 @@ return new ImageNode(this); } + @Override + public Lookup getLookup() { + return getCookieSet().getLookup(); + } /** Node representing ImageDataObject. */ private static final class ImageNode extends DataNode { diff --git a/java.j2seplatform/src/org/netbeans/modules/java/jarloader/JarDataObject.java b/java.j2seplatform/src/org/netbeans/modules/java/jarloader/JarDataObject.java --- a/java.j2seplatform/src/org/netbeans/modules/java/jarloader/JarDataObject.java +++ b/java.j2seplatform/src/org/netbeans/modules/java/jarloader/JarDataObject.java @@ -46,6 +46,7 @@ import org.openide.loaders.MultiDataObject; import org.openide.nodes.Node; import org.openide.util.HelpCtx; +import org.openide.util.Lookup; /** * Represents a JAR file. @@ -64,5 +65,10 @@ protected Node createNodeDelegate() { return new JarDataNode(this); } + + @Override + public Lookup getLookup() { + return getCookieSet().getLookup(); + } } diff --git a/java.source/src/org/netbeans/modules/java/ClassDataObject.java b/java.source/src/org/netbeans/modules/java/ClassDataObject.java --- a/java.source/src/org/netbeans/modules/java/ClassDataObject.java +++ b/java.source/src/org/netbeans/modules/java/ClassDataObject.java @@ -61,7 +61,6 @@ import org.openide.loaders.MultiDataObject; import org.openide.loaders.MultiFileLoader; import org.openide.nodes.Node; -import org.openide.nodes.Node.Cookie; import org.openide.util.Exceptions; import org.openide.util.Lookup; import org.openide.util.NbBundle; @@ -71,20 +70,18 @@ public ClassDataObject(FileObject pf, MultiFileLoader loader) throws DataObjectExistsException { super(pf, loader); + getCookieSet().add(new OpenSourceCookie()); } public @Override Node createNodeDelegate() { return new JavaNode (this, false); } - public @Override T getCookie(Class type) { - if (type.isAssignableFrom(OpenSourceCookie.class)) { - return type.cast(new OpenSourceCookie()); - } else { - return super.getCookie (type); - } + @Override + public Lookup getLookup() { + return getCookieSet().getLookup(); } - + private final class OpenSourceCookie implements OpenCookie { public void open() { diff --git a/javawebstart/src/org/netbeans/modules/javawebstart/JnlpDataObject.java b/javawebstart/src/org/netbeans/modules/javawebstart/JnlpDataObject.java --- a/javawebstart/src/org/netbeans/modules/javawebstart/JnlpDataObject.java +++ b/javawebstart/src/org/netbeans/modules/javawebstart/JnlpDataObject.java @@ -54,6 +54,7 @@ import org.openide.nodes.Node; import org.openide.text.DataEditorSupport; +import org.openide.util.Lookup; import org.xml.sax.InputSource; public class JnlpDataObject extends MultiDataObject { @@ -72,5 +73,10 @@ protected Node createNodeDelegate() { return new JnlpDataNode(this); } + + @Override + public Lookup getLookup() { + return getCookieSet().getLookup(); + } } diff --git a/openide.loaders/src/org/openide/loaders/BrokenDataShadow.java b/openide.loaders/src/org/openide/loaders/BrokenDataShadow.java --- a/openide.loaders/src/org/openide/loaders/BrokenDataShadow.java +++ b/openide.loaders/src/org/openide/loaders/BrokenDataShadow.java @@ -76,6 +76,7 @@ import org.openide.nodes.PropertySupport; import org.openide.nodes.Sheet; import org.openide.util.HelpCtx; +import org.openide.util.Lookup; import org.openide.util.actions.SystemAction; /** For representing data shadows with broken link to original file. @@ -106,6 +107,11 @@ } } enqueueBrokenDataShadow(this); + } + + @Override + public Lookup getLookup() { + return getCookieSet().getLookup(); } /** Map of */ diff --git a/properties/nbproject/project.xml b/properties/nbproject/project.xml --- a/properties/nbproject/project.xml +++ b/properties/nbproject/project.xml @@ -138,6 +138,17 @@ + unit + + org.netbeans.modules.properties + + + + + org.netbeans.modules.masterfs + + + qa-functional org.netbeans.libs.junit4 diff --git a/properties/src/org/netbeans/modules/properties/PropertiesDataObject.java b/properties/src/org/netbeans/modules/properties/PropertiesDataObject.java --- a/properties/src/org/netbeans/modules/properties/PropertiesDataObject.java +++ b/properties/src/org/netbeans/modules/properties/PropertiesDataObject.java @@ -66,8 +66,6 @@ import org.openide.nodes.Node; import org.openide.util.Lookup; import org.openide.util.WeakListeners; -import org.openide.util.lookup.Lookups; -import org.openide.util.lookup.ProxyLookup; import static java.util.logging.Level.FINER; @@ -125,23 +123,9 @@ return ((PropertiesDataLoader) getLoader()).getEncoding(); } - private Lookup getSuperLookup() { - return super.getLookup(); - } - @Override public Lookup getLookup() { - if (lookup == null) { - lookup = new ProxyLookup( - Lookups.singleton(getEncoding()), - Lookups.proxy( - new Lookup.Provider() { - public Lookup getLookup() { - return getSuperLookup(); - } - })); - } - return lookup; + return getCookieSet().getLookup(); } /** Initializes the object. Used by construction and deserialized. */ @@ -151,6 +135,7 @@ arr[0] = PropertiesOpen.class; arr[1] = PropertiesEditorSupport.class; getCookieSet().add(arr, this); + getCookieSet().assign(PropertiesEncoding.class, getEncoding()); } /** Implements CookieSet.Factory interface method. */ diff --git a/properties/test/unit/src/org/netbeans/modules/properties/PropertiesDataObjectTest.java b/properties/test/unit/src/org/netbeans/modules/properties/PropertiesDataObjectTest.java new file mode 100644 --- /dev/null +++ b/properties/test/unit/src/org/netbeans/modules/properties/PropertiesDataObjectTest.java @@ -0,0 +1,69 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2008 Sun Microsystems, Inc. + */ + +package org.netbeans.modules.properties; + +import java.io.File; +import org.netbeans.junit.NbTestCase; +import org.netbeans.spi.queries.FileEncodingQueryImplementation; +import org.openide.filesystems.FileUtil; +import org.openide.loaders.DataObject; +import org.openide.util.Lookup; + +/** + * + * @author Andrei Badea + */ +public class PropertiesDataObjectTest extends NbTestCase { + + public PropertiesDataObjectTest(String name) { + super(name); + } + + public void testLookup() throws Exception { + clearWorkDir(); + File propFile = new File(getWorkDir(), "foo.properties"); + propFile.createNewFile(); + DataObject propDO = DataObject.find(FileUtil.toFileObject(propFile)); + Lookup lookup = propDO.getLookup(); + PropertiesEncoding encoding = lookup.lookup(PropertiesEncoding.class); + assertNotNull(encoding); + assertSame(encoding, lookup.lookup(FileEncodingQueryImplementation.class)); + } +} diff --git a/sql.project/src/org/netbeans/modules/sql/project/ui/SQLDataObject.java b/sql.project/src/org/netbeans/modules/sql/project/ui/SQLDataObject.java --- a/sql.project/src/org/netbeans/modules/sql/project/ui/SQLDataObject.java +++ b/sql.project/src/org/netbeans/modules/sql/project/ui/SQLDataObject.java @@ -26,6 +26,7 @@ import org.openide.nodes.CookieSet; import org.openide.nodes.Node; import org.openide.text.DataEditorSupport; +import org.openide.util.Lookup; public class SQLDataObject extends MultiDataObject { @@ -38,5 +39,10 @@ protected Node createNodeDelegate() { return new SQLDataNode(this); } + + @Override + public Lookup getLookup() { + return getCookieSet().getLookup(); + } } diff --git a/utilities/src/org/netbeans/modules/pdf/PDFDataObject.java b/utilities/src/org/netbeans/modules/pdf/PDFDataObject.java --- a/utilities/src/org/netbeans/modules/pdf/PDFDataObject.java +++ b/utilities/src/org/netbeans/modules/pdf/PDFDataObject.java @@ -51,6 +51,7 @@ import org.openide.nodes.CookieSet; import org.openide.nodes.Node; import org.openide.util.HelpCtx; +import org.openide.util.Lookup; /** * Data object representing a PDF file. @@ -83,4 +84,9 @@ return new PDFDataNode(this); } + @Override + public Lookup getLookup() { + return getCookieSet().getLookup(); + } + } diff --git a/visualweb.complib/src/org/netbeans/modules/visualweb/complib/ComplibPaletteItemDataObject.java b/visualweb.complib/src/org/netbeans/modules/visualweb/complib/ComplibPaletteItemDataObject.java --- a/visualweb.complib/src/org/netbeans/modules/visualweb/complib/ComplibPaletteItemDataObject.java +++ b/visualweb.complib/src/org/netbeans/modules/visualweb/complib/ComplibPaletteItemDataObject.java @@ -121,6 +121,11 @@ public Node createNodeDelegate() { return new ItemNode(); + } + + @Override + public Lookup getLookup() { + return getCookieSet().getLookup(); } /** diff --git a/visualweb.palette/src/org/netbeans/modules/visualweb/palette/PaletteItemDataObject.java b/visualweb.palette/src/org/netbeans/modules/visualweb/palette/PaletteItemDataObject.java --- a/visualweb.palette/src/org/netbeans/modules/visualweb/palette/PaletteItemDataObject.java +++ b/visualweb.palette/src/org/netbeans/modules/visualweb/palette/PaletteItemDataObject.java @@ -138,6 +138,7 @@ PaletteItemDataObject(FileObject fo, MultiFileLoader loader) throws DataObjectExistsException { super(fo, loader); + getCookieSet().add(new PaletteItemInfoImpl(this)); } boolean isFileRead() { @@ -160,14 +161,10 @@ public Node createNodeDelegate() { return new ItemNode(); } - + @Override - public T getCookie(Class cookieClass) { - - if (PaletteItemInfoCookie.class.isAssignableFrom(cookieClass)){ - return cookieClass.cast(new PaletteItemInfoImpl( this )); - } - return cookieClass.cast(super.getCookie(cookieClass)); + public Lookup getLookup() { + return getCookieSet().getLookup(); } // ------- @@ -665,6 +662,8 @@ } public String getClassName() { + // XXX should ensure that the field is set (e.g., by making sure + // loadFile() has already been called)! return pido.componentClassName; } diff --git a/vmd.palette/src/org/netbeans/modules/vmd/palette/PaletteItemDataObject.java b/vmd.palette/src/org/netbeans/modules/vmd/palette/PaletteItemDataObject.java --- a/vmd.palette/src/org/netbeans/modules/vmd/palette/PaletteItemDataObject.java +++ b/vmd.palette/src/org/netbeans/modules/vmd/palette/PaletteItemDataObject.java @@ -53,6 +53,7 @@ import org.openide.loaders.DataObjectExistsException; import org.openide.loaders.MultiDataObject; import org.openide.nodes.Node; +import org.openide.util.Lookup; import org.openide.util.WeakListeners; /** @@ -78,6 +79,11 @@ @Override protected Node createNodeDelegate() { return new PaletteItemDataNode(this); + } + + @Override + public Lookup getLookup() { + return getCookieSet().getLookup(); } private void readProperties(FileObject pf) throws IOException { diff --git a/web.core/src/org/netbeans/modules/web/core/jsploader/JspServletDataObject.java b/web.core/src/org/netbeans/modules/web/core/jsploader/JspServletDataObject.java --- a/web.core/src/org/netbeans/modules/web/core/jsploader/JspServletDataObject.java +++ b/web.core/src/org/netbeans/modules/web/core/jsploader/JspServletDataObject.java @@ -46,7 +46,7 @@ import java.beans.PropertyChangeSupport; import java.io.IOException; import org.openide.nodes.Node; -import org.openide.nodes.Node.Cookie; +import org.openide.util.Lookup; import org.openide.util.Task; import org.openide.text.Line; import org.openide.util.NbBundle; @@ -68,8 +68,6 @@ public static final String EA_ORIGIN_JSP_PAGE = "NetBeansAttrOriginJspPage"; // NOI18N - private transient ServletEditorCookie servletEditor; - public JspServletDataObject(FileObject pf, MultiFileLoader loader) throws DataObjectExistsException { super(pf, loader); } @@ -80,19 +78,10 @@ } @Override - public Cookie getCookie(Class type) { - if (type.isAssignableFrom(ServletEditorCookie.class)) { - if (servletEditor == null) { - EditorCookie ed = (EditorCookie) super.getCookie(EditorCookie.class); - if (ed != null) - servletEditor = new ServletEditorCookie(ed, this); - } - if (servletEditor != null) - return servletEditor; - } - return super.getCookie(type); + public Lookup getLookup() { + return getCookieSet().getLookup(); } - + /** Get the name of the data object. * Uses the name of the source JSP * @return the name diff --git a/xml.schema/src/org/netbeans/modules/xml/schema/SchemaDataObject.java b/xml.schema/src/org/netbeans/modules/xml/schema/SchemaDataObject.java --- a/xml.schema/src/org/netbeans/modules/xml/schema/SchemaDataObject.java +++ b/xml.schema/src/org/netbeans/modules/xml/schema/SchemaDataObject.java @@ -108,16 +108,14 @@ public void saveAs(FileObject folder, String fileName) throws IOException { schemaEditorSupport.saveAs( folder, fileName ); } - }); + }); + set.assign(SearchProvider.class, new SearchProvider(this)); + set.assign(XmlFileEncodingQueryImpl.class, XmlFileEncodingQueryImpl.singleton()); } @Override public final Lookup getLookup() { - return Lookups.fixed(new Object[]{ - super.getLookup(), - this, - new SearchProvider(this), - XmlFileEncodingQueryImpl.singleton()}); + return getCookieSet().getLookup(); } public void addSaveCookie(SaveCookie cookie){ diff --git a/xml.wsdlui/src/org/netbeans/modules/xml/wsdl/ui/netbeans/module/WSDLDataObject.java b/xml.wsdlui/src/org/netbeans/modules/xml/wsdl/ui/netbeans/module/WSDLDataObject.java --- a/xml.wsdlui/src/org/netbeans/modules/xml/wsdl/ui/netbeans/module/WSDLDataObject.java +++ b/xml.wsdlui/src/org/netbeans/modules/xml/wsdl/ui/netbeans/module/WSDLDataObject.java @@ -41,7 +41,6 @@ package org.netbeans.modules.xml.wsdl.ui.netbeans.module; import java.io.IOException; -import java.util.concurrent.atomic.AtomicReference; import org.netbeans.modules.xml.api.XmlFileEncodingQueryImpl; import org.netbeans.spi.xml.cookies.CheckXMLSupport; @@ -56,8 +55,6 @@ import org.openide.nodes.Node; import org.openide.util.HelpCtx; import org.openide.util.Lookup; -import org.openide.util.lookup.Lookups; -import org.openide.util.lookup.ProxyLookup; import org.xml.sax.InputSource; /** @@ -83,6 +80,9 @@ set.add(new WSDLMultiViewSupport(this)); //add validate action here set.add(new WSDLValidateXMLCookie(this)); + + set.assign(SearchProvider.class, new SearchProvider(this)); + set.assign(XmlFileEncodingQueryImpl.class, XmlFileEncodingQueryImpl.singleton()); } @Override @@ -154,23 +154,8 @@ @Override public Lookup getLookup() { - if (myLookup.get() == null) { - Lookup superLookup = super.getLookup(); - // - Lookup[] lookupArr = new Lookup[] { - Lookups.fixed(new Object[] { - new SearchProvider(this), - XmlFileEncodingQueryImpl.singleton()}), - superLookup}; - // - Lookup newLookup = new ProxyLookup(lookupArr); - myLookup.compareAndSet(null, newLookup); - } - return myLookup.get(); + return getCookieSet().getLookup(); } - - private transient AtomicReference myLookup = - new AtomicReference(); private static final long serialVersionUID = 6338889116068357651L; public static final String WSDL_ICON_BASE_WITH_EXT = "org/netbeans/modules/xml/wsdl/ui/netbeans/module/resources/wsdl_file.png"; diff --git a/xsl/src/org/netbeans/modules/xsl/XSLDataObject.java b/xsl/src/org/netbeans/modules/xsl/XSLDataObject.java --- a/xsl/src/org/netbeans/modules/xsl/XSLDataObject.java +++ b/xsl/src/org/netbeans/modules/xsl/XSLDataObject.java @@ -96,14 +96,12 @@ TextEditorSupport.TextEditorSupportFactory editorFactory = new TextEditorSupport.TextEditorSupportFactory (this, XMLKit.MIME_TYPE); editorFactory.registerCookies (set); - + + set.assign(XmlFileEncodingQueryImpl.class, XmlFileEncodingQueryImpl.singleton()); } public final Lookup getLookup() { - return Lookups.fixed(new Object[]{ - super.getLookup(), - this, - XmlFileEncodingQueryImpl.singleton()}); + return getCookieSet().getLookup(); } /** diff --git a/xslt.core/src/org/netbeans/modules/xslt/core/XSLTDataObject.java b/xslt.core/src/org/netbeans/modules/xslt/core/XSLTDataObject.java --- a/xslt.core/src/org/netbeans/modules/xslt/core/XSLTDataObject.java +++ b/xslt.core/src/org/netbeans/modules/xslt/core/XSLTDataObject.java @@ -78,7 +78,6 @@ private static final long serialVersionUID = 1L; private static final String FILE_DESC = "LBL_FileNode_desc"; // NOI18N private transient AtomicReference myLookup = new AtomicReference(); - private transient AtomicBoolean isLookupInit = new AtomicBoolean( false ); private XSLTDataEditorSupport myDataEditorSupport; public XSLTDataObject(final FileObject obj, final MultiFileLoader loader) throws DataObjectExistsException { @@ -97,17 +96,7 @@ @SuppressWarnings("unchecked") public Lookup getLookup() { - Lookup lookup; - List list = new LinkedList(); - //TODO m if (myLookup.get() == null) { - - list.add(Lookups.fixed( new Object[]{ - super.getLookup(), - this})); - - list.add(getCookieSet().getLookup()); - // add lazy initialization InstanceContent.Convertor conv = new InstanceContent.Convertor() { private AtomicReference valControllerRef = new AtomicReference(); @@ -122,9 +111,6 @@ } if (obj == MapperContext.class) { return getEditorSupport().getMapperContext(); - } - if (obj == XSLTDataEditorSupport.class) { - return getEditorSupport(); } return null; } @@ -141,15 +127,16 @@ return obj.getName(); } }; - list.add(Lookups.fixed( - new Class[] { XslModel.class, - Controller.class, - MapperContext.class, - XSLTDataEditorSupport.class}, conv)); - lookup = new ProxyLookup(list.toArray(new Lookup[list.size()])); + + Lookup lookup = new ProxyLookup( + // No need to add XSLTDataEditorSupport, since already added to the cookie set, + // and thus already present in getCookieSet().getLookup(). + Lookups.fixed(new Class[] { XslModel.class, Controller.class, MapperContext.class }, conv), + // Do not call super.getLookup(), it is deadlock-prone! + getCookieSet().getLookup() + ); myLookup.compareAndSet(null, lookup); - isLookupInit.compareAndSet( false, true ); } return myLookup.get(); } diff --git a/xslt.core/src/org/netbeans/modules/xslt/core/text/completion/support/XSLDataObject.java b/xslt.core/src/org/netbeans/modules/xslt/core/text/completion/support/XSLDataObject.java --- a/xslt.core/src/org/netbeans/modules/xslt/core/text/completion/support/XSLDataObject.java +++ b/xslt.core/src/org/netbeans/modules/xslt/core/text/completion/support/XSLDataObject.java @@ -50,7 +50,6 @@ import org.openide.nodes.Children; import org.openide.nodes.CookieSet; import org.openide.util.Lookup; -import org.openide.util.lookup.Lookups; import org.netbeans.spi.xml.cookies.*; import org.netbeans.modules.xml.XMLDataObjectLook; import org.netbeans.modules.xml.text.TextEditorSupport; @@ -97,13 +96,13 @@ TextEditorSupport.TextEditorSupportFactory editorFactory = new TextEditorSupport.TextEditorSupportFactory (this, XMLKit.MIME_TYPE); editorFactory.registerCookies (set); - + + set.assign(XmlFileEncodingQueryImpl.class, XmlFileEncodingQueryImpl.singleton()); } @Override public final Lookup getLookup() { - return Lookups.fixed(new Object[] { - super.getLookup(), this, XmlFileEncodingQueryImpl.singleton()}); + return getCookieSet().getLookup(); } @Override diff --git a/xslt.tmap/src/org/netbeans/modules/xslt/tmap/TMapDataObject.java b/xslt.tmap/src/org/netbeans/modules/xslt/tmap/TMapDataObject.java --- a/xslt.tmap/src/org/netbeans/modules/xslt/tmap/TMapDataObject.java +++ b/xslt.tmap/src/org/netbeans/modules/xslt/tmap/TMapDataObject.java @@ -20,9 +20,6 @@ import java.awt.event.ActionEvent; import java.io.IOException; -import java.util.LinkedList; -import java.util.List; -import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; import javax.swing.AbstractAction; import javax.swing.Action; @@ -44,7 +41,6 @@ import org.openide.util.HelpCtx; import org.openide.util.Lookup; import org.openide.util.NbBundle; -import org.openide.util.lookup.AbstractLookup; import org.openide.util.lookup.InstanceContent; import org.openide.util.lookup.Lookups; import org.openide.util.lookup.ProxyLookup; @@ -61,7 +57,6 @@ private transient TMapDataEditorSupport myDataEditorSupport; private transient AtomicReference myLookup = new AtomicReference(); - private transient AtomicBoolean isLookupInit = new AtomicBoolean( false ); public TMapDataObject(FileObject pf, TMapDataLoader loader) throws DataObjectExistsException, IOException { super(pf, loader); @@ -73,6 +68,8 @@ // add xsl transform support Source source = DataObjectAdapters.source(this); cookies.add(new TransformableSupport(source)); + + cookies.assign(XmlFileEncodingQueryImpl.class, XmlFileEncodingQueryImpl.singleton()); } /** @@ -158,19 +155,6 @@ @Override public Lookup getLookup() { if (myLookup.get() == null) { - - Lookup lookup; - List list = new LinkedList(); - - list.add(Lookups.fixed( new Object[]{ - super.getLookup(), - this, - getEditorSupport(), - XmlFileEncodingQueryImpl.singleton() - })); - - list.add(getCookieSet().getLookup()); - // add lazy initialization InstanceContent.Convertor conv = new InstanceContent.Convertor() { private AtomicReference valControllerRef = new AtomicReference(); @@ -182,12 +166,6 @@ if (obj == Controller.class) { valControllerRef.compareAndSet(null, new Controller(getEditorSupport().getTMapModel())); return valControllerRef.get(); - } - - - - if (obj == TMapDataEditorSupport.class) { - return getEditorSupport(); } return null; } @@ -204,15 +182,16 @@ return obj.getName(); } }; - list.add(Lookups.fixed( - new Class[] { TMapModel.class, - Controller.class, - TMapDataEditorSupport.class}, conv)); - lookup = new ProxyLookup(list.toArray(new Lookup[list.size()])); + Lookup lookup = new ProxyLookup( + // No need to add TMapDataEditorSupport, since already added to the cookie set, + // and thus already present in getCookieSet().getLookup(). + Lookups.fixed(new Class[] { TMapModel.class, Controller.class }, conv), + // Do not call super.getLookup(), it is deadlock-prone! + getCookieSet().getLookup() + ); myLookup.compareAndSet(null, lookup); - isLookupInit.compareAndSet( false, true ); } return myLookup.get(); }