enhancements to the swing popup notification, new behavior for the trayicon, minors code tweak

cusax-fix
Symphorien Wanko 17 years ago
parent 41da838ce2
commit fecc1bc966

@ -912,6 +912,7 @@
<zipfileset dir="${dest}/net/java/sip/communicator/util"
prefix="net/java/sip/communicator/util"/>
<zipfileset src="${lib.noinst}/dnsjava-2.0.3.jar" prefix=""/>
<zipfileset src="lib/installer-exclude/laf-widget.jar" prefix=""/>
</jar>
</target>
@ -1311,7 +1312,6 @@ javax.swing.event, javax.swing.border"/>
<zipfileset src="lib/installer-exclude/jna.jar" prefix=""/>
<zipfileset src="lib/installer-exclude/transparency.jar" prefix=""/>
<zipfileset src="lib/installer-exclude/swing-worker-1.2.jar" prefix=""/>
<zipfileset src="lib/installer-exclude/laf-widget.jar" prefix=""/>
</jar>
</target>

@ -1,5 +1,6 @@
# service gui
service.gui.SIP_COMMUNICATOR_LOGO=resources/images/logo/sc_logo16x16.png
service.gui.SIP_COMMUNICATOR_LOGO_39x58=resources/images/logo/sc_logo_39x58.png
service.gui.MAIN_WINDOW_BACKGROUND=
service.gui.AUTH_WINDOW_BACKGROUND=resources/images/impl/gui/common/passWindowBackground.png
service.gui.ABOUT_WINDOW_BACKGROUND=resources/images/impl/gui/common/aboutWindowBackground.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

@ -339,8 +339,8 @@ impl.systray.SET_STATUS=Set Status
impl.systray.ONLINE_STATUS=Online
impl.systray.OFFLINE_STATUS=Offline
impl.systray.FAILED_TO_OPEN_ADD_CONTACT_DIALOG=Failed to open the "Add Contact" dialog.
impl.systray.POPUP_MESSAGE_HANDLER=Systray balloon message
impl.swingnotification.POPUP_MESSAGE_HANDLER=SC likes popup
impl.systray.POPUP_MESSAGE_HANDLER=Systray balloon messages
impl.swingnotification.POPUP_MESSAGE_HANDLER=SIP Communicator popups
impl.growlnotification.POPUP_MESSAGE_HANDLER=Growl notifications
# account info
@ -669,7 +669,7 @@ plugin.notificationconfig.RESTORE=Restore Defaults
plugin.notificationconfig.PLAY_SOUND=Play a sound :
plugin.notificationconfig.EXEC_PROG=Execute a program :
plugin.notificationconfig.DISPLAY_POPUP=Show a message in a pop-up window
plugin.notificationconfig.POPUP_NOTIF_HANDLER=Popup notifications type
plugin.notificationconfig.POPUP_NOTIF_HANDLER=Popup notifications type :
# ZRTP Securing
impl.media.security.INFO=ZRTP Security information

