本文整理匯總了Java中org.eclipse.jface.dialogs.MessageDialogWithToggle.getToggleState方法的典型用法代碼示例。如果您正苦於以下問題:Java MessageDialogWithToggle.getToggleState方法的具體用法?Java MessageDialogWithToggle.getToggleState怎麽用?Java MessageDialogWithToggle.getToggleState使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jface.dialogs.MessageDialogWithToggle
的用法示例。
在下文中一共展示了MessageDialogWithToggle.getToggleState方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: openIgnoreMessageDialogConfirm
import org.eclipse.jface.dialogs.MessageDialogWithToggle; //導入方法依賴的package包/類
/**
* openIgnoreMessageDialogConfirm
*
* @param shell
* @param title
* @param message
* @param store
* @param key
* Key to store the show/hide this message. Message will be hidden if true
* @return int
*/
public static int openIgnoreMessageDialogConfirm(Shell shell, String title, String message, IPreferenceStore store,
String key)
{
String value = store.getString(key);
if (!shouldShowDialog(key))
{
return value == MessageDialogWithToggle.ALWAYS ? IDialogConstants.YES_ID : IDialogConstants.NO_ID;
}
MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoQuestion(shell, title, message,
Messages.DialogUtils_doNotShowMessageAgain, false, store, key);
if (dialog.getToggleState())
{
setShouldShowDialog(key, false);
store.putValue(key, dialog.getReturnCode() == IDialogConstants.YES_ID ? MessageDialogWithToggle.ALWAYS
: MessageDialogWithToggle.NEVER);
}
return dialog.getReturnCode();
}
示例2: openIgnoreMessageDialogInformation
import org.eclipse.jface.dialogs.MessageDialogWithToggle; //導入方法依賴的package包/類
/**
* Conditionally open an information message dialog. In case this is the first time this dialog is opened (defined
* by its key), the dialog will be displayed, and a "Do not show this message again" checkbox will be available. The
* message dialog will not be opened again when the checkbox is selected.<br>
* Once checked, the only way to display this dialog again is by resetting the messaged through the Studio's main
* preference page.
*
* @param shell
* @param title
* @param message
* @param dialogKey
* A dialog key that will be checked to confirm if the dialog should be diaplayed.
* @return The dialog's return code.
*/
public static int openIgnoreMessageDialogInformation(Shell shell, String title, String message, String dialogKey)
{
if (!shouldShowDialog(dialogKey))
{
return MessageDialog.CANCEL;
}
MessageDialogWithToggle dialog = MessageDialogWithToggle.openInformation(shell, title, message,
Messages.DialogUtils_doNotShowMessageAgain, false, null, null);
if (dialog.getReturnCode() == Dialog.OK)
{
// check the toggle state to see if we need to add the dialog key to the list of hidden dialogs.
if (dialog.getToggleState())
{
setShouldShowDialog(dialogKey, false);
}
}
return dialog.getReturnCode();
}
示例3: isRowSelectionMode
import org.eclipse.jface.dialogs.MessageDialogWithToggle; //導入方法依賴的package包/類
/**
* check row/cell mode, row mode must be set, it works with the cell mode but can be confusing
* because multiple rows can be selected but they are not visible
*
* @return
*/
private boolean isRowSelectionMode() {
if (_isRowEditMode == false) {
final MessageDialogWithToggle dialog = MessageDialogWithToggle.openInformation(
Display.getCurrent().getActiveShell(),
Messages.tour_editor_dlg_delete_rows_title,
Messages.tour_editor_dlg_delete_rows_mode_message,
Messages.tour_editor_dlg_delete_rows_mode_toggle_message,
true,
null,
null);
if (dialog.getToggleState()) {
_actionToggleRowSelectMode.setChecked(true);
actionToggleRowSelectMode();
}
return false;
}
return true;
}
示例4: 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);
}
}
}
示例5: transOverwritePrompt
import org.eclipse.jface.dialogs.MessageDialogWithToggle; //導入方法依賴的package包/類
public boolean transOverwritePrompt( TransMeta transMeta ) {
MessageDialogWithToggle md = new MessageDialogWithToggle( shell,
BaseMessages.getString( PKG, "RepositoryImportDialog.OverwriteTrans.Title" ),
null,
BaseMessages.getString( PKG, "RepositoryImportDialog.OverwriteTrans.Message", transMeta.getName() ),
MessageDialog.QUESTION, new String[] {
BaseMessages.getString( PKG, "System.Button.Yes" ),
BaseMessages.getString( PKG, "System.Button.No" ) },
1,
BaseMessages.getString( PKG, "RepositoryImportDialog.DontAskAgain.Label" ), !askOverwrite );
MessageDialogWithToggle.setDefaultImage( GUIResource.getInstance().getImageSpoon() );
int answer = md.open();
askOverwrite = !md.getToggleState();
return ( answer & 0xFF ) == 0;
}
示例6: jobOverwritePrompt
import org.eclipse.jface.dialogs.MessageDialogWithToggle; //導入方法依賴的package包/類
public boolean jobOverwritePrompt( JobMeta jobMeta ) {
MessageDialogWithToggle md =
new MessageDialogWithToggle(
shell, BaseMessages.getString( PKG, "RepositoryImportDialog.OverwriteJob.Title" ), null, BaseMessages
.getString( PKG, "RepositoryImportDialog.OverwriteJob.Message", jobMeta.getName() ),
MessageDialog.QUESTION, new String[] {
BaseMessages.getString( PKG, "System.Button.Yes" ),
BaseMessages.getString( PKG, "System.Button.No" ) },
1,
BaseMessages.getString( PKG, "RepositoryImportDialog.DontAskAgain.Label" ),
!askOverwrite );
MessageDialogWithToggle.setDefaultImage( GUIResource.getInstance().getImageSpoon() );
int answer = md.open();
askOverwrite = !md.getToggleState();
return ( answer & 0xFF ) == 0;
}
示例7: performOk
import org.eclipse.jface.dialogs.MessageDialogWithToggle; //導入方法依賴的package包/類
/**
* Perform OK button.
*
* @return true, if successful {@inheritDoc}
*/
@Override
public boolean performOk() {
try {
if (preferences.needsSaving()) {
preferences.save();
}
} catch (final IOException e) {
LOGGER.error("Unable to save general preference page preferences", e); //$NON-NLS-1$
}
boolean preferenceChanged = false;
for (final IPreferenceItem item : (IPreferenceItem[]) ((ValidModelTreeContentProvider) treeViewer.getContentProvider()).getElements(null)) {
preferenceChanged = preferenceChanged | preferenceChanged(item);
}
if (preferenceChanged) {
final MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoQuestion(this.getShell(), REVALIDATE_DIALOG_TITLE, REVALIDATE_DIALOG_MESSAGE, EXPENSIVE_CHECKS_TOGGLE_MESSAGE, getPreferenceStore().getBoolean(PERFORM_EXPENSIVE_VALIDATION), null, null);
final boolean yesWeCan = (dialog.getReturnCode() == IDialogConstants.YES_ID);
final boolean performExpensiveValidations = dialog.getToggleState();
getPreferenceStore().setValue(PERFORM_EXPENSIVE_VALIDATION, dialog.getToggleState());
if (yesWeCan) {
final ValidMarkerUpdateJob updateJob = new ValidMarkerUpdateJob(VALIDATION_JOB_MESSAGE, this.fileExtensions, this.resourceSet, this.markerCreator, this.resourceDescriptions, this.resourceServiceProvider, performExpensiveValidations, storage2UriMapper);
// The following gets a global lock on all updateJob, no matter what the language is.
// The reason is that we want to avoid the update job to consume too much memory, but
// we may decide to change that to a lock on a language basis...
updateJob.setRule(ResourcesPlugin.getWorkspace().getRoot());
updateJob.schedule();
}
}
return super.performOk();
}
示例8: confirmPerspectiveSwitch
import org.eclipse.jface.dialogs.MessageDialogWithToggle; //導入方法依賴的package包/類
/**
* Prompts the user for whether to switch perspectives.
*
* @param window
* The workbench window in which to switch perspectives; must not
* be <code>null</code>
* @param finalPersp
* The perspective to switch to; must not be <code>null</code>.
*
* @return <code>true</code> if it's OK to switch, <code>false</code>
* otherwise
*/
private static boolean confirmPerspectiveSwitch(IWorkbenchWindow window, IPerspectiveDescriptor finalPersp) {
IPreferenceStore store = IDEWorkbenchPlugin.getDefault().getPreferenceStore();
String pspm = store.getString(IDEInternalPreferences.PROJECT_SWITCH_PERSP_MODE);
if (!IDEInternalPreferences.PSPM_PROMPT.equals(pspm)) {
// Return whether or not we should always switch
return IDEInternalPreferences.PSPM_ALWAYS.equals(pspm);
}
String desc = finalPersp.getDescription();
String message;
if (desc == null || desc.length() == 0)
message = NLS.bind(ResourceMessages.NewProject_perspSwitchMessage, finalPersp.getLabel());
else
message = NLS.bind(ResourceMessages.NewProject_perspSwitchMessageWithDesc,
new String[] { finalPersp.getLabel(), desc });
MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoQuestion(window.getShell(),
ResourceMessages.NewProject_perspSwitchTitle, message,
null /* use the default message for the toggle */,
false /* toggle is initially unchecked */, store, IDEInternalPreferences.PROJECT_SWITCH_PERSP_MODE);
int result = dialog.getReturnCode();
// If we are not going to prompt anymore propogate the choice.
if (dialog.getToggleState()) {
String preferenceValue;
if (result == IDialogConstants.YES_ID) {
// Doesn't matter if it is replace or new window
// as we are going to use the open perspective setting
preferenceValue = IWorkbenchPreferenceConstants.OPEN_PERSPECTIVE_REPLACE;
} else {
preferenceValue = IWorkbenchPreferenceConstants.NO_NEW_PERSPECTIVE;
}
// update PROJECT_OPEN_NEW_PERSPECTIVE to correspond
PrefUtil.getAPIPreferenceStore().setValue(IDE.Preferences.PROJECT_OPEN_NEW_PERSPECTIVE, preferenceValue);
}
return result == IDialogConstants.YES_ID;
}
示例9: switchToModelingPerspective
import org.eclipse.jface.dialogs.MessageDialogWithToggle; //導入方法依賴的package包/類
public static void switchToModelingPerspective(IWorkbenchWindow window) {
IPreferenceStore prefs = UIPluginActivator.getDefault()
.getPreferenceStore();
boolean hide = prefs.getBoolean(AUTO_SWITCH_PERSPECTIVE);
IWorkbenchPage page = window.getActivePage();
if (!hide) {
IWorkbench workbench = window.getWorkbench();
IPerspectiveRegistry registry = workbench.getPerspectiveRegistry();
IPerspectiveDescriptor descriptor = registry
.findPerspectiveWithId(IYakinduSctPerspectives.ID_PERSPECTIVE_SCT_MODELING);
if ((page != null) && (page.getPerspective() != descriptor)) {
MessageDialogWithToggle dialog = MessageDialogWithToggle
.openYesNoQuestion(
window.getShell(),
"Confirm Perspective Switch",
"This kind of editor is associated with the YAKINDU Modeling perspective. Do you want to switch to this perspective now?",
"Do not offer to switch perspective in the future",
hide, prefs, AUTO_SWITCH_PERSPECTIVE);
if (dialog.getReturnCode() == 2)
page.setPerspective(descriptor);
hide = dialog.getToggleState();
prefs.setValue(AUTO_SWITCH_PERSPECTIVE, hide);
try {
InstanceScope.INSTANCE.getNode(UIPluginActivator.PLUGIN_ID)
.flush();
} catch (BackingStoreException e) {
e.printStackTrace();
}
}
}
}
示例10: shouldCancelBecauseOfRunningLaunches
import org.eclipse.jface.dialogs.MessageDialogWithToggle; //導入方法依賴的package包/類
private boolean shouldCancelBecauseOfRunningLaunches() {
if (mode == MODE_CHECKOUT)
return false;
IPreferenceStore store = Activator.getDefault().getPreferenceStore();
if (!store
.getBoolean(UIPreferences.SHOW_RUNNING_LAUNCH_ON_CHECKOUT_WARNING))
return false;
ILaunchConfiguration launchConfiguration = getRunningLaunchConfiguration();
if (launchConfiguration != null) {
String[] buttons = new String[] {
UIText.BranchOperationUI_Continue,
IDialogConstants.CANCEL_LABEL };
String message = NLS.bind(UIText.BranchOperationUI_RunningLaunchMessage,
launchConfiguration.getName());
MessageDialogWithToggle continueDialog = new MessageDialogWithToggle(
getShell(), UIText.BranchOperationUI_RunningLaunchTitle,
null, message, MessageDialog.NONE, buttons, 0,
UIText.BranchOperationUI_RunningLaunchDontShowAgain, false);
int result = continueDialog.open();
// cancel
if (result == IDialogConstants.CANCEL_ID || result == SWT.DEFAULT)
return true;
boolean dontWarnAgain = continueDialog.getToggleState();
if (dontWarnAgain)
store.setValue(
UIPreferences.SHOW_RUNNING_LAUNCH_ON_CHECKOUT_WARNING,
false);
}
return false;
}
示例11: handleFileError
import org.eclipse.jface.dialogs.MessageDialogWithToggle; //導入方法依賴的package包/類
private Boolean handleFileError(IFile file) {
String launchAlways = DbgActivator.getDefault().getPreferenceStore().getString(PreferenceInitializer.CONTINUE_LAUNCH_WITH_FILE_ERRORS);
if (MessageDialogWithToggle.ALWAYS.equals(launchAlways)) {
return true;
}
String message = "Errors in File: " + file.getName() + "\n\nProceed with launch?";
MessageDialogWithToggle dialog = new MessageDialogWithToggle (
Display.getCurrent().getActiveShell(),
"Errors in File",
null,
message,
MessageDialog.QUESTION, new String[]{IDialogConstants.PROCEED_LABEL, IDialogConstants.CANCEL_LABEL},
0,
"Always launch with file errors",
false);
int result = dialog.open();
if (result == IDialogConstants.PROCEED_ID) {
if (dialog.getToggleState()) {
DbgActivator.getDefault().getPreferenceStore().setValue(PreferenceInitializer.CONTINUE_LAUNCH_WITH_FILE_ERRORS, MessageDialogWithToggle.ALWAYS);
}
return true;
}
else {
return false;
}
}
示例12: storePreference
import org.eclipse.jface.dialogs.MessageDialogWithToggle; //導入方法依賴的package包/類
private void storePreference( )
{
String prompt = PreferenceFactory.getInstance( )
.getPreferences( CrosstabPlugin.getDefault( ) )
.getString( CrosstabPlugin.CUBE_BUILDER_WARNING_PREFERENCE );
if ( prompt == null
|| prompt.length( ) == 0
|| ( prompt.equals( MessageDialogWithToggle.PROMPT ) ) )
{
MessageDialogWithToggle opendialog = MessageDialogWithToggle.openInformation( UIUtil.getDefaultShell( ),
Messages.getString( "CubeBuilder.warning.title" ), //$NON-NLS-1$
Messages.getString( "CubeBuilder.warning.message" ), //$NON-NLS-1$
Messages.getString( "CubeBuilder.warning.prompt" ), //$NON-NLS-1$
false,
null,
null );
if ( opendialog.getReturnCode( ) != Window.OK )
{
return;
}
if ( opendialog.getToggleState( ) == true )
{
savePreference( MessageDialogWithToggle.NEVER );
}
else
{
savePreference( MessageDialogWithToggle.PROMPT );
}
}
}
示例13: transOverwritePrompt
import org.eclipse.jface.dialogs.MessageDialogWithToggle; //導入方法依賴的package包/類
public boolean transOverwritePrompt(TransMeta transMeta) {
MessageDialogWithToggle md = new MessageDialogWithToggle(shell, BaseMessages.getString(PKG, "RepositoryImportDialog.OverwriteTrans.Title"), null, BaseMessages.getString(PKG, "RepositoryImportDialog.OverwriteTrans.Message", transMeta.getName()),
MessageDialog.QUESTION, new String[] { BaseMessages.getString(PKG, "System.Button.Yes"), BaseMessages.getString(PKG, "System.Button.No") }, 1, BaseMessages.getString(PKG, "RepositoryImportDialog.DontAskAgain.Label"), !askOverwrite);
MessageDialogWithToggle.setDefaultImage(GUIResource.getInstance().getImageSpoon());
int answer = md.open();
askOverwrite = !md.getToggleState();
return (answer & 0xFF) == 0;
}
示例14: jobOverwritePrompt
import org.eclipse.jface.dialogs.MessageDialogWithToggle; //導入方法依賴的package包/類
public boolean jobOverwritePrompt(JobMeta jobMeta) {
MessageDialogWithToggle md = new MessageDialogWithToggle(shell, BaseMessages.getString(PKG, "RepositoryImportDialog.OverwriteJob.Title"), null, BaseMessages.getString(PKG, "RepositoryImportDialog.OverwriteJob.Message", jobMeta.getName()),
MessageDialog.QUESTION, new String[] { BaseMessages.getString(PKG, "System.Button.Yes"), BaseMessages.getString(PKG, "System.Button.No") }, 1, BaseMessages.getString(PKG, "RepositoryImportDialog.DontAskAgain.Label"), !askOverwrite);
MessageDialogWithToggle.setDefaultImage(GUIResource.getInstance().getImageSpoon());
int answer = md.open();
askOverwrite = !md.getToggleState();
return (answer & 0xFF) == 0;
}
示例15: getDeleteDefinition
import org.eclipse.jface.dialogs.MessageDialogWithToggle; //導入方法依賴的package包/類
/**
* Verify if the definition associated with the element should be deleted.
*
* @param element
* The element to delete
* @return TRUE if the definition should be delete.
*/
public static boolean getDeleteDefinition(URNmodelElement element) {
if (DeletionContext.isPerformingCutAction() || DeletionContext.isPerformingPasteAction()) return false;
String currentPrefValue = getPreferenceStore().getString(PREF_DELDEFINITION);
if (currentPrefValue.equals(PREF_ALWAYS)) {
return true;
} else if (currentPrefValue.equals(PREF_NEVER)) {
return false;
} else {
// Must prompt the user if he wants to delete the definition
MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoQuestion(new Shell(), Messages.getString("DeletePreferences_Delete") + URNNamingHelper.getName(element) //$NON-NLS-1$
+ Messages.getString("DeletePreferences_Definition"), Messages.getString("DeletePreferences_NoMoreRefAssociated") + URNNamingHelper.getName(element) //$NON-NLS-1$ //$NON-NLS-2$
+ Messages.getString("DeletePreferences_DoYouWantToDelete"), Messages.getString("DeletePreferences_Remember"), false, null, "DELETE_PREFERENCE"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
if (dialog.getReturnCode() == IDialogConstants.YES_ID) {
if (dialog.getToggleState()) {
getPreferenceStore().setValue(PREF_DELDEFINITION, PREF_ALWAYS);
}
return true;
} else {
if (dialog.getToggleState()) {
getPreferenceStore().setValue(PREF_DELDEFINITION, PREF_NEVER);
}
return false;
}
}
}