public class UIModule extends AbstractScriptModule
Modifier and Type | Field and Description |
---|---|
static String |
MODULE_ID
Module identifier.
|
Constructor and Description |
---|
UIModule() |
Modifier and Type | Method and Description |
---|---|
void |
clearConsole()
Clear the script console.
|
static void |
closeView(String name,
String secondaryID)
Close a dedicated view.
|
static Object |
convertSelection(ISelection selection)
Converts selection to a consumable form.
|
Object |
executeUI(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 Object |
getClipboard()
Get text data from the clipboard.
|
static ISelection |
getSelection(String name)
Get the current selection.
|
static Shell |
getShell()
Get the workbench shell instance.
|
static boolean |
isUIThread()
Returns
true when executed in the UI thread. |
static void |
maximizeView(String name)
Maximize a dedicated view.
|
static void |
minimizeView(String name)
Minimize a dedicated view.
|
static int |
openDialog(Window dialog)
Show a generic dialog.
|
static void |
setClipboard(String data)
Write text data to the clipboard.
|
static boolean |
showConfirmDialog(String message,
String title)
Displays a confirmation dialog.
|
static IEditorPart |
showEditor(IFile file)
Opens a file in an editor.
|
IEditorPart |
showEditor(Object location)
Opens a file in an editor.
|
static void |
showErrorDialog(String message,
String title)
Displays an error dialog.
|
static void |
showInfoDialog(String message,
String title)
Displays an info dialog.
|
static String |
showInputDialog(String message,
String initialValue,
String title)
Displays an input dialog.
|
static boolean |
showQuestionDialog(String message,
String title)
Displays a question dialog.
|
static IViewPart |
showView(String name)
Opens a view by given Name or id.
|
static IViewPart |
showView(String name,
String secondaryId,
int mode)
Shows a view in this page with the given id and secondary id.
|
static void |
showWarningDialog(String message,
String title)
Displays a warning dialog.
|
getScriptEngine, initialize
public static final String MODULE_ID
public Object executeUI(Object code)
code
- code/object to executepublic static boolean isUIThread()
true
when executed in the UI thread.true
in UI threadpublic static void showInfoDialog(String message, @ScriptParameter(defaultValue="Info") String title)
message
- dialog messagetitle
- dialog titlepublic static boolean showQuestionDialog(String message, @ScriptParameter(defaultValue="Question") String title)
message
- dialog messagetitle
- dialog titletrue
when 'yes' was pressed, false
otherwisepublic static String showInputDialog(String message, @ScriptParameter(defaultValue="") String initialValue, @ScriptParameter(defaultValue="Information request") String title)
message
- dialog messageinitialValue
- default value used to populate input boxtitle
- dialog titletrue
when 'yes' was pressed, false
otherwisepublic static boolean showConfirmDialog(String message, @ScriptParameter(defaultValue="Confirmation") String title)
message
- dialog messagetitle
- dialog titletrue
when acceptedpublic static void showWarningDialog(String message, @ScriptParameter(defaultValue="Warning") String title)
message
- dialog messagetitle
- dialog titlepublic static void showErrorDialog(String message, @ScriptParameter(defaultValue="Error") String title)
message
- dialog messagetitle
- dialog titlepublic static void exitApplication()
public static IViewPart showView(String name) throws Throwable
name
- name or id of view to opennull
Throwable
- when view cannot be createdpublic static IViewPart showView(String name, @ScriptParameter(defaultValue="org.eclipse.ease.modules.ScriptParameter.null") String secondaryId, @ScriptParameter(defaultValue="1") int mode) throws 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
Throwable
- when the view cannot be openedIllegalArgumentException
- when the supplied mode is not validpublic IEditorPart showEditor(Object location) throws Throwable
public static IEditorPart showEditor(IFile file) throws Throwable
file
- file location to opennull
Throwable
- when we cannot open the editorpublic static ISelection getSelection(@ScriptParameter(defaultValue="org.eclipse.ease.modules.ScriptParameter.null") String name)
name
- name or ID of part to get selection frompublic static 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(String data)
data
- data to write to the clipboardpublic static Object getClipboard()
public void clearConsole()
public static void maximizeView(String name) throws Throwable
name
- visible name or id of view to maximizeThrowable
- when view cannot be openedpublic static void minimizeView(String name) throws Throwable
name
- name or id of view to minimizeThrowable
- when view cannot be openedpublic static void closeView(String name, @ScriptParameter(defaultValue="org.eclipse.ease.modules.ScriptParameter.null") String secondaryID)
name
- visible name or id of view to closesecondaryID
- secondary ID of view to close