use of one.microstream.storage.restclient.app.types.SessionData in project microstream by microstream-one.
the class InternalErrorView method beforeEnter.
@Override
public void beforeEnter(final BeforeEnterEvent event) {
final H3 header = new H3(getTranslation("INTERNAL_ERROR_TITLE"));
header.addClassName(ClassNames.ERROR);
this.add(header);
final VaadinSession session = event.getUI().getSession();
final SessionData sessionData = session.getAttribute(SessionData.class);
if (sessionData != null) {
this.add(new Label(getTranslation("INTERNAL_ERROR_HINT", sessionData.baseUrl())));
}
final Throwable t = (Throwable) session.getAttribute(ApplicationErrorHandler.THROWABLE_ATTRIBUTE);
if (t != null) {
this.add(new Hr());
final StringWriter stringWriter = new StringWriter();
try (final PrintWriter writer = new PrintWriter(stringWriter)) {
t.printStackTrace(writer);
}
final TextArea stackTrace = new TextArea();
stackTrace.setValue(stringWriter.toString());
stackTrace.setReadOnly(true);
stackTrace.setWidth("100%");
final Details details = new Details(getTranslation("DETAILS"), stackTrace);
details.setOpened(false);
this.add(details);
this.setHorizontalComponentAlignment(Alignment.STRETCH, details);
this.setFlexGrow(1, details);
}
}
use of one.microstream.storage.restclient.app.types.SessionData in project microstream by microstream-one.
the class ConnectView method tryConnect.
private void tryConnect(final String baseUrl) {
try (final StorageRestClientJersey client = StorageRestClientJersey.New(baseUrl)) {
client.requestRoot();
this.updateUrlCookie(baseUrl);
final SessionData sessionData = new SessionData(baseUrl);
this.getUI().ifPresent(ui -> {
ui.getSession().setAttribute(SessionData.class, sessionData);
ui.navigate(InstanceView.class);
});
} catch (final Exception e) {
this.getUI().ifPresent(ui -> {
final Notification notification = new Notification();
final H3 header = new H3(this.getTranslation("CONNECT_ERROR"));
header.addClassName(ClassNames.ERROR);
final Button close = new Button(this.getTranslation("OK"), event -> notification.close());
final VerticalLayout content = new VerticalLayout(header, new Hr(), new Label(this.getTranslation("INTERNAL_ERROR_HINT", baseUrl)), close);
content.setHorizontalComponentAlignment(Alignment.END, close);
notification.add(content);
notification.setDuration(0);
notification.setPosition(Position.MIDDLE);
notification.open();
});
}
}
use of one.microstream.storage.restclient.app.types.SessionData in project microstream by microstream-one.
the class RootLayout method beforeEnter.
@Override
public void beforeEnter(final BeforeEnterEvent event) {
final SessionData sessionData = event.getUI().getSession().getAttribute(SessionData.class);
this.headerLabel.setText(sessionData != null ? this.getTranslation("CLIENT") + " - " + sessionData.baseUrl() : this.getTranslation("CLIENT"));
this.toolBar.setVisible(sessionData != null && !event.getNavigationTarget().equals(ConnectView.class));
}
Aggregations