Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/ProjectList.java @ 220:35094660f91a
Implemented a context menu for the project list.
flys-client/trunk@1663 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Mon, 11 Apr 2011 15:38:43 +0000 |
parents | b92281182c6b |
children | 9040663aee01 |
comparison
equal
deleted
inserted
replaced
219:7523faf567e5 | 220:35094660f91a |
---|---|
1 package de.intevation.flys.client.client.ui; | 1 package de.intevation.flys.client.client.ui; |
2 | 2 |
3 import com.google.gwt.core.client.GWT; | 3 import com.google.gwt.core.client.GWT; |
4 import com.google.gwt.user.client.rpc.AsyncCallback; | 4 import com.google.gwt.user.client.rpc.AsyncCallback; |
5 | 5 |
6 import com.smartgwt.client.util.SC; | |
6 import com.smartgwt.client.widgets.Canvas; | 7 import com.smartgwt.client.widgets.Canvas; |
7 import com.smartgwt.client.widgets.Label; | 8 import com.smartgwt.client.widgets.Label; |
8 import com.smartgwt.client.widgets.grid.ListGrid; | 9 import com.smartgwt.client.widgets.grid.ListGrid; |
9 import com.smartgwt.client.widgets.grid.ListGridField; | 10 import com.smartgwt.client.widgets.grid.ListGridField; |
10 import com.smartgwt.client.widgets.grid.ListGridRecord; | 11 import com.smartgwt.client.widgets.grid.ListGridRecord; |
12 import com.smartgwt.client.widgets.grid.events.RowContextClickEvent; | |
13 import com.smartgwt.client.widgets.grid.events.RowContextClickHandler; | |
11 import com.smartgwt.client.widgets.layout.VLayout; | 14 import com.smartgwt.client.widgets.layout.VLayout; |
15 import com.smartgwt.client.widgets.menu.Menu; | |
16 import com.smartgwt.client.widgets.menu.MenuItem; | |
17 import com.smartgwt.client.widgets.menu.events.MenuItemClickEvent; | |
18 import com.smartgwt.client.widgets.menu.events.ClickHandler; | |
12 import com.smartgwt.client.types.VerticalAlignment; | 19 import com.smartgwt.client.types.VerticalAlignment; |
13 | 20 |
14 import de.intevation.flys.client.shared.model.Collection; | 21 import de.intevation.flys.client.shared.model.Collection; |
15 import de.intevation.flys.client.shared.model.CollectionRecord; | 22 import de.intevation.flys.client.shared.model.CollectionRecord; |
16 import de.intevation.flys.client.shared.model.User; | 23 import de.intevation.flys.client.shared.model.User; |
77 | 84 |
78 date.setWidth(100); | 85 date.setWidth(100); |
79 name.setWidth(195); | 86 name.setWidth(195); |
80 | 87 |
81 grid.setFields(date, name); | 88 grid.setFields(date, name); |
89 | |
90 grid.addRowContextClickHandler(new RowContextClickHandler() { | |
91 public void onRowContextClick(RowContextClickEvent event) { | |
92 CollectionRecord record = (CollectionRecord) event.getRecord(); | |
93 | |
94 Menu menu = createContextMenu(record); | |
95 grid.setContextMenu(menu); | |
96 menu.showContextMenu(); | |
97 | |
98 event.cancel(); | |
99 } | |
100 }); | |
101 } | |
102 | |
103 | |
104 /** | |
105 * Creates a new context menu that interacts with a CollectionRecord. | |
106 * | |
107 * @param record The selected record. | |
108 * | |
109 * @return the context menu with operations that interact with | |
110 * <i>record</i>. | |
111 */ | |
112 protected Menu createContextMenu(final CollectionRecord record) { | |
113 Menu menu = new Menu(); | |
114 | |
115 MenuItem open = new MenuItem(messages.open_project()); | |
116 open.addClickHandler(new ClickHandler() { | |
117 public void onClick(MenuItemClickEvent evt) { | |
118 SC.say("Open project: " + record.getName()); | |
119 } | |
120 }); | |
121 | |
122 MenuItem del = new MenuItem(messages.delete_project()); | |
123 del.addClickHandler(new ClickHandler() { | |
124 public void onClick(MenuItemClickEvent evt) { | |
125 SC.warn("Removing projects is not implemented."); | |
126 } | |
127 }); | |
128 | |
129 menu.addItem(open); | |
130 menu.addItem(del); | |
131 | |
132 return menu; | |
82 } | 133 } |
83 | 134 |
84 | 135 |
85 /** | 136 /** |
86 * The init() method handles the layout stuff for this widget. | 137 * The init() method handles the layout stuff for this widget. |