Search in sources :

Example 1 with Node

use of edu.stanford.protege.widgetmap.shared.node.Node 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 2 with Node

use of edu.stanford.protege.widgetmap.shared.node.Node in project webprotege by protegeproject.

the class PerspectiveLayout_TestCase method shouldNotBeEqualToOtherThatHasDifferent_rootNode.

@Test
public void shouldNotBeEqualToOtherThatHasDifferent_rootNode() {
    Node otherNode = Mockito.mock(Node.class);
    when(otherNode.duplicate()).thenReturn(otherNode);
    assertThat(perspectiveLayout, is(not(new PerspectiveLayout(perspectiveId, Optional.of(otherNode)))));
}
Also used : Node(edu.stanford.protege.widgetmap.shared.node.Node) Test(org.junit.Test)

Example 3 with Node

use of edu.stanford.protege.widgetmap.shared.node.Node in project webprotege by protegeproject.

the class PerspectivePresenter method installPerspective.

private void installPerspective(@Nonnull PerspectiveId perspectiveId, @Nonnull PerspectiveLayout layout, boolean viewsCloseable) {
    Perspective perspective = perspectiveFactory.createPerspective(perspectiveId);
    perspective.setViewsCloseable(viewsCloseable);
    EmptyPerspectivePresenter emptyPerspectivePresenter = emptyPerspectivePresenterFactory.createEmptyPerspectivePresenter(perspectiveId);
    perspective.setEmptyPerspectiveWidget(emptyPerspectivePresenter.getView());
    Optional<Node> rootNode = layout.getRootNode();
    perspective.setRootNode(rootNode);
    perspective.setRootNodeChangedHandler(rootNodeChangedEvent -> {
        savePerspectiveLayout(perspectiveId, rootNodeChangedEvent.getTo());
    });
    perspectiveCache.put(perspectiveId, perspective);
    perspectiveView.setWidget(perspective);
    if (rootNode.isPresent()) {
        originalRootNodeMap.put(perspectiveId, rootNode.get().duplicate());
    }
}
Also used : ResetPerspectiveLayoutAction.resetPerspective(edu.stanford.bmir.protege.web.shared.perspective.ResetPerspectiveLayoutAction.resetPerspective) Node(edu.stanford.protege.widgetmap.shared.node.Node)

Aggregations

Node (edu.stanford.protege.widgetmap.shared.node.Node)3 PerspectiveLayout (edu.stanford.bmir.protege.web.shared.perspective.PerspectiveLayout)1 ResetPerspectiveLayoutAction.resetPerspective (edu.stanford.bmir.protege.web.shared.perspective.ResetPerspectiveLayoutAction.resetPerspective)1 JsonNodeSerializer (edu.stanford.protege.widgetmap.server.node.JsonNodeSerializer)1 IOException (java.io.IOException)1 Test (org.junit.Test)1