{
room.setEditable(false);
try
{
if(room.getText().equals(""))return;
JID jid = JID.checkedJIDFromString(room.getText());
Preferences.putString("groupchatalerter","room"+order
,room.getText());
try {
Pattern.compile(rule.getText());
}catch(PatternSyntaxException e2)
{
JOptionPane.showMessageDialog(PrefPanel.this, e2.getMessage());
ruleEnabled.setSelected(false);
return;
}
JID j2 = nu.fw.jeti.plugins.groupchat.Plugin.getGroupchatJID(jid);
if(j2!=null)
{//groupchat already loaded, init with that groupchat nickname
jid =j2;
}
Plugin.addAlerter(new Alerter(backend,jid,rule.getText()),jid);
Preferences.putBoolean("groupchatalerter","ruleEnabled"+order, ruleEnabled.isSelected());
} catch (InstantiationException e2)
{
JOptionPane.showMessageDialog(PrefPanel.this, e2.getMessage());
ruleEnabled.setSelected(false);
}
}
else
{
Preferences.putBoolean("groupchatalerter","ruleEnabled"+order,ruleEnabled.isSelected());
Plugin.removeAlerter(JID.jidFromString(room.getText()));
room.setEditable(true);
}
}
});
room = new JTextField(Preferences.getString(
"groupchatalerter","room"+ruleBlockNo,null));
rule = new JTextField(Preferences.getString(
"groupchatalerter","rule"+ruleBlockNo,null));
rule.addFocusListener(new FocusListener()
{
private String ruleText;
public void focusLost(FocusEvent e)
{
Preferences.putString("groupchatalerter","rule"+order
,rule.getText());
Preferences.putString("groupchatalerter","room"+order
,room.getText());
if(ruleEnabled.isSelected() && !rule.getText().equals(ruleText))
{
try {
Pattern.compile(rule.getText());
}catch(PatternSyntaxException e2)
{
JOptionPane.showMessageDialog(PrefPanel.this, e2.getDescription());
return;
}
}
JID jid = JID.jidFromString(room.getText());
if(Plugin.isMonitoring(jid))
{
Plugin.updateRule(jid,rule.getText());
}
}