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();
}
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;
}
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;
}
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();
}
}
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;
}
}
}
Aggregations