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, ):
     self.__init__._super()
     """
     New Showcase
     """
     vPanel = VerticalPanel()
     vPanel.setStyleName(u"gwittit-Stream_publish")
     innerPanel = VerticalPanel()
     innerPanel.setStyleName(u"innerPanel")
     innerPanel.setSpacing(10)
     publishButton = Button(u"PublishStream #1")
     helpText = Label(u"This will display a dialog where you can publish stream to your wall")
     publishButton2 = Button(u"PublishStream #2")
     helpText2 = HTML(java.str(u"This will publish a stream with the text <b>" + java.str(self.__class__.defaultUserMessage)) + u"</b> ( publish_stream must be granted )")
     publishButton3 = Button(u"PublisStream #3")
     helpText3 = HTML(u"This will prompt user to update his or her status")
     innerPanel.add(publishButton)
     innerPanel.add(helpText)
     vPanel.add(innerPanel)
     publishButton.addClickHandler(self.PublishStreamClickHandler(innerPanel, True))
     innerPanel = VerticalPanel()
     innerPanel.setSpacing(10)
     innerPanel.setStyleName(u"innerPanel")
     innerPanel.add(publishButton2)
     innerPanel.add(helpText2)
     vPanel.add(innerPanel)
     publishButton2.addClickHandler(self.PublishStreamClickHandler(innerPanel, False))
     innerPanel = VerticalPanel()
     innerPanel.setStyleName(u"innerPanel")
     innerPanel.add(publishButton3)
     innerPanel.add(helpText3)
     innerPanel.setSpacing(10)
     vPanel.add(innerPanel)
     publishButton3.addClickHandler(self.PublishStreamSimpleHandler())
     self.initWidget(vPanel)
 def renderUI(self):
     fbName = FbName(self.apiClient.getLoggedInUser())
     fbName.setUseyou(False)
     text = HTML(java.str(u"This will send an email notification to  " + java.str(fbName)) + u"(you).")
     text.getElement().setId(u"text")
     self.notificationText.setWidth(u"500px")
     self.notificationText.setHeight(u"100px")
     self.notificationText.setFocus(True)
     self.outer.setSpacing(10)
     submit = Button(u"Send")
     submit.addClickHandler(self.NotificationSendHandler())
     self.outer.add(text)
     self.outer.add(self.notificationText)
     self.outer.add(submit)
     Xfbml.parse(text)
 def __init__(self, *a, **kw):
     self.outer = VerticalPanel()
     self.inputWrapper = VerticalPanel()
     self.responseWrapper = SimplePanel()
     self.commentsListPanel = VerticalPanel()
     self.text = TextArea()
     self.submitButton = Button(u"Add Comment ")
 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())
 def __init__(self, *a, **kw):
     self.outer = VerticalPanel()
     self.scrollPanel = ScrollPanel()
     self.picsHolder = VerticalPanel()
     self.PAGE_SIZE = 30
     self.page = 0
     self.moreButton = Button(u"More")
     self.uids = None
Beispiel #7
0
    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 onModuleLoad(self):
		self.page=0
		self.min_page=1
		self.max_page=10
		
		self.add=Button("Next >", self)
		self.sub=Button("< Prev", self)
		
		self.g=Grid()
		self.g.resize(5, 5)
		self.g.setHTML(0, 0, "<b>Grid Test</b>")
		self.g.setBorderWidth(2)
		self.g.setCellPadding(4)
		self.g.setCellSpacing(1)
		
		self.updatePageDisplay()
		RootPanel().add(self.sub)
		RootPanel().add(self.add)
		RootPanel().add(self.g)
