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:
Derek DeMoro
2006-12-05 14:30:35 +00:00
committed by derek
parent 850b2b3ac6
commit 64a53231b7
5 changed files with 102 additions and 53 deletions

View File

@ -119,9 +119,9 @@ public final class Spark {
JFrame.setDefaultLookAndFeelDecorated(true); JFrame.setDefaultLookAndFeelDecorated(true);
File skinDir = new File(Spark.getBinDirectory().getParent(), "xtra/skins").getAbsoluteFile(); File skinDir = new File(Spark.getBinDirectory().getParent(), "xtra/skins").getAbsoluteFile();
File defaultSkin = new File(skinDir, "crystal.zip"); File defaultSkin = new File(skinDir, "crystal2themepack.zip");
Skin theSkinToUse = SkinLookAndFeel.loadThemePack(defaultSkin.toURL()); //Skin theSkinToUse = SkinLookAndFeel.loadThemePack(defaultSkin.toURL());
//Skin theSkinToUse = SkinLookAndFeel.loadThemePackDefinition(new File("c:\\craploa\\crystal\\skinlf-themepack.xml").toURL()); Skin theSkinToUse = SkinLookAndFeel.loadThemePackDefinition(new File("c:\\crapola\\crystal\\skinlf-themepack.xml").toURL());
SkinLookAndFeel.setSkin(theSkinToUse); SkinLookAndFeel.setSkin(theSkinToUse);
// finally set the Skin Look And Feel // finally set the Skin Look And Feel
@ -324,7 +324,7 @@ public final class Spark {
} }
public static void installBaseUIProperties() { 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.foreground", Color.BLACK);
UIManager.put("TextField.caretForeground", Color.black); UIManager.put("TextField.caretForeground", Color.black);

View File

@ -38,9 +38,6 @@ import org.jivesoftware.spark.util.log.Log;
import org.jivesoftware.sparkimpl.settings.local.LocalPreferences; import org.jivesoftware.sparkimpl.settings.local.LocalPreferences;
import org.jivesoftware.sparkimpl.settings.local.SettingsManager; import org.jivesoftware.sparkimpl.settings.local.SettingsManager;
import javax.swing.Icon;
import javax.swing.SwingUtilities;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.HashSet; import java.util.HashSet;
@ -48,6 +45,9 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Set; 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 * 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. * 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); invitationListeners.remove(listener);
} }
public Collection<RoomInvitationListener> getInvitationListeners() { public Collection getInvitationListeners() {
return invitationListeners; return invitationListeners;
} }
@ -439,14 +439,18 @@ public class ChatManager implements MessageEventNotificationListener {
try { try {
chatRoom = getChatContainer().getChatRoom(StringUtils.parseBareAddress(from)); chatRoom = getChatContainer().getChatRoom(StringUtils.parseBareAddress(from));
if (chatRoom != null && chatRoom instanceof ChatRoomImpl) { if (chatRoom != null && chatRoom instanceof ChatRoomImpl) {
final ChatRoomImpl roomImpl = (ChatRoomImpl)chatRoom;
// Get Tab // Get Tab
int index = getChatContainer().indexOfComponent(chatRoom); int index = getChatContainer().indexOfComponent(chatRoom);
SparkTab tab = getChatContainer().getTabAt(index); SparkTab tab = getChatContainer().getTabAt(index);
tab.setIcon(SparkRes.getImageIcon(SparkRes.SMALL_MESSAGE_EDIT_IMAGE)); 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()); getChatContainer().getChatFrame().setIconImage(SparkRes.getImageIcon(SparkRes.SMALL_MESSAGE_EDIT_IMAGE).getImage());
} }
roomImpl.setAlternativeIcon(SparkRes.getImageIcon(SparkRes.SMALL_MESSAGE_EDIT_IMAGE));
} }
} }
catch (ChatRoomNotFoundException e) { catch (ChatRoomNotFoundException e) {
@ -458,6 +462,7 @@ public class ChatManager implements MessageEventNotificationListener {
}); });
} }
public void offlineNotification(String from, String packetID) { public void offlineNotification(String from, String packetID) {
} }
@ -470,13 +475,16 @@ public class ChatManager implements MessageEventNotificationListener {
try { try {
chatRoom = getChatContainer().getChatRoom(StringUtils.parseBareAddress(from)); chatRoom = getChatContainer().getChatRoom(StringUtils.parseBareAddress(from));
if (chatRoom != null && chatRoom instanceof ChatRoomImpl) { if (chatRoom != null && chatRoom instanceof ChatRoomImpl) {
final ChatRoomImpl roomImpl = (ChatRoomImpl)chatRoom;
roomImpl.setAlternativeIcon(null);
// Get Tab // Get Tab
int index = getChatContainer().indexOfComponent(chatRoom); int index = getChatContainer().indexOfComponent(chatRoom);
SparkTab tab = getChatContainer().getTabAt(index); SparkTab tab = getChatContainer().getTabAt(index);
tab.setIcon(tab.getPreviousIcon()); tab.setIcon(tab.getPreviousIcon());
} }
getChatContainer().getChatFrame().setIconImage(SparkRes.getImageIcon(SparkRes.SMALL_MESSAGE_IMAGE).getImage()); getChatContainer().getChatFrame().setIconImage(SparkManager.getMainWindow().getIconImage());
} }
catch (ChatRoomNotFoundException e) { catch (ChatRoomNotFoundException e) {
} }
@ -487,6 +495,7 @@ public class ChatManager implements MessageEventNotificationListener {
}); });
} }
/** /**
* Internal implementation of the MessageEventRequestListener. * Internal implementation of the MessageEventRequestListener.
*/ */

