Revision 1d035f5d
Added by Patrick Plitzner about 5 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/wizard/CheckBoxTreeComposite.java | ||
---|---|---|
98 | 98 |
if(parentItem!=null){ |
99 | 99 |
updateItem(parentItem); |
100 | 100 |
} |
101 |
updateChildItems(treeItem); |
|
101 |
else{ |
|
102 |
updateChildItems(treeItem); |
|
103 |
} |
|
102 | 104 |
} |
103 | 105 |
|
104 |
private CheckState updateChildItems(TreeItem treeItem){
|
|
105 |
CheckState checkState = CheckState.NONE;
|
|
106 |
private void updateChildItems(TreeItem treeItem){
|
|
107 |
treeItem.setFont(FONT_DEFAULT);
|
|
106 | 108 |
TreeItem[] children = treeItem.getItems(); |
107 | 109 |
if(children.length==0){ |
108 |
return treeItem.getChecked()?CheckState.CHECKED:CheckState.NONE;
|
|
110 |
return; |
|
109 | 111 |
} |
110 | 112 |
int checkedCount = 0; |
111 | 113 |
for (TreeItem child : children) { |
112 |
CheckState childState = updateChildItems(child); |
|
113 |
if(childState.equals(CheckState.CHECKED)) { |
|
114 |
checkedCount++; |
|
114 |
updateChildItems(child); |
|
115 |
if(child.getChecked()){ |
|
116 |
if ((child.getFont().equals(FONT_BOLD)) || (child.getItems().length == 0)) { |
|
117 |
checkedCount++; |
|
118 |
} |
|
119 |
//some children are checked |
|
120 |
treeItem.setFont(FONT_ITALIC); |
|
115 | 121 |
} |
116 |
else if(childState.equals(CheckState.GRAYED)){ |
|
122 |
else if(child.getFont().equals(FONT_ITALIC) |
|
123 |
|| child.getFont().equals(FONT_BOLD)){ |
|
124 |
//some children are checked |
|
117 | 125 |
treeItem.setFont(FONT_ITALIC); |
118 |
return CheckState.GRAYED; |
|
119 | 126 |
} |
120 | 127 |
} |
121 | 128 |
if(checkedCount==children.length){ |
122 | 129 |
//all children are checked |
123 |
checkState = CheckState.CHECKED; |
|
124 | 130 |
treeItem.setFont(FONT_BOLD); |
125 | 131 |
} |
126 |
else if(checkedCount>0){ |
|
127 |
//some children are checked |
|
128 |
checkState = CheckState.GRAYED; |
|
129 |
treeItem.setFont(FONT_ITALIC); |
|
130 |
} |
|
131 |
else{ |
|
132 |
//no children are checked |
|
133 |
treeItem.setFont(FONT_DEFAULT); |
|
134 |
if(treeItem.getChecked()){ |
|
135 |
//no children but item itself is checked |
|
136 |
checkState = CheckState.CHECKED; |
|
132 |
else if(!treeItem.getFont().equals(FONT_ITALIC)){ |
|
133 |
if(checkedCount>0){ |
|
134 |
//some children are checked |
|
135 |
treeItem.setFont(FONT_ITALIC); |
|
137 | 136 |
} |
138 | 137 |
else{ |
139 |
//neither children nor item itself is checked
|
|
140 |
checkState = CheckState.NONE;
|
|
138 |
//no children are checked
|
|
139 |
treeItem.setFont(FONT_DEFAULT);
|
|
141 | 140 |
} |
142 | 141 |
} |
143 |
return checkState; |
|
144 | 142 |
} |
145 | 143 |
|
144 |
|
|
146 | 145 |
public CheckboxTreeViewer getViewer() { |
147 | 146 |
return viewer; |
148 | 147 |
} |
Also available in: Unified diff
ref #7912 Fix font evaluation in checkbox tree composite