List of usage examples for org.eclipse.jface.dialogs IDialogConstants YES_LABEL
String YES_LABEL
To view the source code for org.eclipse.jface.dialogs IDialogConstants YES_LABEL.
Click Source Link
From source file:at.bestsolution.efxclipse.tooling.jdt.ui.internal.wizard.clazz.NewHtmlTemplateWizard.java
License:Open Source License
@Override protected IFile createFile() { IPath path;/* w w w. j av a 2 s.c o m*/ IPackageFragment fragment = getDomainClass().getPackageFragment(); if (fragment != null) { String cuName = getDomainClass().getName() + JavaFXUIPlugin.FILEEXTENSION_HTML_TEMPLATE; path = fragment.getPath().append(cuName); } else { String cuName = getDomainClass().getName() + JavaFXUIPlugin.FILEEXTENSION_HTML_TEMPLATE; IFolder p = (IFolder) getDomainClass().getFragmentRoot().getResource(); path = p.getLocation().append(cuName); } // If the path already exists then confirm overwrite. IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path); if (file.exists()) { String[] buttons = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }; String question = NLS.bind(IDEWorkbenchMessages.SaveAsDialog_overwriteQuestion, path.toString()); MessageDialog d = new MessageDialog(getShell(), IDEWorkbenchMessages.Question, null, question, MessageDialog.QUESTION, buttons, 0) { protected int getShellStyle() { return super.getShellStyle() | SWT.SHEET; } }; int overwrite = d.open(); switch (overwrite) { case 0: // Yes break; case 1: // No return null; case 2: // Cancel default: return null; } } return file; }
From source file:com.amalto.workbench.editors.dialog.ConfirmFireEventMessageDialog.java
License:Open Source License
static String[] getButtonLabels(int kind) { String[] dialogButtonLabels;//from www.j a v a2s.c om switch (kind) { case ERROR: case INFORMATION: case WARNING: { dialogButtonLabels = new String[] { IDialogConstants.OK_LABEL }; break; } case CONFIRM: { dialogButtonLabels = new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }; break; } case QUESTION: { dialogButtonLabels = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }; break; } case QUESTION_WITH_CANCEL: { dialogButtonLabels = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }; break; } default: { throw new IllegalArgumentException("Illegal value for kind in MessageDialog.open()"); //$NON-NLS-1$ } } return dialogButtonLabels; }
From source file:com.amalto.workbench.export.ImportItemsWizard.java
License:Open Source License
private boolean isSaveModifiedEditor(String editorName) { final MessageDialog dialog = new MessageDialog(getShell(), Messages.ImportItemsWizard_4, null, Messages.ImportItemsWizard_5 + editorName + Messages.ImportItemsWizard_6, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0); dialog.open();//from w w w . j av a 2 s .c o m if (dialog.getReturnCode() == 0) { return true; } return false; }
From source file:com.amalto.workbench.export.ImportItemsWizard.java
License:Open Source License
private int isOveride(String name, String obTypeName) { final MessageDialog dialog = new MessageDialog(getShell(), Messages.ImportItemsWizard_12, null, Messages.ImportItemsWizard_13 + obTypeName + Messages.ImportItemsWizard_14 + name + Messages.ImportItemsWizard_15, MessageDialog.QUESTION,/*from w w w. j a va 2s. c o m*/ new String[] { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 0); dialog.open(); int result = dialog.getReturnCode(); if (result == 0) { return IDialogConstants.YES_ID; } if (result == 1) { return IDialogConstants.YES_TO_ALL_ID; } if (result == 2) { return IDialogConstants.NO_ID; } return IDialogConstants.CANCEL_ID; }
From source file:com.android.ide.eclipse.traceview.editors.TraceviewEditor.java
License:Apache License
@Override public void doSaveAs() { Shell shell = getSite().getShell();/*from www . ja v a 2 s . c o m*/ final IEditorInput input = getEditorInput(); final IEditorInput newInput; if (input instanceof FileEditorInput) { // the file is part of the current workspace FileEditorInput fileEditorInput = (FileEditorInput) input; SaveAsDialog dialog = new SaveAsDialog(shell); IFile original = fileEditorInput.getFile(); if (original != null) { dialog.setOriginalFile(original); } dialog.create(); if (original != null && !original.isAccessible()) { String message = String.format("The original file ''%s'' has been deleted or is not accessible.", original.getName()); dialog.setErrorMessage(null); dialog.setMessage(message, IMessageProvider.WARNING); } if (dialog.open() == Window.CANCEL) { return; } IPath filePath = dialog.getResult(); if (filePath == null) { return; } IWorkspace workspace = ResourcesPlugin.getWorkspace(); IFile file = workspace.getRoot().getFile(filePath); if (copy(shell, fileEditorInput.getURI(), file.getLocationURI()) == null) { return; } try { file.refreshLocal(IFile.DEPTH_ZERO, null); } catch (CoreException e) { // TODO Auto-generated catch block e.printStackTrace(); } newInput = new FileEditorInput(file); setInput(newInput); setPartName(newInput.getName()); } else if (input instanceof FileStoreEditorInput) { // the file is not part of the current workspace FileStoreEditorInput fileStoreEditorInput = (FileStoreEditorInput) input; FileDialog dialog = new FileDialog(shell, SWT.SAVE); IPath oldPath = URIUtil.toPath(fileStoreEditorInput.getURI()); if (oldPath != null) { dialog.setFileName(oldPath.lastSegment()); dialog.setFilterPath(oldPath.toOSString()); } String path = dialog.open(); if (path == null) { return; } // Check whether file exists and if so, confirm overwrite final File localFile = new File(path); if (localFile.exists()) { MessageDialog overwriteDialog = new MessageDialog(shell, "Save As", null, String.format("%s already exists.\nDo you want to replace it?", path), MessageDialog.WARNING, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 1); // 'No' is the default if (overwriteDialog.open() != Window.OK) { return; } } IFileStore destFileStore = copy(shell, fileStoreEditorInput.getURI(), localFile.toURI()); if (destFileStore != null) { IFile file = getWorkspaceFile(destFileStore); if (file != null) { newInput = new FileEditorInput(file); } else { newInput = new FileStoreEditorInput(destFileStore); } setInput(newInput); setPartName(newInput.getName()); } } }
From source file:com.appnativa.studio.MessageDialogEx.java
License:Open Source License
/** * @param kind/* w w w . j a va2s . c o m*/ * @return */ public static String[] getButtonLabels(int kind) { String[] dialogButtonLabels; switch (kind) { case ERROR: case INFORMATION: case WARNING: { dialogButtonLabels = new String[] { IDialogConstants.OK_LABEL }; break; } case CONFIRM: { dialogButtonLabels = new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }; break; } case QUESTION: { dialogButtonLabels = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }; break; } case QUESTION_WITH_CANCEL: { dialogButtonLabels = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }; break; } default: { throw new IllegalArgumentException("Illegal value for kind in MessageDialog.open()"); //$NON-NLS-1$ } } return dialogButtonLabels; }
From source file:com.aptana.editor.common.preferences.ValidationPreferencePage.java
License:Open Source License
/** * If changes don't require a rebuild, return false. Otherwise prompt user and take their answer. * //w w w.ja v a2 s . c o m * @return */ private boolean rebuild() { if (promptForRebuild()) { MessageDialog dialog = new MessageDialog(getShell(), Messages.ValidationPreferencePage_RebuildDialogTitle, null, Messages.ValidationPreferencePage_RebuildDialogMessage, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0); return (dialog.open() == 0); } return false; }
From source file:com.aptana.editor.php.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 ww . j av a2s .c o m return true; } else { hasChanges = true; } 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) { IdeLog.logError(PHPEplPlugin.getDefault(), "Error applying changes", e); //$NON-NLS-1$ return false; } if (doBuild) { CoreUtility.getBuildJob(fProject).schedule(); } } return true; }
From source file:com.aptana.formatter.ui.preferences.OptionsConfigurationBlock.java
License:Open Source License
protected boolean processChanges(IWorkbenchPreferenceContainer container) { IScopeContext currContext = fLookupOrder[0]; List<PreferenceKey> changedOptions = new ArrayList<PreferenceKey>(); boolean needsBuild = getChanges(currContext, changedOptions); if (changedOptions.isEmpty()) { return true; }// w w w . j av a 2s .co m if (needsBuild) { int count = getRebuildCount(); if (count > fRebuildCount) { needsBuild = false; // build already requested fRebuildCount = count; } } boolean doBuild = false; if (needsBuild) { IPreferenceChangeRebuildPrompt prompt = getPreferenceChangeRebuildPrompt(fProject == null, changedOptions); if (prompt != null) { MessageDialog dialog = new MessageDialog(getShell(), prompt.getTitle(), null, prompt.getMessage(), 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 (container != null) { // no need to apply the changes to the original store: will be done // by the page container if (doBuild) { // post build incrementRebuildCount(); for (Job job : createBuildJobs(fProject)) { container.registerUpdateJob(job); } } } else { // apply changes right away try { fManager.applyChanges(); } catch (BackingStoreException e) { IdeLog.logError(FormatterUIEplPlugin.getDefault(), e, IDebugScopes.DEBUG); return false; } if (doBuild) { for (Job job : createBuildJobs(fProject)) { job.schedule(); } } } return true; }
From source file:com.aptana.ide.core.ui.wizards.WizardFolderImportPage.java
License:Open Source License
/** * The <code>WizardDataTransfer</code> implementation of this <code>IOverwriteQuery</code> method asks the user * whether the existing resource at the given path should be overwritten. * /*w ww.ja v a 2 s . com*/ * @param pathString * @return the user's reply: one of <code>"YES"</code>, <code>"NO"</code>, <code>"ALL"</code>, or * <code>"CANCEL"</code> */ public String queryOverwrite(String pathString) { Path path = new Path(pathString); String messageString; // Break the message up if there is a file name and a directory // and there are at least 2 segments. if (path.getFileExtension() == null || path.segmentCount() < 2) { messageString = NLS.bind(IDEWorkbenchMessages.WizardDataTransfer_existsQuestion, pathString); } else { messageString = NLS.bind(IDEWorkbenchMessages.WizardDataTransfer_overwriteNameAndPathQuestion, path.lastSegment(), path.removeLastSegments(1).toOSString()); } final MessageDialog dialog = new MessageDialog(getContainer().getShell(), IDEWorkbenchMessages.Question, null, messageString, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.NO_TO_ALL_LABEL, IDialogConstants.CANCEL_LABEL }, 0); String[] response = new String[] { YES, ALL, NO, NO_ALL, CANCEL }; // run in syncExec because callback is from an operation, // which is probably not running in the UI thread. getControl().getDisplay().syncExec(new Runnable() { public void run() { dialog.open(); } }); return dialog.getReturnCode() < 0 ? CANCEL : response[dialog.getReturnCode()]; }