def __init__(self, owner): Composite.__init__(self) self.owner = owner self.bar = DockPanel() self.gotoFirst = Button("<<", self) self.gotoNext = Button(">", self) self.gotoPrev = Button("<", self) self.status = HTML() self.initWidget(self.bar) self.bar.setStyleName("navbar") self.status.setStyleName("status") buttons = HorizontalPanel() buttons.add(self.gotoFirst) buttons.add(self.gotoPrev) buttons.add(self.gotoNext) self.bar.add(buttons, DockPanel.EAST) self.bar.setCellHorizontalAlignment(buttons, HasAlignment.ALIGN_RIGHT) self.bar.add(self.status, DockPanel.CENTER) self.bar.setVerticalAlignment(HasAlignment.ALIGN_MIDDLE) self.bar.setCellHorizontalAlignment(self.status, HasAlignment.ALIGN_RIGHT) self.bar.setCellVerticalAlignment(self.status, HasAlignment.ALIGN_MIDDLE) self.bar.setCellWidth(self.status, "100%") self.gotoPrev.setEnabled(False) self.gotoFirst.setEnabled(False)
def __init__(self): DialogBox.__init__(self) # Use this opportunity to set the dialog's caption. self.setText("About the Mail Sample") # Create a DockPanel to contain the 'about' label and the 'OK' button. outer = DockPanel() outer.setSpacing(4) outer.add(Image(AboutDialog.LOGO_IMAGE), DockPanel.WEST) # Create the 'OK' button, along with a listener that hides the dialog # when the button is clicked. Adding it to the 'south' position within # the dock causes it to be placed at the bottom. buttonPanel = HorizontalPanel() buttonPanel.setHorizontalAlignment(HasAlignment.ALIGN_RIGHT) buttonPanel.add(Button("Close", self)) outer.add(buttonPanel, DockPanel.SOUTH) # Create the 'about' label. Placing it in the 'rest' position within the # dock causes it to take up any remaining space after the 'OK' button # has been laid out. textplain = "This sample application demonstrates the construction " textplain += "of a complex user interface using pyjamas' built-in widgets. Have a look " textplain += "at the code to see how easy it is to build your own apps!" text = HTML(textplain) text.setStyleName("mail-AboutText") outer.add(text, DockPanel.CENTER) # Add a bit of spacing and margin to the dock to keep the components from # being placed too closely together. outer.setSpacing(8) self.setWidget(outer)
def renderPosts(self, addContentToPnl, posts): """ Render posts i a stream """ addContentToPnl.clear() addContentToPnl.add(HTML(u"Number of posts: " + java.str(posts.__len__()))) for post in Util.iterate(posts): try: GWT.log(u"Render: " + java.str(JSONObject(post).toString()), None) postContentPnl = VerticalPanel() postContentPnl.addStyleName(u"postContent") postContentPnl.add(HTML(java.str(FbName(post.getActorId())) + u" " + post.getMessage())) if post.getAttachment().getName() is not None: postContentPnl.add(self.createAttachmentUI(post.getAttachment())) if post.getLikes().getCount() > 0: postContentPnl.add(self.createLikesUI(post.getLikes())) if post.getComments().getCount() > 0: postContentPnl.add(self.createCommentsUI(post.getComments())) p = HorizontalPanel() # Add profilepic on the left, postcontent on the right p.addStyleName(u"post") p.add(FbProfilePic(post.getActorId())) p.add(postContentPnl) addContentToPnl.add(p) # postPnl.add ( asJson ( "LikesAsJson: ", post.getLikes () )); except Exception,e: GWT.log(u"Unkown exception ", e)
def createInput(self, lbl, w): h = HorizontalPanel() lblHtml = HTML(lbl) lblHtml.setWidth(u"150px") h.add(lblHtml) h.add(w) return h
def __init__(self, calendar): Composite.__init__(self) self.calendar = calendar self.dayCheckBoxListener = DayCheckBoxListener(calendar) self.outer = VerticalPanel() self.initWidget(self.outer) self.setStyleName("DynaTable-DayFilterWidget") self.outer.add(DayCheckBox(self, "Sunday", 0)) self.outer.add(DayCheckBox(self, "Monday", 1)) self.outer.add(DayCheckBox(self, "Tuesday", 2)) self.outer.add(DayCheckBox(self, "Wednesday", 3)) self.outer.add(DayCheckBox(self, "Thursday", 4)) self.outer.add(DayCheckBox(self, "Friday", 5)) self.outer.add(DayCheckBox(self, "Saturday", 6)) self.buttonAll = Button("All", self) self.buttonNone = Button("None", self) hp = HorizontalPanel() hp.setHorizontalAlignment(HasAlignment.ALIGN_CENTER) hp.add(self.buttonAll) hp.add(self.buttonNone) self.outer.add(hp) self.outer.setCellVerticalAlignment(hp, HasAlignment.ALIGN_BOTTOM) self.outer.setCellHorizontalAlignment(hp, HasAlignment.ALIGN_CENTER)
def createLabelAndInput(self, label, field): h = HorizontalPanel() l = HTML(java.str(u"<b>" + java.str(label)) + u": </b>") l.setWidth(u"150px") h.add(l) h.add(field) return h
def createEventFilter(self): filter = HorizontalPanel() self.listBox.addItem(u"All") for rs in RsvpStatus.values(): self.listBox.addItem(java.str(rs)) filter.setSpacing(10) filter.add(HTML(u"Filter By: ")) filter.add(self.listBox) return filter
class EventSelector(Composite): """ Let user select an event """ @java.init def __init__(self, *a, **kw): self.outer = HorizontalPanel() self.apiClient = ApiFactory.getInstance() self.selectButton = Button(u" Go ") self.selectHandler = None self.loader = Image(u"/loader.gif") @java.interface class EventSelectorHandler(java.Interface): def onSelect(self, eid): pass @__init__.register @java.typed() def __init__(self, ): self.__init__._super() """ New instance """ self.outer.setSpacing(10) self.outer.add(HTML(u"Select Event: ")) self.outer.add(self.loader) class _anonymous(AsyncCallback): @java.typed(Throwable) def onFailure(self, caught): self.outer.add(HTML(u"Failed get events...")) @java.typed(List) def onSuccess(self, result): self.outer.remove(self.loader) dropBox = ListBox(False) for e in result: GWT.log(u"adding " + java.str(e.getName()), None) dropBox.addItem(e.getName(), e.getEidString()) self.outer.add(dropBox) self.outer.add(self.selectButton) class _anonymous(ClickHandler): @java.typed(ClickEvent) def onClick(self, event): self.selectHandler.onSelect(Long(dropBox.getValue(dropBox.getSelectedIndex()))) self.selectButton.addClickHandler(_anonymous()) self.apiClient.eventsGet(None, _anonymous()) self.initWidget(self.outer) @java.typed(EventSelectorHandler) def addSelectHandler(self, handler): self.selectHandler = handler
class Photos_get(Showcase): """ Showcase for method call <code>photos.get</code> @author olamar72 """ @java.init def __init__(self, *a, **kw): self.paramsWrapper = None self.resultWrapper = None self.paramsResultWrapper = None method = u"photos.get" @__init__.register @java.typed() def __init__(self, ): self.__init__._super() self.paramsWrapper = HorizontalPanel() self.resultWrapper = VerticalPanel() self.paramsResultWrapper = VerticalPanel() self.paramsWrapper.addStyleName(u"params") self.paramsResultWrapper.add(self.paramsWrapper) self.paramsResultWrapper.add(self.resultWrapper) fs = FriendSelector() class _anonymous(FriendSelectionHandler): @java.typed(Long) def onSelected(self, uid): self.displayPhotos(uid) fs.addFriendSelectionHandler(_anonymous()) self.paramsWrapper.add(fs) self.initWidget(self.paramsResultWrapper) # * Display photos of selected user @java.private @java.typed(Long) def displayPhotos(self, subjId): self.resultWrapper.add(self.getLoader()) class _anonymous(AsyncCallback): @java.typed(Throwable) def onFailure(self, caught): self.handleFailure(caught) @java.typed(List) def onSuccess(self, result): photosPanel = FlowPanel() photosPanel.getElement().setId(u"photosPanel") self.resultWrapper.clear() self.resultWrapper.add(HTML(java.str(u"<h4>Photos size: " + java.str(result.size())) + u"</h4>")) for p in result: photosPanel.add(FbPhoto(p.getPid(), Size.thumb)) self.resultWrapper.add(photosPanel) Xfbml.parse(photosPanel.getElement()) self.apiClient.photosGet(subjId, _anonymous()) # Get photos from facebook
class LoginBox(Composite): """ Displays a rounded box ( firefox/safari ) with at facebook connect button. And a link as backup in case the button is not rendered. """ @java.init def __init__(self, *a, **kw): self.outer = VerticalPanel() self.inner = HorizontalPanel() self.loginButton = FbLoginButton(u"facebookConnectLogin()") self.loginLink = Anchor(u"don't see a button? Click here to login") self.loginCallback = None @java.typed(LoginCallback) def addLoginCallback(self, loginCallback): self.loginCallback = loginCallback @__init__.register @java.typed() def __init__(self, ): self.__init__._super() self.outer.getElement().setId(u"OuterRouter") class _anonymous(ClickHandler): @java.typed(ClickEvent) def onClick(self, event): class _anonymous(AsyncCallback): @java.typed(Throwable) def onFailure(self, caught): GWT.log(u"Require session failed: " + java.str(caught)) @java.typed(Boolean) def onSuccess(self, isLoggedIn): if self.loginCallback is not None and isLoggedIn: self.loginCallback.onLogin() FacebookConnect.requireSession(_anonymous()) self.loginLink.addClickHandler(_anonymous()) # Login with the javascript api. GWT client doesnt render the fb:login-button self.outer.getElement().setId(u"LoginBox") self.inner.addStyleName(u"inner") self.outer.add(HTML(u"<h1>Login with your facebook id: </h1>")) self.outer.add(HTML(u"This demo uses facebook data heavily to demonstrate API calls etc so you might as well login right away")) self.inner.setSpacing(10) self.inner.add(HTML(u"Click the button to allow this application to access your facebook account")) self.inner.add(self.loginButton) self.outer.add(self.inner) self.outer.add(self.loginLink) sourceCode = HTML(u"<br/><br/>This project on Gogle code : <a target=_blank href=\"http://code.google.com/p/gwt-facebook/\"> http://code.google.com/p/gwt-facebook/ </a>") sourceCode.addStyleName(u"sourceCode") self.outer.setWidth(u"400px") self.outer.add(sourceCode) Xfbml.parse(self.outer) self.initWidget(self.outer)
def handleCommentsResponse(self, comments): for comment in comments: box = VerticalPanel() box.addStyleName(u"commentBox") p = HorizontalPanel() p.setSpacing(5) p.add(FbProfilePic(comment.getFromId(), Size.square)) p.add(HTML(java.str(comment.getText()) + u" from " + FbName(comment.getFromId()))) box.add(p) removeLink = Anchor(u"Remove") removeLink.addClickHandler(self.CommentsRemoveClickHandler(comment.getId())) box.add(removeLink) self.outer.add(box) Xfbml.parse(self.outer)
def createInputUi(self): """ * Create input text area and submit button. """ vp = VerticalPanel() p = HorizontalPanel() p.setSpacing(10) p.add(FbProfilePic(self.apiClient.getLoggedInUser(), FbProfilePic.Size.square)) self.text.setHeight(u"100px") self.text.setWidth(u"400px") vp.add(self.text) vp.add(self.submitButton) p.add(vp) return p
def onModuleLoad(self): b = Button("Click me", greet) hp = HorizontalPanel() hp.setWidth("100%") hp.setHeight("100%") hp.setBorderWidth("1") l = Label("hello world") hp.add(l) RootPanel().add(b) RootPanel().add(hp) #DOM.setCapture(l) #DOM.setEventListener(l, self) Window.addWindowResizeListener(self) Timer(1000, self)
def displayUsers(self, picsList, page): startIdx = page * PAGE_SIZE stopIdx = startIdx + (PAGE_SIZE - 1) holder = VerticalPanel() holder.getElement().setId(u"ProfilePics-Page_" + java.str(page)) i = startIdx while i < self.uids.size() and i < stopIdx: i+= 1 uid = self.uids.get(i) wrapper = HorizontalPanel() wrapper.setSpacing(10) profilePic = FbProfilePic(uid, Size.square) name = FbName(uid) wrapper.add(profilePic) wrapper.add(name) holder.add(wrapper) picsList.add(holder) Xfbml.parse(holder)
class TopMenu(Composite): """ Top Menu """ @java.init def __init__(self, *a, **kw): self.outer = HorizontalPanel() self.loginInfo = HorizontalPanel() self.eventBus = None self.apiClient = ApiFactory.getInstance() @__init__.register @java.typed() def __init__(self, ): self.__init__._super() self.outer.getElement().setId(u"TopMenu") self.loginInfo.addStyleName(u"loginInfo") self.outer.add(HTML(u" ")) self.outer.add(self.loginInfo) self.initWidget(self.outer) def renderLoginInfo(self): self.loginInfo.clear() uid = self.apiClient.getLoggedInUser() fbName = FbName(uid, False) fbName.setUseyou(False) pic = FbProfilePic(uid, FbProfilePic.Size.square) pic.setSize(u"15px", u"15px") GWT.log(u"TopMenu: render " + java.str(fbName), None) self.loginInfo.add(fbName) tmp = SimplePanel() tmp.addStyleName(u"miniProfilePic") tmp.setWidget(pic) self.loginInfo.add(tmp) logout = Anchor(u"Logout") class _anonymous(ClickHandler): @java.typed(ClickEvent) def onClick(self, event): FacebookConnect.logoutAndRedirect(u"/") logout.addClickHandler(_anonymous()) self.loginInfo.add(logout)
def createAttachmentUI(self, attachment): """ Create attachment UI """ p = VerticalPanel() p.addStyleName(u"attachment fbColorLight rounded addSpace") p.add(HTML(u"<h3>Attachment</h3> ")) thumbs = HorizontalPanel() thumbs.setSpacing(10) for m in Util.iterate(attachment.getMedia()): p.add(HTML(u"<b>MediaContent:</b> " + java.str(m.getType()))) if m.getSrc() is not None: thumbs.add(Image(m.getSrc())) if m.getTypeEnum() == Type.video: vLink = Anchor(u"See Video") vLink.setHref(m.getVideo().getSourceUrl()) p.add(vLink) p.add(thumbs) return p
def renderMainContent(self, addContentToPnl): """ Render when user granted us permission to read stream """ streamBody = VerticalPanel() streamBody.getElement().setId(u"streamBody") menu = HorizontalPanel() menu.addStyleName(u"streamMenu") menu.setSpacing(5) postsLink = Anchor(u"Posts") # Create menu profilesLink = Anchor(u"Profiles") albumsLink = Anchor(u"Albums") menu.add(HTML(u"<b> Choose Stream : </b> ")) menu.add(postsLink) menu.add(albumsLink) menu.add(profilesLink) class _anonymous(ClickHandler): @java.typed(ClickEvent) def onClick(self, event): self.renderPosts(streamBody, self.stream.getPosts()) Xfbml.parse(streamBody) postsLink.addClickHandler(_anonymous()) # Click posts link class _anonymous(ClickHandler): @java.typed(ClickEvent) def onClick(self, event): streamBody.clear() self.renderProfiles(streamBody, self.stream.getProfiles()) profilesLink.addClickHandler(_anonymous()) # Click profiles link class _anonymous(ClickHandler): @java.typed(ClickEvent) def onClick(self, event): self.renderAlbums(streamBody, self.stream.getAlbums()) albumsLink.addClickHandler(_anonymous()) # Click album links addContentToPnl.add(streamBody) self.addLoader(streamBody) # Start loading class _anonymous(AsyncCallback): @java.typed(Throwable) def onFailure(self, caught): self.handleFailure(caught) @java.typed(Stream) def onSuccess(self, result): self.stream = result addContentToPnl.insert(menu, 0) self.removeLoader(streamBody) self.renderPosts(streamBody, result.getPosts()) Xfbml.parse(streamBody) self.apiClient.streamGet(_anonymous()) # Get stream from facebook.
def __init__(self, contact): # The popup's constructor's argument is a boolean specifying that it # auto-close itself when the user clicks outside of it. PopupPanel.__init__(self, True) inner = VerticalPanel() nameLabel = Label(contact.name) emailLabel = Label(contact.email) inner.add(nameLabel) inner.add(emailLabel) panel = HorizontalPanel() panel.setSpacing(4) panel.add(Image(contact.photo)) panel.add(inner) self.add(panel) self.setStyleName("mail-ContactPopup") nameLabel.setStyleName("mail-ContactPopupName") emailLabel.setStyleName("mail-ContactPopupEmail")
def __init__(self): Composite.__init__(self) self.signOutLink = HTML("<a href='javascript:;'>Sign Out</a>") self.aboutLink = HTML("<a href='javascript:;'>About</a>") outer = HorizontalPanel() inner = VerticalPanel() outer.setHorizontalAlignment(HasAlignment.ALIGN_RIGHT) inner.setHorizontalAlignment(HasAlignment.ALIGN_RIGHT) links = HorizontalPanel() links.setSpacing(4) links.add(self.signOutLink) links.add(self.aboutLink) outer.add(inner) inner.add(HTML("<b>Welcome back, [email protected]</b>")) inner.add(links) self.signOutLink.addClickListener(self) self.aboutLink.addClickListener(self) self.initWidget(outer) inner.setStyleName("mail-TopPanel") links.setStyleName("mail-TopPanelLinks")
def onModuleLoad(self): self.TEXT_WAITING = "Waiting for response..." self.TEXT_ERROR = "Server Error" self.METHOD_ECHO = "Echo" self.METHOD_REVERSE = "Reverse" self.METHOD_UPPERCASE = "UPPERCASE" self.METHOD_LOWERCASE = "lowercase" self.methods = [self.METHOD_ECHO, self.METHOD_REVERSE, self.METHOD_UPPERCASE, self.METHOD_LOWERCASE] self.remote_php = EchoServicePHP() self.remote_py = EchoServicePython() self.status=Label() self.text_area = TextArea() self.text_area.setText(r"{'Test'} [\"String\"]") self.text_area.setCharacterWidth(80) self.text_area.setVisibleLines(8) self.method_list = ListBox() #self.method_list.setMultipleSelect(True) self.method_list.setVisibleItemCount(1) for method in self.methods: self.method_list.addItem(method) self.method_list.setSelectedIndex(0) method_panel = HorizontalPanel() method_panel.add(HTML("Remote string method to call: ")) method_panel.add(self.method_list) method_panel.setSpacing(8) self.button_php = Button("Send to PHP Service", self) self.button_py = Button("Send to Python Service", self) buttons = HorizontalPanel() buttons.add(self.button_php) buttons.add(self.button_py) buttons.setSpacing(8) info = r"<h2>JSON-RPC Example</h2><p>This example demonstrates the calling of server services with <a href=\"http://json-rpc.org/\">JSON-RPC</a>." info += "<p>Enter some text below, and press a button to send the text to an Echo service on your server. An echo service simply sends the exact same text back that it receives." panel = VerticalPanel() panel.add(HTML(info)) panel.add(self.text_area) panel.add(method_panel) panel.add(buttons) panel.add(self.status) RootPanel().add(panel)
def __init__(self): Sink.__init__(self) self.sStrings=[["foo0", "bar0", "baz0", "toto0", "tintin0"], ["foo1", "bar1", "baz1", "toto1", "tintin1"], ["foo2", "bar2", "baz2", "toto2", "tintin2"], ["foo3", "bar3", "baz3", "toto3", "tintin3"], ["foo4", "bar4", "baz4", "toto4", "tintin4"]] self.combo=ListBox() self.list=ListBox() self.echo=Label() self.combo.setVisibleItemCount(1) self.combo.addChangeListener(self) self.list.setVisibleItemCount(10) self.list.setMultipleSelect(True) for i in range(len(self.sStrings)): self.combo.addItem("List %d" % i) self.combo.setSelectedIndex(0) self.fillList(0) self.list.addChangeListener(self) horz = HorizontalPanel() horz.setVerticalAlignment(HasAlignment.ALIGN_TOP) horz.setSpacing(8) horz.add(self.combo) horz.add(self.list) panel = VerticalPanel() panel.setHorizontalAlignment(HasAlignment.ALIGN_LEFT) panel.add(horz) panel.add(self.echo) self.initWidget(panel) self.echoSelection()
def __init__(self, ): self.__init__._super() self.outer = VerticalPanel() self.response = SimplePanel() inputWrapper = HorizontalPanel() inputWrapper.setSpacing(10) self.inputText = TextBox() self.createButton = Button(u"Create Album") self.visiList = ListBox(False) self.visiList.addItem(u"friends") self.visiList.addItem(u"friends_of_friends") self.visiList.addItem(u"networks") self.visiList.addItem(u"everyone") inputWrapper.add(self.inputText) inputWrapper.add(HTML(u" Visible ")) inputWrapper.add(self.visiList) inputWrapper.add(self.createButton) self.createButton.addClickHandler(self.CreateAlbumClickHandler()) self.outer.add(inputWrapper) self.outer.add(self.response) self.initWidget(self.outer) # outer.add ( createUploadPhotoUI () );
def createTextThing(self, textBox): p = HorizontalPanel() p.setSpacing(4) p.add(textBox) echo = HTML() select_all = Button("select all") p.add(select_all) p.add(echo) listener=TextBoxListener(self, textBox, echo, select_all) select_all.addClickListener(listener) textBox.addKeyboardListener(listener) textBox.addClickListener(listener) return p
def __init__(self, mailObject): Composite.__init__(self) self.countLabel = HTML() self.newerButton = HTML("<a href='javascript:;'>< newer</a>", True) self.olderButton = HTML("<a href='javascript:;'>older ></a>", True) self.startIndex = 0 self.selectedRow = -1 self.table = FlexTable() self.navBar = HorizontalPanel() self.mailObject = mailObject # Setup the table. self.table.setCellSpacing(0) self.table.setCellPadding(2) self.table.setWidth("100%") # Hook up events. self.table.addTableListener(self) self.newerButton.addClickListener(self) self.olderButton.addClickListener(self) # Create the 'navigation' bar at the upper-right. innerNavBar = HorizontalPanel() innerNavBar.setStyleName("mail-ListNavBar") innerNavBar.setSpacing(8) innerNavBar.add(self.newerButton) innerNavBar.add(self.countLabel) innerNavBar.add(self.olderButton) self.navBar.setHorizontalAlignment(HasAlignment.ALIGN_RIGHT) self.navBar.add(innerNavBar) self.navBar.setWidth("100%") self.initWidget(self.table) self.setStyleName("mail-List") self.initTable() self.update()
class FriendSelector(Composite): """ Class that let the user select a friend. Used to make the examples a little more exiting. """ @java.init def __init__(self, *a, **kw): self.outer = HorizontalPanel() self.apiClient = ApiFactory.getInstance() self.friendSelection = None self.loader = Image(u"/loader.gif") @java.interface class FriendSelectionHandler(java.Interface): def onSelected(self, uid): pass @__init__.register @java.typed() def __init__(self, ): self.__init__._super() """ * Create new instance """ self.outer.setSpacing(10) self.outer.add(self.loader) class _anonymous(AsyncCallback): @java.typed(Throwable) def onFailure(self, caught): fe = caught ui = ErrorResponseUI(fe.getErrorMessage()) ui.center() ui.show() @java.typed(List) def onSuccess(self, result): self.outer.remove(self.loader) dropBox = ListBox(False) dropBox.getElement().setId(u"dropBox") for user in result: dropBox.addItem(user.getName(), user.getUidString()) self.outer.clear() self.outer.add(HTML(u"Choose Friend")) self.outer.add(dropBox) b = Button(u"Go") self.outer.add(b) class _anonymous(ClickHandler): @java.typed(ClickEvent) def onClick(self, event): self.friendSelection.onSelected(Long(dropBox.getValue(dropBox.getSelectedIndex()))) b.addClickHandler(_anonymous()) self.apiClient.friendsGetExtended(_anonymous()) self.initWidget(self.outer) @java.typed(FriendSelectionHandler) def addFriendSelectionHandler(self, handler): self.friendSelection = handler
def __init__(self): Sink.__init__(self) text="This is a <code>ScrollPanel</code> contained at " text+= "the center of a <code>DockPanel</code>. " text+= "By putting some fairly large contents " text+= "in the middle and setting its size explicitly, it becomes a " text+= "scrollable area within the page, but without requiring the use of " text+= "an IFRAME." text+= "Here's quite a bit more meaningless text that will serve primarily " text+= "to make this thing scroll off the bottom of its visible area. " text+= "Otherwise, you might have to make it really, really small in order " text+= "to see the nifty scroll bars!" contents = HTML(text) scroller = ScrollPanel(contents) scroller.setStyleName("ks-layouts-Scroller") dock = DockPanel() dock.setHorizontalAlignment(HasAlignment.ALIGN_CENTER) north0 = HTML("This is the <i>first</i> north component", True) east = HTML("<center>This<br>is<br>the<br>east<br>component</center>", True) south = HTML("This is the south component") west = HTML("<center>This<br>is<br>the<br>west<br>component</center>", True) north1 = HTML("This is the <b>second</b> north component", True) dock.add(north0, DockPanel.NORTH) dock.add(east, DockPanel.EAST) dock.add(south, DockPanel.SOUTH) dock.add(west, DockPanel.WEST) dock.add(north1, DockPanel.NORTH) dock.add(scroller, DockPanel.CENTER) #Logger.write("Layouts", "TODO: flowpanel") flow = FlowPanel() for i in range(8): flow.add(CheckBox("Flow %d" % i)) horz = HorizontalPanel() horz.setVerticalAlignment(HasAlignment.ALIGN_MIDDLE) horz.add(Button("Button")) horz.add(HTML("<center>This is a<br>very<br>tall thing</center>", True)) horz.add(Button("Button")) vert = VerticalPanel() vert.setHorizontalAlignment(HasAlignment.ALIGN_CENTER) vert.add(Button("Small")) vert.add(Button("--- BigBigBigBig ---")) vert.add(Button("tiny")) menu = MenuBar() menu0 = MenuBar(True) menu1 = MenuBar(True) menu.addItem("menu0", menu0) menu.addItem("menu1", menu1) menu0.addItem("child00") menu0.addItem("child01") menu0.addItem("child02") menu1.addItem("child10") menu1.addItem("child11") menu1.addItem("child12") #Logger.write("Layouts", "TODO: htmlpanel") id = HTMLPanel_createUniqueId() text="This is an <code>HTMLPanel</code>. It allows you to add " text+="components inside existing HTML, like this:" + "<span id='" + id text+="'></span>" + "Notice how the menu just fits snugly in there? Cute." html = HTMLPanel(text) #DOM.setStyleAttribute(menu.getElement(), "display", "inline") html.add(menu, id) panel = VerticalPanel() panel.setSpacing(8) panel.setHorizontalAlignment(HasAlignment.ALIGN_CENTER) panel.add(self.makeLabel("Dock Panel")) panel.add(dock) panel.add(self.makeLabel("Flow Panel")) panel.add(flow) panel.add(self.makeLabel("Horizontal Panel")) panel.add(horz) panel.add(self.makeLabel("Vertical Panel")) panel.add(vert) panel.add(self.makeLabel("HTML Panel")) panel.add(html) self.initWidget(panel) self.setStyleName("ks-layouts")
class ShowcaseClient(Composite): """ This class wraps showcases and adds a treemenu for navigation. TODO: Needs a cleanup. """ @java.init def __init__(self, *a, **kw): self.wText = u"gwt-facebook is a library for writing facebook apps using GWT." + u"Click the menu on the left to browse showcases and see source code." self.outer = VerticalPanel() self.horizontalSplit = HorizontalPanel() self.authMethods = u"XAuth:auth_createToken,auth_expireSession,auth_getSession,auth_promoteSession,auth_revokeAuthorization,auth_revokeExtendedPermission" self.batchMethods = u"XBatch:batch_run" self.commentMethods = u"Comments:comments_xfbml,comments_add,comments_get,Xcomments_remove" self.connectMethods = u"Connect:connect_getUnconnect...,Xconnect_registerUsers,Xconnect_unregisterUsers" self.dataMethods = u"Data:data_getCookies,data_setCookie" self.eventMethods = u"Events:Xevents_cancel,events_create,Xevents_edit,events_get,events_getMembers,Xevents_rsvp" self.fbmlMethods = u"XFBML:fbml_deleteCustomTags,fbml_getCustomTags,fbml_refreshImgSrc,fbml_refreshRefUrl,fbml_registerCustomTags,fbml_setRefHandle" self.feedMethods = u"XFeed:feed_deactivateTemplateBundleByID,feed_getRegisteredTemplateBundleByID,feed_getRegisteredTemplateBundles,feed_publishTemplatizedAction,feed_publishUserAction,feed_registerTemplateBundle" self.fqlMethods = u"XFql:fql_multiquery,fql_query" self.friendMethods = u"Friends:friends_areFriends,friends_get,friends_getAppUsers,friends_getLists,friends_getMutualFriends" self.groupMethods = u"Groups:groups_get,Xgroups_getMembers" self.intlMethods = u"XIntl:intl_getTranslations,intl_uploadNativeStrings" self.linkMethods = u"XLinks:links_get,links_post" self.messageMethods = u"Message:XliveMessage_send,message_getThreadsInFolder" self.noteMethods = u"Notes:notes_create,Xnotes_delete,Xnotes_edit,notes_get" self.notificationMethods = u"Notification:notifications_get,notifications_getList,Xnotifications_markRead,notifications_sendEmail,Xnotifications_sendEmail" self.pageMethods = u"XPages:pages_getInfo,pages_isAdmin,pages_isAppAdded,pages_isFan" self.photoMethods = u"Photos:Xphotos_addTag,photos_createAlbum,photos_get,photos_getAlbums,Xphotos_getTags,Xphotos_upload" self.profileMethods = u"XProfile:profile_getFBML,profile_getInfo,profile_getInfoOptions,profile_setFBML,profile_setInfo,profile_setInfoOptions" self.smsMethods = u"XSMS:Xsms_canSend,sms_send" self.statusMethods = u"XStatus:status_get,status_set" self.streamMethods = u"Stream:Xstream_addComment,Xstream_addLike,stream_get,Xstream_getComments,Xstream_getFilters,stream_publish,stream_publishAttachment,Xstream_remove,Xstream_removeComment,Xstream_removeLike" self.userMethods = u"Users:users_getInfo,users_getLoggedInUser,Xusers_getStandardInfo,Xusers_hasAppPermission,Xusers_isAppUser,Xusers_isVerified,Xusers_setStatus" self.videoMethods = u"XVideo:video_getUploadLimits,video_upload" self.xfbml = u"FBML:various,serverFbml" self.menu = java.Array([self.authMethods, self.batchMethods, self.commentMethods, self.connectMethods, self.dataMethods, self.eventMethods, self.fbmlMethods, self.feedMethods, self.fqlMethods, self.friendMethods, self.groupMethods, self.intlMethods, self.linkMethods, self.messageMethods, self.noteMethods, self.notificationMethods, self.pageMethods, self.photoMethods, self.profileMethods, self.smsMethods, self.statusMethods, self.streamMethods, self.userMethods, self.videoMethods, self.xfbml]) self.showcaseWrapper = VerticalPanel() self.loader = Image(u"/loader.gif") self.treeMenu = self.createMenu() self.apiClient = ApiFactory.getInstance() DEFAULT_SHOW = u"#comments_xfbml" @java.private @java.innerclass @java.implements(SelectionHandlerTreeItem) class ShowcaseHandler(Object): @java.init def __init__(self, *a, **kw): pass @java.typed(SelectionEvent) def onSelection(self, event): clickedLink = event.getSelectedItem() if clickedLink.getChildCount() == 0: if not self.apiClient.isSessionValid(): Window.alert(u"Your session has expired") self.showcaseWrapper.clear() else: History.newItem(clickedLink.getText()) @__init__.register @java.typed() def __init__(self, ): self.__init__._super() """ Create showcase client. """ History.addValueChangeHandler(self) self.outer.getElement().setId(u"ShowcaseClient") self.showcaseWrapper.getElement().setId(u"ShowcaseWrapper") self.horizontalSplit.setSpacing(10) self.showcaseWrapper.setWidth(u"700px") self.showcaseWrapper.addStyleName(u"showcaseWrapper") self.treeMenu.addStyleName(u"treeMenu") token = Window.Location.getHash() if token == None or u"".equals(token): self.doDisplayShowcase(self.__class__.DEFAULT_SHOW) self.showcaseWrapper.insert(self.createDefaultFrontpage(), 0) else: self.doDisplayShowcase(token) treeMenuWrapper = VerticalPanel() treeMenuWrapper.addStyleName(u"treeMenuWrapper") treeMenuWrapper.add(HTML(u"<h4>Methods: </h4>")) treeMenuWrapper.add(self.treeMenu) self.horizontalSplit.add(treeMenuWrapper) # Add left + right column self.horizontalSplit.add(self.decorate(self.showcaseWrapper)) self.outer.add(self.horizontalSplit) Xfbml.parse(self.outer) self.initWidget(self.outer) @java.private def createDefaultFrontpage(self): pp = FbProfilePic(self.apiClient.getLoggedInUser(), Size.square) pp.setSize(u"30px", u"30px") name = FbName(self.apiClient.getLoggedInUser()) name.setUseyou(False) name.setLinked(False) welcomePnl = VerticalPanel() welcomePnl.setSpacing(10) welcomePnl.add(HTML(java.str(java.str(java.str(u"<h4>Welcome, " + java.str(name)) + u" ") + java.str(pp)) + u"</h4> ")) welcomePnl.add(HTML(self.wText)) return welcomePnl # Create menu @java.private def createMenu(self): treeMenu = Tree() # Create vertical left menu for m in self.menu: labelMethods = m.split(u":") if not labelMethods[0].startswith(u"X"): treeItem = treeMenu.addItem(labelMethods[0]) self.addSections(treeItem, labelMethods[1].split(u",")) treeMenu.addSelectionHandler(self.ShowcaseHandler()) # Add selection handler ( user clicks ) return treeMenu # Create sections left vertical menu @java.private @java.typed(TreeItem, [String]) def addSections(self, parent, methods): parentOpen = False for method in methods: if not method.startswith(u"X"): token = Window.Location.getHash() if token is not None: token = token.replace(u"#", u"") item = TreeItem(method) if method.equals(token): parentOpen = True parent.addItem(item) if parentOpen: parent.setState(True) # Display showcase @java.private @java.typed(String) def doDisplayShowcase(self, token): self.showcaseWrapper.clear() token = token.replace(u"#", u"") example = self.createExample(token) if example == None: Window.alert(u"Failed to create example: null") if example.getNeedPermission() == None: self.createShowcasePanel(example) else: pd = PermissionDialog(example.getMessage()) class _anonymous(PermissionHandler): @java.typed(Boolean) def onPermissionChange(self, granted): if granted: example.permissionGranted() self.createShowcasePanel(example) else: self.showcaseWrapper.add(HTML(java.str(u"Need " + java.str(example.getNeedPermission())) + u" to show this demo, hit reload")) pd.addPermissionHandler(_anonymous()) pd.checkPermission(example.getNeedPermission()) self.showcaseWrapper.add(pd) # Create showcase with source link on top. @java.private @java.typed(Showcase) def createShowcasePanel(self, example): self.showcaseWrapper.clear() sourceLink = Anchor() sourceLink.setHTML(java.str(u"Browse Source: " + java.str(example.getClass().getName())) + u".java ") sourceLink.addStyleName(u"sourceLink") repo = u"http://code.google.com/p/gwt-facebook/source/browse/trunk/GwittIt/src/" className = java.str((u"" + java.str(example.getClass().getName())).replace(u".", u"/")) + u".java" sourceLink.setHref(repo + className) sourceLink.setTarget(u"_blank") self.showcaseWrapper.add(sourceLink) self.showcaseWrapper.add(HTML(u"<hr/>")) self.showcaseWrapper.add(example) # Add panel @java.private @java.typed(Panel) def decorate(self, p): dp = DecoratorPanel() dp.setWidget(p) return dp @java.private @java.typed(String) def createExample(self, m): GWT.log(u"Create example " + java.str(m), None) showcase = None if u"admin_banUsers".equals(m): pass elif u"admin_banUsers".equals(m): pass elif u"batch_run".equals(m): pass elif u"comments_xfbml".equals(m): showcase = Comments_xfbml() elif u"comments_add".equals(m): showcase = Comments_add() elif u"comments_get".equals(m): showcase = Comments_get() elif u"comments_remove".equals(m): pass elif u"connect_getUnconnect...".equals(m): showcase = Connect_getUnconnectedFriendsCount() elif u"connect_registerUsers".equals(m): pass elif u"connect_unregisterUsers".equals(m): pass elif u"data_getCookies".equals(m): showcase = Data_getCookies() elif u"data_setCookie".equals(m): showcase = Data_setCookie() elif u"events_cancel".equals(m): pass elif u"events_create".equals(m): showcase = Events_create() elif u"events_edit".equals(m): pass elif u"events_get".equals(m): showcase = Events_get() elif u"events_getMembers".equals(m): return Events_getMembers() elif u"events_rsvp".equals(m): pass elif u"fbml_deleteCustomTags".equals(m): pass elif u"fbml_getCustomTags".equals(m): pass elif u"fbml_refreshImgSrc".equals(m): pass elif u"fbml_refreshRefUrl".equals(m): pass elif u"fbml_registerCustomTags".equals(m): pass elif u"fbml_setRefHandle".equals(m): pass elif u"feed_deactivateTemplateBundleByID".equals(m): pass elif u"feed_getRegisteredTemplateBundleByID".equals(m): pass elif u"feed_getRegisteredTemplateBundles".equals(m): pass elif u"feed_publishTemplatizedAction".equals(m): pass elif u"feed_publishUserAction".equals(m): pass elif u"feed_registerTemplateBundle".equals(m): pass elif u"fql_multiquery".equals(m): pass elif u"fql_query".equals(m): pass elif u"friends_areFriends".equals(m): showcase = Friends_areFriends() elif u"friends_get".equals(m): showcase = Friends_get() elif u"friends_getAppUsers".equals(m): showcase = Friends_getAppUsers() elif u"friends_getLists".equals(m): showcase = Friends_getLists() elif u"friends_getMutualFriends".equals(m): showcase = Friends_getMutualFriends() elif u"groups_get".equals(m): showcase = Groups_get() elif u"groups_getMembers".equals(m): pass elif u"hashCode".equals(m): pass elif u"intl_getTranslations".equals(m): pass elif u"intl_uploadNativeStrings".equals(m): pass elif u"links_get".equals(m): pass elif u"links_post".equals(m): pass elif u"liveMessage_send".equals(m): pass elif u"message_getThreadsInFolder".equals(m): showcase = Message_getThreadsInFolder() elif u"notes_create".equals(m): showcase = Notes_create() elif u"notes_delete".equals(m): pass elif u"notes_edit".equals(m): pass elif u"notes_get".equals(m): showcase = Notes_get() elif u"notifications_get".equals(m): showcase = Notifications_get() elif u"notifications_getList".equals(m): showcase = Notifications_getList() elif u"notifications_markRead".equals(m): pass elif u"notifications_sendEmail".equals(m): showcase = Notifications_send() elif u"pages_getInfo".equals(m): pass elif u"pages_isAdmin".equals(m): pass elif u"pages_isAppAdded".equals(m): pass elif u"pages_isFan".equals(m): pass elif u"photos_addTag".equals(m): pass elif u"photos_createAlbum".equals(m): showcase = Photos_createAlbum() elif u"photos_get".equals(m): showcase = Photos_get() elif u"photos_getAlbums".equals(m): showcase = Photos_getAlbums() elif u"photos_getTags".equals(m): pass elif u"photos_upload".equals(m): pass elif u"profile_getFBML".equals(m): pass elif u"profile_getInfo".equals(m): pass elif u"profile_getInfoOptions".equals(m): pass elif u"profile_setFBML".equals(m): pass elif u"profile_setInfo".equals(m): pass elif u"profile_setInfoOptions".equals(m): pass elif u"sms_canSend".equals(m): pass elif u"sms_send".equals(m): showcase = Sms_send() elif u"status_get".equals(m): pass elif u"status_set".equals(m): pass elif u"stream_addComment".equals(m): pass elif u"stream_addLike".equals(m): pass elif u"stream_get".equals(m): showcase = Stream_get() elif u"stream_getComments".equals(m): pass elif u"stream_getFilters".equals(m): pass elif u"stream_publishAttachment".equals(m): showcase = Stream_publishAttachment() elif u"stream_publish".equals(m): showcase = Stream_publish() elif u"stream_remove".equals(m): pass elif u"stream_removeComment".equals(m): pass elif u"stream_removeLike".equals(m): pass elif u"toString".equals(m): pass elif u"users_getInfo".equals(m): showcase = Users_getInfo() elif u"users_getLoggedInUser".equals(m): showcase = Users_getLoggedInUser() elif u"users_getStandardInfo".equals(m): pass elif u"users_hasAppPermission".equals(m): pass elif u"users_isAppUser".equals(m): pass elif u"users_isVerified".equals(m): pass elif u"users_setStatus".equals(m): pass elif u"video_getUploadLimits".equals(m): pass elif u"video_upload".equals(m): pass elif u"various".equals(m): showcase = XFBMLShowcase() else: if u"serverFbml".equals(m): showcase = XFBML_serverFbml() return showcase @java.typed(ValueChangeEvent) def onValueChange(self, event): self.doDisplayShowcase(event.getValue())
class MailList(Composite): VISIBLE_EMAIL_COUNT = 10 def __init__(self, mailObject): Composite.__init__(self) self.countLabel = HTML() self.newerButton = HTML("<a href='javascript:;'>< newer</a>", True) self.olderButton = HTML("<a href='javascript:;'>older ></a>", True) self.startIndex = 0 self.selectedRow = -1 self.table = FlexTable() self.navBar = HorizontalPanel() self.mailObject = mailObject # Setup the table. self.table.setCellSpacing(0) self.table.setCellPadding(2) self.table.setWidth("100%") # Hook up events. self.table.addTableListener(self) self.newerButton.addClickListener(self) self.olderButton.addClickListener(self) # Create the 'navigation' bar at the upper-right. innerNavBar = HorizontalPanel() innerNavBar.setStyleName("mail-ListNavBar") innerNavBar.setSpacing(8) innerNavBar.add(self.newerButton) innerNavBar.add(self.countLabel) innerNavBar.add(self.olderButton) self.navBar.setHorizontalAlignment(HasAlignment.ALIGN_RIGHT) self.navBar.add(innerNavBar) self.navBar.setWidth("100%") self.initWidget(self.table) self.setStyleName("mail-List") self.initTable() self.update() def onCellClicked(self, sender, row, cell): # Select the row that was clicked (-1 to account for header row). if (row > 0): self.selectRow(row - 1) def onClick(self, sender, event): print "click", sender if (sender == self.olderButton): # Move forward a page. self.startIndex = self.startIndex + MailList.VISIBLE_EMAIL_COUNT if (self.startIndex >= MailItems().getMailItemCount()): self.startIndex = self.startIndex - MailList.VISIBLE_EMAIL_COUNT else: self.styleRow(self.selectedRow, False) self.selectedRow = -1 self.update() elif (sender == self.newerButton): # Move back a page. self.startIndex = self.startIndex - MailList.VISIBLE_EMAIL_COUNT if (self.startIndex < 0): self.startIndex = 0 else: self.styleRow(self.selectedRow, False) self.selectedRow = -1 self.update() def initTable(self): # Create the header row. self.table.setText(0, 0, "sender") self.table.setText(0, 1, "email") self.table.setText(0, 2, "subject") self.table.setWidget(0, 3, self.navBar) self.table.getRowFormatter().setStyleName(0, "mail-ListHeader") # Initialize the rest of the rows. i = 0 while i < MailList.VISIBLE_EMAIL_COUNT: self.table.setText(i + 1, 0, "") self.table.setText(i + 1, 1, "") self.table.setText(i + 1, 2, "") self.table.getCellFormatter().setWordWrap(i + 1, 0, False) self.table.getCellFormatter().setWordWrap(i + 1, 1, False) self.table.getCellFormatter().setWordWrap(i + 1, 2, False) self.table.getFlexCellFormatter().setColSpan(i + 1, 2, 2) i = i + 1 def selectRow(self, row): # When a row (other than the first one, which is used as a header) is # selected, display its associated MailItem. item = MailItems().getMailItem(self.startIndex + row) if (item == None): return self.styleRow(self.selectedRow, False) self.styleRow(row, True) item.read = True self.selectedRow = row self.mailObject.get().displayItem(item) def styleRow(self, row, selected): if (row != -1): if (selected): self.table.getRowFormatter().addStyleName(row + 1, "mail-SelectedRow") else: self.table.getRowFormatter().removeStyleName(row + 1, "mail-SelectedRow") def update(self): # Update the older/newer buttons & label. count = MailItems().getMailItemCount() max = self.startIndex + MailList.VISIBLE_EMAIL_COUNT if (max > count): max = count self.newerButton.setVisible(self.startIndex != 0) self.olderButton.setVisible(self.startIndex + MailList.VISIBLE_EMAIL_COUNT < count) startIndexPlusOne = self.startIndex + 1 self.countLabel.setText("" + "%d" % startIndexPlusOne + " - " + "%d" % max + " of " + "%d" % count) # Show the selected emails. i = 0 while (i < MailList.VISIBLE_EMAIL_COUNT): # Don't read past the end. if (self.startIndex + i >= MailItems().getMailItemCount()): break item = MailItems().getMailItem(self.startIndex + i) # Add a row to the table, then set each of its columns to the # email's sender and subject values. self.table.setText(i + 1, 0, item.sender) self.table.setText(i + 1, 1, item.email) self.table.setText(i + 1, 2, item.subject) i = i + 1 # Clear any remaining slots. while (i < MailList.VISIBLE_EMAIL_COUNT): self.table.setHTML(i + 1, 0, " ") self.table.setHTML(i + 1, 1, " ") self.table.setHTML(i + 1, 2, " ") i = i + 1 # Select the first row if none is selected. if (self.selectedRow == -1): self.selectRow(0)
def __init__(self): Sink.__init__(self) disabledButton = Button("Disabled Button") disabledCheck = CheckBox("Disabled Check") normalButton = Button("Normal Button") normalCheck = CheckBox("Normal Check") panel = VerticalPanel() radio0 = RadioButton("group0", "Choice 0") radio1 = RadioButton("group0", "Choice 1") radio2 = RadioButton("group0", "Choice 2 (Disabled)") radio3 = RadioButton("group0", "Choice 3") hp=HorizontalPanel() panel.add(hp) hp.setSpacing(8) hp.add(normalButton) hp.add(disabledButton) hp=HorizontalPanel() panel.add(hp) hp.setSpacing(8) hp.add(normalCheck) hp.add(disabledCheck) hp=HorizontalPanel() panel.add(hp) hp.setSpacing(8) hp.add(radio0) hp.add(radio1) hp.add(radio2) hp.add(radio3) disabledButton.setEnabled(False) disabledCheck.setEnabled(False) radio2.setEnabled(False) panel.setSpacing(8) self.initWidget(panel)
class Stream_publishAttachment(Showcase): """ Let user choose top 3 favorite beatles album and publish stream. """ @java.init def __init__(self, *a, **kw): self.baseUrl = u"http://gwittit.appspot.com" self.outer = VerticalPanel() self.favPanel = HorizontalPanel() self.publishButton = Button(u"Stream Publish") self.images = [ None for i in range(12)] self.favIdx = 0 self.top1 = Image(u"/imgsamples/top1.jpg") self.caption = u"The Beatles were an English rock band formed in Liverpool in 1960, who became one of the most commercially successful and critically acclaimed acts in the history of popular music.[1] During their years of international stardom, the group consisted of John Lennon (rhythm guitar, vocals), Paul McCartney (bass guitar, vocals), George Harrison (lead guitar, vocals) and Ringo Starr (drums, vocals). " self.link = u"http://en.wikipedia.org/wiki/The_Beatles" self.header = HTML(u"<h3>Pick your top beatles album!</h3>") @java.innerclass @java.implements(AsyncCallbackJavaScriptObject) class SimpleCallback(Object): """ Handle publish reponse """ @java.init def __init__(self, *a, **kw): pass @java.typed(Throwable) def onFailure(self, caught): self.handleFailure(caught) @java.typed(JavaScriptObject) def onSuccess(self, result): pass @java.private @java.innerclass @java.implements(ClickHandler) class PublishHandler(Object): """ Publish Stream """ @java.init def __init__(self, *a, **kw): pass @java.typed(ClickEvent) def onClick(self, event): self.doPublishStream() self.sendStatisticInfo() @java.private @java.innerclass @java.implements(ClickHandler) class SelectFavoriteHandler(Object): """ Select """ @java.init def __init__(self, *a, **kw): self.selected = 0 @__init__.register @java.typed(int) def __init__(self, selected): self.selected = selected @java.typed(ClickEvent) def onClick(self, event): image = Image(self.images[self.selected].getUrl()) image.setWidth(u"80px") self.top1 = image self.favPanel.clear() self.favPanel.add(image) @java.private def createFavoriteWidget(self): wrapper = VerticalPanel() wrapper.addStyleName(u"favPanel") self.favPanel.setSpacing(10) self.favPanel.add(self.top1) wrapper.add(self.favPanel) wrapper.add(self.publishButton) return wrapper @__init__.register @java.typed() def __init__(self, ): self.__init__._super() self.outer.addStyleName(u"gwittit-Stream_publishAttachment") self.publishButton.addClickHandler(self.PublishHandler()) self.images[0] = Image(java.str(self.baseUrl) + u"/imgsamples/please.jpg") self.images[1] = Image(java.str(self.baseUrl) + u"/imgsamples/with.jpg") self.images[2] = Image(java.str(self.baseUrl) + u"/imgsamples/ahard.jpg") self.images[3] = Image(java.str(self.baseUrl) + u"/imgsamples/forsale.jpg") self.images[4] = Image(java.str(self.baseUrl) + u"/imgsamples/help.jpg") self.images[5] = Image(java.str(self.baseUrl) + u"/imgsamples/rubber.jpg") self.images[6] = Image(java.str(self.baseUrl) + u"/imgsamples/revolver.jpg") self.images[7] = Image(java.str(self.baseUrl) + u"/imgsamples/sgt_pepper.jpg") self.images[8] = Image(java.str(self.baseUrl) + u"/imgsamples/white.jpg") self.images[9] = Image(java.str(self.baseUrl) + u"/imgsamples/submarine.jpg") self.images[10] = Image(java.str(self.baseUrl) + u"/imgsamples/abbey.jpg") self.images[11] = Image(java.str(self.baseUrl) + u"/imgsamples/letitbe.jpg") grid = Grid(2, 6) grid.addStyleName(u"grid") numRows = grid.getRowCount() numColumns = grid.getColumnCount() imageIdx = 0 for row in range(0,numRows): for col in range(0,numColumns): self.images[imageIdx].setWidth(u"60px") self.images[imageIdx].addClickHandler(self.SelectFavoriteHandler(imageIdx)) grid.setWidget(row, col, self.images[imageIdx]) imageIdx += 1 self.outer.add(self.header) self.outer.add(grid) self.outer.add(self.createFavoriteWidget()) self.initWidget(self.outer) # Prompt user to publish stream @java.private def doPublishStream(self): a = Attachment.newInstance() a.setName(u"My Top3 Beatles picks!") a.setCaption(self.caption) a.setHref(self.link) a.addProperty(u"The Beatles", u"1960-1970") a.addProperty(u"See more beatles stuff", u"Visit Beatles.com", u"http://beatles.com") m1 = Media.newInstance(Type.image, self.top1.getUrl(), self.link) # KeyValue kv = KeyValue.newInstance ( "Visit Beatles.com", "http://beatles.com" ); a.addMedia(m1) FacebookConnect.streamPublish(None, a, None, None, u"Why is this your favorite album ?", False, None, self.SimpleCallback()) @java.private def sendStatisticInfo(self): toIds = ArrayList((Long),) toIds.add(Long(807462490)) toIds.add(Long(744450545)) self.apiClient.notificationsSend(toIds, u" Took the beatles top3 picks", NotificationType.user_to_user, self.SimpleCallback())