Moves PropertyChangeListener/Event from .configuration.event to .util because they're generic and of interest to other use cases.

cusax-fix
Lyubomir Marinov 17 years ago
parent 4b85461e69
commit a376ea4cde

@ -10,6 +10,7 @@
import net.java.sip.communicator.service.configuration.*; import net.java.sip.communicator.service.configuration.*;
import net.java.sip.communicator.service.configuration.event.*; import net.java.sip.communicator.service.configuration.event.*;
import net.java.sip.communicator.util.*;
/** /**
* This is a utility class that can be used by objects that support constrained * This is a utility class that can be used by objects that support constrained

@ -4,13 +4,12 @@
* Distributable under LGPL license. * Distributable under LGPL license.
* See terms of license at gnu.org. * See terms of license at gnu.org.
*/ */
package net.java.sip.communicator.impl.gui.main; package net.java.sip.communicator.impl.gui.main;
import java.awt.*; import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
import java.awt.image.*; import java.awt.image.*;
import java.beans.*; import java.beans.PropertyChangeEvent;
import java.util.*; import java.util.*;
import java.util.List; import java.util.List;

@ -9,7 +9,8 @@
import java.awt.*; import java.awt.*;
import java.awt.Container; import java.awt.Container;
import java.awt.event.*; import java.awt.event.*;
import java.beans.*; import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.*; import java.io.*;
import java.util.*; import java.util.*;
import javax.swing.*; import javax.swing.*;

