本文整理匯總了Java中org.eclipse.jface.dialogs.MessageDialogWithToggle.openYesNoCancelQuestion方法的典型用法代碼示例。如果您正苦於以下問題:Java MessageDialogWithToggle.openYesNoCancelQuestion方法的具體用法?Java MessageDialogWithToggle.openYesNoCancelQuestion怎麽用?Java MessageDialogWithToggle.openYesNoCancelQuestion使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jface.dialogs.MessageDialogWithToggle
的用法示例。
在下文中一共展示了MessageDialogWithToggle.openYesNoCancelQuestion方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: askUserToSwitch
import org.eclipse.jface.dialogs.MessageDialogWithToggle; //導入方法依賴的package包/類
protected static void askUserToSwitch(IWorkbenchPart part, int warningsNumber) {
final IPreferenceStore store = FindbugsPlugin.getDefault().getPreferenceStore();
String message = "FindBugs analysis finished, " + warningsNumber
+ " warnings found.\n\nSwitch to the FindBugs perspective?";
MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoCancelQuestion(null, "FindBugs analysis finished",
message, "Remember the choice and do not ask me in the future", false, store,
FindBugsConstants.ASK_ABOUT_PERSPECTIVE_SWITCH);
boolean remember = dialog.getToggleState();
int returnCode = dialog.getReturnCode();
if (returnCode == IDialogConstants.YES_ID) {
if (remember) {
store.setValue(FindBugsConstants.SWITCH_PERSPECTIVE_AFTER_ANALYSIS, true);
}
switchPerspective(part);
} else if (returnCode == IDialogConstants.NO_ID) {
if (remember) {
store.setValue(FindBugsConstants.SWITCH_PERSPECTIVE_AFTER_ANALYSIS, false);
}
}
}
示例2: run
import org.eclipse.jface.dialogs.MessageDialogWithToggle; //導入方法依賴的package包/類
@Override
public void run() {
IPreferenceStore prefs = JDepend4EclipsePlugin.getDefault().getPreferenceStore();
boolean shouldAsk = prefs.getBoolean(JDependConstants.SAVE_TO_SHOW_OPTIONS);
/*
* Show dialog if prefs is set, asking for open in editor
*/
boolean saveAsXml = prefs.getBoolean(JDependConstants.SAVE_AS_XML);
if (shouldAsk) {
MessageDialogWithToggle dialogWithToggle = MessageDialogWithToggle
.openYesNoCancelQuestion(getShell(), "Save JDepend output",
"Save JDepend output as XML (and not as plain text)?",
"Remember and do not ask me again", false, prefs,
JDependConstants.SAVE_TO_SHOW_OPTIONS);
int returnCode = dialogWithToggle.getReturnCode();
if (returnCode != IDialogConstants.YES_ID
&& returnCode != IDialogConstants.NO_ID) {
return;
}
saveAsXml = returnCode == IDialogConstants.YES_ID;
prefs.setValue(JDependConstants.SAVE_AS_XML, saveAsXml);
}
/*
* open file selection dialog (external)
*/
File file = getFileFromUser(saveAsXml);
if (file == null) {
return;
}
/*
* if selected file exists, ask for override/append/another file
*/
int overrideOrAppend = checkForExisting(file);
if (overrideOrAppend == CANCEL) {
return;
}
IFile iFile = getWorkspaceFile(file);
/*
* if selected file is in the workspace, checkout it or show error message
*/
if (iFile != null && !checkout(iFile, overrideOrAppend)) {
return;
}
/*
* save it
*/
doSave(file, overrideOrAppend);
}
示例3: continueWorkingOperation
import org.eclipse.jface.dialogs.MessageDialogWithToggle; //導入方法依賴的package包/類
public boolean continueWorkingOperation(final ProfileChangeOperation operation, final Shell shell) {
// don't continue if superclass has already identified problem scenarios
final boolean ok = super.continueWorkingWithOperation(operation, shell);
if (!ok) {
return false;
}
final IProvisioningPlan plan = operation.getProvisioningPlan();
if (plan == null) {
return false;
}
// Check the preference to see whether to continue.
final IPreferenceStore prefs = P2_Activator.getDefault().getPreferenceStore();
final String openPlan = prefs.getString(PreferenceConstants.PREF_OPEN_WIZARD_ON_ERROR_PLAN);
if (MessageDialogWithToggle.ALWAYS.equals(openPlan)) {
return true;
}
if (MessageDialogWithToggle.NEVER.equals(openPlan)) {
StatusManager.getManager().handle(plan.getStatus(), StatusManager.SHOW | StatusManager.LOG);
return false;
}
final MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoCancelQuestion(
shell,
ProvSDKMessages.ProvSDKUIActivator_Question,
ProvSDKMessages.ProvSDKUIActivator_OpenWizardAnyway,
null,
false,
prefs,
PreferenceConstants.PREF_OPEN_WIZARD_ON_ERROR_PLAN);
// Any answer but yes will stop the performance of the plan, but NO is interpreted to mean, show me the error.
if (dialog.getReturnCode() == IDialogConstants.NO_ID) {
StatusManager.getManager().handle(plan.getStatus(), StatusManager.SHOW | StatusManager.LOG);
}
return dialog.getReturnCode() == IDialogConstants.YES_ID;
}
示例4: scheduleJob
import org.eclipse.jface.dialogs.MessageDialogWithToggle; //導入方法依賴的package包/類
private void scheduleJob(final FileAssociationDef def)
{
if (def != null) {
Job job = new UIJob(mJobName) {
private boolean isValidEditor(String[] editorIds, IEditorDescriptor descriptor)
{
if (descriptor != null) {
String id = descriptor.getId();
for (int i = 0; i < editorIds.length; i++) {
if (editorIds[i].equals(id)) {
return true;
}
}
}
return false;
}
@Override
public IStatus runInUIThread(final IProgressMonitor monitor)
{
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
if (!cCheckedAssociations.contains(def.getAssociationId())) {
final boolean toggleState = getFileAssociationChecking(def.getAssociationId());
if (toggleState) {
cCheckedAssociations.add(def.getAssociationId());
final String[] fileTypes = def.getFileTypes();
for (int i = 0; i < fileTypes.length; i++) {
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
if (!isValidEditor(def.getEditorIds(), mEditorRegistry.getDefaultEditor(fileTypes[i]))) {
if (!monitor.isCanceled()) {
String[] args = new String[]{def.getFileTypesName(), def.getEditorsName()};
MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoCancelQuestion(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
mDialogTitleFormat.format(args), mDialogMessageFormat.format(args), mDialogToggleMessageFormat.format(args), !toggleState, null, null);
int rc = dialog.getReturnCode();
switch (rc)
{
case IDialogConstants.YES_ID:
{
for (int j = 0; j < fileTypes.length; j++) {
mEditorRegistry.setDefaultEditor(fileTypes[j], def.getEditorIds()[0]);
}
//Cast to inner class because otherwise it cannot be saved.
((EditorRegistry)mEditorRegistry).saveAssociations();
//Fall through to next case to save the toggle state
}
//$FALL-THROUGH$
case IDialogConstants.NO_ID:
{
boolean newToggleState = !dialog.getToggleState();
if (toggleState != newToggleState) {
setFileAssociationChecking(def.getAssociationId(), newToggleState);
}
break;
}
case IDialogConstants.CANCEL_ID:
return Status.CANCEL_STATUS;
}
}
break;
}
}
}
}
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
else {
return Status.OK_STATUS;
}
}
};
job.setRule(cSchedulingRule);
job.schedule(5000);
}
}