Bug 54347 [Dialogs] Provide "Yes No Always Never" dialog
In Debug UI, we define a dialog that prompts the user to answer Yes, No, Always, or Never. If anyone's interested, this code is generic and could be shipped as a JFace component. The dialog is in the org.eclipse.debug.ui project; the type name is AlwaysNeverDialog. The dialog supports passing in a preference store and preference key for the dialog to persist an Always or Never selection. For cases where clients don't have a preference store but still want to be able to get at the user's response, it alternatively supports passing in a string buffer where the dialog will store the "always/never/prompt" status.
bundles/org.eclipse.ui.ide/src/org/eclipse/ui/wizards/newresource/BasicNewProjectResourceWizard.java
return IDEInternalPreferences.PSPM_ALWAYS.equals(pspm);
	}
	MessageDialogWithToggle dialog = MessageDialogWithToggle.openQuestion(
		window.getShell(),
		ResourceMessages.getString("NewProject.perspSwitchTitle"), 
		ResourceMessages.format(
			"NewProject.perspSwitchMessage", 
			new Object[] { finalPersp.getLabel() }),
		null,	
		false); 
	int result = dialog.getReturnCode();
	if (result >= 0 && dialog.getToggleState()) {
		if (result == 0) {
			
			store.setValue(IDEInternalPreferences.PROJECT_SWITCH_PERSP_MODE, IDEInternalPreferences.PSPM_ALWAYS);
			
		} else {
			
			store.setValue(IDEInternalPreferences.PROJECT_SWITCH_PERSP_MODE, IDEInternalPreferences.PSPM_NEVER);
			
			IDEWorkbenchPlugin.getDefault().getPreferenceStore().setValue(
				IDE.Preferences.PROJECT_OPEN_NEW_PERSPECTIVE,
				IWorkbenchPreferenceConstants.NO_NEW_PERSPECTIVE);
		}
	}
	return result == 0;
}
}