|
org.eclipse.jface.dialogs
Class MessageDialogWithToggle
java.lang.Object
org.eclipse.jface.window.Window
org.eclipse.jface.dialogs.Dialog
org.eclipse.jface.dialogs.IconAndMessageDialog
org.eclipse.jface.dialogs.MessageDialog
org.eclipse.jface.dialogs.MessageDialogWithToggle
-
All Implemented Interfaces:
-
IShellProvider
-
public class MessageDialogWithToggle
- extends
MessageDialog
A message dialog which also allows the user to adjust a toggle setting. If a
preference store is provided and the user selects the toggle, then the user's
answer (yes/ok or no) will be persisted in the store. If no store is
provided, then this information can be queried after the dialog closes.
This type of dialog should be used whenever you want to user to be able to
avoid being prompted in the future. It is strongly
recommended that a cancel option be provided, so that the user has the option
of making the decision at a later point in time. The semantic for a cancel
button should be to cancel the operation (if it has not yet started), or stop
the operation (if it has already started).
It is the responsibility of the developer to provide a mechanism for the user
to change this preference at some later point in time (e.g., through a
preference page).
-
Since:
- 3.0
Field Summary
|
static
String
|
ALWAYS
The value of the preference when the user has asked that the answer to
the question always be "okay" or "yes". |
static
String
|
NEVER
The value of the preference when the user has asked that the answer to
the question always be "no". |
static
String
|
PROMPT
The value of the preference when the user wishes to prompted for an
answer every time the question is to be asked. |
Fields inherited from class org.eclipse.jface.dialogs.
Dialog
|
blockedHandler,
buttonBar,
DIALOG_DEFAULT_BOUNDS,
DIALOG_PERSISTLOCATION,
DIALOG_PERSISTSIZE,
dialogArea,
DLG_IMG_ERROR,
DLG_IMG_HELP,
DLG_IMG_INFO,
DLG_IMG_MESSAGE_ERROR,
DLG_IMG_MESSAGE_INFO,
DLG_IMG_MESSAGE_WARNING,
DLG_IMG_QUESTION,
DLG_IMG_WARNING,
ELLIPSIS
|
Fields inherited from class org.eclipse.jface.window.
Window
|
CANCEL,
OK
|
Method Summary
|
protected void
|
buttonPressed
(int buttonId)
Notifies that this dialog's button with the given id has been pressed. |
protected void
|
createButtonsForButtonBar
(
Composite parent)
Adds buttons to this dialog's button bar. |
protected
Control
|
createDialogArea
(
Composite parent)
This implementation of the Dialog framework method creates
and lays out a composite and calls createMessageArea and
createCustomArea to populate it. |
protected
Button
|
createToggleButton
(
Composite parent)
Creates a toggle button without any text or state. |
String
|
getPrefKey
()
An accessor for the current key of the toggle preference. |
IPreferenceStore
|
getPrefStore
()
An accessor for the current preference store for this dialog. |
protected
Button
|
getToggleButton
()
Returns the toggle button. |
boolean
|
getToggleState
()
Returns the toggle state. |
static
MessageDialogWithToggle
|
open
(int kind,
Shell parent,
String title,
String message,
String toggleMessage,
boolean toggleState,
IPreferenceStore store,
String key,
int style)
Convenience method to open a simple dialog as specified by the kind flag,
with a "don't show again' toggle. |
static
MessageDialogWithToggle
|
openError
(
Shell parent,
String title,
String message,
String toggleMessage,
boolean toggleState,
IPreferenceStore store,
String key)
Convenience method to open a standard error dialog. |
static
MessageDialogWithToggle
|
openInformation
(
Shell parent,
String title,
String message,
String toggleMessage,
boolean toggleState,
IPreferenceStore store,
String key)
Convenience method to open a standard information dialog. |
static
MessageDialogWithToggle
|
openOkCancelConfirm
(
Shell parent,
String title,
String message,
String toggleMessage,
boolean toggleState,
IPreferenceStore store,
String key)
Convenience method to open a simple confirm (OK/Cancel) dialog. |
static
MessageDialogWithToggle
|
openWarning
(
Shell parent,
String title,
String message,
String toggleMessage,
boolean toggleState,
IPreferenceStore store,
String key)
Convenience method to open a standard warning dialog. |
static
MessageDialogWithToggle
|
openYesNoCancelQuestion
(
Shell parent,
String title,
String message,
String toggleMessage,
boolean toggleState,
IPreferenceStore store,
String key)
Convenience method to open a simple question Yes/No/Cancel dialog. |
static
MessageDialogWithToggle
|
openYesNoQuestion
(
Shell parent,
String title,
String message,
String toggleMessage,
boolean toggleState,
IPreferenceStore store,
String key)
Convenience method to open a simple Yes/No question dialog. |
void
|
setPrefKey
(
String prefKey)
A mutator for the key of the preference to be modified by the toggle
button. |
void
|
setPrefStore
(
IPreferenceStore prefStore)
A mutator for the preference store to be modified by the toggle button. |
protected void
|
setToggleButton
(
Button button)
A mutator for the button providing the toggle option. |
protected void
|
setToggleMessage
(
String message)
A mutator for the text on the toggle button. |
void
|
setToggleState
(boolean toggleState)
A mutator for the state of the toggle button. |
Methods inherited from class org.eclipse.jface.dialogs.
MessageDialog
|
configureShell,
createButton,
createCustomArea,
customShouldTakeFocus,
getButton,
getButtonLabels,
getDefaultButtonIndex,
getImage,
getMinimumMessageWidth,
handleShellCloseEvent,
open,
open,
openConfirm,
openError,
openInformation,
openQuestion,
openWarning,
setButtonLabels,
setButtons
|
Methods inherited from class org.eclipse.jface.dialogs.
Dialog
|
applyDialogFont,
cancelPressed,
close,
convertHeightInCharsToPixels,
convertHeightInCharsToPixels,
convertHorizontalDLUsToPixels,
convertHorizontalDLUsToPixels,
convertVerticalDLUsToPixels,
convertVerticalDLUsToPixels,
convertWidthInCharsToPixels,
convertWidthInCharsToPixels,
create,
dialogFontIsDefault,
getBlockedHandler,
getButtonBar,
getCancelButton,
getDialogArea,
getDialogBoundsSettings,
getDialogBoundsStrategy,
getImage,
getInitialLocation,
getInitialSize,
getOKButton,
initializeBounds,
initializeDialogUnits,
isResizable,
okPressed,
setBlockedHandler,
setButtonLayoutData,
setButtonLayoutFormData,
shortenText
|
Methods inherited from class org.eclipse.jface.window.
Window
|
canHandleShellCloseEvent,
constrainShellSize,
createShell,
getConstrainedShellBounds,
getContents,
getDefaultImage,
getDefaultImages,
getDefaultOrientation,
getLayout,
getParentShell,
getReturnCode,
getShell,
getShellListener,
getShellStyle,
getWindowManager,
handleFontChange,
setBlockOnOpen,
setDefaultImage,
setDefaultImages,
setDefaultModalParent,
setDefaultOrientation,
setExceptionHandler,
setParentShell,
setReturnCode,
setShellStyle,
setWindowManager
|
Methods inherited from class java.lang.
Object
|
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait
|
ALWAYS
public static final
String ALWAYS
- The value of the preference when the user has asked that the answer to
the question always be "okay" or "yes".
-
See Also:
-
Constant Field Values
NEVER
public static final
String NEVER
- The value of the preference when the user has asked that the answer to
the question always be "no".
-
See Also:
-
Constant Field Values
PROMPT
public static final
String PROMPT
- The value of the preference when the user wishes to prompted for an
answer every time the question is to be asked.
-
See Also:
-
Constant Field Values
MessageDialogWithToggle
public MessageDialogWithToggle(
Shell parentShell,
String dialogTitle,
Image image,
String message,
int dialogImageType,
String[] dialogButtonLabels,
int defaultIndex,
String toggleMessage,
boolean toggleState)
- Creates a message dialog with a toggle. See the superclass constructor
for info on the other parameters.
-
Parameters:
-
parentShell - the parent shell -
dialogTitle - the dialog title, or null if none -
image - the dialog title image, or null if none -
message - the dialog message -
dialogImageType - one of the following values:
-
MessageDialog.NONE for a dialog with no
image
-
MessageDialog.ERROR for a dialog with an
error image
-
MessageDialog.INFORMATION for a dialog
with an information image
-
MessageDialog.QUESTION for a dialog with a
question image
-
MessageDialog.WARNING for a dialog with a
warning image
-
dialogButtonLabels - an array of labels for the buttons in the button bar -
defaultIndex - the index in the button label array of the default button -
toggleMessage - the message for the toggle control, or null for
the default message -
toggleState - the initial state for the toggle
open
public static
MessageDialogWithToggle open(int kind,
Shell parent,
String title,
String message,
String toggleMessage,
boolean toggleState,
IPreferenceStore store,
String key,
int style)
- Convenience method to open a simple dialog as specified by the
kind flag,
with a "don't show again' toggle.
-
-
Parameters:
-
kind - the kind of dialog to open, one of
MessageDialog.ERROR ,
MessageDialog.INFORMATION ,
MessageDialog.QUESTION ,
MessageDialog.WARNING ,
MessageDialog.CONFIRM , or {#QUESTION_WITH_CANCEL}. -
parent - the parent shell of the dialog, or null if none -
title - the dialog's title, or null if none -
message - the message -
toggleMessage - the message for the toggle control, or null for
the default message -
toggleState - the initial state for the toggle -
store - the IPreference store in which the user's preference should be
persisted; null if you don't want it persisted
automatically. -
key - the key to use when persisting the user's preference;
null if you don't want it persisted. -
style -
SWT.NONE for a default dialog, or
SWT.SHEET for
a dialog with sheet behavior
-
Returns:
- the dialog, after being closed by the user, which the client can
only call
getReturnCode() or
getToggleState()
-
Since:
- 3.5
openError
public static
MessageDialogWithToggle openError(
Shell parent,
String title,
String message,
String toggleMessage,
boolean toggleState,
IPreferenceStore store,
String key)
- Convenience method to open a standard error dialog.
-
-
Parameters:
-
parent - the parent shell of the dialog, or null if none -
title - the dialog's title, or null if none -
message - the message -
toggleMessage - the message for the toggle control, or null for
the default message -
toggleState - the initial state for the toggle -
store - the IPreference store in which the user's preference should be
persisted; null if you don't want it persisted
automatically. -
key - the key to use when persisting the user's preference;
null if you don't want it persisted.
-
Returns:
- the dialog, after being closed by the user, which the client can
only call
getReturnCode() or
getToggleState()
openInformation
public static
MessageDialogWithToggle openInformation(
Shell parent,
String title,
String message,
String toggleMessage,
boolean toggleState,
IPreferenceStore store,
String key)
- Convenience method to open a standard information dialog.
-
-
Parameters:
-
parent - the parent shell of the dialog, or null if none -
title - the dialog's title, or null if none -
message - the message -
toggleMessage - the message for the toggle control, or null for
the default message -
toggleState - the initial state for the toggle -
store - the IPreference store in which the user's preference should be
persisted; null if you don't want it persisted
automatically. -
key - the key to use when persisting the user's preference;
null if you don't want it persisted.
-
Returns:
- the dialog, after being closed by the user, which the client can
only call
getReturnCode() or
getToggleState()
openOkCancelConfirm
public static
MessageDialogWithToggle openOkCancelConfirm(
Shell parent,
String title,
String message,
String toggleMessage,
boolean toggleState,
IPreferenceStore store,
String key)
- Convenience method to open a simple confirm (OK/Cancel) dialog.
-
-
Parameters:
-
parent - the parent shell of the dialog, or null if none -
title - the dialog's title, or null if none -
message - the message -
toggleMessage - the message for the toggle control, or null for
the default message -
toggleState - the initial state for the toggle -
store - the IPreference store in which the user's preference should be
persisted; null if you don't want it persisted
automatically. -
key - the key to use when persisting the user's preference;
null if you don't want it persisted.
-
Returns:
- the dialog, after being closed by the user, which the client can
only call
getReturnCode() or
getToggleState()
openWarning
public static
MessageDialogWithToggle openWarning(
Shell parent,
String title,
String message,
String toggleMessage,
boolean toggleState,
IPreferenceStore store,
String key)
- Convenience method to open a standard warning dialog.
-
-
Parameters:
-
parent - the parent shell of the dialog, or null if none -
title - the dialog's title, or null if none -
message - the message -
toggleMessage - the message for the toggle control, or null for
the default message -
toggleState - the initial state for the toggle -
store - the IPreference store in which the user's preference should be
persisted; null if you don't want it persisted
automatically. -
key - the key to use when persisting the user's preference;
null if you don't want it persisted.
-
Returns:
- the dialog, after being closed by the user, which the client can
only call
getReturnCode() or
getToggleState()
openYesNoCancelQuestion
public static
MessageDialogWithToggle openYesNoCancelQuestion(
Shell parent,
String title,
String message,
String toggleMessage,
boolean toggleState,
IPreferenceStore store,
String key)
- Convenience method to open a simple question Yes/No/Cancel dialog.
-
-
Parameters:
-
parent - the parent shell of the dialog, or null if none -
title - the dialog's title, or null if none -
message - the message -
toggleMessage - the message for the toggle control, or null for
the default message -
toggleState - the initial state for the toggle -
store - the IPreference store in which the user's preference should be
persisted; null if you don't want it persisted
automatically. -
key - the key to use when persisting the user's preference;
null if you don't want it persisted.
-
Returns:
- the dialog, after being closed by the user, which the client can
only call
getReturnCode() or
getToggleState()
openYesNoQuestion
public static
MessageDialogWithToggle openYesNoQuestion(
Shell parent,
String title,
String message,
String toggleMessage,
boolean toggleState,
IPreferenceStore store,
String key)
- Convenience method to open a simple Yes/No question dialog.
-
-
Parameters:
-
parent - the parent shell of the dialog, or null if none -
title - the dialog's title, or null if none -
message - the message -
toggleMessage - the message for the toggle control, or null for
the default message -
toggleState - the initial state for the toggle -
store - the IPreference store in which the user's preference should be
persisted; null if you don't want it persisted
automatically. -
key - the key to use when persisting the user's preference;
null if you don't want it persisted.
-
Returns:
- the dialog, after being closed by the user, which the client can
only call
getReturnCode() or
getToggleState()
buttonPressed
protected void buttonPressed(int buttonId)
-
Description copied from class:
Dialog
- Notifies that this dialog's button with the given id has been pressed.
The Dialog implementation of this framework method calls
okPressed if the ok button is the pressed, and
cancelPressed if the cancel button is the pressed. All
other button presses are ignored. Subclasses may override to handle other
buttons, but should call super.buttonPressed if the
default handling of the ok and cancel buttons is desired.
-
-
Overrides:
-
buttonPressed
in class
MessageDialog
-
-
Parameters:
-
buttonId - the id of the button that was pressed (see
IDialogConstants.*_ID constants) -
See Also:
-
Dialog.buttonPressed(int)
createButtonsForButtonBar
protected void createButtonsForButtonBar(
Composite parent)
-
Description copied from class:
Dialog
- Adds buttons to this dialog's button bar.
The Dialog implementation of this framework method adds
standard ok and cancel buttons using the createButton
framework method. These standard buttons will be accessible from
getCancelButton , and getOKButton .
Subclasses may override.
-
-
Overrides:
-
createButtonsForButtonBar
in class
MessageDialog
-
-
Parameters:
-
parent - the button bar composite -
See Also:
-
Dialog.createButtonBar(Composite)
createDialogArea
protected
Control createDialogArea(
Composite parent)
-
Description copied from class:
MessageDialog
- This implementation of the
Dialog framework method creates
and lays out a composite and calls createMessageArea and
createCustomArea to populate it. Subclasses should
override createCustomArea to add contents below the
message.
-
-
Overrides:
-
createDialogArea
in class
MessageDialog
-
-
Parameters:
-
parent - the parent composite to contain the dialog area
-
Returns:
- the dialog area control
-
See Also:
-
Dialog.createDialogArea(Composite)
createToggleButton
protected
Button createToggleButton(
Composite parent)
- Creates a toggle button without any text or state. The text and state
will be created by
createDialogArea .
-
-
Parameters:
-
parent - The composite in which the toggle button should be placed;
must not be null .
-
Returns:
- The added toggle button; never
null .
getToggleButton
protected
Button getToggleButton()
- Returns the toggle button.
-
-
Returns:
- the toggle button
getPrefStore
public
IPreferenceStore getPrefStore()
- An accessor for the current preference store for this dialog.
-
-
Returns:
- The preference store; this value may be
null if no
preference is being used.
getPrefKey
public
String getPrefKey()
- An accessor for the current key of the toggle preference.
-
-
Returns:
- The preference key; this value may be
null if no
preference is being used.
getToggleState
public boolean getToggleState()
- Returns the toggle state. This can be called even after the dialog is
closed.
-
-
Returns:
-
true if the toggle button is checked,
false if not
setPrefKey
public void setPrefKey(
String prefKey)
- A mutator for the key of the preference to be modified by the toggle
button.
-
-
Parameters:
-
prefKey - The prefKey to set. If this value is null ,
then no preference will be modified.
setPrefStore
public void setPrefStore(
IPreferenceStore prefStore)
- A mutator for the preference store to be modified by the toggle button.
-
-
Parameters:
-
prefStore - The prefStore to set. If this value is null ,
then no preference will be modified.
setToggleButton
protected void setToggleButton(
Button button)
- A mutator for the button providing the toggle option. If the button
exists, then it will automatically get the text set to the current toggle
message, and its selection state set to the current selection state.
-
-
Parameters:
-
button - The button to use; must not be null .
setToggleMessage
protected void setToggleMessage(
String message)
- A mutator for the text on the toggle button. The button will
automatically get updated with the new text, if it exists.
-
-
Parameters:
-
message - The new text of the toggle button; if it is null ,
then used the default toggle message.
setToggleState
public void setToggleState(boolean toggleState)
- A mutator for the state of the toggle button. This method will update the
button, if it exists.
-
-
Parameters:
-
toggleState - The desired state of the toggle button (true
means the toggle should be selected).
Guidelines for using Eclipse APIs.
Copyright (c) Eclipse contributors and others 2000, 2008. All rights reserved.
|
|