+ * If we have made changes to an existing user defined colour scheme but not
+ * saved them, show a dialog with the option to save. If the user chooses to
+ * save, do so, else clear the colour scheme name to indicate a new colour
+ * scheme.
+ */
+ protected void warnIfUnsavedChanges()
+ {
+ if (!changed)
+ {
+ return;
+ }
+
+ String name = schemeName.getText().trim();
+ if (oldColourScheme != null && !"".equals(name)
+ && name.equals(oldColourScheme.getSchemeName()))
+ {
+ String message = MessageManager.formatMessage("label.scheme_changed",
+ name);
+ String title = MessageManager.getString("label.save_changes");
+ String[] options = new String[] { title,
+ MessageManager.getString("label.dont_save_changes"), };
+ final String question = JvSwingUtils.wrapTooltip(true, message);
+ int response = JvOptionPane.showOptionDialog(Desktop.desktop,
+ question, title, JvOptionPane.DEFAULT_OPTION,
+ JvOptionPane.PLAIN_MESSAGE, null, options, options[0]);
+
+ boolean saved = false;
+ if (response == 0)
+ {
+ /*
+ * prompt to save changes to file
+ */
+ saved = savebutton_actionPerformed();
+ }
+
+ /*
+ * if user chooses not to save (either in this dialog or in the
+ * save as dialogs), treat this as a new user defined colour scheme
+ */
+ if (!saved)
+ {
+ /*
+ * clear scheme name and re-apply as an anonymous scheme
+ */
+ schemeName.setText("");
+ applyButton_actionPerformed();
+ }
+ }
+ }
+
+ /**