aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/sip/communicator/plugin/notificationconfiguration
diff options
context:
space:
mode:
authorDamian Minkov <damencho@jitsi.org>2010-12-08 11:07:51 +0000
committerDamian Minkov <damencho@jitsi.org>2010-12-08 11:07:51 +0000
commit54c19cdf2711282994864e9157ec904816413bc5 (patch)
treea026649b06fa4205bac1151c16a00ec1fccc3e7d /src/net/java/sip/communicator/plugin/notificationconfiguration
parent0a4cb156b6ec8698ee1aedd390c09ee75bb4261e (diff)
downloadjitsi-54c19cdf2711282994864e9157ec904816413bc5.zip
jitsi-54c19cdf2711282994864e9157ec904816413bc5.tar.gz
jitsi-54c19cdf2711282994864e9157ec904816413bc5.tar.bz2
Update event config form, fixing storing values when changing file values.
Diffstat (limited to 'src/net/java/sip/communicator/plugin/notificationconfiguration')
-rw-r--r--src/net/java/sip/communicator/plugin/notificationconfiguration/NotificationConfigurationPanel.java53
-rw-r--r--src/net/java/sip/communicator/plugin/notificationconfiguration/NotificationsTable.java21
2 files changed, 67 insertions, 7 deletions
diff --git a/src/net/java/sip/communicator/plugin/notificationconfiguration/NotificationConfigurationPanel.java b/src/net/java/sip/communicator/plugin/notificationconfiguration/NotificationConfigurationPanel.java
index a3b94d7..92c2949 100644
--- a/src/net/java/sip/communicator/plugin/notificationconfiguration/NotificationConfigurationPanel.java
+++ b/src/net/java/sip/communicator/plugin/notificationconfiguration/NotificationConfigurationPanel.java
@@ -15,6 +15,7 @@ import javax.swing.*;
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.*;
@@ -56,6 +57,12 @@ public class NotificationConfigurationPanel
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>.
*/
public NotificationConfigurationPanel()
@@ -173,6 +180,8 @@ public class NotificationConfigurationPanel
*/
public void setNotificationEntry(NotificationEntry entry)
{
+ isCurrentlyChangeEntryInTable = true;
+
programFileChooser.setEnabled(entry.getProgram());
programFileTextField.setEnabled(entry.getProgram());
@@ -186,6 +195,8 @@ public class NotificationConfigurationPanel
String soundFile = entry.getSoundFile();
soundFileTextField.setText(
(soundFile != null && soundFile.length() > 0) ? soundFile : "");
+
+ isCurrentlyChangeEntryInTable = false;
}
/**
@@ -292,16 +303,37 @@ public class NotificationConfigurationPanel
*/
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 class NotificationConfigurationPanel
*/
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(),
+ ""
+ );
}
}
diff --git a/src/net/java/sip/communicator/plugin/notificationconfiguration/NotificationsTable.java b/src/net/java/sip/communicator/plugin/notificationconfiguration/NotificationsTable.java
index 59bd8ff..78b7374 100644
--- a/src/net/java/sip/communicator/plugin/notificationconfiguration/NotificationsTable.java
+++ b/src/net/java/sip/communicator/plugin/notificationconfiguration/NotificationsTable.java
@@ -272,8 +272,7 @@ public class NotificationsTable
{
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 @@ public class NotificationsTable
{
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 class NotificationsTable
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 class NotificationsTable
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 class NotificationsTable
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);
}
}