Search in sources :

Example 71 with IFileStore

use of org.eclipse.core.filesystem.IFileStore in project eclipse.platform.text by eclipse.

the class FileStoreFileBuffersForNonExistingExternalFiles method setReadOnly.

/*
	 * @see org.eclipse.core.filebuffers.tests.FileBufferFunctions#markReadOnly()
	 */
@Override
protected void setReadOnly(boolean state) throws Exception {
    IFileStore fileStore = FileBuffers.getFileStoreAtLocation(getPath());
    assertNotNull(fileStore);
    fileStore.fetchInfo().setAttribute(EFS.ATTRIBUTE_READ_ONLY, state);
}
Also used : IFileStore(org.eclipse.core.filesystem.IFileStore)

Example 72 with IFileStore

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

the class OpenVagrantfileCommandHandler method executeInJob.

@Override
void executeInJob(IVagrantVM vm, IProgressMonitor monitor) {
    Display.getDefault().asyncExec(() -> {
        IWorkbenchPage activePage = Activator.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
        IPath vgFilePath = new Path(vm.directory().getAbsolutePath()).append(// $NON-NLS-1$
        "Vagrantfile");
        IFileStore file = EFS.getLocalFileSystem().getStore(vgFilePath);
        try {
            IDE.openEditorOnFileStore(activePage, file);
        } catch (PartInitException e) {
            Activator.log(e);
        }
    });
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IPath(org.eclipse.core.runtime.IPath) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IFileStore(org.eclipse.core.filesystem.IFileStore) PartInitException(org.eclipse.ui.PartInitException)

Example 73 with IFileStore

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

the class KernelBrowserView method validateProxy.

private boolean validateProxy(IRemoteFileProxy proxy, String kernelSource) {
    if (proxy == null) {
        return false;
    }
    IFileStore fs = proxy.getResource(kernelSource);
    if (fs == null) {
        return false;
    }
    IFileInfo info = fs.fetchInfo();
    if (info == null) {
        return false;
    }
    if (!info.exists()) {
        return false;
    }
    return true;
}
Also used : IFileInfo(org.eclipse.core.filesystem.IFileInfo) IFileStore(org.eclipse.core.filesystem.IFileStore)

Example 74 with IFileStore

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

the class KernelSourceAction method run.

/**
 * The main code body for this action. Causes one of the following to occur:
 * <ul>
 *     <li>If the selected node is clickable, as specified in <code>TreeNode.isClickable</code>
 *         the browser creates an instance of <code>CEditor</code> on the file specified in the selection
 *         (<code>KernelBrowserView</code>'s tree only marks clickable on files, not folders) and
 *         opens it on the current window</li>
 *     <li>If the selected node is not clickable, the code runs the action specified in
 *         <code>TreeExpandCollapseAction</code></li>
 * @see org.eclipse.linuxtools.internal.systemtap.ui.ide.editors.c.CEditor
 * @see TreeNode#isClickable()
 * @see TreeExpandCollapseAction
 */
@Override
public void run() {
    IWorkbench wb = PlatformUI.getWorkbench();
    Object o = getSelectedElement();
    if (o instanceof TreeNode) {
        TreeNode t = (TreeNode) o;
        if (t.isClickable()) {
            IFileStore fs = (IFileStore) t.getData();
            if (fs != null) {
                IEditorInput input = new FileStoreEditorInput(fs);
                try {
                    wb.getActiveWorkbenchWindow().getActivePage().openEditor(input, CDT_EDITOR_ID);
                } catch (PartInitException e) {
                    // $NON-NLS-1$
                    ExceptionErrorDialog.openError(Localization.getString("KernelSourceAction.CantOpenEditor"), e);
                }
            }
        } else {
            runExpandAction();
        }
    }
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) TreeNode(org.eclipse.linuxtools.systemtap.structures.TreeNode) IFileStore(org.eclipse.core.filesystem.IFileStore) PartInitException(org.eclipse.ui.PartInitException) IEditorInput(org.eclipse.ui.IEditorInput) FileStoreEditorInput(org.eclipse.ui.ide.FileStoreEditorInput)

Example 75 with IFileStore

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

the class KernelSourceTree method buildKernelTree.

/**
 * Builds the kernel tree from file parameter direct and stores the excluded string array.
 *
 * @param locationURI The URI to include into the tree.
 * @param excluded The string array to store as excluded.
 * @param proxy The proxy to be used to get the remote files
 * @param monitor a progress monitor for this operation. Can be null.
 * @throws CoreException If traversing the tree fails.
 *
 * @since 1.1
 */
public void buildKernelTree(URI locationURI, String[] excluded, IRemoteFileProxy proxy, IProgressMonitor monitor) throws CoreException {
    if (excluded != null) {
        this.excluded = Arrays.copyOf(excluded, excluded.length);
    }
    IFileStore fs = proxy.getResource(locationURI.getPath());
    if (fs == null) {
        kernelTree = null;
    } else {
        kernelTree = new TreeNode(fs, fs.getName(), false);
        addLevel(kernelTree, monitor);
    }
}
Also used : IFileStore(org.eclipse.core.filesystem.IFileStore)

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