From b6864dd2be1af2910c9799b8dd7fe819164eb48c Mon Sep 17 00:00:00 2001 From: Derek DeMoro Date: Mon, 13 Nov 2006 07:31:14 +0000 Subject: [PATCH] Update EmoticonPack. git-svn-id: http://svn.igniterealtime.org/svn/repos/spark/trunk@6088 b35dd754-fafc-0310-a699-88a17e54d16e --- build/installer/spark.install4j | 4 +--- .../spark/ui/TranscriptWindow.java | 11 +++++++---- .../spark/ui/themes/ThemePanel.java | 19 +++++++++++++++++-- .../plugin/emoticons/EmoticonManager.java | 5 +++++ 4 files changed, 30 insertions(+), 9 deletions(-) diff --git a/build/installer/spark.install4j b/build/installer/spark.install4j index 31f2cf04..412d9907 100644 --- a/build/installer/spark.install4j +++ b/build/installer/spark.install4j @@ -1,5 +1,5 @@ - + @@ -174,8 +174,6 @@ - - diff --git a/src/java/org/jivesoftware/spark/ui/TranscriptWindow.java b/src/java/org/jivesoftware/spark/ui/TranscriptWindow.java index 9d3377be..c312a562 100644 --- a/src/java/org/jivesoftware/spark/ui/TranscriptWindow.java +++ b/src/java/org/jivesoftware/spark/ui/TranscriptWindow.java @@ -21,6 +21,7 @@ import org.jivesoftware.spark.SparkManager; import org.jivesoftware.spark.component.VerticalFlowLayout; import org.jivesoftware.spark.ui.themes.ThemeManager; import org.jivesoftware.spark.util.ModelUtil; +import org.jivesoftware.spark.util.URLFileSystem; import org.jivesoftware.spark.util.log.Log; import org.jivesoftware.sparkimpl.plugin.emoticons.Emoticon; import org.jivesoftware.sparkimpl.plugin.emoticons.EmoticonManager; @@ -171,13 +172,13 @@ public class TranscriptWindow extends JPanel { public void insertCustomMessage(String prefix, String message) { message = filterBody(message); - String text = themeManager.getOutgoingMessage(prefix, "", message, null); + String text = themeManager.getOutgoingMessage(prefix, "", message, vcardManager.getAvatar("")); executeScript("appendMessage('" + text + "')"); } public void insertCustomOtherMessage(String prefix, String message) { message = filterBody(message); - String text = themeManager.getIncomingMessage(prefix, "", message, null); + String text = themeManager.getIncomingMessage(prefix, "", message, vcardManager.getAvatar("")); executeScript("appendMessage('" + text + "')"); } @@ -198,7 +199,7 @@ public class TranscriptWindow extends JPanel { } String body = message.getBody(); - body = filterBody(body); + try { DelayInformation inf = (DelayInformation)message.getExtension("x", "jabber:x:delay"); @@ -215,6 +216,7 @@ public class TranscriptWindow extends JPanel { String theDate = getDate(sentDate); body = org.jivesoftware.spark.util.StringUtils.escapeHTMLTags(body); + body = filterBody(body); if (userid.equals(activeUser)) { String text = themeManager.getNextIncomingMessage(body, theDate); @@ -506,7 +508,7 @@ public class TranscriptWindow extends JPanel { StringBuilder builder = new StringBuilder(); - final StringTokenizer tokenizer = new StringTokenizer(text, "> \n \t", true); + final StringTokenizer tokenizer = new StringTokenizer(text, " \n \t", true); while (tokenizer.hasMoreTokens()) { String textFound = tokenizer.nextToken(); if (textFound.startsWith("http://") || textFound.startsWith("ftp://") @@ -516,6 +518,7 @@ public class TranscriptWindow extends JPanel { else if (emoticonManager.getEmoticon(textFound) != null) { Emoticon emot = emoticonManager.getEmoticon(textFound); URL url = emoticonManager.getEmoticonURL(emot); + File file = URLFileSystem.url2File(url); builder.append(""); } else { diff --git a/src/java/org/jivesoftware/spark/ui/themes/ThemePanel.java b/src/java/org/jivesoftware/spark/ui/themes/ThemePanel.java index 80e09b3b..153ede7c 100644 --- a/src/java/org/jivesoftware/spark/ui/themes/ThemePanel.java +++ b/src/java/org/jivesoftware/spark/ui/themes/ThemePanel.java @@ -16,6 +16,7 @@ import org.jivesoftware.spark.ui.TranscriptWindow; import org.jivesoftware.spark.util.ResourceUtils; import org.jivesoftware.spark.util.URLFileSystem; import org.jivesoftware.spark.util.WindowsFileSystemView; +import org.jivesoftware.sparkimpl.plugin.emoticons.Emoticon; import org.jivesoftware.sparkimpl.plugin.emoticons.EmoticonManager; import org.jivesoftware.sparkimpl.settings.local.LocalPreferences; import org.jivesoftware.sparkimpl.settings.local.SettingsManager; @@ -127,12 +128,14 @@ public class ThemePanel extends JPanel { emoticonBox.addItem(pack); } - String activePack = pref.getEmoticonPack(); + final String activePack = pref.getEmoticonPack(); emoticonBox.setSelectedItem(activePack); emoticonBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { emoticonManager.addEmoticonPack((String)emoticonBox.getSelectedItem()); + emoticonManager.setActivePack((String)emoticonBox.getSelectedItem()); + showSelectedTheme(); } }); @@ -175,6 +178,18 @@ public class ThemePanel extends JPanel { transcript.insertNotificationMessage("Welcome to this theme."); transcript.executeScript(("appendMessage('" + message1 + "')")); transcript.executeScript("appendMessage('" + message2 + "')"); + + StringBuilder builder = new StringBuilder(); + + EmoticonManager emoticonManager = EmoticonManager.getInstance(); + for (Emoticon emoticon : emoticonManager.getActiveEmoticonSet()) { + String eq = emoticon.getEquivalants().get(0); + builder.append(eq); + builder.append(" "); + } + + + transcript.insertCustomMessage("Emoticon Man:", builder.toString()); } public String getSelectedTheme() { @@ -241,7 +256,7 @@ public class ThemePanel extends JPanel { try { EmoticonManager emoticonManager = EmoticonManager.getInstance(); String name = emoticonManager.installPack(pack); - + // If the name does not exists, add it to the message box. for (int i = 0; i < emoticonBox.getItemCount(); i++) { String n = (String)messageStyleBox.getItemAt(i); diff --git a/src/java/org/jivesoftware/sparkimpl/plugin/emoticons/EmoticonManager.java b/src/java/org/jivesoftware/sparkimpl/plugin/emoticons/EmoticonManager.java index d9285295..9e758dc2 100644 --- a/src/java/org/jivesoftware/sparkimpl/plugin/emoticons/EmoticonManager.java +++ b/src/java/org/jivesoftware/sparkimpl/plugin/emoticons/EmoticonManager.java @@ -107,6 +107,11 @@ public class EmoticonManager { return emoticonPack; } + public void setActivePack(String pack) { + final LocalPreferences pref = SettingsManager.getLocalPreferences(); + pref.setEmoticonPack(pack); + } + public String installPack(File pack) { String name = null; // Copy to the emoticon area