Eclipse StatusManager does not show details

the code:

Job job = new Job("Connect to Database") { 
            @Override 
            protected IStatus run(IProgressMonitor monitor) {
                // 即使是在正常的情况下,某些版本的DB2的连接建立时间也比较长。。。
                monitor.beginTask("正在建立到数据库的连接 ...", 100); 
                try {
                    Thread.sleep(3000);
                    database = new Database(cp.getName(),  cp.getConnection());
                } catch (Exception e) {
                    e.printStackTrace();
                    IStatus sqlErrorStatus = new Status(IStatus.ERROR, "amarsoft.dbmp", e.getMessage(), null);
                    StatusManager.getManager().handle(sqlErrorStatus, StatusManager.SHOW);
                }
                monitor.done(); 
                return Status.OK_STATUS; 
            } 
        }; 

enter image description here

How can I get it to display an exception stack trace when the user clicks the Details button?

+5
source share
1 answer

By default, the status dialog box does not display an exception stack trace.

<

If you have your own Eclipse product , you can customize the details and support areas of the status dialog using the org.eclipse.ui.statusHandlers extension point. You will need to expand WorkbenchErrorHandlerand override the method configureStatusDialog(...):

void configureStatusDialog(WorkbenchStatusDialogManager statusDialog) {
    statusDialog.enableDefaultSupportArea(true);
    statusDialog.setDetailsAreaProvider(new CustomStatusAreaProvider());
}

class CustomStatusAreaProvider extends AbstractStatusAreaProvider {
    Control createSupportArea(Composite parent, StatusAdapter statusAdapter) {
        //Create and return details area
    }
}



Status null, .

+6

All Articles