aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/sip/communicator/impl/systray/jdic
diff options
context:
space:
mode:
authorYana Stamcheva <yana@jitsi.org>2007-09-14 13:26:45 +0000
committerYana Stamcheva <yana@jitsi.org>2007-09-14 13:26:45 +0000
commit77db11822d8141b0edd2d4dce300a9c702948995 (patch)
treea716b37a7c6b44f31988d3f769b17a336232f02e /src/net/java/sip/communicator/impl/systray/jdic
parent2af2c9ec343b5c707c2a2eeae412052779e87cb8 (diff)
downloadjitsi-77db11822d8141b0edd2d4dce300a9c702948995.zip
jitsi-77db11822d8141b0edd2d4dce300a9c702948995.tar.gz
jitsi-77db11822d8141b0edd2d4dce300a9c702948995.tar.bz2
Systray message queue system improved.
Diffstat (limited to 'src/net/java/sip/communicator/impl/systray/jdic')
-rw-r--r--src/net/java/sip/communicator/impl/systray/jdic/SystrayServiceJdicImpl.java85
1 files changed, 75 insertions, 10 deletions
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 d4b4e58..660a29e 100644
--- a/src/net/java/sip/communicator/impl/systray/jdic/SystrayServiceJdicImpl.java
+++ b/src/net/java/sip/communicator/impl/systray/jdic/SystrayServiceJdicImpl.java
@@ -67,6 +67,8 @@ public class SystrayServiceJdicImpl
private int maxMessageNumber = 3;
+ private SystrayMessage aggregatedMessage;
+
/**
* The logger for this class.
*/
@@ -252,8 +254,8 @@ public class SystrayServiceJdicImpl
else if (messageType == SystrayService.WARNING_MESSAGE_TYPE)
trayMsgType = TrayIcon.WARNING_MESSAGE_TYPE;
- if(messageContent.length() > 100)
- messageContent = messageContent.substring(0, 100).concat("...");
+ if(messageContent.length() > 40)
+ messageContent = messageContent.substring(0, 40).concat("...");
messageQueue.add(new SystrayMessage(title, messageContent, trayMsgType));
}
@@ -341,16 +343,24 @@ public class SystrayServiceJdicImpl
{
messageQueue.clear();
- String messageContent = msg.getMessageContent();
+ if(aggregatedMessage != null)
+ {
+ aggregatedMessage
+ .addAggregatedMessageNumber(messageNumber);
+ }
+ else
+ {
+ String messageContent = msg.getMessageContent();
- if(!messageContent.endsWith("..."))
- messageContent.concat("...");
+ if(!messageContent.endsWith("..."))
+ messageContent.concat("...");
- messageQueue.add(new SystrayMessage(
- "You have received " + messageNumber
- + " new messages. For more info check your chat window.",
- "Messages starts by: " + messageContent,
- TrayIcon.INFO_MESSAGE_TYPE));
+ aggregatedMessage = new SystrayMessage(
+ "Messages start by: " + messageContent,
+ messageNumber);
+ }
+
+ messageQueue.add(aggregatedMessage);
}
else
{
@@ -359,15 +369,22 @@ public class SystrayServiceJdicImpl
msg.getMessageType());
messageQueue.remove(0);
+
+ if(msg.equals(aggregatedMessage))
+ aggregatedMessage = null;
}
}
}
+ /**
+ * Represents a systray message.
+ */
private class SystrayMessage
{
private String title;
private String messageContent;
private int messageType;
+ private int aggregatedMessageNumber;
/**
* Creates an instance of <tt>SystrayMessage</tt> by specifying the
@@ -388,6 +405,29 @@ public class SystrayServiceJdicImpl
}
/**
+ * Creates an instance of <tt>SystrayMessage</tt> by specifying the
+ * message <tt>title</tt>, the content of the message, the type of
+ * the message and the number of messages that this message has
+ * aggregated.
+ *
+ * @param messageContent the content of the message
+ * @param aggregatedMessageNumber the number of messages that this
+ * message has aggregated
+ */
+ public SystrayMessage( String messageContent,
+ int aggregatedMessageNumber)
+ {
+ this.aggregatedMessageNumber = aggregatedMessageNumber;
+
+ this.title = "You have received "
+ + aggregatedMessageNumber
+ + " new messages.";
+
+ this.messageContent = messageContent;
+ this.messageType = TrayIcon.INFO_MESSAGE_TYPE;
+ }
+
+ /**
* Returns the title of the message.
*
* @return the title of the message
@@ -416,5 +456,30 @@ public class SystrayServiceJdicImpl
{
return messageType;
}
+
+ /**
+ * Returns the number of aggregated messages this message represents.
+ *
+ * @return the number of aggregated messages this message represents.
+ */
+ public int getAggregatedMessageNumber()
+ {
+ return aggregatedMessageNumber;
+ }
+
+ /**
+ * Adds the given number of messages to the number of aggregated
+ * messages contained in this message.
+ *
+ * @param messageNumber the number of messages to add to the number of
+ * aggregated messages contained in this message
+ */
+ public void addAggregatedMessageNumber(int messageNumber)
+ {
+ this.aggregatedMessageNumber += messageNumber;
+
+ this.title = "You have received " + aggregatedMessageNumber
+ + " new messages.";
+ }
}
}