use of org.olat.core.gui.components.date.DateElement in project OpenOLAT by OpenOLAT.
the class InfoDisplayController method loadMessages.
/**
* This is the main method which push the messages in the layout container,
* and clean-up old links.
*/
protected void loadMessages() {
// first clear the current message if any
for (Long key : previousDisplayKeys) {
flc.contextRemove("info.date." + key);
if (flc.getComponent("info.delete." + key) != null) {
flc.remove("info.delete." + key);
}
if (flc.getComponent("info.edit." + key) != null) {
flc.remove("info.edit." + key);
}
}
previousDisplayKeys.clear();
deleteLinks.clear();
List<InfoMessage> msgs = infoMessageManager.loadInfoMessageByResource(ores, resSubPath, businessPath, after, null, 0, maxResults);
List<InfoMessageForDisplay> infoDisplays = new ArrayList<>(msgs.size());
Map<Long, VFSLeaf> keyToDisplay = new HashMap<>();
for (InfoMessage info : msgs) {
previousDisplayKeys.add(info.getKey());
InfoMessageForDisplay infoDisplay = createInfoMessageForDisplay(info);
infoDisplays.add(infoDisplay);
if (infoDisplay.getAttachment() != null) {
keyToDisplay.put(info.getKey(), infoDisplay.getAttachment());
}
String dateCmpName = "info.date." + info.getKey();
DateElement dateEl = DateComponentFactory.createDateElementWithYear(dateCmpName, info.getCreationDate());
flc.add(dateCmpName, dateEl);
if (secCallback.canEdit(info)) {
String editName = "info.edit." + info.getKey();
FormLink link = uifactory.addFormLink(editName, "edit", "edit", flc, Link.BUTTON_SMALL);
link.setElementCssClass("o_sel_info_edit_msg");
link.setUserObject(info);
editLinks.add(link);
flc.add(link);
}
if (secCallback.canDelete()) {
String delName = "info.delete." + info.getKey();
FormLink link = uifactory.addFormLink(delName, "delete", "delete", flc, Link.BUTTON_SMALL);
link.setElementCssClass("o_sel_info_delete_msg");
link.setUserObject(info);
deleteLinks.add(link);
flc.add(link);
}
}
flc.contextPut("infos", infoDisplays);
infoKeyToAttachment = keyToDisplay;
int numOfInfos = infoMessageManager.countInfoMessageByResource(ores, resSubPath, businessPath, null, null);
oldMsgsLink.setVisible((msgs.size() < numOfInfos));
newMsgsLink.setVisible((msgs.size() == numOfInfos) && (numOfInfos > maxResultsConfig) && (maxResultsConfig > 0));
}
use of org.olat.core.gui.components.date.DateElement in project openolat by klemens.
the class InfoDisplayController method loadMessages.
/**
* This is the main method which push the messages in the layout container,
* and clean-up old links.
*/
protected void loadMessages() {
// first clear the current message if any
for (Long key : previousDisplayKeys) {
flc.contextRemove("info.date." + key);
if (flc.getComponent("info.delete." + key) != null) {
flc.remove("info.delete." + key);
}
if (flc.getComponent("info.edit." + key) != null) {
flc.remove("info.edit." + key);
}
}
previousDisplayKeys.clear();
deleteLinks.clear();
List<InfoMessage> msgs = infoMessageManager.loadInfoMessageByResource(ores, resSubPath, businessPath, after, null, 0, maxResults);
List<InfoMessageForDisplay> infoDisplays = new ArrayList<>(msgs.size());
Map<Long, VFSLeaf> keyToDisplay = new HashMap<>();
for (InfoMessage info : msgs) {
previousDisplayKeys.add(info.getKey());
InfoMessageForDisplay infoDisplay = createInfoMessageForDisplay(info);
infoDisplays.add(infoDisplay);
if (infoDisplay.getAttachment() != null) {
keyToDisplay.put(info.getKey(), infoDisplay.getAttachment());
}
String dateCmpName = "info.date." + info.getKey();
DateElement dateEl = DateComponentFactory.createDateElementWithYear(dateCmpName, info.getCreationDate());
flc.add(dateCmpName, dateEl);
if (secCallback.canEdit(info)) {
String editName = "info.edit." + info.getKey();
FormLink link = uifactory.addFormLink(editName, "edit", "edit", flc, Link.BUTTON_SMALL);
link.setElementCssClass("o_sel_info_edit_msg");
link.setUserObject(info);
editLinks.add(link);
flc.add(link);
}
if (secCallback.canDelete()) {
String delName = "info.delete." + info.getKey();
FormLink link = uifactory.addFormLink(delName, "delete", "delete", flc, Link.BUTTON_SMALL);
link.setElementCssClass("o_sel_info_delete_msg");
link.setUserObject(info);
deleteLinks.add(link);
flc.add(link);
}
}
flc.contextPut("infos", infoDisplays);
infoKeyToAttachment = keyToDisplay;
int numOfInfos = infoMessageManager.countInfoMessageByResource(ores, resSubPath, businessPath, null, null);
oldMsgsLink.setVisible((msgs.size() < numOfInfos));
newMsgsLink.setVisible((msgs.size() == numOfInfos) && (numOfInfos > maxResultsConfig) && (maxResultsConfig > 0));
}
Aggregations