Package org.eclipse.swt.widgets

Examples of org.eclipse.swt.widgets.MessageBox


        deleteConfigButton.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(final SelectionEvent e) {
                if (nodesConfigName != null) {
                    final MessageBox messageBox = new MessageBox(parent.getShell(),
                            SWT.ICON_QUESTION | SWT.YES | SWT.NO);
                    messageBox.setMessage("Delete \"" + nodesConfigName + "\"?");
                    messageBox.setText("Delete configuration");
                    if (messageBox.open() == SWT.YES) {
                        ConfigurationManager.removeNodesConfig(nodesConfigName);
                        nodesConfigName = null;
                        configNameLabel.setText("");
                    }
                }
            }
        });

        // "Save nodes configuration" button
        saveConfigButton.setToolTipText("Save current nodes configuration");
        saveConfigButton.setImage(PlatformUI.getWorkbench().getSharedImages()
                .getImage(ISharedImages.IMG_ETOOL_SAVE_EDIT));
        saveConfigButton.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(final SelectionEvent e) {
                if (nodesConfigName != null) {
                    if (!ConfigurationManager.saveNodesConfig(nodesConfigName)) {
                        final MessageBox messageBox = new MessageBox(parent.getShell(),
                                SWT.ICON_ERROR | SWT.OK);
                        messageBox.setMessage("Unable to save configuration: "
                                + nodesConfigName);
                        messageBox.setText("Error");
                        messageBox.open();
                    }
                }
            }
        });

        // "Save nodes configuration as..." button
        saveAsConfigButton.setToolTipText("Save current nodes configuration as...");
        saveAsConfigButton.setImage(PlatformUI.getWorkbench().getSharedImages()
                .getImage(ISharedImages.IMG_ETOOL_SAVEAS_EDIT));
        saveAsConfigButton.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(final SelectionEvent e) {
                final String[] configurations = ConfigurationManager.getNodesConfig();
                final Set<String> existingNames = new HashSet<String>(Arrays
                        .asList(configurations));
                final InputDialog dialog = new ConfigurationSaveAsDialog(parent
                        .getShell(), "Save nodes configuration",
                        "Enter name for configuration:", nodesConfigName, existingNames);

                if (dialog.open() == Window.OK) {
                    if (ConfigurationManager.saveNodesConfig(dialog.getValue())) {
                        nodesConfigName = dialog.getValue();
                        configNameLabel.setText(nodesConfigName);
                    } else {
                        final MessageBox messageBox = new MessageBox(parent.getShell(),
                                SWT.ICON_ERROR | SWT.OK);
                        messageBox.setMessage("Unable to save configuration: "
                                + dialog.getValue());
                        messageBox.setText("Error");
                        messageBox.open();
                    }
                }
            }
        });
    }
View Full Code Here


     */
    public static boolean showDecidableQuestion(final Shell s, final String question,
            final String title) {
        boolean b;
        try {
            final MessageBox mb = new MessageBox(s, SWT.ICON_WARNING | SWT.YES | SWT.NO);
            mb.setMessage(question);
            mb.setText(title);
            final int response = mb.open();
            if (response == SWT.YES) {
                b = true;
            } else {
                b = false;
            }
View Full Code Here

       * @see org.eclipse.swt.events.ShellAdapter#shellClosed(org.eclipse.swt.events.ShellEvent)
       */
      @Override
      public void shellClosed(ShellEvent e) {
        int style = SWT.APPLICATION_MODAL | SWT.YES | SWT.NO;
        MessageBox messageBox = new MessageBox(getShell(), style);
        messageBox.setText("Leave table");
        messageBox.setMessage("Are you sure you want to leave this table?");
        e.doit = messageBox.open() == SWT.YES;
      }
    });
  }
View Full Code Here

              aboutMenuItem.setText("About");
              aboutMenuItem.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent evt) {
                  MessageBox aboutInfo = new MessageBox(getShell());
                  aboutInfo.setMessage("CSPoker SWT Client 0.1");
                  aboutInfo.setText("About");
                  aboutInfo.open();
                }
              });
            }
            helpMenuItem.setMenu(helpMenu);
          }
View Full Code Here

       * @see org.eclipse.swt.events.ShellAdapter#shellClosed(org.eclipse.swt.events.ShellEvent)
       */
      @Override
      public void shellClosed(ShellEvent e) {
        int style = SWT.APPLICATION_MODAL | SWT.YES | SWT.NO;
        MessageBox messageBox = new MessageBox(getShell(), style);
        messageBox.setText("Close Window");
        messageBox.setMessage("Are you sure you want to exit?");
        e.doit = messageBox.open() == SWT.YES;
        // Lobby has been closed
        // Dispose of the display entirely so all GameWindows are closed
        // as well
        if (e.doit){
          exit();
View Full Code Here

   *            info)
   * @return {@link MessageBox#open()}
   */
  public static int displayMessage(String title, String message, int style) {
    logger.info(message);
    MessageBox infoBox = new MessageBox(new Shell(Display.getCurrent()), style | SWT.OK);
    infoBox.setText(title);
    infoBox.setMessage(message);
    return infoBox.open();
  }
View Full Code Here

        return shell;
    }

    private static int showBox(String title, String message, int icon)
    {
        MessageBox messageBox = new MessageBox(getShell(), icon);
        messageBox.setMessage(message);
        messageBox.setText(title);

        return messageBox.open();
    }
View Full Code Here

  public void showErrorMessage(String message) {
    this.showErrorMessage("Error", message);
  }
 
  public void showErrorMessage(String title, String message) {
    MessageBox box = new MessageBox(Display.getCurrent().getActiveShell(), SWT.OK | SWT.ICON_ERROR);
    box.setText(title);
    box.setMessage(message);
    box.open();
  }
View Full Code Here

  public void showWarningMessage(String message) {
    this.showWarningMessage("Warning", message);
  }
 
  public void showWarningMessage(String title, String message) {
    MessageBox box = new MessageBox(Display.getCurrent().getActiveShell(), SWT.OK | SWT.ICON_WARNING);
    box.setText(title);
    box.setMessage(message);
    box.open();
  }
View Full Code Here

     *      the ID of the button that was selected to dismiss
     *      the message box (e.g. SWT.OK, SWT.CANCEL, etc...)
     */
    private static int displayMessageBox( int style, String title, String message )
    {
        MessageBox messageBox = new MessageBox( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), style );
        messageBox.setText( title );
        messageBox.setMessage( message );
        return messageBox.open();
    }
View Full Code Here

TOP

Related Classes of org.eclipse.swt.widgets.MessageBox

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.