aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/sip/communicator/util/swing
diff options
context:
space:
mode:
authorYana Stamcheva <yana@jitsi.org>2009-11-30 13:43:21 +0000
committerYana Stamcheva <yana@jitsi.org>2009-11-30 13:43:21 +0000
commite2c20d0644dfd0116174367fe9934cdb8bb0d6a8 (patch)
treeb1687faa32d3bdecaa28a8bca52903b51a886a7a /src/net/java/sip/communicator/util/swing
parent8672fbb29f5c22354156a9a7a5a42866738687ce (diff)
downloadjitsi-e2c20d0644dfd0116174367fe9934cdb8bb0d6a8.zip
jitsi-e2c20d0644dfd0116174367fe9934cdb8bb0d6a8.tar.gz
jitsi-e2c20d0644dfd0116174367fe9934cdb8bb0d6a8.tar.bz2
General:
- Enhance the SIPCommMenu to support mouse over fade effects. Conference invite dialog: - Add new contacts in the invite dialog by pressing the Enter key. - Remove selection if the user decides to enter something in the field. Conference window: - Replace the call peer arrow icon with a more visible one - Move the call transfer into the call peer menu (it was previously represented by an icon in the status bar) - Change the local user background title color in the conference (the grey was looking like disabled)
Diffstat (limited to 'src/net/java/sip/communicator/util/swing')
-rwxr-xr-xsrc/net/java/sip/communicator/util/swing/SIPCommButton.java8
-rw-r--r--src/net/java/sip/communicator/util/swing/SIPCommFrame.java4
-rw-r--r--src/net/java/sip/communicator/util/swing/SIPCommMenu.java271
-rw-r--r--src/net/java/sip/communicator/util/swing/SIPCommMenuBar.java2
-rw-r--r--src/net/java/sip/communicator/util/swing/SIPCommTextField.java6
-rw-r--r--src/net/java/sip/communicator/util/swing/SelectedObject.java80
6 files changed, 364 insertions, 7 deletions
diff --git a/src/net/java/sip/communicator/util/swing/SIPCommButton.java b/src/net/java/sip/communicator/util/swing/SIPCommButton.java
index e0c5e8f..6b1da3a 100755
--- a/src/net/java/sip/communicator/util/swing/SIPCommButton.java
+++ b/src/net/java/sip/communicator/util/swing/SIPCommButton.java
@@ -67,7 +67,8 @@ public class SIPCommButton
/**
* Creates a button with custom background image.
*
- * @param bgImage The background button image.
+ * @param bgImage the background button image
+ * @param iconImage the icon of this button
*/
public SIPCommButton( Image bgImage,
Image iconImage)
@@ -117,10 +118,13 @@ public class SIPCommButton
}
}
+ /**
+ * Paints this button.
+ * @param g the <tt>Graphics</tt> object used for painting
+ */
private void internalPaintComponent(Graphics g)
{
AntialiasingManager.activateAntialiasing(g);
-
/*
* As JComponent#paintComponent says, if you do not invoke super's
* implementation you must honor the opaque property, that is if this
diff --git a/src/net/java/sip/communicator/util/swing/SIPCommFrame.java b/src/net/java/sip/communicator/util/swing/SIPCommFrame.java
index 8ac2431..a1bf6ab 100644
--- a/src/net/java/sip/communicator/util/swing/SIPCommFrame.java
+++ b/src/net/java/sip/communicator/util/swing/SIPCommFrame.java
@@ -65,8 +65,8 @@ public abstract class SIPCommFrame
amap = rootPane.getActionMap();
amap.put("close", new CloseAction());
- imap =
- rootPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
+ imap
+ = rootPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
}
/**
diff --git a/src/net/java/sip/communicator/util/swing/SIPCommMenu.java b/src/net/java/sip/communicator/util/swing/SIPCommMenu.java
new file mode 100644
index 0000000..25b7c92
--- /dev/null
+++ b/src/net/java/sip/communicator/util/swing/SIPCommMenu.java
@@ -0,0 +1,271 @@
+/*
+ * 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.util.swing;
+
+import java.awt.*;
+import java.awt.event.*;
+
+import javax.swing.*;
+
+import org.jvnet.lafwidget.animation.*;
+
+/**
+ * The <tt>SIPCommMenu</tt> is very similar to a JComboBox. The main
+ * component here is a JLabel only with an icon. When user clicks on the icon a
+ * popup menu is opened, containing a list of icon-text pairs from which the
+ * user could choose one item. When user selects the desired item, the icon of
+ * the selected item is set to the main component label.
+ *
+ * @author Yana Stamcheva
+ */
+public class SIPCommMenu
+ extends JMenu
+{
+ private static final long serialVersionUID = 1L;
+ private Object selectedObject;
+
+ /**
+ * Creates an instance of <tt>SIPCommMenu</tt>.
+ */
+ public SIPCommMenu()
+ {
+ super();
+ init();
+ }
+
+ /**
+ * Creates an instance of <tt>SIPCommMenu</tt> by specifying
+ * the text and the icon.
+ */
+ public SIPCommMenu(String text, Icon defaultIcon)
+ {
+ super(text);
+
+ this.setIcon(defaultIcon);
+ init();
+ }
+
+ /**
+ * Creates an instance of <tt>SIPCommMenu</tt> by specifying the
+ * initialy selected item.
+ *
+ * @param text The item that is initialy selected.
+ */
+ public SIPCommMenu(String text)
+ {
+ super(text);
+ init();
+ }
+
+ private void init()
+ {
+ MouseRolloverHandler mouseHandler = new MouseRolloverHandler();
+
+ this.addMouseListener(mouseHandler);
+ this.addMouseMotionListener(mouseHandler);
+ }
+
+ /**
+ * Adds an item to the "choice list" of this selector box.
+ *
+ * @param text The text of the item.
+ * @param icon The icon of the item.
+ * @param actionListener The <tt>ActionListener</tt>, which handles the
+ * case, when the item is selected.
+ */
+ public void addItem(String text, Icon icon, ActionListener actionListener)
+ {
+ JMenuItem item = new JMenuItem(text, icon);
+
+ item.addActionListener(actionListener);
+
+ this.add(item);
+ }
+
+ /**
+ * Selects the given item.
+ *
+ * @param selectedObject The object to select.
+ */
+ public void setSelected(SelectedObject selectedObject)
+ {
+ if (selectedObject.getIcon() != null)
+ this.setIcon(selectedObject.getIcon());
+
+ if (selectedObject.getText() != null)
+ this.setText(selectedObject.getText());
+
+ if (selectedObject.getObject() != null)
+ this.setSelectedObject(selectedObject.getObject());
+ }
+
+ /**
+ * Selects the given object.
+ *
+ * @param o The <tt>Object</tt> to select.
+ */
+ public void setSelectedObject(Object o)
+ {
+ this.selectedObject = o;
+ }
+
+ /**
+ * Returns the selected object.
+ *
+ * @return the selected object.
+ */
+ public Object getSelectedObject()
+ {
+ return this.selectedObject;
+ }
+
+ /**
+ * Sets the isMouseOver property value and repaints this component.
+ *
+ * @param isMouseOver <code>true</code> to indicate that the mouse is over
+ * this component, <code>false</code> - otherwise.
+ */
+ public void setMouseOver(boolean isMouseOver)
+ {
+ this.repaint();
+ }
+
+ /**
+ * Paints this component.
+ * @param g the <tt>Graphics</tt> object used for painting
+ */
+ public void paintComponent(Graphics g)
+ {
+ g = g.create();
+ try
+ {
+ internalPaintComponent(g);
+ }
+ finally
+ {
+ g.dispose();
+ }
+ }
+
+ /**
+ * Paints a rollover effect when the mouse is over this menu.
+ * @param g the <tt>Graphics</tt> object used for painting
+ */
+ private void internalPaintComponent(Graphics g)
+ {
+ AntialiasingManager.activateAntialiasing(g);
+
+ // Paint a roll over fade out.
+ FadeTracker fadeTracker = FadeTracker.getInstance();
+
+ float visibility = getModel().isRollover() ? 1.0f : 0.0f;
+ if (fadeTracker.isTracked(this, FadeKind.ROLLOVER))
+ {
+ visibility = fadeTracker.getFade(this, FadeKind.ROLLOVER);
+ }
+
+ visibility /= 2;
+
+ g.setColor(new Color(1.0f, 1.0f, 1.0f, visibility));
+
+ g.fillRoundRect(0, 0, this.getWidth(), this.getHeight(), 10, 10);
+
+ g.setColor(UIManager.getColor("Menu.foreground"));
+
+ super.paintComponent(g);
+ }
+
+ /**
+ * The <tt>ButtonRepaintCallback</tt> is charged to repaint this button
+ * when the fade animation is performed.
+ */
+ private class ButtonRepaintCallback implements FadeTrackerCallback
+ {
+ public void fadeEnded(FadeKind arg0)
+ {
+ repaintLater();
+ }
+
+ public void fadePerformed(FadeKind arg0, float arg1)
+ {
+ repaintLater();
+ }
+
+ private void repaintLater()
+ {
+ SwingUtilities.invokeLater(new Runnable()
+ {
+ public void run()
+ {
+ SIPCommMenu.this.repaint();
+ }
+ });
+ }
+
+ public void fadeReversed(FadeKind arg0, boolean arg1, float arg2)
+ {
+ }
+ }
+
+ /**
+ * Perform a fade animation on mouse over.
+ */
+ private class MouseRolloverHandler
+ implements MouseListener,
+ MouseMotionListener
+ {
+ public void mouseMoved(MouseEvent e)
+ {
+ }
+
+ public void mouseExited(MouseEvent e)
+ {
+ if (isEnabled())
+ {
+ getModel().setRollover(false);
+
+ FadeTracker fadeTracker = FadeTracker.getInstance();
+
+ fadeTracker.trackFadeOut(FadeKind.ROLLOVER,
+ SIPCommMenu.this,
+ true,
+ new ButtonRepaintCallback());
+ }
+ }
+
+ public void mouseClicked(MouseEvent e)
+ {
+ }
+
+ public void mouseEntered(MouseEvent e)
+ {
+ if (isEnabled())
+ {
+ getModel().setRollover(true);
+
+ FadeTracker fadeTracker = FadeTracker.getInstance();
+
+ fadeTracker.trackFadeIn(FadeKind.ROLLOVER,
+ SIPCommMenu.this,
+ true,
+ new ButtonRepaintCallback());
+ }
+ }
+
+ public void mousePressed(MouseEvent e)
+ {
+ }
+
+ public void mouseReleased(MouseEvent e)
+ {
+ }
+
+ public void mouseDragged(MouseEvent e)
+ {
+ }
+ }
+}
diff --git a/src/net/java/sip/communicator/util/swing/SIPCommMenuBar.java b/src/net/java/sip/communicator/util/swing/SIPCommMenuBar.java
index 45d4d4e..10fa699 100644
--- a/src/net/java/sip/communicator/util/swing/SIPCommMenuBar.java
+++ b/src/net/java/sip/communicator/util/swing/SIPCommMenuBar.java
@@ -19,6 +19,8 @@ import net.java.sip.communicator.util.swing.plaf.*;
public class SIPCommMenuBar
extends JMenuBar
{
+ private boolean isRollover;
+
public SIPCommMenuBar()
{
this.setBorder(BorderFactory.createEmptyBorder());
diff --git a/src/net/java/sip/communicator/util/swing/SIPCommTextField.java b/src/net/java/sip/communicator/util/swing/SIPCommTextField.java
index 5475da3..8a45bd6 100644
--- a/src/net/java/sip/communicator/util/swing/SIPCommTextField.java
+++ b/src/net/java/sip/communicator/util/swing/SIPCommTextField.java
@@ -106,9 +106,9 @@ public class SIPCommTextField
*/
public void setText(String text)
{
- if (text != null && text.length() > 0)
- super.setText(text);
- else
+ super.setText(text);
+
+ if ((text == null || text.length() == 0) && !isFocusOwner())
setDefaultText();
}
diff --git a/src/net/java/sip/communicator/util/swing/SelectedObject.java b/src/net/java/sip/communicator/util/swing/SelectedObject.java
new file mode 100644
index 0000000..edd343d
--- /dev/null
+++ b/src/net/java/sip/communicator/util/swing/SelectedObject.java
@@ -0,0 +1,80 @@
+/*
+ * 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.util.swing;
+
+import javax.swing.*;
+
+/**
+ * A convenience class used to store combobox complex objects.
+ * The <tt>SelectedObject</tt> is used for all account and status combo boxes
+ * throughout this gui implementation.
+ *
+ * @author Yana Stamcheva
+ */
+public class SelectedObject
+{
+ private String text;
+
+ private Icon icon;
+
+ private Object object;
+
+ /**
+ * Creates an instance of <tt>SelectedObject</tt> by specifying the text,
+ * icon and object associated with it.
+ *
+ * @param text The text.
+ * @param icon The icon.
+ * @param object The object.
+ */
+ public SelectedObject(String text, Icon icon, Object object)
+ {
+ this.text = text;
+ this.icon = icon;
+ this.object = object;
+ }
+
+ /**
+ * Creates an instance of <tt>SelectedObject</tt> by specifying the
+ * icon and object associated with it.
+ *
+ * @param icon The icon.
+ * @param object The object.
+ */
+ public SelectedObject(Icon icon, Object object)
+ {
+ this.icon = icon;
+ this.object = object;
+ }
+
+ /**
+ * Returns the text of this <tt>SelectedObject</tt>.
+ * @return the text of this <tt>SelectedObject</tt>.
+ */
+ public String getText()
+ {
+ return text;
+ }
+
+ /**
+ * Returns the icon of this <tt>SelectedObject</tt>.
+ * @return the icon of this <tt>SelectedObject</tt>.
+ */
+ public Icon getIcon()
+ {
+ return icon;
+ }
+
+ /**
+ * Returns the real object behind this <tt>SelectedObject</tt>.
+ * @return the real object behind this <tt>SelectedObject</tt>.
+ */
+ public Object getObject()
+ {
+ return object;
+ }
+}