Author: lucaa
Date: 2008-02-18 11:20:14 +0100 (Mon, 18 Feb 2008)
New Revision: 7789

Added:
   
xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/client/ui/dialog/KeywordDialog.java
   
xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/client/ui/menu/ItemObject.java
Removed:
   
xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/client/ui/dialog/AddKeywordDialog.java
Modified:
   
xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/client/Watch.java
   
xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/client/data/DataManager.java
   
xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/client/data/Keyword.java
   
xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/client/ui/menu/FeedTreeWidget.java
   
xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/client/ui/menu/HyperlinkComposite.java
   
xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/client/ui/menu/KeywordsWidget.java
   
xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/client/ui/wizard/ConfigWizard.java
   
xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/public/Watch.css
   
xwiki-products/xwiki-watch/trunk/wikis/watch/src/main/resources/WatchCode/Translations
   
xwiki-products/xwiki-watch/trunk/wikis/watch/src/main/resources/WatchCode/Translations.fr
Log:
XWATCH-97: Adding a "delete" button under keyword names in the list on the right


Modified: 
xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/client/Watch.java
===================================================================
--- 
xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/client/Watch.java
    2008-02-18 08:14:19 UTC (rev 7788)
+++ 
xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/client/Watch.java
    2008-02-18 10:20:14 UTC (rev 7789)
@@ -502,8 +502,8 @@
         });
     }
 
-    public void addKeyword(final String keyword, final String group, final 
AsyncCallback cb) {
-        getDataManager().addKeyword(keyword, group, new 
XWikiAsyncCallback(this) {
+    public void addKeyword(final Keyword keyword, final AsyncCallback cb) {
+        getDataManager().addKeyword(keyword, new XWikiAsyncCallback(this) {
             public void onFailure(Throwable caught) {
                 super.onFailure(caught);
                 cb.onFailure(caught);

Modified: 
xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/client/data/DataManager.java
===================================================================
--- 
xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/client/data/DataManager.java
 2008-02-18 08:14:19 UTC (rev 7788)
+++ 
xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/client/data/DataManager.java
 2008-02-18 10:20:14 UTC (rev 7789)
@@ -177,11 +177,12 @@
         });        
     }
 
-    public void addKeyword(final String keyword, final String group, final 
AsyncCallback cb) {
+    public void addKeyword(final Keyword keyword, final AsyncCallback cb) {
         if (keyword==null)
             cb.onFailure(null);
 
-        
watch.getXWikiServiceInstance().getUniquePageName(watch.getWatchSpace(), 
"Keyword_" + keyword, new XWikiAsyncCallback(watch) {
+        
watch.getXWikiServiceInstance().getUniquePageName(watch.getWatchSpace(), 
+                "Keyword_" + keyword.getName(), new XWikiAsyncCallback(watch) {
             public void onFailure(Throwable caught) {
                 super.onFailure(caught);
                 // We failed to get a unique page name
@@ -197,8 +198,8 @@
                 feedObj.setName(pageName);
                 feedObj.setClassName(Constants.CLASS_AGGREGATOR_KEYWORD);
                 feedObj.setNumber(0);
-                feedObj.setProperty(Constants.PROPERTY_KEYWORD_NAME, keyword);
-                feedObj.setProperty(Constants.PROPERTY_KEYWORD_GROUP, group);
+                feedObj.setProperty(Constants.PROPERTY_KEYWORD_NAME, 
keyword.getName());
+                feedObj.setProperty(Constants.PROPERTY_KEYWORD_GROUP, 
keyword.getGroup());
                 watch.getXWikiServiceInstance().saveObject(feedObj, new 
AsyncCallback() {
                     public void onFailure(Throwable throwable) {
                         cb.onFailure(throwable);
@@ -359,12 +360,14 @@
         }
     }
 
-    public void removeKeyword(String keyword, final AsyncCallback cb) {
+    public void removeKeyword(Keyword keyword, final AsyncCallback cb) {
+        String pageName = keyword.getPageName(); 
         try {
-            if ((keyword==null)||(keyword.equals("")))
+            if ((pageName == null) || (pageName.equals(""))) {
                 cb.onFailure(null);
+            }
 
-            watch.getXWikiServiceInstance().deleteDocument(keyword, new 
XWikiAsyncCallback(watch) {
+            watch.getXWikiServiceInstance().deleteDocument(pageName, new 
XWikiAsyncCallback(watch) {
                 public void onFailure(Throwable caught) {
                     super.onFailure(caught);
                     cb.onFailure(caught);

Modified: 
xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/client/data/Keyword.java
===================================================================
--- 
xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/client/data/Keyword.java
     2008-02-18 08:14:19 UTC (rev 7788)
+++ 
xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/client/data/Keyword.java
     2008-02-18 10:20:14 UTC (rev 7789)
@@ -34,6 +34,11 @@
         setGroup((String) xobj.getProperty("group"));
         setPageName(xobj.getName());
     }
+    
+    public Keyword(String keyword, String group) {
+        this.name = keyword;
+        this.group = group;
+    }
 
     public String getDisplayName() {
         if ((group!=null)&&(!group.equals("")))
@@ -51,7 +56,7 @@
     }
 
     public String getGroup() {
-        return group;
+        return group == null ? "" : this.group;
     }
 
     public void setGroup(String group) {
@@ -59,7 +64,7 @@
     }
 
     public String getPageName() {
-        return pageName;
+        return pageName == null ? "" : this.pageName;
     }
 
     public void setPageName(String pageName) {

Deleted: 
xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/client/ui/dialog/AddKeywordDialog.java
===================================================================
--- 
xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/client/ui/dialog/AddKeywordDialog.java
       2008-02-18 08:14:19 UTC (rev 7788)
+++ 
xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/client/ui/dialog/AddKeywordDialog.java
       2008-02-18 10:20:14 UTC (rev 7789)
@@ -1,149 +0,0 @@
-/**
- * See the NOTICE file distributed with this work for additional
- * information regarding copyright ownership.
- * <p/>
- * This is free software;you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation;either version2.1of
- * the License,or(at your option)any later version.
- * <p/>
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY;without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the GNU
- * Lesser General Public License for more details.
- * <p/>
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software;if not,write to the Free
- * Software Foundation,Inc.,51 Franklin St,Fifth Floor,Boston,MA
- * 02110-1301 USA,or see the FSF site:http://www.fsf.org.
- */
-package com.xpn.xwiki.watch.client.ui.dialog;
-
-import com.xpn.xwiki.gwt.api.client.app.XWikiGWTApp;
-import com.xpn.xwiki.gwt.api.client.dialog.Dialog;
-import com.xpn.xwiki.watch.client.Watch;
-import com.xpn.xwiki.watch.client.data.Group;
-import com.google.gwt.user.client.ui.*;
-import com.google.gwt.user.client.Window;
-import com.google.gwt.user.client.rpc.AsyncCallback;
-
-import java.util.Map;
-import java.util.Iterator;
-
-public class AddKeywordDialog extends Dialog {
-    protected TextBox keywordTextBox = new TextBox();
-    protected ListBox groupListBox = new ListBox();
-    protected String keyword;
-    protected String group;
-
-    /**
-     * Choice dialog
-     * @param app  XWiki GWT App object to access translations and css prefix 
names
-     * @param name dialog name
-     * @param buttonModes button modes Dialog.BUTTON_CANCEL|Dialog.BUTTON_NEXT 
for Cancel / Next
-     */
-    public AddKeywordDialog(XWikiGWTApp app, String name, int buttonModes, 
String keyword, String group) {
-        super(app, name, buttonModes);
-        this.keyword = keyword;
-        this.group = group;
-
-        FlowPanel main = new FlowPanel();
-        main.addStyleName(getCSSName("main"));
-
-        HTMLPanel invitationPanel = new 
HTMLPanel(app.getTranslation(getDialogTranslationName() + ".invitation"));
-        invitationPanel.addStyleName(getCssPrefix() + "-invitation");
-        main.add(invitationPanel);
-        main.add(getParametersPanel());
-        main.add(getActionsPanel());
-        add(main);
-    }
-
-    protected boolean updateData() {
-        keyword = keywordTextBox.getText();
-        int selectedIndex = (groupListBox==null) ? -1 : 
groupListBox.getSelectedIndex();
-        // If the All item is selected set no group
-        if (selectedIndex>0)
-         group = groupListBox.getValue(selectedIndex);
-
-        if (keyword.equals("")) {
-            Window.alert(app.getTranslation(getDialogTranslationName() + 
".nokeyword"));
-            return false;
-        }
-
-        return true;
-    }
-
-    protected Widget getParametersPanel() {
-        FlowPanel paramsPanel = new FlowPanel();
-        Label keywordLabel = new Label();
-        keywordLabel.setStyleName("keyword-label");
-        keywordLabel.setText(app.getTranslation(getDialogTranslationName() + 
".keyword"));
-        paramsPanel.add(keywordLabel);
-        if (keyword!=null)
-            keywordTextBox.setText(keyword);
-        keywordTextBox.setVisibleLength(20);
-        keywordTextBox.setName("keyword");
-        keywordTextBox.setStyleName(getCSSName("keyword"));
-        paramsPanel.add(keywordTextBox);
-        paramsPanel.add(getGroupsFields());
-        return paramsPanel;
-    }
-
-    protected Widget getGroupsFields() {
-        FlowPanel groupsPanel = new FlowPanel();
-        Label groupLabel = new Label();
-        groupLabel.setStyleName("groups-label");
-        groupLabel.setText(app.getTranslation(getDialogTranslationName() + 
".groups"));
-        groupsPanel.add(groupLabel);
-        groupListBox.setMultipleSelect(false);
-        Map groupMap = ((Watch)app).getConfig().getGroups();
-        Iterator it = groupMap.keySet().iterator();
-        boolean selected = false;
-        String all = ((Watch)app).getTranslation("all");
-        groupListBox.addItem("all", all);
-        while (it.hasNext()) {
-            String groupname = (String) it.next();
-            if (!groupname.equals(all)) {
-                //get group for this key
-                Group currentGroup = (Group)groupMap.get(groupname);
-                //don't add it unless it is a real group
-                if (!currentGroup.getPageName().equals("") || 
group.equals(groupname)) {
-                    String grouptitle = currentGroup.getName();
-                    groupListBox.addItem(grouptitle,groupname);
-                    if (group.equals(groupname)) {
-                        selected = true;
-                        
groupListBox.setItemSelected(groupListBox.getItemCount(), true);
-                    }
-                }
-            }
-        }
-        // we need to select the first item (All) if none is selected
-        if (selected==false) {
-            groupListBox.setItemSelected(0, true);
-        }
-        groupsPanel.add(groupListBox);
-        return groupsPanel;
-    }
-
-    protected void endDialog() {
-        if (updateData()) {
-            setCurrentResult(keyword);
-            ((Watch)app).addKeyword(keyword, group, new AsyncCallback() {
-                public void onFailure(Throwable throwable)
-                {
-                    // There should already have been an error display
-                }
-                
-                public void onSuccess(Object object) 
-                {
-                    endDialog2();
-                }
-            });
-        }
-    }
-
-    private void endDialog2() {
-        super.endDialog();
-    }
-
-}

Added: 
xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/client/ui/dialog/KeywordDialog.java
===================================================================
--- 
xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/client/ui/dialog/KeywordDialog.java
                          (rev 0)
+++ 
xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/client/ui/dialog/KeywordDialog.java
  2008-02-18 10:20:14 UTC (rev 7789)
@@ -0,0 +1,161 @@
+/**
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ * <p/>
+ * This is free software;you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation;either version2.1of
+ * the License,or(at your option)any later version.
+ * <p/>
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY;without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the GNU
+ * Lesser General Public License for more details.
+ * <p/>
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software;if not,write to the Free
+ * Software Foundation,Inc.,51 Franklin St,Fifth Floor,Boston,MA
+ * 02110-1301 USA,or see the FSF site:http://www.fsf.org.
+ */
+package com.xpn.xwiki.watch.client.ui.dialog;
+
+import com.xpn.xwiki.gwt.api.client.app.XWikiGWTApp;
+import com.xpn.xwiki.gwt.api.client.dialog.Dialog;
+import com.xpn.xwiki.watch.client.Watch;
+import com.xpn.xwiki.watch.client.data.Group;
+import com.xpn.xwiki.watch.client.data.Keyword;
+import com.google.gwt.user.client.ui.*;
+import com.google.gwt.user.client.Window;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+
+import java.util.Map;
+import java.util.Iterator;
+
+public class KeywordDialog extends Dialog {
+    protected TextBox keywordTextBox = new TextBox();
+    protected ListBox groupListBox = new ListBox();
+    protected Keyword keyword;
+
+    /**
+     * Choice dialog
+     * @param app  XWiki GWT App object to access translations and css prefix 
names
+     * @param name dialog name
+     * @param buttonModes button modes Dialog.BUTTON_CANCEL|Dialog.BUTTON_NEXT 
for Cancel / Next
+     */
+    public KeywordDialog(XWikiGWTApp app, String name, int buttonModes, 
Keyword keyword) {
+        super(app, name, buttonModes);
+        this.keyword = keyword;
+
+        FlowPanel main = new FlowPanel();
+        main.addStyleName(getCSSName("main"));
+
+        HTMLPanel invitationPanel = new 
HTMLPanel(app.getTranslation(getDialogTranslationName() + ".invitation"));
+        invitationPanel.addStyleName(getCssPrefix() + "-invitation");
+        main.add(invitationPanel);
+        main.add(getParametersPanel());
+        main.add(getActionsPanel());
+        add(main);
+    }
+
+    protected boolean updateData() {
+        String keywordString = keywordTextBox.getText();
+        //no keyword by default
+        String groupPageName = "";
+        int selectedIndex = (groupListBox==null) ? -1 : 
groupListBox.getSelectedIndex();
+        // If the All item is selected set no group
+        if (selectedIndex > 0) {
+            groupPageName = groupListBox.getValue(selectedIndex);
+        }
+
+        if (keywordString.equals("")) {
+            Window.alert(app.getTranslation(getDialogTranslationName() + 
".nokeyword"));
+            return false; 
+        } else {
+            //update the keyword and go on
+            this.keyword.setName(keywordString);
+            this.keyword.setGroup(groupPageName);
+            return true;
+        }
+    }
+
+    protected Widget getParametersPanel() {
+        FlowPanel paramsPanel = new FlowPanel();
+        Label keywordLabel = new Label();
+        keywordLabel.setStyleName("keyword-label");
+        keywordLabel.setText(app.getTranslation(getDialogTranslationName() + 
".keyword"));
+        paramsPanel.add(keywordLabel);
+        if (keyword != null) {
+            keywordTextBox.setText(keyword.getName());
+        }
+        keywordTextBox.setVisibleLength(20);
+        keywordTextBox.setName("keyword");
+        keywordTextBox.setStyleName(getCSSName("keyword"));
+        paramsPanel.add(keywordTextBox);
+        paramsPanel.add(getGroupsFields());
+        return paramsPanel;
+    }
+
+    protected Widget getGroupsFields() {
+        FlowPanel groupsPanel = new FlowPanel();
+        Label groupLabel = new Label();
+        groupLabel.setStyleName("groups-label");
+        groupLabel.setText(app.getTranslation(getDialogTranslationName() + 
".groups"));
+        groupsPanel.add(groupLabel);
+        groupListBox.setMultipleSelect(false);
+        Map groupMap = ((Watch)app).getConfig().getGroups();
+        Iterator it = groupMap.keySet().iterator();
+        boolean selected = false;
+        String all = ((Watch)app).getTranslation("all");
+        groupListBox.addItem("all", all);
+        while (it.hasNext()) {
+            String groupname = (String) it.next();
+            if (!groupname.equals(all)) {
+                //get group for this key
+                Group currentGroup = (Group)groupMap.get(groupname);
+                //don't add it unless it is a real group
+                if (!currentGroup.getPageName().equals("") 
+                    || this.keyword.getGroup().equals(groupname)) {
+                    String grouptitle = currentGroup.getName();
+                    groupListBox.addItem(grouptitle,groupname);
+                    if (this.keyword.getGroup().equals(groupname)) {
+                        selected = true;
+                        
groupListBox.setItemSelected(groupListBox.getItemCount() - 1, true);
+                    }
+                }
+            }
+        }
+        // we need to select the first item (All) if none is selected
+        if (selected==false) {
+            groupListBox.setItemSelected(0, true);
+        }
+        groupsPanel.add(groupListBox);
+        return groupsPanel;
+    }
+
+    protected void endDialog() {
+        if (updateData()) {
+            setCurrentResult(keyword);
+            //if the kw has just been created, add it
+            if (this.keyword.getPageName().equals("")) {
+                ((Watch)app).addKeyword(this.keyword, new AsyncCallback() {
+                    public void onFailure(Throwable throwable)
+                    {
+                        // There should already have been an error display
+                    }
+                   
+                    public void onSuccess(Object object) 
+                    {
+                        endDialog2();
+                    }
+                });
+            } else {
+                endDialog2();
+            }
+        }
+    }
+
+    private void endDialog2() {
+        super.endDialog();
+    }
+
+}

Modified: 
xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/client/ui/menu/FeedTreeWidget.java
===================================================================
--- 
xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/client/ui/menu/FeedTreeWidget.java
   2008-02-18 08:14:19 UTC (rev 7788)
+++ 
xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/client/ui/menu/FeedTreeWidget.java
   2008-02-18 10:20:14 UTC (rev 7789)
@@ -90,14 +90,14 @@
         for (int i = 0; i < this.groupTree.getItemCount(); i++) {
             TreeItem currentTreeItem = this.groupTree.getItem(i);
             //get user object
-            TreeItemObject userObj = 
(TreeItemObject)currentTreeItem.getUserObject();
+            ItemObject userObj = (ItemObject)currentTreeItem.getUserObject();
             itemsState.put(userObj.getKey(), new 
Boolean(currentTreeItem.getState()));
         }
         //get the selected item to set it back when the tree is refreshed 
         TreeItem selectedTreeItem = this.groupTree.getSelectedItem();
         String selectedItemKey = null;
         if (selectedTreeItem != null) {
-            TreeItemObject selectedItemObject = 
(TreeItemObject)selectedTreeItem.getUserObject();
+            ItemObject selectedItemObject = 
(ItemObject)selectedTreeItem.getUserObject();
             if (selectedItemObject != null) {
                 selectedItemKey = selectedItemObject.getKey();
             }
@@ -141,7 +141,7 @@
                     //set it's userObject to the name of the group + name of 
the feed since a 
                     //feed can be part of multiple groups and we need to 
identify it uniquely.
                     String itemTreeKey = groupname + "." + feedname;
-                    TreeItemObject feedObj = new 
FeedTreeItemObject(itemTreeKey, feed);
+                    ItemObject feedObj = new FeedTreeItemObject(itemTreeKey, 
feed);
                     TreeItem feedItem = new TreeItem();
                     feedItem.setUserObject(feedObj);
                     selected = false;
@@ -167,34 +167,8 @@
     public void resizeWindow() {
         // Watch.setMaxHeight(panel);
     }
-
-    /**
-     * Class to enclose data to be stored by a tree item that should be able 
to:
-     * <ul>
-     * <li> get uniquely identifying key for this tree item </li>
-     * <li> generate a widget to be displayed by the tree item </li>
-     * </ul>
-     */
-    public abstract class TreeItemObject {
-        //the unique ID 
-        protected String key;
-        //the data of the TreeItemObject
-        protected Object data; 
-        
-        public TreeItemObject(String key, Object data)
-        {
-            this.key = key;
-            this.data = data;
-        }
-        
-        public String getKey() {
-            return this.key;
-        }
-        
-        public abstract Widget getWidget(boolean selected);
-    }
     
-    public class GroupTreeItemObject extends TreeItemObject {
+    public class GroupTreeItemObject extends ItemObject {
         public GroupTreeItemObject(String key, Object data)
         {
             super(key, data);
@@ -284,7 +258,7 @@
         }
     }
     
-    public class FeedTreeItemObject extends TreeItemObject {
+    public class FeedTreeItemObject extends ItemObject {
 
         public FeedTreeItemObject(String key, Object data)
         {

Modified: 
xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/client/ui/menu/HyperlinkComposite.java
===================================================================
--- 
xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/client/ui/menu/HyperlinkComposite.java
       2008-02-18 08:14:19 UTC (rev 7788)
+++ 
xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/client/ui/menu/HyperlinkComposite.java
       2008-02-18 10:20:14 UTC (rev 7789)
@@ -1,5 +1,8 @@
 package com.xpn.xwiki.watch.client.ui.menu;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import com.google.gwt.user.client.ui.Composite;
 import com.google.gwt.user.client.ui.FlowPanel;
 import com.google.gwt.user.client.ui.Hyperlink;
@@ -28,4 +31,11 @@
     public void remove(HyperlinkComposite cHyperlink) {
         this.hyperlinksPanel.remove(cHyperlink);
     }
+    public List getHyperlinks() {
+        ArrayList hyperlinks = new ArrayList();
+        for (int i = 0; i < this.hyperlinksPanel.getWidgetCount(); i++) {
+            hyperlinks.add(this.hyperlinksPanel.getWidget(i));
+        }
+        return hyperlinks;
+    }
 }

Added: 
xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/client/ui/menu/ItemObject.java
===================================================================
--- 
xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/client/ui/menu/ItemObject.java
                               (rev 0)
+++ 
xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/client/ui/menu/ItemObject.java
       2008-02-18 10:20:14 UTC (rev 7789)
@@ -0,0 +1,49 @@
+/**
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ * <p/>
+ * This is free software;you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation;either version2.1of
+ * the License,or(at your option)any later version.
+ * <p/>
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY;without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the GNU
+ * Lesser General Public License for more details.
+ * <p/>
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software;if not,write to the Free
+ * Software Foundation,Inc.,51 Franklin St,Fifth Floor,Boston,MA
+ * 02110-1301 USA,or see the FSF site:http://www.fsf.org.
+ *
+ */
+package com.xpn.xwiki.watch.client.ui.menu;
+
+import com.google.gwt.user.client.ui.Widget;
+
+/**
+ * Class to enclose data to be stored by a interface item that should be able 
to:
+ * <ul>
+ * <li> get uniquely identifying key for this item </li>
+ * <li> generate a widget to be displayed by the item </li>
+ * </ul>
+ */
+public abstract class ItemObject {
+    //the unique ID 
+    protected String key;
+    //the data of the ItemObject
+    protected Object data; 
+    
+    public ItemObject(String key, Object data)
+    {
+        this.key = key;
+        this.data = data;
+    }
+    
+    public String getKey() {
+        return this.key;
+    }
+    
+    public abstract Widget getWidget(boolean selected);
+}
\ No newline at end of file

Modified: 
xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/client/ui/menu/KeywordsWidget.java
===================================================================
--- 
xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/client/ui/menu/KeywordsWidget.java
   2008-02-18 08:14:19 UTC (rev 7788)
+++ 
xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/client/ui/menu/KeywordsWidget.java
   2008-02-18 10:20:14 UTC (rev 7789)
@@ -1,9 +1,15 @@
 package com.xpn.xwiki.watch.client.ui.menu;
 
+import com.xpn.xwiki.gwt.api.client.app.XWikiAsyncCallback;
+import com.xpn.xwiki.gwt.api.client.dialog.Dialog;
 import com.xpn.xwiki.watch.client.ui.WatchWidget;
+import com.xpn.xwiki.watch.client.ui.dialog.GroupDialog;
+import com.xpn.xwiki.watch.client.ui.dialog.KeywordDialog;
 import com.xpn.xwiki.watch.client.Watch;
 import com.xpn.xwiki.watch.client.data.Group;
 import com.xpn.xwiki.watch.client.data.Keyword;
+import com.google.gwt.user.client.Window;
+import com.google.gwt.user.client.rpc.AsyncCallback;
 import com.google.gwt.user.client.ui.*;
 
 import java.util.*;
@@ -66,14 +72,12 @@
         String groupactive = watch.getFilterStatus().getGroup();
         while (it.hasNext()) {
             Keyword keyword  = (Keyword) it.next();
-            Hyperlink link = (Hyperlink) keywordsLink.get(keyword);
-            if (link!=null) {
-                if (keyword.getName().equals(keywordactive) 
-                    && keyword.getGroup().equals(groupactive)) {
-                    link.addStyleName(watch.getStyleName("keyword", 
"link-active"));
-                } else {
-                    link.removeStyleName(watch.getStyleName("keyword", 
"link-active"));
-                }
+            KeywordItemObject kwIo = 
(KeywordItemObject)keywordsLink.get(keyword);
+            if (keyword.getName().equals(keywordactive) 
+                && keyword.getGroup().equals(groupactive)) {
+                kwIo.setSelected(true);
+            } else {
+                kwIo.setSelected(false);
             }
         }
     }
@@ -87,43 +91,145 @@
             while (it.hasNext()) {
                 final Keyword keyword = (Keyword) it.next();
                 if ((keyword.getName()!=null)&&(!keyword.equals(""))) {
-                    Group kwGroup = (Group) watch.getConfig().getGroups()
-                                                       
.get(keyword.getGroup());
-                    String groupDisplayName;
-                    if (kwGroup == null) {
-                        groupDisplayName = keyword.getGroup();
-                    } else {
-                        groupDisplayName = kwGroup.getName();
-                    }
-                    String keywordDisplayName = keyword.getName() 
-                        + ((!groupDisplayName.trim().equals("")) ?  (" - " + 
groupDisplayName) : "");
-                    Hyperlink link = new Hyperlink(keywordDisplayName, "");
-                    link.setStyleName(watch.getStyleName("keyword", "link"));
-                    keywordsLink.put(keyword, link);
-                    link.addClickListener(new ClickListener() {
-                        public void onClick(Widget widget) {
-                            watch.refreshOnActivateKeyword(keyword);
-                        }
-                    });
-                    keywordsPanel.add(link);
+                    //get the widget
+                    String kwKey = keyword.getPageName() + "-" + 
keyword.getGroup();
+                    KeywordItemObject kwObject = new KeywordItemObject(kwKey, 
keyword);
+                    keywordsLink.put(keyword, kwObject);
+                    keywordsPanel.add(kwObject.getWidget(false));
                 }
             }
         }
         resetSelections();
     }
+    
+    public class KeywordItemObject extends ItemObject {
+        protected HyperlinkComposite widget;
 
-    /*
-    public void setActiveTags(String[] tags) {
-        Iterator it = tagsLink.values().iterator();
-        while (it.hasNext()) {
-            
((Hyperlink)it.next()).removeStyleName(watch.getStyleName("tagscloud", 
"active"));
+        public KeywordItemObject(String key, Object data)
+        {
+            super(key, data);
         }
-        for (int i=0;i<tags.length;i++) {
-            Hyperlink link = (Hyperlink) tagsLink.get(tags[i]);
-            if (link!=null)
-             link.setStyleName(watch.getStyleName("tagscloud", "active"));
+        
+        public String getDisplayName() {
+            Keyword keyword = (Keyword)this.data;
+            Group kwGroup = (Group) watch.getConfig().getGroups()
+                            .get(keyword.getGroup());
+            String groupDisplayName;
+            if (kwGroup == null) {
+            groupDisplayName = keyword.getGroup();
+            } else {
+            groupDisplayName = kwGroup.getName();
+            }
+            String keywordDisplayName = keyword.getName() 
+                + ((!groupDisplayName.trim().equals("")) ?  (" - " + 
groupDisplayName) : "");
+            return keywordDisplayName;
         }
+
+        public Widget getWidget(boolean selected)
+        {
+            final Keyword keyword = (Keyword)this.data;
+            Hyperlink link = new Hyperlink(this.getDisplayName(), "");
+            link.addStyleName(watch.getStyleName("keyword", "link"));
+            link.addClickListener(new ClickListener() {
+                public void onClick(Widget widget) {
+                    watch.refreshOnActivateKeyword(keyword);
+                }
+            });
+            widget = new HyperlinkComposite(link);
+            widget.addStyleName(watch.getStyleName("keyword"));
+            this.setSelected(selected);
+            return widget;
+        }
+        
+        /**
+         * Ugly method to change the keyword widget associated to this keyword.
+         * 
+         * @param kwWidget the current widget of the keyword to change
+         * @param selected wheather the item should be changed to selected or 
not
+         */
+        public void setSelected(boolean selected) {
+            //remove all hyperlinks, if any
+            for (Iterator wIt = this.widget.getHyperlinks().iterator(); 
wIt.hasNext();) {
+                HyperlinkComposite w = (HyperlinkComposite)wIt.next();
+                this.widget.remove(w);
+            } 
+            if (selected) {
+                
this.widget.addStyleName(watch.getStyleName("keyword","active"));
+            } else {
+                
this.widget.removeStyleName(watch.getStyleName("keyword","active"));
+            }
+            final Keyword keyword = (Keyword)this.data;
+            //now add some actions if needed
+            if (selected && !keyword.getPageName().equals("")) {
+                //create a composite with link as main widget and some actions
+                Hyperlink editHyperlink = new 
Hyperlink(watch.getTranslation("keyword.edit"), "#");
+                editHyperlink.addClickListener(new ClickListener() {
+                    public void onClick (Widget widget) {
+                        KeywordDialog kwDialog = new KeywordDialog(watch, 
"addkeyword", 
+                            Dialog.BUTTON_CANCEL | Dialog.BUTTON_NEXT, 
keyword);
+                        kwDialog.setAsyncCallback(new AsyncCallback() {
+                            public void onFailure(Throwable throwable) {
+                                //nothing
+                            }
+                            public void onSuccess(Object object) {
+                                Keyword newKeyword = (Keyword)object;
+                                
watch.getDataManager().updateKeyword(newKeyword, new XWikiAsyncCallback(watch) {
+                                    public void onFailure(Throwable caught) {
+                                        super.onFailure(caught);
+                                    }
+    
+                                    public void onSuccess(Object result) {
+                                        super.onSuccess(result);
+                                        //refresh on the new keyword
+                                        watch.refreshOnNewKeyword();
+                                        
watch.refreshOnActivateKeyword(keyword);
+                                    }
+                                });
+                            }
+                        });
+                        kwDialog.show();
+                    }
+                });
+                HyperlinkComposite editHyperlinkComposite = new 
HyperlinkComposite(editHyperlink);
+                Hyperlink deleteHyperlink = new 
Hyperlink(watch.getTranslation("keyword.delete"), "");
+                deleteHyperlink.addClickListener(new ClickListener() {
+                   public void onClick(Widget widget) {
+                       String confirmString = 
watch.getTranslation("removekeyword.confirm", 
+                           new String[] 
{KeywordItemObject.this.getDisplayName()});
+                       boolean confirm = Window.confirm(confirmString);
+                       if (confirm) {
+                           watch.getDataManager().removeKeyword(keyword, new 
XWikiAsyncCallback(watch) {
+                               public void onFailure(Throwable caught) {
+                                   super.onFailure(caught);
+                               }
+                               public void onSuccess(Object result) {
+                                   super.onSuccess(result);
+                                   watch.refreshOnNewKeyword();
+                                   //cancel the keyword selection
+                                   watch.refreshOnActivateKeyword(new 
Keyword("", ""));
+                               }
+                           });
+                       } else {
+                           //nothing
+                       }
+                   } 
+                });
+                HyperlinkComposite deleteHyperlinkComposite = new 
HyperlinkComposite(deleteHyperlink);
+                //set styles
+                
editHyperlinkComposite.setStyleName(watch.getStyleName("keyword", 
"keywordaction") 
+                    + " " + watch.getStyleName("keyword", "editkeyword"));
+                
deleteHyperlinkComposite.setStyleName(watch.getStyleName("keyword", 
"keywordaction") 
+                    + " " + watch.getStyleName("keyword", "deletekeyword"));
+                //add the two actions to the hyperlink composite, in reverse 
order since they will
+                //be floated to the right
+                this.widget.add(deleteHyperlinkComposite);
+                this.widget.add(editHyperlinkComposite);
+            }
+        }
+
+        public HyperlinkComposite getWidget()
+        {
+            return widget;
+        }
     }
-    */
-
 }

Modified: 
xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/client/ui/wizard/ConfigWizard.java
===================================================================
--- 
xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/client/ui/wizard/ConfigWizard.java
   2008-02-18 08:14:19 UTC (rev 7788)
+++ 
xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/client/ui/wizard/ConfigWizard.java
   2008-02-18 10:20:14 UTC (rev 7789)
@@ -3,6 +3,7 @@
 import com.xpn.xwiki.watch.client.Watch;
 import com.xpn.xwiki.watch.client.Feed;
 import com.xpn.xwiki.watch.client.data.Group;
+import com.xpn.xwiki.watch.client.data.Keyword;
 import com.xpn.xwiki.watch.client.ui.dialog.*;
 import com.xpn.xwiki.gwt.api.client.wizard.Wizard;
 import com.xpn.xwiki.gwt.api.client.dialog.ChoiceDialog;
@@ -64,7 +65,7 @@
         addSearchEngineDialog("feedster", 
"http://www.feedster.com/search/type/rss/{0}";);
         addSearchEngineDialog("wikio", "http://rss.wikio.fr/search/{0}.rss";);
 
-        AddKeywordDialog addKeywordDialog = new AddKeywordDialog(watch, 
"addkeyword", Dialog.BUTTON_PREVIOUS | Dialog.BUTTON_CANCEL | 
Dialog.BUTTON_NEXT, "", "");
+        KeywordDialog addKeywordDialog = new KeywordDialog(watch, 
"addkeyword", Dialog.BUTTON_PREVIOUS | Dialog.BUTTON_CANCEL | 
Dialog.BUTTON_NEXT, new Keyword("", ""));
         addDialog(addKeywordDialog, "end");
 
         GroupDialog addGroupDialog = new GroupDialog(watch, "addgroup", 
Dialog.BUTTON_PREVIOUS | Dialog.BUTTON_CANCEL | Dialog.BUTTON_NEXT, new 
Group());

Modified: 
xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/public/Watch.css
===================================================================
--- 
xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/public/Watch.css
     2008-02-18 08:14:19 UTC (rev 7788)
+++ 
xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/public/Watch.css
     2008-02-18 10:20:14 UTC (rev 7789)
@@ -219,17 +219,20 @@
        white-space: normal;
 }
 
-.watch-feedtree-feedaction, .watch-feedtree-groupaction {
+.watch-feedtree-feedaction, .watch-feedtree-groupaction, 
.watch-keyword-keywordaction {
        float: right;
        padding-left: 0.5em;
        padding-right: 0.5em;
+       font-size:0.9em;
+       color: #FFFFFF;
+       text-decoration: none;
 }
 
-div.watch-feedtree-editfeed, div.watch-feedtree-editgroup{
+div.watch-feedtree-editfeed, div.watch-feedtree-editgroup, 
div.watch-keyword-editkeyword {
        background-color: #FFAA00;
 }
 
-div.watch-feedtree-deletefeed, div.watch-feedtree-deletegroup{
+div.watch-feedtree-deletefeed, div.watch-feedtree-deletegroup, 
div.watch-keyword-deletekeyword{
        background-color: #FF0000;
 }
 
@@ -537,13 +540,13 @@
 {color: #fff;text-decoration: none;    padding: 0 4px;font-size:  1.5em;}
 
 
- div.watch-keyword-link a, div.watch-tagscloud a
-  div.watch-keyword-link a:link, div.watch-tagscloud a:link,
-   div.watch-keyword-link a:visited, div.watch-tagscloud a:visited,
-    div.watch-keyword-link a:active, div.watch-tagscloud a:active{
+ div.watch-keyword a, div.watch-tagscloud a
+  div.watch-keyword a:link, div.watch-tagscloud a:link,
+   div.watch-keyword a:visited, div.watch-tagscloud a:visited,
+    div.watch-keyword a:active, div.watch-tagscloud a:active{
        color: #fff;
        text-decoration: none;
-line-height:15px;
+       line-height:15px;
 }
 
 /* @end */
@@ -831,12 +834,22 @@
   line-height: 40px;
 }
 
-div.watch-tagscloud-active a, div.watch-keyword-link-active a{
-font-weight: bold;
+div.watch-tagscloud-active a {
+       font-weight: bold;
        color: #ceff7e;
-color: orange;
-       text-decoration: underline;
+       color: orange;
+       text-decoration: none;
 }
+
+div.watch-keyword {
+       clear: both;
+       padding-right: 5px;
+}
+
+div.watch-keyword-active div.watch-keyword-link {
+       font-weight: bold;
+}
+
 /*
 filter styles
 */

Modified: 
xwiki-products/xwiki-watch/trunk/wikis/watch/src/main/resources/WatchCode/Translations
===================================================================
--- 
xwiki-products/xwiki-watch/trunk/wikis/watch/src/main/resources/WatchCode/Translations
      2008-02-18 08:14:19 UTC (rev 7788)
+++ 
xwiki-products/xwiki-watch/trunk/wikis/watch/src/main/resources/WatchCode/Translations
      2008-02-18 10:20:14 UTC (rev 7789)
@@ -73,6 +73,8 @@
 watch.feedtree.title=Feeds
 watch.feedtree.edit=edit
 watch.feedtree.delete=delete
+watch.keyword.delete=delete
+watch.keyword.edit=edit
 
 watch.actionbar.title=Related actions:
 watch.actionbar.pressreview=Press Review
@@ -139,6 +141,7 @@
 
 watch.removefeed.confirm=Are you sure you want to delete feed "{0}"?
 watch.removegroup.confirm=Are you sure you want to delete group "{0}"?
+watch.removekeyword.confirm=Are you sure you want to delete keyword "{0}"?
 
 watch.addgroup.invitation=Please add a group below
 watch.addgroup.group=Group Name

Modified: 
xwiki-products/xwiki-watch/trunk/wikis/watch/src/main/resources/WatchCode/Translations.fr
===================================================================
--- 
xwiki-products/xwiki-watch/trunk/wikis/watch/src/main/resources/WatchCode/Translations.fr
   2008-02-18 08:14:19 UTC (rev 7788)
+++ 
xwiki-products/xwiki-watch/trunk/wikis/watch/src/main/resources/WatchCode/Translations.fr
   2008-02-18 10:20:14 UTC (rev 7789)
@@ -73,6 +73,8 @@
 watch.feedtree.title=Flux
 watch.feedtree.edit=modifier
 watch.feedtree.delete=effacer
+watch.keyword.edit=modifier
+watch.keyword.delete=effacer
 
 watch.actionbar.title=Actions Possibles:
 watch.actionbar.pressreview=Revue de presse
@@ -127,6 +129,7 @@
 
 watch.removefeed.confirm=�tes-vous s�r de vouloir effacer le flux "{0}"?
 watch.removegroup.confirm=�tes-vous s�r de vouloir effacer le group "{0}"?
+watch.removekeyword.confirm=�tes-vous s�r de vouloir effacer le mot-cl� "{0}"?
 
 watch.addgroup.invitation=Veuillez ajouter le nom du groupe ci dessous
 watch.addgroup.group=Noms du groupe:

_______________________________________________
notifications mailing list
notifications@xwiki.org
http://lists.xwiki.org/mailman/listinfo/notifications

Reply via email to