Search in sources :

Example 76 with IFileStore

use of org.eclipse.core.filesystem.IFileStore in project linuxtools by eclipse.

the class KernelSourceTree method addLevel.

/**
 * Adds a level to the kernel source tree.
 *
 * @param top The top of the tree to add a level to.
 * @throws CoreException
 */
private void addLevel(TreeNode top, IProgressMonitor monitor) throws CoreException {
    boolean add;
    TreeNode current;
    IFileStore fs = (IFileStore) top.getData();
    IFileStore[] fsList = null;
    fsList = fs.childStores(EFS.NONE, new NullProgressMonitor());
    if (monitor != null) {
        // $NON-NLS-1$
        monitor.beginTask(Localization.getString("ReadingKernelSourceTree"), 100);
    }
    CCodeFileFilter filter = new CCodeFileFilter();
    for (IFileStore fsChildren : fsList) {
        add = true;
        boolean isDir = fsChildren.fetchInfo().isDirectory();
        if (!filter.accept(fsChildren.getName(), isDir)) {
            continue;
        }
        for (int j = 0; j < excluded.length; j++) {
            if (fsChildren.getName().equals(excluded[j].substring(0, excluded[j].length() - 1)) && isDir) {
                add = false;
                break;
            }
        }
        if (add) {
            current = new TreeNode(fsChildren, fsChildren.getName(), !isDir);
            top.add(current);
            if (isDir) {
                addLevel(top.getChildAt(top.getChildCount() - 1), null);
                if (0 == current.getChildCount()) {
                    top.remove(top.getChildCount() - 1);
                }
            }
        }
        if (monitor != null) {
            monitor.worked(1);
        }
    }
    top.sortLevel();
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFileStore(org.eclipse.core.filesystem.IFileStore)

Example 77 with IFileStore

use of org.eclipse.core.filesystem.IFileStore in project linuxtools by eclipse.

the class DevHelpContentProducer method getInputStream.

@Override
public InputStream getInputStream(String pluginID, String href, Locale locale) {
    // Eclipse help system adds parameters to the href but this breaks our path creation so we just strip them.
    if (href.contains("?")) {
        // $NON-NLS-1$
        href = href.substring(0, href.indexOf('?'));
    }
    IPreferenceStore ps = DevHelpPlugin.getDefault().getPreferenceStore();
    IPath devhelpLocation = new Path(ps.getString(PreferenceConstants.DEVHELP_DIRECTORY)).append(href);
    IFileSystem fs = EFS.getLocalFileSystem();
    IFileStore localLocation = fs.getStore(devhelpLocation);
    InputStream stream = null;
    try {
        stream = localLocation.openInputStream(EFS.NONE, new NullProgressMonitor());
    } catch (CoreException e) {
        e.printStackTrace();
    }
    return stream;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IPath(org.eclipse.core.runtime.IPath) CoreException(org.eclipse.core.runtime.CoreException) InputStream(java.io.InputStream) IFileSystem(org.eclipse.core.filesystem.IFileSystem) IFileStore(org.eclipse.core.filesystem.IFileStore) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)

Example 78 with IFileStore

use of org.eclipse.core.filesystem.IFileStore in project linuxtools by eclipse.

the class DevHelpToc method getTopics.

@Override
public ITopic[] getTopics() {
    try {
        ArrayList<ITopic> topics = new ArrayList<>();
        IPreferenceStore ps = DevHelpPlugin.getDefault().getPreferenceStore();
        IPath devhelpLocation = new Path(ps.getString(PreferenceConstants.DEVHELP_DIRECTORY));
        IFileSystem fs = EFS.getLocalFileSystem();
        IFileStore htmlDir = fs.getStore(devhelpLocation);
        IFileStore[] files = htmlDir.childStores(EFS.NONE, null);
        Arrays.sort(files, (arg0, arg1) -> (arg0.getName().compareToIgnoreCase(arg1.getName())));
        for (IFileStore file : files) {
            String name = file.fetchInfo().getName();
            if (fs.getStore(// $NON-NLS-1$
            devhelpLocation.append(name).append(name + ".devhelp2")).fetchInfo().exists()) {
                ITopic topic = new DevHelpTopic(name);
                topics.add(topic);
            }
        }
        ITopic[] retval = new ITopic[topics.size()];
        return topics.toArray(retval);
    } catch (CoreException e) {
    }
    return null;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) ITopic(org.eclipse.help.ITopic) IPath(org.eclipse.core.runtime.IPath) IFileSystem(org.eclipse.core.filesystem.IFileSystem) ArrayList(java.util.ArrayList) CoreException(org.eclipse.core.runtime.CoreException) IFileStore(org.eclipse.core.filesystem.IFileStore) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)

Example 79 with IFileStore

use of org.eclipse.core.filesystem.IFileStore in project linuxtools by eclipse.

the class LibHover method getCachedLibraries.

private static void getCachedLibraries(IFileStore dir, String type) {
    try {
        // $NON-NLS-1$
        boolean isCPP = type.equals("C++");
        IFileStore[] files = dir.childStores(EFS.NONE, null);
        for (int i = 0; i < files.length; ++i) {
            IFileStore file = files[i];
            String fileName = file.fetchInfo().getName();
            if (fileName.endsWith(".libhover")) {
                // $NON-NLS-1$
                File f = file.toLocalFile(EFS.NONE, null);
                if (f != null) {
                    String name = getCleanName(fileName.substring(0, fileName.length() - 9));
                    HelpBook h = new HelpBook(name, type);
                    helpBooks.add(h);
                    helpBooksMap.put(name, h);
                    String location = file.toURI().toString();
                    LibHoverLibrary l = new LibHoverLibrary(name, location, null, null, isCPP);
                    libraries.put(h, l);
                }
            }
        }
    } catch (CoreException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) HelpBook(org.eclipse.linuxtools.cdt.libhover.HelpBook) ICHelpBook(org.eclipse.cdt.ui.ICHelpBook) IFileStore(org.eclipse.core.filesystem.IFileStore) File(java.io.File)

Example 80 with IFileStore

use of org.eclipse.core.filesystem.IFileStore 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

IFileStore (org.eclipse.core.filesystem.IFileStore)105 CoreException (org.eclipse.core.runtime.CoreException)49 IPath (org.eclipse.core.runtime.IPath)29 IOException (java.io.IOException)26 IFileInfo (org.eclipse.core.filesystem.IFileInfo)25 IRemoteFileProxy (org.eclipse.linuxtools.profiling.launch.IRemoteFileProxy)18 URI (java.net.URI)16 InputStream (java.io.InputStream)14 Path (org.eclipse.core.runtime.Path)14 IFile (org.eclipse.core.resources.IFile)12 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)12 InputStreamReader (java.io.InputStreamReader)11 PartInitException (org.eclipse.ui.PartInitException)11 BufferedReader (java.io.BufferedReader)10 URISyntaxException (java.net.URISyntaxException)10 SubProgressMonitor (org.eclipse.core.runtime.SubProgressMonitor)10 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)10 Test (org.junit.Test)10 ITextFileBuffer (org.eclipse.core.filebuffers.ITextFileBuffer)9 IStatus (org.eclipse.core.runtime.IStatus)9