Added an icon for the auto away configuration form (by Damien ROTH)

Renamed the status update plugin to awto away
moved the getImage() and getImageBytes() methods to the ResourceManagementService
cusax-fix
Emil Ivov 18 years ago
parent 730688e450
commit fbf0168515

@ -639,7 +639,7 @@
bundle-ssh,bundle-plugin-sshaccregwizz,
bundle-contacteventhandler,bundle-plugin-contactinfo,
bundle-plugin-accountinfo,bundle-plugin-chatalerter,
bundle-plugin-statusupdate, bundle-keybindings,
bundle-plugin-autoaway, bundle-keybindings,
bundle-plugin-keybindingChooser,
bundle-jfontchooserlib,
bundle-updatecheckplugin,
@ -1553,12 +1553,12 @@ javax.swing.event, javax.swing.border"/>
</jar>
</target>
<!--BUNDLE-StatusUpdatePlugin-->
<target name="bundle-plugin-statusupdate">
<jar compress="false" destfile="${bundles.dest}/statusupdate.jar"
manifest="${src}/net/java/sip/communicator/plugin/statusupdate/statusupdate.manifest.mf">
<zipfileset dir="${dest}/net/java/sip/communicator/plugin/statusupdate"
prefix="net/java/sip/communicator/plugin/statusupdate" />
<!--BUNDLE-AutoAwayPlugin-->
<target name="bundle-plugin-autoaway">
<jar compress="false" destfile="${bundles.dest}/autoaway.jar"
manifest="${src}/net/java/sip/communicator/plugin/autoaway/autoaway.manifest.mf">
<zipfileset dir="${dest}/net/java/sip/communicator/plugin/autoaway"
prefix="net/java/sip/communicator/plugin/autoaway" />
</jar>
</target>
@ -1571,7 +1571,7 @@ javax.swing.event, javax.swing.border"/>
</jar>
</target>
<!--BUNDLE-StatusUpdatePlugin-->
<!--BUNDLE-General Config-->
<target name="bundle-plugin-generalconfig">
<jar compress="false" destfile="${bundles.dest}/generalconfig.jar"
manifest="${src}/net/java/sip/communicator/plugin/generalconfig/generalconfig.manifest.mf">

@ -126,7 +126,7 @@ felix.auto.start.60= \
reference:file:sc-bundles/accountinfo.jar \
reference:file:sc-bundles/chatalerter.jar \
reference:file:sc-bundles/shutdown.jar \
reference:file:sc-bundles/statusupdate.jar \
reference:file:sc-bundles/autoaway.jar \
reference:file:sc-bundles/keybindingChooser.jar \
reference:file:sc-bundles/generalconfig.jar \
reference:file:sc-bundles/dictaccregwizz.jar

@ -394,8 +394,12 @@ googletalkAwayIcon=resources/images/protocol/googletalk/status16x16-away.png
googletalkFfcIcon=resources/images/protocol/googletalk/status16x16-ffc.png
googletalkXaIcon=resources/images/protocol/googletalk/status16x16-xa.png
# keybinding
keybindingPluginIcon=resources/images/plugin/keybindingchooser/pluginIcon.png
# auto away (statusupdate)
autoAwayConfigIcon=resources/images/plugin/autoaway/aa-config.png
# Notification configuration form
notificationIcon=resources/images/plugin/notificationconfiguration/notificationIcon.png
playIcon=resources/images/plugin/notificationconfiguration/playIcon.png
@ -404,4 +408,5 @@ popupIcon=resources/images/plugin/notificationconfiguration/popupIcon.png
soundIcon=resources/images/plugin/notificationconfiguration/soundIcon.png
activatedIcon=resources/images/plugin/notificationconfiguration/activeIcon.png
desactivatedIcon=resources/images/plugin/notificationconfiguration/desactivatedIcon.png
foldericon=resources/images/plugin/notificationconfiguration/folder.png
foldericon=resources/images/plugin/notificationconfiguration/folder.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

