# Class KeyAssistDialog

java.lang.Object
org.eclipse.jface.window.Window
org.eclipse.jface.dialogs.PopupDialog
org.eclipse.e4.ui.bindings.internal.KeyAssistDialog

All Implemented Interfaces:
  `IShellProvider`

public class KeyAssistDialog extends PopupDialog

A dialog displaying a list of key bindings. The dialog will execute a command if it is selected.

The methods on this class are not thread-safe and must be run from the UI thread.

Since:
  3.1

## Nested Class Summary

### Nested classes/interfaces inherited from class Window

`Window.IExceptionHandler`

## Field Summary

### Fields inherited from class PopupDialog

`HOVER_SHELLSTYLE, INFOPOPUP_SHELLSTYLE, INFOPOPUPRESIZE_SHELLSTYLE, POPUP_HORIZONTALSPACING, POPUP_IMG_MENU, POPUP_IMG_MENU_DISABLED, POPUP_MARGINHEIGHT, POPUP_MARGINWIDTH, POPUP_VERTICALSPACING`

### Fields inherited from class Window

`CANCEL, OK, resizeHasOccurred`

## Constructor Summary

Constructors
Constructor
Description
`KeyAssistDialog(IEclipseContext context, KeyBindingDispatcher associatedKeyboard)`
Constructs a new instance of `KeyAssistDialog`.

## Method Summary

Modifier and Type
Method
Description
`void`
`clearRememberedState()`
Clears out the remembered state of the key assist dialog.
`boolean`
`close()`
Closes this shell, but first remembers some state of the dialog.
`boolean`
`close(boolean rememberState)`
Closes this shell, but first remembers some state of the dialog.
`protected Control`
`createDialogArea(Composite parent)`
Creates the content area for the key assistant.
`protected Binding`
`getSelectedBinding()`
Returns the currently selected binding from the table if the table is not disposed
`boolean`
`isShowingBindings(Collection<Binding> bindings)`
Tests whether the key assist dialog is currently showing a set of bindings.
`int`
`open()`
Opens this dialog.
`int`
`open(Collection<Binding> bindings)`
Opens this dialog with the list of bindings for the user to select from.
`void`
`setParentShell(Shell newParentShell)`
Exposing this within the keys package.

### Methods inherited from class PopupDialog

`adjustBounds, applyBackgroundColor, applyForegroundColor, configureShell, createContents, createInfoTextArea, createTitleControl, createTitleMenuArea, fillDialogMenu, getBackground, getBackgroundColorExclusions, getDefaultLocation, getDefaultSize, getDialogSettings, getFocusControl, getForeground, getForegroundColorExclusions, getInitialLocation, getInitialSize, getPersistLocation, getPersistSize, hasInfoArea, hasTitleArea, saveDialogBounds, setInfoText, setTabOrder, setTitleText, showDialogMenu`

### Methods inherited from class Window

`canHandleShellCloseEvent, constrainShellSize, create, createShell, getConstrainedShellBounds, getContents, getDefaultImage, getDefaultImages, getDefaultOrientation, getLayout, getParentShell, getReturnCode, getShell, getShellListener, getShellStyle, getWindowManager, handleFontChange, handleShellCloseEvent, initializeBounds, setBlockOnOpen, setDefaultImage, setDefaultImages, setDefaultModalParent, setDefaultOrientation, setExceptionHandler, setReturnCode, setShellStyle, setWindowManager`

### Methods inherited from class Object

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

## Constructor Details

### KeyAssistDialog

public KeyAssistDialog(IEclipseContext context, KeyBindingDispatcher associatedKeyboard)
Constructs a new instance of `KeyAssistDialog`. When the dialog is first constructed, it contains no widgets. The dialog is first created with no parent. If a parent is required, call `setParentShell()`. Also, between uses, it might be necessary to call `setParentShell()` as well.

Parameters:
  `context` - The context in which this dialog is created; must not be `null`.
  `associatedKeyboard` - The key binding listener for the workbench; must not be `null`.

## Method Details

### clearRememberedState

public void clearRememberedState()
Clears out the remembered state of the key assist dialog. This includes its width, as well as the selected binding.

### close

public boolean close()
Closes this shell, but first remembers some state of the dialog. This way it will have a response if asked to open the dialog again or if asked to open the keys preference page. This does not remember the internal state.

Overrides:
  `close` in class `PopupDialog`
Returns:
  Whether the shell was already closed.

### close

public boolean close(boolean rememberState)
Closes this shell, but first remembers some state of the dialog. This way it will have a response if asked to open the dialog again or if asked to open the keys preference page.

Parameters:
  `rememberState` - Whether the internal state should be remembered.
Returns:
  Whether the shell was already closed.

### createDialogArea

protected Control createDialogArea(Composite parent)
Creates the content area for the key assistant. This creates a table and places it inside the composite. The composite will contain a list of all the key bindings.

Overrides:
  `createDialogArea` in class `PopupDialog`
Parameters:
  `parent` - The parent composite to contain the dialog area; must not be `null`.
Returns:
  the dialog area control

### open

public int open()
Opens this dialog. This method can be called multiple times on the same dialog. This only opens the dialog if there is no remembered state; if there is remembered state, then it tries to open the preference page instead.

Overrides:
  `open` in class `PopupDialog`
Returns:
  The return code from this dialog.
See Also:
  - `Window.open()`

### open

public int open(Collection<Binding> bindings)
Opens this dialog with the list of bindings for the user to select from.

Returns:
  The return code from this dialog.
Since:
  3.3

### setParentShell

public void setParentShell(Shell newParentShell)
Exposing this within the keys package.

Overrides:
  `setParentShell` in class `Window`
Parameters:
  `newParentShell` - The new parent shell; this value may be `null` if there is to be no parent.

### isShowingBindings

public boolean isShowingBindings(Collection<Binding> bindings)
Tests whether the key assist dialog is currently showing a set of bindings.

Parameters:
  `bindings` - A set of conflicts or partial matches.
Returns:
  Whether the key assist dialog shows the bindings.

### getSelectedBinding

protected Binding getSelectedBinding()
Returns the currently selected binding from the table if the table is not disposed

Returns:
  the currently selected binding or `null`