List of usage examples for org.eclipse.jface.dialogs IDialogConstants NO_LABEL
String NO_LABEL
To view the source code for org.eclipse.jface.dialogs IDialogConstants NO_LABEL.
Click Source Link
From source file:org.eclipse.ui.tests.dialogs.UIMessageDialogsAuto.java
License:Open Source License
public void testSaveAsOverwrite() { Dialog dialog = new MessageDialog(getShell(), "WorkbenchMessages.Question", null, DUMMY_RELATIVE_PATH, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 0);/* w w w . j a v a 2 s . c o m*/ DialogCheck.assertDialogTexts(dialog, this); }
From source file:org.eclipse.ui.tests.dialogs.UIMessageDialogsAuto.java
License:Open Source License
public void testSaveChanges() { Dialog dialog = new MessageDialog(getShell(), WorkbenchMessages.Save_Resource, null, NLS.bind(WorkbenchMessages.EditorManager_saveChangesQuestion, (new Object[] { DUMMY_RESOURCE })), MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 0);/*from w w w .j a va 2 s. c o m*/ DialogCheck.assertDialogTexts(dialog, this); }
From source file:org.eclipse.ui.tests.dialogs.UIMessageDialogsAuto.java
License:Open Source License
public void testWizardOverwrite() { Dialog dialog = new MessageDialog(getShell(), "WorkbenchMessages.Question", null, "WizardDataTransfer_existsQuestion", MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 0);/*from w ww. j a v a 2 s .c o m*/ DialogCheck.assertDialogTexts(dialog, this); }
From source file:org.eclipse.ui.texteditor.AbstractDecoratedTextEditor.java
License:Open Source License
/** * This implementation asks the user for the workspace path of a file resource and saves the document there. * * @param progressMonitor the progress monitor to be used * @since 3.2// w w w .j a v a 2s .c om */ protected void performSaveAs(IProgressMonitor progressMonitor) { Shell shell = PlatformUI.getWorkbench().getModalDialogShellProvider().getShell(); final IEditorInput input = getEditorInput(); IDocumentProvider provider = getDocumentProvider(); final IEditorInput newInput; if (input instanceof IURIEditorInput && !(input instanceof IFileEditorInput)) { FileDialog dialog = new FileDialog(shell, SWT.SAVE); IPath oldPath = URIUtil.toPath(((IURIEditorInput) input).getURI()); if (oldPath != null) { dialog.setFileName(oldPath.lastSegment()); dialog.setFilterPath(oldPath.toOSString()); } String path = dialog.open(); if (path == null) { if (progressMonitor != null) progressMonitor.setCanceled(true); return; } // Check whether file exists and if so, confirm overwrite final File localFile = new File(path); if (localFile.exists()) { MessageDialog overwriteDialog = new MessageDialog(shell, TextEditorMessages.AbstractDecoratedTextEditor_saveAs_overwrite_title, null, NLSUtility.format(TextEditorMessages.AbstractDecoratedTextEditor_saveAs_overwrite_message, path), MessageDialog.WARNING, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 1); // 'No' is the default if (overwriteDialog.open() != Window.OK) { if (progressMonitor != null) { progressMonitor.setCanceled(true); return; } } } IFileStore fileStore; try { fileStore = EFS.getStore(localFile.toURI()); } catch (CoreException ex) { EditorsPlugin.log(ex.getStatus()); String title = TextEditorMessages.AbstractDecoratedTextEditor_error_saveAs_title; String msg = NLSUtility.format(TextEditorMessages.AbstractDecoratedTextEditor_error_saveAs_message, ex.getMessage()); MessageDialog.openError(shell, title, msg); return; } IFile file = getWorkspaceFile(fileStore); if (file != null) newInput = new FileEditorInput(file); else newInput = new FileStoreEditorInput(fileStore); } else { SaveAsDialog dialog = new SaveAsDialog(shell); IFile original = (input instanceof IFileEditorInput) ? ((IFileEditorInput) input).getFile() : null; if (original != null) dialog.setOriginalFile(original); else dialog.setOriginalName(input.getName()); dialog.create(); if (provider.isDeleted(input) && original != null) { String message = NLSUtility.format( TextEditorMessages.AbstractDecoratedTextEditor_warning_saveAs_deleted, original.getName()); dialog.setErrorMessage(null); dialog.setMessage(message, IMessageProvider.WARNING); } if (dialog.open() == Window.CANCEL) { if (progressMonitor != null) progressMonitor.setCanceled(true); return; } IPath filePath = dialog.getResult(); if (filePath == null) { if (progressMonitor != null) progressMonitor.setCanceled(true); return; } IWorkspace workspace = ResourcesPlugin.getWorkspace(); IFile file = workspace.getRoot().getFile(filePath); newInput = new FileEditorInput(file); } if (provider == null) { // editor has programmatically been closed while the dialog was open return; } boolean success = false; try { provider.aboutToChange(newInput); provider.saveDocument(progressMonitor, newInput, provider.getDocument(input), true); success = true; } catch (CoreException x) { final IStatus status = x.getStatus(); if (status == null || status.getSeverity() != IStatus.CANCEL) { String title = TextEditorMessages.AbstractDecoratedTextEditor_error_saveAs_title; String msg = NLSUtility.format(TextEditorMessages.AbstractDecoratedTextEditor_error_saveAs_message, x.getMessage()); MessageDialog.openError(shell, title, msg); } } finally { provider.changed(newInput); if (success) setInput(newInput); } if (progressMonitor != null) progressMonitor.setCanceled(!success); }
From source file:org.eclipse.vex.ui.internal.editor.VexEditor.java
License:Open Source License
/** * Asks the user for the workspace path of a file resource and saves the document there. * * @param progressMonitor//w ww .j a va 2 s .c o m * the monitor in which to run the operation */ protected void performSaveAs(final IProgressMonitor progressMonitor) { final Shell shell = PlatformUI.getWorkbench().getModalDialogShellProvider().getShell(); final IDocumentProvider provider = getDocumentProvider(); final IEditorInput input = getEditorInput(); final IEditorInput newInput; if (input instanceof IURIEditorInput && !(input instanceof IFileEditorInput)) { final FileDialog dialog = new FileDialog(shell, SWT.SAVE); final IPath oldPath = URIUtil.toPath(((IURIEditorInput) input).getURI()); if (oldPath != null) { dialog.setFileName(oldPath.lastSegment()); dialog.setFilterPath(oldPath.toOSString()); } final String path = dialog.open(); if (path == null) { if (progressMonitor != null) { progressMonitor.setCanceled(true); } return; } // Check whether file exists and if so, confirm overwrite final File localFile = new File(path); if (localFile.exists()) { final String title = Messages.getString("VexEditor.saveAs.overwrite.title"); final String message = MessageFormat .format(Messages.getString("VexEditor.saveAs.overwrite.message"), path); final MessageDialog overwriteDialog = new MessageDialog(shell, title, null, message, MessageDialog.WARNING, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 1); // 'No' is the default if (overwriteDialog.open() != Window.OK) { if (progressMonitor != null) { progressMonitor.setCanceled(true); return; } } } IFileStore fileStore; try { fileStore = EFS.getStore(localFile.toURI()); } catch (final CoreException ex) { VexPlugin.getDefault().log(IStatus.ERROR, ex.getLocalizedMessage(), ex); final String title = Messages.getString("VexEditor.saveAs.error.title"); final String msg = MessageFormat.format(Messages.getString("VexEditor.saveAs.error.message"), ex.getLocalizedMessage()); MessageDialog.openError(shell, title, msg); return; } final IFile file = getWorkspaceFile(fileStore); if (file != null) { newInput = new FileEditorInput(file); } else { newInput = new FileStoreEditorInput(fileStore); } } else { final SaveAsDialog dialog = new SaveAsDialog(shell); final IFile original = input instanceof IFileEditorInput ? ((IFileEditorInput) input).getFile() : null; if (original != null) { dialog.setOriginalFile(original); } else { dialog.setOriginalName(input.getName()); } dialog.create(); if (provider.isDeleted(input) && original != null) { final String msg = MessageFormat.format(Messages.getString("VexEditor.saveAs.deleted"), original.getName()); dialog.setErrorMessage(null); dialog.setMessage(msg, IMessageProvider.WARNING); } if (dialog.open() == Window.CANCEL) { if (progressMonitor != null) { progressMonitor.setCanceled(true); } return; } final IPath filePath = dialog.getResult(); if (filePath == null) { if (progressMonitor != null) { progressMonitor.setCanceled(true); } return; } final IWorkspace workspace = ResourcesPlugin.getWorkspace(); final IFile file = workspace.getRoot().getFile(filePath); newInput = new FileEditorInput(file); } if (provider == null) { // editor has programmatically been closed while the dialog was open return; } boolean success = false; try { provider.aboutToChange(newInput); syncDocumentProvider(); provider.saveDocument(progressMonitor, newInput, provider.getDocument(input), true); success = true; } catch (final CoreException ex) { final IStatus status = ex.getStatus(); if (status == null || status.getSeverity() != IStatus.CANCEL) { VexPlugin.getDefault().log(IStatus.ERROR, ex.getLocalizedMessage(), ex); final String title = Messages.getString("VexEditor.saveAs.error.title"); final String msg = MessageFormat.format(Messages.getString("VexEditor.saveAs.error.message"), ex.getLocalizedMessage()); MessageDialog.openError(shell, title, msg); } } finally { provider.changed(newInput); if (success) { setInput(newInput); setClean(); } } if (progressMonitor != null) { progressMonitor.setCanceled(!success); } }
From source file:org.eclipse.wb.internal.swing.FormLayout.model.ui.DimensionEditDialog.java
License:Open Source License
/** * Sets the {@link FormDimensionInfo} to edit. *//* w w w.j av a 2 s. c o m*/ private void setEditDimension(T dimension) { try { // apply changes if (m_currentDimension != null && !m_currentDimension.equals2(m_dimension)) { // open dialog int dialogResult; { String title = ModelMessages.DimensionEditDialog_applyConfirmTitle; String message = MessageFormat.format(ModelMessages.DimensionEditDialog_applyConfirmMessage, m_dimensionName); MessageDialog dialog = new MessageDialog(getShell(), title, null, message, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 0); dialogResult = dialog.open(); } // check cancel/yes if (dialogResult == 2) { return; } else if (dialogResult == 0) { applyChanges(); } } // remember new dimension m_currentDimension = dimension; m_dimension = getCopy(dimension); } catch (Throwable e) { DesignerPlugin.log(e); } }
From source file:org.eclipse.wb.tests.designer.editor.UndoManagerTest.java
License:Open Source License
/** * Test edit read-only file.// w ww.j av a 2 s . c o m */ public void test_readOnly_No() throws Exception { test_readOnly(IDialogConstants.NO_LABEL, true, new String[] { "// filler filler filler", "public class Test extends JFrame {", " public Test() {", " }", " void foo() {", " }", "}" }, new String[] { "// filler filler filler", "public class Test extends JFrame {", " public Test() {", " }", "}" }); }
From source file:org.eclipse.wst.common.frameworks.internal.ui.UIOperationHandler.java
License:Open Source License
/** * A decision needs to made as to whether an action/operation can continue. The boolean array * will return two booleans. The first indicates their response to the original question and the * second indicates if they selected the apply to all check box. * /*from ww w . j av a 2 s.co m*/ * Return the return code for the dialog. 0 = Yes, 1 = Yes to all, 2 = No */ public int canContinueWithAllCheck(String message) { MessageDialog dialog = new MessageDialog(getParentShell(), getConfirmTitle(), null, // accept // the // default // window // icon message, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.NO_LABEL }, 1); // yes // is // the // default return dialog.open(); }
From source file:org.eclipse.wst.common.frameworks.internal.ui.UIOperationHandler.java
License:Open Source License
public int canContinueWithAllCheckAllowCancel(String message) { MessageDialog dialog = new MessageDialog(getParentShell(), getConfirmTitle(), null, // accept // the // default // window // icon message, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 1); // yes // is/*www . j a v a2 s .com*/ // the // default return dialog.open(); }
From source file:org.eclipse.wst.common.project.facet.ui.internal.FacetsPropertyPage.java
License:Open Source License
@Override public boolean performOk() { if (this.fpjwc == null) { return true; }/* w ww.j a va2s .c om*/ for (IProjectFacetVersion fv : this.fpjwc.getFacetedProject().getProjectFacets()) { if (fv.getPluginId() == null || fv.getProjectFacet().getPluginId() == null) { final MessageDialog dialog = new MessageDialog(getShell(), Resources.warningDialogTitle, null, Resources.modifyWithUnknownWarningMessage, MessageDialog.WARNING, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 1); if (dialog.open() != Window.OK) { return false; } } } final IWorkspaceRunnable wr = new IWorkspaceRunnable() { public void run(final IProgressMonitor monitor) throws CoreException { FacetsPropertyPage.this.fpjwc.commitChanges(monitor); } }; final IRunnableWithProgress op = new IRunnableWithProgress() { public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { try { final IWorkspace ws = ResourcesPlugin.getWorkspace(); ws.run(wr, ws.getRoot(), IWorkspace.AVOID_UPDATE, monitor); } catch (CoreException e) { throw new InvocationTargetException(e); } } }; try { new ProgressMonitorDialog(getShell()).run(true, false, op); } catch (InterruptedException e) { return false; } catch (InvocationTargetException e) { final Throwable te = e.getTargetException(); if (te instanceof CoreException) { IStatus st = ((CoreException) te).getStatus(); final String msg = st.getMessage(); if (!(te instanceof FacetedProjectFrameworkException) || !((FacetedProjectFrameworkException) te).isExpected()) { FacetUiPlugin.log(st); } final Throwable cause = st.getException(); if (cause instanceof CoreException) { st = ((CoreException) cause).getStatus(); } ErrorDialog.openError(getShell(), Resources.errDlgTitle, msg, st); } else { throw new RuntimeException(te); } } finally { // Take care of the case where all changes could not be applied, such as if the user // rejects a validateEdit request. try { this.fpjwc.revertChanges(); } catch (Exception e) { FacetUiPlugin.log(e); } } return true; }