class NavBar(Composite):

    def __init__(self, owner):
        Composite.__init__(self)
        self.owner = owner
        self.bar = DockPanel()
        self.gotoFirst = Button("&lt;&lt;", self)
        self.gotoNext = Button("&gt;", self)
        self.gotoPrev = Button("&lt;", 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 onClick(self, sender):
        if sender == self.gotoNext:
            self.owner.startRow += self.owner.getDataRowCount()
            self.owner.refresh()
        elif sender == self.gotoPrev:
            self.owner.startRow -= self.owner.getDataRowCount()
            if self.owner.startRow < 0:
                self.owner.startRow = 0
            self.owner.refresh()
        elif sender == self.gotoFirst:
            self.owner.startRow = 0
            self.owner.refresh()
 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>")
 def __init__(self, *a, **kw):
     self.outer = VerticalPanel()
     self.loader = Image(u"/loader.gif")
     self.eventInfo = None
     self.nameText = TextBox()
     self.categoryListBox = ListBox(False)
     self.subCategoriesListBox = ListBox(False)
     self.hostText = TextBox()
     self.locationText = TextBox()
     self.cityText = TextBox()
     self.createEventButton = Button(u"Create Event")
     self.apiClient = ApiFactory.getInstance()
Beispiel #12
0
class GridTest:
	def onModuleLoad(self):
		self.page=0
		self.min_page=1
		self.max_page=10
		
		self.add=Button("Next >", self)
		self.sub=Button("< Prev", self)
		
		self.g=Grid()
		self.g.resize(5, 5)
		self.g.setHTML(0, 0, "<b>Grid Test</b>")
		self.g.setBorderWidth(2)
		self.g.setCellPadding(4)
		self.g.setCellSpacing(1)
		
		self.updatePageDisplay()
		RootPanel().add(self.sub)
		RootPanel().add(self.add)
		RootPanel().add(self.g)

	def onClick(self, sender, event):
		if sender==self.add:
			self.page+=1
		elif sender==self.sub:
			self.page-=1
		print "onClick", sender, self.page
		self.updatePageDisplay()
		

	def updatePageDisplay(self):
		if self.page<self.min_page: self.page=self.min_page
		elif self.page>self.max_page: self.page=self.max_page
		total_pages=(self.max_page-self.min_page) + 1
		
		self.g.setHTML(0, 4, "<b>page " + str(self.page) + ' of ' + str(total_pages) + "</b>")
		
		if self.page>=self.max_page:
			self.add.setEnabled(False)
		else:
			self.add.setEnabled(True)
			
		if self.page<=self.min_page:
			self.sub.setEnabled(False)
		else:
			self.sub.setEnabled(True)

		for y in range(1, 5):
			for x in range(5):
				self.g.setText(y, x, str(self.page) + ' (' + str(y) + ',' + str(x) + ')')
Beispiel #13
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)
Beispiel #14
0
class Popups(Sink):
    def __init__(self):
        Sink.__init__(self)
        self.fDialogButton = Button("Show Dialog", self)
        self.fPopupButton = Button("Show Popup", self)
        
        panel = VerticalPanel()
        panel.add(self.fPopupButton)
        panel.add(self.fDialogButton)
        
        list = ListBox()
        list.setVisibleItemCount(5)
        for i in range(10):
            list.addItem("list item %d" % i)
        panel.add(list)
        
        panel.setSpacing(8)
        self.initWidget(panel)

    def onShow(self):
        pass

    def onClick(self, sender, event):
        if sender == self.fPopupButton:
            p = MyPopup()
            left = sender.getAbsoluteLeft() + 10
            top = sender.getAbsoluteTop() + 10
            print left, top
            p.setPopupPosition(left, top)
            p.show()
        elif sender == self.fDialogButton:
            dlg = MyDialog()
            left = self.fDialogButton.getAbsoluteLeft() + 10
            top = self.fDialogButton.getAbsoluteTop() + 10
            dlg.setPopupPosition(left, top)
            dlg.show()
Beispiel #15
0
 def __init__(self):
     Sink.__init__(self)
     self.fDialogButton = Button("Show Dialog", self)
     self.fPopupButton = Button("Show Popup", self)
     
     panel = VerticalPanel()
     panel.add(self.fPopupButton)
     panel.add(self.fDialogButton)
     
     list = ListBox()
     list.setVisibleItemCount(5)
     for i in range(10):
         list.addItem("list item %d" % i)
     panel.add(list)
     
     panel.setSpacing(8)
     self.initWidget(panel)
 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 () );
