102 lines
3.7 KiB
Java
102 lines
3.7 KiB
Java
/*
|
|
* Copyright (c) 2003,2008 Declarative Engineering LLC.
|
|
* All rights reserved. This program and the accompanying materials
|
|
* are made available under the terms of the Declarative Engineering LLC
|
|
* verson 1 which accompanies this distribution, and is available at
|
|
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
|
|
*/
|
|
package com.foundation.view.swt;
|
|
|
|
import org.eclipse.swt.SWT;
|
|
import com.common.debug.*;
|
|
import com.foundation.view.*;
|
|
|
|
public class MessageDialog extends Dialog {
|
|
public static final int STYLE_ICON_ERROR = SWT.ICON_ERROR;
|
|
/** The default setting for the dialog if none other is given. */
|
|
public static final int STYLE_ICON_INFORMATION = SWT.ICON_INFORMATION;
|
|
public static final int STYLE_ICON_QUESTION = SWT.ICON_QUESTION;
|
|
public static final int STYLE_ICON_WARNING = SWT.ICON_WARNING;
|
|
public static final int STYLE_ICON_WORKING = SWT.ICON_WORKING;
|
|
/** The default setting for the dialog if none other is given. */
|
|
public static final int STYLE_OK = SWT.OK;
|
|
public static final int STYLE_CANCEL = SWT.CANCEL;
|
|
public static final int STYLE_YES = SWT.YES;
|
|
public static final int STYLE_NO = SWT.NO;
|
|
public static final int STYLE_RETRY = SWT.RETRY;
|
|
public static final int STYLE_IGNORE = SWT.IGNORE;
|
|
public static final int STYLE_ABORT = SWT.ABORT;
|
|
public static final int STYLE_PRIMARY_MODAL = SWT.PRIMARY_MODAL;
|
|
/** The default setting for the dialog if none other is given. */
|
|
public static final int STYLE_APPLICATION_MODAL = SWT.APPLICATION_MODAL;
|
|
public static final int STYLE_SYSTEM_MODAL = SWT.SYSTEM_MODAL;
|
|
/**
|
|
* MessageDialog constructor.
|
|
* @param parent The parent view (accessable from the view controller by calling the getView() method).
|
|
*/
|
|
public MessageDialog(IView parent) {
|
|
super();
|
|
|
|
if(parent instanceof Container) {
|
|
org.eclipse.swt.widgets.Shell shell = ((Container) parent).getSwtControl().getShell();
|
|
|
|
shell.forceFocus();
|
|
shell.forceActive();
|
|
//shell.setActive();
|
|
//shell.setFocus();
|
|
setSwtDialog(new org.eclipse.swt.widgets.MessageBox(shell));
|
|
}//if//
|
|
else {
|
|
Debug.log("Error: Cannot create a dialog without a valid SWT parent control.");
|
|
}//else//
|
|
}//MessageDialog()//
|
|
/**
|
|
* MessageDialog constructor.
|
|
* @param parent The parent view (accessable from the view controller by calling the getView() method).
|
|
* @param style One or more of the style properties defined by this class (or'd together).
|
|
*/
|
|
public MessageDialog(IView parent, int style) {
|
|
super();
|
|
|
|
if(parent instanceof Container) {
|
|
org.eclipse.swt.widgets.Shell shell = ((Container) parent).getSwtControl().getShell();
|
|
|
|
shell.forceFocus();
|
|
shell.forceActive();
|
|
shell.setActive();
|
|
shell.setFocus();
|
|
setSwtDialog(new org.eclipse.swt.widgets.MessageBox(((Container) parent).getSwtControl().getShell(), style));
|
|
}//if//
|
|
else {
|
|
Debug.log("Error: Cannot create a dialog without a valid SWT parent control.");
|
|
}//else//
|
|
}//MessageDialog()//
|
|
/**
|
|
* Gets the SWT message dialog instance.
|
|
* @return The SWT message dialog.
|
|
*/
|
|
private org.eclipse.swt.widgets.MessageBox getSwtMessageDialog() {
|
|
return (org.eclipse.swt.widgets.MessageBox) getSwtDialog();
|
|
}//getSwtMessageDialog()//
|
|
/**
|
|
* Gets the message to be displayed to the user.
|
|
* @return The dialog message.
|
|
*/
|
|
public String getMessage() {
|
|
return getSwtMessageDialog().getMessage();
|
|
}//getMessage()//
|
|
/**
|
|
* Sets the message to be displayed to the user.
|
|
* @param message The dialog message.
|
|
*/
|
|
public void setMessage(String message) {
|
|
getSwtMessageDialog().setMessage(message);
|
|
}//setMessage()//
|
|
/**
|
|
* Opens the dialog making it visible to the user.
|
|
* @return The id of the button used to dismiss the message dialog. For example MessageDialog.STYLE_OK.
|
|
*/
|
|
public int open() {
|
|
return getSwtMessageDialog().open();
|
|
}//open()//
|
|
}//MessageDialog// |