Search in sources :

Example 16 with MessageDialogWithToggle

use of org.eclipse.jface.dialogs.MessageDialogWithToggle in project tdq-studio-se by Talend.

the class ExecSQLAction method run.

public void run() {
    try {
        // Find out how much to restrict results by
        Integer iMax = _editor.getLimitResults();
        if (iMax == null)
            _editor.getSite().getShell().getDisplay().asyncExec(new Runnable() {

                public void run() {
                    MessageDialog.openError(_editor.getSite().getShell(), Messages.getString("SQLEditor.Error.InvalidRowLimit.Title"), Messages.getString("SQLEditor.Error.InvalidRowLimit"));
                }
            });
        final int maxresults = (iMax == null) ? 0 : iMax.intValue();
        if (maxresults < 0)
            throw new Exception(Messages.getString("SQLEditor.LimitRows.Error"));
        final ExecSQLAction action = this;
        boolean confirmWarnLargeMaxrows = SQLExplorerPlugin.getDefault().getPluginPreferences().getBoolean(IConstants.CONFIRM_BOOL_WARN_LARGE_MAXROWS);
        int warnLimit = SQLExplorerPlugin.getDefault().getPluginPreferences().getInt(IConstants.WARN_LIMIT);
        // Confirm with the user if they've left it too large
        if (confirmWarnLargeMaxrows && (maxresults == 0 || maxresults > warnLimit)) {
            _editor.getSite().getShell().getDisplay().asyncExec(new Runnable() {

                public void run() {
                    MessageDialogWithToggle dlg = MessageDialogWithToggle.openOkCancelConfirm(_editor.getSite().getShell(), Messages.getString("SQLEditor.LimitRows.ConfirmNoLimit.Title"), Messages.getString("SQLEditor.LimitRows.ConfirmNoLimit.Message"), Messages.getString("SQLEditor.LimitRows.ConfirmNoLimit.Toggle"), false, null, null);
                    if (dlg.getReturnCode() == IDialogConstants.OK_ID) {
                        if (dlg.getToggleState())
                            SQLExplorerPlugin.getDefault().getPluginPreferences().setValue(IConstants.CONFIRM_BOOL_WARN_LARGE_MAXROWS, false);
                        action.run(maxresults);
                    }
                }
            });
        // Run it
        } else {
            action.run(maxresults);
        }
    } catch (final Exception e) {
        _editor.getSite().getShell().getDisplay().asyncExec(new Runnable() {

            public void run() {
                MessageDialog.openError(_editor.getSite().getShell(), Messages.getString("SQLResultsView.Error.Title"), e.getClass().getCanonicalName() + ": " + e.getMessage());
            }
        });
    }
}
Also used : MessageDialogWithToggle(org.eclipse.jface.dialogs.MessageDialogWithToggle) ParserException(net.sourceforge.sqlexplorer.parsers.ParserException)

Example 17 with MessageDialogWithToggle

use of org.eclipse.jface.dialogs.MessageDialogWithToggle in project whole by wholeplatform.

the class QuitHandler method execute.

@Execute
public void execute(EPartService partService, IWorkbench workbench, Shell shell) {
    IEclipsePreferences preferences = InstanceScope.INSTANCE.getNode("org.whole.product.e4.lw");
    boolean exitWithoutPrompt = preferences.getBoolean("exitWithoutPrompt", false);
    if (exitWithoutPrompt) {
        safeCloseWorkbench(partService, workbench);
        return;
    }
    MessageDialogWithToggle dialog = MessageDialogWithToggle.openOkCancelConfirm(shell, "Confirm exit", "Exit Whole Platform?", "Always exit without prompt", exitWithoutPrompt, null, null);
    if (dialog.getReturnCode() == Window.OK) {
        preferences.putBoolean("exitWithoutPrompt", dialog.getToggleState());
        try {
            preferences.flush();
        } catch (BackingStoreException e) {
        }
        safeCloseWorkbench(partService, workbench);
    }
}
Also used : IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) BackingStoreException(org.osgi.service.prefs.BackingStoreException) MessageDialogWithToggle(org.eclipse.jface.dialogs.MessageDialogWithToggle) Execute(org.eclipse.e4.core.di.annotations.Execute)

Example 18 with MessageDialogWithToggle

use of org.eclipse.jface.dialogs.MessageDialogWithToggle in project webtools.servertools by eclipse.

the class PreferenceUtil method confirmModuleRemoval.

