1 package eu
.etaxonomy
.taxeditor
;
4 import org
.eclipse
.core
.runtime
.IStatus
;
5 import org
.eclipse
.ui
.application
.IWorkbenchConfigurer
;
6 import org
.eclipse
.ui
.application
.IWorkbenchWindowConfigurer
;
7 import org
.eclipse
.ui
.application
.WorkbenchAdvisor
;
8 import org
.eclipse
.ui
.application
.WorkbenchWindowAdvisor
;
9 import org
.eclipse
.ui
.statushandlers
.AbstractStatusHandler
;
10 import org
.eclipse
.ui
.statushandlers
.StatusAdapter
;
12 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
17 * <p>ApplicationWorkbenchAdvisor class.</p>
22 public class ApplicationWorkbenchAdvisor
extends WorkbenchAdvisor
{
24 private CdmStatusHandler cdmStatusHandler
;
27 * @see org.eclipse.ui.application.WorkbenchAdvisor#createWorkbenchWindowAdvisor(org.eclipse.ui.application.IWorkbenchWindowConfigurer)
31 public WorkbenchWindowAdvisor
createWorkbenchWindowAdvisor(
32 IWorkbenchWindowConfigurer configurer
) {
33 return new ApplicationWorkbenchWindowAdvisor(configurer
);
39 * @see org.eclipse.ui.application.WorkbenchAdvisor#getInitialWindowPerspectiveId()
42 * <p>getInitialWindowPerspectiveId</p>
44 * @return a {@link java.lang.String} object.
47 public String
getInitialWindowPerspectiveId() {
48 return "eu.etaxonomy.taxeditor.application.perspective.taxonomic";
53 * @see org.eclipse.ui.application.WorkbenchAdvisor#initialize(org.eclipse.ui.application.IWorkbenchConfigurer)
57 public void initialize(IWorkbenchConfigurer configurer
) {
58 super.initialize(configurer
);
60 // Remembers the user's view layout, window size, window location etc.
61 // for the next time application is started
62 configurer
.setSaveAndRestore(true);
67 * @see org.eclipse.ui.application.WorkbenchAdvisor#getWorkbenchErrorHandler()
70 public synchronized AbstractStatusHandler
getWorkbenchErrorHandler() {
71 if (cdmStatusHandler
== null) {
72 cdmStatusHandler
= new CdmStatusHandler();
74 return cdmStatusHandler
;
79 * Custom status handler for handling scenarios which are
80 * not handled by the editor (e.g. runtime exceptions).
82 * The default {@link org.eclipse.ui.statushandlers.WorkbenchErrorHandler}
83 * is not used or extended because we need a handler for specific scenarios
84 * which displays a custom built error dialog.
89 class CdmStatusHandler
extends AbstractStatusHandler
{
92 * @see org.eclipse.ui.statushandlers.AbstractStatusHandler#handle(org.eclipse.ui.statushandlers.StatusAdapter, int)
95 public void handle(StatusAdapter statusAdapter
, int style
)
97 if(statusAdapter
.getStatus().matches(IStatus
.ERROR
)) {
99 IStatus status
= statusAdapter
.getStatus();
100 Throwable t
= statusAdapter
.getStatus().getException();
101 // NOTE : Currently we only allow RuntimeExceptions since
102 // allowing all kinds of exceptions would also include
103 // those in generated status objects coming from from logging triggers
104 // leading to a recursive infinite loop of :
105 // initial exception thrown -> status handling -> dialog opening + logging of status ->
106 // status handling -> dialog opening + logging of status ... and so on
107 if(t
!= null && t
instanceof RuntimeException
&& ! "Widget is disposed".equals(t
.getMessage())){
108 MessagingUtils
.errorDialog("Unexpected error",
110 MessagingUtils
.UNEXPECTED_ERROR_MESSAGE
,
111 statusAdapter
.getStatus().getPlugin(),