class Photos_createAlbum(Showcase):

    """
    Showcase for method call <code>photos.createAlbum</code>
    @author olamar72
    """
    
    @java.init
    def __init__(self, *a, **kw):
        self.sampleUpload = Image(u"/sample")
        self.outer = None
        self.inputText = None
        self.createButton = None
        self.visiList = None
        self.response = None
    #  User clicks create album
    
    @java.private
    @java.innerclass
    @java.implements(ClickHandler)
    class CreateAlbumClickHandler(Object):
    
        
        @java.init
        def __init__(self, *a, **kw):
            pass
        
        @java.typed(ClickEvent)
        def onClick(self, event):
            self.createAlbum(self.inputText.getValue(), self.visiList.getItemText(self.visiList.getSelectedIndex()))
    #  Create album callback
    
    @java.private
    @java.innerclass
    @java.implements(AsyncCallbackAlbum)
    class CreateAlbumCallback(Object):
    
        
        @java.init
        def __init__(self, *a, **kw):
            pass
        
        @java.typed(Throwable)
        def onFailure(self, caught):
            self.handleFailure(caught)
        
        @java.typed(Album)
        def onSuccess(self, album):
            self.response.setWidget(HTML(u"Album created with id " + java.str(album.getAid())))
    
    @java.private
    @java.innerclass
    @java.implements(ClickHandler)
    class UploadPhotoClickHandler(Object):
    
        """
        Upload photo
        """
        
        @java.init
        def __init__(self, *a, **kw):
            pass
        
        @java.typed(ClickEvent)
        def onClick(self, event):
            self.apiClient.photosUpload(None, u"Testing", self.UploadPhotoCallback())
    
    @java.private
    @java.innerclass
    @java.implements(AsyncCallbackPhoto)
    class UploadPhotoCallback(Object):
    
        """
        Upload photo response
        """
        
        @java.init
        def __init__(self, *a, **kw):
            pass
        
        @java.typed(Throwable)
        def onFailure(self, caught):
            self.handleFailure(caught)
        
        @java.typed(Photo)
        def onSuccess(self, result):
            Window.alert(u"Photo uploaded")
    
    @__init__.register
    @java.typed()
    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 () );
    
    @java.private
    def createUploadPhotoUI(self):
        v = VerticalPanel()
        b = Button(u"Upload Photo")
        b.addClickHandler(self.UploadPhotoClickHandler())
        v.add(b)
        return v
    
    @java.private
    @java.typed(String, String)
    def createAlbum(self, name, visible):
        album = Album.createAlbum(name, None, None, Visibility.valueOf(visible))
        self.apiClient.photosCreateAlbum(album, self.CreateAlbumCallback())
