public final class EclipseUtils
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
CANNOT_OPEN_FILE
Error message displayed when a file could not be opened.
|
private static java.lang.String |
COMMAND_ERROR
Error message displayed when an error occurs while executing a command.
|
static org.eclipse.core.runtime.IProgressMonitor |
NULL_MONITOR
NullProgressMonitor instance shared in order to avoid instance duplication. |
Modifier | Constructor and Description |
---|---|
private |
EclipseUtils()
Private constructor for avoiding instantiation.
|
Modifier and Type | Method and Description |
---|---|
static void |
executeCommand(java.lang.String commandId)
Executes the command denoted by the given commandId.
|
private static java.lang.String |
getContent(org.eclipse.core.resources.IFile file)
Retrieves the content as a
String of the given file |
static java.util.Optional<org.eclipse.core.resources.IFile> |
getCurrentFile()
Retrieves file instance that is currently edited.
|
static java.lang.String |
getCurrentUser()
Retrieves the current user name.
|
static org.eclipse.core.resources.IFolder |
getFolder(org.eclipse.core.resources.IProject project,
java.lang.String path)
Retrieves folder denoted by the given path from
the given project.
|
static org.eclipse.core.resources.IFolder |
getFolder(org.eclipse.core.resources.IProject project,
java.lang.String path,
org.eclipse.core.runtime.IProgressMonitor monitor)
Retrieves folder denoted by the given path from
the given project.
|
static boolean |
isFileEquals(org.eclipse.core.resources.IFile expected,
org.eclipse.core.resources.IFile actual)
Compares and indicates if both given files are equals or not.
|
static void |
openFile(org.eclipse.core.resources.IFile file)
Opens the given file into a default editor
based on file nature.
|
static void |
showError(java.lang.String message,
java.lang.Exception execption)
Handles the given exception by displaying
it to user using eclipse status.
|
private static final java.lang.String CANNOT_OPEN_FILE
private static final java.lang.String COMMAND_ERROR
public static final org.eclipse.core.runtime.IProgressMonitor NULL_MONITOR
NullProgressMonitor
instance shared in order to avoid instance duplication.private EclipseUtils()
public static java.lang.String getCurrentUser()
public static void showError(java.lang.String message, java.lang.Exception execption)
message
- Error message that should be displayed.execption
- Error caught that should be logged.private static java.lang.String getContent(org.eclipse.core.resources.IFile file) throws org.eclipse.core.runtime.CoreException, java.io.IOException
String
of the given filefile
- File to retrieve content from.org.eclipse.core.runtime.CoreException
- If any error occurs while reading the file content.java.io.IOException
- If any error occurs while colsing file input stream.public static boolean isFileEquals(org.eclipse.core.resources.IFile expected, org.eclipse.core.resources.IFile actual) throws org.eclipse.core.runtime.CoreException, java.io.IOException
expected
- File that is containing expected content.actual
- File that is compared to the expected one.org.eclipse.core.runtime.CoreException
- If any error occurs while reading file content.java.io.IOException
public static org.eclipse.core.resources.IFolder getFolder(org.eclipse.core.resources.IProject project, java.lang.String path) throws org.eclipse.core.runtime.CoreException
NullProgressMonitor
before to be returned.project
- Project to retrieve folder from.path
- Project relative path of the folder to retrieve.org.eclipse.core.runtime.CoreException
- If any error occurs while creating folder when required.public static org.eclipse.core.resources.IFolder getFolder(org.eclipse.core.resources.IProject project, java.lang.String path, org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.CoreException
project
- Project to retrieve folder from.path
- Project relative path of the folder to retrieve.monitor
- Monitor instance to use when creating folder.org.eclipse.core.runtime.CoreException
- If any error occurs while creating folder when required.public static void executeCommand(java.lang.String commandId)
commandId
- Identifier of the command to execute.public static void openFile(org.eclipse.core.resources.IFile file)
file
- File to open in an editor.public static java.util.Optional<org.eclipse.core.resources.IFile> getCurrentFile()
Optional
reference.