GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing wiki.eclipse.org — Nebula Dialog - Eclipsepedia
Jump to: navigation,
search
Nebula DialogIntroductionAims to create a trivial Task Dialog API for SWT as described at https://msdn.microsoft.com/en-us/library/dn742499.aspx. Inspired by the Oxbow Project (https://github.com/eugener/oxbow) ContentsUsageFormattingYou can format the message using some pseudo-HTML tags :
Display an errorThe Dialog class provides 2 static methods : public static void error(final String title, final String errorMessage); public static void error(final Shell shell, final String title, final String errorMessage); where title is the title of the dialog box, and errorMessage the error message to display. If no shell is specified, the dialog box will be an on-top window. Example: Dialog.error("CRASH AND BURN !", "The application has performed an illegal action. This action has been logged and reported.");
Display an informationThe Dialog class provides 2 static methods : public static void inform(final String title, final String text); public static void inform(final Shell shell, final String title, final String text); where title is the title of the dialog box, and text is the text to display. If no shell is specified, the dialog box will be an on-top window. Example: Dialog.inform("You've won!", "The game is over with the 15:3 score");
Display a confirmationThe Dialog class provides 4 static methods : public static boolean isConfirmed(final String title, final String text); public static boolean isConfirmed(final Shell shell, final String title, final String text) public static boolean isConfirmed(final String title, final String text, final int timer) public static boolean isConfirmed(final Shell shell,final String title, final String text, final int timer) where title is the title of the dialog box, and text is the text to display. If no shell is specified, the dialog box will be a on-top window. If a timer is specified, this is the time in second before the "Yes" button is enabled. Example: final boolean confirm = Dialog.isConfirmed("Are you sure you want to quit?", "Please do not quit yet!");
System.out.println("Choice is..." + confirm);
final boolean choice = Dialog.isConfirmed("Are you sure you want to quit?", "Please do not quit yet!", 10);
System.out.println("Choice is..." + choice);
Ask for a choice (radio button)The Dialog class provides 2 static methods : public static int radioChoice(final String title, final String text, final int defaultSelection, final String... values) public static int radioChoice(final Shell shell, final String title, final String text, final int defaultSelection, final String... values) where title is the title of the dialog box, text is the text to display, defaultSelection is the index of the default selection (0-based index) and values is a list of propositions. If no shell is specified, the dialog box will be an on-top window. Example: final int choice = Dialog.radioChoice("You've got selection to make", "Go ahead", 1, "Yes", "No", "May be");
System.out.println("Choice is..." + choice);
Ask for a choice (vista style)The Dialog class provides 2 static methods : public static int choice(final String title, final String text, final int defaultSelection, final ChoiceItem... items); public static int choice(final Shell shell, final String title, final String text, final int defaultSelection, final ChoiceItem... items) where title is the title of the dialog box, text is the text to display, defaultSelection is the index of the default selection (0-based index) and items is a list of propositions. ChoiceItem is a POJO used to display the proposition, which is composed of a short text and a description. If no shell is specified, the dialog box will be an on-top window. Example: final int choice = Dialog.choice("What do you want to do with your game in\nprogress?", "", 1,
new ChoiceItem("Exit and save my game", "Save your game in progress, then exit. " + "This will\noverwrite any previously saved games."),
new ChoiceItem("Exit and don't save", "Exit without saving your game. " + "This is counted\nas a loss in your statistics."),
new ChoiceItem("Don't exit", "Return to your game progress"));
System.out.println("Choice is..." + choice);
Display an exceptionThe Dialog class provides 1 static methods : public static void showException(final Throwable exception) where exception is the exception to display. Example: try {
new BigDecimal("seven");
} catch (final Throwable ex) {
Dialog.showException(ex);
}
Display inputThe Dialog class provides 2 static methods : public static String ask(final String title, final String text, final String defaultValue) public static String ask(final Shell shell, final String title, final String text, final String defaultValue) where title is the title of the dialog box, text is the text to display and defaultValue is the default value of the input box. If no shell is specified, the dialog box will be an on-top window. Example: final String input = Dialog.ask("Enter you name", "or any other text if you prefer", "Laurent CARON");
System.out.println("Choice is..." + input);
More complex stuffsA dialog box is composed of 2 parts :
Message Area A message area is composed of 3 or 4 parts :
Footer Area A footer area is composed of different optional parts
End Once the message area and the footer area are built, use the method Examples final Dialog dialog = new Dialog();
dialog.setTitle("Copying...");
dialog.setMinimumWidth(400);
dialog.getMessageArea().setTitle("Copying files") //
.setIcon(Display.getCurrent().getSystemImage(SWT.ICON_INFORMATION)) //
.setText("Location : from 'Others' to 'Others'
final Dialog dialog = new Dialog();
dialog.setTitle("Security Warning");
dialog.setMinimumWidth(400);
dialog.getMessageArea().setTitle("The publisher cannot be verified.\nDo you want to run this software?") //
.setIcon(Display.getCurrent().getSystemImage(SWT.ICON_WARNING)) //
.setText("Name: C:\\Program Files\\eclipse\\eclipse.exe
final Dialog dialog = new Dialog();
dialog.setTitle("Application Error");
dialog.getMessageArea().setTitle("CRASH AND BURN !").//
setText("The application has performed an illegal action. This action has been logged and reported.").//
setIcon(Display.getCurrent().getSystemImage(SWT.ICON_ERROR));
dialog.setButtonType(OpalDialogType.OK);
dialog.getFooterArea().setExpanded(false).addCheckBox("Don't show me this error next time", true).setDetailText("More explanations to come...");
dialog.getFooterArea().setFooterText("Your application crashed because a developer forgot to write a unit test").//
setIcon(SWTGraphicUtil.createImage("org/mihalis/opal/OpalDialog/warning.png"));
dialog.show();
i18nCommon text in the dialog can be shown in any language by putting locale specific resource bundle named opal_<locale_id>.properties on the classpath and switching default locale. The library has following built-in bundles under ’src/main/resources’: (pari Bundle/Locale)
ExampleAn example called OpalDialogSnippet.java is available in the plugin org.eclipse.nebula.widgets.opal.dialog.snippets. An example is also available here : OpalDialogSnippet.java
Retrieved from "https://wiki.eclipse.org/index.php?title=Nebula_Dialog&oldid=438768"
This page was last modified 06:44, 19 March 2020 by Eclipsepedia anonymous user Unnamed Poltroon. |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |