Skip to content

Commit

Permalink
Fix two JSON load and saving problems:
Browse files Browse the repository at this point in the history
* Fix root node never importing JSON loaded UI keyvalues data.
* Fix changed notes being assigned to the root node indiscriminately, for any node being examined.
  • Loading branch information
Adrianilloo committed Sep 9, 2019
1 parent b834c2b commit a8b33a4
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 23 deletions.
23 changes: 14 additions & 9 deletions JBUI/src/jbui/controller/NodeDetailController.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ private SectionStringTreeItem(String text)
private TextArea mNotesTextArea;

public final IdSystemNode mProtocolSaveRootNode;
private IdSystemNode mSelectedNode;

public NodeDetailController()
{
Expand All @@ -111,6 +112,7 @@ private void createCopyToClipboardMenu()
@SuppressWarnings("unchecked")
void init(IdSystemNode modelNode)
{
mSelectedNode = modelNode;
TreeItem<String> strandsItem = new SectionStringTreeItem(
JBUI.sInstance.mLocalizationResources.getString("ParticipantsStrands"));
TreeItem<String> intruderKItem = new SectionStringTreeItem(
Expand Down Expand Up @@ -396,18 +398,21 @@ public void updateItem(String item, boolean empty)

mNotesTextArea.textProperty().addListener((observable, oldText, newText) ->
{
mProtocolSaveRootNode.mNotes = newText;

if (mProtocolSaveFile != null)
if (newText != null)
{
if (mNotesAutoSaveCheck.isSelected())
mSelectedNode.mNotes = newText;

if (mProtocolSaveFile != null)
{
saveCurrentProtocol();
return;
}
if (mNotesAutoSaveCheck.isSelected())
{
saveCurrentProtocol();
return;
}

mNotesSaveBtn.setDisable(false);
handleProtocolDataChanged();
mNotesSaveBtn.setDisable(false);
handleProtocolDataChanged();
}
}
});
}
Expand Down
28 changes: 14 additions & 14 deletions JBUI/src/jbui/model/IdSystemNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ static void parseJSONIdSystemArray(IdSystemNode startNode, int depth, JSONArray
if (JBUI.getMaudeThinker().mRootIdSystemNode != null)
{
JBUI.getMaudeThinker().mRootIdSystemNode.mMsgElemSequences = node.mMsgElemSequences;
JBUI.getMaudeThinker().mRootIdSystemNode.parseUIKeys(jsonIdSystem);
}
else
{
JBUI.getMaudeThinker().mRootIdSystemNode = node;
node.mUIController = JBUI.getMainController().createFXTreeLayout(node);
node.tryParseUIKeys(jsonIdSystem, parseUIKeys);
JBUI.getMainController().mTreeExportItem.setDisable(false);
}
}
Expand Down Expand Up @@ -117,11 +117,7 @@ static void parseJSONIdSystemArray(IdSystemNode startNode, int depth, JSONArray
NonRootIdSystemNode node = new NonRootIdSystemNode(idElems.getLast(), jsonIdSystem);
JBUI.getMaudeThinker().mRootIdSystemNode.insert(node, idElems);
levelNodes.add(node);

if (parseUIKeys)
{
node.parseUIKeys(jsonIdSystem);
}
((IdSystemNode) node).tryParseUIKeys(jsonIdSystem, parseUIKeys);
}

startNode.inferLastReachableNodes(levelNodes, depth, startNode.getDepth());
Expand Down Expand Up @@ -302,19 +298,23 @@ public void outputIdAsJSONArray(JSONArray jsonArray) throws JSONException
jsonArray.put(jsonId);
}

void parseUIKeys(JSONObject jsonIdSystem)
private void tryParseUIKeys(JSONObject jsonIdSystem, boolean parseUIKeys)
{
if (jsonIdSystem.optBoolean("isSelected"))
if (parseUIKeys)
{
JBUI.getMainController().selectScreenNode(mUIController);
}
if (jsonIdSystem.optBoolean("isSelected"))
{
JBUI.getMainController().selectScreenNode(mUIController);
}

if (jsonIdSystem.optBoolean("isFolded"))
{
mUIController.fold();
if (jsonIdSystem.optBoolean("isFolded"))
{
mUIController.fold();
}

mNotes = jsonIdSystem.optString("notes", null);
}

mNotes = jsonIdSystem.optString("notes");
}

protected String unparseId(String separator)
Expand Down

0 comments on commit a8b33a4

Please sign in to comment.