List of usage examples for org.eclipse.jface.dialogs IDialogConstants NO_TO_ALL_LABEL
String NO_TO_ALL_LABEL
To view the source code for org.eclipse.jface.dialogs IDialogConstants NO_TO_ALL_LABEL.
Click Source Link
From source file:fr.inria.linuxtools.internal.tmf.ui.project.wizards.tracepkg.importexport.ImportTracePackageWizardPage.java
License:Open Source License
private boolean checkForOverwrite() { TracePackageElement[] traceElements = (TracePackageElement[]) getElementViewer().getInput(); List<TracePackageTraceElement> noImportTraces = new ArrayList<>(); boolean noToAll = false; for (TracePackageElement packageElement : traceElements) { TracePackageTraceElement traceElement = (TracePackageTraceElement) packageElement; if (!AbstractTracePackageOperation.isFilesChecked(traceElement)) { continue; }// w w w . j av a 2 s .c o m if (noToAll) { noImportTraces.add(traceElement); continue; } if (traceExists(traceElement)) { int returnCode = promptForOverwrite(traceElement.getDestinationElementPath()); // The return code is an index to a button in the dialog but the // 'X' button in the window corner is not considered a button // therefore it returns -1 and unfortunately, there is no // constant for that. if (returnCode < 0) { return false; } final String[] response = new String[] { IDialogConstants.NO_TO_ALL_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.YES_LABEL }; if (response[returnCode].equals(IDialogConstants.YES_TO_ALL_LABEL)) { break; } else if (response[returnCode].equals(IDialogConstants.NO_TO_ALL_LABEL)) { noToAll = true; noImportTraces.add(traceElement); } else if (response[returnCode].equals(IDialogConstants.NO_LABEL)) { noImportTraces.add(traceElement); } } } // Unselect the traces that the user decided not to import for (TracePackageTraceElement t : noImportTraces) { for (TracePackageElement e : t.getChildren()) { if (e instanceof TracePackageFilesElement) { ((TracePackageFilesElement) e).setChecked(false); } } } return true; }
From source file:fr.inria.linuxtools.internal.tmf.ui.project.wizards.tracepkg.importexport.ImportTracePackageWizardPage.java
License:Open Source License
private int promptForOverwrite(String traceName) { final MessageDialog dialog = new MessageDialog(getContainer().getShell(), null, null, MessageFormat.format(Messages.ImportTracePackageWizardPage_AlreadyExists, traceName), MessageDialog.QUESTION, new String[] { IDialogConstants.NO_TO_ALL_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.YES_LABEL, }, 3) {/* w w w.j a v a 2 s. c o m*/ @Override protected int getShellStyle() { return super.getShellStyle() | SWT.SHEET; } }; return dialog.open(); }
From source file:gov.nasa.ensemble.common.ui.wizard.AbstractEnsembleProjectExportWizardPage.java
License:Open Source License
@Override public String queryOverwrite(String pathString) { Path path = new Path(pathString); String messageString;//from w w w .j av a 2s . c o m //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) { // PATH_TO_FILE already exists. Would you like to overwrite it? //messageString = NLS.bind(IDEWorkbenchMessages.WizardDataTransfer_existsQuestion, pathString); IFolder folder = ResourcesPlugin.getWorkspace().getRoot().getFolder(path); IPath location = folder.getLocation(); File file = null; if (location == null) { file = new File(pathString); } else { file = location.toFile(); } messageString = getDialogQuestionText(file); } else { messageString = NLS.bind(IDEWorkbenchMessages.WizardDataTransfer_overwriteNameAndPathQuestion, path.lastSegment(), path.removeLastSegments(1).toOSString()); String osString = path.toOSString(); Date date = new Date(new File(osString).lastModified()); messageString += System.getProperty("line.separator") + System.getProperty("line.separator") + "'" + path.lastSegment() + "' was last modified on: " + date; } final MessageDialog dialog = new MessageDialog(getShellForMessageDialog(), 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) { @Override protected int getShellStyle() { return super.getShellStyle() | SWT.SHEET; } }; 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. WidgetUtils.runInDisplayThread(getShell(), new Runnable() { @Override public void run() { dialog.open(); } }); return dialog.getReturnCode() < 0 ? CANCEL : response[dialog.getReturnCode()]; }
From source file:gov.redhawk.ide.ui.wizard.RedhawkImportWizardPage1.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. * //from w ww . j a va2s . c o m * @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) { protected int getShellStyle() { return super.getShellStyle() | SWT.SHEET; } }; 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()]; }
From source file:net.sf.eclipsensis.wizard.NSISWizardContentsPage.java
License:Open Source License
/** * @param tv//ww w .j a va 2 s. com * @param sel */ private void deleteElements(final TreeViewer tv, ISelection sel) { if (sel instanceof IStructuredSelection) { IStructuredSelection ssel = (IStructuredSelection) sel; if (!ssel.isEmpty()) { try { int buttonId = -1; for (Iterator<?> iter = ssel.iterator(); iter.hasNext();) { INSISInstallElement element = (INSISInstallElement) iter.next(); if (element.hasChildren()) { if (buttonId == IDialogConstants.NO_TO_ALL_ID) { continue; } else if (buttonId != IDialogConstants.YES_TO_ALL_ID) { int index = new MessageDialog(getShell(), cDeleteConfirmTitle, EclipseNSISPlugin.getShellImage(), MessageFormat .format(cDeleteConfirmMessageFormat, new Object[] { element.getDisplayName() }), MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.NO_TO_ALL_LABEL }, 0).open(); if (index >= 0) { buttonId = cDeleteConfirmButtonIds[index]; } else { return; } if (buttonId == IDialogConstants.NO_ID || buttonId == IDialogConstants.NO_TO_ALL_ID) { continue; } } } INSISInstallElement parent = element.getParent(); if (parent != null) { parent.removeChild(element); tv.refresh(parent, true); } } setPageComplete(validatePage(VALIDATE_ALL)); } catch (Exception ex) { delayedValidateAfterError(ex.getLocalizedMessage(), 2000); } finally { tv.refresh(false); } } } }
From source file:net.sourceforge.appgen.job.GenerateFileJob.java
License:Apache License
private void runInternal(IProgressMonitor monitor) { try {/* w ww . j a v a 2s . c o m*/ List<FileGenerator> fileGeneratorList = new ArrayList<FileGenerator>(); ConnectionInformation connectionInformation = mappingData.getConnectionInformation(); GenerationInformation generationInformation = mappingData.getGenerationInformation(); List<Entity> entityList = mappingData.getEntityList(); fileGeneratorList.add(new PomFileGenerator(generationInformation)); fileGeneratorList.add(new WebXmlFileGenerator(generationInformation)); fileGeneratorList.add(new ServletXmlFileGenerator(generationInformation, entityList)); fileGeneratorList.add(new SqlMapConfigFileGenerator(generationInformation, entityList)); fileGeneratorList.add(new Log4jDtdFileGenerator(generationInformation)); fileGeneratorList.add(new Log4jXmlFileGenerator(generationInformation)); fileGeneratorList.add(new MessagePropertiesFileGenerator(generationInformation)); fileGeneratorList.add(new MessageKoPropertiesFileGenerator(generationInformation)); fileGeneratorList.add(new JdbcPropertiesFileGenerator(generationInformation, connectionInformation)); fileGeneratorList.add(new ResourcePropertiesFileGenerator(generationInformation)); fileGeneratorList.add(new JdbcDriverFileGenerator(generationInformation, connectionInformation)); fileGeneratorList.add(new BaseCriteriaFileGenerator(generationInformation)); fileGeneratorList.add(new BaseServiceFileGenerator(generationInformation)); fileGeneratorList.add(new PagingFileGenerator(generationInformation)); fileGeneratorList.add(new UploadSaveDirectoryGenerator(generationInformation)); fileGeneratorList.add(new AttachFileFileGenerator(generationInformation)); fileGeneratorList.add(new AttachFilePersisterFileGenerator(generationInformation)); fileGeneratorList.add(new AttachFilePropertyEditorFileGenerator(generationInformation)); fileGeneratorList.add(new FilenameGeneratorFileGenerator(generationInformation)); fileGeneratorList.add(new UUIDFilenameGeneratorFileGenerator(generationInformation)); fileGeneratorList.add(new DefaultMethodInvocationLoggerFileGenerator(generationInformation)); fileGeneratorList.add(new MethodInvocationInfoInterceptorFileGenerator(generationInformation)); fileGeneratorList.add(new MethodInvocationLoggerFileGenerator(generationInformation)); fileGeneratorList.add(new MethodInvocationLoggingAdviceFileGenerator(generationInformation)); fileGeneratorList.add(new EntityFileGenerator(generationInformation)); fileGeneratorList.add(new CriteriaFileGenerator(generationInformation)); fileGeneratorList.add(new ValidatorFileGenerator(generationInformation)); fileGeneratorList.add(new DaoInterfaceFileGenerator(generationInformation)); fileGeneratorList.add(new DaoClassFileGenerator(generationInformation)); fileGeneratorList.add(new SqlMapFileGenerator(generationInformation)); fileGeneratorList.add(new ServiceInterfaceFileGenerator(generationInformation)); fileGeneratorList.add(new ServiceClassFileGenerator(generationInformation)); fileGeneratorList.add(new ControllerFileGenerator(generationInformation)); fileGeneratorList.add(new FormControllerFileGenerator(generationInformation)); fileGeneratorList.add(new StyleFileGenerator(generationInformation)); fileGeneratorList.add(new TagsFileGenerator(generationInformation)); fileGeneratorList.add(new DefaultPagingFileGenerator(generationInformation)); fileGeneratorList.add(new IndexFileGenerator(generationInformation, entityList)); fileGeneratorList.add(new ListPageFileGenerator(generationInformation)); fileGeneratorList.add(new DetailPageFileGenerator(generationInformation)); fileGeneratorList.add(new WritePageFileGenerator(generationInformation)); fileGeneratorList.add(new EditPageFileGenerator(generationInformation)); // IProgressMonitor monitor = editor.getEditorSite().getActionBars().getStatusLineManager().getProgressMonitor(); monitor.beginTask("Generate soure files", (entityList != null && entityList.size() > 0) ? entityList.size() * fileGeneratorList.size() : 0); if (entityList != null && entityList.size() > 0) { boolean overwriteYesToAll = false; boolean overwriteNoToAll = false; List<File> generatedFileList = new ArrayList<File>(); // outer: for (FileGenerator fileGenerator : fileGeneratorList) { fileGenerator.generateDirectory(); for (Entity entity : entityList) { monitor.subTask(fileGenerator.getFile(entity).getPath()); if (entity.isCreate()) { try { if (fileGenerator.existFile(entity)) { if (overwriteNoToAll) { continue; } if (!overwriteYesToAll) { boolean overwrite = false; MessageDialog overwriteDialog = new MessageDialog( editor.getSite().getShell(), "Question", null, "The file '" + fileGenerator.getFile(entity) + "' already exists. Do you want to replace the existing file?", MessageDialog.WARNING, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.NO_TO_ALL_LABEL }, 1); int value = overwriteDialog.open(); switch (value) { case 0: overwrite = true; break; case 1: overwrite = false; break; case 2: overwrite = true; overwriteYesToAll = true; break; case 3: overwrite = false; overwriteNoToAll = true; break; default: overwriteNoToAll = true; break; } if (!overwrite) { continue; } } } entity.setPackageName(generationInformation.getPackageName()); File file = fileGenerator.generate(entity); if (file != null) { generatedFileList.add(file); } } catch (Exception e) { MessageDialog.openError(editor.getSite().getShell(), "Error - generate", e.getMessage()); } } monitor.worked(1); } } printGeneratedFileList(generatedFileList); } RefreshAction refreshAction = new RefreshAction(editor.getEditorSite()); refreshAction.refreshAll(); monitor.done(); } catch (Exception e) { MessageDialog.openError(editor.getSite().getShell(), "Generate file error", e.getMessage()); } finally { } }
From source file:net.tourbook.importdata.RawDataManager.java
License:Open Source License
private String importRawData_20_CopyFile(final TourbookDevice device, final String sourceFileName, final String destinationPath, final boolean buildNewFileName, final FileCollisionBehavior fileCollision) { String destFileName = new File(sourceFileName).getName(); if (buildNewFileName) { destFileName = null;//www . ja v a 2 s . c o m try { destFileName = device.buildFileNameFromRawData(sourceFileName); } catch (final Exception e) { TourLogManager.logEx(e); } finally { if (destFileName == null) { MessageDialog .openError(Display.getDefault().getActiveShell(), Messages.Import_Data_Error_CreatingFileName_Title, NLS.bind(Messages.Import_Data_Error_CreatingFileName_Message, // new Object[] { sourceFileName, new org.eclipse.core.runtime.Path(destinationPath) .addTrailingSeparator().toString(), TEMP_IMPORTED_FILE })); destFileName = TEMP_IMPORTED_FILE; } } } final File newFile = new File( (new org.eclipse.core.runtime.Path(destinationPath).addTrailingSeparator().toString() + destFileName)); // get source file final File fileIn = new File(sourceFileName); // check if file already exist if (newFile.exists()) { // TODO allow user to rename the file boolean keepFile = false; // for MessageDialog result if (fileCollision.value == FileCollisionBehavior.ASK) { final Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); final MessageDialog messageDialog = new MessageDialog(shell, Messages.Import_Wizard_Message_Title, null, NLS.bind(Messages.Import_Wizard_Message_replace_existing_file, newFile), MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.NO_TO_ALL_LABEL }, 0); messageDialog.open(); final int returnCode = messageDialog.getReturnCode(); switch (returnCode) { case 1: // YES_TO_ALL fileCollision.value = FileCollisionBehavior.REPLACE; break; case 3: // NO_TO_ALL fileCollision.value = FileCollisionBehavior.KEEP; case 2: // NO keepFile = true; break; default: break; } } if (fileCollision.value == FileCollisionBehavior.KEEP || keepFile) { _isImportCanceled = true; fileIn.delete(); return null; } } // copy source file into destination file FileInputStream inReader = null; FileOutputStream outReader = null; try { inReader = new FileInputStream(fileIn); outReader = new FileOutputStream(newFile); int c; while ((c = inReader.read()) != -1) { outReader.write(c); } inReader.close(); outReader.close(); } catch (final FileNotFoundException e) { TourLogManager.logEx(e); return null; } catch (final IOException e) { TourLogManager.logEx(e); return null; } finally { // close the files if (inReader != null) { try { inReader.close(); } catch (final IOException e) { TourLogManager.logEx(e); return null; } } if (outReader != null) { try { outReader.close(); } catch (final IOException e) { TourLogManager.logEx(e); return null; } } } // delete source file fileIn.delete(); return newFile.getAbsolutePath(); }
From source file:net.tourbook.ui.UI.java
License:Open Source License
public static boolean confirmOverwrite(final FileCollisionBehavior fileCollision, final File file) { final boolean[] isOverwrite = { false }; final int fileCollisionValue = fileCollision.value; if (fileCollisionValue == FileCollisionBehavior.REPLACE_ALL) { // overwrite is already confirmed isOverwrite[0] = true;/*from w ww . j a v a 2 s . c om*/ } else if (fileCollisionValue == FileCollisionBehavior.ASK || fileCollisionValue == FileCollisionBehavior.REPLACE || fileCollisionValue == FileCollisionBehavior.KEEP) { Display.getDefault().syncExec(new Runnable() { @Override public void run() { final Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); final MessageDialog dialog = new MessageDialog(// shell, Messages.app_dlg_confirmFileOverwrite_title, null, NLS.bind(Messages.app_dlg_confirmFileOverwrite_message, file.getPath()), MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.NO_TO_ALL_LABEL, IDialogConstants.CANCEL_LABEL }, 0); dialog.open(); final int returnCode = dialog.getReturnCode(); switch (returnCode) { case -1: // dialog was canceled case 4: fileCollision.value = FileCollisionBehavior.DIALOG_IS_CANCELED; break; case 0: // YES fileCollision.value = FileCollisionBehavior.REPLACE; isOverwrite[0] = true; break; case 1: // YES_TO_ALL fileCollision.value = FileCollisionBehavior.REPLACE_ALL; isOverwrite[0] = true; break; case 2: // NO fileCollision.value = FileCollisionBehavior.KEEP; break; case 3: // NO_TO_ALL fileCollision.value = FileCollisionBehavior.KEEP_ALL; break; default: break; } } }); } return isOverwrite[0]; }
From source file:org.eclipse.ajdt.internal.ui.ajdocexport.AJdocWizard.java
License:Open Source License
private void setAllJavadocLocations(IJavaProject[] projects, URL newURL) { Shell shell = getShell();/*from w w w .java 2 s .c o m*/ Image image = shell == null ? null : shell.getDisplay().getSystemImage(SWT.ICON_QUESTION); String[] buttonlabels = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.NO_TO_ALL_LABEL }; for (int j = 0; j < projects.length; j++) { IJavaProject iJavaProject = projects[j]; // AspectJ Extension - message String message = Messages.format(JavadocExportMessages.JavadocWizard_updatejavadoclocation_message, new String[] { iJavaProject.getElementName(), fDestination.toOSString() }); MessageDialog dialog = new MessageDialog(shell, JavadocExportMessages.JavadocWizard_updatejavadocdialog_label, image, message, 4, buttonlabels, 1); switch (dialog.open()) { case YES: JavaUI.setProjectJavadocLocation(iJavaProject, newURL); break; case YES_TO_ALL: for (int i = j; i < projects.length; i++) { iJavaProject = projects[i]; JavaUI.setProjectJavadocLocation(iJavaProject, newURL); j++; } break; case NO_TO_ALL: j = projects.length; break; case NO: default: break; } } }
From source file:org.eclipse.rcptt.ui.resources.wizards.WizardFileSystemResourceImportPage1.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 w w.ja va 2 s.c om*/ * @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( org.eclipse.ui.internal.ide.IDEWorkbenchMessages.WizardDataTransfer_existsQuestion, pathString); } else { messageString = NLS.bind( org.eclipse.ui.internal.ide.IDEWorkbenchMessages.WizardDataTransfer_overwriteNameAndPathQuestion, path.lastSegment(), path.removeLastSegments(1).toOSString()); } final MessageDialog dialog = new MessageDialog(getContainer().getShell(), org.eclipse.ui.internal.ide.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) { protected int getShellStyle() { return super.getShellStyle() | SWT.SHEET; } }; 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()]; }