public class ProjectUtils
extends java.lang.Object
Constructor and Description |
---|
ProjectUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
createFile(IProject project,
java.lang.String fileName,
java.lang.String content) |
static void |
createFolder(IProject project,
java.lang.String folder,
Shell dialogShell)
Creates a folder if it does not exist yet.
|
static boolean |
deleteFolder(IProject project,
java.lang.String folder,
Shell dialogShell)
Deletes a folder if it does exist.
|
static void |
ensureMetadataDirectory(IProject project)
The "
.metadata " directory is
created if it does not exist. |
static IProject |
extractProjectFromPath(java.lang.String path)
Exgtracts the project from a given path.
|
static java.lang.String |
getAbsolutFolderPath(IProject project,
java.lang.String folder)
Converts a project relative path to an file system absolute one.
|
static IDocument |
getDocumentOfOpenEditor(IEditorReference editorReference) |
static IDocument |
getDocumentOfOpenEditor(java.lang.String path,
boolean restore)
Get the document of this already open editor.
|
static IDocument |
getDocumentOfOpenIniEditor(java.lang.String path)
Get the document of this already open editor.
|
static java.io.File |
getFileFromName(java.lang.String fileName,
IniDocument document)
Tries to find a file.
The following search order applies: The given project is searched. |
static java.io.File |
getFileFromName(java.lang.String fileName,
IProject project) |
static IFile |
getFileOfOpenEditor(java.lang.String path) |
static IPath |
getIPathOfCurrentEditor()
Get the IPath of the current editor, or null if we can't figure it out.
It is up to the caller to ensure that this is run in the UI thread. |
static java.util.List<IEditorReference> |
getOpenFileEditors() |
static java.util.List<java.lang.String> |
getOpenFileEditorsFileNames() |
static IEditorPart |
getOpenTextEditor(java.lang.String path) |
static java.lang.String |
getPathOfCurrentEditor() |
static IPath |
getPathOfEditor(IEditorPart editor) |
static IPath |
getPathRelativeToProject(IProject project,
java.lang.String filename)
Get an IPath for a full path relative to a project.
Eclipse needs this to open the file. |
static IProject |
getProjectByName(java.lang.String name)
Returns the project having the given name.
|
static IProject |
getProjectForActivePage()
Tries to get the project the resource being edited resides into.
|
static ProjectPropertyStore |
getProjectPropertyStore(IProject project,
Shell errDialogShell)
Get this project's PropertyStore
|
static IResource |
getUnderlyingResource(IEditorInput input)
Gets the underlying resource for a
IEditorInput . |
static boolean |
isFileInProject(IProject project,
java.lang.String pathname)
Is this file in the project space?
|
static boolean |
isFileInWorkspace(java.lang.String filename)
Is this file in the workspace
|
static IEditorPart |
openFile(java.lang.String pathName)
Open a file in a PovrayEditor
|
static IEditorPart |
openFile(java.lang.String pathName,
int position,
int length)
Open a file in a PovrayEditor
|
static java.lang.String |
readFile(java.lang.String path,
java.nio.charset.Charset encoding) |
static void |
removeAllMarkers()
Delete all of our IMarkers from the known open editors.
|
static void |
updateAllErrorAnnotations() |
public static IProject getProjectByName(java.lang.String name)
name
- The name to be checkednull
if the workspace does not
have such a project.public static IProject extractProjectFromPath(java.lang.String path) throws PovrayException
path
- The file path who's project is to be extracted.PovrayException
- If the resource does not reside in a project.public static IPath getPathRelativeToProject(IProject project, java.lang.String filename)
project
- The project to work off offilename
- The full path of the filepublic static boolean isFileInProject(IProject project, java.lang.String pathname)
project
- The project to work off of.pathname
- The full path of the file.public static boolean isFileInWorkspace(java.lang.String filename)
filename
- The pathname to checkpublic static java.io.File getFileFromName(java.lang.String fileName, IniDocument document)
"Wind"
(that is, we're
running on an Microsoft Operating System) the given
fileName
is compared ignoring the case,
otherwise the case is taken into account.fileName
- The name of the file (without path) to be searched.project
- The project who's library path is to be used.null
if no file could be found.public static java.io.File getFileFromName(java.lang.String fileName, IProject project)
public static IProject getProjectForActivePage()
null
if it can not be found.public static IResource getUnderlyingResource(IEditorInput input)
IEditorInput
.element
- null
if the input is not an instance of
an IFileEditorInput
.public static java.util.List<java.lang.String> getOpenFileEditorsFileNames() throws PartInitException
List
of String
objects, each
representing the path to a file being opened by an editor. Never null
.PartInitException
- If the editor input can not be fetched.public static java.util.List<IEditorReference> getOpenFileEditors() throws PartInitException
List
of IEditorReference
objects, each
representing an editor having an EditorInput
of type
FileEditorInput
. Never null
.PartInitException
- If the editor input can not be fetched.public static IEditorPart getOpenTextEditor(java.lang.String path)
public static IDocument getDocumentOfOpenEditor(java.lang.String path, boolean restore)
path
- The path of the file of the open editor.restore
- open the editor if it's dormant. (like loaded, but not looked at in eclipse)public static IDocument getDocumentOfOpenEditor(IEditorReference editorReference)
public static IDocument getDocumentOfOpenIniEditor(java.lang.String path)
path
- The path of the file of the open editor.public static IFile getFileOfOpenEditor(java.lang.String path)
public static void removeAllMarkers()
public static void updateAllErrorAnnotations()
public static IEditorPart openFile(java.lang.String pathName)
pathName
- The absolute path of the file to be openedpublic static IEditorPart openFile(java.lang.String pathName, int position, int length)
pathName
- The absolute path of the file to be openedposition
- The offset to move the cursor to upon opening. -1 = don't move the cursorlength
- The length of the text to select upon opening.public static java.lang.String getAbsolutFolderPath(IProject project, java.lang.String folder)
project
- The projectfolder
- The project relative folder pathpublic static void createFolder(IProject project, java.lang.String folder, Shell dialogShell)
project
- The project to receive the folderfolder
- The project relative path of the folder to be created.dialogShell
- A Shell to be used as parent when displaying error or warning dialogs.java.io.IOException
- If the folder could not be created.public static void createFile(IProject project, java.lang.String fileName, java.lang.String content)
public static java.lang.String readFile(java.lang.String path, java.nio.charset.Charset encoding)
public static boolean deleteFolder(IProject project, java.lang.String folder, Shell dialogShell)
project
- The project hosting the folderfolder
- The project relative path of the folder to be removed.dialogShell
- A Shell to be used as parent when displaying error or warning dialogs.true
if and only if the directory was deleted,
false
otherwise.public static ProjectPropertyStore getProjectPropertyStore(IProject project, Shell errDialogShell)
project
- The project whose ProjectPropertyStore
is to be loaded.errDialogShell
- The Shell
to be used for displaying
an error dialog if the ProjectPropertyStore
could not be loaded.ProjectPropertyStore
or
null
it it could not be loaded.public static void ensureMetadataDirectory(IProject project)
.metadata
" directory is
created if it does not exist.project
- The projects who's ".metadata
"
directory is to be created.public static IPath getIPathOfCurrentEditor()
public static IPath getPathOfEditor(IEditorPart editor)
public static java.lang.String getPathOfCurrentEditor()