Author: lucaa
Date: 2007-12-12 18:23:28 +0100 (Wed, 12 Dec 2007)
New Revision: 6361
Modified:
xwiki-products/xwiki-watch/trunk/web/src/main/java/com/xpn/xwiki/watch/client/Config.java
xwiki-products/xwiki-watch/trunk/web/src/main/java/com/xpn/xwiki/watch/client/NewArticlesMonitoring.java
xwiki-products/xwiki-watch/trunk/web/src/main/java/com/xpn/xwiki/watch/client/Watch.java
xwiki-products/xwiki-watch/trunk/web/src/main/java/com/xpn/xwiki/watch/client/ui/articles/ArticleListWidget.java
Log:
XWATCH-83: added an article list in Config as an ArticleListWidget model; Moved
the refreshArticleNumber functionality in Watch, only updating data in Config.
Modified:
xwiki-products/xwiki-watch/trunk/web/src/main/java/com/xpn/xwiki/watch/client/Config.java
===================================================================
---
xwiki-products/xwiki-watch/trunk/web/src/main/java/com/xpn/xwiki/watch/client/Config.java
2007-12-12 17:19:31 UTC (rev 6360)
+++
xwiki-products/xwiki-watch/trunk/web/src/main/java/com/xpn/xwiki/watch/client/Config.java
2007-12-12 17:23:28 UTC (rev 6361)
@@ -35,6 +35,7 @@
private Map feedsByGroupList;
private List keywords;
private Map groups;
+ private List articles;
public Config() {
}
@@ -65,6 +66,7 @@
feedsByGroupList = new HashMap();
keywords = new ArrayList();
groups = new HashMap();
+ articles = new ArrayList();
}
/**
@@ -84,7 +86,34 @@
}
});
}
+
+ public void refreshArticleList(final AsyncCallback cb) {
+ FilterStatus fstatus = watch.getFilterStatus();
+ watch.getDataManager().getArticles(fstatus, watch.getArticleNbParam(),
fstatus.getStart(), new AsyncCallback() {
+ public void onFailure(Throwable caught) {
+ if (cb != null) {
+ cb.onFailure(caught);
+ }
+ }
+ public void onSuccess(Object result) {
+ //update the article list
+ updateArticleList((List)result);
+ if (cb != null) {
+ cb.onSuccess(result);
+ }
+ }
+ });
+ }
+
+ private void updateArticleList(List result) {
+ this.articles.clear();
+ //update the articles list
+ for (Iterator rIt = result.iterator(); rIt.hasNext();) {
+ this.articles.add(rIt.next());
+ }
+ }
+
private void addToGroup(String group, String groupTitle, Feed feed) {
Map feeds = (Map) feedsByGroupList.get(group);
if (feeds == null) {
@@ -136,16 +165,21 @@
}
- public void refreshArticleNumber() {
+ public void refreshArticleNumber(final AsyncCallback cb) {
// Load the article counts
watch.getDataManager().getArticleCount(new AsyncCallback() {
public void onFailure(Throwable throwable) {
- // Silent error
+ if (cb != null) {
+ cb.onFailure(throwable);
+ }
}
public void onSuccess(Object result) {
// Update the article list with the current results
updateArticleNumbers((List) result);
- watch.getUserInterface().refreshData("feedtree");
+ //call the cb.onSuccess if cb exists
+ if (cb != null) {
+ cb.onSuccess(result);
+ }
}
});
}
@@ -165,4 +199,9 @@
// watch.refreshFeedTreeUI();
}
+ public List getArticles()
+ {
+ return articles;
+ }
+
}
Modified:
xwiki-products/xwiki-watch/trunk/web/src/main/java/com/xpn/xwiki/watch/client/NewArticlesMonitoring.java
===================================================================
---
xwiki-products/xwiki-watch/trunk/web/src/main/java/com/xpn/xwiki/watch/client/NewArticlesMonitoring.java
2007-12-12 17:19:31 UTC (rev 6360)
+++
xwiki-products/xwiki-watch/trunk/web/src/main/java/com/xpn/xwiki/watch/client/NewArticlesMonitoring.java
2007-12-12 17:23:28 UTC (rev 6361)
@@ -91,7 +91,7 @@
lastChange = new Date();
startBlinking(watch.getTranslation("newarticles", args1),
watch.getTranslation("articles", args2));
// let's refresh the article numbers
- watch.getConfig().refreshArticleNumber();
+ watch.refreshArticleNumber();
}
}
}
Modified:
xwiki-products/xwiki-watch/trunk/web/src/main/java/com/xpn/xwiki/watch/client/Watch.java
===================================================================
---
xwiki-products/xwiki-watch/trunk/web/src/main/java/com/xpn/xwiki/watch/client/Watch.java
2007-12-12 17:19:31 UTC (rev 6360)
+++
xwiki-products/xwiki-watch/trunk/web/src/main/java/com/xpn/xwiki/watch/client/Watch.java
2007-12-12 17:23:28 UTC (rev 6361)
@@ -18,6 +18,8 @@
import java.util.Date;
import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -202,7 +204,7 @@
userInterface.init();
userInterface.refreshData("feedtree");
// Load the number of articles for each feed
- config.refreshArticleNumber();
+ refreshArticleNumber();
// Refresh tag cloud aynchronously
refreshTagCloud();
refreshKeywords();
@@ -221,6 +223,24 @@
public void refreshTagCloud() {
userInterface.refreshData("tagcloud");
}
+
+ /**
+ * Refreshes the article number and handles the interface refresh
triggered by this
+ * data update, if necessary.
+ */
+ public void refreshArticleNumber() {
+ getConfig().refreshArticleNumber(new AsyncCallback() {
+ public void onSuccess(Object arg0)
+ {
+ //update the interface objects affected by this change
+ userInterface.refreshData("feedtree");
+ }
+ public void onFailure(Throwable arg0)
+ {
+ //silent failure
+ }
+ });
+ }
public void refreshOnTagActivated(String tagName) {
FilterStatus fstatus = getFilterStatus();
@@ -249,8 +269,18 @@
* Refresh the Article List
*/
public void refreshArticleList() {
- userInterface.refreshData("articlelist");
- newArticlesMonitoring.stopBlinking();
+ config.refreshArticleList(new XWikiAsyncCallback(this) {
+ public void onFailure(Throwable caught)
+ {
+ super.onFailure(caught);
+ }
+ public void onSuccess(Object result)
+ {
+ super.onSuccess(result);
+ userInterface.refreshData("articlelist");
+ newArticlesMonitoring.stopBlinking();
+ }
+ });
}
/**
@@ -265,7 +295,7 @@
// Refresh the feed tree with refreshed config data
userInterface.refreshData("feedtree");
// Load the number of articles for each feed
- config.refreshArticleNumber();
+ refreshArticleNumber();
}
});
}
Modified:
xwiki-products/xwiki-watch/trunk/web/src/main/java/com/xpn/xwiki/watch/client/ui/articles/ArticleListWidget.java
===================================================================
---
xwiki-products/xwiki-watch/trunk/web/src/main/java/com/xpn/xwiki/watch/client/ui/articles/ArticleListWidget.java
2007-12-12 17:19:31 UTC (rev 6360)
+++
xwiki-products/xwiki-watch/trunk/web/src/main/java/com/xpn/xwiki/watch/client/ui/articles/ArticleListWidget.java
2007-12-12 17:23:28 UTC (rev 6361)
@@ -63,20 +63,9 @@
}
public void refreshData() {
- FilterStatus fstatus = watch.getFilterStatus();
- watch.getDataManager().getArticles(fstatus, watch.getArticleNbParam(),
fstatus.getStart(), new XWikiAsyncCallback(watch) {
- public void onFailure(Throwable caught) {
- super.onFailure(caught);
- }
-
- public void onSuccess(Object result) {
- super.onSuccess(result);
- // Load article list
- List list = (List) result;
- showArticles(list);
- resizeWindow();
- }
- });
+ List articlesList = watch.getConfig().getArticles();
+ showArticles(articlesList);
+ resizeWindow();
}
_______________________________________________
notifications mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/notifications