use of org.eclipse.swt.widgets.MessageBox in project cogtool by cogtool.
the class WindowUtil method createMessageDialog.
/**
* Creates a nested interaction pop-up (modal) window.
*
* For the "flag" parameters, use the following values:
* <code>
* buttons: one of the following combinations
* SWT.OK
* SWT.OK | SWT.CANCEL
* SWT.YES | SWT.NO
* SWT.YES | SWT.NO | SWT.CANCEL
* SWT.RETRY | SWT.CANCEL
* SWT.ABORT | SWT.RETRY | SWT.IGNORE
*
* icon: one of
* SWT.ICON_ERROR, SWT.ICON_INFORMATION, SWT.ICON_QUESTION,
* SWT.ICON_WARNING, SWT.ICON_WORKING, SWT.NONE
*
* mode: one of (in increasing order of restriction)
* SWT.PRIMARY_MODAL, SWT.APPLICATION_MODAL, SWT.SYSTEM_MODAL
* </code>
*
* @param parent the window the pop-up "adheres" to
* @param title the title for the pop-up window
* @param message the message to display to the user
* @param buttons which buttons to display in the pop-up
* @param icon the icon to display, indicating the message's nature
* @param mode whether the pop-up is modal relative to
* the parent window, the application as a whole,
* or the entire user's system/computer
* @return the created MessageBox
* @author mlh
* @see org.eclipse.swt.widgets.MessageBox
* @see org.eclipse.swt.SWT
*/
public static MessageBox createMessageDialog(Shell parent, String title, String message, int buttons, int icon, int mode) {
MessageBox msgBox = new MessageBox(parent, buttons | icon | mode);
msgBox.setText(title);
msgBox.setMessage(message);
return msgBox;
}
use of org.eclipse.swt.widgets.MessageBox in project dbeaver by serge-rider.
the class DBeaverApplication method showMessageBox.
int showMessageBox(String title, String message, int style) {
// Can't lock specified path
Shell shell = new Shell(getDisplay(), SWT.ON_TOP);
shell.setText(GeneralUtils.getProductTitle());
MessageBox messageBox = new MessageBox(shell, style);
messageBox.setText(title);
messageBox.setMessage(message);
int msgResult = messageBox.open();
shell.dispose();
return msgResult;
}
use of org.eclipse.swt.widgets.MessageBox in project translationstudio8 by heartsome.
the class NativeDialogFactory method showMessageBox.
/**
* Show message box.
*
* In default mode, a native MessageBox is used.
* In testing mode, we use a MessageDialog, showing the same title and message.
*
* @param messageText the text of the message
* @param title the title
* @param iconStyle the icon style
* @param shell the parent shell
*/
public static void showMessageBox(Shell shell, String messageText, final String title, final int iconStyle) {
if (shell == null) {
// logger
// .fatal("Shell not yet instantiated, cannot display error message");
System.err.println("Shell not yet instantiated, cannot display error message");
} else {
switch(getMode()) {
case DEFAULT:
{
MessageBox messageBox = new MessageBox(shell, iconStyle);
messageBox.setMessage(messageText);
messageBox.setText(title);
messageBox.open();
break;
}
case TESTING:
{
// ignore the iconStyle, this only creates trouble when testing.
MessageDialog messagDialog = new MessageDialog(shell, title, null, messageText, MessageDialog.NONE, new String[] { "OK" }, 0);
messagDialog.open();
break;
}
default:
final String msg = "Reached default case in NativeDialogFactory, this is a bug, unknown state " + getMode();
// logger.warn(msg);
System.err.println(msg);
throw new RuntimeException(msg);
}
}
}
use of org.eclipse.swt.widgets.MessageBox in project translationstudio8 by heartsome.
the class AspellChecker method checkStatus.
private void checkStatus() {
try {
while (response != null && !response.equals("")) {
if (isError) {
return;
}
if (response.equals("*")) {
// 当前单词是存在于词典中的
spellWriter.write(spellCheckLinePrefix);
spellWriter.newLine();
spellWriter.flush();
response = spellReader.readLine();
} else {
if (response.startsWith("&") || response.startsWith("#")) {
parseSuggestions(response);
response = spellReader.readLine();
}
}
}
if (response == null || response.equals("")) {
return;
}
} catch (IOException e) {
MessageBox box = new MessageBox(shell, SWT.ICON_ERROR);
box.setMessage(e.getMessage());
box.open();
logger.error(Messages.getString("qa.spellCheck.all.log2"), e);
}
}
use of org.eclipse.swt.widgets.MessageBox in project translationstudio8 by heartsome.
the class AddOrUpdateLanguageDialog method okPressed.
@Override
public void okPressed() {
if (txtCode.getText() == null || "".equals(txtCode.getText().trim())) {
//$NON-NLS-1$
MessageDialog.openInformation(getShell(), Messages.getString("languagecode.AddOrUpdateLanguageDialog.msgTitle"), Messages.getString("languagecode.AddOrUpdateLanguageDialog.msg1"));
txtCode.forceFocus();
return;
}
if (intType == DIALOG_ADD) {
if (languageModel.getLanguagesMap().containsKey(txtCode.getText())) {
MessageDialog.openInformation(getShell(), Messages.getString("languagecode.AddOrUpdateLanguageDialog.msgTitle"), Messages.getString("languagecode.AddOrUpdateLanguageDialog.msg2"));
return;
}
} else if (intType == DIALOG_EDIT) {
if (!txtCode.getText().equals(strCode) && languageModel.getLanguagesMap().containsKey(txtCode.getText())) {
MessageDialog.openInformation(getShell(), Messages.getString("languagecode.AddOrUpdateLanguageDialog.msgTitle"), Messages.getString("languagecode.AddOrUpdateLanguageDialog.msg2"));
return;
}
}
if (txtName.getText() == null || "".equals(txtName.getText().trim())) {
//$NON-NLS-1$
MessageDialog.openInformation(getShell(), Messages.getString("languagecode.AddOrUpdateLanguageDialog.msgTitle"), Messages.getString("languagecode.AddOrUpdateLanguageDialog.msg3"));
txtName.forceFocus();
return;
}
String status = parse(txtCode.getText());
if (!status.equals("")) {
//$NON-NLS-1$
MessageBox box = new MessageBox(getShell(), SWT.ICON_QUESTION | SWT.YES | SWT.NO);
//$NON-NLS-1$
box.setMessage(status + Messages.getString("languagecode.AddOrUpdateLanguageDialog.msg4"));
if (box.open() == SWT.NO) {
return;
}
}
imagePath = (String) imageLabel.getData();
if (imagePath == null) {
imagePath = "";
}
strCode = txtCode.getText();
strName = txtName.getText();
blnIsBidi = btnIsBidi.getSelection();
close();
}
Aggregations