Adding new Feature:

in MUCs you can now toggle between showing icons from presence
or showing icons from MUC.Role(e.g moderator,participant,visitor)

toggle in : Preferences -> 
GroupChat/Conference -> 
[ x ] Show chatroleicons instead of statusicons


Added some missing german locales

git-svn-id: http://svn.igniterealtime.org/svn/repos/spark/trunk@12093 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Wolf Posdorfer
2011-03-10 13:27:33 +00:00
committed by wolf.posdorfer
parent 578af51a51
commit 6d37fd24ba
6 changed files with 160 additions and 43 deletions

View File

@ -47,6 +47,8 @@ import org.jivesoftware.spark.ui.rooms.ChatRoomImpl;
import org.jivesoftware.spark.ui.rooms.GroupChatRoom;
import org.jivesoftware.spark.util.ModelUtil;
import org.jivesoftware.spark.util.log.Log;
import org.jivesoftware.sparkimpl.settings.local.LocalPreferences;
import org.jivesoftware.sparkimpl.settings.local.SettingsManager;
import java.awt.Color;
import java.awt.Component;
@ -95,6 +97,7 @@ public final class GroupChatParticipantList extends JPanel implements
private final ImageTitlePanel agentInfoPanel;
private ChatManager chatManager;
private MultiUserChat chat;
private LocalPreferences _localPreferences = SettingsManager.getLocalPreferences();
private final Map<String, String> userMap = new HashMap<String, String>();
@ -332,45 +335,77 @@ public final class GroupChatParticipantList extends JPanel implements
return icon;
}
private void addParticipant(String participantJID, Presence presence) {
// Remove reference to invitees
for (String displayName : invitees.keySet()) {
String jid = SparkManager.getUserManager().getJIDFromDisplayName(
displayName);
private void addParticipant(String participantJID, Presence presence) {
// Remove reference to invitees
for (String displayName : invitees.keySet()) {
String jid = SparkManager.getUserManager().getJIDFromDisplayName(
displayName);
Occupant occ = chat.getOccupant(participantJID);
if (occ != null) {
String actualJID = occ.getJid();
if (actualJID.equals(jid)) {
removeUser(displayName);
}
}
Occupant occ = chat.getOccupant(participantJID);
if (occ != null) {
String actualJID = occ.getJid();
if (actualJID.equals(jid)) {
removeUser(displayName);
}
}
}
String nickname = StringUtils.parseResource(participantJID);
String nickname = StringUtils.parseResource(participantJID);
String userRole = chat.getOccupant(participantJID).getRole();
Icon icon = null;
if (_localPreferences.isShowingRoleIcons()) {
icon = getIconForRole(userRole);
} else {
icon = PresenceManager.getIconFromPresence(presence);
if (icon == null) {
icon = SparkRes.getImageIcon(SparkRes.GREEN_BALL);
}
}
if (!exists(nickname)) {
Icon icon;
if (!exists(nickname)) {
addUser(icon, nickname);
} else {
int index = getIndex(nickname);
if (index != -1) {
final JLabel userLabel = new JLabel(nickname, icon,
JLabel.HORIZONTAL);
model.setElementAt(userLabel, index);
}
}
}
/**
* Returns corresponding Icons for each MUC-Role
* icons are: </p>
* Moderator=Yellow</p>
* Participant=Green</p>
* Visitor=Blue</p>
* N/A=Grey</p>
* @param role
* @return {@link Icon}
*/
private Icon getIconForRole(String role)
{
Icon icon =null;
icon = PresenceManager.getIconFromPresence(presence);
if (icon == null) {
icon = SparkRes.getImageIcon(SparkRes.GREEN_BALL);
}
addUser(icon, nickname);
} else {
Icon icon = PresenceManager.getIconFromPresence(presence);
if (icon == null) {
icon = SparkRes.getImageIcon(SparkRes.GREEN_BALL);
}
int index = getIndex(nickname);
if (index != -1) {
final JLabel userLabel = new JLabel(nickname, icon,
JLabel.HORIZONTAL);
model.setElementAt(userLabel, index);
}
if (role.equalsIgnoreCase("participant"))
{
icon = SparkRes.getImageIcon(SparkRes.STAR_GREEN_IMAGE);
}
else if(role.equalsIgnoreCase("moderator"))
{
icon = SparkRes.getImageIcon(SparkRes.STAR_YELLOW_IMAGE);
}
else if(role.equalsIgnoreCase("visitor"))
{
icon = SparkRes.getImageIcon(SparkRes.STAR_BLUE_IMAGE);
}
else
{
icon = SparkRes.getImageIcon(SparkRes.STAR_GREY_IMAGE);
}
return icon;
}
public void userHasLeft(ChatRoom room, String userid) {
@ -716,6 +751,7 @@ public final class GroupChatParticipantList extends JPanel implements
} else {
grantVoice(selectedUser);
}
Collections.sort(users, labelComp);
}
};
@ -757,6 +793,8 @@ public final class GroupChatParticipantList extends JPanel implements
} else {
revokeModerator(selectedUser);
}
Collections.sort(users, labelComp);
}
};
@ -897,15 +935,51 @@ public final class GroupChatParticipantList extends JPanel implements
}
}
/**
* Sorts ContactItems.
*/
final Comparator<JLabel> labelComp = new Comparator<JLabel>() {
public int compare(JLabel item1, JLabel item2) {
return item1.getText().toLowerCase().compareTo(
item2.getText().toLowerCase());
}
};
/**
* Sorts ContactItems.
*/
final Comparator<JLabel> labelComp = new Comparator<JLabel>() {
public int compare(JLabel item1, JLabel item2) {
if (_localPreferences.isShowingRoleIcons()) {
return compareWithRole(item1, item2);
} else {
return compareWithoutRole(item1.getText(), item2.getText());
}
}
private int compareWithoutRole(String s1, String s2) {
return (s1.toLowerCase().compareTo(s2.toLowerCase()) * -1);
}
private int compareWithRole(JLabel item1, JLabel item2) {
char user1 = 'p';
char user2 = 'p';
// append Room-JID to UserLabel
String jid1 = chat.getRoom() + "/" + item1.getText();
String jid2 = chat.getRoom() + "/" + item2.getText();
user1 = chat.getOccupant(jid1).getRole().charAt(0);
user2 = chat.getOccupant(jid2).getRole().charAt(0);
int result = 0;
if (user1 == user2) {
result = compareWithoutRole(item1.getText(), item2.getText());
} else {
// m < p < v
if (user1 < user2)
result = -1;
if (user1 > user2)
result = 1;
}
return result;
}
};
/**
* The <code>JLabelIconRenderer</code> is the an implementation of

View File

@ -73,11 +73,13 @@ public class GroupChatPreference implements Preference {
boolean highlightMyText = localPreferences.isMucHighTextEnabled();
boolean highlightPopName = localPreferences.isMucHighToastEnabled();
boolean showjoinleavemessage = localPreferences.isShowJoinLeaveMessagesEnabled();
boolean showroleicons = localPreferences.isShowingRoleIcons();
panel.setMucHighNameEnabled(highlightMyName);
panel.setMucHighTextEnabled(highlightMyText);
panel.setMuchHighToastEnabled(highlightPopName);
panel.setShowJoinLeaveMessagesEnabled(showjoinleavemessage);
panel.setShowRoleIconInsteadStatusIcon(showroleicons);
}
};
@ -92,6 +94,7 @@ public class GroupChatPreference implements Preference {
pref.setMucHighTextEnabled(panel.isMucHighTextEnabled());
pref.setMuchHighToastEnabled(panel.isMucHighToastEnabled());
pref.setShowJoinLeaveMessagesEnabled(panel.isShowJoinLeaveMessagesEnabled());
pref.setShowRoleIconInsteadStatusIcon(panel.isShowingRoleIcons());
SettingsManager.saveSettings();
}

View File

@ -42,6 +42,7 @@ public class GroupChatPreferencePanel extends JPanel {
private JCheckBox highlightMyText = new JCheckBox();
private JCheckBox highlightPopName = new JCheckBox();
private JCheckBox showjoinleavemessage = new JCheckBox();
private JCheckBox showroleicons = new JCheckBox();
private JPanel gCPanel = new JPanel();
/**
@ -59,7 +60,8 @@ public class GroupChatPreferencePanel extends JPanel {
ResourceUtils.resButton(highlightMyText , Res.getString("menuitem.add.groupchat.mytext"));
ResourceUtils.resButton(highlightPopName , Res.getString("menuitem.add.groupchat.popname"));
ResourceUtils.resButton(showjoinleavemessage , Res.getString("menuitem.add.groupchat.showjoinleavemessage"));
ResourceUtils.resButton(showroleicons , Res.getString("menuitem.add.groupchat.showrolesinsteadofstatus"));
gCPanel.setBorder(BorderFactory.createTitledBorder(Res.getString("title.group.chat.settings")));
add(gCPanel);
@ -70,6 +72,7 @@ public class GroupChatPreferencePanel extends JPanel {
gCPanel.add(highlightMyText , new GridBagConstraints(0, 1, 2, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
gCPanel.add(highlightPopName , new GridBagConstraints(0, 2, 2, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
gCPanel.add(showjoinleavemessage, new GridBagConstraints(0, 3, 2, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
gCPanel.add(showroleicons , new GridBagConstraints(0, 4, 2, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
}
public void setMucHighNameEnabled(boolean mucNHigh) {
@ -88,6 +91,10 @@ public class GroupChatPreferencePanel extends JPanel {
showjoinleavemessage.setSelected(mucPHigh);
}
public void setShowRoleIconInsteadStatusIcon(boolean roleicons){
showroleicons.setSelected(roleicons);
}
public boolean isShowJoinLeaveMessagesEnabled() {
return showjoinleavemessage.isSelected();
}
@ -103,5 +110,10 @@ public class GroupChatPreferencePanel extends JPanel {
public boolean isMucHighToastEnabled() {
return highlightPopName.isSelected();
}
public boolean isShowingRoleIcons() {
return showroleicons.isSelected();
}
}

View File

@ -661,6 +661,10 @@ public class LocalPreferences {
return getBoolean("isMucHighToastOn", false);
}
public boolean isShowingRoleIcons() {
return getBoolean("isShowingRoleIcons",false);
}
public boolean isShowJoinLeaveMessagesEnabled() {
return getBoolean("isShowJoinLeaveMessagesOn", true);
}
@ -680,6 +684,10 @@ public class LocalPreferences {
public void setMuchHighToastEnabled(boolean setMucPHigh) {
setBoolean("isMucHighToastOn", setMucPHigh);
}
public void setShowRoleIconInsteadStatusIcon(boolean roleicons){
setBoolean("isShowingRoleIcons",roleicons);
}
public void setSSOEnabled(boolean enabled) {
setBoolean("ssoEnabled", enabled);

View File

@ -217,6 +217,7 @@
## Added key: 'message.nickname.not.acceptable'
## Added key: 'button.login'
## Added key: 'administrator'
## Added key: 'menuitem.add.groupchat.showrolesinsteadofstatus'
accept = Accept
active = Active
@ -488,6 +489,7 @@ menuitem.add.groupchat.myname = Highlight my &name when someone says it
menuitem.add.groupchat.mytext = &Highlight my text when I say something
menuitem.add.groupchat.popname= Show &toast popup when someone says my name
menuitem.add.groupchat.showjoinleavemessage = &Show join and leave messages
menuitem.add.groupchat.showrolesinsteadofstatus = Show chatroleicons instead of statusicons
menuitem.always.on.top = Always on top
menuitem.alert.when.online = Alert when user is available
menuitem.ban = Ban

View File

@ -115,6 +115,14 @@
## Added key: 'title.group.chat.settings'
## Added key: 'menuitem.view.logs'
## Added key: 'title.appearance.preferences'
## 2.6.0 beta 1
## Added key: 'menuitem.block.contact'
## Added key: 'menuitem.unblock.contact'
## Removed key: 'status.available'
## Added key: 'message.nickname.not.acceptable'
## Added key: 'button.login'
## Added key: 'administrator'
## Added key: 'menuitem.add.groupchat.showrolesinsteadofstatus'
@ -122,6 +130,7 @@
ok = Ok
apply = <EFBFBD>bernehmen
administrator = Administrator
cancel = Abbrechen
add = Hinzuf<EFBFBD>gen
use.default = Voreinstellungen laden
@ -177,6 +186,8 @@ button.update = &Update
button.cancel = &Abbrechen
button.decline = &Ablehnen
button.join = &Beitreten
button.join.room = Ausgew<EFBFBD>hltem Raum beitreten
button.login = &Login
button.save.for.future.use = &Speichern f<>r die sp<73>tere Verwendung
button.register = &Registrierung
button.dial.number = &Nummer w<>hlen
@ -215,6 +226,7 @@ checkbox.start.in.tray = Spark automatisch in der &Taskleiste starten
checkbox.split.chat.window = &Fenster 'andocken' (ben<65>tigt Neustart von Spark)
checkbox.tabs.on.top = &Chat tabs oben anzeigen (ben<65>tigt Neustart von Spark)
checkbox.allow.buzz = "&Buzzer" Funktion aktivieren.
checkbox.tabs.externalize = Neue Chat Tabs <20>ffnen in seperaten Fenstern
checkbox.enable.emoticons = &Emoticons aktivieren
checkbox.use.system.look.and.feel = System Look And &Feel verwenden (ben<65>tigt Neustart von Spark)
checkbox.notify.user.comes.online = &Benachrichtigen, wenn ein User Online kommt
@ -357,6 +369,8 @@ message.close.other.chats = Alle anderen Chats schlie
message.close.stale.chats = Inaktive Chats schlie<69>en
message.last.message.received = Letzte Nachricht empfangen um {0}
message.shared.group = Gemeinsame Gruppen
message.internalize.tab = Chatroom wieder in Tabliste einbinden
message.externalize.tab = Chatroom in externes Fenster auslagern
message.is.shared.group = {0} ist eine gemeinsame Gruppe.
message.delete.confirmation = {0} - Wirklich l<>schen?
message.idle.for = Inaktiv seit {0}
@ -386,6 +400,7 @@ message.you.have.been.kicked = Sie wurden aus dem Raum ausgeladen.
message.kicked.error = Sie haben nicht das Recht {0} aus dem Raum auszuladen.
message.you.have.been.banned = Der Zugriff auf diesem Raum wurde Ihnen entzogen.
message.nickname.in.use = Ausgew<EFBFBD>hlter Name ist bereits in Benutzung. Bitte einen anderen Namen w<>hlen.
message.nickname.not.acceptable = Das <20>ndern von Spitzname ist nicht erlaubt!
message.update.room.list = Aktualisiere Raumliste
message.join.conference.room = Konferenz beitreten
message.select.add.room.to.add = Bitte einen Raum w<>hlen um ihn der Service-Liste hinzuzuf<75>gen.
@ -691,6 +706,8 @@ menuitem.remove = Entfernen
menuitem.change.nickname = Angezeigten Namen <20>ndern
menuitem.block.user = Teilnehmer blockieren
menuitem.unblock.user = Blockierung eines Teilnehmers aufheben
menuitem.block.contact = Kontakt blockieren
menuitem.unblock.contact = Blockierung eines Kontaktes aufheben
menuitem.kick.user = Teilnehmer aus der Konferenz ausschlie<69>en
menuitem.voice = Schreibrecht
menuitem.revoke.voice = Schreibrecht entziehen
@ -729,6 +746,7 @@ menuitem.add.groupchat.myname = Meinen &Namen hervorheben, wenn ihn jemand schr
menuitem.add.groupchat.mytext = Meinen &Text hervorheben, wenn ich etwas schreibe
menuitem.add.groupchat.popname = &Zeige ein Popup, wenn jemand meinen Namen schreibt
menuitem.add.groupchat.showjoinleavemessage = Zeige an wenn jemand den Raum betritt oder verl<72>sst
menuitem.add.groupchat.showrolesinsteadofstatus = Zeige Chatrecht-Icons anstelle von Statusicons
menuitem.show.offline.users = Zeige Offline User
menuitem.expand.all.groups = <EFBFBD>ffne alle Gruppen
menuitem.collapse.all.groups = Schlie<EFBFBD>e alle Gruppen