Java 类org.eclipse.core.commands.operations.OperationStatus 实例源码

项目:neoscada    文件:Activator.java   
/**
 * Notify error using message box (thread safe).
 * @param message The message to display
 * @param error The error that occurred
 */
public void notifyError ( final String message, final Throwable error )
{
    final Display display = getWorkbench ().getDisplay ();

    if ( !display.isDisposed () )
    {
        display.asyncExec ( new Runnable () {

            @Override
            public void run ()
            {
                final Shell shell = getWorkbench ().getActiveWorkbenchWindow ().getShell ();
                logger.debug ( "Shell disposed: {}", shell.isDisposed () );
                if ( !shell.isDisposed () )
                {
                    final IStatus status = new OperationStatus ( IStatus.ERROR, PLUGIN_ID, 0, message + ":" + error.getMessage (), error );
                    ErrorDialog.openError ( shell, null, message, status );
                }
            }
        } );
    }
}
项目:PDFReporter-Studio    文件:TemplateExporterWizard.java   
/**
 * Display a error message when the selected template type is not compatible with the exported report, in the detail
 * section are listed the founded error
 * 
 * @param errors List of all the validation errors found using the selected report as template of the selected type
 * 
 * @return the code of the pressed button on the dialog
 */
@SuppressWarnings("unused")
private int createErrorMessage(List<String> errors){
    String conf = ""; //$NON-NLS-1$
    for(String error : errors){
        conf += error.concat("\n"); //$NON-NLS-1$ 
    }

    IStatus status = new OperationStatus(IStatus.ERROR, JasperReportsPlugin
            .getDefault().getPluginID(), OperationStatus.NOTHING_TO_REDO,
            conf, null);
    int result = new YesNoDetailsError(
            UIUtils.getShell(),
            Messages.TemplateExporterWizard_errorTitle,
            Messages.TemplateExporterWizard_errorMessage,
            status, IStatus.OK | IStatus.INFO | IStatus.WARNING
                    | IStatus.ERROR).open();
    return result;
}
项目:PDFReporter-Studio    文件:ResourcePage.java   
/**
 * Display a error message when there are conflicts between the resources, in the detail
 * section are listed the conflicted resources
 * 
 * @param conflicts List of all the resource with conflicts. The list must have a even number of elements
 * and every element in a pair position is in conflict with the file in the following position
 */
