Search in sources :

Example 86 with MessageDialog

use of org.eclipse.jface.dialogs.MessageDialog in project nebula.widgets.nattable by eclipse.

the class CrossValidationDialogErrorHandling method showWarningDialog.

@Override
protected void showWarningDialog(String dialogMessage, String dialogTitle) {
    if (!isWarningDialogActive()) {
        if (dialogMessage != null) {
            MessageDialog warningDialog = new MessageDialog(Display.getCurrent().getActiveShell(), dialogTitle, null, dialogMessage, MessageDialog.WARNING, new String[] { getChangeButtonLabel(), getDiscardButtonLabel(), "Commit" }, 0);
            // if discard was selected close the editor
            int returnCode = warningDialog.open();
            if (returnCode == 1) {
                this.editor.close();
            } else if (returnCode == 2) {
                this.editor.commit(MoveDirectionEnum.NONE, true, true);
            }
        }
    }
}
Also used : MessageDialog(org.eclipse.jface.dialogs.MessageDialog)

Example 87 with MessageDialog

use of org.eclipse.jface.dialogs.MessageDialog in project webtools.sourceediting by eclipse.

the class JAXPJavaLaunchConfigurationDelegate method preLaunchCheck.

@Override
public boolean preLaunchCheck(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException {
    this.launchHelper = new LaunchHelper(configuration);
    if (mode.equals(ILaunchManager.DEBUG_MODE)) {
        // TODO don't like having UI code in the launching plugin...where
        // else can it go?
        final IProcessorInstall install = getProcessorInstall(configuration, ILaunchManager.RUN_MODE);
        if (install.getDebugger() == null) {
            final boolean[] result = new boolean[] { false };
            // open a dialog for choosing a different install that does have
            // an associated debugger
            PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {

                public void run() {
                    String debuggingInstallId = JAXPLaunchingPlugin.getDefault().getPluginPreferences().getString(JAXPLaunchConfigurationConstants.ATTR_DEFAULT_DEBUGGING_INSTALL_ID);
                    IProcessorInstall processor = JAXPRuntime.getProcessor(debuggingInstallId);
                    IWorkbenchWindow dw = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
                    String title = Messages.XSLTLaunchConfigurationDelegate_0;
                    String message = Messages.XSLTLaunchConfigurationDelegate_1 + install.getName() + Messages.XSLTLaunchConfigurationDelegate_2 + Messages.XSLTLaunchConfigurationDelegate_3 + processor.getName() + Messages.XSLTLaunchConfigurationDelegate_4;
                    MessageDialog dialog = new MessageDialog(dw.getShell(), title, null, message, MessageDialog.QUESTION, new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, // yes
                    0);
                    // is
                    // the
                    // default
                    result[0] = dialog.open() == 0;
                }
            });
            return result[0];
        } else {
            String debuggerTF = install.getDebugger().getTransformerFactory();
            String installTF = launchHelper.getTransformerFactory() == null ? null : launchHelper.getTransformerFactory().getFactoryClass();
            if (!debuggerTF.equals(installTF)) {
                PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {

                    public void run() {
                        IWorkbenchWindow dw = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
                        String title = Messages.JAXPJavaLaunchConfigurationDelegate_0;
                        String message = install.getName() + Messages.JAXPJavaLaunchConfigurationDelegate_1 + launchHelper.getTransformerFactory().getName() + Messages.JAXPJavaLaunchConfigurationDelegate_2 + Messages.JAXPJavaLaunchConfigurationDelegate_3 + launchHelper.getTransformerFactory().getName() + Messages.JAXPJavaLaunchConfigurationDelegate_4;
                        MessageDialog dialog = new MessageDialog(dw.getShell(), title, null, message, MessageDialog.WARNING, new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, // yes is the default
                        0);
                        dialog.open();
                    }
                });
            }
        }
    }
    return super.preLaunchCheck(configuration, mode, monitor);
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IProcessorInstall(org.eclipse.wst.xsl.jaxp.launching.IProcessorInstall) MessageDialog(org.eclipse.jface.dialogs.MessageDialog)

Example 88 with MessageDialog

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

the class ServerEditor method checkAndCloseEditorOnDeletedServer.

void checkAndCloseEditorOnDeletedServer() {
    // check for deleted files
    if (resourceDeleted) {
        String title = Messages.editorResourceDeleteTitle;
        String message = null;
        if (server != null)
            message = NLS.bind(Messages.editorResourceDeleteServerMessage, server.getName());
        String[] labels = new String[] { Messages.editorResourceDeleteSave, IDialogConstants.CLOSE_LABEL };
        MessageDialog dialog = new MessageDialog(getEditorSite().getShell(), title, null, message, MessageDialog.INFORMATION, labels, 0);
        if (dialog.open() == 0)
            doSave(new NullProgressMonitor());
        else
            closeEditor();
    }
    resourceDeleted = false;
}
Also used : MessageDialog(org.eclipse.jface.dialogs.MessageDialog)

Example 89 with MessageDialog

use of org.eclipse.jface.dialogs.MessageDialog in project epp.mpc by eclipse.

