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());
}
}
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)))));
}
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());
}
}
Aggregations