List of usage examples for org.eclipse.jface.dialogs MessageDialog setBlockOnOpen
public void setBlockOnOpen(boolean shouldBlock)
open
method should block until the window closes. From source file:ch.elexis.core.ui.Hub.java
License:Open Source License
/** * Programmende// www .j a va2s . c o m */ public static void postShutdown() { // shutdownjobs are executed after the workbench has been shut down. // So those jobs must not use any of the workbench's resources. if ((shutdownJobs != null) && (shutdownJobs.size() > 0)) { Shell shell = new Shell(Display.getDefault()); MessageDialog dlg = new MessageDialog(shell, Messages.Hub_title_configuration, Dialog.getDefaultImage(), Messages.Hub_message_configuration, SWT.ICON_INFORMATION, new String[] {}, 0); dlg.setBlockOnOpen(false); dlg.open(); for (ShutdownJob job : shutdownJobs) { try { job.doit(); } catch (Exception e) { log.error("Error starting job: " + e.getMessage()); } } dlg.close(); } }
From source file:ch.elexis.Hub.java
License:Open Source License
/** * Programmende/*from ww w . j a va 2s . c o m*/ */ public static void postShutdown() { // heart.stop(); // JobPool.getJobPool().dispose(); if (Hub.actUser != null) { Anwender.logoff(); } if (globalCfg != null) { // We should not flush at this point, since this might // overwrite other client's // settings // acl.flush(); // globalCfg.flush(); } // shutdownjobs are executed after the workbench has been shut down. // So those jobs must not use any of the workbench's resources. if ((shutdownJobs != null) && (shutdownJobs.size() > 0)) { Shell shell = new Shell(Display.getDefault()); MessageDialog dlg = new MessageDialog(shell, Messages.Hub_title_configuration, Dialog.getDefaultImage(), Messages.Hub_message_configuration, SWT.ICON_INFORMATION, new String[] {}, 0); dlg.setBlockOnOpen(false); dlg.open(); for (ShutdownJob job : shutdownJobs) { try { job.doit(); } catch (Exception e) { log.log("Error starting job: " + e.getMessage(), Log.ERRORS); } } dlg.close(); } }
From source file:com.arc.cdt.debug.seecode.ui.UISeeCodePlugin.java
License:Open Source License
/** * Show an note box.// w w w . ja v a 2 s. co m * (We use JFace ErrorDialog instead of MessageBox. The latter is done outside * of Java and the WindowTester framework loses control). * @param title * @param message */ public static void showNote(String title, String message) { Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); MessageDialog dialog = new MessageDialog(shell, title, null, // accept // the // default // window // icon message, MessageDialog.INFORMATION, new String[] { IDialogConstants.OK_LABEL }, 0); dialog.setBlockOnOpen(false); // we want to be able to make box expire // ok is the default dialog.open(); long expireTime = System.currentTimeMillis() + NOTE_TIME_OUT; Display display = shell.getDisplay(); try { while (dialog.getShell() != null && !dialog.getShell().isDisposed() && System.currentTimeMillis() < expireTime) { if (!display.readAndDispatch()) { display.sleep(); } } } finally { if (dialog.getShell() != null && !dialog.getShell().isDisposed()) { dialog.close(); } } }
From source file:com.heroku.eclipse.ui.git.HerokuCredentialsProvider.java
License:Open Source License
/** * Opens a dialog for a single non-user, non-password type item. * @param shell the shell to use/*from w ww . j a v a2 s. co m*/ * @param uri the uri of the get request * @param item the item to handle * @return <code>true</code> if the request was successful and values were supplied; * <code>false</code> if the user canceled the request and did not supply all requested values. */ private boolean getSingleSpecial(Shell shell, URIish uri, CredentialItem item) { if (item instanceof CredentialItem.InformationalMessage) { MessageDialog.openInformation(shell, UIText.EGitCredentialsProvider_information, item.getPromptText()); return true; } else if (item instanceof CredentialItem.YesNoType) { CredentialItem.YesNoType v = (CredentialItem.YesNoType) item; String[] labels = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }; int[] resultIDs = new int[] { IDialogConstants.YES_ID, IDialogConstants.NO_ID, IDialogConstants.CANCEL_ID }; MessageDialog dialog = new MessageDialog(shell, UIText.EGitCredentialsProvider_question, null, item.getPromptText(), MessageDialog.QUESTION_WITH_CANCEL, labels, 0); dialog.setBlockOnOpen(true); int r = dialog.open(); if (r < 0) { return false; } switch (resultIDs[r]) { case IDialogConstants.YES_ID: { v.setValue(true); return true; } case IDialogConstants.NO_ID: { v.setValue(false); return true; } default: // abort return false; } } else { // generically handles all other types of items return getMultiSpecial(shell, uri, item); } }
From source file:com.mentor.nucleus.bp.core.util.UIUtil.java
License:Open Source License
/** * Note this "MessageDialog" currently only supports an array of 2 dialog button * labels. This is why the result is a boolean. It simply behaves in * a similar manner as if a yes/no question had been asked (offset 0 is * yes and offset 1 is no). If additional buttons are ever needed this * will need to be modified to handle it. *//* ww w . j a v a 2 s. c o m*/ public static boolean openMessageDialog(Shell parentShell, String dialogTitle, Image dialogTitleImage, String dialogMessage, BPMessageTypes dialogType, String[] dialogButtonLabels, int defaultIndex) { int standardDialogType = MessageDialog.WARNING; if (dialogType == BPMessageTypes.ERROR) { standardDialogType = MessageDialog.ERROR; } else if ((dialogType == BPMessageTypes.INFORMATION)) { standardDialogType = MessageDialog.INFORMATION; } boolean result = (defaultIndex == MessageDialog.OK); if (CoreUtil.IsRunningHeadless) { outputTextForheadlessRun(dialogType, dialogTitle, dialogMessage, ""); } else { MessageDialog dialog = new MessageDialog(parentShell, dialogTitle, dialogTitleImage, dialogMessage, standardDialogType, dialogButtonLabels, defaultIndex); dialog.setBlockOnOpen(true); int actualResult = dialog.open(); result = MessageDialog.OK == actualResult; } return result; }
From source file:com.vectrace.MercurialEclipse.dialogs.CommitDialog.java
License:Open Source License
private boolean confirmHistoryRewrite() { if (HgFeatures.PHASES.isEnabled()) { // For secret or draft silently allow amend if (Phase.PUBLIC == currentChangeset.getPhase()) { if (!MessageDialog.openConfirm(getShell(), Messages.getString("CommitDialog.amendPublic.title"), Messages.getString("CommitDialog.amendPublic.message"))) { return false; }/*from w w w.j av a2 s . c om*/ currentChangeset.setDraft(); } return true; } // Always prompt if phases are not supported MessageDialog dialog = new MessageDialog(getShell(), Messages.getString("CommitDialog.reallyAmendAndRewriteHistory"), //$NON-NLS-1$ null, Messages.getString("CommitDialog.amendWarning1") //$NON-NLS-1$ + Messages.getString("CommitDialog.amendWarning2") //$NON-NLS-1$ + Messages.getString("CommitDialog.amendWarning3"), //$NON-NLS-1$ MessageDialog.CONFIRM, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.CANCEL_LABEL }, 1 // default index - cancel ); dialog.setBlockOnOpen(true); // if false then may show in background return dialog.open() == 0; // 0 means yes }
From source file:com.vectrace.MercurialEclipse.menu.UpdateJob.java
License:Open Source License
/** * Call from the UI thread./*from w ww. j a v a2 s . c om*/ * @return True if loss was confirmed. */ private static boolean showConfirmDataLoss(Shell shell) { MessageDialog dialog = new MessageDialog(shell, Messages.getString("UpdateJob.uncommittedChanges1"), null, Messages.getString("UpdateJob.uncommittedChanges2"), MessageDialog.CONFIRM, new String[] { Messages.getString("UpdateJob.continueAndDiscard"), IDialogConstants.CANCEL_LABEL }, 1 // default index - cancel ); dialog.setBlockOnOpen(true); return dialog.open() == 0; }
From source file:cu.uci.abos.core.util.MessageDialogUtil.java
License:Open Source License
private static void open(int kind, Shell parent, String title, String message, final DialogCallback callback) { String[] buttonLabels = getButtonLabels(kind); MessageDialog dialog = new MessageDialog(parent, title, null, message, kind, buttonLabels, 0) { private static final long serialVersionUID = 1L; @Override//from w w w . j a v a 2s. co m protected int getShellStyle() { return super.getShellStyle() | SWT.SHEET; } @Override public boolean close() { boolean result = super.close(); if (callback != null) { callback.dialogClosed(getReturnCode()); } return result; } }; dialog.setBlockOnOpen(false); dialog.open(); }
From source file:eu.hydrologis.jgrass.console.editor.actions.ConsoleEditorActionCompile.java
License:Open Source License
public void run() { Display.getDefault().asyncExec(new Runnable() { public void run() { JGrass console = ConsolePlugin.console(); if (null == console) { MessageDialog dialog = new MessageDialog(null, "Info", null, "Missing JGrass ConsoleEngine.", MessageDialog.INFORMATION, new String[] { "Ok" }, 0); dialog.setBlockOnOpen(true); dialog.open();/*from w w w . ja v a2 s . c o m*/ } else { // JavaEditor editor = (JavaEditor) getTextEditor(); // ProjectOptions projectOptions = editor.projectOptions(); // PreferencesInitializer.initialize(projectOptions); // projectOptions // .setOption(ProjectOptions.CONSOLE_COMPILE_ONLY, new Boolean(true)); // IDocument doc = editor.getDocumentProvider().getDocument( // editor.getEditorInput()); // editor.getTextConsole().clearConsole(); // console.dispatch(projectOptions, doc.get()); // String text = null; JavaEditor editor = (JavaEditor) getTextEditor(); ISelection selection = editor.getSelectionProvider().getSelection(); if (selection instanceof ITextSelection) { ITextSelection textSelection = (ITextSelection) selection; if (!textSelection.isEmpty()) { text = textSelection.getText(); } } ProjectOptions projectOptions = editor.projectOptions(); PreferencesInitializer.initialize(projectOptions); // FIXME check how GRASS preferences are saved in the preferencespage // Object option = projectOptions.getOption(ProjectOptions.COMMON_GRASS_MAPSET); projectOptions.setOption(ProjectOptions.CONSOLE_COMPILE_ONLY, new Boolean(true)); IDocument doc = editor.getDocumentProvider().getDocument(editor.getEditorInput()); editor.getTextConsole().clearConsole(); if (text == null || 0 >= text.length()) { text = doc.get(); } console.dispatch(projectOptions, text); } } }); }
From source file:eu.hydrologis.jgrass.console.editor.actions.ConsoleEditorActionRun.java
License:Open Source License
public void run() { Display.getDefault().asyncExec(new Runnable() { public void run() { JGrass console = ConsolePlugin.console(); if (null == console) { MessageDialog dialog = new MessageDialog(null, "Info", null, "Missing JGrass ConsoleEngine.", MessageDialog.INFORMATION, new String[] { "Ok" }, 0); dialog.setBlockOnOpen(true); dialog.open();//from w ww. j a v a 2s . c o m } else { JavaEditor editor = (JavaEditor) getTextEditor(); IDocument doc = editor.getDocumentProvider().getDocument(editor.getEditorInput()); editor.getTextConsole().clearConsole(); ProjectOptions projectOptions = editor.projectOptions(); PreferencesInitializer.initialize(projectOptions); projectOptions.setOption(ProjectOptions.CONSOLE_COMPILE_ONLY, new Boolean(false)); String text = null; ISelection selection = editor.getSelectionProvider().getSelection(); if (selection instanceof ITextSelection) { ITextSelection textSelection = (ITextSelection) selection; if (!textSelection.isEmpty()) { text = textSelection.getText(); } } if (text == null || 0 >= text.length()) { text = doc.get(); } if (text != null) { List<String> commandsOnly = new ArrayList<String>(); List<String> settingsOnly = new ArrayList<String>(); // extract only the commands String[] scriptSplit = text.split("\n"); //$NON-NLS-1$ for (String string : scriptSplit) { if (string.trim().startsWith("#")) { continue; } commandsOnly.add(string); } // from the whole document extract the settings, even id not selected String allText = doc.get(); String[] allSplit = allText.split("\n"); //$NON-NLS-1$ for (String string : allSplit) { if (string.trim().startsWith("#")) { settingsOnly.add(string); } } StringBuffer sB = new StringBuffer(); for (String string : settingsOnly) { sB.append(string).append("\n"); } sB.append("\n\n"); for (String string : commandsOnly) { sB.append(string).append("\n"); } text = sB.toString(); } console.dispatch(projectOptions, text); } } }); }