diff options
author | Yana Stamcheva <yana@jitsi.org> | 2009-04-29 15:19:03 +0000 |
---|---|---|
committer | Yana Stamcheva <yana@jitsi.org> | 2009-04-29 15:19:03 +0000 |
commit | d9ed67e0c41f6a4d3aaff78b866e6fa4dc0aa198 (patch) | |
tree | 728c15ae63b994855e0ed127ee8e6f5ff9181e6d /src/net/java | |
parent | 7076dcd63d71db20af40cace061765f56514765c (diff) | |
download | jitsi-d9ed67e0c41f6a4d3aaff78b866e6fa4dc0aa198.zip jitsi-d9ed67e0c41f6a4d3aaff78b866e6fa4dc0aa198.tar.gz jitsi-d9ed67e0c41f6a4d3aaff78b866e6fa4dc0aa198.tar.bz2 |
New smileys pack and some improvements of the smileys box look and feel.
Diffstat (limited to 'src/net/java')
-rw-r--r-- | src/net/java/sip/communicator/impl/gui/lookandfeel/SIPCommMenuItemUI.java | 67 | ||||
-rwxr-xr-x | src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationPanel.java | 18 | ||||
-rwxr-xr-x | src/net/java/sip/communicator/impl/gui/main/chat/ChatWindow.java | 6 | ||||
-rwxr-xr-x | src/net/java/sip/communicator/impl/gui/main/chat/ChatWritePanel.java | 2 | ||||
-rw-r--r-- | src/net/java/sip/communicator/impl/gui/main/chat/SmileysSelectorBox.java (renamed from src/net/java/sip/communicator/impl/gui/main/chat/SmiliesSelectorBox.java) | 152 | ||||
-rw-r--r-- | src/net/java/sip/communicator/impl/gui/main/chat/toolBars/EditTextToolBar.java | 22 | ||||
-rw-r--r-- | src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java | 107 | ||||
-rw-r--r-- | src/net/java/sip/communicator/impl/gui/utils/Smiley.java | 83 |
8 files changed, 275 insertions, 182 deletions
diff --git a/src/net/java/sip/communicator/impl/gui/lookandfeel/SIPCommMenuItemUI.java b/src/net/java/sip/communicator/impl/gui/lookandfeel/SIPCommMenuItemUI.java index 7b19ff4..385b871 100644 --- a/src/net/java/sip/communicator/impl/gui/lookandfeel/SIPCommMenuItemUI.java +++ b/src/net/java/sip/communicator/impl/gui/lookandfeel/SIPCommMenuItemUI.java @@ -22,6 +22,12 @@ import net.java.sip.communicator.util.swing.*; public class SIPCommMenuItemUI extends BasicMenuItemUI { + public SIPCommMenuItemUI() + { + UIManager.put("MenuItem.selectionBackground", Color.WHITE); + UIManager.put("MenuItem.background", Color.WHITE); + } + /** * Creates a new SIPCommMenuItemUI instance. */ @@ -30,54 +36,41 @@ public class SIPCommMenuItemUI return new SIPCommMenuItemUI(); } - /** - * Draws the background of the menu item. - * - * @param g the paint graphics - * @param menuItem menu item to be painted - * @param bgColor selection background color - * @since 1.4 - */ - protected void paintBackground(Graphics g, JMenuItem menuItem, Color bgColor) - { - super.paintBackground(g, menuItem, bgColor); - - g = g.create(); - try - { - internalPaintBackground(g, menuItem, bgColor); - } - finally - { - g.dispose(); - } - } - - private void internalPaintBackground(Graphics g, JMenuItem menuItem, - Color bgColor) + private void internalPaintRollover(Graphics g, JMenuItem menuItem) { AntialiasingManager.activateAntialiasing(g); - + ButtonModel model = menuItem.getModel(); Color oldColor = g.getColor(); - + int menuWidth = menuItem.getWidth(); int menuHeight = menuItem.getHeight(); - if (menuItem.isOpaque()) { + if (menuItem.isOpaque()) + { if (model.isArmed() - || (menuItem instanceof JMenu && model.isSelected())) { - g.setColor(bgColor); - g.fillRoundRect(0, 0, menuWidth, menuHeight, 5, 5); - + || (menuItem instanceof JMenu && model.isSelected())) + { g.setColor(SIPCommLookAndFeel.getControlDarkShadow()); - g.drawRoundRect(0, 0, menuWidth - 1, menuHeight - 1, 5, 5); - } - else { - g.setColor(menuItem.getBackground()); - g.fillRoundRect(0, 0, menuWidth, menuHeight, 5, 5); + g.drawRoundRect(0, 0, menuWidth - 1, menuHeight - 1, 10, 10); } g.setColor(oldColor); } } + + protected void paintMenuItem (Graphics g, JComponent c, Icon + checkIcon, Icon arrowIcon, Color background, + Color foreground, int defaultTextIconGap) + { + super.paintMenuItem(g, c, null, arrowIcon, background, foreground, 0); + + this.internalPaintRollover(g, menuItem); + } + + protected void paintText (Graphics g, JMenuItem menuItem, Rectangle + textRect, String text) + { + textRect.x += 6; + super.paintText(g, menuItem, textRect, text); + } } 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 ca87be2..768e95a 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 @@ -28,7 +28,7 @@ import net.java.sip.communicator.util.*; /** * The <tt>ChatConversationPanel</tt> is the panel, where all sent and received * messages appear. All data is stored in an HTML document. An external CSS file - * is applied to the document to provide the look&feel. All smilies and link + * is applied to the document to provide the look&feel. All smileys and link * strings are processed and finally replaced by corresponding images and HTML * links. * @@ -567,7 +567,7 @@ public class ChatConversationPanel } /** - * Formats the given message. Processes all smilies chars, new lines and all + * Formats the given message. Processes all smileys chars, new lines and all * the links. * * @return the formatted message @@ -577,7 +577,7 @@ public class ChatConversationPanel String processedString = message; // If the message content type is HTML we won't process links and - // new lines, but only the smilies. + // new lines, but only the smileys. if (contentType == null || !contentType.equals(HTML_CONTENT_TYPE)) { String linkProcessedString = processLinks(message); @@ -593,7 +593,7 @@ public class ChatConversationPanel contentType); } - return processSmilies(processedString, contentType); + return processSmileys(processedString, contentType); } /** @@ -672,12 +672,12 @@ public class ChatConversationPanel } /** - * Formats message smilies. + * Formats message smileys. * * @param message The source message string. - * @return The message string with properly formated smilies. + * @return The message string with properly formated smileys. */ - private String processSmilies(String message, String contentType) + private String processSmileys(String message, String contentType) { String startPlainTextTag; String endPlainTextTag; @@ -694,13 +694,13 @@ public class ChatConversationPanel endPlainTextTag = ""; } - Collection<Smiley> smilies = ImageLoader.getDefaultSmiliesPack(); + Collection<Smiley> smileys = ImageLoader.getDefaultSmileysPack(); StringBuffer regexp = new StringBuffer(); regexp.append("(?<!(alt='|alt=\"))("); - for (Smiley smiley : smilies) + for (Smiley smiley : smileys) { for (String smileyString : smiley.getSmileyStrings()) { diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/ChatWindow.java b/src/net/java/sip/communicator/impl/gui/main/chat/ChatWindow.java index 022815a..e46ca77 100755 --- a/src/net/java/sip/communicator/impl/gui/main/chat/ChatWindow.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/ChatWindow.java @@ -161,7 +161,7 @@ public class ChatWindow new CopyAction()); this.addKeybindingAction( "plugin.keybindings.CHAT_PASTE", new PasteAction()); - this.addKeybindingAction( "chat-openSmilies", + this.addKeybindingAction( "chat-openSmileys", new OpenSmileyAction()); this.addKeybindingAction( "chat-openHistory", new OpenHistoryAction()); @@ -608,7 +608,7 @@ public class ChatWindow /** * The <tt>OpenSmileyAction</tt> is an <tt>AbstractAction</tt> that - * opens the menu, containing all available smilies' icons. + * opens the menu, containing all available smileys' icons. */ private class OpenSmileyAction extends AbstractAction @@ -616,7 +616,7 @@ public class ChatWindow public void actionPerformed(ActionEvent e) { getCurrentChatPanel().getChatWritePanel() - .getEditTextToolBar().getSmiliesSelectorBox().open(); + .getEditTextToolBar().getSmileysSelectorBox().open(); } } 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 02ef187..149e21b 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 @@ -499,7 +499,7 @@ public class ChatWritePanel /** * Appends the given text to the end of the contained HTML document. This - * method is used to insert smilies when user selects a smiley from the + * method is used to insert smileys when user selects a smiley from the * menu. * * @param text the text to append. diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/SmiliesSelectorBox.java b/src/net/java/sip/communicator/impl/gui/main/chat/SmileysSelectorBox.java index db1baf7f..3c6cb5f 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/SmiliesSelectorBox.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/SmileysSelectorBox.java @@ -13,22 +13,25 @@ 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.lookandfeel.*; import net.java.sip.communicator.impl.gui.utils.*; import net.java.sip.communicator.util.swing.*; /** - * The <tt>SmiliesSelectorBox</tt> is the component where user could choose a + * The <tt>SmileysSelectorBox</tt> is the component where user could choose a * smiley icon to send. * * @author Yana Stamcheva */ -public class SmiliesSelectorBox +public class SmileysSelectorBox extends SIPCommMenuBar - implements ActionListener + implements ActionListener, + MouseListener { private final ChatWritePanel chatWritePanel; - private final Collection<Smiley> imageList; + private final Hashtable<JMenuItem, Smiley> smileysList + = new Hashtable<JMenuItem, Smiley>(); private int gridRowCount = 0; @@ -36,20 +39,20 @@ public class SmiliesSelectorBox private final SIPCommMenu selectorBox = new SIPCommMenu(); - private final SelectorBoxRolloverListener rolloverListener = - new SelectorBoxRolloverListener(); + private final GridBagConstraints gridBagConstraints + = new GridBagConstraints(); + + private final JLabel smileyTextLabel = new JLabel(); /** - * Creates an instance of this <tt>SmiliesSelectorBox</tt> and initializes + * Creates an instance of this <tt>SmileysSelectorBox</tt> and initializes * the panel with the smiley icons given by the incoming imageList. * * @param imageList The pack of smiley icons. */ - public SmiliesSelectorBox(Collection<Smiley> imageList, + public SmileysSelectorBox(Collection<Smiley> imageList, ChatWritePanel writePanel) { - this.imageList = imageList; - this.chatWritePanel = writePanel; this.setOpaque(false); @@ -57,35 +60,35 @@ public class SmiliesSelectorBox // Should explicitly remove any border in order to align correctly the // icon. - this.selectorBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); - + this.selectorBox.setBorder(BorderFactory.createEmptyBorder()); this.selectorBox.setIcon(new ImageIcon(ImageLoader .getImage(ImageLoader.SMILIES_ICON))); this.calculateGridDimensions(imageList.size()); - this.selectorBox.getPopupMenu().setLayout( - new GridLayout(this.gridRowCount, this.gridColCount, 5, 5)); + JPopupMenu popupMenu = this.selectorBox.getPopupMenu(); + popupMenu.setLayout(new GridBagLayout()); + popupMenu.setBackground(Color.WHITE); + + int count = 0; for (Smiley smiley : imageList) { - ImageIcon imageIcon = - new ImageIcon(ImageLoader.getImage(smiley.getImageID())); - - JMenuItem smileyItem = new JMenuItem(imageIcon); + this.addSmileyToGrid(smiley, count); - // smileyItem.setPreferredSize( - // new Dimension( imageIcon.getIconWidth(), - // imageIcon.getIconHeight())); + count++; + } - // smileyItem.setMargin(new Insets(2, 2, 2, 2)); + smileyTextLabel.setPreferredSize(new Dimension(50, 25)); + smileyTextLabel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0)); - smileyItem.setToolTipText(smiley.getSmileyStrings()[0]); + gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = gridRowCount; + gridBagConstraints.gridwidth = gridColCount; - smileyItem.addActionListener(this); + popupMenu.add(smileyTextLabel, gridBagConstraints); - this.selectorBox.add(smileyItem); - } this.add(selectorBox); } @@ -109,7 +112,35 @@ public class SmiliesSelectorBox } /** - * Opens the smilies selector box. + * Adds the given smiley to the grid of the selector box popup menu. + * + * @param smiley the smiley to add + * @param smileyIndex the index of the smiley in the table + */ + private void addSmileyToGrid( Smiley smiley, + int smileyIndex) + { + ImageIcon imageIcon = + new ImageIcon(ImageLoader.getImage(smiley.getImageID())); + + SmileyMenuItem smileyItem = new SmileyMenuItem(imageIcon); + + smileyItem.setPreferredSize(new Dimension(36, 36)); + + smileyItem.addActionListener(this); + smileyItem.addMouseListener(this); + + gridBagConstraints.anchor = GridBagConstraints.EAST; + gridBagConstraints.gridx = smileyIndex%gridColCount; + gridBagConstraints.gridy = smileyIndex%gridRowCount; + + selectorBox.getPopupMenu().add(smileyItem, gridBagConstraints); + + smileysList.put(smileyItem, smiley); + } + + /** + * Opens the smileys selector box. */ public void open() { @@ -127,25 +158,20 @@ public class SmiliesSelectorBox } /** - * Writes the symbol corresponding to a choosen smiley icon to the write + * Writes the symbol corresponding to a chosen smiley icon to the write * message area at the end of the current text. */ public void actionPerformed(ActionEvent e) { JMenuItem smileyItem = (JMenuItem) e.getSource(); - String buttonText = smileyItem.getToolTipText(); - for (Smiley smiley : imageList) - { - String smileyString = smiley.getSmileyStrings()[0]; + Smiley smiley = smileysList.get(smileyItem); - if (buttonText.equals(smileyString)) - { - chatWritePanel.appendText(smileyString); + chatWritePanel.appendText(smiley.getSmileyStrings()[0]); - chatWritePanel.getEditorPane().requestFocus(); - } - } + chatWritePanel.getEditorPane().requestFocus(); + + smileyTextLabel.setText(""); } /** @@ -165,40 +191,40 @@ public class SmiliesSelectorBox .getColor("service.gui.CHAT_MENU_FOREGROUND"))); } - /** - * Enables or disabled the roll-over effect, when user moves the mouse over - * this smilies selector box. - * - * @param isRollover <code>true</code> to enable the roll-over, - * <code>false</code> - otherwise. - */ - public void setRollover(boolean isRollover) + public void paintComponent(Graphics g) { - if (isRollover) - selectorBox.addMouseListener(rolloverListener); - else - selectorBox.removeMouseListener(rolloverListener); } - /** - * Handles <tt>MouseEvent</tt>s and changes the state of the contained - * selector box in order to make a roll-over effect. - */ - private class SelectorBoxRolloverListener - extends MouseAdapter + private class SmileyMenuItem extends JMenuItem { - public void mouseEntered(MouseEvent e) + public SmileyMenuItem(Icon imageIcon) { - selectorBox.setMouseOver(true); + super(imageIcon); + this.setUI(new SIPCommMenuItemUI()); } + } - public void mouseExited(MouseEvent e) - { - selectorBox.setMouseOver(false); - } + public void mouseEntered(MouseEvent e) + { + JMenuItem smileyItem = (JMenuItem) e.getSource(); + + Smiley smiley = smileysList.get(smileyItem); + + smileyTextLabel.setText(smiley.getDescription() + + " - " + smiley.getSmileyStrings()[0]); } - public void paintComponent(Graphics g) + public void mouseExited(MouseEvent e) { + smileyTextLabel.setText(""); } + + public void mouseClicked(MouseEvent e) + {} + + public void mousePressed(MouseEvent e) + {} + + public void mouseReleased(MouseEvent e) + {} } 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 367d99c..4c69ad6 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 @@ -48,7 +48,7 @@ public class EditTextToolBar ImageLoader.getImage(ImageLoader.EDIT_TOOLBAR_BUTTON), ImageLoader.getImage(ImageLoader.FONT_ICON)); - private SmiliesSelectorBox smiliesBox; + private SmileysSelectorBox smileysBox; private JToggleButton boldButton; @@ -75,14 +75,14 @@ public class EditTextToolBar this.initColorLabel(); - this.smiliesBox = new SmiliesSelectorBox( - ImageLoader.getDefaultSmiliesPack(), chatWritePanel); + this.smileysBox = new SmileysSelectorBox( + ImageLoader.getDefaultSmileysPack(), chatWritePanel); - this.smiliesBox.setName("smiley"); - this.smiliesBox.setToolTipText(GuiActivator.getResources() + this.smileysBox.setName("smiley"); + this.smileysBox.setToolTipText(GuiActivator.getResources() .getI18NString("service.gui.INSERT_SMILEY") + " Ctrl-M"); - this.add(smiliesBox); + this.add(smileysBox); logger.trace("[GUI] Editor Pane font name: " + chatEditorPane.getFont().getName()); @@ -477,13 +477,13 @@ public class EditTextToolBar } /** - * Returns the button used to show the list of smilies. + * Returns the button used to show the list of smileys. * - * @return the button used to show the list of smilies. + * @return the button used to show the list of smileys. */ - public SmiliesSelectorBox getSmiliesSelectorBox() + public SmileysSelectorBox getSmileysSelectorBox() { - return smiliesBox; + return smileysBox; } /** @@ -494,7 +494,7 @@ public class EditTextToolBar */ public boolean hasSelectedMenus() { - if(smiliesBox.isMenuSelected()) + if(smileysBox.isMenuSelected()) return true; return false; diff --git a/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java b/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java index ed2e81a..969b560 100644 --- a/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java +++ b/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java @@ -1036,84 +1036,133 @@ public class ImageLoader */ public static final ImageID SMILEY1 - = new ImageID("service.gui.smilies.SMILEY1"); + = new ImageID("service.gui.smileys.SMILEY1"); public static final ImageID SMILEY2 - = new ImageID("service.gui.smilies.SMILEY2"); + = new ImageID("service.gui.smileys.SMILEY2"); public static final ImageID SMILEY3 - = new ImageID("service.gui.smilies.SMILEY3"); + = new ImageID("service.gui.smileys.SMILEY3"); public static final ImageID SMILEY4 - = new ImageID("service.gui.smilies.SMILEY4"); + = new ImageID("service.gui.smileys.SMILEY4"); public static final ImageID SMILEY5 - = new ImageID("service.gui.smilies.SMILEY5"); + = new ImageID("service.gui.smileys.SMILEY5"); public static final ImageID SMILEY6 - = new ImageID("service.gui.smilies.SMILEY6"); + = new ImageID("service.gui.smileys.SMILEY6"); public static final ImageID SMILEY7 - = new ImageID("service.gui.smilies.SMILEY7"); + = new ImageID("service.gui.smileys.SMILEY7"); public static final ImageID SMILEY8 - = new ImageID("service.gui.smilies.SMILEY8"); + = new ImageID("service.gui.smileys.SMILEY8"); public static final ImageID SMILEY9 - = new ImageID("service.gui.smilies.SMILEY9"); + = new ImageID("service.gui.smileys.SMILEY9"); public static final ImageID SMILEY10 - = new ImageID("service.gui.smilies.SMILEY10"); + = new ImageID("service.gui.smileys.SMILEY10"); public static final ImageID SMILEY11 - = new ImageID("service.gui.smilies.SMILEY11"); + = new ImageID("service.gui.smileys.SMILEY11"); public static final ImageID SMILEY12 - = new ImageID("service.gui.smilies.SMILEY12"); + = new ImageID("service.gui.smileys.SMILEY12"); + + public static final ImageID SMILEY13 + = new ImageID("service.gui.smileys.SMILEY13"); + + public static final ImageID SMILEY14 + = new ImageID("service.gui.smileys.SMILEY14"); + + public static final ImageID SMILEY15 + = new ImageID("service.gui.smileys.SMILEY15"); + + public static final ImageID SMILEY16 + = new ImageID("service.gui.smileys.SMILEY16"); + + public static final ImageID SMILEY17 + = new ImageID("service.gui.smileys.SMILEY17"); + + public static final ImageID SMILEY18 + = new ImageID("service.gui.smileys.SMILEY18"); + + public static final ImageID SMILEY19 + = new ImageID("service.gui.smileys.SMILEY19"); + + public static final ImageID SMILEY20 + = new ImageID("service.gui.smileys.SMILEY20"); /** - * Load default smilies pack. + * Load default smileys pack. * - * @return the ArrayList of all smilies. + * @return the ArrayList of all smileys. */ - public static Collection<Smiley> getDefaultSmiliesPack() { + public static Collection<Smiley> getDefaultSmileysPack() { List<Smiley> defaultPackList = new ArrayList<Smiley>(); defaultPackList.add(new Smiley(ImageLoader.SMILEY1, new String[] { - ";-(", ";(", ":'(", ":'-(", ":~-(", ":~(" })); + ":((", ":-((", ":((", ":(", ":-(", "(sad)"}, "Sad")); defaultPackList.add(new Smiley(ImageLoader.SMILEY2, new String[] { - "B-)", "B)" })); + "(angel)" }, "Angel")); defaultPackList.add(new Smiley(ImageLoader.SMILEY3, new String[] { - ":-*", ":*" })); + ":-*", ":*", "(kiss)"}, "Kiss")); defaultPackList.add(new Smiley(ImageLoader.SMILEY4, new String[] { - ":-0" })); + ":-0", "(shocked)"}, "Shocked")); defaultPackList.add(new Smiley(ImageLoader.SMILEY5, new String[] { - ":-((", ":((" })); + ";-((", ";((", ";-(", ";(", ":'(", ":'-(", + ":~-(", ":~(", "(upset)" }, "Upset")); defaultPackList.add(new Smiley(ImageLoader.SMILEY6, new String[] { - "(L)" , "(l)"})); + "(L)" , "(l)", "(H)", "(h)"}, "In love")); defaultPackList.add(new Smiley(ImageLoader.SMILEY7, new String[] { - ":-|", ":|" })); + "(blush)"}, "Blushing")); defaultPackList.add(new Smiley(ImageLoader.SMILEY8, new String[] { - ":-P", ":P", ":-p", ":p" })); + ":-P", ":P", ":-p", ":p" }, "Tongue out")); defaultPackList.add(new Smiley(ImageLoader.SMILEY9, new String[] { - ":-))", ":))" })); + ":-))", ":))", ";-))", ";))", "(lol)"}, "Laughing")); defaultPackList.add(new Smiley(ImageLoader.SMILEY10, new String[] { - ":-(", ":(" })); + "(y)", "(Y)", "(ok)"}, "Ok")); defaultPackList.add(new Smiley(ImageLoader.SMILEY11, new String[] { - ":-)", ":)" })); + ";-)", ";)", ":-)", ":)"}, "Smile")); defaultPackList.add(new Smiley(ImageLoader.SMILEY12, new String[] { - ";-)", ";)" })); + "(sick)"}, "Sick")); + + defaultPackList.add(new Smiley(ImageLoader.SMILEY13, new String[] { + "(n)", "(N)" }, "No")); + + defaultPackList.add(new Smiley(ImageLoader.SMILEY14, new String[] { + "(chuckle)" }, "Chuckle")); + + defaultPackList.add(new Smiley(ImageLoader.SMILEY15, new String[] { + "(wave)" }, "Waving")); + + defaultPackList.add(new Smiley(ImageLoader.SMILEY16, new String[] { + "(clap)"}, "Clapping")); + + defaultPackList.add(new Smiley(ImageLoader.SMILEY17, new String[] { + "(angry)"}, "Angry")); + + defaultPackList.add(new Smiley(ImageLoader.SMILEY18, new String[] { + "(bomb)"}, "Explosing")); + + defaultPackList.add(new Smiley(ImageLoader.SMILEY19, new String[] { + "(search)"}, "Searching")); + + defaultPackList.add(new Smiley(ImageLoader.SMILEY20, new String[] { + "(oops)"}, "Oops")); return defaultPackList; } @@ -1124,9 +1173,9 @@ public class ImageLoader * @return A Smiley object for a given smiley string. */ public static Smiley getSmiley(String smileyString) { - Collection<Smiley> smilies = getDefaultSmiliesPack(); + Collection<Smiley> smileys = getDefaultSmileysPack(); - for (Smiley smiley : smilies) { + for (Smiley smiley : smileys) { String[] smileyStrings = smiley.getSmileyStrings(); for (int j = 0; j < smileyStrings.length; j++) { diff --git a/src/net/java/sip/communicator/impl/gui/utils/Smiley.java b/src/net/java/sip/communicator/impl/gui/utils/Smiley.java index 0482199..66d6c71 100644 --- a/src/net/java/sip/communicator/impl/gui/utils/Smiley.java +++ b/src/net/java/sip/communicator/impl/gui/utils/Smiley.java @@ -16,76 +16,101 @@ import net.java.sip.communicator.service.resources.*; * * @author Yana Stamcheva */ -public class Smiley { - +public class Smiley +{ private ImageID imageID; private String[] smileyStrings; + private String description; + /** - * Creates an instance of <tt>Smily</tt>, by specifying the smily + * Creates an instance of <tt>Smiley</tt>, by specifying the smiley * image identifier and the strings corresponding to it. - * @param imageID The image identifier of the smily icon. - * @param smileyStrings A set of strings corresponding to the smily + * @param imageID The image identifier of the smiley icon. + * @param smileyStrings A set of strings corresponding to the smiley * icon. */ - public Smiley(ImageID imageID, String[] smileyStrings) { - + public Smiley(ImageID imageID, String[] smileyStrings, String description) + { this.imageID = imageID; this.setSmileyStrings(smileyStrings); + + this.setDescription(description); } /** - * Returns the set of Strings corresponding to this smily. - * @return the set of Strings corresponding to this smily. + * Returns the set of Strings corresponding to this smiley. + * @return the set of Strings corresponding to this smiley. */ - public String[] getSmileyStrings() { - + public String[] getSmileyStrings() + { return smileyStrings; } /** - * Sets the set of Strings corresponding to this smily. They could be + * Sets the set of Strings corresponding to this smiley. They could be * ":-)", ":)", ":))" for example. - * @param smileyStrings the set of Strings corresponding to this smily. + * @param smileyStrings the set of Strings corresponding to this smiley. */ - public void setSmileyStrings(String[] smileyStrings) { - + public void setSmileyStrings(String[] smileyStrings) + { this.smileyStrings = smileyStrings; } /** - * Returns the default String corresponding for this smily. For example - * ":-)". - * @return the default String corresponding for this smily. + * Returns the description of this smiley. + * + * @return the description of this smiley. */ - public String getDefaultString() { + public String getDescription() + { + return description; + } - return this.smileyStrings[0]; + /** + * Sets the description of this smiley. + * + * @param description the description of the smiley. + */ + public void setDescription(String description) + { + this.description = description; } /** - * Returns the identifier of the image corresponding to this smily. - * @return the identifier of the image corresponding to this smily. + * Returns the default String corresponding for this smiley. For example + * ":-)". + * @return the default String corresponding for this smiley. */ - public ImageID getImageID() { + public String getDefaultString() + { + return this.smileyStrings[0]; + } + /** + * Returns the identifier of the image corresponding to this smiley. + * @return the identifier of the image corresponding to this smiley. + */ + public ImageID getImageID() + { return this.imageID; } /** - * Returns the path of the image corresponding to this smily. - * @return the path of the image corresponding to this smily. + * Returns the path of the image corresponding to this smiley. + * @return the path of the image corresponding to this smiley. */ public String getImagePath() { - URL url = - GuiActivator.getResources().getImageURL(this.getImageID().getId()); - + URL url + = GuiActivator.getResources() + .getImageURL(this.getImageID().getId()); + if(url == null) return null; - + return url.toString(); } } |