List of usage examples for org.eclipse.jface.dialogs MessageDialogWithToggle setBlockOnOpen
public void setBlockOnOpen(boolean shouldBlock)
open method should block until the window closes. From source file:org.eclipse.cdt.internal.ui.editor.CEditor.java
License:Open Source License
private void updateScalabilityMode(IEditorInput input) { int lines = getDocumentProvider().getDocument(input).getNumberOfLines(); boolean wasEnabled = fEnableScalablilityMode; fEnableScalablilityMode = lines > getPreferenceStore() .getInt(PreferenceConstants.SCALABILITY_NUMBER_OF_LINES); if (fEnableScalablilityMode && !wasEnabled) { // Alert users that scalability mode should be turned on if (getPreferenceStore().getBoolean(PreferenceConstants.SCALABILITY_ALERT)) { MessageDialogWithToggle dialog = new MessageDialogWithToggle(Display.getCurrent().getActiveShell(), CEditorMessages.Scalability_info, null, CEditorMessages.Scalability_message, MessageDialog.INFORMATION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0, CEditorMessages.Scalability_reappear, false) { {/*from ww w . j av a2s . co m*/ setShellStyle(SWT.DIALOG_TRIM | SWT.MODELESS | SWT.ON_TOP | getDefaultOrientation()); } @Override protected void buttonPressed(int buttonId) { PreferenceConstants.getPreferenceStore().setValue(PreferenceConstants.SCALABILITY_ALERT, !getToggleState()); super.buttonPressed(buttonId); if (buttonId == IDialogConstants.YES_ID) { PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn( Display.getCurrent().getActiveShell(), "org.eclipse.cdt.ui.preferences.CScalabilityPreferences", null, null); //$NON-NLS-1$ dialog.open(); } } }; dialog.setBlockOnOpen(false); dialog.open(); } } }
From source file:org.eclipse.titan.common.actions.MergeLog.java
License:Open Source License
private void askUserToCreateOrOverwrite(final IPreferenceStore prefStore, final IFile originalFile) { final String[] buttonLabels = new String[] { "Create a new file", "Overwrite" }; final MessageDialogWithToggle msgDialog = new MessageDialogWithToggle(null, "File already exists", null, "An error occured during log file merging. The file '" + outputFile.getName() + "' already exists. " + "Do you want to keep the original file and choose another location/name for the new one?", MessageDialog.NONE, buttonLabels, SWT.DEFAULT, "Don't ask again", false); msgDialog.setBlockOnOpen(true); final int result = msgDialog.open() - 256; if (result == SWT.DEFAULT) { // The dialog was closed setOutputFile(null);//www . j av a 2 s . c o m return; } // lets save the chosen option to the preference store if the user checked the 'Dont ask' checkbox final boolean dontAskChecked = msgDialog.getToggleState(); if (dontAskChecked) { if (result == 0) { // create a new file pressed prefStore.setValue(PreferenceConstants.LOG_MERGE_OPTIONS, PreferenceConstants.LOG_MERGE_OPTIONS_CREATE); } else if (result == 1) { // overwrite prefStore.setValue(PreferenceConstants.LOG_MERGE_OPTIONS, PreferenceConstants.LOG_MERGE_OPTIONS_OVERWRITE); } } else { prefStore.setValue(PreferenceConstants.LOG_MERGE_OPTIONS, PreferenceConstants.LOG_MERGE_OPTIONS_ASK); } if (result == 0) { // create a new file pressed if (dontAskChecked) { setOutputFile(createNewFileWithUniqueName(originalFile)); return; } displayOutputSelectionDialog(); } else { // overwrite FileUtils.deleteQuietly(outputFile); } }