Search in sources :

Example 1 with AbstractSession

use of org.kie.workbench.common.stunner.core.client.session.impl.AbstractSession in project kie-wb-common by kiegroup.

the class GlobalSessionManager method destroy.

@Override
public <S extends ClientSession> void destroy(final S session) {
    final boolean isCurrent = session.equals(current);
    final String uuid = session.getSessionUUID();
    final Diagram diagram = session.getCanvasHandler().getDiagram();
    final String name = null != diagram ? diagram.getName() : null;
    final String graphUuid = null != diagram ? diagram.getGraph().getUUID() : null;
    final Metadata metadata = null != diagram ? diagram.getMetadata() : null;
    ((AbstractSession) session).destroy();
    sessionInstances.destroy(session);
    if (isCurrent) {
        current = null;
    }
    sessionDestroyedEvent.fire(new SessionDestroyedEvent(uuid, name, graphUuid, metadata));
}
Also used : Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) SessionDestroyedEvent(org.kie.workbench.common.stunner.core.client.session.event.SessionDestroyedEvent) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) AbstractSession(org.kie.workbench.common.stunner.core.client.session.impl.AbstractSession)

Example 2 with AbstractSession

use of org.kie.workbench.common.stunner.core.client.session.impl.AbstractSession in project kie-wb-common by kiegroup.

the class DMNDiagramEditor method open.

@SuppressWarnings("all")
@Override
public void open(final ProjectDiagram diagram, final SessionPresenter.SessionPresenterCallback callback) {
    final AbstractSession currentSession = !getStunnerEditor().isClosed() ? (AbstractSession) getStunnerEditor().getSession() : null;
    this.layoutHelper.applyLayout(diagram, openDiagramLayoutExecutor);
    feelInitializer.initializeFEELEditor();
    super.open(diagram, new SessionPresenter.SessionPresenterCallback() {

        @Override
        public void onSuccess() {
            setupSessionHeaderContainer();
            callback.onSuccess();
            if (null != currentSession) {
                currentSession.close();
            }
        }

        @Override
        public void onError(ClientRuntimeError error) {
            callback.onError(error);
        }
    });
}
Also used : ClientRuntimeError(org.kie.workbench.common.stunner.core.client.service.ClientRuntimeError) SessionPresenter(org.kie.workbench.common.stunner.client.widgets.presenters.session.SessionPresenter) AbstractSession(org.kie.workbench.common.stunner.core.client.session.impl.AbstractSession)

Example 3 with AbstractSession

use of org.kie.workbench.common.stunner.core.client.session.impl.AbstractSession in project kie-wb-common by kiegroup.

the class ProfileSelector method bind.

public ProfileSelector bind(final Supplier<AbstractSession> sessionSupplier) {
    final AbstractSession session = sessionSupplier.get();
    final Metadata metadata = session.getCanvasHandler().getDiagram().getMetadata();
    final String definitionSetId = metadata.getDefinitionSetId();
    final String profileId = metadata.getProfileId();
    useDefinitionSet(definitionSetId);
    useProfile(definitionSetId, profileId);
    selector.setValueChangedCommand(() -> {
        final Profile item = selector.getSelectedItem();
        metadata.setProfileId(item.getProfileId());
        requestSessionRefreshEvent.fire(new RequestSessionRefreshEvent(session.getSessionUUID()));
    });
    return this;
}
Also used : Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) Profile(org.kie.workbench.common.stunner.core.profile.Profile) RequestSessionRefreshEvent(org.kie.workbench.common.stunner.client.widgets.presenters.session.RequestSessionRefreshEvent) AbstractSession(org.kie.workbench.common.stunner.core.client.session.impl.AbstractSession)

Aggregations

AbstractSession (org.kie.workbench.common.stunner.core.client.session.impl.AbstractSession)3 Metadata (org.kie.workbench.common.stunner.core.diagram.Metadata)2 RequestSessionRefreshEvent (org.kie.workbench.common.stunner.client.widgets.presenters.session.RequestSessionRefreshEvent)1 SessionPresenter (org.kie.workbench.common.stunner.client.widgets.presenters.session.SessionPresenter)1 ClientRuntimeError (org.kie.workbench.common.stunner.core.client.service.ClientRuntimeError)1 SessionDestroyedEvent (org.kie.workbench.common.stunner.core.client.session.event.SessionDestroyedEvent)1 Diagram (org.kie.workbench.common.stunner.core.diagram.Diagram)1 Profile (org.kie.workbench.common.stunner.core.profile.Profile)1