Search in sources :

Example 46 with MessageDialogWithToggle

use of org.eclipse.jface.dialogs.MessageDialogWithToggle in project eclipse-integration-commons by spring-projects.

the class ProjectSelectionPart method changeProject.

protected IProject changeProject(String projectNameToSwitch) {
    if (projectNameToSwitch == null) {
        return null;
    }
    int selectedIndex = -1;
    String[] availableProjects = projectList.getItems();
    for (int i = 0; i < availableProjects.length; i++) {
        if (projectNameToSwitch.equals(availableProjects[i])) {
            selectedIndex = i;
            break;
        }
    }
    // Not found in selection
    if (selectedIndex < 0) {
        return null;
    }
    if (showProjectSwitchDialogue && !MessageDialogWithToggle.ALWAYS.equals(FrameworkUIActivator.getDefault().getPreferenceStore().getString(DO_NOT_PROMPT_PROJECT_SWITCH))) {
        MessageDialogWithToggle dialogue = MessageDialogWithToggle.openYesNoCancelQuestion(getShell(), "Confirm Project Switch", "Switching to project: " + projectNameToSwitch + ". All current plugin changes will be lost. Do you wish to proceed?", "Do not show this dialogue again.", false, FrameworkUIActivator.getDefault().getPreferenceStore(), DO_NOT_PROMPT_PROJECT_SWITCH);
        if (dialogue.getReturnCode() != IDialogConstants.YES_ID) {
            // Restore the selection in the project list
            projectList.select(getIndex(getSelectedProjectName()));
            return null;
        }
    }
    // Do the actual switch
    setSelectedProjectName(projectNameToSwitch);
    projectList.select(selectedIndex);
    IProject project = getSelectedProject();
    handleProjectChange(project);
    return project;
}
Also used : MessageDialogWithToggle(org.eclipse.jface.dialogs.MessageDialogWithToggle) IProject(org.eclipse.core.resources.IProject)

Example 47 with MessageDialogWithToggle

use of org.eclipse.jface.dialogs.MessageDialogWithToggle in project liferay-ide by liferay.

the class WorkflowDefinitionEditor method createPages.

@Override
protected void createPages() {
    super.createPages();
    try {
        IWorkbench workBench = PlatformUI.getWorkbench();
        IWorkbenchWindow workBenchWindow = workBench.getActiveWorkbenchWindow();
        IWorkbenchPage workBenchPage = workBenchWindow.getActivePage();
        IPerspectiveDescriptor descripter = workBenchPage.getPerspective();
        String id = descripter.getId();
        if (WorkflowDesignerPerspectiveFactory.ID.equals(id)) {
            return;
        }
    } catch (Exception e) {
    }
    KaleoUI kaleoUI = KaleoUI.getDefault();
    IPreferenceStore preferenceStore = kaleoUI.getPreferenceStore();
    String perspectiveSwitch = preferenceStore.getString(KaleoUIPreferenceConstants.EDITOR_PERSPECTIVE_SWITCH);
    boolean remember = false;
    boolean openPerspective = false;
    if (MessageDialogWithToggle.PROMPT.equals(perspectiveSwitch)) {
        String descriptFile = "This kind of file is associated with the Kaleo Designer perspective.\n\n";
        String descriptPerspective = "This perspective is designed to support Kaleo Workflow development. ";
        String descriptPlace = "It places the Properties and Palette views in optimal location relative to the editor area.\n\n";
        String descriptHint = "Do you want to open this perspective now?";
        MessageDialogWithToggle toggleDialog = MessageDialogWithToggle.openYesNoQuestion(getSite().getShell(), "Open Kaleo Designer Perspective?", descriptFile + descriptPerspective + descriptPlace + descriptHint, "Remember my decision", false, KaleoUI.getDefault().getPreferenceStore(), KaleoUIPreferenceConstants.EDITOR_PERSPECTIVE_SWITCH);
        remember = toggleDialog.getToggleState();
        openPerspective = toggleDialog.getReturnCode() == IDialogConstants.YES_ID;
        if (remember) {
            KaleoUI.getPrefStore().setValue(KaleoUIPreferenceConstants.EDITOR_PERSPECTIVE_SWITCH, openPerspective ? MessageDialogWithToggle.ALWAYS : MessageDialogWithToggle.NEVER);
        }
    } else if (MessageDialogWithToggle.ALWAYS.equals(perspectiveSwitch)) {
        openPerspective = true;
    }
    if (openPerspective) {
        _switchToKaleoDesignerPerspective();
    }
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) MessageDialogWithToggle(org.eclipse.jface.dialogs.MessageDialogWithToggle) IPerspectiveDescriptor(org.eclipse.ui.IPerspectiveDescriptor) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) JSONException(org.json.JSONException) PartInitException(org.eclipse.ui.PartInitException) KaleoUI(com.liferay.ide.kaleo.ui.KaleoUI)

