Search in sources :

Example 11 with MessageDialogWithToggle

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;
}
Also used : MessageDialogWithToggle(org.eclipse.jface.dialogs.MessageDialogWithToggle)

Example 12 with MessageDialogWithToggle

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);
}
Also used : MessageDialogWithToggle(org.eclipse.jface.dialogs.MessageDialogWithToggle) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)

Example 13 with MessageDialogWithToggle

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;
}
Also used : MessageDialogWithToggle(org.eclipse.jface.dialogs.MessageDialogWithToggle) IOException(java.io.IOException) IFile(org.eclipse.core.resources.IFile) File(java.io.File) FileDialog(org.eclipse.swt.widgets.FileDialog) IProject(org.eclipse.core.resources.IProject) IEditorInput(org.eclipse.ui.IEditorInput)

Example 14 with MessageDialogWithToggle

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();
}
Also used : SQLConnection(net.sourceforge.sqlexplorer.dbproduct.SQLConnection) MessageDialogWithToggle(org.eclipse.jface.dialogs.MessageDialogWithToggle) Session(net.sourceforge.sqlexplorer.dbproduct.Session)

Example 15 with MessageDialogWithToggle

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();
            }
        }
    }
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) IPerspectiveRegistry(org.eclipse.ui.IPerspectiveRegistry) BackingStoreException(org.osgi.service.prefs.BackingStoreException) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) MessageDialogWithToggle(org.eclipse.jface.dialogs.MessageDialogWithToggle) IPerspectiveDescriptor(org.eclipse.ui.IPerspectiveDescriptor) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)

Aggregations

MessageDialogWithToggle (org.eclipse.jface.dialogs.MessageDialogWithToggle)66 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)16 TableItem (org.eclipse.swt.widgets.TableItem)8 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)6 Point (org.pentaho.di.core.gui.Point)6 ArrayList (java.util.ArrayList)5 Shell (org.eclipse.swt.widgets.Shell)5 IOException (java.io.IOException)4 IProject (org.eclipse.core.resources.IProject)4 File (java.io.File)3 Display (org.eclipse.swt.widgets.Display)3 MessageBox (org.eclipse.swt.widgets.MessageBox)3 BackingStoreException (org.osgi.service.prefs.BackingStoreException)3 QueryEditorPart (com.cubrid.common.ui.query.editor.QueryEditorPart)2 JobFamily (com.cubrid.common.ui.spi.progress.JobFamily)2 List (java.util.List)2 Job (org.eclipse.core.runtime.jobs.Job)2 IPerspectiveDescriptor (org.eclipse.ui.IPerspectiveDescriptor)2 ConnectionContainer (org.knime.core.node.workflow.ConnectionContainer)2 WorkflowManager (org.knime.core.node.workflow.WorkflowManager)2