Search in sources :

Example 1 with PerspectiveLayout

use of edu.stanford.bmir.protege.web.shared.perspective.PerspectiveLayout in project webprotege by protegeproject.

the class GetPerspectiveLayoutActionHandler method execute.

@Nonnull
@Override
public GetPerspectiveLayoutResult execute(@Nonnull GetPerspectiveLayoutAction action, @Nonnull ExecutionContext executionContext) {
    PerspectiveId perspectiveId = action.getPerspectiveId();
    ProjectId projectId = action.getProjectId();
    UserId userId = action.getUserId();
    PerspectiveLayout perspectiveLayout = perspectiveLayoutStore.getPerspectiveLayout(projectId, userId, perspectiveId);
    return new GetPerspectiveLayoutResult(perspectiveLayout);
}
Also used : UserId(edu.stanford.bmir.protege.web.shared.user.UserId) ProjectId(edu.stanford.bmir.protege.web.shared.project.ProjectId) PerspectiveId(edu.stanford.bmir.protege.web.shared.perspective.PerspectiveId) PerspectiveLayout(edu.stanford.bmir.protege.web.shared.perspective.PerspectiveLayout) GetPerspectiveLayoutResult(edu.stanford.bmir.protege.web.shared.perspective.GetPerspectiveLayoutResult) Nonnull(javax.annotation.Nonnull)

Example 2 with PerspectiveLayout

use of edu.stanford.bmir.protege.web.shared.perspective.PerspectiveLayout in project webprotege by protegeproject.

the class PerspectiveLayoutStoreImpl method getPerspectiveLayoutFromFile.

private PerspectiveLayout getPerspectiveLayoutFromFile(PerspectiveId perspectiveId, File layoutFile) {
    try {
        if (layoutFile.exists()) {
            String serialization = Files.toString(layoutFile, Charset.forName("utf-8"));
            Node node = new JsonNodeSerializer().deserialize(serialization);
            return new PerspectiveLayout(perspectiveId, Optional.of(node));
        } else {
            return new PerspectiveLayout(perspectiveId, Optional.empty());
        }
    } catch (IOException e) {
        return new PerspectiveLayout(perspectiveId, Optional.empty());
    }
}
Also used : Node(edu.stanford.protege.widgetmap.shared.node.Node) IOException(java.io.IOException) JsonNodeSerializer(edu.stanford.protege.widgetmap.server.node.JsonNodeSerializer) PerspectiveLayout(edu.stanford.bmir.protege.web.shared.perspective.PerspectiveLayout)

Example 3 with PerspectiveLayout

use of edu.stanford.bmir.protege.web.shared.perspective.PerspectiveLayout in project webprotege by protegeproject.

the class ResetPerspectiveLayoutActionHandler method execute.

@Nonnull
@Override
public ResetPerspectiveLayoutResult execute(@Nonnull ResetPerspectiveLayoutAction action, @Nonnull ExecutionContext executionContext) {
    ProjectId projectId = action.getProjectId();
    PerspectiveId perspectiveId = action.getPerspectiveId();
    PerspectiveLayout defaultLayout = store.getPerspectiveLayout(projectId, perspectiveId);
    // Only reset the perspective if there is a default for it
    UserId userId = executionContext.getUserId();
    if (defaultLayout.getRootNode().isPresent()) {
        store.clearPerspectiveLayout(projectId, userId, perspectiveId);
    }
    PerspectiveLayout perspectiveLayout = store.getPerspectiveLayout(projectId, userId, perspectiveId);
    return new ResetPerspectiveLayoutResult(perspectiveLayout);
}
Also used : UserId(edu.stanford.bmir.protege.web.shared.user.UserId) ProjectId(edu.stanford.bmir.protege.web.shared.project.ProjectId) PerspectiveId(edu.stanford.bmir.protege.web.shared.perspective.PerspectiveId) PerspectiveLayout(edu.stanford.bmir.protege.web.shared.perspective.PerspectiveLayout) ResetPerspectiveLayoutResult(edu.stanford.bmir.protege.web.shared.perspective.ResetPerspectiveLayoutResult) Nonnull(javax.annotation.Nonnull)

Aggregations

PerspectiveLayout (edu.stanford.bmir.protege.web.shared.perspective.PerspectiveLayout)3 PerspectiveId (edu.stanford.bmir.protege.web.shared.perspective.PerspectiveId)2 ProjectId (edu.stanford.bmir.protege.web.shared.project.ProjectId)2 UserId (edu.stanford.bmir.protege.web.shared.user.UserId)2 Nonnull (javax.annotation.Nonnull)2 GetPerspectiveLayoutResult (edu.stanford.bmir.protege.web.shared.perspective.GetPerspectiveLayoutResult)1 ResetPerspectiveLayoutResult (edu.stanford.bmir.protege.web.shared.perspective.ResetPerspectiveLayoutResult)1 JsonNodeSerializer (edu.stanford.protege.widgetmap.server.node.JsonNodeSerializer)1 Node (edu.stanford.protege.widgetmap.shared.node.Node)1 IOException (java.io.IOException)1