private DefaultMutableTreeNode getTreeNode(FieldMapNode node) { if (node == null) { return new TristateCheckBoxNode(); } TristateCheckBoxNode treeNode = new TristateCheckBoxNode(node); if (node.isLeaf()) { return treeNode; } for (int i = 0; i < node.getChildCount(); i++) { treeNode.add(getTreeNode(node.getChildAt(i))); } return treeNode; }
private void getNodeValue(TristateCheckBoxNode node, List v, String fName, boolean isSel) { if (node == null) { return; } boolean isV = isSel ? State.SELECTED.equals(node.getState()) : State.NOT_SELECTED.equals(node.getState()); if (isV) { FieldMapNode fmn = (FieldMapNode) node.getUserObject(); v.add(fmn.getFieldValue(fName)); } for (TristateCheckBoxNode tmp : node.getChildren()) { getNodeValue(tmp, v, fName, isSel); } }
private void setNodeValue(TristateCheckBoxNode node, List vList, String fName, boolean isSel) { if (node == null) { return; } FieldMapNode fmn = (FieldMapNode) node.getUserObject(); boolean isS = isSel ? vList.contains(fmn.getFieldValue(fName)) : !vList.contains(fmn.getFieldValue(fName)); if (isS && node.isLeaf()) { node.setState(State.SELECTED); } for (TristateCheckBoxNode tmp : node.getChildren()) { setNodeValue(tmp, vList, fName, isSel); } }