+
+ @Override
+ protected void refreshBody() {
+ if (bodyArea == null)
+ return;
+ // clear
+ for (Control child : bodyArea.getChildren())
+ child.dispose();
+ bodyArea.setLayout(CmsUtils.noSpaceGridLayout());
+
+ // Exception
+ Throwable exception = getException();
+ if (exception != null) {
+ new Label(bodyArea, SWT.NONE).setText("Unreachable state : "
+ + getState());
+ if (getNode() != null)
+ new Label(bodyArea, SWT.NONE).setText("Context : "
+ + getNode());
+
+ Text errorText = new Text(bodyArea, SWT.MULTI | SWT.H_SCROLL
+ | SWT.V_SCROLL);
+ errorText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
+ true));
+ StringWriter sw = new StringWriter();
+ exception.printStackTrace(new PrintWriter(sw));
+ errorText.setText(sw.toString());
+ IOUtils.closeQuietly(sw);
+ resetException();
+ // TODO report
+ } else {
+ String state = getState();
+ try {
+ if (state == null)
+ throw new CmsException("State cannot be null");
+ uiProvider.createUi(bodyArea, getNode());
+ } catch (RepositoryException e) {
+ throw new CmsException("Cannot refresh body", e);
+ }
+ }
+ bodyArea.layout(true, true);
+ }
+
+ @Override
+ protected Node getDefaultNode(Session session)
+ throws RepositoryException {
+ if (!session.hasPermission(basePath, "read")) {
+ if (session.getUserID().equals("anonymous"))
+ throw new LoginRequiredException();
+ else
+ throw new CmsException("Unauthorized");
+ }
+ return session.getNode(basePath);
+ }
+
+ @Override
+ public CmsImageManager getImageManager() {
+ return imageManager;
+ }
+
+ }
+
+ private static ResourceLoader createResourceLoader(final String resourceName) {
+ return new ResourceLoader() {
+ public InputStream getResourceAsStream(String resourceName)
+ throws IOException {
+ return getClass().getClassLoader().getResourceAsStream(
+ resourceName);
+ }
+ };