Class NotifyDescriptor
java.lang.Object
org.openide.NotifyDescriptor
- Direct Known Subclasses:
DialogDescriptor, NotifyDescriptor.ComposedInput, NotifyDescriptor.Confirmation, NotifyDescriptor.InputLine, NotifyDescriptor.Message, NotifyDescriptor.QuickPick
This class provides a description of a user notification to be displayed.
Simple example of usage:
NotifyDescriptor d =
new NotifyDescriptor.Message("Hello...", NotifyDescriptor.INFORMATION_MESSAGE);
DialogDisplayer.getDefault().notify(d);
or to get a result:
NotifyDescriptor d =
new NotifyDescriptor.Confirmation("Really do this?!", "Dialog Title",
NotifyDescriptor.OK_CANCEL_OPTION);
if (DialogDisplayer.getDefault().notify(d) == NotifyDescriptor.OK_OPTION) {
// really do it...
}
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classNotification providing a composed input of multiple chained selection lists and/or input lines.static classProvides a description of a possible action and requests confirmation from the user before proceeding.static final classDeprecated.No longer used.static classNotification providing for a line of text input.static classProvides information about the results of a command.static final classNotification providing a password input.static final classNotification providing a selection list allowing multiple selections. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ObjectReturn value if CANCEL is chosen.static final ObjectReturn value if user closes the window without pressing any button.static final intOption type used by default.static final intMessage type for error messages.static final intMessage type for information messages.static final ObjectReturn value if NO is chosen.static final intOption type used for cancellable confirmations.static final ObjectReturn value if OK is chosen.static final intPlain message type using no icon.static final StringName of property for the detail message reported.static final StringName of property for the error message at the bottom of the wizard.static final StringName of property for the error message at the bottom of the wizard.static final StringName of property for the message to be displayed.static final StringName of property for the type of message to use.static final StringName of property for toggling the ESC key and title frame button closing.static final StringName of property for the style of options available.static final StringName of property for the exact list of options.static final StringName of property for the dialog title.static final StringName of property for the OK button validation.static final StringName of property for the value the user selected.static final StringName of property for the error message at the bottom of the wizard.static final intMessage type for questions.static final intMessage type for warning messages.static final intOption type used for negatable and cancellable confirmations.static final intOption type used for negatable confirmations.static final ObjectReturn value if YES is chosen. -
Constructor Summary
ConstructorsConstructorDescriptionNotifyDescriptor(Object message, String title, int optionType, int messageType, Object[] options, Object initialValue) Creates a new notify descriptor with specified information to report. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd aPropertyChangeListenerto the listener list.final NotificationLineSupportCreateNotificationLineSupportif you want to notify users using info/warning/error messages in designed line at the bottom of your dialog.protected voidfirePropertyChange(String propertyName, Object oldValue, Object newValue) Fire aPropertyChangeEventto each listener.Object[]Get the explicit additional choices the user can make.Get the default value of descriptor.Get the message object.intGet the message type.final NotificationLineSupportReturns NotificationLineSupport if it was created ornullif doesn't.Object[]Get the explicit choices the user can make.intGet the type of options that are to be displayed.getTitle()Get the title string for this report description.protected static StringgetTitleForType(int messageType) Get the title to use for the indicated type.getValue()Get the value the user has selected.protected voidMethod that is called before a value is returned from any of getter methods in this object.booleanfinal booleanisValid()Return true if OK button is valid (enabled), otherwise return false.voidRemove aPropertyChangeListenerfrom the listener list.voidsetAdditionalOptions(Object[] newOptions) Define an explicit description of the set of additional user-selectable options.voidsetMessage(Object newMessage) Define a descriptive message to be reported.voidsetMessageType(int newType) Define the style of the message.voidsetNoDefaultClose(boolean noDefaultClose) Disable or enabled the closing of dialog window using ESC and the close button in dialog's title bar.voidsetOptions(Object[] newOptions) Define an explicit description of the set of user-selectable options.voidsetOptionType(int newType) Define the set of options.voidSet the title string for this report description.final voidsetValid(boolean newValid) Set validity of OK button.voidSet the value the user has chosen and fires appropriate property change.
-
Field Details
-
PROP_MESSAGE
-
PROP_MESSAGE_TYPE
Name of property for the type of message to use.- See Also:
-
PROP_OPTION_TYPE
Name of property for the style of options available.- See Also:
-
PROP_OPTIONS
-
PROP_VALUE
-
PROP_TITLE
-
PROP_DETAIL
-
PROP_VALID
-
PROP_NO_DEFAULT_CLOSE
Name of property for toggling the ESC key and title frame button closing.- Since:
- 7.35
- See Also:
-
PROP_ERROR_NOTIFICATION
Name of property for the error message at the bottom of the wizard. To set such message usecreateNotificationLineSupport()- Since:
- 7.10
- See Also:
-
PROP_WARNING_NOTIFICATION
Name of property for the error message at the bottom of the wizard. To set such message usecreateNotificationLineSupport()- Since:
- 7.10
- See Also:
-
PROP_INFO_NOTIFICATION
Name of property for the error message at the bottom of the wizard. To set such message usecreateNotificationLineSupport()- Since:
- 7.10
- See Also:
-
YES_OPTION
Return value if YES is chosen. -
NO_OPTION
Return value if NO is chosen. -
CANCEL_OPTION
Return value if CANCEL is chosen. -
OK_OPTION
Return value if OK is chosen. -
CLOSED_OPTION
Return value if user closes the window without pressing any button. -
DEFAULT_OPTION
public static final int DEFAULT_OPTIONOption type used by default.- See Also:
-
YES_NO_OPTION
public static final int YES_NO_OPTIONOption type used for negatable confirmations.- See Also:
-
YES_NO_CANCEL_OPTION
public static final int YES_NO_CANCEL_OPTIONOption type used for negatable and cancellable confirmations.- See Also:
-
OK_CANCEL_OPTION
public static final int OK_CANCEL_OPTIONOption type used for cancellable confirmations.- See Also:
-
ERROR_MESSAGE
public static final int ERROR_MESSAGEMessage type for error messages.- See Also:
-
INFORMATION_MESSAGE
public static final int INFORMATION_MESSAGEMessage type for information messages.- See Also:
-
WARNING_MESSAGE
public static final int WARNING_MESSAGEMessage type for warning messages.- See Also:
-
QUESTION_MESSAGE
public static final int QUESTION_MESSAGEMessage type for questions.- See Also:
-
PLAIN_MESSAGE
public static final int PLAIN_MESSAGEPlain message type using no icon.- See Also:
-
-
Constructor Details
-
NotifyDescriptor
public NotifyDescriptor(Object message, String title, int optionType, int messageType, Object[] options, Object initialValue) Creates a new notify descriptor with specified information to report. IfoptionTypeisYES_NO_OPTIONorYES_NO_CANCEL_OPTIONand theoptionsparameter isnull, then the options are supplied by the look and feel. ThemessageTypeparameter is primarily used to supply a default icon from the look and feel.- Parameters:
message- the object to displaytitle- the title string for the dialogoptionType- indicates which options are availablemessageType- indicates what type of message should be displayedoptions- an array of objects indicating the possible choicesinitialValue- the object that represents the default value- See Also:
-
-
Method Details
-
initialize
protected void initialize()Method that is called before a value is returned from any of getter methods in this object. Allows subclasses to do some additional initialization actions. -
isValid
public final boolean isValid()Return true if OK button is valid (enabled), otherwise return false.- Returns:
- validity status of OK button.
- See Also:
-
setValid
public final void setValid(boolean newValid) Set validity of OK button.- Parameters:
newValid- validity status of OK button- See Also:
-
setMessage
Define a descriptive message to be reported. In the most common usage, the message is just aString. However, the type of this parameter is actuallyObject. Its interpretation depends on its type:Object[]- A recursively interpreted series of messages.
Component- The
Componentis displayed in the dialog. Icon- The
Iconis wrapped in aJLabeland displayed in the dialog. - anything else
- The
string representationof the object.
- Parameters:
newMessage- theObjectto report- See Also:
-
getMessage
Get the message object.- Returns:
- the
Objectthat is to be reported - See Also:
-
setMessageType
public void setMessageType(int newType) Define the style of the message. The look and feel manager may lay out the dialog differently depending on this value, and will often provide a default icon. The possible values are:- Parameters:
newType- the kind of message- See Also:
-
getMessageType
public int getMessageType()Get the message type.- Returns:
- the message type
- See Also:
-
setOptionType
public void setOptionType(int newType) Define the set of options. The option type is used by the look and feel to determine what options to show (unless explicit options are supplied):- Parameters:
newType- the options the look and feel is to display- See Also:
-
getOptionType
public int getOptionType()Get the type of options that are to be displayed.- Returns:
- the option type
- See Also:
-
setOptions
Define an explicit description of the set of user-selectable options. The usual value for the options parameter is an array ofStrings. But the parameter type is an array ofObjects. Its interpretation depends on its type:- Parameters:
newOptions- an array of user-selectable options- See Also:
-
getOptions
Get the explicit choices the user can make.- Returns:
- the array of
Objects that give the user's choices - See Also:
-
setAdditionalOptions
Define an explicit description of the set of additional user-selectable options. Additional options are supposed to be used for help button, etc.The usual value for the options parameter is an array of
Strings. But the parameter type is an array ofObjects. Its interpretation depends on its type:- Parameters:
newOptions- an array of user-selectable options- See Also:
-
getAdditionalOptions
Get the explicit additional choices the user can make.- Returns:
- the array of
Objects that give the user's choices - See Also:
-
setValue
Set the value the user has chosen and fires appropriate property change. You probably do not want to call this yourself, of course.- Parameters:
newValue- the chosen value- See Also:
-
getValue
Get the value the user has selected.- Returns:
- an
Objectindicating the option selected by the user - See Also:
-
getDefaultValue
Get the default value of descriptor.- Returns:
- an
Objectthat represents the default value - Since:
- 5.9
-
setTitle
Set the title string for this report description.- Parameters:
newTitle- the title of this description- See Also:
-
getTitle
Get the title string for this report description.- Returns:
- the title of this description
- See Also:
-
createNotificationLineSupport
CreateNotificationLineSupportif you want to notify users using info/warning/error messages in designed line at the bottom of your dialog. These message will be labelled with appropriate icons.
Note: Call this method before you callDialogDisplayer.createDialog(DialogDescriptor)- Returns:
- NotificationLineSupport
- Since:
- 7.10
-
getNotificationLineSupport
Returns NotificationLineSupport if it was created ornullif doesn't.
Note: NotificationLineSupport will not be created by default, API client has to create this support purposely with the exceptionWizardDescriptorwhich has such capability longer.- Returns:
- NotificationLineSupport or null if was not created yet
- Since:
- 7.10
- See Also:
-
addPropertyChangeListener
Add aPropertyChangeListenerto the listener list.- Parameters:
listener- thePropertyChangeListenerto be added
-
removePropertyChangeListener
Remove aPropertyChangeListenerfrom the listener list.- Parameters:
listener- thePropertyChangeListenerto be removed
-
firePropertyChange
Fire aPropertyChangeEventto each listener.- Parameters:
propertyName- the programmatic name of the property that was changedoldValue- the old value of the propertynewValue- the new value of the property
-
setNoDefaultClose
public void setNoDefaultClose(boolean noDefaultClose) Disable or enabled the closing of dialog window using ESC and the close button in dialog's title bar.- Parameters:
noDefaultClose- True to disabled ESC closing and to disable the close button in dialog's title bar.- Since:
- 7.35
- See Also:
-
isNoDefaultClose
public boolean isNoDefaultClose()- Returns:
- True if ESC key closing and close button in dialog's title bar are disabled, false otherwise.
- Since:
- 7.35
-
getTitleForType
Get the title to use for the indicated type.- Parameters:
messageType- the type of message- Returns:
- the title to use
-