Module UI

Function Overview

convertSelection Converts selection to a consumable form. Table/Tree selections are transformed into Object[], Text selections into the selected String.
executeUI Run code in UI thread. Needed to interact with SWT elements. Might not be supported by some engines. Might be disabled by the user. Code will be executed synchronously and stall UI updates while executed.
exitApplication Close the application. On unsaved editors user will be asked to save before closing.
getActiveEditor Get the active editor instance.
getActiveView Get the active view instance.
getClipboard Get text data from the clipboard.
getSelection Get the current selection. If partID is provided, the selection of the given part is returned. Otherwise the selection of the current active part is returned.
getShell Get the workbench shell instance.
isUIThread Returns true when executed in the UI thread.
openDialog Show a generic dialog.
openEditor Alias for showEditor.
openView Alias for showView.
setClipboard Write text data to the clipboard.
showConfirmDialog Displays a confirmation dialog.
showEditor Opens a file in an editor.
showErrorDialog Displays an error dialog.
showInfoDialog Displays an info dialog. Needs UI to be available.
showInputDialog Displays an input dialog. Contains yes/no buttons. Needs UI to be available.
showMessageDialog Alias for showInfoDialog.
showQuestionDialog Displays a question dialog. Contains yes/no buttons. Needs UI to be available.
showView Opens a view by given Name or id. When name does not match any known view id we try to match it with a view title. When found the view is opened. If the view is already visible it will be given focus.
showWarningDialog Displays a warning dialog.

Functions

executeUI

java.lang.Object executeUI(java.lang.Object code)

Run code in UI thread. Needed to interact with SWT elements. Might not be supported by some engines. Might be disabled by the user. Code will be executed synchronously and stall UI updates while executed.

Parameter Type Description
code java.lang.Object code/object to execute

java.lang.Object ... execution result

isUIThread

boolean isUIThread()

Returns true when executed in the UI thread.

boolean ... true in UI thread

showInfoDialog

void showInfoDialog(java.lang.String message, java.lang.String title)

Displays an info dialog. Needs UI to be available.

showMessageDialog

Parameter Type Description
message java.lang.String dialog message
title java.lang.String dialog title

showQuestionDialog

boolean showQuestionDialog(java.lang.String message, java.lang.String title)

Displays a question dialog. Contains yes/no buttons. Needs UI to be available.

Parameter Type Description
message java.lang.String dialog message
title java.lang.String dialog title

boolean ... true when 'yes' was pressed, false otherwise

showInputDialog

java.lang.String showInputDialog(java.lang.String message, java.lang.String initialValue, java.lang.String title)

Displays an input dialog. Contains yes/no buttons. Needs UI to be available.

Parameter Type Description
message java.lang.String dialog message
initialValue java.lang.String default value used to populate input box
title java.lang.String dialog title

java.lang.String ... true when 'yes' was pressed, false otherwise

showConfirmDialog

boolean showConfirmDialog(java.lang.String message, java.lang.String title)

Displays a confirmation dialog.

Parameter Type Description
message java.lang.String dialog message
title java.lang.String dialog title

boolean ... true when accepted

showWarningDialog

void showWarningDialog(java.lang.String message, java.lang.String title)

Displays a warning dialog.

Parameter Type Description
message java.lang.String dialog message
title java.lang.String dialog title

showErrorDialog

void showErrorDialog(java.lang.String message, java.lang.String title)

Displays an error dialog.

Parameter Type Description
message java.lang.String dialog message
title java.lang.String dialog title

exitApplication

void exitApplication()

Close the application. On unsaved editors user will be asked to save before closing.

showView

org.eclipse.ui.IViewPart showView(java.lang.String name)

Opens a view by given Name or id. When name does not match any known view id we try to match it with a view title. When found the view is opened. If the view is already visible it will be given focus.

openView

Parameter Type Description
name java.lang.String name or id of viw to open

org.eclipse.ui.IViewPart ... view instance or null

showEditor

org.eclipse.ui.IEditorPart showEditor(java.lang.Object location)

Opens a file in an editor.

openEditor

Parameter Type Description
location java.lang.Object file location to open, either {@link IFile} or workspace file location

org.eclipse.ui.IEditorPart ... editor instance or null

getSelection

org.eclipse.jface.viewers.ISelection getSelection(java.lang.String name)

Get the current selection. If partID is provided, the selection of the given part is returned. Otherwise the selection of the current active part is returned.

Parameter Type Description
name java.lang.String name or ID of part to get selection from

org.eclipse.jface.viewers.ISelection ... current selection

convertSelection

java.lang.Object convertSelection(org.eclipse.jface.viewers.ISelection selection)

Converts selection to a consumable form. Table/Tree selections are transformed into Object[], Text selections into the selected String.

Parameter Type Description
selection org.eclipse.jface.viewers.ISelection selection to convert

java.lang.Object ... converted elements

openDialog

int openDialog(org.eclipse.jface.window.Window dialog)

Show a generic dialog.

Parameter Type Description
dialog org.eclipse.jface.window.Window dialog to display

int ... result of dialog.open() method

getShell

org.eclipse.swt.widgets.Shell getShell()

Get the workbench shell instance.

org.eclipse.swt.widgets.Shell ... shell

getActiveView

org.eclipse.ui.IWorkbenchPart getActiveView()

Get the active view instance.

org.eclipse.ui.IWorkbenchPart ... active view

getActiveEditor

org.eclipse.ui.IEditorPart getActiveEditor()

Get the active editor instance.

org.eclipse.ui.IEditorPart ... active editor

setClipboard

void setClipboard(java.lang.String data)

Write text data to the clipboard.

Parameter Type Description
data java.lang.String data to write to the clipboard

getClipboard

java.lang.Object getClipboard()

Get text data from the clipboard.

java.lang.Object ... clipboard text