the class MarketplaceWizard method notifyNonInstallableItems.

protected void notifyNonInstallableItems(final List<CatalogItem> noninstallableItems) {
    MessageDialog dialog = new MessageDialog(getShell(), Messages.MarketplaceWizard_UnableToInstallSolutions, null, Messages.MarketplaceWizard_IncompatibleSolutionsMessage, MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL }, 0) {

        @Override
        protected Control createCustomArea(Composite parent) {
            parent.setLayout(new GridLayout());
            TableViewer tableViewer = new TableViewer(parent, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
            tableViewer.setLabelProvider(createLabelProvider());
            tableViewer.setContentProvider(createContentProvider());
            tableViewer.setInput(noninstallableItems);
            Control tableControl = tableViewer.getControl();
            GridDataFactory.fillDefaults().grab(true, true).align(SWT.FILL, SWT.FILL).hint(SWT.DEFAULT, Math.max(40, Math.min(120, tableControl.computeSize(SWT.DEFAULT, SWT.DEFAULT).y))).applyTo(tableControl);
            return tableControl;
        }

        private LabelProvider createLabelProvider() {
            return new LabelProvider() {

                @Override
                public String getText(Object element) {
                    // we could show that with an IStyledLabelProvider behind the name
                    return ((CatalogItem) element).getName();
                }

                @Override
                public Image getImage(Object element) {
                    return MarketplaceClientUiPlugin.getInstance().getImageRegistry().get(MarketplaceClientUiPlugin.IU_ICON_ERROR);
                }
            };
        }

        private IStructuredContentProvider createContentProvider() {
            return new IStructuredContentProvider() {

                public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
                }

                public void dispose() {
                }

                public Object[] getElements(Object inputElement) {
                    return ((List<?>) inputElement).toArray();
                }
            };
        }
    };
    dialog.open();
}
Also used : CatalogItem(org.eclipse.equinox.internal.p2.discovery.model.CatalogItem) GridLayout(org.eclipse.swt.layout.GridLayout) Control(org.eclipse.swt.widgets.Control) Composite(org.eclipse.swt.widgets.Composite) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) TableViewer(org.eclipse.jface.viewers.TableViewer) Viewer(org.eclipse.jface.viewers.Viewer) List(java.util.List) ArrayList(java.util.ArrayList) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) TableViewer(org.eclipse.jface.viewers.TableViewer) LabelProvider(org.eclipse.jface.viewers.LabelProvider)

Example 90 with MessageDialog

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

the class BuildLangHandler method checkLanguageFileEncoding.

protected boolean checkLanguageFileEncoding(IFile langFile) throws CoreException {
    IProgressMonitor monitor = new NullProgressMonitor();
    try {
        langFile.refreshLocal(IResource.DEPTH_INFINITE, monitor);
    } catch (Exception e) {
        PortletUIPlugin.logError(e);
    }
    String charset = langFile.getCharset(true);
    if (!"UTF-8".equals(charset)) {
        String dialogMessage = NLS.bind(Msgs.languageFileCharacterSet, charset);
        Display display = UIUtil.getActiveShell().getDisplay();
        MessageDialog dialog = new MessageDialog(UIUtil.getActiveShell(), Msgs.incompatibleCharacterSet, display.getSystemImage(SWT.ICON_WARNING), dialogMessage, MessageDialog.WARNING, new String[] { Msgs.yes, Msgs.no, Msgs.cancel }, 0);
        int retval = dialog.open();
        if (retval == 0) {
            langFile.setCharset("UTF-8", monitor);
            String question = NLS.bind(Msgs.forcedEditFile, langFile.getName());
            if (MessageDialog.openQuestion(UIUtil.getActiveShell(), Msgs.previewFile, question)) {
                IWorkbench workbench = PlatformUI.getWorkbench();
                IDE.openEditor(workbench.getActiveWorkbenchWindow().getActivePage(), langFile);
            }
            return false;
        } else if (retval == 2) {
            return false;
        }
    }
    return true;
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) CoreException(org.eclipse.core.runtime.CoreException) ExecutionException(org.eclipse.core.commands.ExecutionException) Display(org.eclipse.swt.widgets.Display)

Aggregations

MessageDialog (org.eclipse.jface.dialogs.MessageDialog)129 Shell (org.eclipse.swt.widgets.Shell)27 CoreException (org.eclipse.core.runtime.CoreException)16 IPath (org.eclipse.core.runtime.IPath)14 File (java.io.File)10 ArrayList (java.util.ArrayList)10 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)10 InvocationTargetException (java.lang.reflect.InvocationTargetException)9 Composite (org.eclipse.swt.widgets.Composite)9 SelectionEvent (org.eclipse.swt.events.SelectionEvent)7 Point (org.eclipse.swt.graphics.Point)7 IOException (java.io.IOException)6 IFile (org.eclipse.core.resources.IFile)6 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)6 List (java.util.List)5 IStatus (org.eclipse.core.runtime.IStatus)5 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)5 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)5 IWorkspaceRoot (org.eclipse.core.resources.IWorkspaceRoot)4 Path (org.eclipse.core.runtime.Path)4