@ -6,17 +6,21 @@
*/
package net.java.sip.communicator.impl.resources;
import java.awt.image.*;
import java.io.*;
import java.net.*;
import java.text.MessageFormat;
import java.text.*;
import java.util.*;
import javax.imageio.*;
import javax.swing.*;
import net.java.sip.communicator.service.resources.*;
import net.java.sip.communicator.util.*;
import org.osgi.framework.*;
/**
*
* A default implementation of the ResourceManagementService.
*
* @author Damian Minkov
*/
public class ResourceManagementServiceImpl
@ -273,6 +277,7 @@ public InputStream getImageInputStreamForPath(String path)
{
return imagePack.getClass().getClassLoader().getResourceAsStream(path);
}
/**
* Loads a stream from a given identifier.
*
@ -596,4 +601,59 @@ public Iterator getI18nStringsByLocale(Locale l)
return languageList.iterator();
}
/**
* Loads an image from a given image identifier.
*
* @param imageID The identifier of the image.
* @return The image for the given identifier.
*/
public byte[] getImageInBytes(String imageID)
{
InputStream in = getImageInputStream(imageID);
if(in == null)
return null;
byte[] image = null;
try
{
image = new byte[in.available()];
in.read(image);
}
catch (IOException e)
{
logger.error("Failed to load image:" + imageID, e);
}
return image;
}
/**
* Loads an image from a given image identifier.
*
* @param imageID The identifier of the image.
* @return The image for the given identifier.
*/
public ImageIcon getImage(String imageID)
{
BufferedImage image = null;
InputStream in = getImageInputStream(imageID);
if(in == null)
return null;
try
{
image = ImageIO.read(in);
}
catch (IOException e)
{
logger.error("Failed to load image:" + imageID, e);
}
return new ImageIcon(image);
}
}

@ -7,4 +7,5 @@ Export-Package: net.java.sip.communicator.service.resources
Import-Package: org.osgi.framework,
net.java.sip.communicator.util,
net.java.sip.communicator.service.configuration,
net.java.sip.communicator.service.configuration.event
net.java.sip.communicator.service.configuration.event,
javax.swing

