Skip to content

Commit

Permalink
Fixes metadata <-> documentation pane change in the inspection pane
Browse files Browse the repository at this point in the history
  • Loading branch information
André Pereira committed Apr 11, 2016
1 parent 9cb5c3e commit 6e38f7c
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions src/main/java/org/roda/rodain/inspection/InspectionPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,8 @@ private void createContent() {
HBox.setHgrow(space, Priority.ALWAYS);

sipDocumentation = new SipDocumentationTreeView();

docsRoot = new SipContentDirectory(new TreeNode(Paths.get("")), null);
sipDocumentation.setRoot(docsRoot);
toggleDocumentation = new ToggleButton();
toggleDocumentation.setTooltip(new Tooltip(I18n.t("documentation")));
Platform.runLater(() -> {
Expand Down Expand Up @@ -693,7 +694,9 @@ private void createContent() {
}
} else { // from the documentation to the representations
toggleDocumentation.setTooltip(new Tooltip(I18n.t("documentation")));
dataBox.getChildren().clear();
dataBox.getChildren().add(sipFiles);
content.setCenter(dataBox);
content.setBottom(contentBottom);
}
});
Expand Down Expand Up @@ -827,6 +830,8 @@ protected Void call() throws Exception {
sipRoot = newRoot;
if (active) {
sipFiles.setRoot(sipRoot);
dataBox.getChildren().clear();
dataBox.getChildren().add(sipFiles);
content.setCenter(dataBox);
content.setBottom(contentBottom);
}
Expand All @@ -835,8 +840,7 @@ protected Void call() throws Exception {
}

private void createDocumentation(SipPreviewNode sip, boolean active) {
SipContentDirectory newRoot = new SipContentDirectory(new TreeNode(Paths.get("")), null);

docsRoot.getChildren().clear();
if (active) {
content.setCenter(loadingPane);
content.setBottom(new HBox());
Expand All @@ -846,19 +850,21 @@ private void createDocumentation(SipPreviewNode sip, boolean active) {
@Override
protected Void call() throws Exception {
for (TreeNode treeNode : sip.getSip().getDocumentation()) {
TreeItem<Object> startingItem = recCreateSipContent(treeNode, newRoot);
TreeItem<Object> startingItem = recCreateSipContent(treeNode, docsRoot);
startingItem.setExpanded(true);
newRoot.getChildren().add(startingItem);
docsRoot.getChildren().add(startingItem);
}
newRoot.sortChildren();
docsRoot.sortChildren();
return null;
}
};
docsTask.setOnSucceeded(event -> {
docsRoot = newRoot;
if (active) {
sipDocumentation.setRoot(docsRoot);
if (!docsRoot.getChildren().isEmpty()) {
if (!dataBox.getChildren().contains(sipDocumentation)) {
dataBox.getChildren().clear();
dataBox.getChildren().add(sipDocumentation);
}
content.setCenter(dataBox);
content.setBottom(docsBottom);
} else {
Expand All @@ -867,6 +873,7 @@ protected Void call() throws Exception {
}
}
});

new Thread(docsTask).start();
}

Expand Down Expand Up @@ -1047,15 +1054,6 @@ public void update(SipPreviewNode sip) {
boolean documentation = toggleDocumentation.isSelected();
createContent(sip, !documentation);
createDocumentation(sip, documentation);
if (documentation) {
if (docsRoot.getChildren().isEmpty()) {
content.setBottom(new HBox());
} else {
content.setBottom(docsBottom);
}
} else {
content.setBottom(contentBottom);
}

center.getChildren().addAll(metadata, content);
setCenter(center);
Expand Down

0 comments on commit 6e38f7c

Please sign in to comment.