Package org.eclipse.net4j.util.ui

# Class UIUtil

java.lang.Object
org.eclipse.net4j.util.ui.UIUtil

public final class UIUtil extends Object

Author:
  Eike Stepper

## Field Summary

Fields
Modifier and Type
Field
Description
`static final String`
`ERROR_LOG_ID`

## Method Summary

Modifier and Type
Method
Description
`static <T> T`
`adaptElement(ISelection selection, Class<T> type)`
Like `getElement(ISelection, Class)` except that it attempts to adapt `IAdaptable`s to the required `type`, if necessary.
`static <T> List<T>`
`adaptElements(ISelection selection, Class<T> type)`
Like `getElements(ISelection, Class)` except that it attempts to adapt `IAdaptable`s to the required `type`, if necessary.
`static void`
`addDecorationMargin(Control control)`
`static void`
`addDragSupport(StructuredViewer viewer)`
`static void`
`asyncExec(Runnable runnable)`
`static void`
`asyncExec(Display display, Runnable runnable)`
`static void`
`copyToClipboard(Display display, String text)`
`static GridData`
`createEmptyGridData()`
`static Composite`
`createGridComposite(Composite parent, int columns)`
`static GridData`
`createGridData()`
`static GridData`
`createGridData(boolean grabHorizontal, boolean grabVertical)`
`static GridData`
`createGridData(int horizontalSpan, int verticalSpan)`
`static GridLayout`
`createGridLayout(int columns)`
`static IPasswordCredentialsProvider`
`createInteractiveCredentialsProvider()`
`static void`
`dispose(Color color)`
`static void`
`dispose(Font font)`
`static void`
`dispose(Widget widget)`
`static Image`
`errorImage()`
`static void`
`exec(Display display, boolean sync, Runnable runnable)`
`static void`
`forEachChild(Composite composite, Consumer<Control> consumer)`
`static IWorkbenchPage`
`getActiveWorkbenchPage()`
`static IWorkbenchPart`
`getActiveWorkbenchPart()`
`static IWorkbenchWindow`
`getActiveWorkbenchWindow()`
`static Font`
`getBoldFont(Control control)`
`static Display`
`getDisplay()`
`static Object`
`getElement(ISelection selection)`
`static <T> T`
`getElement(ISelection selection, Class<T> type)`
`static Object`
`getElementIfOne(ISelection selection)`
`static List<Object>`
`getElements(ISelection selection)`
`static <T> List<T>`
`getElements(ISelection selection, Class<T> type)`
`static Font`
`getItalicFont(Control control)`
`static Shell`
`getShell()`
`static IWorkbench`
`getWorkbench()`
`static Color`
`grayColor()`
`static <T> T`
`initResource(Function<Display,T> initializer)`
`static boolean`
`isParent(Composite parent, Control controlToCheck)`
`static void`
`preserveViewerState(Viewer viewer, Runnable runnable)`
`static Color`
`redColor()`
`static void`
`refreshElement(StructuredViewer viewer, Object element, boolean updateLabels)`
`static void`
`refreshViewer(Viewer viewer)`
`static void`
`runWithProgress(IRunnableWithProgress runnable)`
`static void`
`selectReveal(Object object)`
`static void`
`setIndentation(Control control, int horizontalIndent, int verticalIndent)`
Adds indentation to the control.
`static void`
`setStatusBarMessage(String message, Image image)`
Shows a message in the StatusBar.
`static int`
`setValidationContext(Control control, ValidationContext context)`
`static void`
`syncExec(Runnable runnable)`
`static void`
`syncExec(Display display, Runnable runnable)`
`static void`
`updateElements(StructuredViewer viewer, Object element)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### ERROR_LOG_ID

public static final String ERROR_LOG_ID

Since:
  3.1
See Also:
  - Constant Field Values

## Method Details

### redColor

public static Color redColor()

Since:
  3.12

### grayColor

public static Color grayColor()

Since:
  3.12

### errorImage

public static Image errorImage()

Since:
  3.12

### copyToClipboard

public static void copyToClipboard(Display display, String text)

Since:
  3.1

### dispose

public static void dispose(Font font)

### dispose

public static void dispose(Color color)

### dispose

public static void dispose(Widget widget)

### getItalicFont

public static Font getItalicFont(Control control)

Since:
  3.3

### getBoldFont

public static Font getBoldFont(Control control)

### getDisplay

public static Display getDisplay()

### getShell

public static Shell getShell()

Since:
  3.5

### getWorkbench

public static IWorkbench getWorkbench()

Since:
  2.0

### getActiveWorkbenchWindow

public static IWorkbenchWindow getActiveWorkbenchWindow()

Since:
  2.0

### getActiveWorkbenchPage

public static IWorkbenchPage getActiveWorkbenchPage()

Since:
  2.0

### getActiveWorkbenchPart

public static IWorkbenchPart getActiveWorkbenchPart()

Since:
  2.0

### getElementIfOne

public static Object getElementIfOne(ISelection selection)

Since:
  3.0

### getElement

public static Object getElement(ISelection selection)

Since:
  2.0

### getElement

public static <T> T getElement(ISelection selection, Class<T> type)

Since:
  2.0

### getElements

public static List<Object> getElements(ISelection selection)

Since:
  3.5

### getElements

public static <T> List<T> getElements(ISelection selection, Class<T> type)

Since:
  2.0

### adaptElement

public static <T> T adaptElement(ISelection selection, Class<T> type)
Like `getElement(ISelection, Class)` except that it attempts to adapt `IAdaptable`s to the required `type`, if necessary.

Since:
  3.4

### adaptElements

public static <T> List<T> adaptElements(ISelection selection, Class<T> type)
Like `getElements(ISelection, Class)` except that it attempts to adapt `IAdaptable`s to the required `type`, if necessary.

Since:
  3.5

### setValidationContext

public static int setValidationContext(Control control, ValidationContext context)

Since:
  3.1

### createInteractiveCredentialsProvider

public static IPasswordCredentialsProvider createInteractiveCredentialsProvider()

### createGridComposite

public static Composite createGridComposite(Composite parent, int columns)

### createGridLayout

public static GridLayout createGridLayout(int columns)

### createGridData

public static GridData createGridData()

### createGridData

public static GridData createGridData(boolean grabHorizontal, boolean grabVertical)

### createGridData

public static GridData createGridData(int horizontalSpan, int verticalSpan)

Since:
  3.4

### createEmptyGridData

public static GridData createEmptyGridData()

Since:
  3.0

### addDecorationMargin

public static void addDecorationMargin(Control control)

### setIndentation

public static void setIndentation(Control control, int horizontalIndent, int verticalIndent)
Adds indentation to the control. if indent value is < 0, the control indentation is left unchanged.

Since:
  2.0

### initResource

public static <T> T initResource(Function<Display,T> initializer)

Since:
  3.12

### syncExec

public static void syncExec(Runnable runnable)

Since:
  3.5

### syncExec

public static void syncExec(Display display, Runnable runnable)

Since:
  3.5

### asyncExec

public static void asyncExec(Runnable runnable)

Since:
  3.9

### asyncExec

public static void asyncExec(Display display, Runnable runnable)

Since:
  3.9

### exec

public static void exec(Display display, boolean sync, Runnable runnable)

Since:
  3.9

### runWithProgress

public static void runWithProgress(IRunnableWithProgress runnable)

Since:
  3.3

### preserveViewerState

public static void preserveViewerState(Viewer viewer, Runnable runnable)

Since:
  3.3

### refreshViewer

public static void refreshViewer(Viewer viewer)

Since:
  2.0

### refreshElement

public static void refreshElement(StructuredViewer viewer, Object element, boolean updateLabels)

Since:
  3.3

### updateElements

public static void updateElements(StructuredViewer viewer, Object element)

Since:
  3.5

### setStatusBarMessage

public static void setStatusBarMessage(String message, Image image)
Shows a message in the StatusBar. Image can be omitted by passing a null parameter

Since:
  2.0

### addDragSupport

public static void addDragSupport(StructuredViewer viewer)

Since:
  3.5

### isParent

public static boolean isParent(Composite parent, Control controlToCheck)

Since:
  3.9

### forEachChild

public static void forEachChild(Composite composite, Consumer<Control> consumer)

Since:
  3.9

### selectReveal

public static void selectReveal(Object object)

Since:
  3.10