You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by gb...@apache.org on 2010/08/31 20:03:47 UTC
svn commit: r991277 -
/pivot/branches/1.5.x/wtk/src/org/apache/pivot/wtk/content/TreeBranch.java
Author: gbrown
Date: Tue Aug 31 18:03:46 2010
New Revision: 991277
URL: http://svn.apache.org/viewvc?rev=991277&view=rev
Log:
Resolve PIVOT-622.
Modified:
pivot/branches/1.5.x/wtk/src/org/apache/pivot/wtk/content/TreeBranch.java
Modified: pivot/branches/1.5.x/wtk/src/org/apache/pivot/wtk/content/TreeBranch.java
URL: http://svn.apache.org/viewvc/pivot/branches/1.5.x/wtk/src/org/apache/pivot/wtk/content/TreeBranch.java?rev=991277&r1=991276&r2=991277&view=diff
==============================================================================
--- pivot/branches/1.5.x/wtk/src/org/apache/pivot/wtk/content/TreeBranch.java (original)
+++ pivot/branches/1.5.x/wtk/src/org/apache/pivot/wtk/content/TreeBranch.java Tue Aug 31 18:03:46 2010
@@ -16,6 +16,7 @@
*/
package org.apache.pivot.wtk.content;
+import java.net.URL;
import java.util.Comparator;
import java.util.Iterator;
@@ -25,9 +26,11 @@ import org.apache.pivot.collections.List
import org.apache.pivot.collections.Sequence;
import org.apache.pivot.util.ImmutableIterator;
import org.apache.pivot.util.ListenerList;
+import org.apache.pivot.util.ThreadUtilities;
+import org.apache.pivot.util.concurrent.TaskExecutionException;
+import org.apache.pivot.wtk.ApplicationContext;
import org.apache.pivot.wtk.media.Image;
-
/**
* Default tree branch implementation.
*/
@@ -67,6 +70,58 @@ public class TreeBranch extends TreeNode
this.expandedIcon = expandedIcon;
}
+ /**
+ * Sets the tree branch's expanded icon by URL.
+ * <p>
+ * <b>Note</b>: Using this signature will cause an entry to be added in the
+ * application context's {@linkplain ApplicationContext#getResourceCache()
+ * resource cache} if one does not already exist.
+ *
+ * @param expandedIconURL
+ * The location of the expanded icon to set.
+ */
+ public void setExpandedIcon(URL expandedIconURL) {
+ if (expandedIconURL == null) {
+ throw new IllegalArgumentException("expandedIconURL is null.");
+ }
+
+ Image icon = (Image)ApplicationContext.getResourceCache().get(expandedIconURL);
+
+ if (icon == null) {
+ try {
+ icon = Image.load(expandedIconURL);
+ } catch (TaskExecutionException exception) {
+ throw new IllegalArgumentException(exception);
+ }
+
+ ApplicationContext.getResourceCache().put(expandedIconURL, icon);
+ }
+
+ setExpandedIcon(icon);
+ }
+
+ /**
+ * Sets the tree branch's expanded icon by {@linkplain ClassLoader#getResource(String)
+ * resource name}.
+ * <p>
+ * <b>Note</b>: Using this signature will cause an entry to be added in the
+ * application context's {@linkplain ApplicationContext#getResourceCache()
+ * resource cache} if one does not already exist.
+ *
+ * @param expandedIconURL
+ * The resource name of the expanded icon to set.
+ *
+ * @see #setExpandedIcon(URL)
+ */
+ public void setExpandedIcon(String expandedIconName) {
+ if (expandedIconName == null) {
+ throw new IllegalArgumentException("expandedIconName is null.");
+ }
+
+ ClassLoader classLoader = ThreadUtilities.getClassLoader();
+ setExpandedIcon(classLoader.getResource(expandedIconName));
+ }
+
@Override
public int add(TreeNode treeNode) {
int index = treeNodes.add(treeNode);