private void createErrorMessage(List<String> conflicts){
    String conf = ""; //$NON-NLS-1$
    for(int i=0; i<conflicts.size(); i+=2){
        conf += conflicts.get(i).concat("\n").concat(conflicts.get(i+1)).concat("\n\n"); //$NON-NLS-1$ //$NON-NLS-2$
    }

    IStatus status = new OperationStatus(IStatus.ERROR, JasperReportsPlugin
            .getDefault().getPluginID(), OperationStatus.NOTHING_TO_REDO,
            conf, null);
    new ConflictDetailsError(
            UIUtils.getShell(),
            Messages.ResourcePage_conflictTitle,
            Messages.ResourcePage_conflictMessage,
            status, IStatus.OK | IStatus.INFO | IStatus.WARNING
                    | IStatus.ERROR) {
        protected void setShellStyle(int newShellStyle) {
            super.setShellStyle(newShellStyle | SWT.SHEET);
        }
    }.open();
}
项目:neoscada    文件:WriteAttributesOperationWizard.java   
public void handleError ( final Map<String, Variant> attributes, final WriteAttributeResults results )
{
    final MultiStatus status = new MultiStatus ( Activator.PLUGIN_ID, 0, Messages.getString ( "WriteAttributesOperationWizard.Status_Message" ), null ); //$NON-NLS-1$

    if ( attributes.size () != results.size () )
    {
        status.add ( new OperationStatus ( IStatus.WARNING, Activator.PLUGIN_ID, 0, String.format ( Messages.getString ( "WriteAttributesOperationWizard.SummaryText" ), results.size (), attributes.size () ), null ) ); //$NON-NLS-1$
    }

    for ( final Map.Entry<String, WriteAttributeResult> entry : results.entrySet () )
    {
        if ( entry.getValue ().isError () )
        {
            status.add ( new OperationStatus ( IStatus.ERROR, Activator.PLUGIN_ID, 0, String.format ( Messages.getString ( "WriteAttributesOperationWizard.EntryMessage" ), entry.getKey (), entry.getValue ().getError ().getMessage () ), null ) ); //$NON-NLS-1$
        }
    }

    for ( final String name : attributes.keySet () )
    {
        if ( !results.containsKey ( name ) )
        {
            status.add ( new OperationStatus ( IStatus.WARNING, Activator.PLUGIN_ID, 0, String.format ( Messages.getString ( "WriteAttributesOperationWizard.Message_MissingAttribute" ), name ), null ) ); //$NON-NLS-1$
        }
    }

    final ErrorDialog dialog = new ErrorDialog ( getShell (), Messages.getString ( "WriteAttributesOperationWizard.WriteError_Title" ), Messages.getString ( "WriteAttributesOperationWizard.ErrorDialog_Description" ), status, IStatus.ERROR | IStatus.WARNING ); //$NON-NLS-1$ //$NON-NLS-2$

    Display.getDefault ().syncExec ( new Runnable () {

        @Override
        public void run ()
        {
            dialog.open ();
        }
    } );
}
项目:OpenSPIFe    文件:AbstractEnsembleUndoableOperation.java   
protected IStatus getStatus(String defaultMessage) {
    if (status != null) {
        return status;
    } else {
        if (state == UndoableState.FAILED)
            return new Status(IStatus.ERROR, CommonPlugin.ID, IStatus.OK, "failed " + defaultMessage, null);
        else
            return new OperationStatus(IStatus.OK, CommonPlugin.ID, 0, defaultMessage, null);
    }

}
项目:PDFReporter-Studio    文件:FontListFieldEditor.java   
protected void exportPressed() {
    int[] selection = table.getSelectionIndices();
    if (selection != null && selection.length > 0) {
        final List<FontFamily> lst = new ArrayList<FontFamily>(selection.length);
        for (int s : selection) {
            FontFamily font = fontFamily.get(s);
            if (font instanceof JRCloneable)
                lst.add((FontFamily) ((JRCloneable) font).clone());
        }
        final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
        FileDialog fd = new FileDialog(Display.getCurrent().getActiveShell(), SWT.SAVE);
        fd.setText(Messages.FontListFieldEditor_exportToJar);
        setupLastLocation(fd);
        fd.setFilterExtensions(new String[] { "*.jar", "*.zip" }); //$NON-NLS-1$ //$NON-NLS-2$
        final String selected = fd.open();
        setLastLocation(fd, selected);
        if (selected != null) {
            Job job = new Job(Messages.FontListFieldEditor_exportToJar) {
                @Override
                protected IStatus run(IProgressMonitor monitor) {
                    monitor.beginTask(Messages.FontListFieldEditor_exportToJar, IProgressMonitor.UNKNOWN);
                    try {
                        exportJAR(lst, selected);

                        IFile[] resource = root.findFilesForLocationURI(new File(selected).toURI());
                        if (resource != null) {
                            for (IFile f : resource)
                                f.refreshLocal(1, monitor);
                        }
                    } catch (final Exception e) {
                        e.printStackTrace();
                        UIUtils.getDisplay().asyncExec(new Runnable() {
                            public void run() {
                                IStatus status = new OperationStatus(IStatus.ERROR, JaspersoftStudioPlugin.getUniqueIdentifier(), 1,
                                        "Error saving file.", e.getCause()); //$NON-NLS-1$
                                ErrorDialog.openError(Display.getDefault().getActiveShell(), Messages.FontListFieldEditor_errorSave,
                                        null, status);
                            }
                        });
                    } finally {
                        monitor.done();
                    }
                    return Status.OK_STATUS;
                }
            };
            job.setPriority(Job.LONG);
            job.schedule();
        }
    }
}