@ -7,6 +7,7 @@
package net.java.sip.communicator.impl.gui.customcontrols;
import java.awt.*;
import net.java.sip.communicator.util.swing.*;
/**
* The <tt>MsgToolbarButton</tt> is a <tt>SIPCommButton</tt> that has

@ -9,8 +9,7 @@
import javax.swing.*;
import javax.swing.plaf.*;
import javax.swing.plaf.metal.*;
import net.java.sip.communicator.impl.gui.utils.*;
import net.java.sip.communicator.util.swing.*;
/**
* The default SIP-Communicator look&feel.

@ -13,7 +13,6 @@
import javax.swing.plaf.metal.*;
import javax.swing.text.*;
import net.java.sip.communicator.impl.gui.customcontrols.*;
import net.java.sip.communicator.impl.gui.utils.*;
import net.java.sip.communicator.util.swing.*;

@ -14,7 +14,6 @@
import javax.swing.border.*;
import net.java.sip.communicator.impl.gui.*;
import net.java.sip.communicator.impl.gui.customcontrols.*;
import net.java.sip.communicator.impl.gui.utils.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.util.swing.*;

@ -57,8 +57,7 @@ public void incomingCallReceived(CallEvent event)
// FIXME: I18N
NotificationManager.fireNotification(
NotificationManager.INCOMING_CALL,
GuiActivator.getResources().getSettingsString(
"service.gui.APPLICATION_NAME"),
"",
"Incoming call received from: "
+ sourceCall.getCallParticipants().next());
}

@ -14,7 +14,6 @@
import javax.swing.Timer;
import net.java.sip.communicator.impl.gui.*;
import net.java.sip.communicator.impl.gui.customcontrols.*;
import net.java.sip.communicator.impl.gui.utils.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.service.protocol.event.*;

@ -15,12 +15,12 @@
import javax.swing.Timer;
import net.java.sip.communicator.impl.gui.*;
import net.java.sip.communicator.impl.gui.customcontrols.*;
import net.java.sip.communicator.impl.gui.utils.*;
import net.java.sip.communicator.service.audionotifier.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.service.resources.*;
import net.java.sip.communicator.util.*;
import net.java.sip.communicator.util.swing.*;
/**
* The <tt>DialPanel</tt> is the panel that contains the buttons to dial a

@ -10,9 +10,9 @@
import java.util.*;
import net.java.sip.communicator.impl.gui.*;
import net.java.sip.communicator.impl.gui.customcontrols.*;
import net.java.sip.communicator.impl.gui.utils.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.util.swing.*;
/**
* Represents an UI means to put an associated <tt>CallPariticant</tt> on/off

@ -10,9 +10,9 @@
import java.util.*;
import net.java.sip.communicator.impl.gui.*;
import net.java.sip.communicator.impl.gui.customcontrols.*;
import net.java.sip.communicator.impl.gui.utils.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.util.swing.*;
/**
* Represents an UI means to mute the audio stream sent to an associated

@ -13,7 +13,6 @@
import javax.swing.*;
import net.java.sip.communicator.impl.gui.*;
import net.java.sip.communicator.impl.gui.customcontrols.*;
import net.java.sip.communicator.impl.gui.utils.*;
import net.java.sip.communicator.service.contactlist.*;
import net.java.sip.communicator.service.protocol.*;

@ -12,7 +12,6 @@
import javax.swing.*;
import net.java.sip.communicator.impl.gui.*;
import net.java.sip.communicator.impl.gui.customcontrols.*;
import net.java.sip.communicator.impl.gui.utils.*;
import net.java.sip.communicator.service.notification.*;
import net.java.sip.communicator.service.protocol.*;

@ -13,11 +13,11 @@
import org.osgi.framework.*;
import net.java.sip.communicator.impl.gui.*;
import net.java.sip.communicator.impl.gui.customcontrols.*;
import net.java.sip.communicator.impl.gui.utils.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.service.protocol.event.*;
import net.java.sip.communicator.util.*;
import net.java.sip.communicator.util.swing.*;
/**
* Represents an UI means to transfer (the <code>Call</code> of) an associated

@ -107,6 +107,8 @@ public ChatConversationPanel(ChatConversationContainer chatContainer)
this.chatEditorPane.addHyperlinkListener(this);
this.chatEditorPane.addMouseListener(this);
this.chatEditorPane.setCursor(
Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
this.setWheelScrollingEnabled(true);

@ -77,6 +77,8 @@ public ChatWritePanel(ChatPanel panel)
this.editorPane.getDocument().addUndoableEditListener(this);
this.editorPane.addKeyListener(this);
this.editorPane.addMouseListener(this);
this.editorPane.setCursor(
Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
//set our own transfer (i.e. copy/paste) handler
this.editorPane.setTransferHandler(new ChatWritePanelTransferHandler());

@ -14,7 +14,6 @@
import javax.swing.text.html.*;
import net.java.sip.communicator.impl.gui.*;
import net.java.sip.communicator.impl.gui.customcontrols.*;
import net.java.sip.communicator.impl.gui.main.chat.*;
import net.java.sip.communicator.impl.gui.utils.*;
import net.java.sip.communicator.util.*;

@ -12,7 +12,6 @@
import javax.swing.*;
import net.java.sip.communicator.impl.gui.*;
import net.java.sip.communicator.impl.gui.customcontrols.*;
import net.java.sip.communicator.impl.gui.main.chatroomslist.*;
import net.java.sip.communicator.impl.gui.main.contactlist.addcontact.*;
import net.java.sip.communicator.impl.gui.utils.*;

@ -2,8 +2,8 @@
import java.awt.*;
import net.java.sip.communicator.impl.gui.customcontrols.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.util.swing.*;
/**
* The ContactProtocolButton is a button behind a "meta contact" in the

@ -31,7 +31,7 @@ public class ConfigurationManager
private static boolean isShowOffline = true;
private static boolean isApplicationVisible = true;
private static boolean isQuitWarningShown = true;
private static boolean isSendTypingNotifications;
@ -96,7 +96,7 @@ public static void loadGuiConfigurations()
if(callPanelShown != null && callPanelShown.length() > 0)
{
isCallPanelShown = new Boolean(callPanelShown).booleanValue();
isCallPanelShown = Boolean.parseBoolean(callPanelShown);
}
// Load the "showOffline" property.
@ -105,7 +105,7 @@ public static void loadGuiConfigurations()
if(showOffline != null && showOffline.length() > 0)
{
isShowOffline = new Boolean(showOffline).booleanValue();
isShowOffline = Boolean.parseBoolean(showOffline);
}
// Load the "showApplication" property.
@ -124,7 +124,7 @@ public static void loadGuiConfigurations()
if(quitWarningShown != null && quitWarningShown.length() > 0)
{
isQuitWarningShown
= new Boolean(quitWarningShown).booleanValue();
= Boolean.parseBoolean(quitWarningShown);
}
// Load the "sendTypingNotifications" property.
@ -141,7 +141,7 @@ public static void loadGuiConfigurations()
if(isSendTypingNotif != null && isSendTypingNotif.length() > 0)
{
isSendTypingNotifications
= new Boolean(isSendTypingNotif).booleanValue();
= Boolean.parseBoolean(isSendTypingNotif);
}
// Load the "isMoveContactConfirmationRequested" property.
@ -153,8 +153,8 @@ public static void loadGuiConfigurations()
&& isMoveContactConfirmationRequestedString.length() > 0)
{
isMoveContactConfirmationRequested
= new Boolean(isMoveContactConfirmationRequestedString)
.booleanValue();
= Boolean.parseBoolean(isMoveContactConfirmationRequestedString)
;
}
// Load the "isMultiChatWindowEnabled" property.
@ -173,8 +173,8 @@ public static void loadGuiConfigurations()
&& isMultiChatWindowEnabledString.length() > 0)
{
isMultiChatWindowEnabled
= new Boolean(isMultiChatWindowEnabledString)
.booleanValue();
= Boolean.parseBoolean(isMultiChatWindowEnabledString)
;
}
// Load the "isHistoryLoggingEnabled" property.
@ -186,8 +186,8 @@ public static void loadGuiConfigurations()
&& isHistoryLoggingEnabledString.length() > 0)
{
isHistoryLoggingEnabled
= new Boolean(isHistoryLoggingEnabledString)
.booleanValue();
= Boolean.parseBoolean(isHistoryLoggingEnabledString)
;
}
// Load the "isHistoryShown" property.
@ -206,8 +206,8 @@ public static void loadGuiConfigurations()
&& isHistoryShownString.length() > 0)
{
isHistoryShown
= new Boolean(isHistoryShownString)
.booleanValue();
= Boolean.parseBoolean(isHistoryShownString)
;
}
// Load the "chatHistorySize" property.
@ -245,7 +245,7 @@ public static void loadGuiConfigurations()
&& isTransparentWindowEnabledString.length() > 0)
{
isTransparentWindowEnabled
= new Boolean(isTransparentWindowEnabledString).booleanValue();
= Boolean.parseBoolean(isTransparentWindowEnabledString);
}
// Load the "windowTransparency" property.
@ -283,7 +283,7 @@ public static void loadGuiConfigurations()
&& isWindowDecoratedString.length() > 0)
{
isWindowDecorated
= new Boolean(isWindowDecoratedString).booleanValue();
= Boolean.parseBoolean(isWindowDecoratedString);
}
// Load the "lastContactParent" property.
@ -524,14 +524,14 @@ public static void setShowCallPanel(boolean isCallPanelShown)
/**
* Updates the "showApplication" property through the
* <tt>ConfigurationService</tt>.
*
*
* @param isVisible <code>true</code> to indicate that the
* application should be shown, <code>false</code> otherwise.
*/
public static void setApplicationVisible(boolean isVisible)
{
isApplicationVisible = isVisible;
configService.setProperty(
"net.java.sip.communicator.impl.systray.showApplication",
Boolean.toString(isVisible));
@ -824,7 +824,7 @@ public static boolean getContactListGroupStatus(String groupID)
String status = (String) configService
.getProperty( groupRootPropName + ".isClosed");
return new Boolean(status).booleanValue();
return Boolean.parseBoolean(status);
}
}
@ -845,7 +845,7 @@ else if (evt.getPropertyName().equals(
String autoPopupString = (String) evt.getNewValue();
autoPopupNewMessage
= new Boolean(autoPopupString).booleanValue();
= Boolean.parseBoolean(autoPopupString);
}
else if (evt.getPropertyName().equals(
"service.gui.SEND_MESSAGE_COMMAND"))
@ -859,7 +859,7 @@ else if (evt.getPropertyName().equals(
String showCallPanelString = (String) evt.getNewValue();
isCallPanelShown
= new Boolean(showCallPanelString).booleanValue();
= Boolean.parseBoolean(showCallPanelString);
}
else if (evt.getPropertyName().equals(
"net.java.sip.communicator.impl.gui.showOffline"))
@ -867,13 +867,13 @@ else if (evt.getPropertyName().equals(
String showOfflineString = (String) evt.getNewValue();
isShowOffline
= new Boolean(showOfflineString).booleanValue();
= Boolean.parseBoolean(showOfflineString);
}
else if (evt.getPropertyName().equals(
"net.java.sip.communicator.impl.systray.showApplication"))
{
String showApplicationString = (String) evt.getNewValue();
isApplicationVisible
= new Boolean(showApplicationString).booleanValue();
}
@ -883,7 +883,7 @@ else if (evt.getPropertyName().equals(
String showQuitWarningString = (String) evt.getNewValue();
isQuitWarningShown
= new Boolean(showQuitWarningString).booleanValue();
= Boolean.parseBoolean(showQuitWarningString);
}
else if (evt.getPropertyName().equals(
"service.gui.SEND_TYPING_NOTIFICATIONS_ENABLED"))
@ -891,7 +891,7 @@ else if (evt.getPropertyName().equals(
String sendTypingNorifString = (String) evt.getNewValue();
isSendTypingNotifications
= new Boolean(sendTypingNorifString).booleanValue();
= Boolean.parseBoolean(sendTypingNorifString);
}
else if (evt.getPropertyName().equals(
"net.java.sip.communicator.impl.gui.isMoveContactConfirmationRequested"))
@ -899,7 +899,7 @@ else if (evt.getPropertyName().equals(
String moveContactConfirmString = (String) evt.getNewValue();
isMoveContactConfirmationRequested
= new Boolean(moveContactConfirmString).booleanValue();
= Boolean.parseBoolean(moveContactConfirmString);
}
else if (evt.getPropertyName().equals(
"service.gui.IS_MULTI_CHAT_WINDOW_ENABLED"))
@ -907,7 +907,7 @@ else if (evt.getPropertyName().equals(
String multiChatWindowString = (String) evt.getNewValue();
isMultiChatWindowEnabled
= new Boolean(multiChatWindowString).booleanValue();
= Boolean.parseBoolean(multiChatWindowString);
}
else if (evt.getPropertyName().equals(
"net.java.sip.communicator.impl.gui.isHistoryLoggingEnabled"))
@ -915,7 +915,7 @@ else if (evt.getPropertyName().equals(
String historyLoggingString = (String) evt.getNewValue();
isHistoryLoggingEnabled
= new Boolean(historyLoggingString).booleanValue();
= Boolean.parseBoolean(historyLoggingString);
}
else if (evt.getPropertyName().equals(
"service.gui.IS_MESSAGE_HISTORY_SHOWN"))
@ -923,7 +923,7 @@ else if (evt.getPropertyName().equals(
String historyShownString = (String) evt.getNewValue();
isHistoryShown
= new Boolean(historyShownString).booleanValue();
= Boolean.parseBoolean(historyShownString);
}
else if (evt.getPropertyName().equals(
"service.gui.MESSAGE_HISTORY_SIZE"))
@ -939,7 +939,7 @@ else if (evt.getPropertyName().equals(
String isTransparentString = (String) evt.getNewValue();
isTransparentWindowEnabled
= new Boolean(isTransparentString).booleanValue();
= Boolean.parseBoolean(isTransparentString);
}
else if (evt.getPropertyName().equals(
"impl.gui.WINDOW_TRANSPARENCY"))

@ -115,7 +115,7 @@ public static void fireNotification(String eventType,
if(notificationService == null)
return;
notificationService.fireNotification(eventType, messageTitle, message);
notificationService.fireNotification(eventType, messageTitle, message, null);
}
/**
@ -148,8 +148,7 @@ public static void fireChatNotification(Object contact,
else if (contact instanceof ChatRoom)
{
// For system rooms we don't want to send notification events.
if ((contact instanceof ChatRoom)
&& ((ChatRoom) contact).isSystem())
if (((ChatRoom) contact).isSystem())
return;
chatPanel = GuiActivator.getUIService().getChat((ChatRoom) contact);
@ -166,7 +165,8 @@ else if (contact instanceof ChatRoom)
popupActionHandler.setEnabled(false);
}
notificationService.fireNotification(eventType, messageTitle, message);
notificationService.fireNotification(
eventType, messageTitle, message, contact);
if(popupActionHandler != null)
popupActionHandler.setEnabled(true);

@ -376,8 +376,13 @@ public void removeNotificationChangeListener(
* @param title the title of the given message
* @param message the message to use if and where appropriate (e.g. with
* systray or log notification.)
* @param tag additional info to be used by the notification handler
*/
public void fireNotification(String eventType, String title, String message)
public void fireNotification(
String eventType,
String title,
String message,
Object tag)
{
EventNotification notification
= (EventNotification) notificationsTable.get(eventType);
@ -401,7 +406,7 @@ public void fireNotification(String eventType, String title, String message)
if (actionType.equals(NotificationService.ACTION_POPUP_MESSAGE))
{
((PopupMessageNotificationHandler) handler)
.popupMessage(new PopupMessage(title, message));
.popupMessage(new PopupMessage(title, message, tag));
}
else if (actionType.equals(NotificationService.ACTION_LOG_MESSAGE))
{
@ -431,7 +436,7 @@ else if (actionType.equals(NotificationService.ACTION_COMMAND))
*/
public void fireNotification(String eventType)
{
this.fireNotification(eventType, null, null);
this.fireNotification(eventType, null, null, null);
}
/**

@ -13,6 +13,7 @@
import javax.swing.*;
import javax.swing.Timer;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.service.systray.*;
import net.java.sip.communicator.service.systray.event.*;
import net.java.sip.communicator.util.*;
@ -36,7 +37,7 @@ public class PopupMessageHandlerSwingImpl implements PopupMessageHandler
/** An icon representing the contact from which the notification comes */
private ImageIcon defaultIcon =
SwingNotificationActivator.getResources().getImage(
"service.gui.DEFAULT_USER_PHOTO");;
"service.gui.SIP_COMMUNICATOR_LOGO_39x58");;
/**
* Adds a listerner to receive popup events
@ -76,11 +77,9 @@ public void showPopupMessage(PopupMessage popupMessage)
getDefaultConfiguration();
final JWindow notificationWindow = new JWindow(graphicsConf);
notificationWindow.setPreferredSize(new Dimension(225, 125));
final Timer popupTimer = new Timer(10000, new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
if (notificationWindow.isVisible())
@ -108,18 +107,27 @@ public void mouseExited(MouseEvent e)
@Override
public void mouseClicked(MouseEvent e)
{
firePopupMessageClicked(new SystrayPopupMessageEvent(e));
Container container = notificationWindow.getContentPane();
PopupNotificationPanel notif =
(PopupNotificationPanel) container.getComponent(0);
firePopupMessageClicked(
new SystrayPopupMessageEvent(e, notif.getTag()));
notificationWindow.dispose();
}
});
if (popupMessage.getComponent() != null)
{
notificationWindow.add(popupMessage.getComponent());
}
else
{
notificationWindow.add(createPopup(
popupMessage.getMessageTitle(),
popupMessage.getMessage(),
popupMessage.getIcon()));
popupMessage.getTag()));
notificationWindow.setPreferredSize(new Dimension(225, 120));
}
notificationWindow.setAlwaysOnTop(true);
notificationWindow.pack();
@ -136,38 +144,46 @@ public void mouseClicked(MouseEvent e)
* @return
*/
private JComponent createPopup(String title, String message,
ImageIcon icon)
Object tag)
{
String msg;
if (message.length() > 70)
msg = "<html><b>" + message.substring(0, 77) + "...";
else
msg = "<html><b>" + message;
JLabel msgContent = new JLabel(msg);
if (title.length() > 40)
title = title.substring(0, 28) + "...";
JLabel msgFrom = new JLabel(title);
msgFrom.setForeground(Color.DARK_GRAY);
JLabel msgIcon = (icon == null) ?
new JLabel(defaultIcon) :
new JLabel(icon);
msgIcon.setOpaque(false);
String ttle = title;
if (title.length() > 50)
ttle = title.substring(0, 47) + "...";
JLabel msgTitle = new JLabel("<html>" + ttle);
msgTitle.setForeground(Color.DARK_GRAY);
String msg = message;
if (message.length() > 90)
msg = message.substring(0, 87) + "...";
JLabel msgContent = new JLabel("<html><b>" + msg);
JPanel notificationBody = new JPanel(new BorderLayout());
notificationBody.setOpaque(false);
notificationBody.add(msgTitle, BorderLayout.NORTH);
notificationBody.add(msgContent, BorderLayout.CENTER);
JLabel msgIcon = new JLabel(defaultIcon);
if (tag instanceof Contact)
{
byte[] b = ((Contact) tag).getImage();
if (b != null)
msgIcon = new JLabel(new ImageIcon(b));
}
else if (tag instanceof ImageIcon)
{
msgIcon = new JLabel((ImageIcon) tag);
}
msgIcon.setPreferredSize(new Dimension(45, 45));
JPanel notificationContent = new JPanel(new BorderLayout(5, 1));
JPanel notificationContent = new JPanel(new BorderLayout(5, 0));
notificationContent.setBorder(
BorderFactory.createEmptyBorder(10, 10, 10, 10));
BorderFactory.createEmptyBorder(0, 3, 3, 3));
notificationContent.setOpaque(false);
notificationContent.add(msgFrom, BorderLayout.NORTH);
notificationContent.add(msgContent, BorderLayout.CENTER);
notificationContent.add(msgIcon, BorderLayout.WEST);
notificationContent.add(notificationBody, BorderLayout.CENTER);
return new PopupNotificationPanel(notificationContent);
return new PopupNotificationPanel(notificationContent, tag);
}
/**

@ -6,6 +6,7 @@ Bundle-Version: 0.0.1
System-Bundle: yes
Import-Package: org.osgi.framework,
net.java.sip.communicator.service.configuration,
net.java.sip.communicator.service.protocol,
net.java.sip.communicator.service.resources,
net.java.sip.communicator.service.systray,
net.java.sip.communicator.service.systray.event,

@ -1,46 +0,0 @@
/*
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.impl.systray.jdic;
import java.awt.*;
import java.awt.image.*;
import javax.swing.*;
/**
* An image filter that "disables" an image by turning
* it into a grayscale image, and brightening the pixels
* in the image. Used by buttons to create an image for
* a disabled button. Creates a more brighter image than
* the javax.swing.GrayFilter.
*
* @author Yana Stamcheva
*/
public class LightGrayFilter extends GrayFilter {
/**
* Creates an instance of a LightGrayFilter.
* @param b a boolean -- true if the pixels should be brightened
* @param p an int in the range 0..100 that determines the percentage
* of gray, where 100 is the darkest gray, and 0 is the lightest
*/
public LightGrayFilter(boolean b, int p) {
super(b, p);
}
/**
* Creates a disabled image.
* @param i The source image.
* @return A disabled image based on the source image.
*/
public static Image createDisabledImage(Image i) {
LightGrayFilter filter = new LightGrayFilter(true, 65);
ImageProducer prod = new FilteredImageSource(i.getSource(), filter);
Image grayImage = Toolkit.getDefaultToolkit().createImage(prod);
return grayImage;
}
}

@ -14,6 +14,7 @@
import net.java.sip.communicator.impl.systray.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.util.*;
import net.java.sip.communicator.util.swing.*;
/**
* The <tt>StatusSimpleSelector</tt> is a submenu which allow to select a status

@ -8,7 +8,6 @@
import org.osgi.framework.*;
import java.awt.Toolkit;
import java.awt.event.*;
import java.net.*;
import java.util.*;
@ -64,11 +63,6 @@ public class SystrayServiceJdicImpl
private final Hashtable<String, PopupMessageHandler> popupHandlerSet =
new Hashtable<String, PopupMessageHandler>();
/**
* Stores the system time, when the main window was restored the last time
*/
private long setVisibleTime = 0;
/**
* A reference of the <tt>ConfigurationService</tt> obtained from the
* <tt>SystrayServiceActivator</tt>
@ -137,9 +131,7 @@ public SystrayServiceJdicImpl()
UIService ui = SystrayActivator.getUIService();
if (ui != null)
{
ui.setExitOnMainWindowClose(false);
}
}
}
@ -148,13 +140,6 @@ public SystrayServiceJdicImpl()
*/
private void initSystray()
{
// Get the system's double click speed
Object o = Toolkit.getDefaultToolkit().getDesktopProperty(
"awt.multiClickInterval");
final int doubleClickSpeed = (o instanceof Integer ? ((Integer) o).
intValue() : 500);
menu = TrayMenuFactory.createTrayMenu(this, systray.isSwing());
String osName = System.getProperty("os.name");
@ -222,29 +207,19 @@ else if (osName.startsWith("Mac OS X"))
//Show/hide the contact list when user clicks on the systray.
trayIcon.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
long currentTime = System.currentTimeMillis();
UIService uiService = SystrayActivator.getUIService();
boolean isVisible = !uiService.isVisible();
if (isVisible)
ExportedWindow win =
uiService.getExportedWindow(ExportedWindow.MAIN_WINDOW);
if (!win.isVisible())
{
setVisibleTime = currentTime;
} else if (currentTime < (setVisibleTime + doubleClickSpeed))
{
// Do nothing. the last restore is less than 2 seconds, so it is very
// likely, that the user made a double click. prevent the main window
// from opening and immediately closing again.
return;
win.setVisible(true);
configService.setProperty(
"net.java.sip.communicator.impl.systray.showApplication",
Boolean.toString(true));
}
uiService.setVisible(isVisible);
configService.setProperty(
"net.java.sip.communicator.impl.systray.showApplication",
Boolean.toString(isVisible));
win.bringToFront();
}
});
@ -288,12 +263,15 @@ public void popupMenuCanceled(PopupMenuEvent e)
});
}
PopupMessageHandler pph = new PopupMessageHandlerTrayIconImpl(trayIcon);
popupHandlerSet.put(pph.getClass().getName(), pph);
SystrayActivator.bundleContext.registerService(
PopupMessageHandler.class.getName(),
pph, null);
PopupMessageHandler pph = null;
if (!osName.startsWith("Mac OS X"))
{
pph = new PopupMessageHandlerTrayIconImpl(trayIcon);
popupHandlerSet.put(pph.getClass().getName(), pph);
SystrayActivator.bundleContext.registerService(
PopupMessageHandler.class.getName(),
pph, null);
}
try
{
SystrayActivator.bundleContext.addServiceListener(
@ -611,9 +589,12 @@ public void popupMessageClicked(SystrayPopupMessageEvent evt)
UIService uiService = SystrayActivator.getUIService();
ExportedWindow chatWindow = uiService.getExportedWindow(
ExportedWindow.CHAT_WINDOW);
if (chatWindow != null && chatWindow.isVisible())
{
if (chatWindow != null)
chatWindow.bringToFront();
Object o = evt.getTag();
if (o instanceof Contact)
{
// TODO: bring the chat with that contact to front
}
}
}

@ -65,8 +65,7 @@ private void initGUI()
this.setOpaque(false);
this.mainPanel.setOpaque(false);
BoxLayout boxLayout = new BoxLayout(
mainPanel, javax.swing.BoxLayout.Y_AXIS);
BoxLayout boxLayout = new BoxLayout(mainPanel, BoxLayout.Y_AXIS);
mainPanel.setLayout(boxLayout);
this.add(mainPanel, BorderLayout.NORTH);
@ -101,8 +100,7 @@ private void initGUI()
mainPanel.add(logHistoryPanel);
mainPanel.add(Box.createVerticalStrut(10));
logHistoryPanel.setLayout(null);
logHistoryPanel.setPreferredSize(
new java.awt.Dimension(380, 57));
logHistoryPanel.setPreferredSize(new Dimension(380, 57));
logHistoryPanel.setAlignmentX(0.0f);
{
logHistoryCheckBox = new SIPCommCheckBox();
@ -174,8 +172,7 @@ public void stateChanged(ChangeEvent e)
mainPanel.add(sendMessagePanel);
mainPanel.add(Box.createVerticalStrut(10));
sendMessagePanel.setAlignmentX(0.0f);
sendMessagePanel.setPreferredSize(
new java.awt.Dimension(380, 22));
sendMessagePanel.setPreferredSize(new Dimension(380, 22));
{
sendMessageLabel = new JLabel();
sendMessagePanel.add(
@ -211,7 +208,7 @@ public void itemStateChanged(ItemEvent arg0)
enableTypingNotifiCheckBox.setText(
Resources.getString("service.gui.ENABLE_TYPING_NOTIFICATIONS"));
enableTypingNotifiCheckBox.setPreferredSize(
new java.awt.Dimension(253, 20));
new Dimension(253, 20));
enableTypingNotifiCheckBox.setAlignmentY(0.0f);
enableTypingNotifiCheckBox.addActionListener(this);
}
@ -236,15 +233,13 @@ public void itemStateChanged(ItemEvent arg0)
{
logger.warn("Error while retrieving service refs", ex);
}
// user has choice only if there is more than one handler
if ((handlerRefs != null) && (handlerRefs.length > 1))
if (handlerRefs != null)
{
notifConfigPanel = new JPanel();
notifConfigPanel.setOpaque(false);
notifConfigPanel.setLayout(new BorderLayout(10, 10));
notifConfigPanel.setAlignmentX(0.0f);
notifConfigPanel.setPreferredSize(
new java.awt.Dimension(380, 22));
notifConfigPanel.setPreferredSize(new Dimension(380, 22));
mainPanel.add(notifConfigPanel);
mainPanel.add(Box.createVerticalStrut(10));

@ -333,10 +333,12 @@ public void removeNotificationChangeListener(
* (e.g. with systray)
* @param message the message to use if and where appropriate (e.g. with
* systray or log notification.)
* @param tag additional info to be used by the notification handler
*/
public void fireNotification( String eventType,
String messageTitle,
String message);
String message,
Object tag);
/**
* Fires all notifications registered for the specified <tt>eventType</tt>

@ -35,8 +35,8 @@ public class PopupMessage
/** type of the message */
private int messageType;
/** the contact which is the cause of this popup message */
private Contact contact;
/** additional info to be used by the <tt>PopupMessageHandler</tt> */
private Object tag;
/**
* Creates a <tt>PopupMessage</tt> with the given title and message inside
@ -94,6 +94,21 @@ public PopupMessage(JComponent component, String title, String message)
this.component = component;
}
/**
* Creates a new <tt>PopupMessage</tt> with the given
* <tt>JComponent</tt> as its content. This constructor also takes a title
* and a message as replacements in cases the component is not usable.
*
* @param component the component to put in the <tt>PopupMessage</tt>
* @param title of the message
* @param tag additional info to be used by the <tt>PopupMessageHandler</tt>
*/
public PopupMessage(String title, String message, Object tag)
{
this(title, message);
this.tag = tag;
}
/**
* @return the message
*/
@ -175,18 +190,18 @@ public void setMessageType(int messageType)
}
/**
* @return the contact
* @return the object used to tag this <tt>PopupMessage</tt>
*/
public Contact getContact()
public Object getTag()
{
return contact;
return tag;
}
/**
* @param contact the contact to set
* @param tag the object to set
*/
public void setContact(Contact contact)
public void setTag(Object tag)
{
this.contact = contact;
this.tag = tag;
}
}

@ -17,8 +17,40 @@
public class SystrayPopupMessageEvent
extends EventObject
{
/** an object to distinguish this <tt>SystrayPopupMessageEvent</tt> */
private Object tag;
public SystrayPopupMessageEvent(Object source)
{
super(source);
}
/**
* Creates a new <tt>SystrayPopupMessageEvent</tt> with the source of the
* event and additional info provided by the popup handler.
* @param source the source of the event
* @param tag additional info for listeners
*/
public SystrayPopupMessageEvent(Object source, Object tag)
{
super(source);
this.tag = tag;
}
/**
* @return the tag
*/
public Object getTag()
{
return tag;
}
/**
* @param tag the tag to set
*/
public void setTag(Object tag)
{
this.tag = tag;
}
}

@ -4,7 +4,7 @@
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.impl.gui.utils;
package net.java.sip.communicator.util.swing;
import java.awt.*;
import java.awt.image.*;
@ -14,9 +14,9 @@
* An image filter that "disables" an image by turning
* it into a grayscale image, and brightening the pixels
* in the image. Used by buttons to create an image for
* a disabled button. Creates a more brighter image than
* a disabled button. Creates a more brighter image than
* the javax.swing.GrayFilter.
*
*
* @author Yana Stamcheva
*/
public class LightGrayFilter extends GrayFilter {

@ -23,6 +23,9 @@ public class PopupNotificationPanel extends SIPCommFrame.MainContentPane
/** logger for this class */
private final Logger logger = Logger.getLogger(SIPCommFrame.class);
/** an object to distinguish this <tt>PopupNotificationPanel</tt> */
private Object tag;
/**
* Creates a new <tt>PopupNotificationPanel</tt> with a customized panel title
*/
@ -35,15 +38,20 @@ private PopupNotificationPanel()
"service.gui.SIP_COMMUNICATOR_LOGO"),
SwingConstants.LEFT);
final JLabel notifClose = new JLabel(
// JLabel notifClose = new JLabel(
// UtilActivator.getResources()
// .getImage("service.gui.lookandfeel.CLOSE_TAB_ICON"));
final SIPCommButton notifClose = new SIPCommButton(
UtilActivator.getResources()
.getImage("service.gui.lookandfeel.CLOSE_TAB_ICON"));
.getImage("service.gui.lookandfeel.CLOSE_TAB_ICON").getImage());
notifClose.setToolTipText(UtilActivator.getResources()
.getI18NString("service.gui.CLOSE"));
//notifClose.
notifClose.addMouseListener(new MouseAdapter()
notifClose.addActionListener(new ActionListener()
{
@Override
//@Override
public void mouseClicked(MouseEvent e)
{
try
@ -63,22 +71,40 @@ public void mouseClicked(MouseEvent e)
, ex);
}
}
});
BorderLayout borderLayout = new BorderLayout();
borderLayout.setVgap(5);
public void actionPerformed(ActionEvent e)
{
try
{
// TODO : that is pretty ugly. It will be nice if
// it is possible to reach the top window in a better way
JWindow jw = (JWindow) notifClose
.getParent().getParent().getParent()
.getParent().getParent().getParent();
jw.dispose();
}
catch (Exception ex)
{
// should never happens : if the user clicks on the close
// icon, it means that the popup window were visible
logger.warn("error while getting the popup window :"
, ex);
}
}
});
JPanel notificationWindowTitle = new JPanel(borderLayout);
JPanel notificationWindowTitle =
new JPanel(new BorderLayout(0, 2));
notificationWindowTitle
.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
notificationWindowTitle.setOpaque(false);
notificationWindowTitle.add(notifTitle, BorderLayout.WEST);
notificationWindowTitle.add(notifClose, BorderLayout.EAST);
JSeparator jSep = new JSeparator();
notificationWindowTitle.add(jSep, BorderLayout.SOUTH);
add(notificationWindowTitle, BorderLayout.NORTH);
setBorder(BorderFactory.createLineBorder(Color.GRAY));
}
@ -89,10 +115,28 @@ public void mouseClicked(MouseEvent e)
*
* @param notificationContent content to add in the new created
* <tt>PopupNotificationPanel</tt>
* @param tag an object to distinguish this <tt>PopupNotificationPanel</tt>
*/
public PopupNotificationPanel(JPanel notificationContent)
public PopupNotificationPanel(JPanel notificationContent, Object tag)
{
this();
add(notificationContent, BorderLayout.CENTER);
this.tag = tag;
}
/**
* @return the tag
*/
public Object getTag()
{
return tag;
}
/**
* @param tag the tag to set
*/
public void setTag(Object tag)
{
this.tag = tag;
}
}

