Update event config form, fixing storing values when changing file values.

cusax-fix
Damian Minkov 15 years ago
parent 0a4cb156b6
commit 54c19cdf27

@ -293,6 +293,8 @@ public static void stopSound(String eventType)
.getEventNotificationActionHandler(
eventType, NotificationService.ACTION_SOUND);
soundHandler.stop();
// There can be no sound action handler for this event type
if(soundHandler != null)
soundHandler.stop();
}
}

@ -45,6 +45,9 @@ public CommandNotificationHandlerImpl(String commandDescriptor)
*/
public void execute()
{
if(StringUtils.isNullOrEmpty(commandDescriptor, true))
return;
try
{
Runtime.getRuntime().exec(commandDescriptor);

@ -8,6 +8,7 @@
import net.java.sip.communicator.service.audionotifier.*;
import net.java.sip.communicator.service.notification.*;
import net.java.sip.communicator.util.*;
/**
* An implementation of the <tt>SoundNotificationHandlerImpl</tt> interface.
@ -80,7 +81,8 @@ public void start()
AudioNotifierService audioNotifService
= NotificationActivator.getAudioNotifier();
if(audioNotifService == null)
if(audioNotifService == null
|| StringUtils.isNullOrEmpty(soundFileDescriptor, true))
return;
audio = audioNotifService.createAudio(soundFileDescriptor);

@ -15,6 +15,7 @@
import javax.swing.event.*;
import net.java.sip.communicator.service.audionotifier.*;
import net.java.sip.communicator.service.notification.*;
import net.java.sip.communicator.util.*;
import net.java.sip.communicator.util.swing.*;
@ -55,6 +56,12 @@ public class NotificationConfigurationPanel
private SipCommFileChooser fileChooserProgram;
private SipCommFileChooser fileChooserSound;
/**
* Used to suppress saving entry values while filling
* programFileTextField and soundFileTextField.
*/
private boolean isCurrentlyChangeEntryInTable = false;
/**
* Creates an instance of <tt>NotificationConfigurationPanel</tt>.
*/
@ -173,6 +180,8 @@ private void initNotificationsList()
*/
public void setNotificationEntry(NotificationEntry entry)
{
isCurrentlyChangeEntryInTable = true;
programFileChooser.setEnabled(entry.getProgram());
programFileTextField.setEnabled(entry.getProgram());
@ -186,6 +195,8 @@ public void setNotificationEntry(NotificationEntry entry)
String soundFile = entry.getSoundFile();
soundFileTextField.setText(
(soundFile != null && soundFile.length() > 0) ? soundFile : "");
isCurrentlyChangeEntryInTable = false;
}
/**
@ -292,16 +303,37 @@ else if(e.getSource() == playSoundButton)
*/
public void insertUpdate(DocumentEvent event)
{
// we are just changing display values, no real change in data
// to save it
if(isCurrentlyChangeEntryInTable)
return;
NotificationEntry entry = notificationList.getNotificationEntry(
notificationList.getSelectedRow());
if(event.getDocument().equals(programFileTextField.getDocument()))
{
entry.setProgramFile(programFileTextField.getText());
NotificationConfigurationActivator.getNotificationService()
.registerNotificationForEvent(
entry.getEvent(),
NotificationService.ACTION_COMMAND,
entry.getProgramFile(),
""
);
}
if(event.getDocument().equals(soundFileTextField.getDocument()))
{
entry.setSoundFile(soundFileTextField.getText());
NotificationConfigurationActivator.getNotificationService()
.registerNotificationForEvent(
entry.getEvent(),
NotificationService.ACTION_SOUND,
entry.getSoundFile(),
""
);
}
}
@ -311,16 +343,37 @@ public void insertUpdate(DocumentEvent event)
*/
public void removeUpdate(DocumentEvent event)
{
// we are just changing display values, no real change in data
// to save it
if(isCurrentlyChangeEntryInTable)
return;
NotificationEntry entry = notificationList.getNotificationEntry(
notificationList.getSelectedRow());
if(event.getDocument().equals(programFileTextField.getDocument()))
{
entry.setProgramFile(programFileTextField.getText());
NotificationConfigurationActivator.getNotificationService()
.registerNotificationForEvent(
entry.getEvent(),
NotificationService.ACTION_COMMAND,
entry.getProgramFile(),
""
);
}
if(event.getDocument().equals(soundFileTextField.getDocument()))
{
entry.setSoundFile(soundFileTextField.getText());
NotificationConfigurationActivator.getNotificationService()
.registerNotificationForEvent(
entry.getEvent(),
NotificationService.ACTION_SOUND,
entry.getSoundFile(),
""
);
}
}

@ -272,8 +272,7 @@ private NotificationEntry getNotificationEntry(String eventName)
{
for (int row = 0; row < notifTable.getRowCount(); row++)
{
NotificationEntry entry = (NotificationEntry) notifTable
.getValueAt(row, notifTable.getColumnCount() - 1);
NotificationEntry entry = getNotificationEntry(row);
if (entry.getEvent() == eventName)
return entry;
@ -309,8 +308,7 @@ private int indexOfEntry(NotificationEntry entry)
{
for (int row = 0; row < notifTable.getRowCount(); row++)
{
NotificationEntry e = (NotificationEntry) notifTable
.getValueAt(row, notifTable.getColumnCount() - 1);
NotificationEntry e = getNotificationEntry(row);
if (e.equals(entry))
return row;
@ -440,9 +438,8 @@ public void mouseClicked(MouseEvent e)
else
notifTable.setValueAt(ENABLED, row, col);
NotificationEntry entry = (NotificationEntry) notifTable
.getValueAt(row, notifTable.getColumnCount() - 1);
NotificationEntry entry = getNotificationEntry(row);
switch(col)
{
case 0:
@ -460,15 +457,19 @@ public void mouseClicked(MouseEvent e)
entry.setProgram(isProgram);
if(isProgram)
{
notificationService.registerNotificationForEvent(
entry.getEvent(),
NotificationService.ACTION_COMMAND,
entry.getProgramFile(),
"");
}
else
{
notificationService.removeEventNotificationAction(
entry.getEvent(),
NotificationService.ACTION_COMMAND);
}
break;
case 2:
boolean isPopup = notifTable.getValueAt(row, 2).equals(ENABLED);
@ -494,17 +495,23 @@ public void mouseClicked(MouseEvent e)
entry.setSound(isSound);
if (isSound)
{
notificationService.registerNotificationForEvent(
entry.getEvent(),
NotificationService.ACTION_SOUND,
entry.getSoundFile(),
"");
}
else
{
notificationService.removeEventNotificationAction(
entry.getEvent(),
NotificationService.ACTION_SOUND);
}
break;
};
configPanel.setNotificationEntry(entry);
}
}

Loading…
Cancel
Save