List of usage examples for org.eclipse.jface.dialogs MessageDialog QUESTION
int QUESTION
To view the source code for org.eclipse.jface.dialogs MessageDialog QUESTION.
Click Source Link
From source file:org.eclipse.php.internal.ui.preferences.OptionsConfigurationBlock.java
License:Open Source License
protected boolean processChanges(IWorkbenchPreferenceContainer container) { IScopeContext currContext = fLookupOrder[0]; List<Key> changedOptions = new ArrayList<Key>(); boolean needsBuild = getChanges(currContext, changedOptions); if (changedOptions.isEmpty()) { hasChanges = false;//from w w w.j av a 2 s . com return true; } else { hasChanges = true; } if (!this.checkChanges(currContext)) { // check failed return false; } boolean doBuild = false; if (needsBuild) { String[] strings = getFullBuildDialogStrings(fProject == null); if (strings != null) { MessageDialog dialog = new MessageDialog(getShell(), strings[0], null, strings[1], MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 2); int res = dialog.open(); if (res == 0) { doBuild = true; } else if (res != 1) { return false; // cancel pressed } } } if (doBuild) { prepareForBuild(); } if (container != null) { // no need to apply the changes to the original store: will be done // by the page container if (doBuild) { // post build container.registerUpdateJob(CoreUtility.getBuildJob(fProject)); } } else { // apply changes right away try { fManager.applyChanges(); } catch (BackingStoreException e) { PHPUiPlugin.log(e); return false; } if (doBuild) { CoreUtility.getBuildJob(fProject).schedule(); } } return true; }
From source file:org.eclipse.php.internal.ui.wizards.types.NewPHPTraitPage.java
License:Open Source License
/** * This method was overriden to handle cases in which project's PHP version * is less than 5//ww w .j a v a 2 s . c o m */ @Override public void setVisible(boolean visible) { if (!visible) { super.setVisible(visible); return; } // close the wizard if it is PHP4 project and user selected not to // continue getShell().getDisplay().asyncExec(() -> { if (phpVersion.isLessThan(PHPVersion.PHP5_4)) { MessageDialog dialog = new MessageDialog(getShell(), phpVersion.getAlias().toUpperCase() + Messages.NewPHPTraitPage_4, null, Messages.NewPHPTraitPage_5 + phpVersion.getAlias().toUpperCase() + Messages.NewPHPTraitPage_6, MessageDialog.QUESTION, new String[] { Messages.NewPHPTraitPage_7, Messages.NewPHPTraitPage_8 }, 0); int res = dialog.open(); if (res != 0) {// NO clicked WizardDialog wizardDialog = (WizardDialog) getContainer(); wizardDialog.close(); } } }); super.setVisible(visible); }
From source file:org.eclipse.ptp.etfw.tau.selinst.popup.actions.IncrementInstrument.java
License:Open Source License
public static String getPhaseTimeLine(String file, int start, int stop) { class ValidateName implements IInputValidator { public String isValid(String newText) { if (newText.equals("")) { return Messages.IncrementInstrument_EnterValidText; }/*from ww w. java 2 s . co m*/ return null; } } final String[] opts = { "static timer", "dynamic timer", "static phase", "dynamic phase", //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$ Messages.IncrementInstrument_Cancel }; final MessageDialog timephase = new MessageDialog(CUIPlugin.getActiveWorkbenchShell(), Messages.IncrementInstrument_InstTypeSelect, null, Messages.IncrementInstrument_SelectOneOfFollowing, MessageDialog.QUESTION, opts, 0); if (timephase.open() == 4) { return null; } final int optline = timephase.getReturnCode(); final InputDialog namedialog = new InputDialog(CUIPlugin.getActiveWorkbenchShell(), Messages.IncrementInstrument_UserDefEventName, Messages.IncrementInstrument_EnterUniqueName, "", new ValidateName()); if (namedialog.open() == Window.CANCEL) { return null; } final String testline = namedialog.getValue(); return opts[optline] + " name=\"TAU__" + testline.replaceAll("\\W", "") + "\" file=\"" + file + "\" line=" //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$//$NON-NLS-5$ + start + " to line=" + stop; //$NON-NLS-1$ }
From source file:org.eclipse.qvt.declarative.editor.ui.commands.PageChangeDialog.java
License:Open Source License
public PageChangeDialog(Shell shell, String newTitle, String oldTitle, String fileName, String reasonNotToDeactivate, boolean canUpdate, boolean canRevert) { super(shell, "Update " + fileName + " Resource", null, null, reasonNotToDeactivate != null ? MessageDialog.ERROR : MessageDialog.QUESTION, buttonLabels, reasonNotToDeactivate != null ? RESUME_BUTTON : UPDATE_BUTTON); this.canRevert = canRevert; this.canUpdate = canUpdate; StringBuffer s = new StringBuffer(); if (reasonNotToDeactivate != null) s.append(reasonNotToDeactivate + "\n"); else/*from w ww . jav a2s .c o m*/ s.append("'" + oldTitle + "' page has been modified.\n"); s.append("\n Update - accept changes to '" + oldTitle + "' page"); // if (!canAbort) // s.append("\n - start editing '" + newTitle + "' page"); // else { s.append("\n - reconcile and edit '" + newTitle + "' page"); s.append("\n\n Revert - discard changes to '" + oldTitle + "' page"); s.append("\n - revert to editing '" + newTitle + "' page"); // } s.append("\n\n Resume - continue editing '" + oldTitle + "' page"); message = s.toString(); }
From source file:org.eclipse.rap.examples.pages.MessageDialogUtil.java
License:Open Source License
private static String[] getButtonLabels(int kind) { String[] dialogButtonLabels;/*ww w. j av a 2 s . co m*/ switch (kind) { case MessageDialog.ERROR: case MessageDialog.INFORMATION: case MessageDialog.WARNING: { dialogButtonLabels = new String[] { IDialogConstants.get().OK_LABEL }; break; } case MessageDialog.CONFIRM: { dialogButtonLabels = new String[] { IDialogConstants.get().OK_LABEL, IDialogConstants.get().CANCEL_LABEL }; break; } case MessageDialog.QUESTION: { dialogButtonLabels = new String[] { IDialogConstants.get().YES_LABEL, IDialogConstants.get().NO_LABEL }; break; } case MessageDialog.QUESTION_WITH_CANCEL: { dialogButtonLabels = new String[] { IDialogConstants.get().YES_LABEL, IDialogConstants.get().NO_LABEL, IDialogConstants.get().CANCEL_LABEL }; break; } default: { throw new IllegalArgumentException("Illegal value for kind in MessageDialog.open()"); } } return dialogButtonLabels; }
From source file:org.eclipse.rap.ui.internal.launch.PortBusyStatusHandler.java
License:Open Source License
public Object handleStatus(final IStatus status, final Object source) throws CoreException { RAPLaunchConfig config = (RAPLaunchConfig) source; String title = LaunchMessages.PortBusyStatusHandler_PortInUseTitle; String text = LaunchMessages.PortBusyStatusHandler_PortInUseMessage; Object[] args = new Object[] { new Integer(config.getPort()), config.getName() }; String msg = MessageFormat.format(text, args); String[] buttons = new String[] { IDialogConstants.PROCEED_LABEL, IDialogConstants.CANCEL_LABEL }; MessageDialog dialog = new MessageDialog(getShell(), title, null, msg, MessageDialog.QUESTION, buttons, 0); Boolean result;// ww w . jav a 2 s . c om if (dialog.open() == IDialogConstants.OK_ID) { result = Boolean.TRUE; } else { result = Boolean.FALSE; } return result; }
From source file:org.eclipse.rcptt.ui.actions.edit.PasteAction.java
License:Open Source License
/** * Check if the user wishes to overwrite the supplied resource or all * resources. Copied from//from ww w .j a va2 s . com * org.eclipse.ui.actions.CopyFilesAndFoldersOperation. * * @param source * the source resource * @param destination * the resource to be overwritten * @return one of IDialogConstants.YES_ID, IDialogConstants.YES_TO_ALL_ID, * IDialogConstants.NO_ID, IDialogConstants.CANCEL_ID indicating * whether the current resource or all resources can be overwritten, * or if the operation should be canceled. */ private int checkOverwrite(final IResource source, final IResource destination) { final int[] result = new int[1]; // Dialogs need to be created and opened in the UI thread Runnable query = new Runnable() { public void run() { String message; int resultId[] = { IDialogConstants.YES_ID, IDialogConstants.YES_TO_ALL_ID, IDialogConstants.NO_ID, IDialogConstants.CANCEL_ID }; String labels[] = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }; String[] bindings = new String[] { IDEResourceInfoUtils.getLocationText(destination), IDEResourceInfoUtils.getDateStringValue(destination), IDEResourceInfoUtils.getLocationText(source), IDEResourceInfoUtils.getDateStringValue(source) }; message = NLS.bind(IDEWorkbenchMessages.CopyFilesAndFoldersOperation_overwriteWithDetailsQuestion, bindings); MessageDialog dialog = new MessageDialog(shell, IDEWorkbenchMessages.CopyFilesAndFoldersOperation_resourceExists, null, message, MessageDialog.QUESTION, labels, 0) { protected int getShellStyle() { return super.getShellStyle() | SWT.SHEET; } }; dialog.open(); if (dialog.getReturnCode() == SWT.DEFAULT) { // A window close returns SWT.DEFAULT, which has to be // mapped to a cancel result[0] = IDialogConstants.CANCEL_ID; } else { result[0] = resultId[dialog.getReturnCode()]; } } }; shell.getDisplay().syncExec(query); return result[0]; }
From source file:org.eclipse.rcptt.ui.actions.edit.Q7CopyFilesAndFoldersOperation.java
License:Open Source License
/** * Check if the user wishes to overwrite the supplied resource or all * resources./*w ww.j a v a2s . c o m*/ * * @param source * the source resource * @param destination * the resource to be overwritten * @return one of IDialogConstants.YES_ID, IDialogConstants.YES_TO_ALL_ID, * IDialogConstants.NO_ID, IDialogConstants.CANCEL_ID indicating * whether the current resource or all resources can be overwritten, * or if the operation should be canceled. */ private int checkOverwrite(final IResource source, final IResource destination) { final int[] result = new int[1]; // Dialogs need to be created and opened in the UI thread Runnable query = new Runnable() { @SuppressWarnings("restriction") public void run() { String message; int resultId[] = { IDialogConstants.YES_ID, IDialogConstants.YES_TO_ALL_ID, IDialogConstants.NO_ID, IDialogConstants.CANCEL_ID }; String labels[] = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }; if (destination.getType() == IResource.FOLDER) { if (homogenousResources(source, destination)) { message = NLS.bind( org.eclipse.ui.internal.ide.IDEWorkbenchMessages.CopyFilesAndFoldersOperation_overwriteMergeQuestion, destination.getFullPath().makeRelative()); } else { if (destination.isLinked()) { message = NLS.bind( org.eclipse.ui.internal.ide.IDEWorkbenchMessages.CopyFilesAndFoldersOperation_overwriteNoMergeLinkQuestion, destination.getFullPath().makeRelative()); } else { message = NLS.bind( org.eclipse.ui.internal.ide.IDEWorkbenchMessages.CopyFilesAndFoldersOperation_overwriteNoMergeNoLinkQuestion, destination.getFullPath().makeRelative()); } resultId = new int[] { IDialogConstants.YES_ID, IDialogConstants.NO_ID, IDialogConstants.CANCEL_ID }; labels = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }; } } else { String[] bindings = new String[] { org.eclipse.ui.internal.ide.dialogs.IDEResourceInfoUtils.getLocationText(destination), org.eclipse.ui.internal.ide.dialogs.IDEResourceInfoUtils .getDateStringValue(destination), org.eclipse.ui.internal.ide.dialogs.IDEResourceInfoUtils.getLocationText(source), org.eclipse.ui.internal.ide.dialogs.IDEResourceInfoUtils.getDateStringValue(source) }; message = NLS.bind( org.eclipse.ui.internal.ide.IDEWorkbenchMessages.CopyFilesAndFoldersOperation_overwriteWithDetailsQuestion, bindings); } MessageDialog dialog = new MessageDialog(messageShell, org.eclipse.ui.internal.ide.IDEWorkbenchMessages.CopyFilesAndFoldersOperation_resourceExists, null, message, MessageDialog.QUESTION, labels, 0) { protected int getShellStyle() { return super.getShellStyle() | SWT.SHEET; } }; dialog.open(); if (dialog.getReturnCode() == SWT.DEFAULT) { // A window close returns SWT.DEFAULT, which has to be // mapped to a cancel result[0] = IDialogConstants.CANCEL_ID; } else { result[0] = resultId[dialog.getReturnCode()]; } } }; messageShell.getDisplay().syncExec(query); return result[0]; }
From source file:org.eclipse.rcptt.ui.actions.edit.Q7CopyFilesAndFoldersOperation.java
License:Open Source License
/** * Performs an import of the given stores into the provided container. * Returns a status indicating if the import was successful. * /* w w w. j a v a 2 s . c o m*/ * @param stores * stores that are to be imported * @param target * container to which the import will be done * @param monitor * a progress monitor for showing progress and for cancelation */ private void performFileImport(IFileStore[] stores, IContainer target, IProgressMonitor monitor) { IOverwriteQuery query = new IOverwriteQuery() { @SuppressWarnings("restriction") public String queryOverwrite(String pathString) { if (alwaysOverwrite) { return ALL; } final String returnCode[] = { CANCEL }; final String msg = NLS.bind( org.eclipse.ui.internal.ide.IDEWorkbenchMessages.CopyFilesAndFoldersOperation_overwriteQuestion, pathString); final String[] options = { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }; messageShell.getDisplay().syncExec(new Runnable() { public void run() { MessageDialog dialog = new MessageDialog(messageShell, org.eclipse.ui.internal.ide.IDEWorkbenchMessages.CopyFilesAndFoldersOperation_question, null, msg, MessageDialog.QUESTION, options, 0) { protected int getShellStyle() { return super.getShellStyle() | SWT.SHEET; } }; dialog.open(); int returnVal = dialog.getReturnCode(); String[] returnCodes = { YES, ALL, NO, CANCEL }; returnCode[0] = returnVal == -1 ? CANCEL : returnCodes[returnVal]; } }); if (returnCode[0] == ALL) { alwaysOverwrite = true; } else if (returnCode[0] == CANCEL) { canceled = true; } return returnCode[0]; } }; ImportOperation op = new ImportOperation(target.getFullPath(), stores[0].getParent(), FileStoreStructureProvider.INSTANCE, query, Arrays.asList(stores)); op.setContext(messageShell); op.setCreateContainerStructure(false); op.setVirtualFolders(createVirtualFoldersAndLinks); op.setCreateLinks(createLinks); op.setRelativeVariable(relativeVariable); try { op.run(monitor); } catch (InterruptedException e) { return; } catch (InvocationTargetException e) { if (e.getTargetException() instanceof CoreException) { displayError(((CoreException) e.getTargetException()).getStatus()); } else { display(e); } return; } // Special case since ImportOperation doesn't throw a CoreException on // failure. IStatus status = op.getStatus(); if (!status.isOK()) { if (errorStatus == null) { errorStatus = new MultiStatus(PlatformUI.PLUGIN_ID, IStatus.ERROR, getProblemsMessage(), null); } errorStatus.merge(status); } }
From source file:org.eclipse.rcptt.ui.launching.aut.BasicAUTComposite.java
License:Open Source License
public void removeAUT() { List<AutElement> elements = new ArrayList<AutElement>(); ISelection selection = viewer.getSelection(); if (selection instanceof IStructuredSelection) { Iterator<?> i = ((IStructuredSelection) selection).iterator(); while (i.hasNext()) { Object next = i.next(); elements.add((AutElement) next); }//from w ww .j ava 2s. c o m } if (elements.size() != 0) { StringBuilder names = new StringBuilder(); for (AutElement iautElement : elements) { if (names.length() > 0) { names.append(", "); } names.append(iautElement.getName()); } MessageDialog dialog = new MessageDialog(viewer.getControl().getShell(), getMessageTitle(), null, MessageFormat.format(Messages.BasicAUTComposite_RemoveApprovalMsg, names.toString()), MessageDialog.QUESTION, new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 0) { }; int value = dialog.open(); if (value == MessageDialog.OK) { for (AutElement element : elements) { try { element.remove(); } catch (CoreException e) { Q7UIPlugin.log(e); } } } } }