Search in sources :

Example 1 with ICHelpBook

use of org.eclipse.cdt.ui.ICHelpBook in project linuxtools by eclipse.

the class LibHover method getLibHoverDocs.

public static synchronized void getLibHoverDocs() {
    if (docsFetched) {
        return;
    }
    libraries.clear();
    helpBooks.clear();
    helpBooksMap.clear();
    // Check if caching of library info is enabled and if so, get any
    // cached library hover info.
    IPreferenceStore ps = LibhoverPlugin.getDefault().getPreferenceStore();
    if (ps.getBoolean(PreferenceConstants.CACHE_EXT_LIBHOVER)) {
        // Look for cached libhover files in the plugin state location
        IPath stateLocation = LibhoverPlugin.getDefault().getStateLocation();
        IFileSystem fs = EFS.getLocalFileSystem();
        // $NON-NLS-1$
        IPath CLibraryLocation = stateLocation.append("C");
        // $NON-NLS-1$
        IPath CPPLibraryLocation = stateLocation.append("CPP");
        IFileStore cDir = fs.getStore(CLibraryLocation);
        if (cDir.fetchInfo().exists()) {
            // $NON-NLS-1$
            getCachedLibraries(cDir, "C");
        }
        IFileStore cppDir = fs.getStore(CPPLibraryLocation);
        if (cppDir.fetchInfo().exists()) {
            // $NON-NLS-1$
            getCachedLibraries(cppDir, "C++");
        }
    }
    IExtensionRegistry x = RegistryFactory.getRegistry();
    IConfigurationElement[] ces = x.getConfigurationElementsFor(LIBHOVER_DOC_EXTENSION);
    for (int i = 0; i < ces.length; ++i) {
        IConfigurationElement ce = ces[i];
        if (ce.getName().equals("library")) {
            // $NON-NLS-1$
            // see comment in initialize()
            // Use the FileLocator class to open the magic hover doc file
            // in the plugin's jar.
            // Either open the html file or file system file depending
            // on what has been specified.
            // $NON-NLS-1$
            String location = ce.getAttribute("location");
            // $NON-NLS-1$
            String name = ce.getAttribute("name");
            // $NON-NLS-1$
            String helpdocs = ce.getAttribute("docs");
            // $NON-NLS-1$
            String type = ce.getAttribute("type");
            String nameSpace = ce.getContributor().getName();
            // If library not already cached, create it
            ICHelpBook book = helpBooksMap.get(name);
            if (book == null) {
                HelpBook h = new HelpBook(name, type);
                helpBooks.add(h);
                helpBooksMap.put(name, h);
                LibHoverLibrary l = new LibHoverLibrary(name, location, helpdocs, nameSpace, // $NON-NLS-1$
                "C++".equals(type));
                libraries.put(h, l);
            } else {
                LibHoverLibrary l = libraries.get(book);
                if (l != null) {
                    l.setDocs(helpdocs);
                }
            }
            docsFetched = true;
        }
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) HelpBook(org.eclipse.linuxtools.cdt.libhover.HelpBook) ICHelpBook(org.eclipse.cdt.ui.ICHelpBook) IFileSystem(org.eclipse.core.filesystem.IFileSystem) IFileStore(org.eclipse.core.filesystem.IFileStore) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) ICHelpBook(org.eclipse.cdt.ui.ICHelpBook) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry)

Aggregations

ICHelpBook (org.eclipse.cdt.ui.ICHelpBook)1 IFileStore (org.eclipse.core.filesystem.IFileStore)1 IFileSystem (org.eclipse.core.filesystem.IFileSystem)1 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)1 IExtensionRegistry (org.eclipse.core.runtime.IExtensionRegistry)1 IPath (org.eclipse.core.runtime.IPath)1 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)1 HelpBook (org.eclipse.linuxtools.cdt.libhover.HelpBook)1