Using Dialog Prompts (Discardable Advanced)

Revision as of 08:35, 6 September 2007 by Paulb (Talk | contribs) (State Preference Persistence)

Construction.png Not Ready for Review: This Page is Under Development!

Showing dialog prompts displaying the same messages over and over again can be annoying for most end-user. Take the security or alert notifications in your browser, most of us just turn them off after we have read them after they have been shown for the first time, we even discard them without reading them in some cases. EiffelStudio another product full of cases where "discardable" dialogs prompts are a necessity, without them we could hinder and annoy end-users.


Getting Started

You should already be familiar with the topics detailed in Using Dialog Prompts (Advanced) as the information there applies to discardable dialogs prompts also.

Before continuing you may also want to check out the following pages:

The Need For Discardable Dialog Prompts

One such example of a need for a discardable dialog is performing a finalization compilation. Finalization asks the end-user if they want to discard or keep assertions. For the most part (95%-99% of cases) assertions are always discarded. It makes sense to offer a way to suppress the dialog in the future and perform a default, commonly used, pre-defined action (discarding assertions in this case) when performing a finalization in the future.

Dialog shown when finalizing an Eiffel project


Using Discardable Dialog Prompts

There are only a couple of few pieces of information required when using a discardable dialog prompt over the non-discardable variant.

State Preference Persistence

Most importantly is the configuration preference that the discardable states is stored. Upon creation of a discardable dialog prompt you will need to supply the full name of a preference, which is typically in the form interface.dialogs.confirm_xxxx where xxxx represents the name of the dialog.

Information.png Note: For dialog preferences and preference names examine the class EB_DIALOGS_DATA. For a general overview of adding preferences to EiffelStudio see Adding EiffelStudio Preferences.

Not only does the preference record the state of a user-opted discard but it also permits the user to reactive the dialog prompt via the preferences tool.

Default Discard Button

Like non-discarable dialog prompts, discardable prompts require setting of a "Discard Button". the discard button is the button who's actions are performed, and dialog result set to when the the dialog prompt is not show becasue it was selected to be discarded on a previous showing. To set the discard button call set_discard_button on the dialog prompt after it has been created, using a button identifier that corresponds to a button that is available on the dialog prompt:

ask_save_changes
    -- Ask user if they want to save the changes before continuing
  local
    l_prompt: ES_DISCARDABLE_QUESTION_PROMPT
  do
    create l_prompt.make_standard ("Save changes before continuing?", "", "interface.dialog.confirm_save")
    l_prompt.set_discard_button ({ES_DIALOG_BUTTONS}.yes_button)
    l_prompt.show_on_active_window
  end

The discard button is set to Yes

For all of the predefined, common discardable dialogs as discard button is set by default when creating the dialog prompt using either make_standard or make_standard_with_cancel. Below outlines the dialog prompt type and the default standard discard button for the prompt.

  • Warning: Ok
  • Information: Ok
  • Question: Yes

Introducing Discardable Dialog Prompt Classes

There are, as of EiffelStudio 6.1, four common discardable dialog prompt classes for use which are somewhat self-explanatory.

All dialog prompt classes are based on an abstract implementation ES_DISCARDABLE_PROMPT, which in turn implements parts of ES_PROMPT.

Extending A Discardable Dialog Prompt

Like the regular dialog prompts (see Using Dialog Prompts (Advanced)), discardable dialog prompts can also be extended. For an example of extension inside EiffelStudio, see the ES_DISCARDABLE_COMPILE_SAVE_PROMPT class. Below shows an extended ES_DISCARDABLE_QUESTION_PROMPT class to create a discardable prompt that informs the user about unsaved modifications to one or more classes in the project, prior to a compilation.

Unsaved changes dialog prompt with a subtitle