aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/sip/communicator/util/swing
diff options
context:
space:
mode:
authorDamian Minkov <damencho@jitsi.org>2012-03-14 11:07:04 +0000
committerDamian Minkov <damencho@jitsi.org>2012-03-14 11:07:04 +0000
commit6485119bee78d3c893ab7403273aeadcd40ff4be (patch)
treebf27bfd2f1e185276b059349df58503dba685d45 /src/net/java/sip/communicator/util/swing
parent3285adc53cfded8a590377b8138ca54388d43a4f (diff)
downloadjitsi-6485119bee78d3c893ab7403273aeadcd40ff4be.zip
jitsi-6485119bee78d3c893ab7403273aeadcd40ff4be.tar.gz
jitsi-6485119bee78d3c893ab7403273aeadcd40ff4be.tar.bz2
Fixes missing buttons and call timer start when call is answered through global shortcut or auto-answer.
Orders buttons used in CallPanel.
Diffstat (limited to 'src/net/java/sip/communicator/util/swing')
-rw-r--r--src/net/java/sip/communicator/util/swing/OrderedComponent.java28
-rw-r--r--src/net/java/sip/communicator/util/swing/OrderedTransparentPanel.java68
-rwxr-xr-xsrc/net/java/sip/communicator/util/swing/SIPCommButton.java24
-rw-r--r--src/net/java/sip/communicator/util/swing/SIPCommToggleButton.java24
4 files changed, 144 insertions, 0 deletions
diff --git a/src/net/java/sip/communicator/util/swing/OrderedComponent.java b/src/net/java/sip/communicator/util/swing/OrderedComponent.java
new file mode 100644
index 0000000..d907c27
--- /dev/null
+++ b/src/net/java/sip/communicator/util/swing/OrderedComponent.java
@@ -0,0 +1,28 @@
+/*
+ * Jitsi, 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;
+
+/**
+ * Components (like buttons) implement this interface to be able to
+ * order them in a Ordered Transparent Panels.
+ *
+ * @author Damian Minkov
+ */
+public interface OrderedComponent
+{
+ /**
+ * Change component index when we want to order it.
+ * @param index the button index.
+ */
+ public void setIndex(int index);
+
+ /**
+ * Returns the current component index we have set, or -1 if none used.
+ * @return
+ */
+ public int getIndex();
+}
diff --git a/src/net/java/sip/communicator/util/swing/OrderedTransparentPanel.java b/src/net/java/sip/communicator/util/swing/OrderedTransparentPanel.java
new file mode 100644
index 0000000..9cc9367
--- /dev/null
+++ b/src/net/java/sip/communicator/util/swing/OrderedTransparentPanel.java
@@ -0,0 +1,68 @@
+/*
+ * Jitsi, 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.*;
+
+/**
+ * Ordered transparent panel. Components added to the panel
+ * must implement OrderedComponent to be able to order them or
+ * will leave the parent to add them as usual.
+ * @author Damian Minkov
+ */
+public class OrderedTransparentPanel
+ extends TransparentPanel
+{
+ private static final long serialVersionUID = 0L;
+
+ public Component add(Component comp)
+ {
+ if(comp instanceof OrderedComponent)
+ {
+ return addOrdered(comp);
+ }
+ else
+ return super.add(comp);
+ }
+
+ /**
+ * Method to order add OrderedComponents.
+ * @param comp the component to order.
+ * @return the component argument
+ */
+ private Component addOrdered(Component comp)
+ {
+ int orederIndex = ((OrderedComponent)comp).getIndex();
+
+ Component[] cs = getComponents();
+
+ // don't add a component if already added or it will be removed
+ // and added at the end
+ for(int i = 0; i < cs.length; i++)
+ {
+ if(cs[i].equals(comp))
+ return comp;
+ }
+
+ for(int i = 0; i < cs.length; i++)
+ {
+ Component c = cs[i];
+ int cIx;
+ if(c instanceof OrderedComponent)
+ {
+ cIx = ((OrderedComponent)c).getIndex();
+
+ if(orederIndex < cIx)
+ {
+ return super.add(comp, i);
+ }
+ }
+ }
+
+ return super.add(comp);
+ }
+}
diff --git a/src/net/java/sip/communicator/util/swing/SIPCommButton.java b/src/net/java/sip/communicator/util/swing/SIPCommButton.java
index cf37c6b..cbdea52 100755
--- a/src/net/java/sip/communicator/util/swing/SIPCommButton.java
+++ b/src/net/java/sip/communicator/util/swing/SIPCommButton.java
@@ -22,6 +22,7 @@ import org.jvnet.lafwidget.animation.*;
*/
public class SIPCommButton
extends JButton
+ implements OrderedComponent
{
/**
* Serial version UID.
@@ -41,6 +42,11 @@ public class SIPCommButton
private Image iconImage;
/**
+ * The index of the button, used when we want to order our buttons.
+ */
+ private int index = -1;
+
+ /**
* Creates a button.
*/
public SIPCommButton()
@@ -347,6 +353,24 @@ public class SIPCommButton
}
/**
+ * Change buttons index when we want to order it.
+ * @param index the button index.
+ */
+ public void setIndex(int index)
+ {
+ this.index = index;
+ }
+
+ /**
+ * Returns the current button index we have set, or -1 if none used.
+ * @return
+ */
+ public int getIndex()
+ {
+ return this.index;
+ }
+
+ /**
* The <tt>ButtonRepaintCallback</tt> is charged to repaint this button
* when the fade animation is performed.
*/
diff --git a/src/net/java/sip/communicator/util/swing/SIPCommToggleButton.java b/src/net/java/sip/communicator/util/swing/SIPCommToggleButton.java
index c8d6544..6a1ca46 100644
--- a/src/net/java/sip/communicator/util/swing/SIPCommToggleButton.java
+++ b/src/net/java/sip/communicator/util/swing/SIPCommToggleButton.java
@@ -22,6 +22,7 @@ import org.jvnet.lafwidget.animation.*;
*/
public class SIPCommToggleButton
extends JToggleButton
+ implements OrderedComponent
{
/**
* Serial version UID.
@@ -54,6 +55,11 @@ public class SIPCommToggleButton
private Image pressedIconImage;
/**
+ * The index of the button, used when we want to order our buttons.
+ */
+ private int index = -1;
+
+ /**
* Creates an instance of <tt>SIPCommToggleButton</tt>.
*/
public SIPCommToggleButton()
@@ -324,6 +330,24 @@ public class SIPCommToggleButton
}
/**
+ * Change buttons index when we want to order it.
+ * @param index the button index.
+ */
+ public void setIndex(int index)
+ {
+ this.index = index;
+ }
+
+ /**
+ * Returns the current button index we have set, or -1 if none used.
+ * @return
+ */
+ public int getIndex()
+ {
+ return this.index;
+ }
+
+ /**
* The <tt>ButtonRepaintCallback</tt> is charged to repaint this button
* when the fade animation is performed.
*/