View File

@ -91,7 +91,7 @@ public final class Notifications implements ActionListener, MainWindowListener {
unavaliableIcon = SparkRes.getImageIcon(SparkRes.MESSAGE_AWAY); unavaliableIcon = SparkRes.getImageIcon(SparkRes.MESSAGE_AWAY);
busyIcon = SparkRes.getImageIcon(SparkRes.MESSAGE_DND); busyIcon = SparkRes.getImageIcon(SparkRes.MESSAGE_DND);
trayIcon = new TrayIcon(availableIcon); trayIcon = new TrayIcon(availableIcon);
trayIcon.setToolTip("Spark"); // NORES trayIcon.setToolTip("Spark Client"); // NORES
JPopupMenu popupMenu = new JPopupMenu(Res.getString("title.tray.information")); JPopupMenu popupMenu = new JPopupMenu(Res.getString("title.tray.information"));
@ -161,6 +161,12 @@ public final class Notifications implements ActionListener, MainWindowListener {
else { else {
trayIcon.setIcon(busyIcon); 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) { public void actionPerformed(ActionEvent e) {
Object o = e.getSource(); Object o = e.getSource();
if (!(o instanceof JMenuItem)) { if (!(o instanceof JMenuItem)) {
if (SparkManager.getMainWindow().isVisible()) {
SparkManager.getMainWindow().setVisible(false);
hideMenu.setEnabled(false);
}
else {
showMainWindow(); showMainWindow();
}
return; return;
} }
@ -284,6 +296,8 @@ public final class Notifications implements ActionListener, MainWindowListener {
notificationDialog.setVisible(false); notificationDialog.setVisible(false);
hideMenu.setEnabled(true); hideMenu.setEnabled(true);
SparkManager.getMainWindow().toFront();
} }

View File

@ -12,13 +12,11 @@ package org.jivesoftware.spark.ui.rooms;
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.Roster; import org.jivesoftware.smack.Roster;
import org.jivesoftware.smack.RosterEntry; import org.jivesoftware.smack.RosterEntry;
import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.filter.AndFilter; import org.jivesoftware.smack.filter.AndFilter;
import org.jivesoftware.smack.filter.FromContainsFilter; import org.jivesoftware.smack.filter.FromContainsFilter;
import org.jivesoftware.smack.filter.PacketFilter;
import org.jivesoftware.smack.filter.PacketTypeFilter; import org.jivesoftware.smack.filter.PacketTypeFilter;
import org.jivesoftware.smack.packet.Message; import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Packet; 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.ContactList;
import org.jivesoftware.spark.ui.MessageEventListener; import org.jivesoftware.spark.ui.MessageEventListener;
import org.jivesoftware.spark.ui.RosterDialog; import org.jivesoftware.spark.ui.RosterDialog;
import org.jivesoftware.spark.ui.VCardPanel;
import org.jivesoftware.spark.util.ModelUtil; import org.jivesoftware.spark.util.ModelUtil;
import org.jivesoftware.spark.util.log.Log; import org.jivesoftware.spark.util.log.Log;
import org.jivesoftware.sparkimpl.profile.VCardManager; import org.jivesoftware.sparkimpl.profile.VCardManager;
import javax.swing.Icon; import java.awt.GridBagConstraints;
import javax.swing.SwingUtilities; import java.awt.Insets;
import javax.swing.Timer;
import javax.swing.event.DocumentEvent;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.net.URL;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
@ -53,6 +48,11 @@ import java.util.Date;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; 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 is the Person to Person implementation of <code>ChatRoom</code>
* This room only allows for 1 to 1 conversations. * This room only allows for 1 to 1 conversations.
@ -86,6 +86,8 @@ public class ChatRoomImpl extends ChatRoom {
private boolean iconHandler; private boolean iconHandler;
private Icon alternativeIcon;
/** /**
* Constructs a 1-to-1 ChatRoom. * Constructs a 1-to-1 ChatRoom.
@ -98,15 +100,13 @@ public class ChatRoomImpl extends ChatRoom {
this.participantJID = participantJID; this.participantJID = participantJID;
this.participantNickname = participantNickname; this.participantNickname = participantNickname;
AndFilter presenceFilter = new AndFilter(new PacketTypeFilter(Presence.class), new FromContainsFilter(participantJID));
// Register PacketListeners // 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)); AndFilter messageFilter = new AndFilter(new PacketTypeFilter(Message.class), new FromContainsFilter(participantJID));
SparkManager.getConnection().addPacketListener(this, messageFilter); SparkManager.getConnection().addPacketListener(this, messageFilter);
SparkManager.getConnection().addPacketListener(this, presenceFilter);
// The roomname will be the participantJID // The roomname will be the participantJID
this.roomname = participantJID; this.roomname = participantJID;
@ -130,13 +130,6 @@ public class ChatRoomImpl extends ChatRoom {
tabIcon = SparkManager.getUserManager().getTabIconForPresence(presence); 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. // Create toolbar buttons.
ChatRoomButton infoButton = new ChatRoomButton("", SparkRes.getImageIcon(SparkRes.PROFILE_IMAGE_24x24)); ChatRoomButton infoButton = new ChatRoomButton("", SparkRes.getImageIcon(SparkRes.PROFILE_IMAGE_24x24));
infoButton.setToolTipText(Res.getString("message.view.information.about.this.user")); infoButton.setToolTipText(Res.getString("message.view.information.about.this.user"));
@ -193,17 +186,9 @@ public class ChatRoomImpl extends ChatRoom {
typingTimer.start(); typingTimer.start();
lastActivity = System.currentTimeMillis(); lastActivity = System.currentTimeMillis();
// Add VCard Panel
String time = formatter.format(new Date()); final VCardPanel vcardPanel = new VCardPanel(participantJID);
transcriptWindow.setInnerHTML("chatName", participantNickname); 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));
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);
} }
@ -361,6 +346,8 @@ public class ChatRoomImpl extends ChatRoom {
final Runnable runnable = new Runnable() { final Runnable runnable = new Runnable() {
public void run() { public void run() {
if (packet instanceof Presence) { if (packet instanceof Presence) {
presence = (Presence)packet;
final Presence presence = (Presence)packet; final Presence presence = (Presence)packet;
ContactList list = SparkManager.getWorkspace().getContactList(); ContactList list = SparkManager.getWorkspace().getContactList();
@ -434,6 +421,8 @@ public class ChatRoomImpl extends ChatRoom {
} }
participantJID = message.getFrom(); participantJID = message.getFrom();
insertMessage(message); 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. * The last time this chat room sent or receieved a message.
* *
@ -566,6 +565,7 @@ public class ChatRoomImpl extends ChatRoom {
this.sendTypingNotification = isSendTypingNotification; this.sendTypingNotification = isSendTypingNotification;
} }
public void connectionClosed() { public void connectionClosed() {
handleDisconnect(); handleDisconnect();
@ -598,6 +598,8 @@ public class ChatRoomImpl extends ChatRoom {
} }
SparkManager.getChatManager().getChatContainer().useTabDefault(this); SparkManager.getChatManager().getChatContainer().useTabDefault(this);
getChatInputEditor().setEnabled(true);
getSendButton().setEnabled(true);
} }
private void handleDisconnect() { private void handleDisconnect() {
@ -606,4 +608,24 @@ public class ChatRoomImpl extends ChatRoom {
getSendButton().setEnabled(false); getSendButton().setEnabled(false);
SparkManager.getChatManager().getChatContainer().useTabDefault(this); 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;
}
} }

View File

@ -42,6 +42,14 @@ 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.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.AbstractAction;
import javax.swing.Action; import javax.swing.Action;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
@ -53,15 +61,6 @@ import javax.swing.JPanel;
import javax.swing.JPopupMenu; import javax.swing.JPopupMenu;
import javax.swing.SwingUtilities; 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. * 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. * @param message the message to show.
*/ */
private void showAlert(Message message) { 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(); final String body = message.getBody();
String subject = message.getSubject(); String subject = message.getSubject();