class EventEditor(Composite):

    """
    Let user create a new Event.
    
    CSS Configuration
    <ul>
    <li>.gwittit-EventEditor
    </ul>
    """
    
    @java.init
    def __init__(self, *a, **kw):
        self.outer = VerticalPanel()
        self.loader = Image(u"/loader.gif")
        self.eventInfo = None
        self.nameText = TextBox()
        self.categoryListBox = ListBox(False)
        self.subCategoriesListBox = ListBox(False)
        self.hostText = TextBox()
        self.locationText = TextBox()
        self.cityText = TextBox()
        self.createEventButton = Button(u"Create Event")
        self.apiClient = ApiFactory.getInstance()
    
    @__init__.register
    @java.typed()
    def __init__(self, ):
        self.__init__._super()
        self.outer.addStyleName(u"gwittit-EventEditor")
        self.outer.setSpacing(10)
        self.initFields()
        self.outer.add(self.createLabelAndInput(u"Name", self.nameText))
        self.outer.add(self.createLabelAndInput(u"Category", self.categoryListBox))
        self.outer.add(self.createLabelAndInput(u"SubCategory", self.subCategoriesListBox))
        self.outer.add(self.createLabelAndInput(u"Host", self.hostText)) #  outer.add ( createLabelAndInput ( "EventEnds" , endTimePicker ) );
        self.outer.add(self.createLabelAndInput(u"Location", self.locationText))
        self.outer.add(self.createLabelAndInput(u"City", self.cityText))
        self.outer.add(self.createEventButton)
        class _anonymous(ClickHandler):
            
            @java.typed(ClickEvent)
            def onClick(self, event):
                self.saveOrUpdate()
        self.createEventButton.addClickHandler(_anonymous())
        self.initWidget(self.outer)
    
    @java.private
    def saveOrUpdate(self):
        """
        Save event to facebook
        """
        jEvent = Json()
        jEvent.put(u"name", self.nameText.getValue())
        jEvent.put(u"host", self.hostText.getValue())
        jEvent.put(u"location", self.locationText.getValue())
        jEvent.put(u"city", self.cityText.getValue())
        selectedCategory = Integer(self.categoryListBox.getValue(self.categoryListBox.getSelectedIndex())) #  Save Category
        selectedSubCategory = Integer(self.subCategoriesListBox.getValue(self.subCategoriesListBox.getSelectedIndex()))
        jEvent.put(u"category", EventInfo.Category.values()[(selectedCategory - 1)].toString())
        jEvent.put(u"subcategory", EventInfo.SubCategory.values()[(selectedSubCategory - 1)].toString())
        jEvent.put(u"start_time", Date().getTime() + Long(u"9999999999"))
        jEvent.put(u"end_time", Date().getTime() + Long(u"9999999999999"))
        eventInfo = EventInfo.fromJson(java.str(jEvent))
        self.outer.add(self.loader)
        class _anonymous(AsyncCallback):
            
            @java.typed(Throwable)
            def onFailure(self, caught):
                self.outer.remove(self.loader)
                errorResponse = ErrorResponseUI(caught)
                errorResponse.center()
                errorResponse.show()
            
            @java.typed(JavaScriptObject)
            def onSuccess(self, result):
                self.outer.remove(self.loader)
                self.outer.add(HTML(u"Created event with ID " + java.str(result)))
        self.apiClient.eventsCreate(eventInfo, _anonymous()) #  Create the event.
    
    @java.private
    def initFields(self):
        """
        Create widgets, and set default values if any
        """
        self.nameText.setValue(u"Birthday")
        self.hostText.setValue(u"host")
        self.locationText.setValue(u"location")
        self.cityText.setValue(u"Palo Alto, CA")
        for category in EventInfo.Category.values():
            self.categoryListBox.addItem(java.str(category).replace(u"_", u" "), u"" + java.str(category.getId()))
        for subCategory in EventInfo.SubCategory.values():
            self.subCategoriesListBox.addItem(java.str(subCategory).replace(u"_", u" "), u"" + java.str(subCategory.getId()))
    
    @java.private
    @java.typed(String, Widget)
    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 __init__(self, *a, **kw):
     self.outer = VerticalPanel()
     self.inputPanel = HorizontalPanel()
     self.nameText = TextBox()
     self.valueText = TextBox()
     self.addButton = Button(u"Set Cookie")
class Data_setCookie(Showcase):

    """
    Showcase of method <code>data.setCookie</code>
    """
    
    @java.init
    def __init__(self, *a, **kw):
        self.outer = VerticalPanel()
        self.inputPanel = HorizontalPanel()
        self.nameText = TextBox()
        self.valueText = TextBox()
        self.addButton = Button(u"Set Cookie")
    #  Handle click
    
    @java.private
    @java.innerclass
    @java.implements(ClickHandler)
    class SetCookieClickHandler(Object):
    
        
        @java.init
        def __init__(self, *a, **kw):
            pass
        
        @java.typed(ClickEvent)
        def onClick(self, event):
            self.sendToServer(self.nameText.getValue(), self.valueText.getValue())
    #  Render response
    
    @java.private
    @java.innerclass
    @java.implements(AsyncCallbackBoolean)
    class ResponseCallback(Object):
    
        
        @java.init
        def __init__(self, *a, **kw):
            pass
        
        @java.typed(Throwable)
        def onFailure(self, caught):
            self.handleFailure(caught)
        
        @java.typed(Boolean)
        def onSuccess(self, result):
            self.removeLoader(self.outer)
            self.renderResponse(result)
    
    @__init__.register
    @java.typed()
    def __init__(self, ):
        self.__init__._super()
        """
        Create showcase
        """
        self.inputPanel.setSpacing(10)
        self.inputPanel.add(HTML(u"Name: "))
        self.inputPanel.add(self.nameText)
        self.inputPanel.add(HTML(u"Value: "))
        self.inputPanel.add(self.valueText)
        self.inputPanel.add(self.addButton)
        self.outer.add(self.inputPanel)
        self.addButton.addClickHandler(self.SetCookieClickHandler())
        self.initWidget(self.outer)
    #  Save Cookie
    
    @java.private
    @java.typed(String, String)
    def sendToServer(self, name, value):
        self.addLoader(self.outer)
        j = Json().put(u"name", name).put(u"value", value)
        cookie = Cookie.fromJson(java.str(j))
        self.apiClient.dataSetCookie(cookie, self.ResponseCallback())
    #  Render response
    
    @java.private
    @java.typed(Boolean)
    def renderResponse(self, added):
        if added:
            self.outer.add(HTML(u"Cookie added successfully"))
        else:
            self.outer.add(HTML(u"Could not set cookie"))
