use of org.eclipse.jface.dialogs.MessageDialogWithToggle in project egit by eclipse.
the class LaunchFinder method showContinueDialogInUI.
private static boolean showContinueDialogInUI(final IPreferenceStore store, final ILaunchConfiguration launchConfiguration) {
String[] buttons = new String[] { UIText.BranchOperationUI_Continue, IDialogConstants.CANCEL_LABEL };
String message = NLS.bind(UIText.LaunchFinder_RunningLaunchMessage, launchConfiguration.getName()) + ' ' + UIText.LaunchFinder_ContinueQuestion;
MessageDialogWithToggle continueDialog = new MessageDialogWithToggle(PlatformUI.getWorkbench().getModalDialogShellProvider().getShell(), UIText.LaunchFinder_RunningLaunchTitle, null, message, MessageDialog.NONE, buttons, 0, UIText.LaunchFinder_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;
}
use of org.eclipse.jface.dialogs.MessageDialogWithToggle in project egit by eclipse.
the class RepositoriesView method executeOpenCommandWithConfirmation.
private void executeOpenCommandWithConfirmation(RepositoryTreeNode element, String refName) {
if (!BranchOperationUI.checkoutWillShowQuestionDialog(refName)) {
IPreferenceStore store = Activator.getDefault().getPreferenceStore();
if (store.getBoolean(UIPreferences.SHOW_CHECKOUT_CONFIRMATION)) {
MessageDialogWithToggle dialog = new MessageDialogWithToggle(getViewSite().getShell(), UIText.RepositoriesView_CheckoutConfirmationTitle, null, MessageFormat.format(UIText.RepositoriesView_CheckoutConfirmationMessage, Repository.shortenRefName(refName)), MessageDialog.QUESTION, new String[] { UIText.RepositoriesView_CheckoutConfirmationDefaultButtonLabel, IDialogConstants.CANCEL_LABEL }, 0, UIText.RepositoriesView_CheckoutConfirmationToggleMessage, false);
// Since we use a custom button here, we may get back the first
// internal ID instead of Window.OK.
int result = dialog.open();
if (result != Window.OK && result != IDialogConstants.INTERNAL_ID) {
return;
}
// store and key).
if (dialog.getToggleState()) {
store.setValue(UIPreferences.SHOW_CHECKOUT_CONFIRMATION, false);
}
}
}
executeOpenCommand(element);
}
use of org.eclipse.jface.dialogs.MessageDialogWithToggle in project tdq-studio-se by Talend.
the class SQLEditor method doSave.
/**
* Implementation for save-as; returns true if successfull, false if not (i.e. the user cancelled the dialog)
*
* @return true if saved, false if cancelled
*/
public boolean doSave(boolean saveAs, IProgressMonitor monitor) {
IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
boolean haveProjects = projects != null && projects.length > 0;
IEditorInput input = getEditorInput();
boolean saveInsideProject = true;
File file = null;
if (input instanceof SQLEditorInput) {
SQLEditorInput seInput = (SQLEditorInput) input;
file = seInput.getFile();
}
// but if we're doing a save-as then recheck with the user
if (file != null && !saveAs) {
saveInsideProject = false;
} else if (input instanceof SQLEditorInput) {
IConstants.Confirm confirm = SQLExplorerPlugin.getConfirm(IConstants.CONFIRM_YNA_SAVING_INSIDE_PROJECT);
// If we're supposed to ask the user...
if (confirm == IConstants.Confirm.ASK) {
// Build up the message to ask
String msg = Messages.getString("Confirm.SaveInsideProject.Intro") + "\n\n";
if (!haveProjects) {
msg = msg + Messages.getString("Confirm.SaveInsideProject.NoProjectsConfigured") + "\n\n";
}
msg = msg + Messages.getString("Confirm.SaveInsideProject.SaveInProject");
// Ask them
MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoCancelQuestion(getSite().getShell(), Messages.getString("SQLEditor.SaveAsDialog.Title"), msg, Messages.getString("Confirm.SaveInsideProject.Toggle"), false, null, null);
if (dialog.getReturnCode() == IDialogConstants.CANCEL_ID) {
return false;
}
// If they turned on the toggle ("Use this answer in the future"), update the preferences
if (dialog.getToggleState()) {
confirm = dialog.getReturnCode() == IDialogConstants.YES_ID ? IConstants.Confirm.YES : IConstants.Confirm.NO;
SQLExplorerPlugin.getDefault().getPreferenceStore().setValue(IConstants.CONFIRM_YNA_SAVING_INSIDE_PROJECT, confirm.toString());
}
// Whether to save inside or outside
saveInsideProject = dialog.getReturnCode() == IDialogConstants.YES_ID;
} else {
saveInsideProject = confirm == IConstants.Confirm.YES;
}
}
// Saving inside a project - convert SQLEditorInput into a Resource by letting TextEditor do the work for us
if (saveInsideProject) {
if (!haveProjects) {
MessageDialog.openError(getSite().getShell(), Messages.getString("Confirm.SaveInsideProject.Title"), Messages.getString("Confirm.SaveInsideProject.CreateAProject"));
return false;
}
if (input instanceof SQLEditorInput) {
saveAs = true;
}
// Save it and use their EditorInput
if (saveAs) {
textEditor.doSaveAs();
} else {
if (monitor == null) {
monitor = textEditor.getProgressMonitor();
}
textEditor.doSave(monitor);
}
if (input.equals(textEditor.getEditorInput())) {
return false;
}
input = textEditor.getEditorInput();
setInput(input);
// Update the display
setPartName(input.getName());
setTitleToolTip(input.getToolTipText());
} else {
try {
if (file == null || saveAs) {
FileDialog dialog = new FileDialog(getSite().getShell(), SWT.SAVE);
dialog.setText(Messages.getString("SQLEditor.SaveAsDialog.Title"));
dialog.setFilterExtensions(SUPPORTED_FILETYPES);
dialog.setFilterNames(SUPPORTED_FILETYPES);
dialog.setFileName("*.sql");
String path = dialog.open();
if (path == null) {
return false;
}
file = new File(path);
}
// Save it
saveToFile(file);
// Update the editor input
input = new SQLEditorInput(file);
setInput(input);
setPartName(input.getName());
setTitleToolTip(input.getToolTipText());
} catch (IOException e) {
SQLExplorerPlugin.error("Couldn't save sql", e);
MessageDialog.openError(getSite().getShell(), Messages.getString("SQLEditor.SaveAsDialog.Error"), e.getMessage());
return false;
}
}
setIsDirty(textEditor.isDirty());
return true;
}
use of org.eclipse.jface.dialogs.MessageDialogWithToggle in project tdq-studio-se by Talend.
the class CloseConnectionAction method run.
public void run() {
boolean confirm = SQLExplorerPlugin.getDefault().getPluginPreferences().getBoolean(IConstants.CONFIRM_BOOL_CLOSE_CONNECTION);
for (SQLConnection connection : getView().getSelectedConnections(false)) {
Session session = connection.getSession();
if (session != null && !session.isConnectionInUse()) {
if (confirm) {
MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoQuestion(getView().getSite().getShell(), Messages.getString("ConnectionsView.Actions.CloseAll.Confirm.Title"), Messages.getString("ConnectionsView.Actions.CloseAll.Confirm.Message"), Messages.getString("ConnectionsView.Actions.CloseAll.Confirm.Toggle"), false, null, null);
if (dialog.getToggleState() && dialog.getReturnCode() == IDialogConstants.YES_ID)
SQLExplorerPlugin.getDefault().getPluginPreferences().setValue(IConstants.CONFIRM_BOOL_CLOSE_CONNECTION, false);
if (dialog.getReturnCode() != IDialogConstants.YES_ID)
return;
}
session.disposeConnection();
} else if (session == null)
connection.getUser().releaseFromPool(connection);
}
getView().refresh();
}
use of org.eclipse.jface.dialogs.MessageDialogWithToggle in project statecharts by Yakindu.
the class PerspectiveUtil method switchToModelingPerspective.
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();
}
}
}
}
Aggregations