Revision 7f6f8587
Added by Andreas Kohlbecker over 2 years ago
src/main/java/eu/etaxonomy/cdm/vaadin/ui/AbstractUI.java | ||
---|---|---|
27 | 27 |
import com.vaadin.ui.UI; |
28 | 28 |
import com.vaadin.ui.themes.ValoTheme; |
29 | 29 |
|
30 |
import eu.etaxonomy.cdm.addon.config.UIDisabledException; |
|
30 | 31 |
import eu.etaxonomy.cdm.database.PermissionDeniedException; |
31 | 32 |
import eu.etaxonomy.cdm.vaadin.event.error.DelegatingErrorHandler; |
32 | 33 |
import eu.etaxonomy.cdm.vaadin.event.error.ErrorTypeErrorHandlerWrapper; |
33 | 34 |
import eu.etaxonomy.cdm.vaadin.event.error.PermissionDeniedErrorHandler; |
35 |
import eu.etaxonomy.cdm.vaadin.event.error.UIDisabledErrorHandler; |
|
34 | 36 |
import eu.etaxonomy.cdm.vaadin.permission.ReleasableResourcesView; |
35 | 37 |
import eu.etaxonomy.cdm.vaadin.view.RedirectToLoginView; |
36 | 38 |
import eu.etaxonomy.vaadin.ui.UIInitializedEvent; |
... | ... | |
67 | 69 |
@Autowired |
68 | 70 |
protected UIEventBus uiEventBus; |
69 | 71 |
|
72 |
// private boolean enabled; |
|
73 |
|
|
70 | 74 |
public AbstractUI() { |
71 | 75 |
super(); |
72 | 76 |
} |
... | ... | |
87 | 91 |
assert getViewDisplay() != null; |
88 | 92 |
|
89 | 93 |
logger.debug(this.getClass().getSimpleName() + ".init() ViewDisplay: " + getViewDisplay().getClass().getSimpleName() + ", initialViewName: " + getInitialViewName()); |
94 |
|
|
95 |
if(!isEnabled()) { |
|
96 |
throw new UIDisabledException(getClass().getSimpleName()); |
|
97 |
} |
|
98 |
|
|
90 | 99 |
initAdditionalContent(); |
91 | 100 |
|
92 | 101 |
getNavigationManagerBean().setViewDisplay(getViewDisplay()); |
... | ... | |
120 | 129 |
uiEventBus.publish(this, new UIInitializedEvent()); |
121 | 130 |
} |
122 | 131 |
|
132 |
// /** |
|
133 |
// * @return |
|
134 |
// */ |
|
135 |
// @Override |
|
136 |
// protected abstract String getUIName(); |
|
137 |
|
|
123 | 138 |
/** |
124 | 139 |
* @return The name of the initial view to show |
125 | 140 |
*/ |
... | ... | |
148 | 163 |
|
149 | 164 |
protected void registerErrorHandlers() { |
150 | 165 |
DelegatingErrorHandler delegatingErrorHander = new DelegatingErrorHandler(); |
151 |
WindowErrorHandler errorHandler = new WindowErrorHandler(this, RegistrationUIDefaults.ERROR_CONTACT_MESSAGE_LINE + "</br></br>" |
|
166 |
WindowErrorHandler errorHandler = new WindowErrorHandler( |
|
167 |
this, |
|
168 |
RegistrationUIDefaults.ERROR_CONTACT_MESSAGE_LINE + "</br></br>" |
|
152 | 169 |
+ "<i>To help analyzing the problem please describe your actions that lead to this error and provide the error details from below in your email. " |
153 | 170 |
+ "You also might want to add a sreenshot of the browser page in error.</i>"); |
154 |
delegatingErrorHander.registerHandler(new ErrorTypeErrorHandlerWrapper<PermissionDeniedException>(PermissionDeniedException.class, new PermissionDeniedErrorHandler(this))); |
|
155 |
delegatingErrorHander.registerHandler(new ErrorTypeErrorHandlerWrapper<Exception>(Exception.class, errorHandler)); |
|
171 |
delegatingErrorHander.registerHandler( |
|
172 |
new ErrorTypeErrorHandlerWrapper<PermissionDeniedException>(PermissionDeniedException.class, new PermissionDeniedErrorHandler(this)) |
|
173 |
); |
|
174 |
delegatingErrorHander.registerHandler( |
|
175 |
new ErrorTypeErrorHandlerWrapper<UIDisabledException>(UIDisabledException.class, new UIDisabledErrorHandler(this)) |
|
176 |
); |
|
177 |
delegatingErrorHander.registerHandler( |
|
178 |
new ErrorTypeErrorHandlerWrapper<Exception>(Exception.class, errorHandler) |
|
179 |
); |
|
156 | 180 |
setErrorHandler(delegatingErrorHander); |
157 | 181 |
VaadinSession.getCurrent().setErrorHandler(delegatingErrorHander); |
158 | 182 |
} |
... | ... | |
171 | 195 |
return state; |
172 | 196 |
} |
173 | 197 |
|
198 |
// @Override |
|
199 |
// public void setEnabled(boolean state) { |
|
200 |
// this.enabled = state; |
|
201 |
// } |
|
202 |
// |
|
203 |
// @Override |
|
204 |
// public boolean isEnabled() { |
|
205 |
// return enabled; |
|
206 |
// } |
|
207 |
|
|
208 |
|
|
174 | 209 |
} |
Also available in: Unified diff
ref #9884 refactoring UI enablement: