def __init__(self):
     PopupPanel.__init__(self, True)
     
     contents = HTML("Click anywhere outside this popup to make it disappear.")
     contents.setWidth("128px")
     self.setWidget(contents)
     
     self.setStyleName("ks-popups-Popup")
Exemple #2
0
 def __init__(self):
     PopupPanel.__init__(self, True)
     
     contents = HTML("Click anywhere outside this popup to make it disappear.")
     contents.setWidth("128px")
     self.add(contents)
     
     self.setStyleName("ks-popups-Popup")
Exemple #3
0
    def __init__(self, sender, offsetX, offsetY, text, show_delay, hide_delay, styleName):
        global tooltip_hide_timer
        
        PopupPanel.__init__(self, True)
        self.show_delay = show_delay
        self.hide_delay = hide_delay
        
        contents = HTML(text)
        self.add(contents)

        left = sender.getAbsoluteLeft() + offsetX
        top = sender.getAbsoluteTop() + offsetY

        self.setPopupPosition(left, top)
        self.setStyleName(styleName)

        if tooltip_hide_timer:
            self.tooltip_show_timer = Timer(1, self)
        else:
            self.tooltip_show_timer = Timer(self.show_delay, self)
    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, sender, offsetX, offsetY, text, show_delay, hide_delay,
                 styleName):
        global tooltip_hide_timer

        PopupPanel.__init__(self, True)
        self.show_delay = show_delay
        self.hide_delay = hide_delay

        contents = HTML(text)
        self.add(contents)

        left = sender.getAbsoluteLeft() + offsetX
        top = sender.getAbsoluteTop() + offsetY

        self.setPopupPosition(left, top)
        self.setStyleName(styleName)

        if tooltip_hide_timer:
            self.tooltip_show_timer = Timer(1, self)
        else:
            self.tooltip_show_timer = Timer(self.show_delay, self)
Exemple #6
0
    def __init__(self):
        self.choicesPopup = PopupPanel(True)
        self.choices = ListBox()
        self.items = SimpleAutoCompletionItems()
        self.popupAdded = False
        self.visible = False

        TextBox.__init__(self)
        self.addKeyboardListener(self)
        self.choices.addChangeListener(self)
        self.setStyleName("AutoCompleteTextBox")

        self.choicesPopup.add(self.choices)
        self.choicesPopup.addStyleName("AutoCompleteChoices")
            
        self.choices.setStyleName("list")
 def hide(self):
     self.tooltip_show_timer.cancel()
     PopupPanel.hide(self)
    def show(self):
        global tooltip_hide_timer

        # activate fast tooltips
        tooltip_hide_timer = Timer(self.hide_delay, self)
        PopupPanel.show(self)
Exemple #9
0
class AutoCompleteTextBox(TextBox):
    def __init__(self):
        self.choicesPopup = PopupPanel(True)
        self.choices = ListBox()
        self.items = SimpleAutoCompletionItems()
        self.popupAdded = False
        self.visible = False

        TextBox.__init__(self)
        self.addKeyboardListener(self)
        self.choices.addChangeListener(self)
        self.setStyleName("AutoCompleteTextBox")

        self.choicesPopup.add(self.choices)
        self.choicesPopup.addStyleName("AutoCompleteChoices")
            
        self.choices.setStyleName("list")

    def setCompletionItems(self, items):
        if not items.getCompletionItems:
            items = SimpleAutoCompletionItems(items)
        
        self.items = items

    def getCompletionItems(self):
        return self.items

    def onKeyDown(self, arg0, arg1, arg2):
        pass

    def onKeyPress(self, arg0, arg1, arg2):
        pass

    def onKeyUp(self, arg0, arg1, arg2):
        if arg1 == KeyboardListener.KEY_DOWN:
            selectedIndex = self.choices.getSelectedIndex()
            selectedIndex += 1
            if selectedIndex > self.choices.getItemCount():
                selectedIndex = 0
        
            self.choices.setSelectedIndex(selectedIndex)           
            return

        if arg1 == KeyboardListener.KEY_UP:
            selectedIndex = self.choices.getSelectedIndex()
            selectedIndex -= 1
            if selectedIndex < 0:
                selectedIndex = self.choices.getItemCount()
            self.choices.setSelectedIndex(selectedIndex)
            return

        if arg1 == KeyboardListener.KEY_ENTER:
            if self.visible:
                self.complete()      
            return

        if arg1 == KeyboardListener.KEY_ESCAPE:
            self.choices.clear()
            self.choicesPopup.hide()
            self.visible = False
            return

        text = self.getText()
        matches = []
        if len(text) > 0:
            matches = self.items.getCompletionItems(text)

        if len(matches) > 0:
            self.choices.clear()

            for i in range(len(matches)):
                self.choices.addItem(matches[i])
                
            if len(matches) == 1 and matches[0] == text:
                self.choicesPopup.hide()
            else:
                self.choices.setSelectedIndex(0)
                self.choices.setVisibleItemCount(len(matches) + 1)
                    
                if not self.popupAdded:
                    RootPanel().add(self.choicesPopup)
                    self.popupAdded = True

                self.choicesPopup.show()
                self.visible = True
                self.choicesPopup.setPopupPosition(self.getAbsoluteLeft(), self.getAbsoluteTop() + self.getOffsetHeight())
                self.choices.setWidth(self.getOffsetWidth() + "px")
        else:
            self.visible = False
            self.choicesPopup.hide()

    def onChange(self, arg0):
        self.complete()

    def onClick(self, arg0):
        self.complete()

    def complete(self):
        if self.choices.getItemCount() > 0:
            self.setText(self.choices.getItemText(self.choices.getSelectedIndex()))
            
        self.choices.clear()
        self.choicesPopup.hide()
        self.setFocus(True)
Exemple #10
0
 def hide(self):
     self.tooltip_show_timer.cancel()
     PopupPanel.hide(self)
Exemple #11
0
 def show(self):
     global tooltip_hide_timer
     
     # activate fast tooltips
     tooltip_hide_timer=Timer(self.hide_delay, self)
     PopupPanel.show(self)