From e18803d66dde2c26a72c81f68a363cf81d8532fc Mon Sep 17 00:00:00 2001 From: Wolf Posdorfer Date: Wed, 4 May 2011 12:07:29 +0000 Subject: [PATCH] SPARK-1103 - option to register with room SPARK-1306 - fixed rendering issue with the "X"-button reworked user.kicked and user.banned listener changed locale string: message.user.kicked.from.room = {0} has been kicked out of the room by {1}. Reason: {2} -> {0}=username,{1}=adminname,{2}=reason message.user.banned = {0} has been banned from this room. Reason: {1} -> {0}=username,{1}=reason new locale: message.groupchat.registered.member = Successfully registered with {0} ->{0}=roomname git-svn-id: http://svn.igniterealtime.org/svn/repos/spark/trunk@12324 b35dd754-fafc-0310-a699-88a17e54d16e --- .../org/jivesoftware/resource/SparkRes.java | 1 + .../jivesoftware/resource/spark.properties | 1 + .../spark/component/CheckBoxList.java | 3 +- .../component/tabbedPane/SparkTabbedPane.java | 213 +++++++++--------- .../ui/conferences/ConferenceRoomBrowser.java | 5 +- .../spark/ui/rooms/GroupChatRoom.java | 38 +++- src/resources/i18n/spark_i18n.properties | 5 +- src/resources/i18n/spark_i18n_de.properties | 7 +- src/resources/images/people-icon.png | Bin 0 -> 495 bytes 9 files changed, 155 insertions(+), 118 deletions(-) create mode 100644 src/resources/images/people-icon.png diff --git a/src/java/org/jivesoftware/resource/SparkRes.java b/src/java/org/jivesoftware/resource/SparkRes.java index 2065897f..72275478 100644 --- a/src/java/org/jivesoftware/resource/SparkRes.java +++ b/src/java/org/jivesoftware/resource/SparkRes.java @@ -327,6 +327,7 @@ public class SparkRes { public static final String COLOR_ICON = "COLOR_ICON"; public static final String SETTINGS_IMAGE_16x16 = "SETTINGS_IMAGE_16x16"; public static final String SETTINGS_IMAGE_24x24 = "SETTINGS_IMAGE_24x24"; + public static final String PEOPLE_IMAGE = "PEOPLE_IMAGE"; static ClassLoader cl = SparkRes.class.getClassLoader(); diff --git a/src/java/org/jivesoftware/resource/spark.properties b/src/java/org/jivesoftware/resource/spark.properties index fa14184c..f1691358 100644 --- a/src/java/org/jivesoftware/resource/spark.properties +++ b/src/java/org/jivesoftware/resource/spark.properties @@ -229,6 +229,7 @@ PROFILE_ICON = images/profile.png SEND_FILE_ICON = images/document_into.png ADD_CONTACT_IMAGE = images/add_contact.png JOIN_GROUPCHAT_IMAGE = images/join_groupchat.png +PEOPLE_IMAGE = images/people-icon.png DOWN_ARROW_IMAGE = images/down_arrow.gif PRINTER_IMAGE_16x16 = images/printer.png SEND_MAIL_IMAGE_16x16 = images/sendmail.png diff --git a/src/java/org/jivesoftware/spark/component/CheckBoxList.java b/src/java/org/jivesoftware/spark/component/CheckBoxList.java index 1faec722..13d94429 100644 --- a/src/java/org/jivesoftware/spark/component/CheckBoxList.java +++ b/src/java/org/jivesoftware/spark/component/CheckBoxList.java @@ -35,6 +35,7 @@ import javax.swing.JScrollPane; * @author Derek DeMoro */ public class CheckBoxList extends JPanel { + private static final long serialVersionUID = 4145933151755357313L; private Map valueMap = new HashMap(); private JPanel internalPanel = new JPanel(); @@ -63,7 +64,7 @@ public class CheckBoxList extends JPanel { * * @return list of selected checkbox values. */ - public List getSelectedValues() { + public List getSelectedValues() { List list = new ArrayList(); for (JCheckBox checkbox : valueMap.keySet()) { if (checkbox.isSelected()) { diff --git a/src/java/org/jivesoftware/spark/component/tabbedPane/SparkTabbedPane.java b/src/java/org/jivesoftware/spark/component/tabbedPane/SparkTabbedPane.java index 144525e0..dad6f395 100644 --- a/src/java/org/jivesoftware/spark/component/tabbedPane/SparkTabbedPane.java +++ b/src/java/org/jivesoftware/spark/component/tabbedPane/SparkTabbedPane.java @@ -360,119 +360,124 @@ public class SparkTabbedPane extends JPanel { } } - private class TabPanel extends JPanel { - private static final long serialVersionUID = -8249981130816404360L; - private final BorderLayout layout = new BorderLayout(5,5); - private final Font defaultFont = new Font("Dialog", Font.PLAIN, 11); - private JLabel iconLabel; - private JLabel titleLabel; + private class TabPanel extends JPanel { + private static final long serialVersionUID = -8249981130816404360L; + private final BorderLayout layout = new BorderLayout(5, 5); + private final Font defaultFontPlain = new Font("Dialog", Font.PLAIN, 11); + private final Font defaultFontBold = new Font("Dialog", Font.BOLD, 11); + private JLabel iconLabel; + private JLabel titleLabel; + private JLabel tabCloseButton = new JLabel(closeInactiveButtonIcon); - public TabPanel(final SparkTab sparktab, String title, Icon icon) { - setOpaque(false); - this.setLayout(layout); - - titleLabel = new JLabel(title); - titleLabel.setFont(defaultFont); - if (icon != null) - { - iconLabel = new JLabel(icon); - add(iconLabel, BorderLayout.WEST); + public TabPanel(final SparkTab sparktab, String title, Icon icon) { + setOpaque(false); + this.setLayout(layout); + titleLabel = new JLabel(title); + + titleLabel.setFont(closeEnabled ? defaultFontBold + : defaultFontPlain); + if (icon != null) { + iconLabel = new JLabel(icon); + add(iconLabel, BorderLayout.WEST); + } + + add(titleLabel, BorderLayout.CENTER); + if (closeEnabled) { + tabCloseButton.addMouseListener(new MouseAdapter() { + public void mouseEntered(MouseEvent mouseEvent) { + if (Spark.isWindows()) { + tabCloseButton.setIcon(closeActiveButtonIcon); } - - add(titleLabel, BorderLayout.CENTER); - if (closeEnabled) { - final JLabel tabCloseButton = new JLabel( - closeInactiveButtonIcon); - tabCloseButton.addMouseListener(new MouseAdapter() { - public void mouseEntered(MouseEvent mouseEvent) { - if (Spark.isWindows()) { - tabCloseButton.setIcon(closeActiveButtonIcon); - } - setCursor(HAND_CURSOR); - } + setCursor(HAND_CURSOR); + } - public void mouseExited(MouseEvent mouseEvent) { - if (Spark.isWindows()) { - tabCloseButton.setIcon(closeInactiveButtonIcon); - } - setCursor(DEFAULT_CURSOR); - } - - public void mousePressed(MouseEvent mouseEvent) { - final SwingWorker closeTimerThread = new SwingWorker() { - public Object construct() { - try { - Thread.sleep(100); - } catch (InterruptedException e) { - Log.error(e); - } - return true; - } - - public void finished() { - close(sparktab); - } - }; - closeTimerThread.start(); - } - }); - add(tabCloseButton, BorderLayout.EAST); - } - } - - @Override - public Dimension getPreferredSize() { - Dimension dim = super.getPreferredSize(); - if (closeEnabled && titleLabel.getText().length() < 6) { - return new Dimension(80, dim.height); - - } else - return super.getPreferredSize(); - - } - - public Font getDefaultFont() { - return defaultFont; - } - - public void setIcon(Icon icon) { - iconLabel.setIcon(icon); - } - - public void setTitle(String title) { - titleLabel.setText(title); - } - - public void setTitleColor(Color color) { - titleLabel.setForeground(color); - titleLabel.validate(); - titleLabel.repaint(); - } - - public void setTitleBold(boolean bold) { - Font oldFont = titleLabel.getFont(); - Font newFont; - if (bold) { - newFont = new Font(oldFont.getFontName(), Font.BOLD, oldFont - .getSize()); - } else { - newFont = new Font(oldFont.getFontName(), Font.PLAIN, oldFont - .getSize()); + public void mouseExited(MouseEvent mouseEvent) { + if (Spark.isWindows()) { + tabCloseButton.setIcon(closeInactiveButtonIcon); } + setCursor(DEFAULT_CURSOR); + } - titleLabel.setFont(newFont); - titleLabel.validate(); - titleLabel.repaint(); - } + public void mousePressed(MouseEvent mouseEvent) { + final SwingWorker closeTimerThread = new SwingWorker() { + public Object construct() { + try { + Thread.sleep(100); + } catch (InterruptedException e) { + Log.error(e); + } + return true; + } - public void setTitleFont(Font font) { - titleLabel.setFont(font); - titleLabel.validate(); - titleLabel.repaint(); - } + public void finished() { + close(sparktab); + } + }; + closeTimerThread.start(); + } + }); + add(tabCloseButton, BorderLayout.EAST); + } + } + + @Override + public Dimension getPreferredSize() { + Dimension dim = super.getPreferredSize(); + + if (closeEnabled && titleLabel.getText().length() < 6 + && dim.getWidth() < 80) { + return new Dimension(80, dim.height); + + } else { + return dim; + } } + public Font getDefaultFont() { + return defaultFontPlain; + } + + public void setIcon(Icon icon) { + iconLabel.setIcon(icon); + } + + public void setTitle(String title) { + titleLabel.setText(title); + } + + public void setTitleColor(Color color) { + titleLabel.setForeground(color); + titleLabel.validate(); + titleLabel.repaint(); + } + + public void setTitleBold(boolean bold) { + Font oldFont = titleLabel.getFont(); + Font newFont; + if (bold) { + newFont = new Font(oldFont.getFontName(), Font.BOLD, + oldFont.getSize()); + } else { + newFont = new Font(oldFont.getFontName(), Font.PLAIN, + oldFont.getSize()); + } + + titleLabel.setFont(newFont); + titleLabel.validate(); + titleLabel.repaint(); + titleLabel.revalidate(); + } + + public void setTitleFont(Font font) { + titleLabel.setFont(font); + titleLabel.validate(); + titleLabel.repaint(); + titleLabel.revalidate(); + } + + } + /** * Drag and Drop */ diff --git a/src/java/org/jivesoftware/spark/ui/conferences/ConferenceRoomBrowser.java b/src/java/org/jivesoftware/spark/ui/conferences/ConferenceRoomBrowser.java index 8536025e..a0ce6af1 100644 --- a/src/java/org/jivesoftware/spark/ui/conferences/ConferenceRoomBrowser.java +++ b/src/java/org/jivesoftware/spark/ui/conferences/ConferenceRoomBrowser.java @@ -853,7 +853,7 @@ public class ConferenceRoomBrowser extends JPanel implements ActionListener, } /** - * Returns true if the room is password protected + * Returns true if the room is password protected or Members only * * @param roomjid * @return @@ -862,7 +862,8 @@ public class ConferenceRoomBrowser extends JPanel implements ActionListener, boolean result = false; try { - RoomInfo rif = MultiUserChat.getRoomInfo(SparkManager.getConnection(), roomjid); + RoomInfo rif = MultiUserChat.getRoomInfo( + SparkManager.getConnection(), roomjid); result = rif.isMembersOnly() || rif.isPasswordProtected(); diff --git a/src/java/org/jivesoftware/spark/ui/rooms/GroupChatRoom.java b/src/java/org/jivesoftware/spark/ui/rooms/GroupChatRoom.java index 0d9d7298..cd444860 100644 --- a/src/java/org/jivesoftware/spark/ui/rooms/GroupChatRoom.java +++ b/src/java/org/jivesoftware/spark/ui/rooms/GroupChatRoom.java @@ -76,6 +76,7 @@ import org.jivesoftware.spark.ui.ChatFrame; import org.jivesoftware.spark.ui.ChatRoom; import org.jivesoftware.spark.ui.ChatRoomNotFoundException; import org.jivesoftware.spark.ui.GroupChatRoomTransferHandler; +import org.jivesoftware.spark.ui.conferences.AnswerFormDialog; import org.jivesoftware.spark.ui.conferences.ConferenceUtils; import org.jivesoftware.spark.ui.conferences.DataFormDialog; import org.jivesoftware.spark.ui.conferences.GroupChatParticipantList; @@ -822,10 +823,11 @@ public final class GroupChatRoom extends ChatRoom { */ private void setupListeners() { chat.addParticipantStatusListener(new DefaultParticipantStatusListener() { - public void kicked(String participant) { + + public void kicked(String participant, String actor, String reason) { String nickname = StringUtils.parseResource(participant); insertText(Res.getString("message.user.kicked.from.room", - nickname)); + nickname,actor,reason)); } public void voiceGranted(String participant) { @@ -839,9 +841,9 @@ public final class GroupChatRoom extends ChatRoom { .getString("message.user.voice.revoked", nickname)); } - public void banned(String participant) { + public void banned(String participant, String actor, String reason) { String nickname = StringUtils.parseResource(participant); - insertText(Res.getString("message.user.banned", nickname)); + insertText(Res.getString("message.user.banned", nickname, reason)); } public void membershipGranted(String participant) { @@ -1351,14 +1353,20 @@ public final class GroupChatRoom extends ChatRoom { RolloverButton settings = new RolloverButton( SparkRes.getImageIcon(SparkRes.SETTINGS_IMAGE_16x16)); settings.setToolTipText(Res.getString("title.configure.room")); + RolloverButton thema = new RolloverButton( SparkRes.getImageIcon(SparkRes.TYPING_TRAY)); thema.setToolTipText(Res.getString("menuitem.change.subject")); + + RolloverButton register = new RolloverButton( + SparkRes.getImageIcon(SparkRes.PEOPLE_IMAGE)); + register.setToolTipText(Res.getString("button.register").replace("&","")); JPanel bar = room.getRoomControllerBar(); - bar.add(thema); - bar.add(settings); + bar.add(settings,0); + bar.add(thema,0); + bar.add(register,0); settings.addActionListener(new AbstractAction() { private static final long serialVersionUID = 6780230647854132857L; @@ -1399,6 +1407,24 @@ public final class GroupChatRoom extends ChatRoom { } } }); + + register.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + try { + Form form = chat.getRegistrationForm(); + ChatFrame chatFrame = SparkManager.getChatManager() + .getChatContainer().getChatFrame(); + + new AnswerFormDialog(chatFrame, chat, form); + + } catch (XMPPException xmpe) { + getTranscriptWindow().insertNotificationMessage( + xmpe.getMessage(), ChatManager.ERROR_COLOR); + scrollToBottom(); + } + } + }); } diff --git a/src/resources/i18n/spark_i18n.properties b/src/resources/i18n/spark_i18n.properties index 9d9c802a..76a085da 100644 --- a/src/resources/i18n/spark_i18n.properties +++ b/src/resources/i18n/spark_i18n.properties @@ -785,7 +785,7 @@ message.unable.to.send.file = You were unable to send the file to {0} message.unrecoverable.error = Invalid username or password message.update.room.list = Update room list message.updating.cancelled = Updating has been canceled -message.user.banned = {0} has been banned from this room +message.user.banned = {0} has been banned from this room. Reason: {1} message.user.given.voice = {0} has been given a voice in this room message.user.granted.admin = {0} has been granted administrator privileges message.user.granted.membership = {0} has been given membership privileges @@ -793,7 +793,7 @@ message.user.granted.moderator = {0} has been granted moderator privileges message.user.granted.owner = {0} has been granted owner privileges message.user.is.sending.you.a.file = {0} is sending you a file message.user.joined.room = {0} has joined the room -message.user.kicked.from.room = {0} has been kicked out of the room +message.user.kicked.from.room = {0} has been kicked out of the room by {1}. Reason: {2} message.user.left.room = {0} has left the room message.user.nickname.changed = {0} is now known as {1} message.user.now.available.to.chat = {0} is online at {1} @@ -825,6 +825,7 @@ message.your.revoked.granted = Your admin privileges have been revoked message.your.voice.granted = You have been given a voice in this chat message.your.voice.revoked = Your voice has been revoked message.groupchat.require.password = This group chat room requires a password to enter +message.groupchat.registered.member = Successfully registered with {0} message.search.for.history = Search conversation history status.away = Away diff --git a/src/resources/i18n/spark_i18n_de.properties b/src/resources/i18n/spark_i18n_de.properties index 2e3755b2..a0fd1abe 100644 --- a/src/resources/i18n/spark_i18n_de.properties +++ b/src/resources/i18n/spark_i18n_de.properties @@ -425,10 +425,10 @@ message.subject.change.error = Sie haben keine Rechte das Konferenzthema in dies message.forbidden.error = Sie haben nicht die Rechte für diese Aktion. message.room.destroyed = Dieser Raum wurde aus dem folgenden Grund gelöscht: {0} message.subject.has.been.changed.to = Das Thema der Konferenz wurde von {1} in "{0}" geändert. -message.user.kicked.from.room = {0} wurde aus dem Raum ausgeladen. +message.user.kicked.from.room = {0} wurde von {1} aus dem Raum geworfen. Grund: {2} message.user.given.voice = {0} hat jetzt Schreibenrechte. message.user.voice.revoked = Schreibrechte wurde {0} entzogen. -message.user.banned = {0} ist für diesen Raum gesperrt. +message.user.banned = {0} wurde für diesen Raum gesperrt. Grund: {2} message.user.granted.membership = {0} ist jetzt Mitglied. message.user.revoked.membership = Mitgliedschaft für {0} wurde widerufen. message.user.granted.moderator = {0} ist jetzt Moderator. @@ -682,7 +682,7 @@ menuitem.send.a.message = Nachricht senden... menuitem.show.empty.groups = Leere Gruppen anzeigen menuitem.send.a.file = Datei senden menuitem.view.last.activity = Letzte Aktivität sehen -menuitem.unban = Verbannung rückgängig machen +menuitem.unban = Teilnehmer entsperren menuitem.ban = Verbannen menuitem.browse.service = Services anzeigen menuitem.remove.service = Service entfernen @@ -862,6 +862,7 @@ message.unrecoverable.error = Ung message.waiting.for.user.to.join = Warte auf {0} zum Beitritt message.your.voice.granted = Du hast Schreibrechte in diesem Chat bekommen message.groupchat.require.password = Dieser GruppenChat benötigt ein Passwort +message.groupchat.registered.member = Registrierung mit {0} erfolgreich message.search.for.history = Durchsuche Gesprächsverlauf status.extended.away = Nicht verfügbar status.free.to.chat = Bereit zu chatten diff --git a/src/resources/images/people-icon.png b/src/resources/images/people-icon.png new file mode 100644 index 0000000000000000000000000000000000000000..d609d60f11256186ffd5c95dd51f95785b77b845 GIT binary patch literal 495 zcmVPx#1ZP1_K>z@;j|==^1poj5AY({UO#lFTCIA3{ga82g0001h=l}q9FaQARU;qF* zm;eA5aGbhPJOBUy8FWQhbW?9;ba!ELWdKlNX>N2bPDNB8b~7$DE;u(kfL#Cp0Z2(i zK~y+TjZ(3Z0x=BK7eGMj@Pco^4X6Q!A6x@&fCf|m4O|@*;DGe%pbfoNXM+vTJ)YSy zC#2PSC8Ea>$w_mHY9Z<3AN}OAoK)AvaZ2AH;jWV7bSxsfg8A~Yt@gUj$hQjM zd^2*J!dJfvQp)y>QmS#i2QV^~%|Kuycsba8tgakp8(mL;Y2;cA0*rO<1Y769L=aT+ ldJppd;u4>I1JU(e!(Vx;S$$`1aMAz(002ovPDHLkV1hP6!g>Gz literal 0 HcmV?d00001