Example usage for org.eclipse.jface.dialogs MessageDialog openError

List of usage examples for org.eclipse.jface.dialogs MessageDialog openError

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs MessageDialog openError.

Prototype

public static void openError(Shell parent, String title, String message) 

Source Link

Document

Convenience method to open a standard error dialog.

Usage

From source file:ac.soton.xeventb.ui.AbstractXEventBActionProvider.java

License:Open Source License

/**
 * Provides an open action for IXEventBNavigatorObject
 * //  ww  w. j av  a 2s . c  om
 * @param site
 *          The information for the action provider
 * @return An open action
 */
public Action getOpenAction(final ICommonActionExtensionSite site) {
    final Action doubleClickAction = new Action("Open") {
        @Override
        public void run() {
            final ISelection selection = site.getStructuredViewer().getSelection();
            final Object obj = ((IStructuredSelection) selection).getFirstElement();
            if ((obj instanceof IXEventBNavigatorObject)) {
                final IFile resource = ((IXEventBNavigatorObject) obj).getResource();
                final IEditorDescriptor desc = IDE.getDefaultEditor(resource);
                try {
                    final IWorkbenchPage activePage = XEventBUIPlugin.getDefault().getWorkbench()
                            .getActiveWorkbenchWindow().getActivePage();
                    FileEditorInput _fileEditorInput = new FileEditorInput(resource);
                    final IEditorPart editor = activePage.openEditor(_fileEditorInput, desc.getId());
                    if ((editor == null)) {
                        return;
                    }
                } catch (final Throwable _t) {
                    if (_t instanceof PartInitException) {
                        final String errorMsg = "Error opening Editor";
                        MessageDialog.openError(null, null, errorMsg);
                    } else {
                        throw Exceptions.sneakyThrow(_t);
                    }
                }
            }
        }
    };
    return doubleClickAction;
}

From source file:actions.AddToPlaylistAction.java

License:Open Source License

public void handleEvent(Event e) {
    int[] indices = table.getSelectionIndices();

    if (indices.length > 0) {
        try {/*w w  w  .  ja va  2  s .c  om*/
            for (int index : indices) {
                playlist.addTrack(eventList.get(index));
            }
        } catch (DataAccessException dae) {
            MessageDialog.openError(Display.getDefault().getActiveShell(), "Error",
                    "There was a database error while adding the track to the playlist");
        }

    }

}

From source file:actions.FileScanningAction.java

License:Open Source License

@Override
public void run() {

    try {/*www. j  ava 2s . c om*/
        mainTable.setRedrawEnabled(false);
        // disable action
        DirectoryDialog dialog = new DirectoryDialog(shell);
        dialog.setText("Select a Directory");
        dialog.setMessage(
                "Select a directory of music files. Music files found in that directory will be added to your music library.");
        final String path = dialog.open();

        new ProgressMonitorDialog(shell).run(true, true, new ScanProgressMonitor(path));
    } catch (InvocationTargetException e) {
        MessageDialog.openError(shell, "Error", e.getMessage());
    } catch (InterruptedException e) {
        MessageDialog.openInformation(shell, "Cancelled", e.getMessage());
    } finally {
        mainTable.setRedrawEnabled(true);
    }
}

From source file:actions.FileScanningAction.java

License:Open Source License

public void scanFiles(String[] files) {
    try {//from ww  w  .  j  a  va 2 s.c o  m
        ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
        dialog.run(true, true, new ScanProgressMonitor(files));
    } catch (InvocationTargetException e) {
        MessageDialog.openError(shell, "Error", e.getMessage());
    } catch (InterruptedException e) {
        MessageDialog.openInformation(shell, "Cancelled", e.getMessage());
    }
}

From source file:actions.RemoveFromPlaylistAction.java

License:Open Source License

public void handleEvent(Event e) {
    int[] indices = table.getSelectionIndices();

    if (indices.length > 0) {
        try {//from w ww .  ja  va 2s.  c o  m
            for (int index : indices) {
                playlist.remove(index);
            }
        } catch (DataAccessException ex) {
            MessageDialog.openError(Display.getDefault().getActiveShell(), "Error",
                    "There was a database error while removing the track from the playlist");
        }
    }

}

From source file:actions.StreamOpenAction.java

License:Open Source License

@Override
public void run() {
    // openDialog();

    Player p = new Player();
    try {// w ww.j  a v a 2 s  . c o  m
        p.play("http://mublog.co.uk/finalyear/music/Dethbed.mp3");
    } catch (Exception e) {
        MessageDialog.openError(Display.getDefault().getActiveShell(), "Playback Error",
                "There was an error opening the stream");
    }
}

From source file:aguiaj.console.Console.java

License:Open Source License

private static AguiaJConsoleActivator getConsole() {
    AguiaJConsoleActivator console = AguiaJConsoleActivator.getInstance();
    if (console == null)
        MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Error",
                "Could not load AGUIA/J console.");
    return console;
}

From source file:algsymboleditor.editors.FencedEditor.java

License:Open Source License

/**
 * Performs a save as and reports the result state back to the
 * given progress monitor./*w  ww .  j  a v a 2 s  .  c  om*/
 *
 * @param path The default path at which to perform the save.
 * @param progressMonitor the progress monitor for communicating result state or <code>null</code>
 */
protected void performSaveAs(IPath path, IProgressMonitor progressMonitor) {

    IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
    IEditorInput newInput = new FileEditorInput(file);

    boolean success = false;
    try {
        performSave(newInput, true, progressMonitor);
        success = true;

    } catch (CoreException x) {
        final IStatus status = x.getStatus();
        if (status == null || status.getSeverity() != IStatus.CANCEL) {
            Shell shell = PlatformUI.getWorkbench().getModalDialogShellProvider().getShell();
            String title = "Save As Error";
            String msg = "Error Saving " + (x.getMessage());
            MessageDialog.openError(shell, title, msg);
        }
    } finally {
        if (success)
            setInput(newInput);
    }

    if (progressMonitor != null)
        progressMonitor.setCanceled(!success);
}

From source file:algsymboleditor.editors.FencedEditor.java

License:Open Source License

@Override
public void doSave(IProgressMonitor progressMonitor) {
    try {/*from  www  . ja  v  a2 s  . c o  m*/
        performSave(getEditorInput(), false, progressMonitor);
    } catch (CoreException x) {
        Shell shell = PlatformUI.getWorkbench().getModalDialogShellProvider().getShell();
        String title = "Save As Error";
        String msg = "Error Saving " + (x.getMessage());
        MessageDialog.openError(shell, title, msg);
    }
}

From source file:algsymboleditor.wizards.NewFencedWizard.java

License:Open Source License

@Override
public boolean performFinish() {
    final String containerName = page.getContainerName();
    final String fileName = page.getFileName();
    IRunnableWithProgress op = new IRunnableWithProgress() {
        @Override/*from  www .ja  va  2 s .c o  m*/
        public void run(IProgressMonitor monitor) throws InvocationTargetException {
            try {
                doFinish(containerName, fileName, monitor);
            } catch (CoreException e) {
                throw new InvocationTargetException(e);
            } finally {
                monitor.done();
            }
        }
    };
    try {
        getContainer().run(true, false, op);
    } catch (InterruptedException e) {
        return false;
    } catch (InvocationTargetException e) {
        Throwable realException = e.getTargetException();
        MessageDialog.openError(getShell(), "Error", realException.getMessage());
        return false;
    }
    return true;
}