class ProfilePicsPopup(DecoratedPopupPanel):

    """
    Let user browse a user list in a popup.
    
    CSS Configuration
    
    <ul>
    <li>.gwittit-ProfilePicsPopup
    <li>.gwittit-ProfilePicsPopup-content
    <li>.gwittit-ProfilePicsPopup-moreButton
    </ul>
    """
    
    @java.init
    def __init__(self, *a, **kw):
        self.outer = VerticalPanel()
        self.scrollPanel = ScrollPanel()
        self.picsHolder = VerticalPanel()
        self.PAGE_SIZE = 30
        self.page = 0
        self.moreButton = Button(u"More")
        self.uids = None
    
    @__init__.register
    @java.typed(List)
    def __init__(self, uids):
        self.__init__._super()
        self.uids = uids
        super(self.__class__,self).setAutoHideEnabled(True)
        self.outer.addStyleName(u"gwittit-ProfilePicsPopup")
        self.moreButton.addStyleName(u"gwittit-ProfilePicsPopup-moreButton")
        self.scrollPanel.addStyleDependentName(u"gwittit-ProfilePicsPopup-scrollPanel") #  ScrollPanel
        self.scrollPanel.setWidth(u"400px")
        self.scrollPanel.setHeight(u"500px")
        self.outer.getElement().setId(u"gwittit-ProfilePicsPopup-content") #  Main Content
        self.outer.addStyleName(u"gwittit-ProfilePicsPopup-content")
        self.displayUsers(self.picsHolder, self.page)
        self.outer.add(self.picsHolder) #  Compile Panels
        self.outer.add(self.moreButton)
        self.scrollPanel.add(self.outer)
        super(self.__class__,self).setWidget(self.scrollPanel)
        Xfbml.parse(self.outer)
        class _anonymous(ClickHandler):
            
            @java.typed(ClickEvent)
            def onClick(self, event):
                self.displayUsers(self.picsHolder, self.page+= 1)
        self.moreButton.addClickHandler(_anonymous()) #  Add Clickhandler that enables user to browse list
    
    @java.private
    @java.typed(VerticalPanel, int)
    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 Comments_add(Showcase):

    """
    Showcase for method call <code>comments.add</code>
    
    @author olamar72
    """
    
    @java.init
    def __init__(self, *a, **kw):
        self.outer = VerticalPanel()
        self.inputWrapper = VerticalPanel()
        self.responseWrapper = SimplePanel()
        self.commentsListPanel = VerticalPanel()
        self.text = TextArea()
        self.submitButton = Button(u"Add Comment ")
    #  Handle add comment
    
    @java.private
    @java.innerclass
    @java.implements(AsyncCallbackJavaScriptObject)
    class AddCommentCallback(Object):
    
        
        @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):
            self.removeLoader(self.outer)
            self.text.setValue(None)
            self.responseWrapper.add(HTML(u" Thanks :-)"))
            self.displayComments()
    #  User adds comment
    
    @java.private
    @java.innerclass
    @java.implements(ClickHandler)
    class AddCommentClickHandler(Object):
    
        
        @java.init
        def __init__(self, *a, **kw):
            pass
        
        @java.typed(ClickEvent)
        def onClick(self, event):
            comment = Comment.createComment(u"comments_test", self.text.getValue())
            self.apiClient.commentsAdd(comment, self.AddCommentCallback())
    
    @__init__.register
    @java.typed()
    def __init__(self, ):
        self.__init__._super()
        """
        New demo
        """
        self.inputWrapper.setSpacing(10)
        self.outer.setSpacing(10)
        self.inputWrapper.getElement().setId(u"CommentsAdd-Input") #  ID's
        self.submitButton.getElement().getStyle().setProperty(u"float", u"right") #  Styles
        self.submitButton.getElement().getStyle().setProperty(u"marginTop", u"10px")
        self.inputWrapper.add(HTML(u"A comment would be great! Thanks."))
        self.inputWrapper.add(self.createInputUi())
        self.outer.add(self.inputWrapper)
        self.outer.add(self.responseWrapper) #  Thank you
        self.outer.add(self.commentsListPanel) #  Show list of comments
        self.displayComments()
        self.submitButton.addClickHandler(self.AddCommentClickHandler())
        Xfbml.parse(self.inputWrapper)
        self.initWidget(self.outer)
    
    @java.private
    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 displayComments(self):
        self.commentsListPanel.clear()
        comments = Comments_get()
        self.commentsListPanel.add(comments)
class Notes_create(Showcase):

    """
    Showcase for method <code>notes.create</code>
    
    @author ola
    """
    
    @java.init
    def __init__(self, *a, **kw):
        self.outer = VerticalPanel()
        self.permissionHolder = HorizontalPanel()
        self.saveButton = Button(u"Save Note ")
    
    @java.private
    @java.innerclass
    @java.implements(AsyncCallbackBoolean)
    class DeleteNoteCallback(Object):
    
        """
        Delete note callback
        """
        
        @java.init
        def __init__(self, *a, **kw):
            pass
        
        @java.typed(Throwable)
        def onFailure(self, caught):
            self.handleFailure(caught)
        
        @java.typed(Boolean)
        def onSuccess(self, result):
            self.outer.add(Label(u"Note deleted"))
    
    @java.private
    @java.innerclass
    @java.implements(ClickHandler)
    class DeleteNoteClickHandler(Object):
    
        """
        Delete note
        """
        
        @java.init
        def __init__(self, *a, **kw):
            self.noteId = None
        
        @__init__.register
        @java.typed(Long)
        def __init__(self, noteId):
            self.noteId = noteId
        
        @java.typed(ClickEvent)
        def onClick(self, event):
            self.deleteNote(self.noteId)
    
    @__init__.register
    @java.typed()
    def __init__(self, ):
        self.__init__._super()
        self.outer = VerticalPanel()
        self.saveButton.setEnabled(False) #  Need this here so we can enable when user granted permission
        self.outer.add(HTML(u"<h3>Note: this method is marked as beta in the API and may not work </h3> "))
        self.outer.add(self.permissionHolder)
        self.outer.add(self.createUserInputUI(self.saveButton))
        self.initWidget(self.outer) #  Get right permission to create a note, if we get the right
    
    @java.private
    @java.typed(Long)
    def deleteNote(self, noteId):
        self.apiClient.notesDelete(noteId, self.DeleteNoteCallback())
    
    def permissionGranted(self):
        self.saveButton.setEnabled(True)
    
    def getNeedPermission(self):
        return Permission.create_note
    
    @java.private
    @java.typed(Button)
    def createUserInputUI(self, saveButton):
        """
        Create user input UI
        
        @return user input ui
        """
        p = VerticalPanel()
        title = TextBox()
        content = TextBox()
        p.setSpacing(10)
        p.add(self.createInput(u"Title", title))
        p.add(self.createInput(u"Content", content))
        p.add(saveButton)
        class _anonymous(ClickHandler):
            
            @java.typed(ClickEvent)
            def onClick(self, event):
                note = Note.createNote(title.getValue(), content.getValue())
                class _anonymous(AsyncCallback):
                    
                    @java.typed(Throwable)
                    def onFailure(self, caught):
                        Notes_create.self###NOTIMPL QThis###.handleFailure(caught)
                    
                    @java.typed(Long)
                    def onSuccess(self, noteId):
                        p.add(HTML(u"Added note with id " + java.str(noteId)))
                        deleteNoteLink = Anchor(u"Delete")
                        deleteNoteLink.addClickHandler(self.DeleteNoteClickHandler(noteId))
                        p.add(deleteNoteLink)
                self.apiClient.notesCreate(note, _anonymous())
        saveButton.addClickHandler(_anonymous()) #  User clicks save, store it to facebook
        return p
    
    @java.private
    @java.typed(String, Widget)
    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, *a, **kw):
     self.outer = VerticalPanel()
     self.permissionHolder = HorizontalPanel()
     self.saveButton = Button(u"Save Note ")
