List of usage examples for org.eclipse.jface.dialogs MessageDialog openQuestion
public static boolean openQuestion(Shell parent, String title, String message)
From source file:descent.internal.ui.preferences.ClasspathVariablesPreferencePage.java
License:Open Source License
public void setVisible(boolean visible) { // check if the stored settings have changed if (visible) { if (fStoredSettings != null && !fStoredSettings.equals(getCurrentSettings())) { fVariableBlock.refresh(null); }//from w ww . j a v a2s .c o m } else { if (fVariableBlock.hasChanges()) { String title = PreferencesMessages.ClasspathVariablesPreferencePage_savechanges_title; String message = PreferencesMessages.ClasspathVariablesPreferencePage_savechanges_message; if (MessageDialog.openQuestion(getShell(), title, message)) { performOk(); } fVariableBlock.setChanges(false); // forget } fStoredSettings = getCurrentSettings(); } super.setVisible(visible); }
From source file:descent.internal.ui.preferences.CodeTemplateBlock.java
License:Open Source License
private boolean confirmOverwrite(File file) { return MessageDialog.openQuestion(getShell(), PreferencesMessages.CodeTemplateBlock_export_exists_title, Messages.format(PreferencesMessages.CodeTemplateBlock_export_exists_message, file.getAbsolutePath())); }
From source file:descent.internal.ui.preferences.formatter.ModifyDialog.java
License:Open Source License
private void saveButtonPressed() { Profile selected = new CustomProfile(fProfileNameField.getText(), new HashMap(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 = JavaPlugin.getDefault().getDialogSettings().get(fLastSaveLoadPathKey + ".savepath"); //$NON-NLS-1$ if (lastPath != null) { dialog.setFilterPath(lastPath);/* w w w. j a v a2s . c o m*/ } final String path = dialog.open(); if (path == null) return; JavaPlugin.getDefault().getDialogSettings().put(fLastSaveLoadPathKey + ".savepath", dialog.getFilterPath()); //$NON-NLS-1$ 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, path))) { return; } String encoding = ProfileStore.ENCODING; final IContentType type = Platform.getContentTypeManager().getContentType("org.eclipse.core.runtime.xml"); //$NON-NLS-1$ if (type != null) encoding = type.getDefaultCharset(); final Collection profiles = new ArrayList(); 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:descent.internal.ui.wizards.buildpaths.AccessRulesDialog.java
License:Open Source License
final void doErrorWarningLinkPressed() { if (fParentCanSwitchPage && MessageDialog.openQuestion(getShell(), NewWizardMessages.AccessRulesDialog_switch_dialog_title, NewWizardMessages.AccessRulesDialog_switch_dialog_message)) { setReturnCode(SWITCH_PAGE);// w ww .ja v a 2 s .co m close(); } }
From source file:descent.internal.ui.wizards.buildpaths.BuildPathSupport.java
License:Open Source License
private static boolean putJarOnClasspathDialog(final Shell shell) { if (shell == null) { return false; }//from w ww . j a v a2s.co m final boolean[] result = new boolean[1]; shell.getDisplay().syncExec(new Runnable() { public void run() { String title = NewWizardMessages.BuildPathSupport_putoncpdialog_title; String message = NewWizardMessages.BuildPathSupport_putoncpdialog_message; result[0] = MessageDialog.openQuestion(shell, title, message); } }); return result[0]; }
From source file:descent.internal.ui.wizards.buildpaths.CreateMultipleSourceFoldersDialog.java
License:Open Source License
/** * Asks to change the output folder to 'proj/bin' when no source folders were existing *///from www.j a v a 2 s .c o m private boolean removeProjectFromBP(CPListElement existing) { IPath outputFolder = new Path(fOutputLocation); IPath newOutputFolder = null; String message; if (outputFolder.segmentCount() == 1) { String outputFolderName = PreferenceConstants.getPreferenceStore() .getString(PreferenceConstants.SRCBIN_BINNAME); newOutputFolder = outputFolder.append(outputFolderName); message = Messages.format( NewWizardMessages.SourceContainerWorkbookPage_ChangeOutputLocationDialog_project_and_output_message, newOutputFolder); } else { message = NewWizardMessages.SourceContainerWorkbookPage_ChangeOutputLocationDialog_project_message; } String title = NewWizardMessages.SourceContainerWorkbookPage_ChangeOutputLocationDialog_title; if (MessageDialog.openQuestion(getShell(), title, message)) { fRemovedElements.add(existing); if (newOutputFolder != null) { fOutputLocation = newOutputFolder.toString(); } return true; } return false; }
From source file:descent.internal.ui.wizards.buildpaths.newsourcepage.ClasspathModifierQueries.java
License:Open Source License
/** * The query is used to get information about whether the project should be removed as * source folder and update build folder to <code>outputLocation</code> * /*from w w w . j a v a2s .co m*/ * @param shell shell if there is any or <code>null</code> * @param outputLocation the desired project's output location * @return an <code>IOutputFolderQuery</code> that can be executed * * @see OutputFolderQuery * @see descent.internal.corext.buildpath.AddSelectedSourceFolderOperation */ public static OutputFolderQuery getDefaultFolderQuery(final Shell shell, IPath outputLocation) { return new OutputFolderQuery(outputLocation) { protected IPath fOutputLocation; protected boolean fRemoveProject; public boolean doQuery(final boolean editingOutputFolder, final OutputFolderValidator validator, final IJavaProject project) throws JavaModelException { final boolean[] result = { false }; fRemoveProject = false; fOutputLocation = project.getOutputLocation(); Display.getDefault().syncExec(new Runnable() { public void run() { Shell sh = shell != null ? shell : JavaPlugin.getActiveWorkbenchShell(); String title = NewWizardMessages.ClasspathModifier_ChangeOutputLocationDialog_title; if (fDesiredOutputLocation.segmentCount() == 1) { String outputFolderName = PreferenceConstants.getPreferenceStore() .getString(PreferenceConstants.SRCBIN_BINNAME); IPath newOutputFolder = fDesiredOutputLocation.append(outputFolderName); newOutputFolder = getValidPath(newOutputFolder, validator); String message = Messages.format( NewWizardMessages.ClasspathModifier_ChangeOutputLocationDialog_project_outputLocation, newOutputFolder); fRemoveProject = true; if (MessageDialog.openConfirm(sh, title, message)) { fOutputLocation = newOutputFolder; result[0] = true; } } else { IPath newOutputFolder = fDesiredOutputLocation; newOutputFolder = getValidPath(newOutputFolder, validator); if (editingOutputFolder) { fOutputLocation = newOutputFolder; result[0] = true; return; // show no dialog } String message = NewWizardMessages.ClasspathModifier_ChangeOutputLocationDialog_project_message; fRemoveProject = true; if (MessageDialog.openQuestion(sh, title, message)) { fOutputLocation = newOutputFolder; result[0] = true; } } } }); return result[0]; } public IPath getOutputLocation() { return fOutputLocation; } public boolean removeProjectFromClasspath() { return fRemoveProject; } private IPath getValidPath(IPath newOutputFolder, OutputFolderValidator validator) { int i = 1; IPath path = newOutputFolder; while (!validator.validate(path)) { path = new Path(newOutputFolder.toString() + i); i++; } return path; } }; }
From source file:descent.internal.unittest.ui.CopyFailureListAction.java
License:Open Source License
public void run() { TextTransfer plainTextTransfer = TextTransfer.getInstance(); try {//from w w w . j a v a 2s . com fClipboard.setContents(new String[] { getAllFailureTraces() }, new Transfer[] { plainTextTransfer }); } catch (SWTError e) { if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD) throw e; if (MessageDialog.openQuestion(JavaPlugin.getActiveWorkbenchShell(), JUnitMessages.CopyFailureList_problem, JUnitMessages.CopyFailureList_clipboard_busy)) run(); } }
From source file:descent.internal.unittest.ui.JUnitCopyAction.java
License:Open Source License
public void run() { if (null == fTestElement || !(fTestElement instanceof TestCaseElement)) return;/*from w w w .j a v a 2s .c o m*/ TestCaseElement testCaseElement = (TestCaseElement) fTestElement; ITestResult result = testCaseElement.getResult(); String source = TraceUtil.getTraceAsString(result); TextTransfer plainTextTransfer = TextTransfer.getInstance(); try { fClipboard.setContents(new String[] { convertLineTerminators(source) }, new Transfer[] { plainTextTransfer }); } catch (SWTError e) { if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD) throw e; if (MessageDialog.openQuestion(fView.getComposite().getShell(), JUnitMessages.CopyTraceAction_problem, JUnitMessages.CopyTraceAction_clipboard_busy)) run(); } }
From source file:descent.internal.unittest.ui.TestRunnerViewPart.java
License:Open Source License
/** * Stops the currently running test and shuts down the RemoteTestRunner *//*www .j av a 2 s . c o m*/ public void rerunTestRun() { if (lastLaunchIsKeptAlive()) { // prompt for terminating the existing run if (MessageDialog.openQuestion(getSite().getShell(), JUnitMessages.TestRunnerViewPart_terminate_title, JUnitMessages.TestRunnerViewPart_terminate_message)) { stopTest(); } } if (fTestRunSession != null && fTestRunSession.getLaunch().getLaunchConfiguration() != null) { ILaunchConfiguration configuration = fTestRunSession.getLaunch().getLaunchConfiguration(); DebugUITools.launch(configuration, fTestRunSession.getLaunch().getLaunchMode()); } }