public class UIModule extends AbstractScriptModule
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
MODULE_ID
Module identifier.
|
Constructor and Description |
---|
UIModule() |
Modifier and Type | Method and Description |
---|---|
void |
clearConsole()
Clear the script console.
|
static void |
closeView(java.lang.String name,
java.lang.String secondaryID)
Close a dedicated view.
|
static java.lang.Object |
convertSelection(ISelection selection)
Converts selection to a consumable form.
|
Color |
createColor(int red,
int green,
int blue)
Constructs a new color given the desired red, green and blue values expressed as ints in the range 0 to 255 (where 0 is black and 255 is full
brightness).
|
java.lang.Object |
executeUI(java.lang.Object code)
Run code in UI thread.
|
static void |
exitApplication()
Close the application.
|
static IEditorPart |
getActiveEditor()
Get the active editor instance.
|
static IWorkbenchPart |
getActiveView()
Get the active view instance.
|
static java.lang.Object |
getClipboard()
Get text data from the clipboard.
|
ScriptConsole |
getConsole()
Get the script console for the current engine.
|
static ISelection |
getSelection(java.lang.String name)
Get the current selection.
|
static Shell |
getShell()
Get the workbench shell instance.
|
static boolean |
isHeadless()
Verify if we are running in headless mode.
|
static boolean |
isUIThread()
Returns
true when executed in the UI thread. |
static void |
maximizeView(java.lang.String name)
Maximize a dedicated view.
|
static void |
minimizeView(java.lang.String name)
Minimize a dedicated view.
|
static int |
openDialog(Window dialog)
Show a generic dialog.
|
static void |
setClipboard(java.lang.String data)
Write text data to the clipboard.
|
boolean |
showConfirmDialog(java.lang.String message,
java.lang.String title)
Displays a confirmation dialog.
|
static IEditorPart |
showEditor(IFile file)
Opens a file in an editor.
|
IEditorPart |
showEditor(java.lang.Object location)
Opens a file in an editor.
|
void |
showErrorDialog(java.lang.String message,
java.lang.String title)
Displays an error dialog.
|
void |
showInfoDialog(java.lang.String message,
java.lang.String title)
Displays an info dialog.
|
java.lang.String |
showInputDialog(java.lang.String message,
java.lang.String initialValue,
java.lang.String title)
Displays an input dialog.
|
boolean |
showQuestionDialog(java.lang.String message,
java.lang.String title)
Displays a question dialog.
|
java.lang.Object |
showSelectionDialog(java.lang.Object[] elements,
java.lang.String message,
java.lang.String title)
Displays a selection dialog.
|
static IViewPart |
showView(java.lang.String name)
Opens a view by given Name or id.
|
static IViewPart |
showView(java.lang.String name,
java.lang.String secondaryId,
int mode)
Shows a view in this page with the given id and secondary id.
|
void |
showWarningDialog(java.lang.String message,
java.lang.String title)
Displays a warning dialog.
|
static void |
shutdown()
Shut down the application.
|
getScriptEngine, initialize
public static final java.lang.String MODULE_ID
public java.lang.Object executeUI(java.lang.Object code)
code
- code/object to executepublic static boolean isUIThread()
true
when executed in the UI thread.true
in UI threadpublic void showInfoDialog(java.lang.String message, @ScriptParameter(defaultValue="Info") java.lang.String title)
message
- dialog messagetitle
- dialog titlepublic boolean showQuestionDialog(java.lang.String message, @ScriptParameter(defaultValue="Question") java.lang.String title)
message
- dialog messagetitle
- dialog titletrue
when 'yes' was pressed, false
otherwisepublic java.lang.String showInputDialog(java.lang.String message, @ScriptParameter(defaultValue="") java.lang.String initialValue, @ScriptParameter(defaultValue="Information request") java.lang.String title)
message
- dialog messageinitialValue
- default value used to populate input boxtitle
- dialog titlenull
in case the user aborted/closed the dialogpublic java.lang.Object showSelectionDialog(java.lang.Object[] elements, @ScriptParameter(defaultValue="") java.lang.String message, @ScriptParameter(defaultValue="Selection request") java.lang.String title)
elements
- array of elements to choose frommessage
- dialog messagetitle
- dialog titlenull
in case the user aborted/closed the dialogpublic boolean showConfirmDialog(java.lang.String message, @ScriptParameter(defaultValue="Confirmation") java.lang.String title)
message
- dialog messagetitle
- dialog titletrue
when acceptedpublic void showWarningDialog(java.lang.String message, @ScriptParameter(defaultValue="Warning") java.lang.String title)
message
- dialog messagetitle
- dialog titlepublic void showErrorDialog(java.lang.String message, @ScriptParameter(defaultValue="Error") java.lang.String title)
message
- dialog messagetitle
- dialog titlepublic static void exitApplication()
public static IViewPart showView(java.lang.String name) throws java.lang.Throwable
name
- name or id of view to opennull
java.lang.Throwable
- when view cannot be createdpublic static IViewPart showView(java.lang.String name, @ScriptParameter(defaultValue="org.eclipse.ease.modules.ScriptParameter.null") java.lang.String secondaryId, @ScriptParameter(defaultValue="1") int mode) throws java.lang.Throwable
VIEW_ACTIVATE
is supplied, the view is given focus. If VIEW_VISIBLE
is supplied, then it is made visible but not given focus.
Finally, if VIEW_CREATE
is supplied the view is created and will only be made visible if it is not created in a folder that already contains
visible views.
This allows multiple instances of a particular view to be created. They are disambiguated using the secondary id. If a secondary id is given, the view must allow multiple instances by having specified allowMultiple="true" in its extension.
name
- either the id of the view extension to use or the visible name of the view (tab title)secondaryId
- the secondary id to use, or null
for no secondary idmode
- the activation mode. Must be #VIEW_ACTIVATE
, #VIEW_VISIBLE
or #VIEW_CREATE
, Default is #VIEW_ACTIVATE
java.lang.Throwable
- when the view cannot be openedjava.lang.IllegalArgumentException
- when the supplied mode is not validpublic IEditorPart showEditor(java.lang.Object location) throws java.lang.Throwable
location
- file location to open, either IFile
or workspace file locationnull
java.lang.Throwable
- when we cannot open the editorpublic static IEditorPart showEditor(IFile file) throws java.lang.Throwable
file
- file location to opennull
java.lang.Throwable
- when we cannot open the editorpublic static ISelection getSelection(@ScriptParameter(defaultValue="org.eclipse.ease.modules.ScriptParameter.null") java.lang.String name)
name
- name or ID of part to get selection frompublic static java.lang.Object convertSelection(ISelection selection)
selection
- selection to convertpublic static int openDialog(Window dialog)
dialog
- dialog to displaypublic static Shell getShell()
public static IWorkbenchPart getActiveView()
public static IEditorPart getActiveEditor()
public static void setClipboard(java.lang.String data)
data
- data to write to the clipboardpublic static java.lang.Object getClipboard()
public void clearConsole()
public ScriptConsole getConsole()
null
public static void maximizeView(java.lang.String name) throws java.lang.Throwable
name
- visible name or id of view to maximizejava.lang.Throwable
- when view cannot be openedpublic static void minimizeView(java.lang.String name) throws java.lang.Throwable
name
- name or id of view to minimizejava.lang.Throwable
- when view cannot be openedpublic static void closeView(java.lang.String name, @ScriptParameter(defaultValue="org.eclipse.ease.modules.ScriptParameter.null") java.lang.String secondaryID)
name
- visible name or id of view to closesecondaryID
- secondary ID of view to closepublic static void shutdown()
public static boolean isHeadless()
true
if we are running without UIpublic Color createColor(int red, int green, int blue)
You must dispose the color when it is no longer required.
red
- the amount of red in the colorgreen
- the amount of green in the colorblue
- the amount of blue in the colorjava.lang.IllegalArgumentException
-