|
What this is
Other links
The source code/* * 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-2004 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.modules.java.j2seplatform.platformdefinition; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.net.MalformedURLException; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; import java.util.ArrayList; import java.util.Iterator; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import org.netbeans.api.java.classpath.ClassPath; import org.netbeans.api.java.platform.JavaPlatform; import org.netbeans.api.java.platform.JavaPlatformManager; import org.netbeans.api.java.queries.JavadocForBinaryQuery; import org.netbeans.spi.java.queries.JavadocForBinaryQueryImplementation; import org.openide.ErrorManager; import org.openide.filesystems.FileObject; import org.openide.filesystems.FileStateInvalidException; import org.openide.filesystems.URLMapper; import org.openide.util.WeakListeners; /** * Implementation of Javadoc query for the platform. */ public class JavadocForBinaryQueryPlatformImpl implements JavadocForBinaryQueryImplementation { private static final int STATE_ERROR = -1; private static final int STATE_START = 0; private static final int STATE_DOCS = 1; private static final int STATE_LAN = 2; private static final int STATE_API = 3; private static final int STATE_INDEX = 4; private static final String NAME_DOCS = "docs"; //NOI18N private static final String NAME_JA = "ja"; //NOI18N private static final String NAME_API = "api"; //NOI18N private static final String NAME_IDNEX ="index-files"; //NOI18N /** Default constructor for lookup. */ public JavadocForBinaryQueryPlatformImpl() { } public JavadocForBinaryQuery.Result findJavadoc(final URL b) { class R implements JavadocForBinaryQuery.Result, PropertyChangeListener { private JavaPlatform platform; private ArrayList listeners; private URL[] cachedRoots; public R (JavaPlatform plat) { this.platform = plat; this.platform.addPropertyChangeListener (WeakListeners.propertyChange(this,this.platform)); } public synchronized URL[] getRoots() { if (this.cachedRoots == null) { ArrayList l = new ArrayList(); for (Iterator i2 = this.platform.getJavadocFolders().iterator(); i2.hasNext();) { URL u = (URL)i2.next(); l.add(getIndexFolder(u)); } this.cachedRoots = (URL[])l.toArray(new URL[l.size()]); } return this.cachedRoots; } public synchronized void addChangeListener(ChangeListener l) { assert l != null : "Listener can not be null"; //NOI18N if (this.listeners == null) { this.listeners = new ArrayList (); } this.listeners.add (l); } public synchronized void removeChangeListener(ChangeListener l) { assert l != null : "Listener can not be null"; //NOI18N if (this.listeners == null) { return; } this.listeners.remove (l); } public void propertyChange (PropertyChangeEvent event) { if (JavaPlatform.PROP_JAVADOC_FOLDER.equals(event.getPropertyName())) { synchronized (this) { this.cachedRoots = null; } this.fireChange (); } } private void fireChange () { Iterator it = null; synchronized (this) { if (this.listeners == null) { return; } it = ((ArrayList)this.listeners.clone()).iterator(); } ChangeEvent event = new ChangeEvent (this); while (it.hasNext()) { ((ChangeListener)it.next()).stateChanged(event); } } } JavaPlatformManager jpm = JavaPlatformManager.getDefault(); JavaPlatform platforms[] = jpm.getInstalledPlatforms(); for (int i=0; i |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.