Progress on Dialogue Sketch to JSON Data conversion.

Opportunistic bug fix in JSON import wizard.
This commit is contained in:
Zukero
2016-12-16 09:41:04 +01:00
parent 6ac332834d
commit b1d0175a9d
5 changed files with 46 additions and 22 deletions

View File

@@ -801,7 +801,7 @@ public class Project implements ProjectTreeNode, Serializable {
/**
*
* @param node. Before calling this method, make sure that no other node with the same class exist in either created or altered.
* @param node. Before calling this method, make sure that no other node with the same class and id exist in either created or altered.
*/
public void createElement(JSONElement node) {
node.writable = true;
@@ -823,6 +823,34 @@ public class Project implements ProjectTreeNode, Serializable {
fireElementAdded(node, getNodeIndex(node));
}
/**
*
* @param node. Before calling this method, make sure that no other node with the same class and id exist in either created or altered.
*/
public void createElements(List<JSONElement> nodes) {
for (JSONElement node : nodes) {
//Already added.
if (node.getProject() != null) continue;
node.writable = true;
if (getGameDataElement(node.getClass(), node.id) != null) {
GameDataElement existingNode = getGameDataElement(node.getClass(), node.id);
for (GameDataElement backlink : existingNode.getBacklinks()) {
backlink.elementChanged(existingNode, node);
}
existingNode.getBacklinks().clear();
node.writable = true;
alteredContent.gameData.addElement(node);
} else {
createdContent.gameData.addElement(node);
}
}
for (JSONElement node : nodes) {
node.link();
node.state = GameDataElement.State.created;
fireElementAdded(node, getNodeIndex(node));
}
}
public void moveToCreated(JSONElement target) {
target.childrenRemoved(new ArrayList<ProjectTreeNode>());