@SuppressWarnings("unchecked") protected void onSessionOpened(final S session) { destroyToolbar(); destroyPalette(); initToolbar(session); initPalette(session); getView().setCanvasWidget(getDisplayer().getView()); getView().showLoading(false); }
@SuppressWarnings("unchecked") private void initPalette(final S session) { if (hasPalette) { palette = (PaletteWidget<PaletteDefinition>) buildPalette(session); if (null != palette) { getView().setPaletteWidget(palette); } } }
public Optional<S> getSession() { return Optional.ofNullable(getInstance()); }
public void refresh() { destroyPalette(); getSession().ifPresent(this::initPalette); }
@Override public void destroy() { destroyToolbar(); destroyPalette(); getSession().ifPresent(sessionManager::destroy); getDisplayer().destroy(); getView().destroy(); diagram = null; }
public void open(final S session, final SessionPresenterCallback<D> callback) { beforeOpen(session); getDisplayer().open(session, new SessionViewer.SessionViewerCallback<D>() { @Override public void afterCanvasInitialized() { callback.afterCanvasInitialized(); sessionManager.open(session); callback.afterSessionOpened(); } @Override public void onSuccess() { onSessionOpened(session); callback.onSuccess(); } @Override public void onError(final ClientRuntimeError error) { AbstractSessionPresenter.this.showError(error); callback.onError(error); } }); }
public S getInstance() { return getDisplayer().getInstance(); }
public void clear() { if (null != palette) { palette.unbind(); } if (null != toolbar) { destroyToolbar(); } getDisplayer().clear(); diagram = null; }
@Override @SuppressWarnings("unchecked") public void open(final D diagram, final SessionPresenterCallback<D> callback) { this.diagram = diagram; notificationsObserver.onCommandExecutionFailed(this::showCommandError); notificationsObserver.onValidationSuccess(this::showNotificationMessage); notificationsObserver.onValidationFailed(this::showValidationError); sessionManager.newSession(diagram.getMetadata(), getSessionType(), session -> open((S) session, callback)); }
@Override public void focus() { getSession().ifPresent(sessionManager::open); getSession().ifPresent(s -> sessionFocusedEvent.fire(new SessionFocusedEvent(s))); }
private void destroyToolbar() { if (null != toolbar) { toolbar.destroy(); destroyToolbarInstace(toolbar); toolbar = null; } }
private boolean isThisContext(final Notification notification) { try { final NotificationContext context = (NotificationContext) notification.getContext(); return null != getDiagram() && getDiagram().getName().equals(context.getDiagramName()); } catch (final ClassCastException e) { return false; } }
public void open(final S session, final int width, final int height, final SessionPresenterCallback<D> callback) { beforeOpen(session); getDisplayer().open(session, width, height, new SessionViewer.SessionViewerCallback<D>() { @Override public void afterCanvasInitialized() { callback.afterCanvasInitialized(); sessionManager.open(session); callback.afterSessionOpened(); } @Override public void onSuccess() { onSessionOpened(session); callback.onSuccess(); } @Override public void onError(final ClientRuntimeError error) { AbstractSessionPresenter.this.showError(error); callback.onError(error); } }); }
public void scale(final int width, final int height) { getDisplayer().scale(width, height); }
public H getHandler() { return getDisplayer().getHandler(); }
protected void addDRGEditorToCanvasWidget() { presenter.getView().setCanvasWidget(((AbstractSessionPresenter) presenter).getDisplayer().getView()); }