From: Christos Stathis Date: Mon, 28 Nov 2011 16:17:46 +0000 (+0200) Subject: Invitations dialog almost ready X-Git-Tag: v0.1~60 X-Git-Url: https://code.grnet.gr/git/pithos-web-client/commitdiff_plain/2ba08401644b0abd1ac7297480f891dbb5a74206 Invitations dialog almost ready --- diff --git a/src/gr/grnet/pithos/web/client/InvitationsDialog.java b/src/gr/grnet/pithos/web/client/InvitationsDialog.java index 27e39d6..cc60f62 100644 --- a/src/gr/grnet/pithos/web/client/InvitationsDialog.java +++ b/src/gr/grnet/pithos/web/client/InvitationsDialog.java @@ -72,11 +72,11 @@ public class InvitationsDialog extends DialogBox { * The current displayed page of sent invitations */ int currentPage = 0; - + HorizontalPanel pagerPanel; /** * The widget constructor. */ - public InvitationsDialog(Pithos _app, Invitations inv) { + public InvitationsDialog(Pithos _app, final Invitations inv) { this.app = _app; Anchor close = new Anchor(); close.addStyleName("close"); @@ -187,16 +187,42 @@ public class InvitationsDialog extends DialogBox { fillSentInvitationsTable(inv); right.add(sentInvitationsTable); - HorizontalPanel pagerPanel = new HorizontalPanel(); - Button prev = new Button("prev"); + pagerPanel = new HorizontalPanel(); + pagerPanel.setSpacing(5); + Button prev = new Button("Prev"); + prev.addStyleName("pithos-pagerButton"); + prev.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + if (currentPage > 0) { + pagerPanel.getWidget(currentPage + 1).removeStyleName("pithos-pagerButtonCurrent"); + currentPage--; + fillSentInvitationsTable(inv); + pagerPanel.getWidget(currentPage + 1).addStyleName("pithos-pagerButtonCurrent"); + } + } + }); pagerPanel.add(prev); - Button one = new Button("one"); - pagerPanel.add(one); - Button two = new Button("two"); - pagerPanel.add(two); - Button next = new Button("next"); + Button next = new Button("Next"); + next.addStyleName("pithos-pagerButton"); + next.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + int numOfInvs = inv.getSentInvitations().size(); + int numOfPages = numOfInvs / INV_PER_PAGE + (numOfInvs % INV_PER_PAGE == 0 ? 0 : 1); + if (currentPage < numOfPages - 1) { + pagerPanel.getWidget(currentPage + 1).removeStyleName("pithos-pagerButtonCurrent"); + currentPage++; + pagerPanel.getWidget(currentPage + 1).addStyleName("pithos-pagerButtonCurrent"); + fillSentInvitationsTable(inv); + } + } + }); pagerPanel.add(next); right.add(pagerPanel); + updatePagerPanel(inv); split.add(right); @@ -233,12 +259,12 @@ public class InvitationsDialog extends DialogBox { } void fillSentInvitationsTable(Invitations inv) { + sentInvitationsTable.removeAllRows(); int row = 0; for (int j=currentPage * INV_PER_PAGE + 0; j