public static boolean confirmModuleRemoval(IServerAttributes server, Shell shell, List<IModule> moduleList) {
    // Get preference value to see if the confirmation dialog should appear or not. Default is to show the dialog.
    boolean doNotShowDialog = ServerUIPlugin.getPreferences().getDoNotShowRemoveModuleWarning();
    if (!doNotShowDialog) {
        String message = null;
        String id = server.getServerType().getId();
        RemoveModuleMessageExtension targetExtension = ServerUIPlugin.getRemoveModuleMessageExtension(id);
        String customMessage = null;
        if (moduleList.size() > 0) {
            if (targetExtension != null) {
                customMessage = targetExtension.getConfirmationMessage(server, moduleList.toArray(new IModule[0]));
            }
            // The extension might still return null or an empty string.  If so, then use the default/original message.
            if (customMessage == null || customMessage.length() == 0) {
                if (moduleList.size() == 1) {
                    // Default singular
                    message = Messages.dialogRemoveModuleConfirm;
                } else {
                    // Default plural
                    message = Messages.dialogRemoveModulesConfirm;
                }
            } else {
                message = customMessage;
            }
        }
        MessageDialogWithToggle messageWithToggle = MessageDialogWithToggle.openOkCancelConfirm(shell, Messages.defaultDialogTitle, message, Messages.doNotShowAgain, false, null, null);
        // If cancel is pressed, do not update the preference even if the checkbox changed.
        if (messageWithToggle.getReturnCode() == Window.CANCEL) {
            // Do not remove, return false
            return false;
        }
        // If OK was pressed, then also update the preference
        ServerUIPlugin.getPreferences().setDoNotShowRemoveModuleWarning(messageWithToggle.getToggleState());
    }
    // Proceed with removal
    return true;
}
Also used : RemoveModuleMessageExtension(org.eclipse.wst.server.ui.RemoveModuleMessageExtension) MessageDialogWithToggle(org.eclipse.jface.dialogs.MessageDialogWithToggle)

Example 19 with MessageDialogWithToggle

use of org.eclipse.jface.dialogs.MessageDialogWithToggle in project mdw-designer by CenturyLinkCloud.

the class DesignerPerspective method promptForShowPerspective.

public static void promptForShowPerspective(IWorkbenchWindow activeWindow, WorkflowElement workflowElement) {
    if (MdwPlugin.isRcp())
        return;
    IPerspectiveDescriptor pd = activeWindow.getActivePage().getPerspective();
    if (!"mdw.perspectives.designer".equals(pd.getId())) {
        boolean switchPerspective = false;
        String switchPref = MdwPlugin.getStringPref(PreferenceConstants.PREFS_SWITCH_TO_DESIGNER_PERSPECTIVE);
        if (switchPref == null || switchPref.length() == 0) {
            String message = "Resources of type '" + workflowElement.getTitle() + "' are associated with MDW Designer Perspective.  Switch to this perspective now?";
            String toggleMessage = "Remember my answer and don't ask me again";
            MessageDialogWithToggle mdwt = MessageDialogWithToggle.openYesNoQuestion(activeWindow.getShell(), "Switch Perspective", message, toggleMessage, false, MdwPlugin.getDefault().getPreferenceStore(), PreferenceConstants.PREFS_SWITCH_TO_DESIGNER_PERSPECTIVE);
            switchPerspective = mdwt.getReturnCode() == IDialogConstants.YES_ID || mdwt.getReturnCode() == IDialogConstants.OK_ID;
        } else {
            switchPerspective = switchPref.equalsIgnoreCase("always");
        }
        if (switchPerspective) {
            try {
                showPerspective(activeWindow);
            } catch (Exception ex) {
                PluginMessages.uiError(activeWindow.getShell(), ex, "Show Perspective", workflowElement.getProject());
            }
        }
    }
}
Also used : MessageDialogWithToggle(org.eclipse.jface.dialogs.MessageDialogWithToggle) IPerspectiveDescriptor(org.eclipse.ui.IPerspectiveDescriptor) WorkbenchException(org.eclipse.ui.WorkbenchException)

Example 20 with MessageDialogWithToggle

use of org.eclipse.jface.dialogs.MessageDialogWithToggle in project mdw-designer by CenturyLinkCloud.

the class ArtifactResourceListener method resourceChanged.

