[dmdirc commit] r5821 - trunk/src/com/dmdirc/config/prefs

0 views
Skip to first unread message

com...@dmdirc.com

unread,
Jan 23, 2010, 7:46:06 PM1/23/10
to dmd...@googlegroups.com
Author: chris87
Date: 2010-01-24 00:46:04 +0000 (Sun, 24 Jan 2010)
New Revision: 5821

Modified:
trunk/src/com/dmdirc/config/prefs/PreferencesCategory.java
Log:
Show warnings on unloaded plugin's prefs categories

Git-version: 0.6.3m2-352-gd4b5449


Modified: trunk/src/com/dmdirc/config/prefs/PreferencesCategory.java
===================================================================
--- trunk/src/com/dmdirc/config/prefs/PreferencesCategory.java 2010-01-23 23:10:05 UTC (rev 5820)
+++ trunk/src/com/dmdirc/config/prefs/PreferencesCategory.java 2010-01-24 00:46:04 UTC (rev 5821)
@@ -19,6 +19,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
+
package com.dmdirc.config.prefs;

import com.dmdirc.util.ListenerList;
@@ -30,7 +31,7 @@
* Represents one category of preferences. Categories can contain 0 or more
* subcategories, and either 0 or more PreferencesSettings or exactly 1
* PreferencesInterface object.
- *
+ *
* @author chris
*/
public class PreferencesCategory {
@@ -38,40 +39,43 @@
/** A logger for this class. */
private static final java.util.logging.Logger LOGGER = java.util.logging
.Logger.getLogger(PreferencesCategory.class.getName());
-
+
/** The title (name) of this category. */
private final String title;
-
+
/** A description of this category. */
private final String description;

/** The icon to use for this category. */
private final String icon;
-
+
+ /** The warning displayed for this category, if any. */
+ private String warning;
+
/** Whether or not this category is inline. */
private boolean isInline = false;
-
+
/** Whether or not to show inline categories before settings. */
private boolean inlineBefore = true;

/** Our parent category, if known. */
private PreferencesCategory parent;
-
+
/** A list of settings in this category. */
private final List<PreferencesSetting> settings = new ArrayList<PreferencesSetting>();
-
+
/** A list of subcategories of this category. */
private final List<PreferencesCategory> subcats = new ArrayList<PreferencesCategory>();
-
+
/** The replacement object to use for this category. */
private final PreferencesInterface object;
-
+
/** A list of listeners who are interested in this category. */
private final ListenerList listeners = new ListenerList();

/**
* Creates a new preferences category that contains settings.
- *
+ *
* @param title The title of this preferences category
* @param description The description of this category
*/
@@ -103,7 +107,7 @@
final PreferencesInterface object) {
this(title, description, null, object);
}
-
+
/**
* Creates a new preferences category that contains an object.
*
@@ -120,50 +124,50 @@
this.icon = icon;
this.object = object;
}
-
+
/**
* Sets this as an inline category.
- *
+ *
* @return A reference to this category, for convenience
*/
public PreferencesCategory setInline() {
isInline = true;
return this;
}
-
+
/**
* Sets this category to show inline categories after settings, rather than
* before.
- *
+ *
* @return A reference to this category, for convenience
*/
public PreferencesCategory setInlineAfter() {
inlineBefore = false;
return this;
}
-
+
/**
* Determines if this category is meant to be displayed inline or not.
- *
+ *
* @return True if this category should be shown inline, false otherwise
*/
public boolean isInline() {
return isInline;
}
-
+
/**
* Determines whether this category wants inline subcats to be displayed
* before the settings, or after.
- *
+ *
* @return True if subcats should be displayed first, false otherwise.
*/
public boolean isInlineBefore() {
return inlineBefore;
}
-
+
/**
* Adds the specified setting to this category.
- *
+ *
* @param setting The setting to be added
*/
public void addSetting(final PreferencesSetting setting) {
@@ -171,13 +175,13 @@
throw new IllegalArgumentException("Can't add settings to a " +
"category that uses a replacement object");
}
-
+
settings.add(setting);
}
-
+
/**
* Adds the specified subcategory to this category.
- *
+ *
* @param subcategory The category to be asdded
*/
public void addSubCategory(final PreferencesCategory subcategory) {
@@ -192,7 +196,7 @@

/**
* Retrieves the description of this category.
- *
+ *
* @return This category's description
*/
public String getDescription() {
@@ -201,7 +205,7 @@

/**
* Retrieves the settings in this category.
- *
+ *
* @return This category's settings
*/
public List<PreferencesSetting> getSettings() {
@@ -210,7 +214,7 @@

/**
* Retrieves the subcategories of this category.
- *
+ *
* @return This category's subcategories
*/
public List<PreferencesCategory> getSubcats() {
@@ -219,7 +223,7 @@

/**
* Retrieves the title of this category.
- *
+ *
* @return This category's title
*/
public String getTitle() {
@@ -235,20 +239,40 @@
public String getIcon() {
return icon;
}
-
+
/**
+ * Retrieves the warning for this category, if any.
+ *
+ * @return This category's warning message, or null if one doesn't exist
+ * @since 0.6.3
+ */
+ public String getWarning() {
+ return warning;
+ }
+
+ /**
+ * Sets the warning that this preferences category will display.
+ *
+ * @param warning The new warning, or null to remove any previous warning
+ * @since 0.6.3
+ */
+ public void setWarning(final String warning) {
+ this.warning = warning;
+ }
+
+ /**
* Determines if this category has a replacement object.
- *
+ *
* @return True if the category has a replacement object, false otherwise
* @see #getObject()
*/
public boolean hasObject() {
return object != null;
}
-
+
/**
* Retrieves this category's replacement object.
- *
+ *
* @return This category's replacement object.
* @see #hasObject()
*/
@@ -323,25 +347,25 @@
child.dismiss();
}
}
-
+
/**
* Registers a change listener for this category.
- *
+ *
* @param listener The listener to be added
*/
public void addChangeListener(final CategoryChangeListener listener) {
listeners.add(CategoryChangeListener.class, listener);
}
-
+
/**
* Removes a change listener from this category.
- *
+ *
* @param listener The listener to be added
*/
public void removeChangeListener(final CategoryChangeListener listener) {
listeners.remove(CategoryChangeListener.class, listener);
}
-
+
/**
* Informs all registered listeners that this category has been selected.
*/
@@ -350,7 +374,7 @@
listener.categorySelected(this);
}
}
-
+
/**
* Informs all registered listeners that this category has been deselected.
*/
@@ -358,6 +382,6 @@
for (CategoryChangeListener listener : listeners.get(CategoryChangeListener.class)) {
listener.categoryDeselected(this);
}
- }
+ }

}

com...@dmdirc.com

unread,
Jan 23, 2010, 7:48:04 PM1/23/10
to dmd...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages