Show error when preferences cannot be saved.
At times, a plugin that integrates with the preferences panel fails to store its configurations. This has been observed with 'old' plugins, that suffer from class-not-found exceptions. When this occurs, Spark should notify the user, but otherwise ignore the issue.
@@ -40,6 +40,7 @@ import org.jivesoftware.resource.Res;
import org.jivesoftware.spark.component.TitlePanel;
import org.jivesoftware.spark.component.renderer.JLabelIconRenderer;
import org.jivesoftware.spark.preference.Preference;
+import org.jivesoftware.spark.util.log.Log;
import org.jivesoftware.sparkimpl.settings.local.SettingsManager;
public class PreferencesPanel extends JPanel implements ListSelectionListener {
@@ -138,6 +139,7 @@ public class PreferencesPanel extends JPanel implements ListSelectionListener {
if (!e.getValueIsAdjusting()) {
if (currentPreference != null) {
+ try {
if (currentPreference.isDataValid()) {
currentPreference.commit();
}
@@ -149,7 +151,18 @@ public class PreferencesPanel extends JPanel implements ListSelectionListener {
list.setSelectedIndex(e.getLastIndex());
list.addListSelectionListener(this);
}
-
+ }
+ catch ( Throwable t )
+ {
+ // This is observed with some plugins, that require classes not (no longer) provided by Spark.
+ Log.error( "An error occurred while trying to commit settings for preference: " + currentPreference.getListName(), t );
+ UIManager.put( "OptionPane.okButtonText", Res.getString( "ok" ) );
+ JOptionPane.showMessageDialog( this, "Unable to save all settings for " + currentPreference.getListName() + ":\n" + t.getMessage(),
+ Res.getString( "title.error" ), JOptionPane.ERROR_MESSAGE );
+ list.removeListSelectionListener( this );
+ list.setSelectedIndex( e.getLastIndex() );
+ list.addListSelectionListener( this );
+ }
}
selectionChanged();
}