Beispiel #25
0
 def onModuleLoad(self):
     b = Button("Click me", greet)
     RootPanel().add(b)
 def __init__(self, *a, **kw):
     self.outer = VerticalPanel()
     self.userDataPanel = VerticalPanel()
     self.requestArgsPanel = VerticalPanel()
     self.closeButton = Button(u"Okay")
class ErrorResponseUI(DecoratedPopupPanel):

    """
    Wraps an errorresponse from facebook
    
    Css Configuration
    
    <ul>
    <li>gwittit-ErrorResponse
    <li>gwittit-ErrorResponse-header
    <li>gwittit-ErrorResponse-userData
    <li>gwittit-ErrorResponse-requestArgs
    <li>gwittit-ErrorResponse .closeButton
    </ul>
    """
    
    @java.init
    def __init__(self, *a, **kw):
        self.outer = VerticalPanel()
        self.userDataPanel = VerticalPanel()
        self.requestArgsPanel = VerticalPanel()
        self.closeButton = Button(u"Okay")
    
    @__init__.register
    @java.typed(Throwable)
    def __init__(self, t):
        self((t).getErrorMessage()) ##AltConstrInv
        """
        Create new UI object
        @param t original exception
        """
    
    @__init__.register
    @java.typed(ErrorResponse)
    def __init__(self, errorResponse):
        self.__init__._super()
        """
        Create new UI error response
        @param errorResponse original error response
        """
        super(self.__class__,self).setAutoHideEnabled(True)
        msg = errorResponse.getMessage()
        #  Check if the call resulted in an invalid session state.
        if msg.matches(u".*Invalid session.*"):
            msg = u"You must be logged in to do that..."
        self.outer.setWidth(u"600px")
        self.outer.addStyleName(u"gwittit-ErrorResponse") #  Css
        self.userDataPanel.addStyleName(u"gwittit-ErrorResponse-userData")
        self.requestArgsPanel.addStyleName(u"gwittit-ErrorResponse-requestArgs")
        self.closeButton.addStyleName(u"closeButton")
        self.outer.add(HTML(java.str(u"<h3 class=gwittit-ErrorResponse-header> Error Response: " + java.str(msg)) + u"</h3>")) #  Header
        userData = errorResponse.getUserData() #  User Data
        if userData is not None:
            userDataHtml = java.str(java.str(java.str(u"<h3>User Data </h3>" + u"<ul>") + u"<li>ErrorCode: " + userData.getErrorCode()) + u"<li>ErrorMessage: " + userData.getErrorMsg()) + u"</li>"
            self.userDataPanel.add(HTML(userDataHtml))
            self.outer.add(self.userDataPanel)
        requestArgs = userData.getRequestArgs() #  Request Args
        if requestArgs.__len__() > 0:
            self.requestArgsPanel.add(HTML(u"<h3> Request Args </h3>"))
            self.requestArgsPanel.add(HTML(u"<ul>"))
            for i in range(0,requestArgs.__len__()):
                self.requestArgsPanel.add(HTML(java.str(u"<li> " + java.str(requestArgs.get(i).getKey())) + u": " + requestArgs.get(i).getValue()))
            self.requestArgsPanel.add(HTML(u"</ul>"))
            self.outer.add(self.requestArgsPanel)
        class _anonymous(ClickHandler):
            
            @java.typed(ClickEvent)
            def onClick(self, event):
                ErrorResponseUI.self###NOTIMPL QThis###.hide()
        self.closeButton.addClickHandler(_anonymous()) #  Close Button
        self.outer.add(self.closeButton)
        self.setWidget(self.outer)
 def createUploadPhotoUI(self):
     v = VerticalPanel()
     b = Button(u"Upload Photo")
     b.addClickHandler(self.UploadPhotoClickHandler())
     v.add(b)
     return v
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())