mirror of
https://github.com/igniterealtime/Spark.git
synced 2025-12-01 12:27:58 +00:00
SPARK-1285
Server Messages display rework if you like the "old ways" go to default.properties and put BROADCAST_IN_CHATWINDOW = true git-svn-id: http://svn.igniterealtime.org/svn/repos/spark/trunk@12255 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
committed by
wolf.posdorfer
parent
3acb6feba4
commit
c39a4e7f46
@ -66,6 +66,7 @@ public class Default {
|
|||||||
public static final String DEINSTALL_PLUGINS_DISABLED = "DEINSTALL_PLUGINS_DISABLED";
|
public static final String DEINSTALL_PLUGINS_DISABLED = "DEINSTALL_PLUGINS_DISABLED";
|
||||||
public static final String ADVANCED_DISABLED = "ADVANCED_DISABLED";
|
public static final String ADVANCED_DISABLED = "ADVANCED_DISABLED";
|
||||||
public static final String HELP_USER_GUIDE = "HELP_USER_GUIDE";
|
public static final String HELP_USER_GUIDE = "HELP_USER_GUIDE";
|
||||||
|
public static final String BROADCAST_IN_CHATWINDOW = "BROADCAST_IN_CHATWINDOW";
|
||||||
|
|
||||||
static ClassLoader cl = SparkRes.class.getClassLoader();
|
static ClassLoader cl = SparkRes.class.getClassLoader();
|
||||||
|
|
||||||
|
|||||||
@ -36,6 +36,7 @@ import java.util.ResourceBundle;
|
|||||||
public class SparkRes {
|
public class SparkRes {
|
||||||
private static PropertyResourceBundle prb;
|
private static PropertyResourceBundle prb;
|
||||||
|
|
||||||
|
public static final String ALERT = "ALERT";
|
||||||
public static final String NOTE_EDIT_16x16 = "NOTE_EDIT_16x16";
|
public static final String NOTE_EDIT_16x16 = "NOTE_EDIT_16x16";
|
||||||
public static final String MAGICIAN_IMAGE = "MAGICIAN_IMAGE";
|
public static final String MAGICIAN_IMAGE = "MAGICIAN_IMAGE";
|
||||||
public static final String IM_AWAY = "IM_AWAY";
|
public static final String IM_AWAY = "IM_AWAY";
|
||||||
|
|||||||
@ -106,10 +106,14 @@ DEINSTALL_PLUGINS_DISABLED =
|
|||||||
######### Color + LookandFeel ###########
|
######### Color + LookandFeel ###########
|
||||||
#################################################
|
#################################################
|
||||||
|
|
||||||
|
# by Default Server-Broadcast get their own JFrame containing the Message
|
||||||
|
# also HTML tags like <b> <i> <u> can be used
|
||||||
|
# if you want server broadcasts handled like every other message including transcripts
|
||||||
|
# set this to true
|
||||||
|
BROADCAST_IN_CHATWINDOW = false
|
||||||
# Disable Look&Feel change || "true" = disabled , anything else = enabled
|
# Disable Look&Feel change || "true" = disabled , anything else = enabled
|
||||||
# By Default the user can Change his Look&Feel in the Preferences Menu,
|
# By Default the user can Change his Look&Feel in the Preferences Menu,
|
||||||
#if you dont want this then set it to true
|
# if you dont want this then set it to true
|
||||||
# Preferences -> Appearence -> Customization Tab
|
# Preferences -> Appearence -> Customization Tab
|
||||||
LOOK_AND_FEEL_DISABLED =
|
LOOK_AND_FEEL_DISABLED =
|
||||||
# Disable if you dont want Users to be able to Change the Textcolors in the Preference Menu
|
# Disable if you dont want Users to be able to Change the Textcolors in the Preference Menu
|
||||||
|
|||||||
@ -158,6 +158,7 @@ SERVER_UNAVAILABLE = Can't connect to server: invalid name or server not reachab
|
|||||||
UNRECOVERABLE_ERROR = Invalid username or password.
|
UNRECOVERABLE_ERROR = Invalid username or password.
|
||||||
|
|
||||||
#Chat Window Images
|
#Chat Window Images
|
||||||
|
ALERT = images/alert.png
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -19,6 +19,36 @@
|
|||||||
*/
|
*/
|
||||||
package org.jivesoftware.sparkimpl.plugin.alerts;
|
package org.jivesoftware.sparkimpl.plugin.alerts;
|
||||||
|
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Component;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.GridBagConstraints;
|
||||||
|
import java.awt.GridBagLayout;
|
||||||
|
import java.awt.Insets;
|
||||||
|
import java.awt.Toolkit;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.swing.AbstractAction;
|
||||||
|
import javax.swing.Action;
|
||||||
|
import javax.swing.BorderFactory;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JMenu;
|
||||||
|
import javax.swing.JMenuItem;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JPopupMenu;
|
||||||
|
import javax.swing.SwingUtilities;
|
||||||
|
|
||||||
|
import org.jivesoftware.resource.Default;
|
||||||
import org.jivesoftware.resource.Res;
|
import org.jivesoftware.resource.Res;
|
||||||
import org.jivesoftware.resource.SparkRes;
|
import org.jivesoftware.resource.SparkRes;
|
||||||
import org.jivesoftware.smack.PacketListener;
|
import org.jivesoftware.smack.PacketListener;
|
||||||
@ -51,27 +81,6 @@ import org.jivesoftware.spark.util.ResourceUtils;
|
|||||||
import org.jivesoftware.spark.util.log.Log;
|
import org.jivesoftware.spark.util.log.Log;
|
||||||
import org.jivesoftware.sparkimpl.plugin.manager.Enterprise;
|
import org.jivesoftware.sparkimpl.plugin.manager.Enterprise;
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Component;
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import java.awt.event.MouseEvent;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import javax.swing.AbstractAction;
|
|
||||||
import javax.swing.Action;
|
|
||||||
import javax.swing.BorderFactory;
|
|
||||||
import javax.swing.JMenu;
|
|
||||||
import javax.swing.JMenuItem;
|
|
||||||
import javax.swing.JOptionPane;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.JPopupMenu;
|
|
||||||
import javax.swing.SwingUtilities;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles broadcasts from server and allows for roster wide broadcasts.
|
* Handles broadcasts from server and allows for roster wide broadcasts.
|
||||||
*/
|
*/
|
||||||
@ -109,9 +118,9 @@ public class BroadcastPlugin extends SparkTabHandler implements Plugin, PacketLi
|
|||||||
startConversationtMenu.addActionListener(new ActionListener() {
|
startConversationtMenu.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
ContactList contactList = SparkManager.getWorkspace().getContactList();
|
ContactList contactList = SparkManager.getWorkspace().getContactList();
|
||||||
Collection selectedUsers = contactList.getSelectedUsers();
|
Collection<ContactItem> selectedUsers = contactList.getSelectedUsers();
|
||||||
String selectedUser = "";
|
String selectedUser = "";
|
||||||
Iterator selectedUsersIterator = selectedUsers.iterator();
|
Iterator<ContactItem> selectedUsersIterator = selectedUsers.iterator();
|
||||||
if (selectedUsersIterator.hasNext()) {
|
if (selectedUsersIterator.hasNext()) {
|
||||||
ContactItem contactItem = (ContactItem)selectedUsersIterator.next();
|
ContactItem contactItem = (ContactItem)selectedUsersIterator.next();
|
||||||
selectedUser = contactItem.getJID();
|
selectedUser = contactItem.getJID();
|
||||||
@ -140,7 +149,9 @@ public class BroadcastPlugin extends SparkTabHandler implements Plugin, PacketLi
|
|||||||
if (component instanceof ContactGroup) {
|
if (component instanceof ContactGroup) {
|
||||||
final ContactGroup group = (ContactGroup)component;
|
final ContactGroup group = (ContactGroup)component;
|
||||||
Action broadcastMessageAction = new AbstractAction() {
|
Action broadcastMessageAction = new AbstractAction() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
private static final long serialVersionUID = -6411248110270296726L;
|
||||||
|
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
broadcastToGroup(group);
|
broadcastToGroup(group);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -267,25 +278,14 @@ public class BroadcastPlugin extends SparkTabHandler implements Plugin, PacketLi
|
|||||||
toaster.setBorder(BorderFactory.createBevelBorder(0));
|
toaster.setBorder(BorderFactory.createBevelBorder(0));
|
||||||
|
|
||||||
|
|
||||||
if (!from.contains("@")) {
|
if (!from.contains("@")) {
|
||||||
ChatManager chatManager = SparkManager.getChatManager();
|
if (Default.getBoolean(Default.BROADCAST_IN_CHATWINDOW)) {
|
||||||
ChatContainer container = chatManager.getChatContainer();
|
broadcastInChat(message);
|
||||||
|
} else {
|
||||||
|
broadcastWithPanel(message);
|
||||||
|
}
|
||||||
|
|
||||||
ChatRoomImpl chatRoom;
|
}
|
||||||
try {
|
|
||||||
chatRoom = (ChatRoomImpl)container.getChatRoom(from);
|
|
||||||
}
|
|
||||||
catch (ChatRoomNotFoundException e) {
|
|
||||||
chatRoom = new ChatRoomImpl("serveralert@" + from, Res.getString("broadcast"), Res.getString("administrator"));
|
|
||||||
chatRoom.getBottomPanel().setVisible(false);
|
|
||||||
chatRoom.getToolBar().setVisible(false);
|
|
||||||
SparkManager.getChatManager().getChatContainer().addChatRoom(chatRoom);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
chatRoom.insertMessage(message);
|
|
||||||
broadcastRooms.add(chatRoom);
|
|
||||||
}
|
|
||||||
else if (message.getFrom() != null) {
|
else if (message.getFrom() != null) {
|
||||||
String jid = StringUtils.parseBareAddress(from);
|
String jid = StringUtils.parseBareAddress(from);
|
||||||
String nickname = SparkManager.getUserManager().getUserNicknameFromJID(jid);
|
String nickname = SparkManager.getUserManager().getUserNicknameFromJID(jid);
|
||||||
@ -380,4 +380,81 @@ public class BroadcastPlugin extends SparkTabHandler implements Plugin, PacketLi
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Displays the Serverbroadcast like all other messages
|
||||||
|
* in its on chatcontainer with transcript history
|
||||||
|
* @param message
|
||||||
|
* @param from
|
||||||
|
*/
|
||||||
|
private void broadcastInChat(Message message)
|
||||||
|
{
|
||||||
|
String from = message.getFrom() != null ? message.getFrom() : "";
|
||||||
|
ChatManager chatManager = SparkManager.getChatManager();
|
||||||
|
ChatContainer container = chatManager.getChatContainer();
|
||||||
|
|
||||||
|
ChatRoomImpl chatRoom;
|
||||||
|
try {
|
||||||
|
chatRoom = (ChatRoomImpl)container.getChatRoom(from);
|
||||||
|
}
|
||||||
|
catch (ChatRoomNotFoundException e) {
|
||||||
|
chatRoom = new ChatRoomImpl("serveralert@" + from, Res.getString("broadcast"), Res.getString("administrator"));
|
||||||
|
chatRoom.getBottomPanel().setVisible(false);
|
||||||
|
chatRoom.getToolBar().setVisible(false);
|
||||||
|
SparkManager.getChatManager().getChatContainer().addChatRoom(chatRoom);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
chatRoom.insertMessage(message);
|
||||||
|
broadcastRooms.add(chatRoom);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Displays a Serverbroadcast within a JFrame<br>
|
||||||
|
* Messages can contain html-tags
|
||||||
|
* @param message
|
||||||
|
*/
|
||||||
|
private void broadcastWithPanel(Message message) {
|
||||||
|
|
||||||
|
String title = Res.getString("message.broadcast.from",
|
||||||
|
Res.getString("administrator"));
|
||||||
|
final JFrame alert = new JFrame(title);
|
||||||
|
|
||||||
|
alert.setLayout(new GridBagLayout());
|
||||||
|
alert.setIconImage(SparkRes.getImageIcon(SparkRes.MAIN_IMAGE)
|
||||||
|
.getImage());
|
||||||
|
String msg = "<html><body>" + message.getBody().replace("\n", "<br>")
|
||||||
|
+ "</body></html>";
|
||||||
|
|
||||||
|
JLabel icon = new JLabel(SparkRes.getImageIcon(SparkRes.ALERT));
|
||||||
|
JLabel alertlabel = new JLabel(msg);
|
||||||
|
|
||||||
|
JButton close = new JButton(Res.getString("close"));
|
||||||
|
|
||||||
|
close.addActionListener(new AbstractAction() {
|
||||||
|
private static final long serialVersionUID = -3822361866008590946L;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
alert.setVisible(false);
|
||||||
|
alert.dispose();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
alert.add(icon,new GridBagConstraints(0,0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5,5,5,5), 0, 0));
|
||||||
|
alert.add(alertlabel, new GridBagConstraints(1,0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5,5,5,5), 0, 0));
|
||||||
|
alert.add(close, new GridBagConstraints(1,1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5,5,5,5), 0, 0));
|
||||||
|
|
||||||
|
alert.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||||
|
alert.setVisible(true);
|
||||||
|
|
||||||
|
alert.setMinimumSize(new Dimension(340, 200));
|
||||||
|
alert.pack();
|
||||||
|
Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
|
||||||
|
int x = (dim.width - alert.getSize().width) / 2;
|
||||||
|
int y = (dim.height - alert.getSize().height) / 2;
|
||||||
|
alert.setLocation(x, y);
|
||||||
|
alert.toFront();
|
||||||
|
alert.requestFocus();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
src/resources/images/alert.png
Normal file
BIN
src/resources/images/alert.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.3 KiB |
Reference in New Issue
Block a user