mirror of
https://github.com/igniterealtime/Spark.git
synced 2025-12-01 12:27:58 +00:00
Migrating from 2.0 branch.
git-svn-id: http://svn.igniterealtime.org/svn/repos/spark/trunk@6311 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
@ -119,9 +119,9 @@ public final class Spark {
|
||||
|
||||
JFrame.setDefaultLookAndFeelDecorated(true);
|
||||
File skinDir = new File(Spark.getBinDirectory().getParent(), "xtra/skins").getAbsoluteFile();
|
||||
File defaultSkin = new File(skinDir, "crystal.zip");
|
||||
Skin theSkinToUse = SkinLookAndFeel.loadThemePack(defaultSkin.toURL());
|
||||
//Skin theSkinToUse = SkinLookAndFeel.loadThemePackDefinition(new File("c:\\craploa\\crystal\\skinlf-themepack.xml").toURL());
|
||||
File defaultSkin = new File(skinDir, "crystal2themepack.zip");
|
||||
//Skin theSkinToUse = SkinLookAndFeel.loadThemePack(defaultSkin.toURL());
|
||||
Skin theSkinToUse = SkinLookAndFeel.loadThemePackDefinition(new File("c:\\crapola\\crystal\\skinlf-themepack.xml").toURL());
|
||||
SkinLookAndFeel.setSkin(theSkinToUse);
|
||||
|
||||
// finally set the Skin Look And Feel
|
||||
@ -324,7 +324,7 @@ public final class Spark {
|
||||
}
|
||||
|
||||
public static void installBaseUIProperties() {
|
||||
UIManager.put("TextField.lightforeground", Color.BLACK);
|
||||
UIManager.put("TextField.lightforeground", Color.lightGray);
|
||||
UIManager.put("TextField.foreground", Color.BLACK);
|
||||
UIManager.put("TextField.caretForeground", Color.black);
|
||||
|
||||
|
||||
@ -38,9 +38,6 @@ import org.jivesoftware.spark.util.log.Log;
|
||||
import org.jivesoftware.sparkimpl.settings.local.LocalPreferences;
|
||||
import org.jivesoftware.sparkimpl.settings.local.SettingsManager;
|
||||
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
@ -48,6 +45,9 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
/**
|
||||
* Handles the Chat Management of each individual <code>Workspace</code>. The ChatManager is responsible
|
||||
* for creation and removal of chat rooms, transcripts, and transfers and room invitations.
|
||||
@ -350,7 +350,7 @@ public class ChatManager implements MessageEventNotificationListener {
|
||||
invitationListeners.remove(listener);
|
||||
}
|
||||
|
||||
public Collection<RoomInvitationListener> getInvitationListeners() {
|
||||
public Collection getInvitationListeners() {
|
||||
return invitationListeners;
|
||||
}
|
||||
|
||||
@ -439,14 +439,18 @@ public class ChatManager implements MessageEventNotificationListener {
|
||||
try {
|
||||
chatRoom = getChatContainer().getChatRoom(StringUtils.parseBareAddress(from));
|
||||
if (chatRoom != null && chatRoom instanceof ChatRoomImpl) {
|
||||
final ChatRoomImpl roomImpl = (ChatRoomImpl)chatRoom;
|
||||
|
||||
// Get Tab
|
||||
int index = getChatContainer().indexOfComponent(chatRoom);
|
||||
SparkTab tab = getChatContainer().getTabAt(index);
|
||||
tab.setIcon(SparkRes.getImageIcon(SparkRes.SMALL_MESSAGE_EDIT_IMAGE));
|
||||
|
||||
if (getChatContainer().getActiveChatRoom() == chatRoom) {
|
||||
if (getChatContainer().getActiveChatRoom() == chatRoom && !getChatContainer().getChatFrame().isInFocus()) {
|
||||
getChatContainer().getChatFrame().setIconImage(SparkRes.getImageIcon(SparkRes.SMALL_MESSAGE_EDIT_IMAGE).getImage());
|
||||
}
|
||||
|
||||
roomImpl.setAlternativeIcon(SparkRes.getImageIcon(SparkRes.SMALL_MESSAGE_EDIT_IMAGE));
|
||||
}
|
||||
}
|
||||
catch (ChatRoomNotFoundException e) {
|
||||
@ -458,6 +462,7 @@ public class ChatManager implements MessageEventNotificationListener {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void offlineNotification(String from, String packetID) {
|
||||
}
|
||||
|
||||
@ -470,13 +475,16 @@ public class ChatManager implements MessageEventNotificationListener {
|
||||
try {
|
||||
chatRoom = getChatContainer().getChatRoom(StringUtils.parseBareAddress(from));
|
||||
if (chatRoom != null && chatRoom instanceof ChatRoomImpl) {
|
||||
final ChatRoomImpl roomImpl = (ChatRoomImpl)chatRoom;
|
||||
roomImpl.setAlternativeIcon(null);
|
||||
|
||||
// Get Tab
|
||||
int index = getChatContainer().indexOfComponent(chatRoom);
|
||||
SparkTab tab = getChatContainer().getTabAt(index);
|
||||
tab.setIcon(tab.getPreviousIcon());
|
||||
}
|
||||
|
||||
getChatContainer().getChatFrame().setIconImage(SparkRes.getImageIcon(SparkRes.SMALL_MESSAGE_IMAGE).getImage());
|
||||
getChatContainer().getChatFrame().setIconImage(SparkManager.getMainWindow().getIconImage());
|
||||
}
|
||||
catch (ChatRoomNotFoundException e) {
|
||||
}
|
||||
@ -487,6 +495,7 @@ public class ChatManager implements MessageEventNotificationListener {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Internal implementation of the MessageEventRequestListener.
|
||||
*/
|
||||
|
||||
@ -91,7 +91,7 @@ public final class Notifications implements ActionListener, MainWindowListener {
|
||||
unavaliableIcon = SparkRes.getImageIcon(SparkRes.MESSAGE_AWAY);
|
||||
busyIcon = SparkRes.getImageIcon(SparkRes.MESSAGE_DND);
|
||||
trayIcon = new TrayIcon(availableIcon);
|
||||
trayIcon.setToolTip("Spark"); // NORES
|
||||
trayIcon.setToolTip("Spark Client"); // NORES
|
||||
|
||||
JPopupMenu popupMenu = new JPopupMenu(Res.getString("title.tray.information"));
|
||||
|
||||
@ -161,6 +161,12 @@ public final class Notifications implements ActionListener, MainWindowListener {
|
||||
else {
|
||||
trayIcon.setIcon(busyIcon);
|
||||
}
|
||||
|
||||
// Get Status Text
|
||||
if (presence != null) {
|
||||
String status = presence.getStatus();
|
||||
trayIcon.setToolTip("Spark Client\n" + status);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -233,7 +239,13 @@ public final class Notifications implements ActionListener, MainWindowListener {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Object o = e.getSource();
|
||||
if (!(o instanceof JMenuItem)) {
|
||||
if (SparkManager.getMainWindow().isVisible()) {
|
||||
SparkManager.getMainWindow().setVisible(false);
|
||||
hideMenu.setEnabled(false);
|
||||
}
|
||||
else {
|
||||
showMainWindow();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@ -284,6 +296,8 @@ public final class Notifications implements ActionListener, MainWindowListener {
|
||||
notificationDialog.setVisible(false);
|
||||
|
||||
hideMenu.setEnabled(true);
|
||||
|
||||
SparkManager.getMainWindow().toFront();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -12,13 +12,11 @@ package org.jivesoftware.spark.ui.rooms;
|
||||
|
||||
import org.jivesoftware.resource.Res;
|
||||
import org.jivesoftware.resource.SparkRes;
|
||||
import org.jivesoftware.smack.PacketListener;
|
||||
import org.jivesoftware.smack.Roster;
|
||||
import org.jivesoftware.smack.RosterEntry;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.filter.AndFilter;
|
||||
import org.jivesoftware.smack.filter.FromContainsFilter;
|
||||
import org.jivesoftware.smack.filter.PacketFilter;
|
||||
import org.jivesoftware.smack.filter.PacketTypeFilter;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.packet.Packet;
|
||||
@ -34,18 +32,15 @@ import org.jivesoftware.spark.ui.ContactItem;
|
||||
import org.jivesoftware.spark.ui.ContactList;
|
||||
import org.jivesoftware.spark.ui.MessageEventListener;
|
||||
import org.jivesoftware.spark.ui.RosterDialog;
|
||||
import org.jivesoftware.spark.ui.VCardPanel;
|
||||
import org.jivesoftware.spark.util.ModelUtil;
|
||||
import org.jivesoftware.spark.util.log.Log;
|
||||
import org.jivesoftware.sparkimpl.profile.VCardManager;
|
||||
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.Timer;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.Insets;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.net.URL;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@ -53,6 +48,11 @@ import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.Timer;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
|
||||
/**
|
||||
* This is the Person to Person implementation of <code>ChatRoom</code>
|
||||
* This room only allows for 1 to 1 conversations.
|
||||
@ -86,6 +86,8 @@ public class ChatRoomImpl extends ChatRoom {
|
||||
|
||||
private boolean iconHandler;
|
||||
|
||||
private Icon alternativeIcon;
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a 1-to-1 ChatRoom.
|
||||
@ -98,15 +100,13 @@ public class ChatRoomImpl extends ChatRoom {
|
||||
this.participantJID = participantJID;
|
||||
this.participantNickname = participantNickname;
|
||||
|
||||
AndFilter presenceFilter = new AndFilter(new PacketTypeFilter(Presence.class), new FromContainsFilter(participantJID));
|
||||
|
||||
// Register PacketListeners
|
||||
AndFilter presenceFilter = new AndFilter(new PacketTypeFilter(Presence.class), new FromContainsFilter(participantJID));
|
||||
SparkManager.getConnection().addPacketListener(this, presenceFilter);
|
||||
|
||||
AndFilter messageFilter = new AndFilter(new PacketTypeFilter(Message.class), new FromContainsFilter(participantJID));
|
||||
SparkManager.getConnection().addPacketListener(this, messageFilter);
|
||||
|
||||
SparkManager.getConnection().addPacketListener(this, presenceFilter);
|
||||
|
||||
// The roomname will be the participantJID
|
||||
this.roomname = participantJID;
|
||||
|
||||
@ -130,13 +130,6 @@ public class ChatRoomImpl extends ChatRoom {
|
||||
|
||||
tabIcon = SparkManager.getUserManager().getTabIconForPresence(presence);
|
||||
|
||||
PacketFilter filter = new AndFilter(new PacketTypeFilter(Presence.class), new FromContainsFilter(participantJID));
|
||||
SparkManager.getConnection().addPacketListener(new PacketListener() {
|
||||
public void processPacket(Packet packet) {
|
||||
presence = (Presence)packet;
|
||||
}
|
||||
}, filter);
|
||||
|
||||
// Create toolbar buttons.
|
||||
ChatRoomButton infoButton = new ChatRoomButton("", SparkRes.getImageIcon(SparkRes.PROFILE_IMAGE_24x24));
|
||||
infoButton.setToolTipText(Res.getString("message.view.information.about.this.user"));
|
||||
@ -193,17 +186,9 @@ public class ChatRoomImpl extends ChatRoom {
|
||||
typingTimer.start();
|
||||
lastActivity = System.currentTimeMillis();
|
||||
|
||||
|
||||
String time = formatter.format(new Date());
|
||||
transcriptWindow.setInnerHTML("chatName", participantNickname);
|
||||
transcriptWindow.setInnerHTML("timeOpened", "Conversation started on " + time);
|
||||
|
||||
URL url = SparkManager.getVCardManager().getAvatar(participantJID);
|
||||
if (url != null) {
|
||||
transcriptWindow.setInnerHTML("incomingIconPath", "<img src=\"" + url.toExternalForm() + "\">");
|
||||
}
|
||||
|
||||
getToolBar().setVisible(false);
|
||||
// Add VCard Panel
|
||||
final VCardPanel vcardPanel = new VCardPanel(participantJID);
|
||||
getToolBar().add(vcardPanel, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
|
||||
}
|
||||
|
||||
|
||||
@ -361,6 +346,8 @@ public class ChatRoomImpl extends ChatRoom {
|
||||
final Runnable runnable = new Runnable() {
|
||||
public void run() {
|
||||
if (packet instanceof Presence) {
|
||||
presence = (Presence)packet;
|
||||
|
||||
final Presence presence = (Presence)packet;
|
||||
|
||||
ContactList list = SparkManager.getWorkspace().getContactList();
|
||||
@ -434,6 +421,8 @@ public class ChatRoomImpl extends ChatRoom {
|
||||
}
|
||||
participantJID = message.getFrom();
|
||||
insertMessage(message);
|
||||
|
||||
showTyping(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -536,6 +525,16 @@ public class ChatRoomImpl extends ChatRoom {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Show the typing notification.
|
||||
*
|
||||
* @param typing true if the typing notification should show, otherwise hide it.
|
||||
*/
|
||||
public void showTyping(boolean typing) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The last time this chat room sent or receieved a message.
|
||||
*
|
||||
@ -566,6 +565,7 @@ public class ChatRoomImpl extends ChatRoom {
|
||||
this.sendTypingNotification = isSendTypingNotification;
|
||||
}
|
||||
|
||||
|
||||
public void connectionClosed() {
|
||||
handleDisconnect();
|
||||
|
||||
@ -598,6 +598,8 @@ public class ChatRoomImpl extends ChatRoom {
|
||||
}
|
||||
|
||||
SparkManager.getChatManager().getChatContainer().useTabDefault(this);
|
||||
getChatInputEditor().setEnabled(true);
|
||||
getSendButton().setEnabled(true);
|
||||
}
|
||||
|
||||
private void handleDisconnect() {
|
||||
@ -606,4 +608,24 @@ public class ChatRoomImpl extends ChatRoom {
|
||||
getSendButton().setEnabled(false);
|
||||
SparkManager.getChatManager().getChatContainer().useTabDefault(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the alternative icon to use for the chat room. If null,
|
||||
* then the default icon will be used.
|
||||
*
|
||||
* @param icon the alternative icon
|
||||
*/
|
||||
public void setAlternativeIcon(Icon icon) {
|
||||
this.alternativeIcon = icon;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the alternative icon. This can be null.
|
||||
*
|
||||
* @return the alternative icon.
|
||||
*/
|
||||
public Icon getAlternativeIcon() {
|
||||
return alternativeIcon;
|
||||
}
|
||||
|
||||
}
|
||||
@ -42,6 +42,14 @@ import org.jivesoftware.spark.util.ResourceUtils;
|
||||
import org.jivesoftware.spark.util.log.Log;
|
||||
import org.jivesoftware.sparkimpl.plugin.manager.Enterprise;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.Action;
|
||||
import javax.swing.BorderFactory;
|
||||
@ -53,15 +61,6 @@ import javax.swing.JPanel;
|
||||
import javax.swing.JPopupMenu;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Handles broadcasts from server and allows for roster wide broadcasts.
|
||||
*/
|
||||
@ -216,6 +215,11 @@ public class BroadcastPlugin implements Plugin, PacketListener {
|
||||
* @param message the message to show.
|
||||
*/
|
||||
private void showAlert(Message message) {
|
||||
// Do not show alert if the message is an error.
|
||||
if (message.getError() != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final String body = message.getBody();
|
||||
String subject = message.getSubject();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user