From 3ecda686abe72d4168ba0290bb164af7c4179e43 Mon Sep 17 00:00:00 2001 From: sukunis Date: Mon, 4 Jan 2021 11:57:54 +0100 Subject: [PATCH 1/5] Bugfix: getChildsByType returns now NULL or NOT empty list of childs --- .../shoola/agents/fsimporter/mde/MDEHelper.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/openmicroscopy/shoola/agents/fsimporter/mde/MDEHelper.java b/src/main/java/org/openmicroscopy/shoola/agents/fsimporter/mde/MDEHelper.java index f30b94ed8..dccc9c99b 100644 --- a/src/main/java/org/openmicroscopy/shoola/agents/fsimporter/mde/MDEHelper.java +++ b/src/main/java/org/openmicroscopy/shoola/agents/fsimporter/mde/MDEHelper.java @@ -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 getChildsByType(DefaultMutableTreeNode tree, String type) { if(tree!=null) { List listOfChilds=new ArrayList<>(); @@ -343,7 +349,7 @@ public static List getChildsByType(DefaultMutableTreeNod listOfChilds.add(node); } } - return listOfChilds; + return listOfChilds.size()>0 ? listOfChilds:null; } return null; } From c175bfe7f98b15d5c47ac1aedad70d75ae4ea0b4 Mon Sep 17 00:00:00 2001 From: sukunis Date: Mon, 4 Jan 2021 11:59:25 +0100 Subject: [PATCH 2/5] extract method --- .../mde/components/view/ModuleTree.java | 53 ++++++++++++------- 1 file changed, 33 insertions(+), 20 deletions(-) diff --git a/src/main/java/org/openmicroscopy/shoola/agents/fsimporter/mde/components/view/ModuleTree.java b/src/main/java/org/openmicroscopy/shoola/agents/fsimporter/mde/components/view/ModuleTree.java index 8f1f8480a..32736a37b 100644 --- a/src/main/java/org/openmicroscopy/shoola/agents/fsimporter/mde/components/view/ModuleTree.java +++ b/src/main/java/org/openmicroscopy/shoola/agents/fsimporter/mde/components/view/ModuleTree.java @@ -307,35 +307,48 @@ public void customizeTree(String micName){ if(confMap!=null) { for (Map.Entry entry : confMap.entrySet()) { if(entry.getValue()!=null ) { - if (MDEHelper.getChildByName(cTree, entry.getKey()) == null) { - if(entry.getValue().isInsertInTree()) { - String pType = entry.getValue().getInsertPoint(); - List 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 confMap){ + // test auf element ist bereits child of root + if (MDEHelper.getChildByName(cTree, nodeType) == null) { + // soll element sichtbar sein + if(nodeConf.isInsertInTree()) { + // parent node + String pType = nodeConf.getInsertPoint(); + List 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; From c8dc55c4d3e938a5101f0ef6b9f4b9317b85b0ab Mon Sep 17 00:00:00 2001 From: sukunis Date: Mon, 4 Jan 2021 11:57:54 +0100 Subject: [PATCH 3/5] Bugfix: getChildsByType returns now NULL or NOT empty list of childs --- .../shoola/agents/fsimporter/mde/MDEHelper.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/openmicroscopy/shoola/agents/fsimporter/mde/MDEHelper.java b/src/main/java/org/openmicroscopy/shoola/agents/fsimporter/mde/MDEHelper.java index f30b94ed8..dccc9c99b 100644 --- a/src/main/java/org/openmicroscopy/shoola/agents/fsimporter/mde/MDEHelper.java +++ b/src/main/java/org/openmicroscopy/shoola/agents/fsimporter/mde/MDEHelper.java @@ -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 getChildsByType(DefaultMutableTreeNode tree, String type) { if(tree!=null) { List listOfChilds=new ArrayList<>(); @@ -343,7 +349,7 @@ public static List getChildsByType(DefaultMutableTreeNod listOfChilds.add(node); } } - return listOfChilds; + return listOfChilds.size()>0 ? listOfChilds:null; } return null; } From 956d2fc83f71f517a4060b4f7aad07f7f7563cc3 Mon Sep 17 00:00:00 2001 From: sukunis Date: Mon, 4 Jan 2021 11:59:25 +0100 Subject: [PATCH 4/5] extract method --- .../mde/components/view/ModuleTree.java | 53 ++++++++++++------- 1 file changed, 33 insertions(+), 20 deletions(-) diff --git a/src/main/java/org/openmicroscopy/shoola/agents/fsimporter/mde/components/view/ModuleTree.java b/src/main/java/org/openmicroscopy/shoola/agents/fsimporter/mde/components/view/ModuleTree.java index 8f1f8480a..32736a37b 100644 --- a/src/main/java/org/openmicroscopy/shoola/agents/fsimporter/mde/components/view/ModuleTree.java +++ b/src/main/java/org/openmicroscopy/shoola/agents/fsimporter/mde/components/view/ModuleTree.java @@ -307,35 +307,48 @@ public void customizeTree(String micName){ if(confMap!=null) { for (Map.Entry entry : confMap.entrySet()) { if(entry.getValue()!=null ) { - if (MDEHelper.getChildByName(cTree, entry.getKey()) == null) { - if(entry.getValue().isInsertInTree()) { - String pType = entry.getValue().getInsertPoint(); - List 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 confMap){ + // test auf element ist bereits child of root + if (MDEHelper.getChildByName(cTree, nodeType) == null) { + // soll element sichtbar sein + if(nodeConf.isInsertInTree()) { + // parent node + String pType = nodeConf.getInsertPoint(); + List 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; From a60f419748b746c51d9bac7f849260cf5ed556e6 Mon Sep 17 00:00:00 2001 From: sukunis Date: Mon, 18 Jan 2021 15:58:51 +0100 Subject: [PATCH 5/5] delete german comment --- .../agents/fsimporter/mde/components/view/ModuleTree.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/org/openmicroscopy/shoola/agents/fsimporter/mde/components/view/ModuleTree.java b/src/main/java/org/openmicroscopy/shoola/agents/fsimporter/mde/components/view/ModuleTree.java index 32736a37b..cb263acd6 100644 --- a/src/main/java/org/openmicroscopy/shoola/agents/fsimporter/mde/components/view/ModuleTree.java +++ b/src/main/java/org/openmicroscopy/shoola/agents/fsimporter/mde/components/view/ModuleTree.java @@ -314,9 +314,8 @@ public void customizeTree(String micName){ } private void insertCustomizeNode(String nodeType,ModuleConfiguration nodeConf, DefaultMutableTreeNode cTree,HashMap confMap){ - // test auf element ist bereits child of root if (MDEHelper.getChildByName(cTree, nodeType) == null) { - // soll element sichtbar sein + // element visible? if(nodeConf.isInsertInTree()) { // parent node String pType = nodeConf.getInsertPoint();