use of org.eclipse.core.filesystem.IFileStore in project linuxtools by eclipse.
the class KernelSourceTreeTest method testBuildKernelTree.
@Test
public void testBuildKernelTree() {
TreeNode t;
// Null
String direct = null;
String[] excluded = null;
kst.buildKernelTree(direct, excluded);
assertNull("Null directory", kst.getTree());
// Empty string for directory
direct = "";
kst.buildKernelTree(direct, excluded);
assertNull("Empty string directory", kst.getTree());
// Missing folder
direct = "/noSuchDirectory/";
kst.buildKernelTree(direct, excluded);
assertEquals("Missing directory", 0, kst.getTree().getChildCount());
// Inaccessible
direct = "/root/";
kst.buildKernelTree(direct, excluded);
assertEquals("Inaccessable directory", 0, kst.getTree().getChildCount());
// No .c or .h files
direct = "/bin/";
kst.buildKernelTree(direct, excluded);
t = kst.getTree();
assertEquals("Bin folder item count", 0, t.getChildCount());
assertTrue("Bin folder name", "bin".equals(t.toString()));
assertTrue("Bin has file", t.getData() instanceof IFileStore);
excluded = new String[] { ".git" };
// No .c or .h files
direct = "/tmp/";
kst.buildKernelTree(direct, excluded);
}
use of org.eclipse.core.filesystem.IFileStore in project linuxtools by eclipse.
the class ErrorLineMatcher method matchFound.
@Override
public void matchFound(PatternMatchEvent event) {
try {
String line = console.getDocument().get(event.getOffset(), event.getLength());
String file = line.substring(line.indexOf('/'));
// $NON-NLS-1$
String[] splitted = file.split(":");
Path path = new Path(splitted[0]);
if (path.toFile().exists()) {
IFileStore iFileStore = EFS.getLocalFileSystem().getStore(path);
FileHyperlink fileLink = new FileHyperlink(iFileStore, Integer.valueOf(splitted[1]));
console.addHyperlink(fileLink, line.indexOf('/') + event.getOffset(), file.length());
}
} catch (BadLocationException e1) {
return;
}
}
use of org.eclipse.core.filesystem.IFileStore in project linuxtools by eclipse.
the class OpenFileHandler method runActions.
private void runActions(File file) {
successful = false;
IFileStore fileStore = EFS.getLocalFileSystem().getStore(file.toURI());
IWorkbenchPage page = window.getActivePage();
try {
IDE.openEditorOnFileStore(page, fileStore);
successful = true;
} catch (PartInitException e) {
ErrorDialog.openError(window.getShell(), // $NON-NLS-1$
Localization.getString("OpenFileHandler.Problem"), // $NON-NLS-1$
Localization.getString("OpenFileHandler.ProblemMessage"), new Status(IStatus.ERROR, IDEPlugin.PLUGIN_ID, e.getMessage(), e));
}
}
use of org.eclipse.core.filesystem.IFileStore in project linuxtools by eclipse.
the class ImageBuildPage method validate.
private void validate() {
boolean complete = true;
boolean error = false;
setMessage(null);
String name = nameText.getText();
if (name.length() > 0 && name.charAt(name.length() - 1) == ':') {
setErrorMessage(WizardMessages.getString(INVALID_ID));
error = true;
} else {
if (name.contains(":")) {
// $NON-NLS-1$
if (name.substring(name.indexOf(':') + 1).contains(":")) {
// $NON-NLS-1$
setErrorMessage(WizardMessages.getString(INVALID_ID));
error = true;
}
} else if (name.isEmpty()) {
setMessage(WizardMessages.getString(IMAGE_NAME_EMPTY), WARNING);
}
}
if (!error) {
String dir = directoryText.getText();
if (dir.length() == 0) {
editButton.setEnabled(false);
complete = false;
} else {
IFileStore fileStore = EFS.getLocalFileSystem().getStore(new Path(dir));
IFileInfo info = fileStore.fetchInfo();
if (!info.exists()) {
error = true;
setErrorMessage(WizardMessages.getString(NONEXISTENT_DIRECTORY));
} else if (!info.isDirectory()) {
error = true;
setErrorMessage(WizardMessages.getString(INVALID_DIRECTORY));
} else if (!Files.isReadable(Paths.get(dir))) {
error = true;
setErrorMessage(WizardMessages.getString(UNREADABLE_DIRECTORY));
} else {
editButton.setEnabled(true);
// $NON-NLS-1$
IFileStore dockerStore = fileStore.getChild("Dockerfile");
if (!dockerStore.fetchInfo().exists()) {
complete = false;
setMessage(WizardMessages.getString(NO_DOCKER_FILE), IMessageProvider.INFORMATION);
} else {
lastDirectoryPath = dir;
}
}
}
}
if (!error) {
setErrorMessage(null);
} else {
editButton.setEnabled(false);
}
setPageComplete(complete && !error);
}
use of org.eclipse.core.filesystem.IFileStore in project linuxtools by eclipse.
the class JavaDocContentProducer method getInputStream.
/**
* Returns an input stream for the requested file. This method will be
* called by the Eclipse help system to serve up content to the internal
* web server, which will then be displayed in the help browser.
*
* @param pluginID the plugin ID as set in the manifest
* @param href the link to the file generated by the help system
* @param locale the locale of the file requested (as set in
* JavaDocTocProvider)
* @return the input stream to the file requested
*/
@Override
public InputStream getInputStream(String pluginID, String href, Locale locale) {
// path creation so we just strip them.
if (href.contains("?")) {
// $NON-NLS-1$
href = href.substring(0, href.indexOf('?'));
}
// Eclipse help system appends additional plugin ID, so we strip this
// as well.
// $NON-NLS-1$ //$NON-NLS-2$
String pathToFile = href.replace("org.eclipse.linuxtools.javadocs", "");
// Get path from preferences store, attempt to open input stream to the
// file being requested.
IPreferenceStore ps = JavaDocPlugin.getDefault().getPreferenceStore();
IPath javadocLocation = new Path(ps.getString(PreferenceConstants.JAVADOCS_DIRECTORY)).append(pathToFile);
IFileSystem fs = EFS.getLocalFileSystem();
IFileStore localLocation = fs.getStore(javadocLocation);
InputStream stream = null;
if (!localLocation.fetchInfo().exists()) {
return null;
}
try {
stream = localLocation.openInputStream(EFS.NONE, new NullProgressMonitor());
} catch (CoreException e) {
ILog eLog = JavaDocPlugin.getDefault().getLog();
eLog.log(e.getStatus());
}
return stream;
}
Aggregations