List of usage examples for org.eclipse.jface.dialogs MessageDialog ERROR
int ERROR
To view the source code for org.eclipse.jface.dialogs MessageDialog ERROR.
Click Source Link
From source file:Gui.NewGameDialog.java
License:Open Source License
private void getNames() { String sel = numberOfPlayersCombo.getText(); // System.out.println(sel); if (!sel.equals("1") && !sel.equals("2") && !sel.equals("3") && !sel.equals("4")) { // if (shell == null) System.out.println("bla"); String title = ("Number of players error"); String message = ("Number of players is not valid"); MessageDialog m = new MessageDialog(dialogShell, title, null, message, MessageDialog.ERROR, new String[] { "OK" }, 1); m.open();//ww w . j a va 2s . c o m return; } int numberOfPlayers = Integer.parseInt(sel); String[] names = new String[4]; names[0] = player1Text.getText(); names[1] = player2Text.getText(); names[2] = player3Text.getText(); names[3] = player4Text.getText(); //check that names are valid(non empty) for (int i = 0; i < numberOfPlayers; i++) { String isValid = isValidName(names[i]); if (isValid != null) { String title = ("Player name error"); String message = ("Player name must be at length 1 at minimum and 15 at most"); MessageDialog m = new MessageDialog(dialogShell, title, null, message, MessageDialog.ERROR, new String[] { "OK" }, 1); m.open(); return; } } boolean[] isAuto = new boolean[4]; isAuto[0] = false; isAuto[1] = computerCheck2.getSelection(); isAuto[2] = computerCheck3.getSelection(); isAuto[3] = computerCheck4.getSelection(); playersInfo = new PlayerInfo[numberOfPlayers]; for (int i = 0; i < numberOfPlayers; i++) { playersInfo[i] = new PlayerInfo(names[i], isAuto[i]); } // if (basicButton.getSelection()) {System.out.println("bla");} gameMode = basicButton.getSelection() ? 'b' : 'a'; dialogShell.dispose(); }
From source file:Gui.NewMultiDialog.java
License:Open Source License
public void open() { try {/*from ww w. ja v a 2 s. com*/ Shell parent = getParent(); dialogShell = new Shell(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); { //Register as a resource user - SWTResourceManager will //handle the obtaining and disposing of resources SWTResourceManager.registerResourceUser(dialogShell); } dialogShell.setLayout(new FormLayout()); dialogShell.setText("Multiplayer Dialog"); { Existing = new Button(dialogShell, SWT.PUSH | SWT.CENTER); Existing.setText("Login"); FormData ExistingLData = new FormData(); ExistingLData.width = 66; ExistingLData.height = 33; ExistingLData.left = new FormAttachment(0, 1000, 131); ExistingLData.top = new FormAttachment(0, 1000, 120); Existing.setLayoutData(ExistingLData); Existing.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent evt) { //System.out.println("Existing.widgetSelected, event="+evt); isClosed = false; if (text1.getText().equals("")) { String title = ("Error"); String message = ("You must specify your name"); MessageDialog m = new MessageDialog(dialogShell, title, null, message, MessageDialog.ERROR, new String[] { "OK" }, 1); m.open(); } else if (EmailText.isEnabled() == true) { //new user login if (EmailText.getText().equals("")) { String title = ("Error"); String message = ("If you login as new user you must specify your email"); MessageDialog m = new MessageDialog(dialogShell, title, null, message, MessageDialog.ERROR, new String[] { "OK" }, 1); m.open(); } else if (text2.getText().equals("")) { String title = ("Error"); String message = ("You must specify your password"); MessageDialog m = new MessageDialog(dialogShell, title, null, message, MessageDialog.ERROR, new String[] { "OK" }, 1); m.open(); } else { setClientInfo(true); // System.out.println("login as new"); } } else { setClientInfo(false); // System.out.println("login as user"); } } }); } { cancelConnect = new Button(dialogShell, SWT.PUSH | SWT.CENTER); cancelConnect.setText("Cancel"); FormData cancelConnectLData = new FormData(); cancelConnectLData.width = 43; cancelConnectLData.height = 33; cancelConnectLData.top = new FormAttachment(0, 1000, 120); cancelConnectLData.left = new FormAttachment(0, 1000, 203); cancelConnectLData.right = new FormAttachment(1000, 1000, -41); cancelConnect.setLayoutData(cancelConnectLData); cancelConnect.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent evt) { isClosed = true; dialogShell.dispose(); } }); } { newUser = new Button(dialogShell, SWT.PUSH | SWT.CENTER); newUser.setText("New User"); FormData connectLData = new FormData(); connectLData.width = 86; connectLData.height = 33; connectLData.top = new FormAttachment(0, 1000, 120); connectLData.left = new FormAttachment(0, 1000, 38); newUser.setLayoutData(connectLData); newUser.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent evt) { isClosed = false; EmailText.setEnabled(true); newUser.setEnabled(false); label3.setEnabled(true); // if (!text1.getText().equals("")) // setClientInfo(true); // else{ // MessageBox m = new MessageBox(dialogShell, SWT.ICON_ERROR); // m.setText("Error"); // m.setMessage("You must specify the name"); // m.open(); // } } }); } { EmailText = new Text(dialogShell, SWT.NONE); FormData EmailTextLData = new FormData(); EmailTextLData.width = 119; EmailTextLData.height = 17; EmailTextLData.left = new FormAttachment(0, 1000, 91); EmailTextLData.top = new FormAttachment(0, 1000, 101); EmailText.setLayoutData(EmailTextLData); EmailText.setEnabled(false); } { text2 = new Text(dialogShell, SWT.NONE); FormData text2LData = new FormData(); text2LData.width = 119; text2LData.height = 17; text2LData.left = new FormAttachment(0, 1000, 91); text2LData.top = new FormAttachment(0, 1000, 72); text2.setLayoutData(text2LData); text2.setEchoChar('*'); } { text1 = new Text(dialogShell, SWT.NONE); FormData text1LData = new FormData(); text1LData.width = 119; text1LData.height = 17; text1LData.left = new FormAttachment(0, 1000, 91); text1LData.top = new FormAttachment(0, 1000, 40); text1.setLayoutData(text1LData); } { label3 = new Label(dialogShell, SWT.NONE); label3.setText("Email:"); FormData label3LData = new FormData(); label3LData.width = 43; label3LData.height = 17; label3LData.left = new FormAttachment(0, 1000, 18); label3LData.top = new FormAttachment(0, 1000, 101); label3.setLayoutData(label3LData); label3.setFont(SWTResourceManager.getFont("Tahoma", 10, 0, false, false)); label3.setEnabled(false); } { label2 = new Label(dialogShell, SWT.NONE); label2.setText("password:"); FormData label2LData = new FormData(); label2LData.width = 61; label2LData.height = 17; label2LData.left = new FormAttachment(0, 1000, 18); label2LData.top = new FormAttachment(0, 1000, 72); label2.setLayoutData(label2LData); label2.setFont(SWTResourceManager.getFont("Tahoma", 10, 0, false, false)); } { label1 = new Label(dialogShell, SWT.NONE); label1.setText("username:"); FormData label1LData = new FormData(); label1LData.width = 61; label1LData.height = 20; label1LData.left = new FormAttachment(0, 1000, 18); label1LData.top = new FormAttachment(0, 1000, 40); label1.setLayoutData(label1LData); label1.setFont(SWTResourceManager.getFont("Tahoma", 10, 0, false, false)); } { helpLabel = new Label(dialogShell, SWT.NONE); helpLabel.setText("Before login please read carefully the\nrelevant notes at the help window"); FormData helpLabelData = new FormData(); helpLabelData.width = 250; helpLabelData.height = 35; helpLabelData.left = new FormAttachment(0, 1000, 5); helpLabelData.top = new FormAttachment(0, 1000, 5); helpLabel.setLayoutData(helpLabelData); helpLabel.setFont(SWTResourceManager.getFont("Tahoma", 9, 0, false, false)); } dialogShell.layout(); dialogShell.pack(); dialogShell.setLocation(getParent().toDisplay(100, 100)); dialogShell.open(); Display display = dialogShell.getDisplay(); while (!dialogShell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } } catch (Exception e) { e.printStackTrace(); } }
From source file:hydrograph.ui.propertywindow.widgets.dialog.hiveInput.HiveFieldDialogHelper.java
License:Apache License
/** * /*from ww w. jav a 2 s .c om*/ * Message dialog to be displayed if compare_fields() method returns false. * */ public int Message_Dialog() { MessageDialog dialog = new MessageDialog(Display.getCurrent().getActiveShell(), "Rearrange Fields", null, Messages.HIVE_PARTI_SEQ_ERROR, MessageDialog.ERROR, new String[] { "Rearrange Schema", "Rearrange Partition Fields" }, 0); int result = dialog.open(); return result; }
From source file:ilg.gnuarmeclipse.packs.data.Utils.java
License:Open Source License
public static boolean copyFileWithShell(final URL sourceUrl, File destinationFile, MessageConsoleStream out, IProgressMonitor monitor, final Shell shell) throws IOException { while (true) { try {/* w w w . j a v a 2 s. c o m*/ Utils.copyFile(sourceUrl, destinationFile, out, monitor); return true; } catch (final IOException e) { class ErrorMessageDialog implements Runnable { public int retCode = 0; @Override public void run() { String[] buttons = new String[] { "Retry", "Ignore", "Abort" }; MessageDialog dialog = new MessageDialog(shell, "Read error", null, sourceUrl.toString() + "\n" + e.getMessage(), MessageDialog.ERROR, buttons, 0); retCode = dialog.open(); } } ErrorMessageDialog messageDialog = new ErrorMessageDialog(); Display.getDefault().syncExec(messageDialog); if (messageDialog.retCode == 2) { throw e; // Abort } else if (messageDialog.retCode == 1) { return false; // Ignore } // Else try again } } // HandlerUtil.getActiveShell(event) }
From source file:ilg.gnuarmeclipse.packs.ui.views.PacksView.java
License:Open Source License
private boolean checkCopyDestinationFolders(TreeSelection selection, String[] param) { IPath m_destFolderPath = new Path(param[0]); boolean isNonEmpty = false; for (Object sel : selection.toList()) { PackNode exampleNode = (PackNode) sel; Leaf outlineExampleNode = exampleNode.getOutline().findChild(Type.EXAMPLE); String exampleRelativeFolder = outlineExampleNode.getProperty(Node.FOLDER_PROPERTY); File destFolder = m_destFolderPath.append(exampleRelativeFolder).toFile(); if (destFolder.isDirectory() && (destFolder.listFiles().length > 0)) { isNonEmpty = true;//from w ww .j a va2 s.c o m break; } } if (isNonEmpty) { String msg = "One of the destination folders is not empty."; msg += "\nDo you agree to delete the previous content?"; String[] buttons = new String[] { "OK", "Cancel" }; MessageDialog dlg = new MessageDialog(fComposite.getShell(), null, null, msg, MessageDialog.ERROR, buttons, 0); if (dlg.open() == 0) { return true; // OK } return false; } return true; }
From source file:ilg.gnumcueclipse.packs.data.Utils.java
License:Open Source License
/** * //from w w w .j a va 2 s . c o m * @param sourceUrl * @param destinationFile * @param out * @param monitor * @param shell * @return 0 = Ok, 1 = Retry, 2 = Ignore, 3 = Ignore All, 4 = Abort * @throws IOException */ public static int copyFileWithShell(final URL sourceUrl, File destinationFile, MessageConsoleStream out, IProgressMonitor monitor, final Shell shell, final boolean ignoreError) throws IOException { while (true) { try { Utils.copyFile(sourceUrl, destinationFile, out, monitor); return 0; } catch (final IOException e) { if (ignoreError) { return 3; // Ignore All } class ErrorMessageDialog implements Runnable { public int retCode = 0; @Override public void run() { String[] buttons = new String[] { "Retry", "Ignore", "Ignore All", "Abort" }; MessageDialog dialog = new MessageDialog(shell, "Read error", null, sourceUrl.toString() + "\n" + e.getMessage(), MessageDialog.ERROR, buttons, 0); retCode = dialog.open(); } } ErrorMessageDialog messageDialog = new ErrorMessageDialog(); Display.getDefault().syncExec(messageDialog); if (messageDialog.retCode == 3) { throw e; // Abort } else if (messageDialog.retCode == 1 || messageDialog.retCode == 2) { return messageDialog.retCode + 1; // Ignore & Ignore All } // Else try again } } // HandlerUtil.getActiveShell(event) }
From source file:lslforge.LSLForgePlugin.java
License:Open Source License
private boolean determineExecutable() { String path = getDefault().getPreferenceStore().getString(LSLFORGE_NATIVE_PATH); String preferredVersion = null; String embeddedVersion = null; String installedVersion = null; if (path != null && !"".equals(path.trim())) { //$NON-NLS-1$ preferredVersion = tryTask("Version", path); //$NON-NLS-1$ if (checkVersion(preferredVersion)) { setExecutablePath(path);//from ww w .j av a 2s . c om return true; } } URL url = FileLocator.find(getDefault().getBundle(), preferredNativePath(), null); if (url != null) { try { path = FileLocator.toFileURL(url).getFile(); embeddedVersion = tryTask("Version", path); //$NON-NLS-1$ if (checkVersion(embeddedVersion)) { setExecutablePath(path); return true; } } catch (IOException e) { Util.error(e, "can't locate " + url); //$NON-NLS-1$ } } url = FileLocator.find(getDefault().getBundle(), alternateNativePath(), null); if (url != null) { try { path = FileLocator.toFileURL(url).getFile(); embeddedVersion = tryTask("Version", path); //$NON-NLS-1$ if (checkVersion(embeddedVersion)) { setExecutablePath(path); return true; } } catch (IOException e) { Util.error(e, "can't locate " + url); //$NON-NLS-1$ } } installedVersion = tryTask("Version", LSL_COMMAND); //$NON-NLS-1$ if (checkVersion(installedVersion)) { setExecutablePath(LSL_COMMAND); return true; } StringBuilder versions = new StringBuilder(); boolean versionFound = false; if (preferredVersion != null) { versions.append(preferredVersion).append(" (version of executable set in LSLForge Preferences)\n"); //$NON-NLS-1$ TODO versionFound = true; } if (embeddedVersion != null) { versions.append(embeddedVersion).append(" (version installed as part of plugin)\n"); //$NON-NLS-1$ TODO versionFound = true; } if (installedVersion != null) { versions.append(installedVersion).append(" (version found on PATH)\n"); //$NON-NLS-1$ TODO versionFound = true; } final StringBuilder buf = new StringBuilder(); if (versionFound) { buf.append("The following versions of the LSLForge native executable were found:\n"); //$NON-NLS-1$ TODO buf.append(versions); buf.append("\nNone of these version are compatible with this plugin, which requires\n"); //$NON-NLS-1$ TODO buf.append("version ").append(LSLFORGE_CORE_VERSION).append(".\n"); //$NON-NLS-1$//$NON-NLS-2$ TODO } else { buf.append("The LSLForge native executable was not found!\n"); //$NON-NLS-1$ TODO } buf.append("The LSLForge native executable is available from Hackage:\n"); //$NON-NLS-1$ TODO buf.append("http://hackage.haskell.org/cgi-bin/hackage-scripts/package/LSLForge\n\n"); //$NON-NLS-1$ TODO buf.append("Please also see the Help documentation for LSLForge, under 'Installation'"); //$NON-NLS-1$ TODO getWorkbench().getDisplay().asyncExec(new Runnable() { public void run() { MessageDialog dlg = new MessageDialog(getWorkbench().getActiveWorkbenchWindow().getShell(), "LSLForge Native Executable Problem", //$NON-NLS-1$ TODO null, buf.toString(), MessageDialog.ERROR, new String[] { "Ok" }, //$NON-NLS-1$ TODO 0); dlg.open(); } }); return false; }
From source file:lslplus.LslPlusPlugin.java
License:Open Source License
private boolean determineExecutable() { String path = getDefault().getPreferenceStore().getString(LSLPLUS_NATIVE_PATH); String preferredVersion = null; String embeddedVersion = null; String installedVersion = null; if (path != null && !"".equals(path.trim())) { //$NON-NLS-1$ preferredVersion = tryTask("Version", path); //$NON-NLS-1$ if (checkVersion(preferredVersion)) { setExecutablePath(path);/*from w w w .j a v a 2 s. c o m*/ return true; } } URL url = FileLocator.find(getDefault().getBundle(), preferredNativePath(), null); if (url != null) { try { path = FileLocator.toFileURL(url).getFile(); embeddedVersion = tryTask("Version", path); //$NON-NLS-1$ if (checkVersion(embeddedVersion)) { setExecutablePath(path); return true; } } catch (IOException e) { Util.error(e, "can't locate " + url); //$NON-NLS-1$ } } url = FileLocator.find(getDefault().getBundle(), alternateNativePath(), null); if (url != null) { try { path = FileLocator.toFileURL(url).getFile(); embeddedVersion = tryTask("Version", path); //$NON-NLS-1$ if (checkVersion(embeddedVersion)) { setExecutablePath(path); return true; } } catch (IOException e) { Util.error(e, "can't locate " + url); //$NON-NLS-1$ } } installedVersion = tryTask("Version", LSL_COMMAND); //$NON-NLS-1$ if (checkVersion(installedVersion)) { setExecutablePath(LSL_COMMAND); return true; } StringBuilder versions = new StringBuilder(); boolean versionFound = false; if (preferredVersion != null) { versions.append(preferredVersion).append(" (version of executable set in LSL Plus Preferences)\n"); //$NON-NLS-1$ TODO versionFound = true; } if (embeddedVersion != null) { versions.append(embeddedVersion).append(" (version installed as part of plugin)\n"); //$NON-NLS-1$ TODO versionFound = true; } if (installedVersion != null) { versions.append(installedVersion).append(" (version found on PATH)\n"); //$NON-NLS-1$ TODO versionFound = true; } final StringBuilder buf = new StringBuilder(); if (versionFound) { buf.append("The following versions of the LSL Plus native executable were found:\n"); //$NON-NLS-1$ TODO buf.append(versions); buf.append("\nNone of these version are compatible with this plugin, which requires\n"); //$NON-NLS-1$ TODO buf.append("version ").append(LSLPLUS_CORE_VERSION).append(".\n"); //$NON-NLS-1$//$NON-NLS-2$ TODO } else { buf.append("The LSL Plus native executable was not found!\n"); //$NON-NLS-1$ TODO } buf.append("The LSLPlus native executable is available from Hackage:\n"); //$NON-NLS-1$ TODO buf.append("http://hackage.haskell.org/cgi-bin/hackage-scripts/pacakge/LslPlus\n\n"); //$NON-NLS-1$ TODO buf.append("Please also see the Help documentation for LSL Plus, under 'Installation'"); //$NON-NLS-1$ TODO getWorkbench().getDisplay().asyncExec(new Runnable() { public void run() { MessageDialog dlg = new MessageDialog(getWorkbench().getActiveWorkbenchWindow().getShell(), "LSL Plus Native Executable Problem", //$NON-NLS-1$ TODO null, buf.toString(), MessageDialog.ERROR, new String[] { "Ok" }, //$NON-NLS-1$ TODO 0); dlg.open(); } }); return false; }
From source file:melnorme.lang.ide.ui.utils.UIOperationErrorHandlerImpl.java
License:Open Source License
public void handleStatus(boolean logError, Shell shell, String title, StatusException status) { if (logError) { LangCore.logStatusException(status); }/*from w w w. j a v a 2 s .c o m*/ if (shell == null) { shell = WorkbenchUtils.getActiveWorkbenchShell(); } assertNotNull(shell); if (status.getCause() == null) { // No point in using ErrorDialog, use simpler dialog openMessageDialog(MessageDialog.ERROR, shell, title, status.getMessage()); return; } openErrorDialog(shell, title, status); }
From source file:melnorme.util.swt.SWTUtil.java
License:Open Source License
public static int statusLevelToMessageDialogKing(StatusLevel statusLevel) { switch (statusLevel) { case ERROR:/* w w w .j a v a 2 s . c o m*/ return MessageDialog.ERROR; case WARNING: return MessageDialog.WARNING; case INFO: return MessageDialog.INFORMATION; case OK: return MessageDialog.OK; } throw assertFail(); }