diff --git a/api.debugger/src/org/netbeans/api/debugger/Lookup.java b/api.debugger/src/org/netbeans/api/debugger/Lookup.java --- a/api.debugger/src/org/netbeans/api/debugger/Lookup.java +++ b/api.debugger/src/org/netbeans/api/debugger/Lookup.java @@ -68,13 +68,17 @@ import java.util.logging.Level; import java.util.logging.Logger; +import org.netbeans.debugger.registry.ContextAwareService; import org.netbeans.spi.debugger.ContextProvider; import org.openide.modules.ModuleInfo; import org.openide.util.Exceptions; +import org.openide.util.Lookup.Item; import org.openide.util.LookupEvent; import org.openide.util.RequestProcessor; import org.openide.util.WeakListeners; import org.openide.util.WeakSet; +import org.openide.util.lookup.Lookups; +import org.openide.util.Lookup.Result; /** @@ -251,9 +255,11 @@ private List list(String folder, Class service) { String name = service.getName (); - String resourceName = "META-INF/debugger/" + - ((rootFolder == null) ? "" : rootFolder + "/") + - ((folder == null) ? "" : folder + "/") + + String pathResourceName = "debugger/" + + ((rootFolder == null) ? "" : rootFolder + "/") + + ((folder == null) ? "" : folder + "/"); + String resourceName = "META-INF/" + + pathResourceName + name; synchronized(registrationCache) { List l = registrationCache.get(resourceName); @@ -265,6 +271,13 @@ } } + private Result listLookup(String folder, Class service) { + String pathResourceName = "Debugger/" + + ((rootFolder == null) ? "" : rootFolder + "/") + + ((folder == null) ? "" : folder + "/"); + return Lookups.forPath(pathResourceName).lookupResult(service); + } + private static Set getHiddenClassNames(List l) { Set s = null; int i, k = l.size (); @@ -580,40 +593,56 @@ public int notifyUnloadOrder = 0; public MetaInfLookupList(String folder, Class service) { - this(list(folder, service), service); + this(list(folder, service), listLookup(folder, service), service); this.folder = folder; } - private MetaInfLookupList(List l, Class service) { - this(l, getHiddenClassNames(l), service); + private MetaInfLookupList(List l, Result lr, Class service) { + this(l, lr, getHiddenClassNames(l), service); } - private MetaInfLookupList(List l, Set s, Class service) { + private MetaInfLookupList(List l, Result lr, Set s, Class service) { super(s); assert service != null; this.service = service; - fillInstances(l, s); + fillInstances(l, lr, s); listenOnDisabledModules(); } - private void fillInstances(List l, Set s) { + private void fillInstances(List l, Result lr, Set s) { for (String className : l) { if (className.endsWith(HIDDEN)) continue; if (s != null && s.contains (className)) continue; - Object instance = null; - synchronized(instanceCache) { - instance = instanceCache.get (className); + fillClassInstance(className); + } + for (Item li : lr.allItems()) { + add(new LazyInstance(service, li)); + } + /* + for (Object lri : lr.allInstances()) { + if (lri instanceof ContextAwareService) { + String className = ((ContextAwareService) lri).serviceName(); + if (s != null && s.contains (className)) continue; + fillClassInstance(className); } - if (instance != null) { - try { - add(service.cast(instance), className); - } catch (ClassCastException cce) { - Logger.getLogger(Lookup.class.getName()).log(Level.WARNING, null, cce); - } - listenOn(instance.getClass().getClassLoader()); - } else if (checkClassName(className)) { - add(new LazyInstance(service, className), className); + } + */ + } + + private void fillClassInstance(String className) { + Object instance = null; + synchronized(instanceCache) { + instance = instanceCache.get (className); + } + if (instance != null) { + try { + add(service.cast(instance), className); + } catch (ClassCastException cce) { + Logger.getLogger(Lookup.class.getName()).log(Level.WARNING, null, cce); } + listenOn(instance.getClass().getClassLoader()); + } else if (checkClassName(className)) { + add(new LazyInstance(service, className), className); } } @@ -645,9 +674,10 @@ // can sync on it clear(); List l = list(folder, service); + Result lr = listLookup(folder, service); Set s = getHiddenClassNames(l); hiddenClassNames = s; - fillInstances(l, s); + fillInstances(l, lr, s); firePropertyChange(); } @@ -704,25 +734,44 @@ } private class LazyInstance extends LookupLazyEntry { + private String className; private Class service; + Item lookupItem; + public LazyInstance(Class service, String className) { this.service = service; this.className = className; + } + + public LazyInstance(Class service, Item lookupItem) { + this.service = service; + this.lookupItem = lookupItem; } private final Object instanceCreationLock = new Object(); protected T getEntry() { Object instance = null; - synchronized (instanceCreationLock) { - synchronized(instanceCache) { - instance = instanceCache.get (className); + if (lookupItem != null) { + instance = lookupItem.getInstance(); + if (instance instanceof ContextAwareService) { + ContextAwareService cas = (ContextAwareService) instance; + className = cas.serviceName(); + lookupItem = null; + instance = null; } - if (instance == null) { - instance = createInstance (className); - synchronized (instanceCache) { - instanceCache.put (className, instance); + } + if (instance == null) { + synchronized (instanceCreationLock) { + synchronized(instanceCache) { + instance = instanceCache.get (className); + } + if (instance == null) { + instance = createInstance (className); + synchronized (instanceCache) { + instanceCache.put (className, instance); + } } } } diff --git a/api.debugger/src/org/netbeans/debugger/registry/ContextAwareService.java b/api.debugger/src/org/netbeans/debugger/registry/ContextAwareService.java new file mode 100644 --- /dev/null +++ b/api.debugger/src/org/netbeans/debugger/registry/ContextAwareService.java @@ -0,0 +1,65 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2009 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 2009 Sun Microsystems, Inc. + */ + +package org.netbeans.debugger.registry; + +/** + * Instance of registry entry, that delegates to a debugger service, that can be + * context-aware. + * This instances should be registered in layers and created by createService factory + * method as follows: + * + *
+ *   <folder name="Debugger">
+ *       <file name="MyDebuggerService.instance">
+ *           <attr name="instanceCreate" methodvalue="org.netbeans.debugger.registry.ContextAwareServiceHandler.createService"/>
+ *           <attr name="serviceName" stringvalue="org.netbeans.my_debugger.MyServiceImpl"/>
+ *           <attr name="serviceClass" stringvalue="org.netbeans.debugger.Service"/>
+ *       </file>
+ *   </folder>
+ * + *
+ * + * @author Martin Entlicher + */ +public interface ContextAwareService { + + String serviceName(); + +} diff --git a/api.debugger/src/org/netbeans/debugger/registry/ContextAwareServiceHandler.java b/api.debugger/src/org/netbeans/debugger/registry/ContextAwareServiceHandler.java new file mode 100644 --- /dev/null +++ b/api.debugger/src/org/netbeans/debugger/registry/ContextAwareServiceHandler.java @@ -0,0 +1,91 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2009 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 2009 Sun Microsystems, Inc. + */ + +package org.netbeans.debugger.registry; + +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; +import java.lang.reflect.Proxy; +import java.util.Map; +import org.openide.util.Lookup; + +/** + * + * @author martin + */ +public class ContextAwareServiceHandler implements InvocationHandler { + + private static final String SERVICE_NAME = "serviceName"; // NOI18N + private static final String SERVICE_CLASS = "serviceClass"; // NOI18N + + private String serviceName; + + private ContextAwareServiceHandler(String serviceName) { + this.serviceName = serviceName; + } + + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { + if (method.getName().equals("serviceName")) { // NOI18N + return serviceName; + } else { + throw new UnsupportedOperationException("Method "+method.getName()+" can not be called on this virtual object!"); // NOI18N + } + } + + /** + * Creates instance of ContextAwareService based on layer.xml + * attribute values + * + * @param attrs attributes loaded from layer.xml + * @return new ContextAwareService instance + */ + static ContextAwareService createService(Map attrs) throws ClassNotFoundException { + String serviceName = (String) attrs.get(SERVICE_NAME); + String serviceClass = (String) attrs.get(SERVICE_CLASS); + + ClassLoader cl = Lookup.getDefault().lookup(ClassLoader.class); + return (ContextAwareService) + Proxy.newProxyInstance( + cl, + new Class[] { ContextAwareService.class, + Class.forName(serviceClass, true, cl) }, + new ContextAwareServiceHandler(serviceName)); + } + +} diff --git a/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/resources/mf-layer.xml b/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/resources/mf-layer.xml --- a/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/resources/mf-layer.xml +++ b/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/resources/mf-layer.xml @@ -306,4 +306,17 @@ + + + + + + + + + + + + + diff --git a/spi.debugger.ui/test/unit/src/org/netbeans/api/debugger/DebuggerApiTestBase.java b/spi.debugger.ui/test/unit/src/org/netbeans/api/debugger/DebuggerApiTestBase.java --- a/spi.debugger.ui/test/unit/src/org/netbeans/api/debugger/DebuggerApiTestBase.java +++ b/spi.debugger.ui/test/unit/src/org/netbeans/api/debugger/DebuggerApiTestBase.java @@ -59,7 +59,8 @@ } protected void assertInstanceOf(String msg, Object obj, Class aClass) { - if (!obj.getClass().isAssignableFrom(aClass)) + assertNotNull("An object is not an instance of "+aClass+", because it is 'null'.", obj); + if (!aClass.isAssignableFrom(obj.getClass())) { fail(msg); } diff --git a/spi.debugger.ui/test/unit/src/org/netbeans/api/debugger/IDEInitializer.java b/spi.debugger.ui/test/unit/src/org/netbeans/api/debugger/IDEInitializer.java new file mode 100644 --- /dev/null +++ b/spi.debugger.ui/test/unit/src/org/netbeans/api/debugger/IDEInitializer.java @@ -0,0 +1,157 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2007 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]" + * + * Contributor(s): + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Microsystems, Inc. All Rights Reserved. + * + * 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. + */ + +package org.netbeans.api.debugger; + +import java.beans.PropertyVetoException; +import java.io.File; +import java.io.IOException; +import java.net.URL; +import java.net.URLStreamHandler; +import java.net.URLStreamHandlerFactory; +import java.util.Enumeration; +import junit.framework.Assert; +import org.netbeans.junit.Manager; +import org.openide.filesystems.FileObject; +import org.openide.filesystems.FileSystem; +import org.openide.filesystems.FileUtil; +import org.openide.filesystems.MultiFileSystem; +import org.openide.filesystems.Repository; +import org.openide.filesystems.XMLFileSystem; +import org.openide.util.Lookup; +import org.openide.util.lookup.Lookups; +import org.openide.util.lookup.ProxyLookup; + + +/** + * Inspired by org.netbeans.api.project.TestUtil. + * + * @author Miloslav Metelka, Jan Lahoda + */ +public class IDEInitializer extends ProxyLookup { + + public static IDEInitializer DEFAULT_LOOKUP = null; + private static FileSystem lfs; + + static { + IDEInitializer.class.getClassLoader ().setDefaultAssertionStatus (true); + System.setProperty ("org.openide.util.Lookup", IDEInitializer.class.getName ()); + Assert.assertEquals (IDEInitializer.class, Lookup.getDefault ().getClass ()); + } + + public IDEInitializer () { + Assert.assertNull (DEFAULT_LOOKUP); + DEFAULT_LOOKUP = this; + URL.setURLStreamHandlerFactory (new MyURLHandlerFactory ()); + } + + /** + * Set the global default lookup with the specified content. + * + * @param layers xml-layer URLs to be present in the system filesystem. + * @param instances object instances to be present in the default lookup. + */ + public static void setup ( + String[] layers, + Object[] instances + ) { + ClassLoader classLoader = IDEInitializer.class.getClassLoader (); + File workDir = new File (Manager.getWorkDirPath ()); + URL[] urls = new URL [layers.length]; + int i, k = urls.length; + for (i = 0; i < k; i++) + urls [i] = classLoader.getResource (layers [i]); + + // 1) create repository + XMLFileSystem systemFS = new XMLFileSystem (); + lfs = FileUtil.createMemoryFileSystem(); + try { + systemFS.setXmlUrls (urls); + } catch (Exception ex) { + ex.printStackTrace (); + } + MyFileSystem myFileSystem = new MyFileSystem ( + new FileSystem [] {lfs, systemFS} + ); + Repository repository = new Repository (myFileSystem); + + Object[] lookupContent = new Object [instances.length + 1]; + lookupContent [0] = repository; + System.arraycopy (instances, 0, lookupContent, 1, instances.length); + + DEFAULT_LOOKUP.setLookups (new Lookup[] { + Lookups.fixed (lookupContent), + Lookups.metaInfServices (classLoader), + Lookups.singleton (classLoader), + }); + Assert.assertTrue (myFileSystem.isDefault()); + } + + public static void cleanWorkDir () { + try { + Enumeration en = lfs.getRoot ().getChildren (false); + while (en.hasMoreElements ()) + ((FileObject) en.nextElement ()).delete (); + } catch (IOException ex) { + ex.printStackTrace (); + } + } + + private static class MyFileSystem extends MultiFileSystem { + public MyFileSystem (FileSystem[] fileSystems) { + super (fileSystems); + try { + setSystemName ("TestFS"); + } catch (PropertyVetoException ex) { + ex.printStackTrace(); + } + } + } + + private static class MyURLHandlerFactory implements URLStreamHandlerFactory { + public URLStreamHandler createURLStreamHandler(String protocol) { + if (protocol.equals ("nbfs")) { + return FileUtil.nbfsURLStreamHandler (); + } + return null; + } + } +} diff --git a/spi.debugger.ui/test/unit/src/org/netbeans/api/debugger/LookupWithForPathTest.java b/spi.debugger.ui/test/unit/src/org/netbeans/api/debugger/LookupWithForPathTest.java new file mode 100644 --- /dev/null +++ b/spi.debugger.ui/test/unit/src/org/netbeans/api/debugger/LookupWithForPathTest.java @@ -0,0 +1,81 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2009 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 2009 Sun Microsystems, Inc. + */ + +package org.netbeans.api.debugger; + +import java.util.List; +import org.netbeans.api.debugger.test.TestLookupServiceFirst; +import org.netbeans.api.debugger.test.TestNodeModelContext; +import org.netbeans.spi.viewmodel.NodeModel; + +/** + * + * @author Martin Entlicher + */ +public class LookupWithForPathTest extends DebuggerApiTestBase { + + static { + String[] layers = new String[] {"org/netbeans/api/debugger/test/mf-layer.xml"};//NOI18N + Object[] instances = new Object[] { }; + IDEInitializer.setup(layers,instances); + } + + public LookupWithForPathTest(String s) { + super(s); + } + + public void testForPath() throws Exception { + Lookup.MetaInf l = new Lookup.MetaInf("unittest"); + List list = l.lookup(null, TestLookupServiceFirst.class); + assertEquals("Wrong looked up object", 2, list.size()); + assertInstanceOf("Wrong looked up object", list.get(0), TestLookupServiceFirst.class); + assertInstanceOf("Wrong looked up object", list.get(1), TestLookupServiceFirst.class); + + Lookup testContext = new Lookup.Instance(new Object[] {}); + l.setContext(testContext); + List nodeModelList = l.lookup(null, NodeModel.class); + assertEquals("Wrong looked up object", 2, nodeModelList.size()); + assertInstanceOf("Wrong looked up object", nodeModelList.get(0), NodeModel.class); + assertInstanceOf("Wrong looked up object", nodeModelList.get(1), NodeModel.class); + assertInstanceOf("Wrong looked up object", nodeModelList.get(1), TestNodeModelContext.class); + TestNodeModelContext nmc = (TestNodeModelContext) nodeModelList.get(1); + assertNotNull(nmc.getContext()); + assertEquals(testContext, nmc.getContext()); + } +} diff --git a/spi.debugger.ui/test/unit/src/org/netbeans/api/debugger/test/TestNodeModel.java b/spi.debugger.ui/test/unit/src/org/netbeans/api/debugger/test/TestNodeModel.java new file mode 100644 --- /dev/null +++ b/spi.debugger.ui/test/unit/src/org/netbeans/api/debugger/test/TestNodeModel.java @@ -0,0 +1,72 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2009 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 2009 Sun Microsystems, Inc. + */ + +package org.netbeans.api.debugger.test; + +import org.netbeans.spi.viewmodel.ModelListener; +import org.netbeans.spi.viewmodel.NodeModel; +import org.netbeans.spi.viewmodel.UnknownTypeException; + +/** + * + * @author martin + */ +public class TestNodeModel implements NodeModel { + + public String getDisplayName(Object node) throws UnknownTypeException { + throw new UnsupportedOperationException("Not supported yet."); + } + + public String getIconBase(Object node) throws UnknownTypeException { + throw new UnsupportedOperationException("Not supported yet."); + } + + public String getShortDescription(Object node) throws UnknownTypeException { + throw new UnsupportedOperationException("Not supported yet."); + } + + public void addModelListener(ModelListener l) { + throw new UnsupportedOperationException("Not supported yet."); + } + + public void removeModelListener(ModelListener l) { + throw new UnsupportedOperationException("Not supported yet."); + } + +} diff --git a/spi.debugger.ui/test/unit/src/org/netbeans/api/debugger/test/TestNodeModelContext.java b/spi.debugger.ui/test/unit/src/org/netbeans/api/debugger/test/TestNodeModelContext.java new file mode 100644 --- /dev/null +++ b/spi.debugger.ui/test/unit/src/org/netbeans/api/debugger/test/TestNodeModelContext.java @@ -0,0 +1,83 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2009 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 2009 Sun Microsystems, Inc. + */ + +package org.netbeans.api.debugger.test; + +import org.netbeans.spi.debugger.ContextProvider; +import org.netbeans.spi.viewmodel.ModelListener; +import org.netbeans.spi.viewmodel.NodeModel; +import org.netbeans.spi.viewmodel.UnknownTypeException; + +/** + * + * @author martin + */ +public class TestNodeModelContext implements NodeModel { + + private ContextProvider context; + + public TestNodeModelContext(ContextProvider context) { + this.context = context; + } + + public ContextProvider getContext() { + return context; + } + + public String getDisplayName(Object node) throws UnknownTypeException { + throw new UnsupportedOperationException("Not supported yet."); + } + + public String getIconBase(Object node) throws UnknownTypeException { + throw new UnsupportedOperationException("Not supported yet."); + } + + public String getShortDescription(Object node) throws UnknownTypeException { + throw new UnsupportedOperationException("Not supported yet."); + } + + public void addModelListener(ModelListener l) { + throw new UnsupportedOperationException("Not supported yet."); + } + + public void removeModelListener(ModelListener l) { + throw new UnsupportedOperationException("Not supported yet."); + } + +} diff --git a/spi.debugger.ui/test/unit/src/org/netbeans/api/debugger/test/mf-layer.xml b/spi.debugger.ui/test/unit/src/org/netbeans/api/debugger/test/mf-layer.xml new file mode 100644 --- /dev/null +++ b/spi.debugger.ui/test/unit/src/org/netbeans/api/debugger/test/mf-layer.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + +