Difference between revisions of "Using Dialog Prompts (Discardable Advanced)"

m (Discard Message)
m (Using Discardable Dialog Prompts)
Line 60: Line 60:
 
</eiffel>
 
</eiffel>
  
[[Image:Dialog prompts example question no default.png|The discard button is set to Yes]]
+
[[Image:Discardable dialog prompts example no message.png|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 <eiffel>make_standard</eiffel> or <eiffel>make_standard_with_cancel</eiffel>. Below outlines the dialog prompt type and the default standard discard button for the prompt.
 
For all of the predefined, common discardable dialogs as discard button is set by default when creating the dialog prompt using either <eiffel>make_standard</eiffel> or <eiffel>make_standard_with_cancel</eiffel>. Below outlines the dialog prompt type and the default standard discard button for the prompt.
Line 92: Line 92:
 
</eiffel>
 
</eiffel>
  
[[Image:Dialog prompts example question no default.png|Setting a discard message to 'always save']]
+
[[Image:Discardable dialog prompts example message.png|Setting a discard message to 'always save']]
  
 
== Extending A Discardable Dialog Prompt ==
 
== Extending A Discardable Dialog Prompt ==

Revision as of 08:31, 6 September 2007

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


Introducing Discardable Dialog Prompt Classes

There are, as of EiffelStudio 6.1, three 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.

Information.png Note: There is no error variant of a discardable dialog prompt because errors are considered too important to discard. If an error occurs it should always been shown to the user!

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-discardable 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

In addition to being the button who's actions are perform, the discard button also is used to determine if the dialog prompt should save the selected discard state. It is logical to expect that if the user choose to perform an action which is not designated as the the discardable action then the discardable state should never be saved. Imagine the finalization dialog prompt mentioned at the beginning of this page. If the user chose to discard the dialog prompt and selected the Keep Assertions button, if the discard state was persisted, the next time the user finalizes a project the dialog prompt should not be shown and the assertions would be discarded in the compilation. This is because the Discard Assertions button is the action performed when the dialog prompt is discarded.

Discard Message

A discard message is an optional message that can be set on the dialog prompt during creation, through the a_discard_message argument.

By default all discardable dialogs prompt have a check option to discard the dialog in the future. When no discard message is set the check option reads Do not show again. In the case where a discard message is set (a non-empty string) the message will be placed in parenthesis after the Do not show again check option text. The discard assertions finalization dialog prompt is an example of this, the discard check option reads Do not show again (always discard assertions when finalizing). In this case the discard message is always discard assertions when finalizing.

Information.png Note: Discard messages should indicate what action will be performed when discarded. The messages should be terse but clear and formatted without an initial capital letter as it's part of a sentence, not a new one.

In the section detailing discard buttons the example was created without a discard message but passing "" as an argument for parameter a_discard_message of make_standard. The follow example sets a discard message "always save":

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?", "always save", "interface.dialog.confirm_save")
    l_prompt.set_discard_button ({ES_DIALOG_BUTTONS}.yes_button)
    l_prompt.show_on_active_window
  end

Setting a discard message to 'always save'

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