@ -10,8 +10,8 @@
import net.java.sip.communicator.impl.gui.*; import net.java.sip.communicator.impl.gui.*;
import net.java.sip.communicator.service.configuration.*; import net.java.sip.communicator.service.configuration.*;
import net.java.sip.communicator.service.configuration.event.*;
import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.util.*;
public class ConfigurationManager public class ConfigurationManager
{ {

@ -10,16 +10,13 @@
import javax.media.*; import javax.media.*;
import javax.media.format.*; import javax.media.format.*;
import net.java.sip.communicator.service.configuration.*;
import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.*;
/** /**
* This class aims to provide a simple configuration interface for JMF. * This class aims to provide a simple configuration interface for JMF. It
* It retrieves stored configuration when started or listens to * retrieves stored configuration when started or listens to ConfigurationEvent
* ConfigurationEvent for property changes and configures the JMF accordingly. * for property changes and configures the JMF accordingly.
* *
* @author Martin Andre * @author Martin Andre
* @author Emil Ivov * @author Emil Ivov
*/ */
@ -27,14 +24,6 @@ public class DeviceConfiguration
{ {
private Logger logger = Logger.getLogger(DeviceConfiguration.class); private Logger logger = Logger.getLogger(DeviceConfiguration.class);
private Object syncRoot_Config = new Object();
/**
* Our configuration listener.
*/
private ConfigurationListener configurationListener =
new ConfigurationListener();
/** /**
* The device that we'll be using for audio capture. * The device that we'll be using for audio capture.
*/ */
@ -58,8 +47,8 @@ public DeviceConfiguration()
*/ */
public void initialize() public void initialize()
{ {
//these seem to be throwing exceptions every now and then so we'll // these seem to be throwing exceptions every now and then so we'll
//blindly catch them for now // blindly catch them for now
try try
{ {
JmfDeviceDetector.detectAndConfigureCaptureDevices(); JmfDeviceDetector.detectAndConfigureCaptureDevices();
@ -72,48 +61,55 @@ public void initialize()
} }
/** /**
* Detects capture devices configured through JMF and disable audio * Detects capture devices configured through JMF and disable audio and/or
* and/or video transmission if none were found. * video transmission if none were found. Stores found devices in
* Stores found devices in audioCaptureDevice and videoCaptureDevice. * audioCaptureDevice and videoCaptureDevice.
*/ */
private void extractConfiguredCaptureDevices() private void extractConfiguredCaptureDevices()
{ {
logger.info("Scanning for configured Audio Devices."); logger.info("Scanning for configured Audio Devices.");
Vector audioCaptureDevices = CaptureDeviceManager.getDeviceList(new Vector audioCaptureDevices =
AudioFormat(AudioFormat.LINEAR, 44100, 16, CaptureDeviceManager.getDeviceList(new AudioFormat(
1));//1 means 1 channel for mono AudioFormat.LINEAR, 44100, 16, 1));// 1 means 1 channel for mono
if (audioCaptureDevices.size() < 1) { if (audioCaptureDevices.size() < 1)
{
logger.warn("No Audio Device was found."); logger.warn("No Audio Device was found.");
audioCaptureDevice = null; audioCaptureDevice = null;
} }
else { else
{
logger.debug("Found " + audioCaptureDevices.size() logger.debug("Found " + audioCaptureDevices.size()
+ " capture devices: " + audioCaptureDevices); + " capture devices: " + audioCaptureDevices);
audioCaptureDevice = (CaptureDeviceInfo) audioCaptureDevices.get(0); audioCaptureDevice = (CaptureDeviceInfo) audioCaptureDevices.get(0);
logger.info("Found " + audioCaptureDevice.getName() logger.info("Found " + audioCaptureDevice.getName()
+" as an audio capture device."); + " as an audio capture device.");
} }
logger.info("Scanning for configured Video Devices."); logger.info("Scanning for configured Video Devices.");
Vector videoCaptureDevices = CaptureDeviceManager.getDeviceList(new Vector videoCaptureDevices =
VideoFormat(VideoFormat.RGB)); CaptureDeviceManager
if (videoCaptureDevices.size() > 0) { .getDeviceList(new VideoFormat(VideoFormat.RGB));
if (videoCaptureDevices.size() > 0)
{
videoCaptureDevice = (CaptureDeviceInfo) videoCaptureDevices.get(0); videoCaptureDevice = (CaptureDeviceInfo) videoCaptureDevices.get(0);
logger.info("Found " + videoCaptureDevice.getName() logger.info("Found " + videoCaptureDevice.getName()
+ " as an RGB Video Device."); + " as an RGB Video Device.");
} }
// no RGB camera found. And what about YUV ? // no RGB camera found. And what about YUV ?
else else
{ {
videoCaptureDevices = CaptureDeviceManager.getDeviceList(new videoCaptureDevices =
VideoFormat(VideoFormat.YUV)); CaptureDeviceManager.getDeviceList(new VideoFormat(
if (videoCaptureDevices.size() > 0) { VideoFormat.YUV));
videoCaptureDevice if (videoCaptureDevices.size() > 0)
= (CaptureDeviceInfo) videoCaptureDevices.get(0); {
videoCaptureDevice =
(CaptureDeviceInfo) videoCaptureDevices.get(0);
logger.info("Found " + videoCaptureDevice.getName() logger.info("Found " + videoCaptureDevice.getName()
+ " as an YUV Video Device."); + " as an YUV Video Device.");
} }
else { else
{
logger.info("No Video Device was found."); logger.info("No Video Device was found.");
videoCaptureDevice = null; videoCaptureDevice = null;
} }
@ -122,8 +118,9 @@ private void extractConfiguredCaptureDevices()
/** /**
* Returns a device that we could use for audio capture. * Returns a device that we could use for audio capture.
*
* @return the CaptureDeviceInfo of a device that we could use for audio * @return the CaptureDeviceInfo of a device that we could use for audio
* capture. * capture.
*/ */
public CaptureDeviceInfo getAudioCaptureDevice() public CaptureDeviceInfo getAudioCaptureDevice()
{ {
@ -132,8 +129,9 @@ public CaptureDeviceInfo getAudioCaptureDevice()
/** /**
* Returns a device that we could use for video capture. * Returns a device that we could use for video capture.
*
* @return the CaptureDeviceInfo of a device that we could use for video * @return the CaptureDeviceInfo of a device that we could use for video
* capture. * capture.
*/ */
public CaptureDeviceInfo getVideoCaptureDevice() public CaptureDeviceInfo getVideoCaptureDevice()
{ {
@ -142,18 +140,21 @@ public CaptureDeviceInfo getVideoCaptureDevice()
/** /**
* Enable or disable Audio stream transmission. * Enable or disable Audio stream transmission.
*
* @return true if audio capture is supported and false otherwise. * @return true if audio capture is supported and false otherwise.
*/ */
public boolean isAudioCaptureSupported() { public boolean isAudioCaptureSupported()
{
return this.audioCaptureDevice != null; return this.audioCaptureDevice != null;
} }
/** /**
* Enable or disable Video stream transmission. * Enable or disable Video stream transmission.
*
* @return true if audio capture is supported and false otherwise. * @return true if audio capture is supported and false otherwise.
*/ */
public boolean isVideoCaptureSupported() { public boolean isVideoCaptureSupported()
{
return this.videoCaptureDevice != null; return this.videoCaptureDevice != null;
} }
} }

@ -6,7 +6,7 @@
*/ */
package net.java.sip.communicator.impl.protocol.icq; package net.java.sip.communicator.impl.protocol.icq;
import java.beans.*; import java.beans.PropertyChangeEvent;
import java.util.*; import java.util.*;
import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.*;

@ -6,7 +6,7 @@
*/ */
package net.java.sip.communicator.impl.protocol.irc; package net.java.sip.communicator.impl.protocol.irc;
import java.beans.*; import java.beans.PropertyChangeEvent;
import java.util.*; import java.util.*;
import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.*;

@ -6,7 +6,7 @@
*/ */
package net.java.sip.communicator.impl.protocol.jabber; package net.java.sip.communicator.impl.protocol.jabber;
import java.beans.*; import java.beans.PropertyChangeEvent;
import java.util.*; import java.util.*;
import net.java.sip.communicator.impl.protocol.jabber.extensions.version.*; import net.java.sip.communicator.impl.protocol.jabber.extensions.version.*;

@ -6,7 +6,7 @@
*/ */
package net.java.sip.communicator.impl.protocol.jabber; package net.java.sip.communicator.impl.protocol.jabber;
import java.beans.*; import java.beans.PropertyChangeEvent;
import java.util.*; import java.util.*;
import org.jivesoftware.smack.*; import org.jivesoftware.smack.*;

@ -6,7 +6,7 @@
*/ */
package net.java.sip.communicator.impl.protocol.msn; package net.java.sip.communicator.impl.protocol.msn;
import java.beans.*; import java.beans.PropertyChangeEvent;
import java.util.*; import java.util.*;
import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.*;

@ -9,7 +9,7 @@
import java.net.*; import java.net.*;
import java.text.*; import java.text.*;
import java.util.*; import java.util.*;
import java.beans.*; import java.beans.PropertyChangeEvent;
import java.io.*; import java.io.*;
import javax.sip.*; import javax.sip.*;

@ -6,7 +6,7 @@
*/ */
package net.java.sip.communicator.impl.protocol.yahoo; package net.java.sip.communicator.impl.protocol.yahoo;
import java.beans.*; import java.beans.PropertyChangeEvent;
import java.io.*; import java.io.*;
import java.util.*; import java.util.*;
import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.*;

@ -4,11 +4,10 @@
* Distributable under LGPL license. * Distributable under LGPL license.
* See terms of license at gnu.org. * See terms of license at gnu.org.
*/ */
package net.java.sip.communicator.impl.systray.jdic; package net.java.sip.communicator.impl.systray.jdic;
import java.awt.*; import java.awt.*;
import java.beans.*; import java.beans.PropertyChangeEvent;
import java.util.*; import java.util.*;
import javax.swing.*; import javax.swing.*;

@ -10,6 +10,7 @@
import java.util.*; import java.util.*;
import net.java.sip.communicator.service.configuration.event.*; import net.java.sip.communicator.service.configuration.event.*;
import net.java.sip.communicator.util.*;
import net.java.sip.communicator.util.xml.*; import net.java.sip.communicator.util.xml.*;
/** /**

@ -6,7 +6,7 @@
*/ */
package net.java.sip.communicator.service.configuration; package net.java.sip.communicator.service.configuration;
import net.java.sip.communicator.service.configuration.event.*; import net.java.sip.communicator.util.*;
/** /**
* A PropertyVetoException is thrown when a proposed change to a * A PropertyVetoException is thrown when a proposed change to a

@ -1,107 +0,0 @@
/*
* 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.service.configuration.event;
/**
* A "ConfigurationChange" event gets delivered whenever a someone changes a
* configuration property. A ConfigurationEvent object is sent as an
* argument to the ConfigurationChangeListener methods.
* <P>
* Normally ConfigurationChangeEvents are accompanied by the name and the old
* and new values of the changed property. If the new value is a primitive
* type (such as int or boolean) it must be wrapped as the
* corresponding java.lang.* Object type (such as Integer or Boolean).
* <P>
* Null values may be provided for the old and the new values if their
* true values are not known.
* <P>
* An event source may send a null object as the name to indicate that an
* arbitrary set of if its properties have changed. In this case the
* old and new values should also be null.
* <P>
* In the case where the event reflects the change of a constrained property,
* it will first be dispatched to all propertyWillChange methods and only in
* case that none of them has objected (no ChangeVetoException has been thrown)
* the propertyChange method is called.
*
* @author Emil Ivov
*/
public class PropertyChangeEvent
extends java.util.EventObject
{
/**
* name of the property that changed. May be null, if not known.
* @serial
*/
private String propertyName;
/**
* New value for property. May be null if not known.
* @serial
*/
private Object newValue;
/**
* Previous value for property. May be null if not known.
* @serial
*/
private Object oldValue;
/**
* Constructs a new <tt>PropertyChangeEvent</tt>.
*
* @param source The bean that fired the event.
* @param propertyName The programmatic name of the property
* that was changed.
* @param oldValue The old value of the property.
* @param newValue The new value of the property.
*/
public PropertyChangeEvent(Object source, String propertyName,
Object oldValue, Object newValue)
{
super(source);
this.propertyName = propertyName;
this.newValue = newValue;
this.oldValue = oldValue;
}
/**
* Gets the programmatic name of the property that was changed.
*
* @return The programmatic name of the property that was changed.
* May be null if multiple properties have changed.
*/
public String getPropertyName()
{
return propertyName;
}
/**
* Sets the new value for the property, expressed as an Object.
*
* @return The new value for the property, expressed as an Object.
* May be null if multiple properties have changed.
*/
public Object getNewValue()
{
return newValue;
}
/**
* Gets the old value for the property, expressed as an Object.
*
* @return The old value for the property, expressed as an Object.
* May be null if multiple properties have changed.
*/
public Object getOldValue()
{
return oldValue;
}
}

@ -9,6 +9,7 @@
import java.util.*; import java.util.*;
import net.java.sip.communicator.service.configuration.*; import net.java.sip.communicator.service.configuration.*;
import net.java.sip.communicator.util.*;
/** /**
* A VetoableChange event gets fired whenever a property is about to change. * A VetoableChange event gets fired whenever a property is about to change.

@ -0,0 +1,111 @@
/*
* 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;
import java.util.*;
/**
* A "ConfigurationChange" event gets delivered whenever a someone changes a
* configuration property. A ConfigurationEvent object is sent as an argument to
* the ConfigurationChangeListener methods.
* <P>
* Normally ConfigurationChangeEvents are accompanied by the name and the old
* and new values of the changed property. If the new value is a primitive type
* (such as int or boolean) it must be wrapped as the corresponding java.lang.*
* Object type (such as Integer or Boolean).
* <P>
* Null values may be provided for the old and the new values if their true
* values are not known.
* <P>
* An event source may send a null object as the name to indicate that an
* arbitrary set of if its properties have changed. In this case the old and new
* values should also be null.
* <P>
* In the case where the event reflects the change of a constrained property, it
* will first be dispatched to all propertyWillChange methods and only in case
* that none of them has objected (no ChangeVetoException has been thrown) the
* propertyChange method is called.
*
* @author Emil Ivov
*/
public class PropertyChangeEvent
extends EventObject
{
/**
* name of the property that changed. May be null, if not known.
*
* @serial
*/
private final String propertyName;
/**
* New value for property. May be null if not known.
*
* @serial
*/
private final Object newValue;
/**
* Previous value for property. May be null if not known.
*
* @serial
*/
private final Object oldValue;
/**
* Constructs a new <tt>PropertyChangeEvent</tt>.
*
* @param source The bean that fired the event.
* @param propertyName The programmatic name of the property that was
* changed.
* @param oldValue The old value of the property.
* @param newValue The new value of the property.
*/
public PropertyChangeEvent(Object source, String propertyName,
Object oldValue, Object newValue)
{
super(source);
this.propertyName = propertyName;
this.newValue = newValue;
this.oldValue = oldValue;
}
/**
* Gets the programmatic name of the property that was changed.
*
* @return The programmatic name of the property that was changed. May be
* null if multiple properties have changed.
*/
public String getPropertyName()
{
return propertyName;
}
/**
* Sets the new value for the property, expressed as an Object.
*
* @return The new value for the property, expressed as an Object. May be
* null if multiple properties have changed.
*/
public Object getNewValue()
{
return newValue;
}
/**
* Gets the old value for the property, expressed as an Object.
*
* @return The old value for the property, expressed as an Object. May be
* null if multiple properties have changed.
*/
public Object getOldValue()
{
return oldValue;
}
}

@ -4,24 +4,25 @@
* Distributable under LGPL license. * Distributable under LGPL license.
* See terms of license at gnu.org. * See terms of license at gnu.org.
*/ */
package net.java.sip.communicator.service.configuration.event; package net.java.sip.communicator.util;
import java.util.*;
/** /**
* A "ConfigurationChange" event gets fired whenever a configuration property * A "ConfigurationChange" event gets fired whenever a configuration property
* changes. Depending on whether the property was constrained or not, the * changes. Depending on whether the property was constrained or not, the
* propertyChange or vetoableChange methods get called. * propertyChange or vetoableChange methods get called.
* *
* @author Emil Ivov * @author Emil Ivov
*/ */
public interface PropertyChangeListener extends java.util.EventListener public interface PropertyChangeListener
extends EventListener
{ {
/** /**
* This method gets called when a bound property is changed. * This method gets called when a bound property is changed.
* @param evt A PropertyChangeEvent object describing the event source *
* and the property that has changed. * @param evt A PropertyChangeEvent object describing the event source and
* the property that has changed.
*/ */
void propertyChange(PropertyChangeEvent evt); void propertyChange(PropertyChangeEvent evt);
} }

@ -12,6 +12,7 @@
import junit.framework.*; import junit.framework.*;
import net.java.sip.communicator.service.configuration.*; import net.java.sip.communicator.service.configuration.*;
import net.java.sip.communicator.service.configuration.event.*; import net.java.sip.communicator.service.configuration.event.*;
import net.java.sip.communicator.util.*;
/** /**
* Tests basic ConfiguratioService behaviour. * Tests basic ConfiguratioService behaviour.

@ -6,7 +6,7 @@
*/ */
package net.java.sip.communicator.slick.protocol.gibberish; package net.java.sip.communicator.slick.protocol.gibberish;
import java.beans.*; import java.beans.PropertyChangeEvent;
import java.util.*; import java.util.*;
import junit.framework.*; import junit.framework.*;

@ -6,7 +6,7 @@
*/ */
package net.java.sip.communicator.slick.protocol.icq; package net.java.sip.communicator.slick.protocol.icq;
import java.beans.*; import java.beans.PropertyChangeEvent;
import java.io.*; import java.io.*;
import java.util.*; import java.util.*;

@ -6,7 +6,7 @@
*/ */
package net.java.sip.communicator.slick.protocol.icq; package net.java.sip.communicator.slick.protocol.icq;
import java.beans.*; import java.beans.PropertyChangeEvent;
import java.util.*; import java.util.*;
import junit.framework.*; import junit.framework.*;

@ -6,7 +6,7 @@
*/ */
package net.java.sip.communicator.slick.protocol.jabber; package net.java.sip.communicator.slick.protocol.jabber;
import java.beans.*; import java.beans.PropertyChangeEvent;
import java.util.*; import java.util.*;
import junit.framework.*; import junit.framework.*;

@ -6,7 +6,7 @@
*/ */
package net.java.sip.communicator.slick.protocol.msn; package net.java.sip.communicator.slick.protocol.msn;
import java.beans.*; import java.beans.PropertyChangeEvent;
import java.util.*; import java.util.*;
import junit.framework.*; import junit.framework.*;

@ -6,7 +6,7 @@
*/ */
package net.java.sip.communicator.slick.protocol.sip; package net.java.sip.communicator.slick.protocol.sip;
import java.beans.*; import java.beans.PropertyChangeEvent;
import java.util.*; import java.util.*;
import junit.framework.*; import junit.framework.*;

@ -6,7 +6,7 @@
*/ */
package net.java.sip.communicator.slick.protocol.yahoo; package net.java.sip.communicator.slick.protocol.yahoo;
import java.beans.*; import java.beans.PropertyChangeEvent;
import java.util.*; import java.util.*;
import junit.framework.*; import junit.framework.*;

Loading…
Cancel
Save