@ -4,7 +4,7 @@
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.plugin.statusupdate;
package net.java.sip.communicator.plugin.autoaway;
import java.util.*;
@ -20,11 +20,11 @@
*
* @author Thomas Hofer
*/
public class StatusUpdateActivator implements BundleActivator
public class AutoAwayActivator implements BundleActivator
{
private static Logger logger = Logger
.getLogger(StatusUpdateActivator.class);
.getLogger(AutoAwayActivator.class);
static BundleContext bundleContext = null;
@ -41,9 +41,11 @@ public class StatusUpdateActivator implements BundleActivator
public void start(BundleContext bc) throws Exception
{
bundleContext = bc;
// Set config form
StatusConfigForm statusCF = new StatusConfigForm();
AutoAwayConfigForm statusCF = new AutoAwayConfigForm();
bundleContext.registerService(ConfigurationForm.class.getName(),
statusCF,
null);
@ -92,7 +94,7 @@ static void startThread()
if (thread == null || !runner.isRunning())
{
thread = new Thread(runner);
thread.setName(StatusUpdateActivator.class.getName());
thread.setName(AutoAwayActivator.class.getName());
thread.setPriority(Thread.MIN_PRIORITY);
thread.setDaemon(true);
thread.start();
@ -127,7 +129,7 @@ static void stopThread()
static ProtocolProviderService[] getProtocolProviders()
{
// get the protocol provider factory
BundleContext bundleContext = StatusUpdateActivator.bundleContext;
BundleContext bundleContext = AutoAwayActivator.bundleContext;
ServiceReference[] serRefs = null;
// String osgiFilter = "(" + ProtocolProviderFactory.PROTOCOL + "="
@ -153,8 +155,7 @@ static ProtocolProviderService[] getProtocolProviders()
for (ServiceReference serviceReference : serRefs)
{
ProtocolProviderService protocolProvider
= (ProtocolProviderService) bundleContext
ProtocolProviderService protocolProvider = (ProtocolProviderService) bundleContext
.getService(serviceReference);
pps.add(protocolProvider);
}

@ -0,0 +1,188 @@
/*
* 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.plugin.autoaway;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import net.java.sip.communicator.service.configuration.*;
import net.java.sip.communicator.service.gui.*;
/**
* The <tt>ConfigurationForm</tt> that would be added in the user interface
* configuration window.
*
* @author Damien Roth
*/
public class AutoAwayConfigForm
extends JPanel
implements ConfigurationForm
{
private JPanel mainPanel;
private JCheckBox enable;
private JSpinner timer;
/**
* Create an instance of <tt>StatusConfigForm</tt>
*/
public AutoAwayConfigForm()
{
super(new BorderLayout(10, 10));
mainPanel = new JPanel();
mainPanel.setLayout(new BorderLayout());
init();
initValues();
this.add(mainPanel);
}
/**
* Init the widgets
*/
private void init()
{
JPanel autoStatusPanel = new JPanel(new BorderLayout());
// Title : automatic status
JLabel autoStatusLabel
= new JLabel(Resources.getString("automaticStatus"));
Font bold = autoStatusLabel.getFont().deriveFont(Font.BOLD);
autoStatusLabel.setFont(bold);
JPanel fieldsPanel = new JPanel(new BorderLayout(5, 5));
fieldsPanel.setBorder(BorderFactory.createEmptyBorder(10, 30, 0, 0));
enable = new JCheckBox(Resources.getString("enableChangeStatus"));
fieldsPanel.add(enable, BorderLayout.NORTH);
enable.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
timer.setEnabled(enable.isSelected());
saveData();
}
});
JPanel timerPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
// Texte
timerPanel.add(new JLabel(Resources.getString("awayMinutes")));
// Spinner
timer = new JSpinner(new SpinnerNumberModel(15, 1, 180, 1));
timerPanel.add(timer);
timer.addChangeListener(new ChangeListener()
{
public void stateChanged(ChangeEvent e)
{
saveData();
}
});
fieldsPanel.add(timerPanel, BorderLayout.WEST);
autoStatusPanel.add(autoStatusLabel, BorderLayout.NORTH);
autoStatusPanel.add(fieldsPanel, BorderLayout.CENTER);
mainPanel.add(autoStatusPanel, BorderLayout.NORTH);
}
/**
* Init the values of the widgets
*/
private void initValues()
{
ConfigurationService configService
= AutoAwayActivator.getConfigService();
String e = (String) configService.getProperty(Preferences.ENABLE);
if (e != null)
{
try
{
this.enable.setSelected(Boolean.parseBoolean(e));
this.timer.setEnabled(Boolean.parseBoolean(e));
} catch (NumberFormatException ex)
{
this.enable.setSelected(false);
this.timer.setEnabled(false);
}
} else
{
this.enable.setSelected(false);
this.timer.setEnabled(false);
}
String t = (String) configService.getString(Preferences.TIMER);
if (t != null)
{
try
{
this.timer.setValue(Integer.parseInt(t));
} catch (NumberFormatException ex)
{
}
}
}
/**
* Save data in the configuration file
*/
private void saveData()
{
ConfigurationService configService
= AutoAwayActivator.getConfigService();
configService.setProperty(Preferences.ENABLE,
Boolean.toString(enable.isSelected()));
Integer interval = (Integer) timer.getValue();
configService.setProperty(Preferences.TIMER, interval);
}
/**
* Implements the <tt>ConfigurationForm.getForm()</tt> method. Returns the
* component corresponding to this configuration form.
*/
public Object getForm()
{
return this;
}
/**
* Implements the <tt>ConfigurationForm.getIcon()</tt> method. Returns the
* icon of this configuration form.
*/
public byte[] getIcon()
{
return Resources.getResources().getImageInBytes("autoAwayConfigIcon");
}
/**
* Implements the <tt>ConfigurationForm.getIndex()</tt> method.
*/
public int getIndex()
{
return -1;
}
/**
* Implements the <tt>ConfigurationForm.getIcon()</tt> method. Returns the
* icon of this configuration form.
*/
public String getTitle()
{
return Resources.getString("automaticStatus");
}
}

@ -4,7 +4,7 @@
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.plugin.statusupdate;
package net.java.sip.communicator.plugin.autoaway;
/**
* Preferences for the Status Update

@ -4,10 +4,15 @@
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.plugin.statusupdate;
package net.java.sip.communicator.plugin.autoaway;
import java.io.*;
import java.awt.image.*;
import javax.imageio.*;
import javax.swing.*;
import net.java.sip.communicator.service.resources.*;
import net.java.sip.communicator.util.*;
import org.osgi.framework.*;
/**
@ -18,13 +23,15 @@
*/
public class Resources
{
private static Logger logger = Logger.getLogger(Resources.class);
private static ResourceManagementService resourcesService;
/**
* Returns an internationalized string corresponding to the given key.
*
* @param key
* The key of the string.
* @param key The key of the string.
*
* @return An internationalized string corresponding to the given key.
*/
public static String getString(String key)
@ -32,18 +39,23 @@ public static String getString(String key)
return getResources().getI18NString(key);
}
/**
* Returns a reference to the resrouce management service.
*
* @return a reference to the resource management service.
*/
public static ResourceManagementService getResources()
{
if (resourcesService == null)
{
ServiceReference serviceReference = StatusUpdateActivator.bundleContext
ServiceReference serviceReference = AutoAwayActivator.bundleContext
.getServiceReference(ResourceManagementService.class.getName());
if(serviceReference == null)
return null;
resourcesService =
(ResourceManagementService)StatusUpdateActivator.bundleContext
(ResourceManagementService)AutoAwayActivator.bundleContext
.getService(serviceReference);
}

@ -4,7 +4,7 @@
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.plugin.statusupdate;
package net.java.sip.communicator.plugin.autoaway;
import java.awt.*;
import java.util.*;
@ -46,7 +46,7 @@ public void run()
// check, if a minor state has been automatically set
// and
// reset this state to the former state.
ProtocolProviderService[] pps = StatusUpdateActivator
ProtocolProviderService[] pps = AutoAwayActivator
.getProtocolProviders();
for (ProtocolProviderService protocolProviderService : pps)
@ -77,7 +77,7 @@ public void run()
// position has not changed!
// get all protocols and set them to away
ProtocolProviderService[] pps = StatusUpdateActivator
ProtocolProviderService[] pps = AutoAwayActivator
.getProtocolProviders();
for (ProtocolProviderService protocolProviderService : pps)
@ -165,7 +165,7 @@ private PresenceStatus findAwayStatus(OperationSetPresence presence)
private int getTimer()
{
ConfigurationService configService = StatusUpdateActivator
ConfigurationService configService = AutoAwayActivator
.getConfigService();
String e = (String) configService.getProperty(Preferences.ENABLE);

@ -1,6 +1,6 @@
Bundle-Activator: net.java.sip.communicator.plugin.statusupdate.StatusUpdateActivator
Bundle-Name: StatusUpdatePlugin
Bundle-Description: A bundle that automatically can update the status of your protocols
Bundle-Activator: net.java.sip.communicator.plugin.autoaway.AutoAwayActivator
Bundle-Name: AutoAwayPlugin
Bundle-Description: A bundle that would automatically put your protocols in the away status after you've been idle for a certain amount of time.
Bundle-Vendor: sip-communicator.org
Bundle-Version: 0.0.2
Import-Package: org.osgi.framework,

@ -149,15 +149,15 @@ private ImageIcon getStateIcon(int state)
switch (state)
{
case Bundle.INSTALLED:
return Resources.getImage("installedStateIcon");
return Resources.getResources().getImage("installedStateIcon");
case Bundle.RESOLVED:
return Resources.getImage("deactivatedStateIcon");
return Resources.getResources().getImage("deactivatedStateIcon");
case Bundle.STARTING:
return Resources.getImage("startingStateIcon");
return Resources.getResources().getImage("startingStateIcon");
case Bundle.ACTIVE:
return Resources.getImage("activeStateIcon");
return Resources.getResources().getImage("activeStateIcon");
case Bundle.STOPPING:
return Resources.getImage("stoppingStateIcon");
return Resources.getResources().getImage("stoppingStateIcon");
}
return null;
}

@ -151,7 +151,8 @@ public String getTitle()
*/
public byte[] getIcon()
{
return Resources.getImageInBytes("pluginIconPluginManager");
return Resources.getResources()
.getImageInBytes("pluginIconPluginManager");
}
/**

@ -26,7 +26,7 @@
*/
public class Resources
{
private static Logger log = Logger.getLogger(Resources.class);
private static Logger logger = Logger.getLogger(Resources.class);
private static ResourceManagementService resourcesService;
@ -40,64 +40,7 @@ public static String getString(String key)
{
return getResources().getI18NString(key);
}
/**
* Loads an image from a given image identifier.
*
* @param imageID The identifier of the image.
* @return The image for the given identifier.
*/
public static ImageIcon getImage(String imageID)
{
BufferedImage image = null;
InputStream in =
getResources().getImageInputStream(imageID);
if(in == null)
return null;
try
{
image = ImageIO.read(in);
}
catch (IOException e)
{
log.error("Failed to load image:" + imageID, e);
}
return new ImageIcon(image);
}
/**
* Loads an image from a given image identifier.
*
* @param imageID The identifier of the image.
* @return The image for the given identifier.
*/
public static byte[] getImageInBytes(String imageID)
{
InputStream in =
getResources().getImageInputStream(imageID);
if(in == null)
return null;
byte[] image = null;
try
{
image = new byte[in.available()];
in.read(image);
}
catch (IOException e)
{
log.error("Failed to load image:" + imageID, e);
}
return image;
}
/**
* Returns an int RGB color corresponding to the given key.
*

@ -1,189 +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.plugin.statusupdate;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import net.java.sip.communicator.service.configuration.*;
import net.java.sip.communicator.service.gui.*;
/**
* The <tt>ConfigurationForm</tt> that would be added in the user interface
* configuration window.
*
* @author ROTH Damien
*/
public class StatusConfigForm
extends JPanel
implements ConfigurationForm
{
private JPanel mainPanel;
private JCheckBox enable;
private JSpinner timer;
/**
* Create an instance of <tt>StatusConfigForm</tt>
*/
public StatusConfigForm()
{
super(new BorderLayout(10, 10));
mainPanel = new JPanel();
mainPanel.setLayout(new BorderLayout());
init();
initValues();
this.add(mainPanel);
}
/**
* Init the widgets
*/
private void init()
{
JPanel autoStatusPanel = new JPanel(new BorderLayout());
// Title : automatic status
JLabel autoStatusLabel = new JLabel(Resources.getString("automaticStatus"));
Font bold = autoStatusLabel.getFont().deriveFont(Font.BOLD);
autoStatusLabel.setFont(bold);
JPanel fieldsPanel = new JPanel(new BorderLayout(5, 5));
fieldsPanel.setBorder(BorderFactory.createEmptyBorder(10,30,0,0));
enable = new JCheckBox(Resources.getString("enableChangeStatus"));
fieldsPanel.add(enable, BorderLayout.NORTH);
enable.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
timer.setEnabled(enable.isSelected());
saveData();
}
});
JPanel timerPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
// Texte
timerPanel.add(new JLabel(Resources.getString("awayMinutes")));
// Spinner
timer = new JSpinner(new SpinnerNumberModel(15, 1, 180, 1));
timerPanel.add(timer);
timer.addChangeListener(new ChangeListener()
{
public void stateChanged(ChangeEvent e)
{
saveData();
}
});
fieldsPanel.add(timerPanel, BorderLayout.WEST);
autoStatusPanel.add(autoStatusLabel, BorderLayout.NORTH);
autoStatusPanel.add(fieldsPanel, BorderLayout.CENTER);
mainPanel.add(autoStatusPanel, BorderLayout.NORTH);
}
/**
* Init the values of the widgets
*/
private void initValues()
{
ConfigurationService configService = StatusUpdateActivator
.getConfigService();
String e = (String) configService.getProperty(Preferences.ENABLE);
if (e != null)
{
try
{
this.enable.setSelected(Boolean.parseBoolean(e));
this.timer.setEnabled(Boolean.parseBoolean(e));
}
catch (NumberFormatException ex)
{
this.enable.setSelected(false);
this.timer.setEnabled(false);
}
}
else
{
this.enable.setSelected(false);
this.timer.setEnabled(false);
}
String t = (String) configService.getString(Preferences.TIMER);
if (t != null)
{
try
{
this.timer.setValue(Integer.parseInt(t));
}
catch (NumberFormatException ex)
{
}
}
}
/**
* Save data in the configuration file
*/
private void saveData()
{
ConfigurationService configService = StatusUpdateActivator
.getConfigService();
configService.setProperty(Preferences.ENABLE, Boolean
.toString(enable.isSelected()));
Integer interval = (Integer) timer.getValue();
configService.setProperty(Preferences.TIMER, interval);
}
/**
* Implements the <tt>ConfigurationForm.getForm()</tt> method. Returns the
* component corresponding to this configuration form.
*/
public Object getForm()
{
return this;
}
/**
* Implements the <tt>ConfigurationForm.getIcon()</tt> method. Returns the
* icon of this configuration form.
*/
public byte[] getIcon()
{
return null;
}
/**
* Implements the <tt>ConfigurationForm.getIndex()</tt> method.
*/
public int getIndex()
{
return -1;
}
/**
* Implements the <tt>ConfigurationForm.getIcon()</tt> method. Returns the
* icon of this configuration form.
*/
public String getTitle()
{
return Resources.getString("automaticStatus");
}
}

@ -9,6 +9,7 @@
import java.io.*;
import java.net.*;
import java.util.*;
import javax.swing.*;
/**
*
@ -148,4 +149,23 @@ public interface ResourceManagementService
public Iterator getAvailableLocales();
public Iterator getI18nStringsByLocale(Locale l);
/**
* Constructs an <tt>ImageIcon</tt> from the specified image ID and returns
* it.
*
* @param imageID The identifier of the image.
* @return An <tt>ImageIcon</tt> containing the image with the given
* identifier.
*/
public ImageIcon getImage(String imageID);
/**
* Loads the image with the specified ID and returns a byte array
* containing it.
*
* @param imageID The identifier of the image.
* @return A byte array containing the image with the given identifier.
*/
public byte[] getImageInBytes(String imageID);
}

Loading…
Cancel
Save