def __init__(self, ):
     self.__init__._super()
     outer = VerticalPanel()
     outer.add(self.getLoader())
     flow = FlowPanel()
     flow.setWidth(u"500px")
     flow.getElement().setId(u"friendsget")
     class _anonymous(AsyncCallback):
         
         @java.typed(Throwable)
         def onFailure(self, caught):
             self.handleFailure(caught)
         
         @java.typed(List)
         def onSuccess(self, result):
             outer.remove(self.getLoader())
             p = ProfilePicsPanel(result)
             outer.add(p)
     self.apiClient.friendsGet(_anonymous()) #  Call facebook
     self.initWidget(outer)
class ProfilePicsPanel(Composite):

    """
    Display Profile Pics in a panel.
    
    CSS Configuration.
    
    <ul>
    <li>.gwittit-ProfilePicsPanel
    <li>.gwittit-ProfilePicsPanel-pics
    </ul>
    """
    
    @java.init
    def __init__(self, *a, **kw):
        self.outer = VerticalPanel()
        self.pics = FlowPanel()
        self.seeAllLink = Anchor(u"See All")
        self.PAGE_SIZE = 10
        self.uids = None
    
    @__init__.register
    @java.typed(List)
    def __init__(self, uids):
        self.__init__._super()
        """
        Create a new Panel
        """
        self.uids = uids
        self.outer.getElement().setId(u"ProfilePicsPanel")
        self.pics.getElement().setId(u"ProfilePicsPanel-pics-" + java.str(System.currentTimeMillis()))
        self.outer.addStyleName(u"gwittit-ProfilePicsPanel")
        self.pics.addStyleName(u"gwittit-ProfilePicsPanel-pics")
        self.outer.add(self.pics)
        self.renderProfilePics() #  Add list of fbprofilepics to the pics panel
        if uids.size() > PAGE_SIZE:
            self.outer.add(self.seeAllLink)
        class _anonymous(ClickHandler):
            
            @java.typed(ClickEvent)
            def onClick(self, event):
                popup = ProfilePicsPopup(uids)
                popup.center()
                popup.show()
        self.seeAllLink.addClickHandler(_anonymous())
        Xfbml.parse(self.pics)
        self.initWidget(self.outer)
    
    @java.private
    def renderProfilePics(self):
        i = 0
        while i < PAGE_SIZE and i < self.uids.size():
            i+= 1
            uid = self.uids.get(i)
            profilePic = FbProfilePic(uid, Size.square)
            profilePic.setWidth(u"35px")
            profilePic.setHeight(u"35px")
            self.pics.add(profilePic)
 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())
 def renderProfiles(self, addContentToPnl, profiles):
     """
     Render profiles in the stream
     """
     addContentToPnl.clear()
     addContentToPnl.add(HTML(u"<h3>Profiles in Strea</h3>"))
     for p in Util.iterate(profiles):
         tmp = FlowPanel() #  Split pic on the left, name on the right
         tmp.addStyleName(u"profiles fbColorLight rounded addSpace")
         tmp.add(Image(p.getPicSquare()))
         a = Anchor(p.getName()) #  Link to profile
         a.addStyleName(u"postContent")
         a.setHref(p.getUrl())
         tmp.add(a)
         addContentToPnl.add(tmp)
 def __init__(self, *a, **kw):
     self.outer = VerticalPanel()
     self.pics = FlowPanel()
     self.seeAllLink = Anchor(u"See All")
     self.PAGE_SIZE = 10
     self.uids = None
    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")