public void updateFont(TreeItem item) {
FontData fontDatas[] = item.getFont().getFontData();
FontData data = fontDatas[0];
boolean isBold = false;
TreeData data_ = (TreeData) item.getData();
if(data_ == null || data_.getElement() == null)
return;
int type = data_.getType();
Element elem = data_.getElement();
if (type == Editor.EVERYDAY) {
if(!elem.getChildren("period").isEmpty() || !elem.getChildren("at").isEmpty())
isBold = true;
} else if(type == Editor.DAYS) {
if(!elem.getChildren("date").isEmpty())
isBold = true;
} else if(type == Editor.WEEKDAYS) {
if(item.getData("key") != null && item.getData("key").equals("holidays_@_weekdays")) {
if(elem.getChild("holidays") != null && !elem.getChild("holidays").getChildren("weekdays").isEmpty()) {
isBold = true;
}
} else {
if(!elem.getChildren("weekdays").isEmpty())
isBold = true;
}
} else if(type == Editor.MONTHDAYS) {
if(!elem.getChildren("monthdays").isEmpty() && !elem.getChild("monthdays").getChildren("day").isEmpty())
isBold = true;
} else if(type == Editor.ULTIMOS) {
if(!elem.getChildren("ultimos").isEmpty())
isBold = true;
} else if(type == Editor.SPECIFIC_WEEKDAYS) {
if(!elem.getChildren("monthdays").isEmpty() && !elem.getChild("monthdays").getChildren("weekday").isEmpty())
isBold = true;
} else if(type == Editor.SPECIFIC_MONTHS) {
if(!elem.getChildren("month").isEmpty())
isBold = true;
} else if(type == Editor.RUNTIME) {
elem = elem.getChild("run_time");
if(elem != null) {
/*int hasAttribute = Utils.getAttributeValue("begin", elem).length() + Utils.getAttributeValue("end", elem).length() +
(Utils.getAttributeValue("let_run", elem).equals("yes") ? 1 : 0) +
(Utils.getAttributeValue("once", elem).equals("yes") ? 1 : 0);
if(hasAttribute > 0)
*/
if(elem.getAttributes().size()>0)
isBold = true;
}
}
Font font = null;
if(isBold){
font = new Font(Display.getCurrent(), data.getName(), data.getHeight(), SWT.BOLD);
} else {
font = new Font(Display.getCurrent(), data.getName(), data.getHeight(), SWT.NONE);
}
item.setFont(font);
}