Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MDE: Fix error in creation of fields from objectDef #186

Merged
merged 7 commits into from
Jan 25, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,13 @@ public static DefaultMutableTreeNode getChildByName(DefaultMutableTreeNode tree,
}
return null;
}


/**
*
* @param tree
* @param type
* @return null or list of objects with given type in the given tree
*/
public static List<DefaultMutableTreeNode> getChildsByType(DefaultMutableTreeNode tree, String type) {
if(tree!=null) {
List<DefaultMutableTreeNode> listOfChilds=new ArrayList<>();
Expand All @@ -343,7 +349,7 @@ public static List<DefaultMutableTreeNode> getChildsByType(DefaultMutableTreeNod
listOfChilds.add(node);
}
}
return listOfChilds;
return listOfChilds.size()>0 ? listOfChilds:null;
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,35 +307,48 @@ public void customizeTree(String micName){
if(confMap!=null) {
for (Map.Entry<String, ModuleConfiguration> entry : confMap.entrySet()) {
if(entry.getValue()!=null ) {
if (MDEHelper.getChildByName(cTree, entry.getKey()) == null) {
if(entry.getValue().isInsertInTree()) {
String pType = entry.getValue().getInsertPoint();
List<DefaultMutableTreeNode> insertAtNodeList=MDEHelper.getChildsByType(cTree,pType);
if(insertAtNodeList!=null){
for(DefaultMutableTreeNode insertAtNode:insertAtNodeList) {
// Test if this kind of child still exists
if(MDEHelper.getListOfChilds(entry.getKey(),insertAtNode)==null ) {
ModuleContent c = controller.getContentOfType(entry.getKey());
ModuleTreeElement choice = null;
if (c != null && c.getList() == null) {
choice = new ModuleTreeElement(c, insertAtNode);
} else {
choice = new ModuleTreeElement(entry.getKey(), null, "", c, insertAtNode);
}

addNode(insertAtNode, new DefaultMutableTreeNode(choice));
}
}
insertCustomizeNode(entry.getKey(),entry.getValue(),cTree,confMap);
}
}
}
}

private void insertCustomizeNode(String nodeType,ModuleConfiguration nodeConf, DefaultMutableTreeNode cTree,HashMap<String,ModuleConfiguration> confMap){
// test auf element ist bereits child of root
jburel marked this conversation as resolved.
Show resolved Hide resolved
if (MDEHelper.getChildByName(cTree, nodeType) == null) {
// soll element sichtbar sein
if(nodeConf.isInsertInTree()) {
// parent node
String pType = nodeConf.getInsertPoint();
List<DefaultMutableTreeNode> insertAtNodeList=MDEHelper.getChildsByType(cTree,pType);
if(insertAtNodeList!=null){
for(DefaultMutableTreeNode insertAtNode:insertAtNodeList) {
// Test if this kind of child still exists
if(MDEHelper.getListOfChilds(nodeType,insertAtNode)==null ) {
ModuleContent c = controller.getContentOfType(nodeType);
ModuleTreeElement choice = null;
if (c != null && c.getList() == null) {
choice = new ModuleTreeElement(c, insertAtNode);
} else {
choice = new ModuleTreeElement(nodeType, null, "", c, insertAtNode);
}

addNode(insertAtNode, new DefaultMutableTreeNode(choice));
}
}
}else{
if(confMap.containsKey(pType) && confMap.get(pType)!=null){
// insert first parent before child
insertCustomizeNode(pType,confMap.get(pType),cTree,confMap);
insertCustomizeNode(nodeType,nodeConf,cTree,confMap);
}

}
}
}
}



public void removeNodeFromParent(DefaultMutableTreeNode current) {
if(tree==null)
return;
Expand Down