Revision 2ba08401 src/gr/grnet/pithos/web/client/InvitationsDialog.java
b/src/gr/grnet/pithos/web/client/InvitationsDialog.java | ||
---|---|---|
72 | 72 |
* The current displayed page of sent invitations |
73 | 73 |
*/ |
74 | 74 |
int currentPage = 0; |
75 |
|
|
75 |
HorizontalPanel pagerPanel; |
|
76 | 76 |
/** |
77 | 77 |
* The widget constructor. |
78 | 78 |
*/ |
79 |
public InvitationsDialog(Pithos _app, Invitations inv) { |
|
79 |
public InvitationsDialog(Pithos _app, final Invitations inv) {
|
|
80 | 80 |
this.app = _app; |
81 | 81 |
Anchor close = new Anchor(); |
82 | 82 |
close.addStyleName("close"); |
... | ... | |
187 | 187 |
fillSentInvitationsTable(inv); |
188 | 188 |
right.add(sentInvitationsTable); |
189 | 189 |
|
190 |
HorizontalPanel pagerPanel = new HorizontalPanel(); |
|
191 |
Button prev = new Button("prev"); |
|
190 |
pagerPanel = new HorizontalPanel(); |
|
191 |
pagerPanel.setSpacing(5); |
|
192 |
Button prev = new Button("Prev"); |
|
193 |
prev.addStyleName("pithos-pagerButton"); |
|
194 |
prev.addClickHandler(new ClickHandler() { |
|
195 |
|
|
196 |
@Override |
|
197 |
public void onClick(ClickEvent event) { |
|
198 |
if (currentPage > 0) { |
|
199 |
pagerPanel.getWidget(currentPage + 1).removeStyleName("pithos-pagerButtonCurrent"); |
|
200 |
currentPage--; |
|
201 |
fillSentInvitationsTable(inv); |
|
202 |
pagerPanel.getWidget(currentPage + 1).addStyleName("pithos-pagerButtonCurrent"); |
|
203 |
} |
|
204 |
} |
|
205 |
}); |
|
192 | 206 |
pagerPanel.add(prev); |
193 |
Button one = new Button("one"); |
|
194 |
pagerPanel.add(one); |
|
195 |
Button two = new Button("two"); |
|
196 |
pagerPanel.add(two); |
|
197 |
Button next = new Button("next"); |
|
207 |
Button next = new Button("Next"); |
|
208 |
next.addStyleName("pithos-pagerButton"); |
|
209 |
next.addClickHandler(new ClickHandler() { |
|
210 |
|
|
211 |
@Override |
|
212 |
public void onClick(ClickEvent event) { |
|
213 |
int numOfInvs = inv.getSentInvitations().size(); |
|
214 |
int numOfPages = numOfInvs / INV_PER_PAGE + (numOfInvs % INV_PER_PAGE == 0 ? 0 : 1); |
|
215 |
if (currentPage < numOfPages - 1) { |
|
216 |
pagerPanel.getWidget(currentPage + 1).removeStyleName("pithos-pagerButtonCurrent"); |
|
217 |
currentPage++; |
|
218 |
pagerPanel.getWidget(currentPage + 1).addStyleName("pithos-pagerButtonCurrent"); |
|
219 |
fillSentInvitationsTable(inv); |
|
220 |
} |
|
221 |
} |
|
222 |
}); |
|
198 | 223 |
pagerPanel.add(next); |
199 | 224 |
right.add(pagerPanel); |
225 |
updatePagerPanel(inv); |
|
200 | 226 |
|
201 | 227 |
split.add(right); |
202 | 228 |
|
... | ... | |
233 | 259 |
} |
234 | 260 |
|
235 | 261 |
void fillSentInvitationsTable(Invitations inv) { |
262 |
sentInvitationsTable.removeAllRows(); |
|
236 | 263 |
int row = 0; |
237 | 264 |
for (int j=currentPage * INV_PER_PAGE + 0; j<inv.getSentInvitations().size() && j<(currentPage + 1)* INV_PER_PAGE; j++) { |
238 | 265 |
final Invitation i = inv.getSentInvitations().get(j); |
239 | 266 |
sentInvitationsTable.setText(row, 0, i.getRealname()); |
240 |
row++; |
|
241 |
sentInvitationsTable.setText(row, 0, i.getEmail()); |
|
267 |
sentInvitationsTable.getFlexCellFormatter().addStyleName(row, 0, "pithos-invitedEmail"); |
|
242 | 268 |
if (i.isAccepted()) |
243 | 269 |
sentInvitationsTable.setWidget(row, 1, new Image("images/invitation_accepted.png")); |
244 | 270 |
else { |
... | ... | |
253 | 279 |
}); |
254 | 280 |
sentInvitationsTable.setWidget(row, 1, img); |
255 | 281 |
} |
282 |
sentInvitationsTable.getFlexCellFormatter().setRowSpan(row, 1, 2); |
|
256 | 283 |
row++; |
284 |
sentInvitationsTable.setText(row, 0, i.getEmail()); |
|
285 |
row++; |
|
286 |
} |
|
287 |
} |
|
288 |
|
|
289 |
void updatePagerPanel(final Invitations inv) { |
|
290 |
int numOfInvitations = inv.getSentInvitations().size(); |
|
291 |
int numOfPages = numOfInvitations / INV_PER_PAGE + (numOfInvitations % INV_PER_PAGE == 0 ? 0 : 1); |
|
292 |
for (int i=0; i<numOfPages; i++) { |
|
293 |
final Button page = new Button(String.valueOf(i + 1)); |
|
294 |
page.addStyleName("pithos-pagerButton"); |
|
295 |
if (i == currentPage) |
|
296 |
page.addStyleName("pithos-pagerButtonCurrent"); |
|
297 |
|
|
298 |
final int j = i; |
|
299 |
page.addClickHandler(new ClickHandler() { |
|
300 |
|
|
301 |
@Override |
|
302 |
public void onClick(ClickEvent event) { |
|
303 |
pagerPanel.getWidget(currentPage + 1).removeStyleName("pithos-pagerButtonCurrent"); |
|
304 |
currentPage = j; |
|
305 |
fillSentInvitationsTable(inv); |
|
306 |
page.addStyleName("pithos-pagerButtonCurrent"); |
|
307 |
} |
|
308 |
}); |
|
309 |
pagerPanel.insert(page, i + 1); |
|
257 | 310 |
} |
258 | 311 |
} |
259 | 312 |
} |
Also available in: Unified diff