@ -0,0 +1,384 @@
|
||||
/*
|
||||
* 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.notificationconfiguration;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import javax.swing.table.*;
|
||||
|
||||
/**
|
||||
* @author Alexandre Maillard
|
||||
*/
|
||||
class ListModel extends DefaultTableModel
|
||||
{
|
||||
ListModel(Object[] columns, int rowCount)
|
||||
{
|
||||
super(columns, rowCount);
|
||||
}
|
||||
|
||||
public Class getColumnClass(int c)
|
||||
{
|
||||
return getValueAt(0, c).getClass();
|
||||
}
|
||||
|
||||
/* non editable cell */
|
||||
public boolean isCellEditable(int row, int col)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class MyRenderer implements TableCellRenderer
|
||||
{
|
||||
// Create a JLabel for use as a renderer and pre-load this label
|
||||
// with an icon image.
|
||||
|
||||
private JLabel l;
|
||||
|
||||
MyRenderer(JLabel JLIcon)
|
||||
{
|
||||
this.l = JLIcon;
|
||||
}
|
||||
|
||||
public Component getTableCellRendererComponent (
|
||||
JTable table,
|
||||
Object value,
|
||||
boolean isSelected,
|
||||
boolean hasFocus,
|
||||
int row,
|
||||
int column)
|
||||
{
|
||||
// Extract the original header renderer for this column.
|
||||
|
||||
TableCellRenderer tcr = table.getTableHeader().getDefaultRenderer ();
|
||||
|
||||
// Extract the component used to render the column header.
|
||||
|
||||
Component c = tcr.getTableCellRendererComponent (
|
||||
table,
|
||||
value,
|
||||
isSelected,
|
||||
hasFocus,
|
||||
row,
|
||||
column);
|
||||
|
||||
// Establish the font, foreground color, and border for the
|
||||
// JLabel so that the rendered header will look the same as the
|
||||
// other rendered headers.
|
||||
|
||||
l.setFont (c.getFont ());
|
||||
l.setForeground (c.getForeground ());
|
||||
l.setBorder (((JComponent) c).getBorder ());
|
||||
|
||||
// Establish the column name.
|
||||
|
||||
l.setText ((String) value);
|
||||
|
||||
// Return the cached JLabel a the renderer for this column
|
||||
// header.
|
||||
|
||||
return l;
|
||||
}
|
||||
}
|
||||
|
||||
class MyTableRenderer extends DefaultTableCellRenderer
|
||||
{
|
||||
MyTableRenderer()
|
||||
{
|
||||
super();
|
||||
}
|
||||
public Component getTableCellRendererComponent(
|
||||
JTable table,
|
||||
Object value,
|
||||
boolean isSelected,
|
||||
boolean hasFocus,
|
||||
int row,
|
||||
int column)
|
||||
{
|
||||
if(column == 0)
|
||||
{
|
||||
if(((String)value).equals("enable") == true)
|
||||
{
|
||||
setIcon(new ImageIcon(
|
||||
Resources.getImageInBytes("activatedIcon")));
|
||||
setText(null);
|
||||
setHorizontalAlignment(SwingConstants.CENTER);
|
||||
}
|
||||
else
|
||||
{
|
||||
setIcon(new ImageIcon(
|
||||
Resources.getImageInBytes("desactivatedIcon")));
|
||||
setText(null);
|
||||
setHorizontalAlignment(SwingConstants.CENTER);
|
||||
}
|
||||
}
|
||||
else if(column == 1)
|
||||
{
|
||||
if(((String)value).equals("Yes") == true)
|
||||
{
|
||||
setIcon(new ImageIcon(Resources.getImageInBytes("progIcon")));
|
||||
setText(null);
|
||||
setHorizontalAlignment(SwingConstants.CENTER);
|
||||
}
|
||||
else
|
||||
{
|
||||
setIcon(null);
|
||||
setText(null);
|
||||
}
|
||||
}
|
||||
else if(column == 2)
|
||||
{
|
||||
if(((String)value).equals("Yes") == true)
|
||||
{
|
||||
setIcon(new ImageIcon(Resources.getImageInBytes("popupIcon")));
|
||||
setText(null);
|
||||
setHorizontalAlignment(SwingConstants.CENTER);
|
||||
}
|
||||
else
|
||||
{
|
||||
setIcon(null);
|
||||
setText(null);
|
||||
}
|
||||
}
|
||||
else if(column == 3)
|
||||
{
|
||||
if(((String)value).equals("Yes") == true)
|
||||
{
|
||||
setIcon(new ImageIcon(Resources.getImageInBytes("soundIcon")));
|
||||
setText(null);
|
||||
setHorizontalAlignment(SwingConstants.CENTER);
|
||||
}
|
||||
else
|
||||
{
|
||||
setIcon(null);
|
||||
setText(null);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
setIcon(null);
|
||||
setText((String)value);
|
||||
setHorizontalAlignment(SwingConstants.LEFT);
|
||||
}
|
||||
if(isSelected)
|
||||
{
|
||||
this.setOpaque(true);
|
||||
this.setBackground(new Color(209, 212, 225));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setBackground(Color.WHITE);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public class ListMulti extends JPanel
|
||||
{
|
||||
private MyJTable listMulti;
|
||||
private ListModel model;
|
||||
private String colunmToolTips [] = null;
|
||||
|
||||
ListMulti(Object columns[], String colunmToolTips [])
|
||||
{
|
||||
super(new GridLayout(1, 0));
|
||||
String strTmp = new String();
|
||||
|
||||
model = new ListModel(columns, 0);
|
||||
|
||||
listMulti = new MyJTable(model);
|
||||
|
||||
listMulti.setRowSelectionAllowed(true);
|
||||
listMulti.getTableHeader().setReorderingAllowed(false);
|
||||
listMulti.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
|
||||
this.colunmToolTips = colunmToolTips;
|
||||
for(int i = 0; i< columns.length; i ++)
|
||||
{
|
||||
TableColumn tmp = listMulti.getColumnModel().getColumn(i);
|
||||
if(columns[i].getClass() != strTmp.getClass())
|
||||
{
|
||||
tmp.setHeaderRenderer(new MyRenderer((JLabel)columns[i]));
|
||||
tmp.setHeaderValue("");
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp.setHeaderValue((String)columns[i]);
|
||||
}
|
||||
|
||||
if(i == 0)
|
||||
{
|
||||
tmp.setMaxWidth(67);
|
||||
tmp.setMinWidth(67);
|
||||
tmp.setPreferredWidth(67);
|
||||
}
|
||||
else if(i < columns.length - 1)
|
||||
{
|
||||
tmp.setMaxWidth(25);
|
||||
tmp.setMinWidth(25);
|
||||
tmp.setPreferredWidth(25);
|
||||
}
|
||||
}
|
||||
|
||||
/* for headers */
|
||||
JScrollPane scrollPane = new JScrollPane(listMulti);
|
||||
this.add(scrollPane);
|
||||
listMulti.setDefaultRenderer(Object.class, new MyTableRenderer());
|
||||
}
|
||||
|
||||
public void addLine(NotificationsTableEntry dataNTE)
|
||||
{
|
||||
Object row[] = new Object[5];
|
||||
|
||||
row[0] = dataNTE.getEnabled()
|
||||
? new String("enable")
|
||||
: new String("disable");
|
||||
row[1] = (dataNTE.getProgram()
|
||||
&& (dataNTE.getProgramFile().trim().length() > 0))
|
||||
? new String("Yes")
|
||||
: new String("No");
|
||||
row[2] = dataNTE.getPopup() ? new String("Yes") : new String("No");
|
||||
row[3] = (dataNTE.getSound()
|
||||
&& (dataNTE.getSoundFile().trim().length() > 0))
|
||||
? new String("Yes")
|
||||
: new String("No");
|
||||
row[4] = dataNTE.getEvent();
|
||||
|
||||
this.addLine(row);
|
||||
}
|
||||
|
||||
public void addLine(Object data[])
|
||||
{
|
||||
if(data.length != model.getColumnCount())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
model.addRow(data);
|
||||
|
||||
}
|
||||
|
||||
public int removeLine(int num)
|
||||
{
|
||||
model.removeRow(num);
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getLine()
|
||||
{
|
||||
return listMulti.getSelectedRow() ;
|
||||
}
|
||||
|
||||
public Object getRowValue(int line, int column)
|
||||
{
|
||||
return listMulti.getValueAt(line, column);
|
||||
}
|
||||
|
||||
public String getValue(int line, int column)
|
||||
{
|
||||
return (String)listMulti.getValueAt(line, column);
|
||||
}
|
||||
|
||||
public void setValue(String value, int line, int column)
|
||||
{
|
||||
listMulti.setValueAt(value, line, column);
|
||||
}
|
||||
|
||||
/*
|
||||
* Gives the number of lines of the Table.
|
||||
*/
|
||||
public int getRowCount()
|
||||
{
|
||||
return listMulti.getRowCount();
|
||||
|
||||
}
|
||||
|
||||
public void setLine(NotificationsTableEntry dataNTE, int line)
|
||||
{
|
||||
Object row[] = new Object[5];
|
||||
|
||||
row[0] = dataNTE.getEnabled()
|
||||
? new String("enable")
|
||||
: new String("disable");
|
||||
row[1] = (dataNTE.getProgram()
|
||||
&& (dataNTE.getProgramFile().trim().length() > 0))
|
||||
? new String("Yes")
|
||||
: new String("No");
|
||||
row[2] = dataNTE.getPopup() ? new String("Yes") : new String("No");
|
||||
row[3] = (dataNTE.getSound()
|
||||
&& (dataNTE.getSoundFile().trim().length() > 0))
|
||||
? new String("Yes")
|
||||
: new String("No");
|
||||
row[4] = dataNTE.getEvent();
|
||||
|
||||
this.setLine(row,line);
|
||||
}
|
||||
|
||||
public void setLine(Object data[], int line)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < model.getColumnCount(); i ++)
|
||||
{
|
||||
setValue((String)data[i], line, i);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Adding a mouse listener on the table.
|
||||
*/
|
||||
public void addMouseListener(MouseListener mL)
|
||||
{
|
||||
|
||||
listMulti.addMouseListener(mL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Allows selection of a line or a group of lines.
|
||||
*/
|
||||
public void setRowSelectionInterval(int row, int col)
|
||||
{
|
||||
listMulti.setRowSelectionInterval(row,col);
|
||||
}
|
||||
|
||||
/*
|
||||
* Returne the current line number
|
||||
*/
|
||||
public int rowAtPoint(Point p)
|
||||
{
|
||||
return listMulti.rowAtPoint(p);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Extends the JTable to make easier to use whith the pluggin
|
||||
*/
|
||||
class MyJTable extends JTable
|
||||
{
|
||||
MyJTable(TableModel model)
|
||||
{
|
||||
super(model);
|
||||
}
|
||||
|
||||
protected JTableHeader createDefaultTableHeader()
|
||||
{
|
||||
return new JTableHeader(columnModel)
|
||||
{
|
||||
public String getToolTipText(MouseEvent e)
|
||||
{
|
||||
java.awt.Point p = e.getPoint();
|
||||
int index = columnModel.getColumnIndexAtX(p.x);
|
||||
int realIndex =
|
||||
columnModel.getColumn(index).getModelIndex();
|
||||
return NotificationConfigurationConfigForm.columnToolTips[
|
||||
realIndex];
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,115 @@
|
||||
/*
|
||||
* 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.notificationconfiguration;
|
||||
|
||||
import net.java.sip.communicator.service.configuration.*;
|
||||
import net.java.sip.communicator.service.audionotifier.*;
|
||||
import net.java.sip.communicator.service.notification.*;
|
||||
import net.java.sip.communicator.service.gui.*;
|
||||
|
||||
import org.osgi.framework.*;
|
||||
|
||||
/**
|
||||
* The <tt>BundleActivator</tt> of the AudioConfiguration plugin.
|
||||
* @author Alexandre Maillard
|
||||
*/
|
||||
public class NotificationConfigurationActivator implements BundleActivator
|
||||
{
|
||||
public static BundleContext bundleContext;
|
||||
|
||||
private static ConfigurationService configService;
|
||||
|
||||
private static AudioNotifierService audioService;
|
||||
|
||||
private static NotificationService notificationService;
|
||||
|
||||
/**
|
||||
* Starts this bundle and adds the <tt>AudioConfigurationConfigForm</tt>
|
||||
* contained in it to the configuration window obtained from the
|
||||
* <tt>UIService</tt>.
|
||||
*/
|
||||
public void start(BundleContext bc) throws Exception
|
||||
{
|
||||
bundleContext = bc;
|
||||
|
||||
NotificationConfigurationConfigForm notificationconfiguration
|
||||
= new NotificationConfigurationConfigForm();
|
||||
|
||||
bundleContext.registerService( ConfigurationForm.class.getName(),
|
||||
notificationconfiguration,
|
||||
null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops this bundles.
|
||||
*/
|
||||
public void stop(BundleContext arg0) throws Exception
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the <tt>ConfigurationService</tt> obtained from the bundle
|
||||
* context.
|
||||
* @return the <tt>ConfigurationService</tt> obtained from the bundle
|
||||
* context
|
||||
*/
|
||||
public static ConfigurationService getConfigurationService()
|
||||
{
|
||||
if(configService == null)
|
||||
{
|
||||
ServiceReference configReference
|
||||
= bundleContext.getServiceReference(
|
||||
ConfigurationService.class.getName());
|
||||
|
||||
configService = (ConfigurationService) bundleContext.getService(
|
||||
configReference);
|
||||
}
|
||||
|
||||
return configService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the <tt>AudioService</tt> obtained from the bundle
|
||||
* context.
|
||||
* @return the <tt>AudioService</tt> obtained from the bundle
|
||||
* context
|
||||
*/
|
||||
public static AudioNotifierService getAudioNotifierService()
|
||||
{
|
||||
if(audioService == null)
|
||||
{
|
||||
ServiceReference audioReference
|
||||
= bundleContext.getServiceReference(
|
||||
AudioNotifierService.class.getName());
|
||||
|
||||
audioService = (AudioNotifierService) bundleContext.getService(
|
||||
audioReference);
|
||||
}
|
||||
return audioService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the <tt>NotificationService</tt> obtained from the bundle
|
||||
* context.
|
||||
* @return the <tt>NotificationService</tt> obtained from the bundle
|
||||
* context
|
||||
*/
|
||||
public static NotificationService getNotificationService()
|
||||
{
|
||||
if(notificationService == null)
|
||||
{
|
||||
ServiceReference notificationReference
|
||||
= bundleContext.getServiceReference(
|
||||
NotificationService.class.getName());
|
||||
|
||||
notificationService
|
||||
= (NotificationService) bundleContext.getService(
|
||||
notificationReference);
|
||||
}
|
||||
return notificationService;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,249 @@
|
||||
/*
|
||||
* 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.notificationconfiguration;
|
||||
|
||||
import net.java.sip.communicator.service.notification.event.*;
|
||||
|
||||
/**
|
||||
* The <tt>NotificationsTableEntry</tt> is a class which defined the different
|
||||
* entry in the utilitary "NotificationConfiguration" JTable. It
|
||||
* regroups one entry's whole parameters.
|
||||
* @author Alexandre Maillard
|
||||
*/
|
||||
public class NotificationsTableEntry
|
||||
{
|
||||
/**
|
||||
* Parameter which defines if the notification is enabled or disabled.
|
||||
*/
|
||||
private boolean enabled = false;
|
||||
|
||||
/**
|
||||
* Parameter which defines if the program's execution is activated.
|
||||
*/
|
||||
private boolean program = false;
|
||||
|
||||
/**
|
||||
* Program filenames which is executed.
|
||||
*/
|
||||
private String programFile = "";
|
||||
|
||||
/**
|
||||
* Parameter which defines if the popup is activated.
|
||||
*/
|
||||
private boolean popup = false;
|
||||
|
||||
/**
|
||||
* Parameter which defines if the sound is activated.
|
||||
*/
|
||||
private boolean sound = false;
|
||||
|
||||
/**
|
||||
* Name of sound file which is play
|
||||
*/
|
||||
private String soundFile = "";
|
||||
|
||||
/**
|
||||
* Parameter which describes, in a simple sentence, the notification.
|
||||
*/
|
||||
private String event = "";
|
||||
|
||||
/**
|
||||
* Parameter which describes if the notification has been modified
|
||||
*/
|
||||
private boolean isModify = false;
|
||||
|
||||
/**
|
||||
* Empty class constructor.
|
||||
* Creates a new instance of NotificationsTableEntry.
|
||||
*/
|
||||
public NotificationsTableEntry()
|
||||
{
|
||||
enabled = false;
|
||||
program = false;
|
||||
programFile = "";
|
||||
popup = false;
|
||||
sound = false;
|
||||
soundFile = "";
|
||||
event = "";
|
||||
isModify = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Class constructor with five parameters.
|
||||
* Creates a new instance of NotificationsTableEntry.
|
||||
* @param _enabled assigns the value of _enabled to this.enabled.
|
||||
* @param _program assigns the value of _program to this.program.
|
||||
* @param _programFile assigns the value of _programFile to this.programFile.
|
||||
* @param _popup assigns the value of _popup to this.popup.
|
||||
* @param _sound assigns the value of _sound to this.sound.
|
||||
* @param _soundFile assigns the value of _soundFile to this.soundFile.
|
||||
* @param _event assigns the value of _event to this.event.
|
||||
* @param _isModify assigns the value of _isModify to this.isModify.
|
||||
*/
|
||||
public NotificationsTableEntry(
|
||||
boolean _enabled, boolean _program,
|
||||
String _programFile, boolean _popup, boolean _sound,
|
||||
String _soundFile, String _event, boolean _isModify)
|
||||
{
|
||||
setEnabled(_enabled);
|
||||
setProgram(_program);
|
||||
setProgramFile(_programFile);
|
||||
setPopup(_popup);
|
||||
setSound(_sound);
|
||||
setSoundFile(_soundFile);
|
||||
setEvent(_event);
|
||||
setModify(_isModify);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method which returns the state of the notification.
|
||||
* @return boolean enable/disable.
|
||||
*/
|
||||
public boolean getEnabled()
|
||||
{
|
||||
return this.enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method which returns true if one program is executed.
|
||||
* @return boolean true if a programm is executed
|
||||
*/
|
||||
public boolean getProgram()
|
||||
{
|
||||
return this.program;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method which returns the program's name which is executed.
|
||||
* @return String representing the program file name.
|
||||
*/
|
||||
public String getProgramFile()
|
||||
{
|
||||
return this.programFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method which returns true if one systray popup is executed.
|
||||
* @return boolean true if a popup is executed.
|
||||
*/
|
||||
public boolean getPopup()
|
||||
{
|
||||
return this.popup;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method which returns if one sound is executed.
|
||||
* @return boolean true if a sound is playing.
|
||||
*/
|
||||
public boolean getSound()
|
||||
{
|
||||
return this.sound;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method which returns the sound file name which is executed.
|
||||
* @return String representing the sound file name.
|
||||
*/
|
||||
public String getSoundFile()
|
||||
{
|
||||
return this.soundFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method which returns the description of the notification.
|
||||
* @return String representing the notification's description.
|
||||
*/
|
||||
public String getEvent()
|
||||
{
|
||||
return this.event;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method which returns true if the notification has been modified
|
||||
* @return boolean true if the notification has been modified
|
||||
*/
|
||||
public boolean isModified()
|
||||
{
|
||||
return this.isModify;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Method which assigns the notification state.
|
||||
* @param true if the notification is enabled.
|
||||
*/
|
||||
public void setEnabled(boolean _enabled)
|
||||
{
|
||||
this.enabled = _enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method which set a boolean to true if a program is executed for the
|
||||
* notification.
|
||||
* @param boolean for the program's presence.
|
||||
*/
|
||||
public void setProgram(boolean _program)
|
||||
{
|
||||
this.program = _program;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method which assigns the program filename for the notification.
|
||||
* @param String representing the program file name.
|
||||
*/
|
||||
public void setProgramFile(String _programFile)
|
||||
{
|
||||
this.programFile = _programFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method which set a boolean to true if a systray popup is executed for the
|
||||
* notification.
|
||||
* @param boolean for the presence of popup.
|
||||
*/
|
||||
public void setPopup(boolean _popup)
|
||||
{
|
||||
this.popup = _popup;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method which set a boolean to true a sound is playing for the
|
||||
* notification.
|
||||
* @param boolean for the presence of a sound.
|
||||
*/
|
||||
public void setSound(boolean _sound)
|
||||
{
|
||||
this.sound = _sound;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method which assigns the sound file name for the notification.
|
||||
* @param String for the sound file name.
|
||||
*/
|
||||
public void setSoundFile(String _soundFile)
|
||||
{
|
||||
this.soundFile = _soundFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method which assigns the notification's description.
|
||||
* @param String to assigns a description of a notification.
|
||||
*/
|
||||
public void setEvent(String _event)
|
||||
{
|
||||
this.event = _event;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method which defines that the notification has been modified
|
||||
* @param boolean true if the notification is modified
|
||||
*/
|
||||
public void setModify(boolean _isModify)
|
||||
{
|
||||
this.isModify = _isModify;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,88 @@
|
||||
/*
|
||||
* 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.notificationconfiguration;
|
||||
|
||||
import java.awt.image.*;
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
import javax.imageio.*;
|
||||
import javax.swing.*;
|
||||
|
||||
import net.java.sip.communicator.util.*;
|
||||
|
||||
/**
|
||||
* The Messages class manages the access to the internationalization
|
||||
* properties files.
|
||||
* @author Yana Stamcheva
|
||||
*/
|
||||
public class Resources {
|
||||
|
||||
private static Logger log = Logger.getLogger(Resources.class);
|
||||
|
||||
private static final String BUNDLE_NAME
|
||||
= "net.java.sip.communicator.plugin.notificationconfiguration.resources";
|
||||
|
||||
private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle
|
||||
.getBundle(BUNDLE_NAME);
|
||||
|
||||
/**
|
||||
* Returns an internationalized string corresponding to the given key.
|
||||
* @param key The key of the string.
|
||||
* @return An internationalized string corresponding to the given key.
|
||||
*/
|
||||
public static String getString(String key) {
|
||||
try {
|
||||
return RESOURCE_BUNDLE.getString(key);
|
||||
|
||||
} catch (MissingResourceException e) {
|
||||
|
||||
return '!' + 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;
|
||||
|
||||
String path = Resources.getString(imageID);
|
||||
try {
|
||||
image = ImageIO.read(Resources.class.getClassLoader()
|
||||
.getResourceAsStream(path));
|
||||
|
||||
} catch (IOException e) {
|
||||
log.error("Failed to load image:" + path, 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) {
|
||||
byte[] image = new byte[100000];
|
||||
|
||||
String path = Resources.getString(imageID);
|
||||
try {
|
||||
Resources.class.getClassLoader()
|
||||
.getResourceAsStream(path).read(image);
|
||||
|
||||
} catch (IOException e) {
|
||||
log.error("Failed to load image:" + path, e);
|
||||
}
|
||||
|
||||
return image;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,109 @@
|
||||
/*
|
||||
* 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.notificationconfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import javax.swing.filechooser.*;
|
||||
|
||||
/**
|
||||
* Filter to display only the sound files in the filechooser
|
||||
* @author Alexandre Maillard
|
||||
*/
|
||||
public class SoundFilter
|
||||
extends FileFilter
|
||||
{
|
||||
/**
|
||||
* Method which describes differents permits extensions and defines which file or
|
||||
* directory will be displayed in the filechoser.
|
||||
* @param File file for the test
|
||||
* @return boolean true if the File is a Directory or a sound file. And
|
||||
* return false in the other cases.
|
||||
*/
|
||||
public boolean accept(File f)
|
||||
{
|
||||
/*
|
||||
* Test if the file passed in argument is a directory.
|
||||
*/
|
||||
if (f.isDirectory())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
/*
|
||||
* Else, it tests if the exension is correct
|
||||
*/
|
||||
String extension = Utils.getExtension(f);
|
||||
if (extension != null)
|
||||
{
|
||||
if (extension.equals(Utils.wav) ||
|
||||
extension.equals(Utils.mid) ||
|
||||
extension.equals(Utils.mp2) ||
|
||||
extension.equals(Utils.mp3) ||
|
||||
extension.equals(Utils.mod) ||
|
||||
extension.equals(Utils.ogg) ||
|
||||
extension.equals(Utils.wma) ||
|
||||
extension.equals(Utils.au) ||
|
||||
extension.equals(Utils.ram))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Method which describes, in the file chooser, the text representing the permit extension
|
||||
* files.
|
||||
* @return String which is displayed in the sound file chooser.
|
||||
*/
|
||||
public String getDescription()
|
||||
{
|
||||
return "Sound File (*.au, *.mid, *.mod, *.mp2, *.mp3, *.ogg, *.ram," +
|
||||
"*.wav, *.wma)";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* class which defines the different permit extension file
|
||||
* @author Alexandre Maillard
|
||||
*/
|
||||
class Utils
|
||||
{
|
||||
/*
|
||||
* Differents extension of a sound file
|
||||
*/
|
||||
public final static String wav = "wav";
|
||||
public final static String mid = "mid";
|
||||
public final static String mp2 = "mp2";
|
||||
public final static String mp3 = "mp3";
|
||||
public final static String mod = "mod";
|
||||
public final static String ram = "ram";
|
||||
public final static String wma = "wma";
|
||||
public final static String ogg = "ogg";
|
||||
public final static String au = "au";
|
||||
|
||||
/*
|
||||
* Gets the file extension.
|
||||
* @param File which wants the extension
|
||||
* @return Return the extension as a String
|
||||
*/
|
||||
public static String getExtension(File f)
|
||||
{
|
||||
String ext = null;
|
||||
String s = f.getName();
|
||||
int i = s.lastIndexOf('.');
|
||||
|
||||
if (i > 0 && i < s.length() - 1)
|
||||
ext = s.substring(i+1).toLowerCase();
|
||||
|
||||
return ext;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
Bundle-Activator: net.java.sip.communicator.plugin.notificationconfiguration.NotificationConfigurationActivator
|
||||
Bundle-Name: Plugin Manager Notification
|
||||
Bundle-Description: Manage all SIP Communicator notification.
|
||||
Bundle-Vendor: sip-communicator.org
|
||||
Bundle-Version: 0.0.1
|
||||
System-Bundle: yes
|
||||
Import-Package: org.osgi.framework,
|
||||
net.java.sip.communicator.util,
|
||||
net.java.sip.communicator.service.gui,
|
||||
net.java.sip.communicator.service.gui.event,
|
||||
net.java.sip.communicator.service.configuration,
|
||||
net.java.sip.communicator.service.audionotifier,
|
||||
net.java.sip.communicator.service.notification,
|
||||
net.java.sip.communicator.service.notification.event,
|
||||
javax.swing,
|
||||
javax.swing.event,
|
||||
javax.swing.table,
|
||||
javax.swing.text,
|
||||
javax.swing.text.html,
|
||||
javax.accessibility,
|
||||
javax.swing.plaf,
|
||||
javax.swing.plaf.metal,
|
||||
javax.swing.plaf.basic,
|
||||
javax.imageio,
|
||||
javax.swing.filechooser,
|
||||
javax.swing.tree,
|
||||
javax.swing.undo,
|
||||
javax.swing.border,
|
||||
@ -0,0 +1,20 @@
|
||||
notification=Notifications
|
||||
play=Play
|
||||
activate=Activate
|
||||
desactivate=Desactivate
|
||||
turnonall=Turn On All
|
||||
turnoffall=Turn Off All
|
||||
actions=Actions
|
||||
quickcontrols=Quick Controls
|
||||
apply=Apply
|
||||
playsound=Play a sound :
|
||||
execprog=Execute a program :
|
||||
displaypopup=Show a message in a pop-up window
|
||||
notificationIcon=net/java/sip/communicator/plugin/notificationconfiguration/resources/notificationIcon.png
|
||||
playIcon=net/java/sip/communicator/plugin/notificationconfiguration/resources/playIcon.png
|
||||
progIcon=net/java/sip/communicator/plugin/notificationconfiguration/resources/progIcon.png
|
||||
popupIcon=net/java/sip/communicator/plugin/notificationconfiguration/resources/popupIcon.png
|
||||
soundIcon=net/java/sip/communicator/plugin/notificationconfiguration/resources/soundIcon.png
|
||||
activatedIcon=net/java/sip/communicator/plugin/notificationconfiguration/resources/activeIcon.png
|
||||
desactivatedIcon=net/java/sip/communicator/plugin/notificationconfiguration/resources/desactivatedIcon.png
|
||||
foldericon=net/java/sip/communicator/plugin/notificationconfiguration/resources/folder.png
|
||||
|
After Width: | Height: | Size: 689 B |
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 4.3 KiB |
|
After Width: | Height: | Size: 4.4 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 590 B |
|
After Width: | Height: | Size: 869 B |
|
After Width: | Height: | Size: 971 B |
|
After Width: | Height: | Size: 889 B |