Revision 49c6e8c3
Added by Cherian Mathew over 9 years ago
eu.etaxonomy.taxeditor.application/src/main/java/eu/etaxonomy/taxeditor/ApplicationWorkbenchAdvisor.java | ||
---|---|---|
1 | 1 |
package eu.etaxonomy.taxeditor; |
2 | 2 |
|
3 | 3 |
|
4 |
import java.io.PrintWriter; |
|
5 |
import java.io.StringWriter; |
|
6 |
import java.rmi.activation.Activator; |
|
7 |
|
|
8 | 4 |
import org.eclipse.core.runtime.IStatus; |
9 |
import org.eclipse.core.runtime.Status; |
|
10 |
import org.eclipse.jface.dialogs.ErrorDialog; |
|
11 |
import org.eclipse.swt.widgets.Shell; |
|
12 | 5 |
import org.eclipse.ui.application.IWorkbenchConfigurer; |
13 | 6 |
import org.eclipse.ui.application.IWorkbenchWindowConfigurer; |
14 | 7 |
import org.eclipse.ui.application.WorkbenchAdvisor; |
15 | 8 |
import org.eclipse.ui.application.WorkbenchWindowAdvisor; |
16 | 9 |
import org.eclipse.ui.statushandlers.AbstractStatusHandler; |
17 | 10 |
import org.eclipse.ui.statushandlers.StatusAdapter; |
18 |
import org.eclipse.ui.statushandlers.StatusManager; |
|
19 | 11 |
|
20 | 12 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
21 | 13 |
|
... | ... | |
35 | 27 |
* @see org.eclipse.ui.application.WorkbenchAdvisor#createWorkbenchWindowAdvisor(org.eclipse.ui.application.IWorkbenchWindowConfigurer) |
36 | 28 |
*/ |
37 | 29 |
/** {@inheritDoc} */ |
38 |
public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor( |
|
30 |
@Override |
|
31 |
public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor( |
|
39 | 32 |
IWorkbenchWindowConfigurer configurer) { |
40 | 33 |
return new ApplicationWorkbenchWindowAdvisor(configurer); |
41 | 34 |
} |
42 | 35 |
|
43 |
|
|
36 |
|
|
44 | 37 |
/* |
45 | 38 |
* (non-Javadoc) |
46 | 39 |
* @see org.eclipse.ui.application.WorkbenchAdvisor#getInitialWindowPerspectiveId() |
... | ... | |
50 | 43 |
* |
51 | 44 |
* @return a {@link java.lang.String} object. |
52 | 45 |
*/ |
53 |
public String getInitialWindowPerspectiveId() { |
|
46 |
@Override |
|
47 |
public String getInitialWindowPerspectiveId() { |
|
54 | 48 |
return "eu.etaxonomy.taxeditor.application.perspective.taxonomic"; |
55 | 49 |
} |
56 |
|
|
50 |
|
|
57 | 51 |
/* |
58 | 52 |
* (non-Javadoc) |
59 | 53 |
* @see org.eclipse.ui.application.WorkbenchAdvisor#initialize(org.eclipse.ui.application.IWorkbenchConfigurer) |
60 | 54 |
*/ |
61 | 55 |
/** {@inheritDoc} */ |
62 |
public void initialize(IWorkbenchConfigurer configurer) { |
|
56 |
@Override |
|
57 |
public void initialize(IWorkbenchConfigurer configurer) { |
|
63 | 58 |
super.initialize(configurer); |
64 |
|
|
59 |
|
|
65 | 60 |
// Remembers the user's view layout, window size, window location etc. |
66 | 61 |
// for the next time application is started |
67 | 62 |
configurer.setSaveAndRestore(true); |
68 |
} |
|
69 |
|
|
70 |
/* (non-Javadoc) |
|
71 |
* @see org.eclipse.ui.application.WorkbenchAdvisor#preStartup() |
|
72 |
*/ |
|
73 |
/** {@inheritDoc} */ |
|
74 |
@Override |
|
75 |
public void preStartup() { |
|
76 |
// TODO Auto-generated method stub |
|
77 |
super.preStartup(); |
|
78 |
// XXX check for updates before starting up. |
|
79 |
// If an update is performed, restart. |
|
80 |
// if (P2Util.checkForUpdates()) |
|
81 |
// PlatformUI.getWorkbench().restart(); |
|
82 | 63 |
} |
83 |
|
|
84 |
/** |
|
85 |
* see: https://bugs.eclipse.org/bugs/show_bug.cgi?id=234252 |
|
86 |
*/ |
|
87 |
// public void initialize(IWorkbenchConfigurer configurer) { |
|
88 |
// |
|
89 |
// WorkbenchAdapterBuilder.registerAdapters(); |
|
90 |
// |
|
91 |
// final String ICONS_PATH = "icons/full/"; |
|
92 |
// final String PATH_OBJECT = ICONS_PATH + "obj16/"; |
|
93 |
// Bundle ideBundle = Platform.getBundle(IDEWorkbenchPlugin.IDE_WORKBENCH); |
|
94 |
// declareWorkbenchImage(configurer, ideBundle, |
|
95 |
// IDE.SharedImages.IMG_OBJ_PROJECT, PATH_OBJECT + "prj_obj.gif", |
|
96 |
// true); |
|
97 |
// declareWorkbenchImage(configurer, ideBundle, |
|
98 |
// IDE.SharedImages.IMG_OBJ_PROJECT_CLOSED, PATH_OBJECT |
|
99 |
// + "cprj_obj.gif", true); |
|
100 |
// |
|
101 |
// } |
|
102 |
// |
|
103 |
// private void declareWorkbenchImage(IWorkbenchConfigurer configurer_p, |
|
104 |
// Bundle ideBundle, String symbolicName, String path, boolean shared) { |
|
105 |
// URL url = ideBundle.getEntry(path); |
|
106 |
// ImageDescriptor desc = ImageDescriptor.createFromURL(url); |
|
107 |
// configurer_p.declareImage(symbolicName, desc, shared); |
|
108 |
// } |
|
109 |
// |
|
110 |
// public IAdaptable getDefaultPageInput() { |
|
111 |
// IWorkspace workspace = ResourcesPlugin.getWorkspace(); |
|
112 |
// return workspace.getRoot(); |
|
113 |
// } |
|
114 |
|
|
115 |
// @Override |
|
116 |
// public void eventLoopException(Throwable exception) { |
|
117 |
// super.eventLoopException(exception); |
|
118 |
// StoreUtil.messageDialog("Unexpected error", null, exception.getMessage(), exception); |
|
119 |
// } |
|
120 |
|
|
121 |
|
|
64 |
|
|
65 |
|
|
122 | 66 |
/* (non-Javadoc) |
123 | 67 |
* @see org.eclipse.ui.application.WorkbenchAdvisor#getWorkbenchErrorHandler() |
124 | 68 |
*/ |
... | ... | |
129 | 73 |
} |
130 | 74 |
return cdmStatusHandler; |
131 | 75 |
} |
132 |
|
|
76 |
|
|
133 | 77 |
|
134 | 78 |
/** |
135 |
* Custom status handler for handling scenarios which are
|
|
79 |
* Custom status handler for handling scenarios which are |
|
136 | 80 |
* not handled by the editor (e.g. runtime exceptions). |
137 |
*
|
|
81 |
* |
|
138 | 82 |
* The default {@link org.eclipse.ui.statushandlers.WorkbenchErrorHandler} |
139 | 83 |
* is not used or extended because we need a handler for specific scenarios |
140 | 84 |
* which displays a custom built error dialog. |
141 |
*
|
|
85 |
* |
|
142 | 86 |
* @author cmathew |
143 | 87 |
* |
144 | 88 |
*/ |
145 | 89 |
class CdmStatusHandler extends AbstractStatusHandler { |
146 |
|
|
90 |
|
|
147 | 91 |
/* (non-Javadoc) |
148 | 92 |
* @see org.eclipse.ui.statushandlers.AbstractStatusHandler#handle(org.eclipse.ui.statushandlers.StatusAdapter, int) |
149 | 93 |
*/ |
... | ... | |
151 | 95 |
public void handle(StatusAdapter statusAdapter, int style) |
152 | 96 |
{ |
153 | 97 |
if(statusAdapter.getStatus().matches(IStatus.ERROR)) { |
154 |
|
|
155 |
IStatus status = statusAdapter.getStatus();
|
|
156 |
Throwable t = statusAdapter.getStatus().getException();
|
|
98 |
|
|
99 |
IStatus status = statusAdapter.getStatus(); |
|
100 |
Throwable t = statusAdapter.getStatus().getException(); |
|
157 | 101 |
// NOTE : Currently we only allow RuntimeExceptions since |
158 |
// allowing all kinds of exceptions would also include
|
|
159 |
// those in generated status objects coming from from logging triggers
|
|
102 |
// allowing all kinds of exceptions would also include |
|
103 |
// those in generated status objects coming from from logging triggers |
|
160 | 104 |
// leading to a recursive infinite loop of : |
161 |
// initial exception thrown -> status handling -> dialog opening + logging of status ->
|
|
105 |
// initial exception thrown -> status handling -> dialog opening + logging of status -> |
|
162 | 106 |
// status handling -> dialog opening + logging of status ... and so on |
163 |
if(t != null && t instanceof RuntimeException) {
|
|
164 |
MessagingUtils.errorDialog("Unexpected error",
|
|
165 |
null,
|
|
166 |
MessagingUtils.UNEXPECTED_ERROR_MESSAGE,
|
|
167 |
statusAdapter.getStatus().getPlugin(),
|
|
107 |
if(t != null && t instanceof RuntimeException) { |
|
108 |
MessagingUtils.errorDialog("Unexpected error", |
|
109 |
null, |
|
110 |
MessagingUtils.UNEXPECTED_ERROR_MESSAGE, |
|
111 |
statusAdapter.getStatus().getPlugin(), |
|
168 | 112 |
t, |
169 |
true);
|
|
170 |
}
|
|
113 |
true); |
|
114 |
} |
|
171 | 115 |
} |
172 | 116 |
} |
173 | 117 |
} |
174 |
|
|
175 | 118 |
|
176 |
|
|
119 |
|
|
120 |
|
|
177 | 121 |
} |
Also available in: Unified diff
P2 update implementation and editor version extraction
ApplicationWorkbenchAdvisor : clean up
ApplicationWorkbenchWindowAdvisor : added update of editor to startup
P2Util : replaced older class with a new one which handles background update of editor
UpdateHandler : handles modal update of editor when requested
InstallNewSoftwareHandler, PreloadingRepositoryHandler : handlers for installing new software and preloading repositories (not used yet)
ApplicationUtil : added new methods to retrieve editor version number
TaxonomicEditorPlugin : added new methods for retrieving provisioning elements
build.properties, pom.xml, plugin_en.properties, plugin.properties, plugin_de.properties : setup dynamic properties (version number , build date) to be replaced via maven
plugin.xml, MANIFEST.MF : added new dependencies for p2 update mechanism
p2.inf : deleted since we now setup update repositories programmatically