public void resourceChanged(IResourceChangeEvent event) {
    if (event.getType() == IResourceChangeEvent.POST_CHANGE) {
        IResourceDelta rootDelta = event.getDelta();
        IResourceDelta artifactDelta = rootDelta.findMember(tempFile.getFullPath());
        if (artifactDelta != null && artifactDelta.getKind() == IResourceDelta.CHANGED && (artifactDelta.getFlags() & IResourceDelta.CONTENT) != 0) {
            // the file has been changed
            final Display display = Display.getCurrent();
            if (display != null) {
                display.syncExec(new Runnable() {

                    public void run() {
                        byte[] newValue = PluginUtil.readFile(tempFile);
                        String attrVal = valueProvider.isBinary() ? encodeBase64(newValue) : new String(newValue);
                        if (getElement() instanceof Activity || getElement() instanceof WorkflowProcess) {
                            WorkflowProcess processVersion = null;
                            if (getElement() instanceof Activity) {
                                Activity activity = (Activity) getElement();
                                activity.setAttribute(valueProvider.getAttributeName(), attrVal);
                                processVersion = activity.getProcess();
                            } else {
                                processVersion = (WorkflowProcess) getElement();
                                processVersion.setAttribute(valueProvider.getAttributeName(), attrVal);
                            }
                            processVersion.fireDirtyStateChanged(true);
                            ProcessEditor processEditor = findProcessEditor(processVersion);
                            if (processEditor == null) {
                                try {
                                    processEditor = openProcessEditor(processVersion);
                                    IEditorPart tempFileEditor = findTempFileEditor(tempFile);
                                    if (tempFileEditor != null)
                                        processEditor.addActiveScriptEditor(tempFileEditor);
                                } catch (PartInitException ex) {
                                    PluginMessages.uiError(display.getActiveShell(), ex, "Open Process", processVersion.getProject());
                                    return;
                                }
                            }
                            processVersion = processEditor.getProcess();
                            if (processVersion.isReadOnly()) {
                                WorkflowProject workflowProject = getElement().getProject();
                                PluginMessages.uiMessage("Process for '" + getElement().getName() + "' in workflow project '" + workflowProject.getName() + "' is Read Only.", "Not Updated", workflowProject, PluginMessages.INFO_MESSAGE);
                                return;
                            }
                            if (getElement() instanceof Activity) {
                                Activity activity = (Activity) getElement();
                                // previously-opened process version
                                for (Node node : processEditor.getProcessCanvasWrapper().getFlowchartPage().getProcess().nodes) {
                                    if (activity.getLogicalId() != null && activity.getLogicalId().equals(node.getAttribute("LOGICAL_ID"))) {
                                        node.setAttribute(valueProvider.getAttributeName(), attrVal);
                                        ActivityImpl actImpl = processVersion.getProject().getActivityImpl(node.nodet.getImplementorClassName());
                                        element = new Activity(node, processVersion, actImpl);
                                    }
                                }
                                activity.fireDirtyStateChanged(true);
                            }
                            processEditor.dirtyStateChanged(true);
                            valueProvider.afterTempFileSaved();
                            // process editor is open
                            String message = valueProvider.getArtifactTypeDescription() + " temporary file has been saved locally; however, you must still save the process for the changes to be persisted.";
                            String toggleMessage = "Don't show me this message again.";
                            IPreferenceStore prefsStore = MdwPlugin.getDefault().getPreferenceStore();
                            String prefsKey = "Mdw" + valueProvider.getArtifactTypeDescription() + "SuppressSaveNag";
                            if (!prefsStore.getBoolean(prefsKey)) {
                                MessageDialogWithToggle dialog = MessageDialogWithToggle.openInformation(display.getActiveShell(), "Artifact Save", message, toggleMessage, false, null, null);
                                prefsStore.setValue(prefsKey, dialog.getToggleState());
                            }
                        }
                    }
                });
            }
        }
    }
}
Also used : Node(com.centurylink.mdw.designer.display.Node) Activity(com.centurylink.mdw.plugin.designer.model.Activity) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) IEditorPart(org.eclipse.ui.IEditorPart) ActivityImpl(com.centurylink.mdw.plugin.designer.model.ActivityImpl) MessageDialogWithToggle(org.eclipse.jface.dialogs.MessageDialogWithToggle) PartInitException(org.eclipse.ui.PartInitException) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess) ProcessEditor(com.centurylink.mdw.plugin.designer.editors.ProcessEditor) IResourceDelta(org.eclipse.core.resources.IResourceDelta) Display(org.eclipse.swt.widgets.Display)

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