@ -4,7 +4,7 @@
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.impl.gui.customcontrols;
package net.java.sip.communicator.util.swing;
import java.awt.*;
import java.awt.event.*;
@ -13,13 +13,10 @@
import org.jvnet.lafwidget.animation.*;
import net.java.sip.communicator.impl.gui.utils.*;
import net.java.sip.communicator.util.swing.*;
/**
* The <tt>SIPCommButton</tt> is a very flexible <tt>JButton</tt> that allows
* to configure its background, its icon, the look when a mouse is over it, etc.
*
*
* @author Yana Stamcheva
*/
public class SIPCommButton
@ -33,7 +30,7 @@ public class SIPCommButton
/**
* Creates a button with custom background image and icon image.
*
*
* @param bgImage The background image.
* @param pressedImage The pressed image.
* @param iconImage The icon.
@ -69,7 +66,7 @@ public SIPCommButton( Image bgImage,
/**
* Creates a button with custom background image.
*
*
* @param bgImage The background button image.
*/
public SIPCommButton( Image bgImage,
@ -80,7 +77,7 @@ public SIPCommButton( Image bgImage,
/**
* Creates a button with custom background image.
*
*
* @param bgImage The background button image.
*/
public SIPCommButton(Image bgImage)
@ -90,7 +87,7 @@ public SIPCommButton(Image bgImage)
/**
* Resets the background image for this button.
*
*
* @param bgImage the new image to set.
*/
public void setImage(Image bgImage)
@ -104,7 +101,7 @@ public void setImage(Image bgImage)
* Overrides the <code>paintComponent</code> method of <tt>JButton</tt> to
* paint the button background and icon, and all additional effects of this
* configurable button.
*
*
* @param g The Graphics object.
*/
protected void paintComponent(Graphics g)
@ -219,7 +216,7 @@ else if (isContentAreaFilled() || (visibility != 0.0f))
/**
* Returns the background image of this button.
*
*
* @return the background image of this button.
*/
public Image getBackgroundImage()
@ -229,7 +226,7 @@ public Image getBackgroundImage()
/**
* Sets the background image of this button.
*
*
* @param bgImage the background image of this button.
*/
public void setBackgroundImage(Image bgImage)

@ -4,23 +4,20 @@
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.impl.gui.customcontrols;
package net.java.sip.communicator.util.swing;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import net.java.sip.communicator.impl.gui.utils.*;
import net.java.sip.communicator.util.swing.*;
import org.jvnet.lafwidget.animation.*;
/**
* The <tt>SIPCommToggleButton</tt> is a flexible <tt>JToggleButton</tt> that
* allows to configure its background, its icon, the look when a mouse is over
* it, etc.
*
*
* @author Yana Stamcheva
*/
public class SIPCommToggleButton
@ -49,14 +46,14 @@ public SIPCommToggleButton()
/**
* Creates a button with custom background image, rollover image and
* icon image.
*
*
* @param bgImage The background image.
* @param rolloverImage The roll over image.
* @param iconImage The icon.
* @param pressedImage The image used to paint the pressed state.
*/
public SIPCommToggleButton( Image bgImage,
Image rolloverImage,
Image rolloverImage,
Image iconImage,
Image pressedImage)
{
@ -77,7 +74,7 @@ public SIPCommToggleButton( Image bgImage,
/**
* Creates a button with custom background image and rollover image.
*
*
* @param bgImage The background button image.
* @param rolloverImage The rollover button image.
*/
@ -90,10 +87,10 @@ public SIPCommToggleButton(Image bgImage, Image rolloverImage)
* Overrides the <code>paintComponent</code> method of <tt>JButton</tt>
* to paint the button background and icon, and all additional effects
* of this configurable button.
*
*
* @param g The Graphics object.
*/
public void paintComponent(Graphics g)
{
g = g.create();
@ -109,7 +106,7 @@ public void paintComponent(Graphics g)
/**
* Paints this button.
*
*
* @param g The Graphics object.
*/
private void internalPaintComponent(Graphics g)
@ -249,10 +246,10 @@ public void setIconImage(Image iconImage)
this.iconImage = iconImage;
this.repaint();
}
/**
* Sets the image representing the pressed state of this button.
*
*
* @param pressedImage The image representing the pressed state of this
* button.
*/

@ -128,7 +128,8 @@ public void testNotificationHandling()
notificationService.fireNotification(
NotificationService.ACTION_POPUP_MESSAGE,
messageStart,
messageStart);
messageStart,
null);
}
/** A trivial handler implementing <tt>PopupMessageHandler</tt> */

Loading…
Cancel
Save