org.eclipse.wst.jsdt.js.common.util

## Class WorkbenchResourceUtil

- java.lang.Object
- - org.eclipse.wst.jsdt.js.common.util.WorkbenchResourceUtil

    public final class WorkbenchResourceUtil
    extends java.lang.Object

### Method Summary

All Methods Static Methods Concrete Methods
`static void` `createFile(IFile file, java.lang.String content)`
`static IFile` `findFileRecursively(IContainer container, java.lang.String name)`
`static java.lang.String` `getAbsolutePath(IResource resource)`
`static IWorkbenchPart` `getActivePart()` Must be called from SWT UI thread only
`static Shell` `getActiveShell()` Must be called from SWT UI thread only
`static IContainer` `getContainerFromSelection(IStructuredSelection selection)`
`static IFile` `getEditorFile(IWorkbenchPart part)`
`static java.io.File` `getFile(java.lang.String path)`
`static IFile` `getFileForLocation(java.lang.String path)`
`static ISelection` `getNamedFileOrTaskSelection(java.lang.String fileName, java.lang.Class<? extends ITask> taskClass)` This method tests the current workbench state and returns one of the following: 1.
`static IProject` `getProject(java.lang.String name)`
`static IResource` `getResource(IProject project, java.lang.String filePath)`
`static IProject` `getSelectedProject()`
`static void` `openInEditor(IFile file, java.lang.String editorID)`
`static void` `showConsoleView()`
`static void` `showErrorDialog(java.lang.String title, java.lang.String message, IStatus status)`
`static void` `updateFile(IFile file, java.lang.String content)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Method Detail

#### getActiveShell

    public static Shell getActiveShell()

Must be called from SWT UI thread only

Returns:
  The active `Shell`

#### getActivePart

    public static IWorkbenchPart getActivePart()

Must be called from SWT UI thread only

Returns:
  The active `IWorkbenchPart`

#### openInEditor

    public static void openInEditor(IFile file,
                                    java.lang.String editorID)
                             throws PartInitException

Throws:
  `PartInitException`

#### createFile

    public static void createFile(IFile file,
                                  java.lang.String content)
                           throws CoreException

Throws:
  `CoreException`

#### updateFile

    public static void updateFile(IFile file,
                                  java.lang.String content)
                           throws CoreException

Throws:
  `CoreException`

#### getSelectedProject

    public static IProject getSelectedProject()

#### getProject

    public static IProject getProject(java.lang.String name)

#### getResource

    public static IResource getResource(IProject project,
                                        java.lang.String filePath)

#### getContainerFromSelection

    public static IContainer getContainerFromSelection(IStructuredSelection selection)

#### getAbsolutePath

    public static java.lang.String getAbsolutePath(IResource resource)

#### showConsoleView

    public static void showConsoleView()
                                throws PartInitException

Throws:
  `PartInitException`

#### findFileRecursively

    public static IFile findFileRecursively(IContainer container,
                                            java.lang.String name)
                                     throws CoreException

Throws:
  `CoreException`

#### getFile

    public static java.io.File getFile(java.lang.String path)

#### getFileForLocation

    public static IFile getFileForLocation(java.lang.String path)

#### showErrorDialog

    public static void showErrorDialog(java.lang.String title,
                                       java.lang.String message,
                                       IStatus status)

#### getEditorFile

    public static IFile getEditorFile(IWorkbenchPart part)

#### getNamedFileOrTaskSelection

    public static ISelection getNamedFileOrTaskSelection(java.lang.String fileName,
                                                         java.lang.Class<? extends ITask> taskClass)

This method tests the current workbench state and returns one of the following: 1. A StructuredSelection containing the currently edited file if it matches the specified name 2. The current selection if its first element is a file matching the specified name 3. The current selection if its first element is an ITask 4. A StructuredSelection containing the first IFile instance in the currently selected container that matches the specified name.

Parameters:
  `fileName` - The file name to test for
Returns:
  The file or ITask selection depending on the documented conditions