List of usage examples for org.eclipse.jface.dialogs MessageDialog openQuestion
public static boolean openQuestion(Shell parent, String title, String message)
From source file:com.google.cloud.tools.eclipse.sdk.ui.preferences.CloudSdkPrompter.java
License:Apache License
/** * Prompt the user to install and configure the Google Cloud SDK. * //from w ww. jav a 2s. com * @param shellProvider an object that knows how to obtain a shell; may be {@code null} * @return true if the user appears to have configured the SDK, or false if the SDK is unavailable */ static boolean promptForSdk(IShellProvider shellProvider) { if (!MessageDialog.openQuestion(null, SdkUiMessages.CloudSdkPrompter_0, SdkUiMessages.CloudSdkPrompter_1)) { return false; } Shell shell = shellProvider == null ? null : shellProvider.getShell(); final PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(shell, CloudSdkPreferenceArea.PAGE_ID, null, null); return dialog.open() == PreferenceDialog.OK; }
From source file:com.google.dart.tools.search.internal.ui.CopyToClipboardAction.java
License:Open Source License
private void copyToClipboard(Clipboard clipboard, String str, Shell shell) { try {// w ww .j a v a 2s . c o m clipboard.setContents(new String[] { str }, new Transfer[] { TextTransfer.getInstance() }); } catch (SWTError ex) { if (ex.code != DND.ERROR_CANNOT_SET_CLIPBOARD) { throw ex; } String title = SearchMessages.CopyToClipboardAction_error_title; String message = SearchMessages.CopyToClipboardAction_error_message; if (MessageDialog.openQuestion(shell, title, message)) { copyToClipboard(clipboard, str, shell); } } }
From source file:com.google.dart.tools.ui.actions.CopyDetailsToClipboardAction.java
License:Open Source License
private void copyToClipboard(Clipboard clipboard, String text, int repeatCount) { try {/* ww w. j av a 2 s . c o m*/ clipboard.setContents(new String[] { text }, new Transfer[] { TextTransfer.getInstance() }); } catch (SWTError e) { if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD || repeatCount >= MAX_REPEAT_COUNT) { throw e; } if (MessageDialog.openQuestion(getShell(), "Problem Copying to Clipboard", "There was a problem when accessing the system clipboard.\nRetry?")) { copyToClipboard(clipboard, text, repeatCount + 1); } } }
From source file:com.google.dart.tools.ui.actions.CopyFilePathAction.java
License:Open Source License
private void copyToClipboard(Clipboard clipboard, String str, Shell shell) { try {//from w ww. j a v a 2s.c o m clipboard.setContents(new String[] { str }, new Transfer[] { TextTransfer.getInstance() }); } catch (SWTError ex) { if (ex.code != DND.ERROR_CANNOT_SET_CLIPBOARD) { throw ex; } String title = ActionMessages.CopyFilePathAction_dialogTitle; String message = ActionMessages.CopyFilePathAction_dialogMessage; if (MessageDialog.openQuestion(shell, title, message)) { copyToClipboard(clipboard, str, shell); } } }
From source file:com.google.dart.tools.ui.actions.DeleteResourceAction.java
License:Open Source License
/** * Asks the user to confirm a delete operation, where the selection contains no projects. * //from w w w .ja va 2s.com * @param resources the selected resources * @return <code>true</code> if the user says to go ahead, and <code>false</code> if the deletion * should be abandoned */ private boolean confirmDeleteNonProjects(IResource[] resources) { String title; String msg; if (resources.length == 1) { title = IDEWorkbenchMessages.DeleteResourceAction_title1; IResource resource = resources[0]; if (resource.isLinked()) { msg = NLS.bind(IDEWorkbenchMessages.DeleteResourceAction_confirmLinkedResource1, resource.getName()); } else { msg = NLS.bind(IDEWorkbenchMessages.DeleteResourceAction_confirm1, resource.getName()); } } else { title = IDEWorkbenchMessages.DeleteResourceAction_titleN; if (containsLinkedResource(resources)) { msg = NLS.bind(IDEWorkbenchMessages.DeleteResourceAction_confirmLinkedResourceN, new Integer(resources.length)); } else { msg = NLS.bind(IDEWorkbenchMessages.DeleteResourceAction_confirmN, new Integer(resources.length)); } } return MessageDialog.openQuestion(shellProvider.getShell(), title, msg); }
From source file:com.google.dart.tools.ui.callhierarchy.CopyCallHierarchyAction.java
License:Open Source License
@Override public void run() { StringBuffer buf = new StringBuffer(); addCalls(viewer.getTree().getSelection()[0], 0, buf); TextTransfer plainTextTransfer = TextTransfer.getInstance(); try {/*w ww . ja v a 2s. c om*/ clipboard.setContents(new String[] { convertLineTerminators(buf.toString()) }, new Transfer[] { plainTextTransfer }); } catch (SWTError e) { if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD) { throw e; } if (MessageDialog.openQuestion(view.getViewSite().getShell(), CallHierarchyMessages.CopyCallHierarchyAction_problem, CallHierarchyMessages.CopyCallHierarchyAction_clipboard_busy)) { run(); } } }
From source file:com.google.dart.tools.ui.callhierarchy.LocationCopyAction.java
License:Open Source License
@Override public void run() { IStructuredSelection selection = (IStructuredSelection) locationViewer.getSelection(); StringBuffer buf = new StringBuffer(); for (Iterator<?> iterator = selection.iterator(); iterator.hasNext();) { CallLocation location = (CallLocation) iterator.next(); buf.append(location.getLineNumber()).append('\t').append(location.getCallText()); buf.append('\n'); }// w w w .ja va 2 s . c o m TextTransfer plainTextTransfer = TextTransfer.getInstance(); try { clipboard.setContents(new String[] { CopyCallHierarchyAction.convertLineTerminators(buf.toString()) }, new Transfer[] { plainTextTransfer }); } catch (SWTError e) { if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD) { throw e; } if (MessageDialog.openQuestion(viewSite.getShell(), CallHierarchyMessages.CopyCallHierarchyAction_problem, CallHierarchyMessages.CopyCallHierarchyAction_clipboard_busy)) { run(); } } }
From source file:com.google.dart.tools.ui.internal.actions.OpenTypeAction.java
License:Open Source License
/** * Opens the new project dialog if the workspace is empty. * //from w w w .ja v a 2 s. co m * @param parent the parent shell * @return returns <code>true</code> when a project has been created, or <code>false</code> when * the new project has been canceled. */ protected boolean doCreateProjectFirstOnEmptyWorkspace(Shell parent) { IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); if (workspaceRoot.getProjects().length == 0) { String title = DartUIMessages.OpenTypeAction_dialogTitle; String message = DartUIMessages.OpenTypeAction_createProjectFirst; if (MessageDialog.openQuestion(parent, title, message)) { new NewProjectAction().run(); return workspaceRoot.getProjects().length != 0; } return false; } return true; }
From source file:com.google.dart.tools.ui.internal.cleanup.preference.ModifyDialog.java
License:Open Source License
private void saveButtonPressed() { Profile selected = new CustomProfile(fProfileNameField.getText(), new HashMap<String, String>(fWorkingValues), fProfile.getVersion(), fProfileManager.getProfileVersioner().getProfileKind()); final FileDialog dialog = new FileDialog(getShell(), SWT.SAVE); dialog.setText(FormatterMessages.CodingStyleConfigurationBlock_save_profile_dialog_title); dialog.setFilterExtensions(new String[] { "*.xml" }); //$NON-NLS-1$ final String lastPath = DartToolsPlugin.getDefault().getDialogSettings() .get(fLastSaveLoadPathKey + ".savepath"); //$NON-NLS-1$ if (lastPath != null) { dialog.setFilterPath(lastPath);//w w w .ja v a 2s .c o m } final String path = dialog.open(); if (path == null) { return; } DartToolsPlugin.getDefault().getDialogSettings().put(fLastSaveLoadPathKey + ".savepath", //$NON-NLS-1$ dialog.getFilterPath()); final File file = new File(path); if (file.exists() && !MessageDialog.openQuestion(getShell(), FormatterMessages.CodingStyleConfigurationBlock_save_profile_overwrite_title, Messages.format(FormatterMessages.CodingStyleConfigurationBlock_save_profile_overwrite_message, // BasicElementLabels.getPathLabel(file)))) { file.getAbsolutePath()))) { return; } String encoding = ProfileStore.ENCODING; final IContentType type = Platform.getContentTypeManager() .getContentType("com.google.dart.tools.core.runtime.xml"); //$NON-NLS-1$ if (type != null) { encoding = type.getDefaultCharset(); } final Collection<Profile> profiles = new ArrayList<Profile>(); profiles.add(selected); try { fProfileStore.writeProfilesToFile(profiles, file, encoding); } catch (CoreException e) { final String title = FormatterMessages.CodingStyleConfigurationBlock_save_profile_error_title; final String message = FormatterMessages.CodingStyleConfigurationBlock_save_profile_error_message; ExceptionHandler.handle(e, getShell(), title, message); } }
From source file:com.google.dart.tools.ui.internal.filesview.CopyAction.java
License:Open Source License
/** * Set the clipboard contents. Prompt to retry if clipboard is busy. * /*w ww.ja va2s . c o m*/ * @param resources the resources to copy to the clipboard * @param fileNames file names of the resources to copy to the clipboard * @param names string representation of all names */ private void setClipboard(IResource[] resources, String[] fileNames, String names) { try { // set the clipboard contents if (fileNames.length > 0) { clipboard.setContents(new Object[] { resources, fileNames, names }, new Transfer[] { ResourceTransfer.getInstance(), FileTransfer.getInstance(), TextTransfer.getInstance() }); } else { clipboard.setContents(new Object[] { resources, names }, new Transfer[] { ResourceTransfer.getInstance(), TextTransfer.getInstance() }); } } catch (SWTError e) { if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD) { throw e; } if (MessageDialog.openQuestion(shell, ResourceNavigatorMessages.CopyToClipboardProblemDialog_title, ResourceNavigatorMessages.CopyToClipboardProblemDialog_message)) { setClipboard(resources, fileNames, names); } } }