From fecc1bc966159c745cd1b23e49dc4ef5e89e08a3 Mon Sep 17 00:00:00 2001 From: Symphorien Wanko Date: Fri, 20 Feb 2009 17:59:58 +0000 Subject: [PATCH] enhancements to the swing popup notification, new behavior for the trayicon, minors code tweak --- build.xml | 2 +- resources/images/images.properties | 1 + resources/images/logo/sc_logo_39x58.png | Bin 0 -> 3243 bytes resources/languages/resources.properties | 6 +- .../gui/customcontrols/ChatToolbarButton.java | 1 + .../gui/lookandfeel/SIPCommLookAndFeel.java | 3 +- .../gui/lookandfeel/SIPCommTextFieldUI.java | 1 - .../impl/gui/main/call/CallDialog.java | 1 - .../impl/gui/main/call/CallManager.java | 3 +- .../gui/main/call/CallParticipantPanel.java | 1 - .../impl/gui/main/call/DialPanel.java | 2 +- .../impl/gui/main/call/HoldButton.java | 2 +- .../impl/gui/main/call/MuteButton.java | 2 +- .../gui/main/call/ReceivedCallDialog.java | 1 - .../impl/gui/main/call/SecurityPanel.java | 1 - .../gui/main/call/TransferCallButton.java | 2 +- .../gui/main/chat/ChatConversationPanel.java | 2 + .../impl/gui/main/chat/ChatWritePanel.java | 2 + .../main/chat/toolBars/EditTextToolBar.java | 1 - .../gui/main/contactlist/ActionMenuPanel.java | 1 - .../contactlist/ContactProtocolButton.java | 2 +- .../impl/gui/utils/ConfigurationManager.java | 58 +++++++------- .../impl/gui/utils/NotificationManager.java | 8 +- .../notification/NotificationServiceImpl.java | 11 ++- .../PopupMessageHandlerSwingImpl.java | 74 +++++++++++------- .../swingnotification.manifest.mf | 1 + .../impl/systray/jdic/LightGrayFilter.java | 46 ----------- .../systray/jdic/StatusSimpleSelector.java | 1 + .../systray/jdic/SystrayServiceJdicImpl.java | 63 ++++++--------- .../GeneralConfigurationPanel.java | 17 ++-- .../notification/NotificationService.java | 4 +- .../service/systray/PopupMessage.java | 31 ++++++-- .../event/SystrayPopupMessageEvent.java | 32 ++++++++ .../utils => util/swing}/LightGrayFilter.java | 6 +- .../util/swing/PopupNotificationPanel.java | 66 +++++++++++++--- .../swing}/SIPCommButton.java | 21 +++-- .../swing}/SIPCommToggleButton.java | 23 +++--- .../TestPopupMessageHandler.java | 3 +- 38 files changed, 270 insertions(+), 232 deletions(-) create mode 100644 resources/images/logo/sc_logo_39x58.png delete mode 100644 src/net/java/sip/communicator/impl/systray/jdic/LightGrayFilter.java rename src/net/java/sip/communicator/{impl/gui/utils => util/swing}/LightGrayFilter.java (92%) rename src/net/java/sip/communicator/{impl/gui/customcontrols => util/swing}/SIPCommButton.java (97%) rename src/net/java/sip/communicator/{impl/gui/customcontrols => util/swing}/SIPCommToggleButton.java (97%) diff --git a/build.xml b/build.xml index c03eec5ca..4c0a5d2ce 100644 --- a/build.xml +++ b/build.xml @@ -912,6 +912,7 @@ + @@ -1311,7 +1312,6 @@ javax.swing.event, javax.swing.border"/> - diff --git a/resources/images/images.properties b/resources/images/images.properties index b8865f0bd..88a2da3ac 100644 --- a/resources/images/images.properties +++ b/resources/images/images.properties @@ -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 diff --git a/resources/images/logo/sc_logo_39x58.png b/resources/images/logo/sc_logo_39x58.png new file mode 100644 index 0000000000000000000000000000000000000000..10d0be4ecfb1f4b8666a0d1679189cd9806de41a GIT binary patch literal 3243 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 is a SIPCommButton that has diff --git a/src/net/java/sip/communicator/impl/gui/lookandfeel/SIPCommLookAndFeel.java b/src/net/java/sip/communicator/impl/gui/lookandfeel/SIPCommLookAndFeel.java index 1d9cf3c9d..f2a453e35 100644 --- a/src/net/java/sip/communicator/impl/gui/lookandfeel/SIPCommLookAndFeel.java +++ b/src/net/java/sip/communicator/impl/gui/lookandfeel/SIPCommLookAndFeel.java @@ -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. diff --git a/src/net/java/sip/communicator/impl/gui/lookandfeel/SIPCommTextFieldUI.java b/src/net/java/sip/communicator/impl/gui/lookandfeel/SIPCommTextFieldUI.java index 2fbf4b4e5..616689b15 100644 --- a/src/net/java/sip/communicator/impl/gui/lookandfeel/SIPCommTextFieldUI.java +++ b/src/net/java/sip/communicator/impl/gui/lookandfeel/SIPCommTextFieldUI.java @@ -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.*; diff --git a/src/net/java/sip/communicator/impl/gui/main/call/CallDialog.java b/src/net/java/sip/communicator/impl/gui/main/call/CallDialog.java index d23f56dd3..43bebab3c 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/CallDialog.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/CallDialog.java @@ -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.*; diff --git a/src/net/java/sip/communicator/impl/gui/main/call/CallManager.java b/src/net/java/sip/communicator/impl/gui/main/call/CallManager.java index 2af9286bb..a042a37b5 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/CallManager.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/CallManager.java @@ -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()); } diff --git a/src/net/java/sip/communicator/impl/gui/main/call/CallParticipantPanel.java b/src/net/java/sip/communicator/impl/gui/main/call/CallParticipantPanel.java index 2e66bd05e..36342e4c9 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/CallParticipantPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/CallParticipantPanel.java @@ -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.*; diff --git a/src/net/java/sip/communicator/impl/gui/main/call/DialPanel.java b/src/net/java/sip/communicator/impl/gui/main/call/DialPanel.java index 2e3e151d7..d4ff3e116 100755 --- a/src/net/java/sip/communicator/impl/gui/main/call/DialPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/DialPanel.java @@ -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 DialPanel is the panel that contains the buttons to dial a diff --git a/src/net/java/sip/communicator/impl/gui/main/call/HoldButton.java b/src/net/java/sip/communicator/impl/gui/main/call/HoldButton.java index fce4b8fd2..0402bef05 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/HoldButton.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/HoldButton.java @@ -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 CallPariticant on/off diff --git a/src/net/java/sip/communicator/impl/gui/main/call/MuteButton.java b/src/net/java/sip/communicator/impl/gui/main/call/MuteButton.java index 88660c602..1d1fa53c2 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/MuteButton.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/MuteButton.java @@ -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 diff --git a/src/net/java/sip/communicator/impl/gui/main/call/ReceivedCallDialog.java b/src/net/java/sip/communicator/impl/gui/main/call/ReceivedCallDialog.java index 2bfdd292d..617723076 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/ReceivedCallDialog.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/ReceivedCallDialog.java @@ -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.*; diff --git a/src/net/java/sip/communicator/impl/gui/main/call/SecurityPanel.java b/src/net/java/sip/communicator/impl/gui/main/call/SecurityPanel.java index e93c46979..057976e8b 100755 --- a/src/net/java/sip/communicator/impl/gui/main/call/SecurityPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/SecurityPanel.java @@ -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.*; diff --git a/src/net/java/sip/communicator/impl/gui/main/call/TransferCallButton.java b/src/net/java/sip/communicator/impl/gui/main/call/TransferCallButton.java index aea380567..932be4760 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/TransferCallButton.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/TransferCallButton.java @@ -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 Call of) an associated diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationPanel.java b/src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationPanel.java index 55c0eff6c..39fefc02d 100755 --- a/src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationPanel.java @@ -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); diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/ChatWritePanel.java b/src/net/java/sip/communicator/impl/gui/main/chat/ChatWritePanel.java index 62e6279b9..569940299 100755 --- a/src/net/java/sip/communicator/impl/gui/main/chat/ChatWritePanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/ChatWritePanel.java @@ -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()); diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/EditTextToolBar.java b/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/EditTextToolBar.java index 9f3520e3e..e37789cba 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/EditTextToolBar.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/EditTextToolBar.java @@ -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.*; diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/ActionMenuPanel.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/ActionMenuPanel.java index 62b95a6c1..5186f858f 100644 --- a/src/net/java/sip/communicator/impl/gui/main/contactlist/ActionMenuPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/ActionMenuPanel.java @@ -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.*; diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactProtocolButton.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactProtocolButton.java index fc4deef29..743f4a2a8 100644 --- a/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactProtocolButton.java +++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactProtocolButton.java @@ -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 diff --git a/src/net/java/sip/communicator/impl/gui/utils/ConfigurationManager.java b/src/net/java/sip/communicator/impl/gui/utils/ConfigurationManager.java index 4c876c8ac..777152d07 100644 --- a/src/net/java/sip/communicator/impl/gui/utils/ConfigurationManager.java +++ b/src/net/java/sip/communicator/impl/gui/utils/ConfigurationManager.java @@ -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 * ConfigurationService. - * + * * @param isVisible true to indicate that the * application should be shown, false 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")) diff --git a/src/net/java/sip/communicator/impl/gui/utils/NotificationManager.java b/src/net/java/sip/communicator/impl/gui/utils/NotificationManager.java index 5dd3ed986..005d9ee57 100644 --- a/src/net/java/sip/communicator/impl/gui/utils/NotificationManager.java +++ b/src/net/java/sip/communicator/impl/gui/utils/NotificationManager.java @@ -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); diff --git a/src/net/java/sip/communicator/impl/notification/NotificationServiceImpl.java b/src/net/java/sip/communicator/impl/notification/NotificationServiceImpl.java index cd635fef3..e7e653397 100644 --- a/src/net/java/sip/communicator/impl/notification/NotificationServiceImpl.java +++ b/src/net/java/sip/communicator/impl/notification/NotificationServiceImpl.java @@ -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); } /** diff --git a/src/net/java/sip/communicator/impl/swingnotification/PopupMessageHandlerSwingImpl.java b/src/net/java/sip/communicator/impl/swingnotification/PopupMessageHandlerSwingImpl.java index 79748e173..38c1d3949 100644 --- a/src/net/java/sip/communicator/impl/swingnotification/PopupMessageHandlerSwingImpl.java +++ b/src/net/java/sip/communicator/impl/swingnotification/PopupMessageHandlerSwingImpl.java @@ -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 = "" + message.substring(0, 77) + "..."; - else - msg = "" + 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("" + ttle); + msgTitle.setForeground(Color.DARK_GRAY); + + String msg = message; + if (message.length() > 90) + msg = message.substring(0, 87) + "..."; + JLabel msgContent = new JLabel("" + 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); } /** diff --git a/src/net/java/sip/communicator/impl/swingnotification/swingnotification.manifest.mf b/src/net/java/sip/communicator/impl/swingnotification/swingnotification.manifest.mf index edaf035df..5dc583584 100644 --- a/src/net/java/sip/communicator/impl/swingnotification/swingnotification.manifest.mf +++ b/src/net/java/sip/communicator/impl/swingnotification/swingnotification.manifest.mf @@ -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, diff --git a/src/net/java/sip/communicator/impl/systray/jdic/LightGrayFilter.java b/src/net/java/sip/communicator/impl/systray/jdic/LightGrayFilter.java deleted file mode 100644 index 3c7212759..000000000 --- a/src/net/java/sip/communicator/impl/systray/jdic/LightGrayFilter.java +++ /dev/null @@ -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; - } -} diff --git a/src/net/java/sip/communicator/impl/systray/jdic/StatusSimpleSelector.java b/src/net/java/sip/communicator/impl/systray/jdic/StatusSimpleSelector.java index 0d4cdbb38..dfb71fbca 100644 --- a/src/net/java/sip/communicator/impl/systray/jdic/StatusSimpleSelector.java +++ b/src/net/java/sip/communicator/impl/systray/jdic/StatusSimpleSelector.java @@ -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 StatusSimpleSelector is a submenu which allow to select a status diff --git a/src/net/java/sip/communicator/impl/systray/jdic/SystrayServiceJdicImpl.java b/src/net/java/sip/communicator/impl/systray/jdic/SystrayServiceJdicImpl.java index 9ccc8b0df..b44ca19b4 100644 --- a/src/net/java/sip/communicator/impl/systray/jdic/SystrayServiceJdicImpl.java +++ b/src/net/java/sip/communicator/impl/systray/jdic/SystrayServiceJdicImpl.java @@ -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 popupHandlerSet = new Hashtable(); - /** - * Stores the system time, when the main window was restored the last time - */ - private long setVisibleTime = 0; - /** * A reference of the ConfigurationService obtained from the * SystrayServiceActivator @@ -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 } } } diff --git a/src/net/java/sip/communicator/plugin/generalconfig/GeneralConfigurationPanel.java b/src/net/java/sip/communicator/plugin/generalconfig/GeneralConfigurationPanel.java index 81dc7a503..9dba1316e 100644 --- a/src/net/java/sip/communicator/plugin/generalconfig/GeneralConfigurationPanel.java +++ b/src/net/java/sip/communicator/plugin/generalconfig/GeneralConfigurationPanel.java @@ -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)); diff --git a/src/net/java/sip/communicator/service/notification/NotificationService.java b/src/net/java/sip/communicator/service/notification/NotificationService.java index 6026354c9..1998426d7 100644 --- a/src/net/java/sip/communicator/service/notification/NotificationService.java +++ b/src/net/java/sip/communicator/service/notification/NotificationService.java @@ -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 eventType diff --git a/src/net/java/sip/communicator/service/systray/PopupMessage.java b/src/net/java/sip/communicator/service/systray/PopupMessage.java index 3f8232411..60c97e057 100644 --- a/src/net/java/sip/communicator/service/systray/PopupMessage.java +++ b/src/net/java/sip/communicator/service/systray/PopupMessage.java @@ -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 PopupMessageHandler */ + private Object tag; /** * Creates a PopupMessage 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 PopupMessage with the given + * JComponent 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 PopupMessage + * @param title of the message + * @param tag additional info to be used by the PopupMessageHandler + */ + 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 PopupMessage */ - 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; } } diff --git a/src/net/java/sip/communicator/service/systray/event/SystrayPopupMessageEvent.java b/src/net/java/sip/communicator/service/systray/event/SystrayPopupMessageEvent.java index ac0f7ef9b..bdc83189e 100644 --- a/src/net/java/sip/communicator/service/systray/event/SystrayPopupMessageEvent.java +++ b/src/net/java/sip/communicator/service/systray/event/SystrayPopupMessageEvent.java @@ -17,8 +17,40 @@ public class SystrayPopupMessageEvent extends EventObject { + /** an object to distinguish this SystrayPopupMessageEvent */ + private Object tag; + public SystrayPopupMessageEvent(Object source) { super(source); } + + /** + * Creates a new SystrayPopupMessageEvent 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; + } + } diff --git a/src/net/java/sip/communicator/impl/gui/utils/LightGrayFilter.java b/src/net/java/sip/communicator/util/swing/LightGrayFilter.java similarity index 92% rename from src/net/java/sip/communicator/impl/gui/utils/LightGrayFilter.java rename to src/net/java/sip/communicator/util/swing/LightGrayFilter.java index a0660dd26..6282d2dae 100644 --- a/src/net/java/sip/communicator/impl/gui/utils/LightGrayFilter.java +++ b/src/net/java/sip/communicator/util/swing/LightGrayFilter.java @@ -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 { diff --git a/src/net/java/sip/communicator/util/swing/PopupNotificationPanel.java b/src/net/java/sip/communicator/util/swing/PopupNotificationPanel.java index 7933b5158..606a843b9 100644 --- a/src/net/java/sip/communicator/util/swing/PopupNotificationPanel.java +++ b/src/net/java/sip/communicator/util/swing/PopupNotificationPanel.java @@ -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 PopupNotificationPanel */ + private Object tag; + /** * Creates a new PopupNotificationPanel 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 * PopupNotificationPanel + * @param tag an object to distinguish this PopupNotificationPanel */ - 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; } } diff --git a/src/net/java/sip/communicator/impl/gui/customcontrols/SIPCommButton.java b/src/net/java/sip/communicator/util/swing/SIPCommButton.java similarity index 97% rename from src/net/java/sip/communicator/impl/gui/customcontrols/SIPCommButton.java rename to src/net/java/sip/communicator/util/swing/SIPCommButton.java index 6ec3199df..e0c5e8fee 100755 --- a/src/net/java/sip/communicator/impl/gui/customcontrols/SIPCommButton.java +++ b/src/net/java/sip/communicator/util/swing/SIPCommButton.java @@ -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 SIPCommButton is a very flexible JButton 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 paintComponent method of JButton 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) diff --git a/src/net/java/sip/communicator/impl/gui/customcontrols/SIPCommToggleButton.java b/src/net/java/sip/communicator/util/swing/SIPCommToggleButton.java similarity index 97% rename from src/net/java/sip/communicator/impl/gui/customcontrols/SIPCommToggleButton.java rename to src/net/java/sip/communicator/util/swing/SIPCommToggleButton.java index 823822b57..d6eef5494 100644 --- a/src/net/java/sip/communicator/impl/gui/customcontrols/SIPCommToggleButton.java +++ b/src/net/java/sip/communicator/util/swing/SIPCommToggleButton.java @@ -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 SIPCommToggleButton is a flexible JToggleButton 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 paintComponent method of JButton * 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. */ diff --git a/test/net/java/sip/communicator/slick/popupmessagehandler/TestPopupMessageHandler.java b/test/net/java/sip/communicator/slick/popupmessagehandler/TestPopupMessageHandler.java index 2a0e9eea0..c72544f50 100644 --- a/test/net/java/sip/communicator/slick/popupmessagehandler/TestPopupMessageHandler.java +++ b/test/net/java/sip/communicator/slick/popupmessagehandler/TestPopupMessageHandler.java @@ -128,7 +128,8 @@ public void testNotificationHandling() notificationService.fireNotification( NotificationService.ACTION_POPUP_MESSAGE, messageStart, - messageStart); + messageStart, + null); } /** A trivial handler implementing PopupMessageHandler */