Example 48 with MessageDialogWithToggle

use of org.eclipse.jface.dialogs.MessageDialogWithToggle in project dsl-devkit by dsldevkit.

the class AbstractValidPreferencePage method performOk.

/**
 * Perform OK button.
 *
 * @return true, if successful {@inheritDoc}
 */
@Override
public boolean performOk() {
    try {
        if (preferences.needsSaving()) {
            preferences.save();
        }
    } catch (final IOException e) {
        // $NON-NLS-1$
        LOGGER.error("Unable to save general preference page preferences", e);
    }
    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();
}
Also used : MessageDialogWithToggle(org.eclipse.jface.dialogs.MessageDialogWithToggle) IOException(java.io.IOException)

Example 49 with MessageDialogWithToggle

use of org.eclipse.jface.dialogs.MessageDialogWithToggle in project janrufmonitor by tbrandt77.

the class AbstractBaseApplication method checkAmountOfEntries.

protected void checkAmountOfEntries(long time1, long time2) {
    long delta = time2 - time1;
    long entries = this.m_controller.countElements();
    boolean doNotShowmessage = this.getConfiguration().getProperty(CFG_SHOW_ENTRY_WARNING, "false").equalsIgnoreCase("true");
    if (!doNotShowmessage && delta > 2000 && entries > 100) {
        long right_entry = Math.round((entries / (delta / 1000)) * 0.9);
        String message = this.getI18nManager().getString(this.getNamespace(), "timemessage", "description", this.getLanguage());
        message = StringUtils.replaceString(message, "{%1}", Long.toString(entries));
        message = StringUtils.replaceString(message, "{%2}", Long.toString(right_entry));
        PropagationFactory.getInstance().fire(new Message(Message.WARNING, getI18nManager().getString(Editor.NAMESPACE, "title", "label", getLanguage()), new Exception(message)), "Tray");
        MessageDialogWithToggle d = MessageDialogWithToggle.openWarning(new Shell(DisplayManager.getDefaultDisplay()), this.getI18nManager().getString(this.getNamespace(), "timemessage", "label", this.getLanguage()), message, this.getI18nManager().getString(this.getNamespace(), "confirmtimemessage", "label", this.getLanguage()), false, null, null);
        this.getConfiguration().setProperty(CFG_SHOW_ENTRY_WARNING, (d.getToggleState() ? "true" : "false"));
        this.storeConfiguration();
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) Message(de.janrufmonitor.exception.Message) MessageDialogWithToggle(org.eclipse.jface.dialogs.MessageDialogWithToggle)

Example 50 with MessageDialogWithToggle

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

the class CloseAllConnectionsAction method run.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.action.IAction#run()
     */
public void run() {
    boolean confirm = SQLExplorerPlugin.getDefault().getPluginPreferences().getBoolean(IConstants.CONFIRM_BOOL_CLOSE_ALL_CONNECTIONS);
    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_ALL_CONNECTIONS, false);
        if (dialog.getReturnCode() != IDialogConstants.YES_ID)
            return;
    }
    Set<SQLConnection> connections = getView().getSelectedConnections(true);
    for (SQLConnection connection : connections) {
        synchronized (connection) {
            Session session = connection.getSession();
            if (session != null) {
                synchronized (session) {
                    if (!session.isConnectionInUse())
                        session.disposeConnection();
                }
            } else
                connection.getUser().releaseFromPool(connection);
        }
    }
    setEnabled(false);
    getView().refresh();
}
Also used : SQLConnection(net.sourceforge.sqlexplorer.dbproduct.SQLConnection) MessageDialogWithToggle(org.eclipse.jface.dialogs.MessageDialogWithToggle) Session(net.sourceforge.sqlexplorer.dbproduct.Session)

Aggregations

MessageDialogWithToggle (org.eclipse.jface.dialogs.MessageDialogWithToggle)65 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