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:edu.tsinghua.lumaqq.ui.helper.ShellLauncher.java
License:Open Source License
/** * ??/*ww w . ja v a 2s.c om*/ * * @param url * URL * @param title * ? * @param errorString * ? */ public void openBrowserShell(String url, String title, String errorString) { // ????? String browser = main.getOptionHelper().getBrowser(); try { if (browser.equals("")) { MessageDialog dialog = new MessageDialog(main.getShell(), message_box_common_question_title, null, message_box_browser_not_set, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 0); switch (dialog.open()) { case 0: main.getShellLauncher().openSystemOptionWindow().setCurrentPage(SystemOptionWindow.OTHER); break; case 1: BrowserShell bs = ShellFactory.createBrowserShell(main); bs.setUrl(url); bs.setTitle(title); bs.open(); break; } } else Runtime.getRuntime().exec(browser.replaceAll("\\[URL\\]", url)); } catch (Throwable t) { MessageDialog.openWarning(main.getShell(), message_box_common_warning_title, errorString); } }
From source file:es.cv.gvcase.mdt.common.part.MOSKittMultiPageEditor.java
License:Open Source License
/** * {@link ISaveablePart2} implementation. <br> * Will ask nested editors that implement ISaveablePart2 to perform their * prompt./*ww w. ja v a 2 s.c o m*/ * */ public int promptToSaveOnClose() { // clear the previous map mapEditorIndex2SaveOnClose.clear(); int saveOption = ISaveablePart2.DEFAULT; boolean saveNeeded = false; ISaveablePart saveablePart1 = null; ISaveablePart2 saveablePart2 = null; String partsNamesToSave = ""; //$NON-NLS-1$ for (int i = 0; i < getPageCount(); i++) { IEditorPart editor = getEditor(i); if (editor == null) { continue; } saveablePart1 = (ISaveablePart) Platform.getAdapterManager().getAdapter(editor, ISaveablePart.class); saveablePart2 = (ISaveablePart2) Platform.getAdapterManager().getAdapter(editor, ISaveablePart2.class); if (saveablePart2 != null) { saveOption = saveablePart2.promptToSaveOnClose(); } else if (saveablePart1 != null) { saveOption = saveablePart1.isSaveOnCloseNeeded() ? ISaveablePart2.YES : ISaveablePart2.NO; } else { saveOption = ISaveablePart2.DEFAULT; } mapEditorIndex2SaveOnClose.put(i, saveOption); if (saveOption == ISaveablePart2.YES) { saveNeeded = true; partsNamesToSave += ((partsNamesToSave.length() == 0 ? "" //$NON-NLS-1$ : ", ") + getPageText(i)); //$NON-NLS-1$ } } if (saveNeeded) { String message = Messages.MOSKittMultiPageEditor_15; String[] buttons = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }; MessageDialog dialog = new MessageDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), Messages.MOSKittMultiPageEditor_16, null, message, MessageDialog.QUESTION, buttons, 0) { protected int getShellStyle() { return SWT.CLOSE | SWT.TITLE | SWT.BORDER | SWT.APPLICATION_MODAL | getDefaultOrientation(); } }; int choice = ISaveablePart2.NO; choice = dialog.open(); // map value of choice back to ISaveablePart2 values switch (choice) { case 0: // Yes choice = ISaveablePart2.YES; break; case 1: // No choice = ISaveablePart2.NO; break; case 2: // Cancel choice = ISaveablePart2.CANCEL; break; default: // ?? choice = ISaveablePart2.DEFAULT; break; } return choice; } else { return ISaveablePart2.NO; } }
From source file:eu.geclipse.ui.internal.actions.DeleteGridElementAction.java
License:Open Source License
private void deleteWorkflowJobDescriptions(final List<IGridJobDescription> selectedJobDescriptions) { MessageDialog dialog = null;/*from w w w. j a v a 2 s . co m*/ String dialogMessage = ""; //$NON-NLS-1$ if (selectedJobDescriptions.size() == 1) { IGridJobDescription selectedJobDesc = selectedJobDescriptions.get(0); String jsdl = selectedJobDesc.getResource().getName(); dialogMessage = String.format(Messages.getString("DeleteGridElementAction.confirmJobDescDeleteOne"), //$NON-NLS-1$ jsdl); } else { String jsdlList = ""; //$NON-NLS-1$ for (Iterator<IGridJobDescription> i = selectedJobDescriptions.iterator(); i.hasNext();) { jsdlList = jsdlList + " " + i.next().getResource().getName(); //$NON-NLS-1$ } dialogMessage = String.format(Messages.getString("DeleteGridElementAction.confirmJobDescDeleteMany"), //$NON-NLS-1$ jsdlList); } dialog = new MessageDialog(DeleteGridElementAction.this.shell, Messages.getString("DeleteGridElementAction.confirmationTitle"), //$NON-NLS-1$ null, dialogMessage, MessageDialog.WARNING, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0); if (dialog.open() == Window.OK) { try { for (Iterator<IGridJobDescription> i1 = selectedJobDescriptions.iterator(); i1.hasNext();) { IResource r = i1.next().getResource(); r.delete(true, new NullProgressMonitor()); // TODO add a proper progress monitor to use } } catch (CoreException e) { // TODO Auto-generated catch block, add proper problem reporting e.printStackTrace(); } } }
From source file:eu.geclipse.workflow.ui.edit.policies.WorkflowJobDragDropEditPolicy.java
License:Open Source License
@SuppressWarnings("unchecked") @Override/*from w w w . j a v a 2s .co m*/ public Command getDropObjectsCommand(DropObjectsRequest dropRequest) { List objects = dropRequest.getObjects(); CompoundCommand cmd = new CompoundCommand(); JSDLJobDescription jsdl = null; for (Object o : objects) { if (o instanceof JSDLJobDescription) { jsdl = (JSDLJobDescription) o; this.selectedElement = (WorkflowJobEditPart) getHost(); IWorkflowJob selectedJob = (IWorkflowJob) this.selectedElement.resolveSemanticElement(); CopyJobDescToWorkflowCommand copyCmd = new CopyJobDescToWorkflowCommand( this.selectedElement.resolveSemanticElement(), jsdl); UpdateJobPortsCommand updatePortsCmd = new UpdateJobPortsCommand(this.selectedElement, jsdl); if (!(selectedJob.getName() == null && selectedJob.getJobDescription() == null)) { MessageDialog confirmDialog = new MessageDialog(null, Messages.getString("WorkflowJobDragDropEditPolicy_confirmationTitle"), //$NON-NLS-1$ null, Messages.getString("WorkflowJobDragDropEditPolicy_userPrompt"), //$NON-NLS-1$ true ? MessageDialog.QUESTION : MessageDialog.WARNING, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0); int result = confirmDialog.open(); if (result == 0) { cmd.add(new ICommandProxy(copyCmd)); cmd.add(new ICommandProxy(updatePortsCmd)); } } else { cmd.add(new ICommandProxy(copyCmd)); cmd.add(new ICommandProxy(updatePortsCmd)); } } return cmd; } return super.getDropObjectsCommand(dropRequest); }
From source file:eu.geclipse.workflow.ui.internal.actions.GetJobDescriptionFromFileAction.java
License:Open Source License
/** * Fires up a GridFileDialog and fetches the contents of a user-chosen JSDL * file./*from www .j a v a2 s.c o m*/ */ public void run(final IAction action) { FileDialog dialog = new FileDialog(this.myShell, SWT.OPEN); String[] exts = { "*.jsdl" }; //$NON-NLS-1$ dialog.setFilterExtensions(exts); // this bit find the root directory of the workflow TransactionalEditingDomain domain = this.mySelectedElement.getEditingDomain(); ResourceSet resourceSet = domain.getResourceSet(); Resource res = resourceSet.getResources().get(0); URI wfRootUri = res.getURI(); String wfRootPath = wfRootUri.path(); this.dirs = wfRootPath.split("/"); //$NON-NLS-1$ String projectName = this.dirs[2]; this.wfRootFileStore = GridModel.getRoot().getFileStore().getChild(projectName); dialog.setFilterPath(this.wfRootFileStore.toString()); if (dialog.open() != null) { String result = dialog.getFileName(); if ((result != null) && (result.length() > 0)) { String filePath = dialog.getFilterPath() + "/" + result; //$NON-NLS-1$ // filePath = filePath.replace(' ', '+'); java.net.URI filePathUri = null; filePathUri = URIUtil.toURI(filePath); IFile jsdlFile = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(filePathUri)[0]; IWorkflowJob selectedJob = (IWorkflowJob) this.mySelectedElement.resolveSemanticElement(); if (!(selectedJob.getName() == null && selectedJob.getJobDescription() == null)) { MessageDialog confirmDialog = new MessageDialog(null, Messages.getString("WorkflowJobDragDropEditPolicy_confirmationTitle"), //$NON-NLS-1$ null, Messages.getString("WorkflowJobDragDropEditPolicy_userPrompt"), //$NON-NLS-1$ true ? MessageDialog.QUESTION : MessageDialog.WARNING, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0); int confirmResult = confirmDialog.open(); if (confirmResult == 0) { JSDLJobDescription jsdl = new JSDLJobDescription(jsdlFile); AbstractTransactionalCommand copyCommand = new CopyJobDescToWorkflowCommand( this.mySelectedElement.resolveSemanticElement(), jsdl); AbstractTransactionalCommand updatePortsCommand = new UpdateJobPortsCommand( GetJobDescriptionFromFileAction.this.mySelectedElement, jsdl); try { OperationHistoryFactory.getOperationHistory().execute(copyCommand, new NullProgressMonitor(), null); OperationHistoryFactory.getOperationHistory().execute(updatePortsCommand, new NullProgressMonitor(), null); } catch (ExecutionException eE) { eE.printStackTrace(); } } } } } }
From source file:eu.numberfour.n4js.ui.export.AbstractExportToSingleFileWizardPage.java
License:Open Source License
/** * The default implementation of this <code>IOverwriteQuery</code> method asks the user whether the existing * resource at the given path should be overwritten. * * @param pathString//from w w w .j av a2s .co m * the path of the archive * @return the user's reply: one of <code>"YES"</code>, <code>"NO"</code>, <code>"ALL"</code>, or * <code>"CANCEL"</code> */ @Override public String queryOverwrite(String pathString) { IPath path = Path.fromOSString(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) { @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. getControl().getDisplay().syncExec(new Runnable() { @Override public void run() { dialog.open(); } }); return dialog.getReturnCode() < 0 ? CANCEL : response[dialog.getReturnCode()]; }
From source file:eu.numberfour.n4js.ui.export.AbstractExportToSingleFileWizardPage.java
License:Open Source License
/** * Displays a Yes/No question to the user with the specified message and returns the user's response. * * @param message//from ww w .j a v a2s . com * the question to ask * @return <code>true</code> for Yes, and <code>false</code> for No */ private boolean queryYesNoQuestion(String message) { MessageDialog dialog = new MessageDialog(getContainer().getShell(), IDEWorkbenchMessages.Question, (Image) null, message, MessageDialog.NONE, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0) { @Override protected int getShellStyle() { return super.getShellStyle() | SWT.SHEET; } }; return dialog.open() == 0; }
From source file:eu.numberfour.n4js.ui.preferences.N4JSBuilderPreferencePage.java
License:Open Source License
/** * This method has been copied and adapted from org.eclipse.xtext.ui.preferences.OptionsConfigurationBlock. *///w w w .ja va 2 s . c o m @Override protected boolean processChanges(IWorkbenchPreferenceContainer container) { boolean needsBuild = !getPreferenceChanges().isEmpty() | projectSpecificChanged; boolean doBuild = false; if (needsBuild) { int count = getRebuildCount(); if (count > rebuildCount) { needsBuild = false; rebuildCount = count; } } if (needsBuild) { String[] strings = getFullBuildDialogStrings(project == null); if (strings != null) { MessageDialog dialog = new MessageDialog(this.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; } } } if (container != null) { if (doBuild) { incrementRebuildCount(); container.registerUpdateJob(getBuildJob(getProject())); } } else { if (doBuild) { getBuildJob(getProject()).schedule(); } } return true; }
From source file:ext.org.eclipse.jdt.internal.ui.javadocexport.JavadocWizard.java
License:Open Source License
private void setAllJavadocLocations(IJavaProject[] projects, URL newURL) { Shell shell = getShell();/*from www . j av a2s . c o m*/ 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]; String message = Messages.format(JavadocExportMessages.JavadocWizard_updatejavadoclocation_message, new String[] { BasicElementLabels.getJavaElementName(iJavaProject.getElementName()), BasicElementLabels.getPathLabel(fDestination, true) }); MessageDialog dialog = new MessageDialog(shell, JavadocExportMessages.JavadocWizard_updatejavadocdialog_label, null, message, MessageDialog.QUESTION, 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:ext.org.eclipse.jdt.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()) { return true; }/*w ww .j a va 2 s . c o m*/ if (needsBuild) { int count = getRebuildCount(); if (count > fRebuildCount) { needsBuild = false; // build already requested fRebuildCount = count; } } 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 (container != null) { // no need to apply the changes to the original store: will be done by the page container if (doBuild) { // post build incrementRebuildCount(); container.registerUpdateJob(CoreUtility.getBuildJob(fProject)); } } else { // apply changes right away try { fManager.applyChanges(); } catch (BackingStoreException e) { JavaPlugin.log(e); return false; } if (doBuild) { CoreUtility.getBuildJob(fProject).schedule(); } } return true; }