Skip to content
Snippets Groups Projects
Commit a41d2a52 authored by srosse's avatar srosse
Browse files

OO-450: fix some issues after feedback from K.

parent b6343e89
No related branches found
No related tags found
No related merge requests found
Showing
with 155 additions and 41 deletions
......@@ -798,7 +798,11 @@ public class DBImpl extends LogDelegator implements DB, Destroyable {
if (hasTransaction()) {
TransactionStatus status = txManager.getTransaction(null);
txManager.rollback(status);
//getTransaction().rollback();
EntityTransaction trx = getCurrentEntityManager().getTransaction();
if(trx != null) {
trx.rollback();
}
}
} catch (Error er) {
logError("Uncaught Error in DBImpl.commit.catch(Exception).", er);
......@@ -823,7 +827,11 @@ public class DBImpl extends LogDelegator implements DB, Destroyable {
TransactionStatus status = txManager.getTransaction(null);
txManager.rollback(status);
//getTransaction().rollback();
EntityTransaction trx = getCurrentEntityManager().getTransaction();
if(trx != null) {
trx.rollback();
}
} catch (Exception ex) {
logWarn("Could not rollback transaction!",ex);
......
......@@ -45,6 +45,7 @@ import org.olat.core.gui.translator.Translator;
import org.olat.core.id.OLATResourceable;
import org.olat.core.logging.OLog;
import org.olat.core.logging.Tracing;
import org.olat.core.util.Formatter;
import org.olat.core.util.Util;
import org.olat.core.util.filter.FilterFactory;
import org.olat.core.util.xml.XStreamHelper;
......@@ -115,6 +116,7 @@ public class ChatLogHelper {
Workbook wb = new HSSFWorkbook();
String tableExportTitle = translator.translate("logChat.export.title");
Sheet exportSheet = wb.createSheet(tableExportTitle);
Formatter formatter = Formatter.getInstance(locale);
//headers
Row headerRow = exportSheet.createRow(0);
......@@ -129,7 +131,7 @@ public class ChatLogHelper {
for(InstantMessage message:messages) {
Row dataRow = exportSheet.createRow(count++);
addCell(dataRow, message.getFromNickName(), 0);
addCell(dataRow, message.getCreationDate(), 1);
addCell(dataRow, message.getCreationDate(), 1, formatter);
addCell(dataRow, message.getBody(), 2);
}
return wb;
......@@ -141,9 +143,9 @@ public class ChatLogHelper {
cell.setCellValue(val);
}
private void addCell(Row dataRow, Date val, int position) {
private void addCell(Row dataRow, Date val, int position, Formatter formatter) {
Cell cell = dataRow.createCell(position);
cell.setCellValue(val);
cell.setCellValue(formatter.formatDateAndTime(val));
}
private void addHeader(Row headerRow, CellStyle headerCellStyle, String val, int position) {
......@@ -159,6 +161,4 @@ public class ChatLogHelper {
cellStyle.setFont(boldFont);
return cellStyle;
}
}
......@@ -102,6 +102,11 @@ public class Buddy implements OLATResourceable, Comparable<Buddy>, Serializable
public Long getResourceableId() {
return identityKey;
}
@Override
public Buddy clone() {
return new Buddy(identityKey, username, name, anonym, vip, status);
}
@Override
public int compareTo(Buddy o) {
......
......@@ -104,18 +104,27 @@ public class ChatManagerController extends BasicController {
protected void closeAllChats() {
List<Long> chatKeys = new ArrayList<Long>(chats.keySet());
for(Long chatKey :chatKeys) {
Component p = container.getComponent(chatKey.toString());
if(p != null) {
container.remove(p);
}
ChatController ctrl = chats.get(chatKey);
if(ctrl != null) {
ctrl.closeChat();
}
closeChat(chatKey);
}
chats.clear();
}
protected void closeChat(OLATResourceable ores) {
closeChat(ores.getResourceableId());
}
private void closeChat(Long chatKey) {
Component p = container.getComponent(chatKey.toString());
if(p != null) {
container.remove(p);
}
ChatController ctrl = chats.get(chatKey);
if(ctrl != null) {
ctrl.closeChat();
}
chats.remove(chatKey);
}
public void createChat(UserRequest ureq, Buddy buddy) {
if (buddy == null) return;
OLATResourceable ores = imService.getPrivateChatResource(getIdentity().getKey(), buddy.getIdentityKey());
......
......@@ -42,12 +42,13 @@ import org.olat.instantMessaging.model.BuddyGroup;
*/
public class IMBuddyListController extends BasicController {
private Link toggleOffline;
private Link toggleOffline, toggleGroup;
private final VelocityContainer mainVC;
private final VelocityContainer buddiesListContent;
private Roster buddyList;
private ViewMode viewMode;
private boolean viewGroups = true;
private final InstantMessagingModule imModule;
private final InstantMessagingService imService;
......@@ -70,23 +71,19 @@ public class IMBuddyListController extends BasicController {
} else {
viewMode = ViewMode.offlineUsers;
}
toggleGroup = LinkFactory.createCustomLink("toggleGroups", "cmd.group", "", Link.NONTRANSLATED, mainVC, this);
toggleGroup.setCustomDisplayText(translate("im.hide.groups"));
toggleGroup.setCustomEnabledLinkCSS("o_instantmessaging_showgroupswitch");
buddyList = new Roster(getIdentity().getKey());
mainVC.contextPut("buddyList", buddyList);
buddiesListContent.contextPut("buddyList", buddyList);
buddiesListContent.contextPut("viewGroups", Boolean.TRUE);
loadRoster(viewMode);
mainVC.put("buddiesListContent", buddiesListContent);
putInitialPanel(mainVC);
}
private String getStatusCss(Buddy buddy) {
StringBuilder sb = new StringBuilder(32);
sb.append("o_instantmessaging_").append(buddy.getStatus()).append("_icon ");
if(buddy.isVip()) {
sb.append("o_instantmessaging_vip");
}
return sb.toString();
}
@Override
protected void doDispose() {
......@@ -106,6 +103,18 @@ public class IMBuddyListController extends BasicController {
toggleOffline.setCustomEnabledLinkCSS("o_instantmessaging_showofflineswitch");
loadRoster(ViewMode.onlineUsers);
}
} else if (source == toggleGroup) {
if (viewGroups) {
toggleGroup.setCustomDisplayText(translate("im.show.groups"));
toggleGroup.setCustomEnabledLinkCSS("o_instantmessaging_hidegroupswitch");
buddiesListContent.contextPut("viewGroups", Boolean.FALSE);
viewGroups = false;
} else {
toggleGroup.setCustomDisplayText(translate("im.hide.groups"));
toggleGroup.setCustomEnabledLinkCSS("o_instantmessaging_showgroupswitch");
buddiesListContent.contextPut("viewGroups", Boolean.TRUE);
viewGroups = true;
}
} else if (source instanceof Link) {
Link link = (Link)source;
if("cmd.buddy".equals(link.getCommand())) {
......@@ -136,10 +145,32 @@ public class IMBuddyListController extends BasicController {
if(buddiesListContent.getComponent(linkId) == null) {
Link buddyLink = LinkFactory.createCustomLink(linkId, "cmd.buddy", "", Link.NONTRANSLATED, buddiesListContent, this);
buddyLink.setCustomDisplayText(buddy.getName());
String css = (imModule.isOnlineStatusEnabled() ? getStatusCss(buddy) : "o_instantmessaging_chat_icon");
String css = getStatusCss(buddy);
buddyLink.setCustomEnabledLinkCSS(css);
buddyLink.setUserObject(buddy);
}
String linkIdAlt = "buddy_" + buddy.getIdentityKey();
if(buddiesListContent.getComponent(linkIdAlt) == null) {
Link buddyLink = LinkFactory.createCustomLink(linkIdAlt, "cmd.buddy", "", Link.NONTRANSLATED, buddiesListContent, this);
buddyLink.setCustomDisplayText(buddy.getName());
String css = getStatusCss(buddy);
buddyLink.setCustomEnabledLinkCSS(css);
buddyLink.setUserObject(buddy);
}
}
private String getStatusCss(Buddy buddy) {
StringBuilder sb = new StringBuilder(32);
if(imModule.isOnlineStatusEnabled()) {
sb.append("o_instantmessaging_").append(buddy.getStatus()).append("_icon ");
} else {
sb.append("o_instantmessaging_chat_icon ");
}
if(buddy.isVip()) {
sb.append("o_instantmessaging_vip");
}
return sb.toString();
}
private enum ViewMode {
......
......@@ -255,7 +255,7 @@ public class InstantMessagingMainController extends BasicController implements G
} else if (event instanceof OpenInstantMessageEvent) {
processOpenInstantMessageEvent((OpenInstantMessageEvent)event);
} else if(event instanceof CloseInstantMessagingEvent) {
processCloseInstantMessageEvent();
processCloseInstantMessageEvent((CloseInstantMessagingEvent)event);
} else if(Window.BEFORE_INLINE_RENDERING.equals(event)) {
if(++stateUpdateCounter % 25 == 0) {
updateBuddyStats();
......@@ -359,7 +359,21 @@ public class InstantMessagingMainController extends BasicController implements G
}
}
private void processCloseInstantMessageEvent() {
private void processCloseInstantMessageEvent(CloseInstantMessagingEvent event) {
if(event.getOres() == null) {
close();
} else {
closeChat(event.getOres());
}
}
private void closeChat(OLATResourceable ores) {
if(chatMgrCtrl != null) {
chatMgrCtrl.closeChat(ores);
}
}
private void close() {
if(statusChangerPanelCtr != null) {
statusChangerPanelCtr.executeCloseCommand();
removeAsListenerAndDispose(statusChangerPanelCtr);
......
......@@ -20,7 +20,10 @@
package org.olat.instantMessaging.ui;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.olat.instantMessaging.model.Buddy;
import org.olat.instantMessaging.model.BuddyGroup;
......@@ -96,6 +99,36 @@ public class Roster {
}
}
public synchronized List<Buddy> getBuddies() {
Set<Buddy> buddies = new HashSet<Buddy>();
Set<Buddy> vips = new HashSet<Buddy>();
for(Buddy entry:entries) {
if(entry.isVip()) {
vips.add(entry);
}
buddies.add(entry);
}
for(BuddyGroup group:groups) {
for(Buddy entry:group.getBuddy()) {
if(entry.isVip()) {
vips.add(entry);
}
buddies.add(entry);
}
}
//if vip once, vip always
List<Buddy> orderedBuddies = new ArrayList<Buddy>(buddies.size());
for(Buddy buddy:buddies) {
Buddy clone = buddy.clone();
clone.setVip(vips.contains(buddy));
orderedBuddies.add(clone);
}
Collections.sort(orderedBuddies);
return orderedBuddies;
}
public synchronized void add(Buddy entry) {
entries.add(entry);
}
......
$r.contextHelpWithWrapper("org.olat.instantMessaging.ui","instant-messenger.html","help.hover.im")
<div id='o_instantmessages_buddieslist'>
#if ($r.available("toggleOnline"))
$r.render("toggleOnline")
$r.render("toggleOnline") | $r.render("toggleGroups")
<hr class="b_form_spacer" />
#end
$r.render("buddiesListContent")
......
<ul>
#foreach ($group in $buddyList.groups)
<li class="o_instantmessaging_group">
<div class="o_instantmessaging_groupname">$group.groupName</div>
<ul>
#foreach ($buddy in $group.buddy)
<li>$r.render("buddy_${group.groupKey}_${buddy.identityKey}")</li>
#end
</ul></li>
#if($viewGroups)
#foreach ($group in $buddyList.groups)
<li class="o_instantmessaging_group">
<div class="o_instantmessaging_groupname">$group.groupName</div>
<ul>
#foreach ($buddy in $group.buddy)
<li>$r.render("buddy_${group.groupKey}_${buddy.identityKey}")</li>
#end
</ul></li>
#end
#else
#foreach ($buddy in $buddyList.buddies)
<li>$r.render("buddy_${buddy.identityKey}")</li>
#end
#end
</ul>
\ No newline at end of file
......@@ -24,6 +24,13 @@ function tweak_${panelName}() {
}
function focus_${panelName}() {
try {
var win = Ext.getCmp('${panelName}');
var histEl = win.body.dom.getElementsByClassName('o_instantmessaging_chat_history');
if (histEl.length == 1) {
histEl[0].style.height=win.getSize().height-150 + 'px';
histEl[0].scrollTop = histEl[0].scrollHeight;
}
var el = document.getElementById('o_fioinput_${panelName}');
if(el != null) {
el.focus();
......
......@@ -103,6 +103,7 @@
background-position: 0 50%;
}
a.o_instantmessaging_showgroupswitch {padding: 2px 0 2px 20px; background: url(../openolat/images/users_conf.png) no-repeat 0 50%;}
a.o_instantmessaging_hidegroupswitch {padding: 2px 0 2px 20px; @include o-opacity(60); background: url(../openolat/images/users_conf.png) no-repeat 0 50%;}
a.o_instantmessaging_showofflineswitch {padding: 2px 0 2px 20px; background: url(../openolat/images/im/status-offline.png) no-repeat 0 50%;}
a.o_instantmessaging_hideofflineswitch {padding: 2px 0 2px 20px; background: url(../openolat/images/im/status.png) no-repeat 0 50%;}
}
......
source diff could not be displayed: it is too large. Options to address this: view the blob.
source diff could not be displayed: it is too large. Options to address this: view the blob.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment