Subversion Repositories SmartDukaan

Rev

Rev 2359 | Rev 3872 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1961 ankur.sing 1
package in.shop2020.catalog.dashboard.client;
2
 
3
import com.google.gwt.event.dom.client.ClickEvent;
4
import com.google.gwt.event.dom.client.ClickHandler;
5
import com.google.gwt.user.client.ui.Anchor;
6
import com.google.gwt.user.client.ui.Composite;
7
import com.google.gwt.user.client.ui.Tree;
8
import com.google.gwt.user.client.ui.TreeItem;
9
 
10
/**
2427 ankur.sing 11
 * A tree containing links to display different sets of items
12
 * based on item statuses and some other parameters.
1961 ankur.sing 13
 */
14
public class CatalogTree extends Composite {
2027 ankur.sing 15
 
16
    public static final String ALL_ITEMS = "All Items";
2359 ankur.sing 17
    public static final String ALL_ACTIVE_ITEMS = "Active Items";
18
    public static final String ALL_PHASED_OUT_ITEMS = "Phased Out Items";
19
    public static final String ALL_PAUSED_ITEMS = "Paused Items";
20
    public static final String IN_PROCESS_ITEMS = "In Process Items";
21
    public static final String CONTENT_COMPLETE_ITEMS = "Content Complete Items";
22
 
23
    public static final String RISKY_ITEMS = "Risky Items";
24
 
2027 ankur.sing 25
    public static final String BEST_DEALS = "Best Deals";
26
    public static final String BEST_SELLERS = "Best Sellers";
27
    public static final String LATEST_ARRIVALS = "Latest Arrivals";
2359 ankur.sing 28
 
1992 ankur.sing 29
    private Tree tree;
30
 
31
    interface TreeListener {
2027 ankur.sing 32
        void onTreeItemClicked(String itemTypes);
1992 ankur.sing 33
    }
34
 
35
    TreeListener treeListener;
1961 ankur.sing 36
 
1992 ankur.sing 37
    public CatalogTree() {
38
        tree = new Tree();
39
        TreeItem root = new TreeItem("Catalog");
40
        tree.addItem(root);
1961 ankur.sing 41
 
2027 ankur.sing 42
        addItem(root, ALL_ITEMS);
2208 ankur.sing 43
        addItem(root, ALL_ACTIVE_ITEMS);
44
        addItem(root, ALL_PHASED_OUT_ITEMS);
45
        addItem(root, ALL_PAUSED_ITEMS);
2359 ankur.sing 46
        addItem(root, IN_PROCESS_ITEMS);
47
        addItem(root, CONTENT_COMPLETE_ITEMS);
48
 
49
        addItem(root, RISKY_ITEMS);
50
 
2027 ankur.sing 51
        addItem(root, BEST_DEALS);
52
        addItem(root, BEST_SELLERS);
53
        addItem(root, LATEST_ARRIVALS);
2208 ankur.sing 54
 
1961 ankur.sing 55
 
1992 ankur.sing 56
        root.setState(true);
57
        initWidget(tree);
58
    }
1961 ankur.sing 59
 
2027 ankur.sing 60
    private void addItem(TreeItem root, final String title) {
1992 ankur.sing 61
        Anchor item = new Anchor(title);
62
        root.addItem(item);
63
        item.addClickHandler(new ClickHandler() {
64
            @Override
65
            public void onClick(ClickEvent event) {
2027 ankur.sing 66
                treeListener.onTreeItemClicked(title);
1992 ankur.sing 67
            }
68
        });
69
    }
70
 
71
    public void setTreeListener(TreeListener treeListener) {
72
        this.treeListener = treeListener;
73
    }
1961 ankur.sing 74
}