Пример #1
0
    def __init__(self):
        SimplePanel.__init__(self)
        vert = VerticalPanel()
        vert.setSpacing("10px")
        self.add(vert)

        panel = ScrollPanel(Size=("300px", "100px"))

        contents = HTML("<b>Tao Te Ching, Chapter One</b><p>" +
                        "The Way that can be told of is not an unvarying " +
                        "way;<p>The names that can be named are not " +
                        "unvarying names.<p>It was from the Nameless that " +
                        "Heaven and Earth sprang;<p>The named is but the " +
                        "mother that rears the ten thousand creatures, " +
                        "each after its kind.")
        panel.add(contents)
        vert.add(panel)

        container = SimplePanel(Width="400px", Height="200px")
        contents2 = HTML(
            50 *
            "Dont forget to grab the css for SuperScrollPanel in Showcase.css! "
        )
        panel2 = SuperScrollPanel(contents2)
        container.add(panel2)
        vert.add(container)
Пример #2
0
class HTMLDialog(DialogBox):
    def __init__(self, name, html):
        DialogBox.__init__(self)
        self.setText(name)

        closeButton = Button("Close", self)

        htp = HTMLPanel(html)
        self.sp = ScrollPanel(htp)

        dock = DockPanel()
        dock.setSpacing(4)

        dock.add(closeButton, DockPanel.SOUTH)
        dock.add(self.sp, DockPanel.CENTER)

        dock.setCellHorizontalAlignment(closeButton, HasAlignment.ALIGN_RIGHT)
        dock.setCellWidth(self.sp, "100%")
        dock.setWidth("100%")
        self.setWidget(dock)

    def setWidth(self, width):
        DialogBox.setWidth(self, "%dpx" % width)
        self.sp.setWidth("%dpx" % (width - 20))

    def setHeight(self, height):
        DialogBox.setHeight(self, "%dpx" % height)
        self.sp.setHeight("%dpx" % (height - 65))

    def onClick(self, sender):
        self.hide()
Пример #3
0
    def loadChapters(self):

        self.curInfo = ''
        self.curSink = None
        self.description = HTML()
        self.sink_list = SinkList()
        self.panel = DockPanel()

        self.loadSinks()
        self.sinkContainer = DockPanel()
        self.sinkContainer.setStyleName("ks-Sink")

        #self.nf = NamedFrame("section")
        #self.nf.setWidth("100%")
        #self.nf.setHeight("10000")

        self.sp = ScrollPanel(self.sinkContainer)
        #self.sp = VerticalSplitPanel()
        self.sp.setWidth("100%")
        self.sp.setHeight("100%")

        #self.sp.setTopWidget(self.sinkContainer)
        #self.sp.setBottomWidget(self.nf)
        #self.sp.setSplitPosition(10000) # deliberately high - max out.

        vp = VerticalPanel()
        vp.setWidth("99%")
        vp.setHeight("100%")
        vp.add(self.description)
        vp.add(self.sp)

        authors = [("2008, 2009", "Kenneth Casson Leighton", "*****@*****.**")]
        for years, name, email in authors:
            authors_html = \
            '&copy; %s <a href="mailto:%s">%s</a><br />' %\
            (years, email, name)
        authors_panel = HTML()
        authors_panel.setStyleName("ks-Authors")
        authors_panel.setHTML(authors_html[:-6])

        left_panel = DockPanel(Height="100%")
        left_panel.add(self.sink_list, DockPanel.NORTH)
        left_panel.add(authors_panel, DockPanel.SOUTH)

        self.description.setStyleName("ks-Intro")

        self.panel.add(left_panel, DockPanel.WEST)
        self.panel.add(vp, DockPanel.CENTER)

        self.panel.setCellVerticalAlignment(self.sink_list,
                                            HasAlignment.ALIGN_TOP)
        self.panel.setCellWidth(vp, "100%")
        self.panel.setCellHeight(vp, "100%")

        Window.addWindowResizeListener(self)

        History.addHistoryListener(self)
        RootPanel().add(self.panel)

        self.onWindowResized(Window.getClientWidth(), Window.getClientHeight())
Пример #4
0
class HTMLDialog(DialogBox):
    def __init__(self, name, html):
        DialogBox.__init__(self)
        self.setText(name)

        closeButton = Button("Close", self)

        htp = HTMLPanel(html)
        self.sp = ScrollPanel(htp)

        dock = DockPanel()
        dock.setSpacing(4)

        dock.add(closeButton, DockPanel.SOUTH)
        dock.add(self.sp, DockPanel.CENTER)

        dock.setCellHorizontalAlignment(closeButton, HasAlignment.ALIGN_RIGHT)
        dock.setCellWidth(self.sp, "100%")
        dock.setWidth("100%")
        self.setWidget(dock)

    def setWidth(self, width):
        DialogBox.setWidth(self, "%dpx" % width)
        self.sp.setWidth("%dpx" % (width-20))

    def setHeight(self, height):
        DialogBox.setHeight(self, "%dpx" % height)
        self.sp.setHeight("%dpx" % (height-65))

    def onClick(self, sender):
        self.hide()
Пример #5
0
def panel ( ui ):
    """ Creates a panel-based user interface for a specified UI object.
    """
    # Bind the context values to the 'info' object:
    ui.info.bind_context()

    # Get the content that will be displayed in the user interface:
    content = ui._groups
    nr_groups = len(content)

    if nr_groups == 0:
        panel = None
    if nr_groups == 1:
        panel = _GroupPanel(content[0], ui).control
    elif nr_groups > 1:
        panel = TabPanel()
        _fill_panel(panel, content, ui)
        panel.ui = ui

    # If the UI is scrollable then wrap the panel in a scroll area.
    if ui.scrollable and panel is not None:
        sp = ScrollPanel()
        sp.add(panel)
        panel = sp

    return panel
Пример #6
0
class HorizontalCollapsePanel(FlowPanel):
    def __init__(self, *args, **kwargs):
        # set defaults
        if not 'StyleName' in kwargs:
            kwargs['StyleName'] = "rjw-HorizontalCollapsePanel"

        FlowPanel.__init__(self, *args, **kwargs)

        self._containers = [
                ScrollPanel(StyleName = self.getStylePrimaryName() + '-left'),
                ScrollPanel(StyleName = self.getStylePrimaryName() + '-right'),
        ]
        self._collapse_widget = ScrollPanel(StyleName = self.getStylePrimaryName() + '-collapse')
        collapse_button = ToggleButton(StyleName = self.getStylePrimaryName() + '-collapse-button')
        collapse_button.addClickListener(self._sync_collapse)
        self._collapse_widget.add(collapse_button)

        FlowPanel.add(self, self._containers[0])
        FlowPanel.add(self, self._collapse_widget)
        FlowPanel.add(self, self._containers[1])

        self._sync_collapse()

    def _sync_collapse(self, w=None):
        collapse_button = self._collapse_widget.getWidget(0)
        if collapse_button.isDown():
            self.addStyleName(self.getStylePrimaryName() + '-collapsed')
        else:
            self.removeStyleName(self.getStylePrimaryName() + '-collapsed')

    def getWidget(self, index):
        if index >= 0 and index < len(self._containers):
            return self._containers[index].getWidget()
        console.error('HorizontalCollapsePanel.getWidget passed invalid index: ' + str(index))
        raise IndexError('Index out of range')

    def setWidget(self, index, widget):
        if index >= 0 and index < len(self._containers):
            return self._containers[index].setWidget(widget)
        console.error('HorizontalCollapsePanel.setWidget passed invalid index: ' + str(index))
        raise IndexError('Index out of range')

    # Adds a widget to a pane
    def add(self, widget):
        if self.getWidget(0) == None:
            self.setWidget(0, widget)
        elif self.getWidget(1) == None:
            self.setWidget(1, widget)
        else:
            console.error("HorizontalCollapsePanel can only contain two child widgets.")

    # Removes a child widget.
    def remove(self, widget):
        if self.getWidget(0) == widget:
            self._containers[0].remove(widget)
        elif self.getWidget(1) == widget:
            self._containers[1].remove(widget)
        else:
            AbsolutePanel.remove(self, widget)
Пример #7
0
    def __init__(self, panel):
        ScrollPanel.__init__(self)
        self.setHeight("100%")
        self.setStyleName("SuperScrollPanelOuter")

        self.inner = SimplePanel(Height="100%")
        self.add(self.inner)
        self.inner.setStyleName("SuperScrollPanelInner")
        self.inner.add(panel)
Пример #8
0
    def __init__(self,onClick):
        ScrollPanel.__init__(self, Size=("630px", "500px"))
        self.checkbox_list = []
        self.hpanel_list = []
        self.image_list = []

        self.pok = VerticalPanel()
        self.add(self.pok)
        self.onclick=onClick
Пример #9
0
    def __init__(self, panel):
        ScrollPanel.__init__(self)
        self.setHeight("100%")
        self.setStyleName("SuperScrollPanelOuter")

        self.inner = SimplePanel(Height="100%")
        self.add(self.inner)
        self.inner.setStyleName("SuperScrollPanelInner")
        self.inner.add(panel)
Пример #10
0
class MailDetail(Composite):
    def __init__(self):
        Composite.__init__(self)

        panel = VerticalPanel()
        headerPanel = VerticalPanel()
        self.subject = HTML()
        self.sender = HTML()
        self.recipient = HTML()
        self.body = HTML()
        self.scroller = ScrollPanel(self.body)

        self.body.setWordWrap(True)

        headerPanel.add(self.subject)
        headerPanel.add(self.sender)
        headerPanel.add(self.recipient)
        headerPanel.setWidth("100%")

        innerPanel = DockPanel()
        innerPanel.add(headerPanel, DockPanel.NORTH)
        innerPanel.add(self.scroller, DockPanel.CENTER)

        innerPanel.setCellHeight(self.scroller, "100%")
        panel.add(innerPanel)
        innerPanel.setSize("100%", "100%")
        self.scroller.setSize("100%", "100%")
        self.initWidget(panel)

        self.setStyleName("mail-Detail")
        headerPanel.setStyleName("mail-DetailHeader")
        innerPanel.setStyleName("mail-DetailInner")
        self.subject.setStyleName("mail-DetailSubject")
        self.sender.setStyleName("mail-DetailSender")
        self.recipient.setStyleName("mail-DetailRecipient")
        self.body.setStyleName("mail-DetailBody")
        Logger("Mail detail", " ")

    def setItem(self, item):
        self.scroller.setScrollPosition(0)
        self.scroller.setHorizontalScrollPosition(0)
        self.subject.setHTML(item.subject)
        self.sender.setHTML("<b>From:</b>&nbsp;" + item.sender)
        self.recipient.setHTML("<b>To:</b>&nbsp;[email protected]")
        self.body.setHTML(item.body)
        
    def adjustSize(self, windowWidth, windowHeight):
        scrollWidth = windowWidth - self.scroller.getAbsoluteLeft() - 9
        if (scrollWidth < 1):
            scrollWidth = 1

        scrollHeight = windowHeight - self.scroller.getAbsoluteTop() - 9
        if (scrollHeight < 1):
            scrollHeight = 1

        self.scroller.setSize("%dpx" % scrollWidth, "%dpx" % scrollHeight)
Пример #11
0
class MailDetail(Composite):
    def __init__(self):
        Composite.__init__(self)

        panel = VerticalPanel()
        headerPanel = VerticalPanel()
        self.subject = HTML()
        self.sender = HTML()
        self.recipient = HTML()
        self.body = HTML()
        self.scroller = ScrollPanel(self.body)

        self.body.setWordWrap(True)

        headerPanel.add(self.subject)
        headerPanel.add(self.sender)
        headerPanel.add(self.recipient)
        headerPanel.setWidth("100%")

        innerPanel = DockPanel()
        innerPanel.add(headerPanel, DockPanel.NORTH)
        innerPanel.add(self.scroller, DockPanel.CENTER)

        innerPanel.setCellHeight(self.scroller, "100%")
        panel.add(innerPanel)
        innerPanel.setSize("100%", "100%")
        self.scroller.setSize("100%", "100%")
        self.initWidget(panel)

        self.setStyleName("mail-Detail")
        headerPanel.setStyleName("mail-DetailHeader")
        innerPanel.setStyleName("mail-DetailInner")
        self.subject.setStyleName("mail-DetailSubject")
        self.sender.setStyleName("mail-DetailSender")
        self.recipient.setStyleName("mail-DetailRecipient")
        self.body.setStyleName("mail-DetailBody")
        Logger("Mail detail", " ")

    def setItem(self, item):
        self.scroller.setScrollPosition(0)
        self.scroller.setHorizontalScrollPosition(0)
        self.subject.setHTML(item.subject)
        self.sender.setHTML("<b>From:</b>&nbsp;" + item.sender)
        self.recipient.setHTML("<b>To:</b>&nbsp;[email protected]")
        self.body.setHTML(item.body)

    def adjustSize(self, windowWidth, windowHeight):
        scrollWidth = windowWidth - self.scroller.getAbsoluteLeft() - 9
        if (scrollWidth < 1):
            scrollWidth = 1

        scrollHeight = windowHeight - self.scroller.getAbsoluteTop() - 9
        if (scrollHeight < 1):
            scrollHeight = 1

        self.scroller.setSize("%dpx" % scrollWidth, "%dpx" % scrollHeight)
Пример #12
0
 def __init__(self):
     HorizontalPanel.__init__(self, Spacing=4)
     self.add(Label("Queued:", StyleName="section"))
     s = ScrollPanel()
     self.add(s)
     v = VerticalPanel()
     s.add(v)
     self.queued = Grid(StyleName="users")
     v.add(self.queued)
     self.button = Button("Refresh", self, StyleName="refresh")
     self.add(self.button)
     self.err = Label()
     self.add(self.err)
     self.update()
Пример #13
0
    def onModuleLoad(self):

        self.remote = InfoServicePython()

        self.tree_width = 200

        self.tp = HorizontalPanel()
        self.tp.setWidth("%dpx" % (self.tree_width))
        self.treeview = Trees()
        self.treeview.fTree.addTreeListener(self)
        self.sp = ScrollPanel()
        self.tp.add(self.treeview)
        self.sp.add(self.tp)
        self.sp.setHeight("100%")

        self.horzpanel1 = HorizontalPanel()
        self.horzpanel1.setSize("100%", "100%")
        self.horzpanel1.setBorderWidth(1)
        self.horzpanel1.setSpacing("10px")

        self.rp = RightPanel()
        self.rps = ScrollPanel()
        self.rps.add(self.rp)
        self.rps.setWidth("100%")
        self.rp.setWidth("100%")

        self.cp1 = CollapserPanel(self)
        self.cp1.setWidget(self.sp)
        self.cp1.setHTML("&nbsp;")


        self.midpanel = MidPanel(self)
        self.cp2 = CollapserPanel(self)
        self.cp2.setWidget(self.midpanel)
        self.cp2.setHTML("&nbsp;")

        self.horzpanel1.add(self.cp1)
        self.horzpanel1.add(self.cp2)
        self.horzpanel1.add(self.rps)

        self.cp1.setInitialWidth("%dpx" % self.tree_width)
        self.cp2.setInitialWidth("200px")

        RootPanel().add(self.horzpanel1)

        width = Window.getClientWidth()
        height = Window.getClientHeight()

        self.onWindowResized(width, height)
        Window.addWindowResizeListener(self)
Пример #14
0
class AdinfoIFACE(PanelIFACE):
    def __init__(self, parent = None):
        PanelIFACE.__init__(self, parent)
        
        self.panel = ScrollPanel()
        adinfo = HTML("", Size=("100%", parent.getHeight()))
        self.panel.setSize("100%", parent.getHeight())
        
        self.panel.add(adinfo)
        self.adInfo = parent.adInfo = adinfo
        Window.addWindowResizeListener(self)
        return
        
    def onTreeItemSelected(self, item):
        pathdict = self.pathdict
        
        filename = item.getText()
        #check if already in
        if filename in pathdict:
            if pathdict[filename]["filetype"] == "fileEntry":
                url = "adinfo?filename=%s" % self.pathdict[item.getText()]["path"]
                HTTPRequest().asyncGet(url, 
                               ADInfoLoader(self),
                              )
            else:
                self.adInfo.setHTML("""
                    <b style="font-size:200%%">%s</b>""" % pathdict[filename]["filetype"])
        
    def scroll(self, where):
        self.panel.setScrollPosition(where)
        
    def onWindowResized(self, width, height):
        self.panel.setSize("100%", self.parent.getHeight())
        self.adInfo.setSize("100%", self.parent.getHeight())
Пример #15
0
    def onModuleLoad(self):

        self.remote = InfoServicePython()

        self.tree_width = 200

        self.tp = HorizontalPanel()
        self.tp.setWidth("%dpx" % (self.tree_width))
        self.treeview = Trees()
        self.treeview.fTree.addTreeListener(self)
        self.sp = ScrollPanel()
        self.tp.add(self.treeview)
        self.sp.add(self.tp)
        self.sp.setHeight("100%")

        self.horzpanel1 = HorizontalPanel()
        self.horzpanel1.setSize("100%", "100%")
        self.horzpanel1.setBorderWidth(1)
        self.horzpanel1.setSpacing("10px")

        self.rp = RightPanel()
        self.rps = ScrollPanel()
        self.rps.add(self.rp)
        self.rps.setWidth("100%")
        self.rp.setWidth("100%")

        self.cp1 = CollapserPanel(self)
        self.cp1.setWidget(self.sp)
        self.cp1.setHTML("&nbsp;")


        self.midpanel = MidPanel(self)
        self.cp2 = CollapserPanel(self)
        self.cp2.setWidget(self.midpanel)
        self.cp2.setHTML("&nbsp;")

        self.horzpanel1.add(self.cp1)
        self.horzpanel1.add(self.cp2)
        self.horzpanel1.add(self.rps)

        self.cp1.setInitialWidth("%dpx" % self.tree_width)
        self.cp2.setInitialWidth("200px")

        RootPanel().add(self.horzpanel1)

        width = Window.getClientWidth()
        height = Window.getClientHeight()

        self.onWindowResized(width, height)
        Window.addWindowResizeListener(self)
Пример #16
0
    def __init__(self):
        Composite.__init__(self)

        self.vp_list = VerticalPanel()
        self.sinks = []
        self.selectedSink = -1

        self.sp = ScrollPanel(self.vp_list)
        self.sp.setWidth("24em")

        self.initWidget(self.sp)
        self.setStyleName("ks-List")

        self.resize(Window.getClientWidth(), Window.getClientHeight())
Пример #17
0
 def __init__(self):
     HorizontalPanel.__init__(self, Spacing=4)
     self.add(Label('Underway:', StyleName='section'))
     s = ScrollPanel()
     self.add(s)
     v = VerticalPanel()
     s.add(v)
     self.queued = Grid(StyleName='users')
     v.add(self.queued)
     self.button = Button('Refresh', self, StyleName='refresh')
     self.add(self.button)
     self.err = Label()
     self.add(self.err)
     self.update()
    def __init__(self, vertical=False, **kwargs):
        # set defaults
        if not 'StyleName' in kwargs:
            if vertical:    # vertical split panel
                kwargs['StyleName'] = "gwt-VerticalSplitPanel"
            else:
                kwargs['StyleName'] = "gwt-HorizontalSplitPanel"
        # splitter drag state vars
        self._drag_start = None
        self._pos = "50%"
        # orientation
        self._vertical = vertical
        # now init the bases
        AbsolutePanel.__init__(self, **kwargs)
        MouseHandler.__init__(self)
        # add our event support?
        self.addListenedEvent("Resize")
        # create the top/left widget container
        self._container1 = ScrollPanel()
        # create the bottom/right widget container
        self._container2 = ScrollPanel()
        # create the splitter
        self._splitter = SplitPanelSplitter(self)
        # add splitter handling
        self._splitter.addMouseListener(self)
        # add mouse event handling
        self.addMouseListener(self)
        # add the parts
        AbsolutePanel.add(self, self._container1, 0, 0)
        AbsolutePanel.add(self, self._splitter, 0, 0)
        AbsolutePanel.add(self, self._container2, 0, 0)

        # set the layout
        if vertical:    # vertical split panel
            self._splitter.setStyleName("vsplitter")
            self._splitter.setWidth("100%")
            self._container1.setWidth("100%")
            self._container2.setWidth("100%")
            # set drag cursor
            DOM.setStyleAttribute(self._splitter.getElement(),
                                    "cursor", "n-resize")
        else:   # horizontal split panel
            self._splitter.setStyleName("hsplitter")
            self._splitter.setHeight("100%")
            self._container1.setHeight("100%")
            self._container2.setHeight("100%")
            # set drag cursor
            DOM.setStyleAttribute(self._splitter.getElement(),
                                    "cursor", "e-resize")
Пример #19
0
    def loadChapters(self):

        self.curInfo = ''
        self.curSink = None
        self.description = HTML()
        self.sink_list = SinkList()
        self.panel = DockPanel()

        self.loadSinks()
        self.sinkContainer = DockPanel()
        self.sinkContainer.setStyleName("ks-Sink")

        #self.nf = NamedFrame("section")
        #self.nf.setWidth("100%")
        #self.nf.setHeight("10000")

        height = Window.getClientHeight()

        self.sp = ScrollPanel(self.sinkContainer)
        #self.sp = VerticalSplitPanel()
        self.sp.setWidth("98%")
        self.sp.setHeight("%dpx" % (height - 200))

        #self.sp.setTopWidget(self.sinkContainer)
        #self.sp.setBottomWidget(self.nf)
        #self.sp.setSplitPosition(10000) # deliberately high - max out.

        vp = VerticalPanel()
        vp.setWidth("100%")
        vp.setHeight("100%")
        vp.add(self.description)
        vp.add(self.sp)

        self.description.setStyleName("ks-Intro")

        self.panel.add(self.sink_list, DockPanel.WEST)
        self.panel.add(vp, DockPanel.CENTER)

        self.panel.setCellVerticalAlignment(self.sink_list,
                                            HasAlignment.ALIGN_TOP)
        self.panel.setCellWidth(vp, "100%")
        self.panel.setCellHeight(vp, "100%")

        Window.addWindowResizeListener(self)

        History.addHistoryListener(self)
        RootPanel().add(self.panel)

        self.onWindowResized(Window.getClientWidth(), Window.getClientHeight())
Пример #20
0
    def __init__(self, vertical=False, **kwargs):
        # set defaults
        if not 'StyleName' in kwargs:
            if vertical:    # vertical split panel
                kwargs['StyleName'] = "gwt-VerticalSplitPanel"
            else:
                kwargs['StyleName'] = "gwt-HorizontalSplitPanel"
        # splitter drag state vars
        self._drag_start = None
        self._pos = "50%"
        # orientation
        self._vertical = vertical
        # now init the bases
        AbsolutePanel.__init__(self, **kwargs)
        MouseHandler.__init__(self)
        # add our event support?
        self.addListenedEvent("Resize")
        # create the top/left widget container
        self._container1 = ScrollPanel()
        # create the bottom/right widget container
        self._container2 = ScrollPanel()
        # create the splitter
        self._splitter = SplitPanelSplitter(self)
        # add splitter handling
        self._splitter.addMouseListener(self)
        # add mouse event handling
        self.addMouseListener(self)
        # add the parts
        AbsolutePanel.add(self, self._container1, 0, 0)
        AbsolutePanel.add(self, self._splitter, 0, 0)
        AbsolutePanel.add(self, self._container2, 0, 0)

        # set the layout
        if vertical:    # vertical split panel
            self._splitter.setStyleName("vsplitter")
            self._splitter.setWidth("100%")
            self._container1.setWidth("100%")
            self._container2.setWidth("100%")
            # set drag cursor
            DOM.setStyleAttribute(self._splitter.getElement(),
                                    "cursor", "n-resize")
        else:   # horizontal split panel
            self._splitter.setStyleName("hsplitter")
            self._splitter.setHeight("100%")
            self._container1.setHeight("100%")
            self._container2.setHeight("100%")
            # set drag cursor
            DOM.setStyleAttribute(self._splitter.getElement(),
                                    "cursor", "e-resize")
Пример #21
0
    def __init__(self):
        SimplePanel.__init__(self)

        panel = ScrollPanel(Size=("300px", "100px"))

        contents = HTML("<b>Tao Te Ching, Chapter One</b><p>" +
                        "The Way that can be told of is not an unvarying " +
                        "way;<p>The names that can be named are not " +
                        "unvarying names.<p>It was from the Nameless that " +
                        "Heaven and Earth sprang;<p>The named is but the " +
                        "mother that rears the ten thousand creatures, " +
                        "each after its kind.")

        panel.add(contents)
        self.add(panel)
Пример #22
0
    def __init__(self):
        SimplePanel.__init__(self)

        panel = ScrollPanel(Size=("300px", "100px"))

        contents = HTML("<b>Tao Te Ching, Chapter One</b><p>" +
                        "The Way that can be told of is not an unvarying " +
                        "way;<p>The names that can be named are not " +
                        "unvarying names.<p>It was from the Nameless that " +
                        "Heaven and Earth sprang;<p>The named is but the " +
                        "mother that rears the ten thousand creatures, " +
                        "each after its kind.")

        panel.add(contents)
        self.add(panel)
Пример #23
0
class SinkList(Composite):
    def __init__(self):
        Composite.__init__(self)

        self.vp_list = VerticalPanel()
        self.sinks = []
        self.selectedSink = -1

        self.sp = ScrollPanel(self.vp_list)
        self.sp.setWidth("24em")

        self.initWidget(self.sp)
        self.setStyleName("ks-List")

        self.resize(Window.getClientWidth(), Window.getClientHeight())

    def resize(self, width, height):
        self.sp.setHeight("%dpx" % (height - 70))

    def addSink(self, info):
        name = info.getName()
        link = Hyperlink(name, False, name)
        link.setStyleName("ks-SinkItem")
        self.vp_list.add(link)
        self.sinks.append(info)

    def find(self, sinkName):
        for info in self.sinks:
            if info.getName() == sinkName:
                return info
        return None

    def setSinkSelection(self, name):
        if self.selectedSink <> -1:
            self.vp_list.getWidget(
                self.selectedSink).removeStyleName("ks-SinkItem-selected")

        for i in range(len(self.sinks)):
            info = self.sinks[i]
            if (info.getName() == name):
                self.selectedSink = i
                widget = self.vp_list.getWidget(self.selectedSink)
                widget.addStyleName("ks-SinkItem-selected")
                return
Пример #24
0
class SinkList(Composite):
    def __init__(self):
        Composite.__init__(self)

        self.vp_list=VerticalPanel()
        self.sinks=[]
        self.selectedSink=-1

        self.sp = ScrollPanel(self.vp_list)
        self.sp.setWidth("14em")

        self.initWidget(self.sp)
        self.setStyleName("ks-List")

        self.resize(Window.getClientWidth(), Window.getClientHeight())

    def resize(self, width, height):
        self.sp.setHeight("%dpx" % (height - 70))

    def addSink(self, info):
        name = info.getName()
        link = Hyperlink(name, False, TargetHistoryToken=name)
        link.setStyleName("ks-SinkItem")
        self.vp_list.add(link)
        self.sinks.append(info)

    def find(self, sinkName):
        for info in self.sinks:
            if info.getName()==sinkName:
                return info
        return None

    def setSinkSelection(self, name):
        if self.selectedSink <> -1:
            self.vp_list.getWidget(self.selectedSink).removeStyleName("ks-SinkItem-selected")

        for i in range(len(self.sinks)):
            info = self.sinks[i]
            if (info.getName()==name):
                self.selectedSink = i
                widget=self.vp_list.getWidget(self.selectedSink)
                widget.addStyleName("ks-SinkItem-selected")
                return
Пример #25
0
    def __init__(self, after):
        ScrollPanel.__init__(self, Size=("630px", "500px"))
        self.after = after
        self.pok = VerticalPanel()
        self.add(self.pok)
        self.images = list()

        def onItemSelected():
            item = self.list2.getItemText(self.list2.getSelectedIndex())
            self.refresh_theorems(item)

        self.list2 = ListBox()
        self.list2.setVisibleItemCount(1)
        for f in Theorem.get_all_folders():
            self.list2.addItem(f)
        self.pok.add(self.list2)
        self.list2.addChangeListener(onItemSelected)

        self.refresh_theorems(self.list2.getItemText(self.list2.getSelectedIndex()))
Пример #26
0
    def __init__(self, name, html):
        DialogBox.__init__(self)
        self.setText(name)

        closeButton = Button("Close", self)

        htp = HTMLPanel(html)
        self.sp = ScrollPanel(htp)

        dock = DockPanel()
        dock.setSpacing(4)

        dock.add(closeButton, DockPanel.SOUTH)
        dock.add(self.sp, DockPanel.CENTER)

        dock.setCellHorizontalAlignment(closeButton, HasAlignment.ALIGN_RIGHT)
        dock.setCellWidth(self.sp, "100%")
        dock.setWidth("100%")
        self.setWidget(dock)
Пример #27
0
    def __init__(self, after):
        ScrollPanel.__init__(self, Size=("630px", "500px"))
        self.after = after
        self.pok = VerticalPanel()
        self.add(self.pok)
        self.images = list()

        def onItemSelected():
            item = self.list2.getItemText(self.list2.getSelectedIndex())
            self.refresh_theorems(item)

        self.list2 = ListBox()
        self.list2.setVisibleItemCount(1)
        for f in Theorem.get_all_folders():
            self.list2.addItem(f)
        self.pok.add(self.list2)
        self.list2.addChangeListener(onItemSelected)

        self.refresh_theorems(
            self.list2.getItemText(self.list2.getSelectedIndex()))
Пример #28
0
    def __init__(self, **kwargs):
        DockPanel.__init__(self, **kwargs)
        self.grid = Grid(StyleName="datagrid")
        self.sp = ScrollPanel(self.grid, Width="100%", Height="100%")
        self.header = Grid(Height="50px")
        self.add(self.header, DockPanel.NORTH)
        self.add(self.sp, DockPanel.CENTER)
        cf = self.setCellHeight(self.header, "50px")
        cf = self.setCellHeight(self.sp, "100%")

        self.sortcol = 0
Пример #29
0
 def __init__(self, parent = None):
     PanelIFACE.__init__(self, parent)
     
     self.panel = ScrollPanel()
     adinfo = HTML("", Size=("100%", parent.getHeight()))
     self.panel.setSize("100%", parent.getHeight())
     
     self.panel.add(adinfo)
     self.adInfo = parent.adInfo = adinfo
     Window.addWindowResizeListener(self)
     return
Пример #30
0
    def __init__(self):
        self.artist =''
        self.start_date = ''
        self.end_date = ''
        self.period_search =''
        self.search_option = 1
        #declare the general interface widgets
        self.panel = DockPanel(StyleName = 'background')
        self.ret_area = TextArea()
        self.ret_area.setWidth("350px")
        self.ret_area.setHeight("90px")
        self.options = ListBox()

        self.search_button = Button("Search", getattr(self, "get_result"), StyleName = 'button')

        #set up the date search panel; it has different text boxes for
        #to and from search dates
        self.date_search_panel = VerticalPanel()
        self.date_search_start = TextBox()
        self.date_search_start.addInputListener(self)
        self.date_search_end = TextBox()
        self.date_search_end.addInputListener(self)
        
        self.date_search_panel.add(HTML("Enter as month/day/year", True, StyleName = 'text'))
        self.date_search_panel.add(HTML("From:", True, StyleName = 'text'))
        self.date_search_panel.add(self.date_search_start)
        self.date_search_panel.add(HTML("To:", True, StyleName = 'text'))
        self.date_search_panel.add(self.date_search_end)
        #set up the artist search panel
        self.artist_search = TextBox()
        self.artist_search.addInputListener(self)
        self.artist_search_panel = VerticalPanel()
        self.artist_search_panel.add(HTML("Enter artist's name:",True,
                                          StyleName = 'text'))
        self.artist_search_panel.add(self.artist_search)

        #Put together the list timespan search options
        self.period_search_panel = VerticalPanel()
        self.period_search_panel.add(HTML("Select a seach period:",True,
                                          StyleName = 'text'))
        self.period_search = ListBox()
        self.period_search.setVisibleItemCount(1)
        self.period_search.addItem("last week")
        self.period_search.addItem("last month")
        self.period_search.addItem("last year")
        self.period_search.addItem("all time")
        self.period_search_panel.add(self.period_search)
        #add the listeners to the appropriate widgets
        self.options.addChangeListener(self)
        self.period_search.addChangeListener(self)
        self.ret_area_scroll = ScrollPanel()
        self.search_panel = HorizontalPanel()
        self.options_panel = VerticalPanel()
Пример #31
0
    def onModuleLoad(self):
        self.curInfo = ''
        self.curSink = None
        self.description = HTML()
        self.sink_list = SinkList()
        self.panel = DockPanel()
        self.b = Button("load", self)

        self.sinkContainer = DockPanel()
        self.sinkContainer.setStyleName("ks-Sink")

        height = Window.getClientHeight()

        self.sp = ScrollPanel(self.sinkContainer)
        self.sp.setWidth("100%")
        self.sp.setHeight("%dpx" % (height - 110))

        vp = VerticalPanel()
        vp.setWidth("100%")
        vp.setHeight("100%")
        vp.add(self.description)
        vp.add(self.sp)

        self.description.setStyleName("ks-Intro")

        self.panel.add(self.sink_list, DockPanel.WEST)
        self.panel.add(vp, DockPanel.CENTER)

        self.panel.setCellVerticalAlignment(self.sink_list,
                                            HasAlignment.ALIGN_TOP)
        self.panel.setCellWidth(vp, "100%")
        self.panel.setCellHeight(vp, "100%")

        Window.addWindowResizeListener(self)

        History.addHistoryListener(self)
        RootPanel().add(self.panel)
        RootPanel().add(self.b)

        self.loadSinks()
Пример #32
0
    def onModuleLoad(self):
        # build image display
        img = Image("babykatie_small.jpg", width="300px", height="300px")
        img.element.setAttribute("usemap", "#themap")
        img.element.setAttribute("ismap", "1")
        imagepanel = ScrollPanel()
        imagepanel.add(img)

        # build message display
        msgpanel = VerticalPanel()
        msgpanel.add(
            Label("move mouse over baby katie's eyes, nose and mouth."))
        msgarea1 = Label("movement messages")
        msgpanel.add(msgarea1)
        msgarea2 = Label("click messages")
        msgpanel.add(msgarea2)

        imageClickHandler = MapClickHandler(msgarea1, msgarea2)

        # build imagemap
        map = ImageMap("themap", width="300px", height="300px")
        areas = [ \
            NamedMapArea("right eye", "circle", "73, 97, 7"),
            NamedMapArea("left eye", "circle", "116, 88, 5"),
            NamedMapArea("nose", "rect", "88, 97, 115, 115", href="http://lkcl.net"),
            NamedMapArea("mouth", "polygon", "82, 129, 102, 124, 119, 119, 121, 125, 103, 132, 79, 133"),
            ]
        for nma in areas:
            nma.addMouseListener(imageClickHandler)
            nma.addClickListener(imageClickHandler)
            map.add(nma)

        # layout page
        hpanel = HorizontalPanel()
        hpanel.add(map)
        hpanel.add(imagepanel)
        hpanel.add(msgpanel)

        RootPanel().add(hpanel)
Пример #33
0
    def onModuleLoad(self):
        # build image display
        img = Image("babykatie_small.jpg", width="300px", height="300px")
        img.element.setAttribute("usemap", "#themap")
        img.element.setAttribute("ismap", "1")
        imagepanel = ScrollPanel()
        imagepanel.add(img)

        # build message display
        msgpanel = VerticalPanel()
        msgpanel.add(Label("move mouse over baby katie's eyes, nose and mouth."))
        msgarea1 = Label("movement messages")
        msgpanel.add(msgarea1)
        msgarea2 = Label("click messages")
        msgpanel.add(msgarea2)

        imageClickHandler = MapClickHandler(msgarea1, msgarea2)

        # build imagemap
        map = ImageMap("themap", width="300px", height="300px")
        areas = [ \
            NamedMapArea("right eye", "circle", "73, 97, 7"),
            NamedMapArea("left eye", "circle", "116, 88, 5"),
            NamedMapArea("nose", "rect", "88, 97, 115, 115", href="http://lkcl.net"),
            NamedMapArea("mouth", "polygon", "82, 129, 102, 124, 119, 119, 121, 125, 103, 132, 79, 133"),
            ]
        for nma in areas:
            nma.addMouseListener(imageClickHandler)
            nma.addClickListener(imageClickHandler)
            map.add(nma)

        # layout page
        hpanel = HorizontalPanel()
        hpanel.add(map)
        hpanel.add(imagepanel)
        hpanel.add(msgpanel)
                    
        RootPanel().add(hpanel)
Пример #34
0
    def __init__(self):
        SimplePanel.__init__(self)
        vert = VerticalPanel()
        vert.setSpacing("10px")
        self.add(vert)

        panel = ScrollPanel(Size=("300px", "100px"))

        contents = HTML("<b>Tao Te Ching, Chapter One</b><p>" +
                        "The Way that can be told of is not an unvarying " +
                        "way;<p>The names that can be named are not " +
                        "unvarying names.<p>It was from the Nameless that " +
                        "Heaven and Earth sprang;<p>The named is but the " +
                        "mother that rears the ten thousand creatures, " +
                        "each after its kind.")
        panel.add(contents)
        vert.add(panel)

        container = SimplePanel(Width="400px", Height="200px")
        contents2 = HTML(50*"Dont forget to grab the css for SuperScrollPanel in Showcase.css! ")
        panel2 = SuperScrollPanel(contents2)
        container.add(panel2)
        vert.add(container)
Пример #35
0
    def __init__(self):
        Composite.__init__(self)

        self.vp_list=VerticalPanel()
        self.sinks=[]
        self.selectedSink=-1

        self.sp = ScrollPanel(self.vp_list)
        self.sp.setWidth("14em")

        self.initWidget(self.sp)
        self.setStyleName("ks-List")

        self.resize(Window.getClientWidth(), Window.getClientHeight())
Пример #36
0
    def __init__(self):
        Composite.__init__(self)

        panel = VerticalPanel()
        headerPanel = VerticalPanel()
        self.subject = HTML()
        self.sender = HTML()
        self.recipient = HTML()
        self.body = HTML()
        self.scroller = ScrollPanel(self.body)

        self.body.setWordWrap(True)

        headerPanel.add(self.subject)
        headerPanel.add(self.sender)
        headerPanel.add(self.recipient)
        headerPanel.setWidth("100%")

        innerPanel = DockPanel()
        innerPanel.add(headerPanel, DockPanel.NORTH)
        innerPanel.add(self.scroller, DockPanel.CENTER)

        innerPanel.setCellHeight(self.scroller, "100%")
        panel.add(innerPanel)
        innerPanel.setSize("100%", "100%")
        self.scroller.setSize("100%", "100%")
        self.initWidget(panel)

        self.setStyleName("mail-Detail")
        headerPanel.setStyleName("mail-DetailHeader")
        innerPanel.setStyleName("mail-DetailInner")
        self.subject.setStyleName("mail-DetailSubject")
        self.sender.setStyleName("mail-DetailSender")
        self.recipient.setStyleName("mail-DetailRecipient")
        self.body.setStyleName("mail-DetailBody")
        Logger("Mail detail", " ")
Пример #37
0
    def loadChapters(self):

        self.curInfo = ''
        self.curSink = None
        self.description = HTML()
        self.sink_list = SinkList()
        self.panel = DockPanel()
        
        self.loadSinks()
        self.sinkContainer = DockPanel()
        self.sinkContainer.setStyleName("ks-Sink")

        #self.nf = NamedFrame("section")
        #self.nf.setWidth("100%")
        #self.nf.setHeight("10000")

        height = Window.getClientHeight()

        self.sp = ScrollPanel(self.sinkContainer)
        #self.sp = VerticalSplitPanel()
        self.sp.setWidth("100%")
        self.sp.setHeight("%dpx" % (height-110))

        #self.sp.setTopWidget(self.sinkContainer)
        #self.sp.setBottomWidget(self.nf)
        #self.sp.setSplitPosition(10000) # deliberately high - max out.

        vp = VerticalPanel()
        vp.setWidth("100%")
        vp.setHeight("100%")
        vp.add(self.description)
        vp.add(self.sp)

        self.description.setStyleName("ks-Intro")

        self.panel.add(self.sink_list, DockPanel.WEST)
        self.panel.add(vp, DockPanel.CENTER)

        self.panel.setCellVerticalAlignment(self.sink_list,
                                            HasAlignment.ALIGN_TOP)
        self.panel.setCellWidth(vp, "100%")
        self.panel.setCellHeight(vp, "100%")

        Window.addWindowResizeListener(self)

        History.addHistoryListener(self)
        RootPanel().add(self.panel)
Пример #38
0
    def __init__(self, parent = None):
        Sink.__init__(self, parent)
        self.reduceFiles = []
        if True:
            HTTPRequest().asyncGet("datadir.xml", 
                                    DirDictLoader(self),
                                )
        dock = DockPanel(HorizontalAlignment=HasAlignment.ALIGN_LEFT, 
                            Spacing=10,
                             Size=("100%","100%"))
        self.dock = dock
        self.fProto = []

        self.fTree = Tree()
        self.treePanel = ScrollPanel()
        self.treePanel.setSize("100%", 
                                str(
                                 int(
                                  Window.getClientHeight()*.75
                                 )
                                )+"px")
        Window.addWindowResizeListener(self)
        
        self.treePanel.add(self.fTree)
        dock.add(self.treePanel, DockPanel.WEST)
        
        
        #self.treePanel.setBorderWidth(1)
        #self.treePanel.setWidth("100%")
        
        prPanel = self.createRightPanel()
        dock.add(prPanel,DockPanel.EAST)
        
        dock.setCellWidth(self.treePanel, "50%")
        dock.setCellWidth(prPanel, "50%")
        for i in range(len(self.fProto)):
            self.createItem(self.fProto[i])
            self.fTree.addItem(self.fProto[i].item)

        self.fTree.addTreeListener(self)
        self.initWidget(self.dock)
        
        if False: #self.parent.filexml != None:
            DirDictLoader(self).onCompletion(self.parent.filexml)
Пример #39
0
    def __init__(self, name, html):
        DialogBox.__init__(self)
        self.setText(name)

        closeButton = Button("Close", self)

        htp = HTMLPanel(html)
        self.sp = ScrollPanel(htp)

        dock = DockPanel()
        dock.setSpacing(4)

        dock.add(closeButton, DockPanel.SOUTH)
        dock.add(self.sp, DockPanel.CENTER)

        dock.setCellHorizontalAlignment(closeButton, HasAlignment.ALIGN_RIGHT)
        dock.setCellWidth(self.sp, "100%")
        dock.setWidth("100%")
        self.setWidget(dock)
Пример #40
0
    def __init__(self, *args, **kwargs):
        # set defaults
        if not 'StyleName' in kwargs:
            kwargs['StyleName'] = "rjw-HorizontalCollapsePanel"

        FlowPanel.__init__(self, *args, **kwargs)

        self._containers = [
                ScrollPanel(StyleName = self.getStylePrimaryName() + '-left'),
                ScrollPanel(StyleName = self.getStylePrimaryName() + '-right'),
        ]
        self._collapse_widget = ScrollPanel(StyleName = self.getStylePrimaryName() + '-collapse')
        collapse_button = ToggleButton(StyleName = self.getStylePrimaryName() + '-collapse-button')
        collapse_button.addClickListener(self._sync_collapse)
        self._collapse_widget.add(collapse_button)

        FlowPanel.add(self, self._containers[0])
        FlowPanel.add(self, self._collapse_widget)
        FlowPanel.add(self, self._containers[1])

        self._sync_collapse()
Пример #41
0
    def onModuleLoad(self):
        self.curInfo=''
        self.curSink=None
        self.description=HTML()
        self.sink_list=SinkList()
        self.panel=DockPanel()
        self.b=Button("load", self)
        
        self.sinkContainer = DockPanel()
        self.sinkContainer.setStyleName("ks-Sink")

        height = Window.getClientHeight()

        self.sp = ScrollPanel(self.sinkContainer)
        self.sp.setWidth("100%")
        self.sp.setHeight("%dpx" % (height-110))

        vp=VerticalPanel()
        vp.setWidth("100%")
        vp.setHeight("100%")
        vp.add(self.description)
        vp.add(self.sp)

        self.description.setStyleName("ks-Intro")

        self.panel.add(self.sink_list, DockPanel.WEST)
        self.panel.add(vp, DockPanel.CENTER)

        self.panel.setCellVerticalAlignment(self.sink_list, HasAlignment.ALIGN_TOP)
        self.panel.setCellWidth(vp, "100%")
        self.panel.setCellHeight(vp, "100%")

        Window.addWindowResizeListener(self)

        History.addHistoryListener(self)
        RootPanel().add(self.panel)
        #RootPanel().add(self.b)

        self.loadSinks()
Пример #42
0
    def __init__(self):
        Composite.__init__(self)

        panel = VerticalPanel()
        headerPanel = VerticalPanel()
        self.subject = HTML()
        self.sender = HTML()
        self.recipient = HTML()
        self.body = HTML()
        self.scroller = ScrollPanel(self.body)

        self.body.setWordWrap(True)

        headerPanel.add(self.subject)
        headerPanel.add(self.sender)
        headerPanel.add(self.recipient)
        headerPanel.setWidth("100%")

        innerPanel = DockPanel()
        innerPanel.add(headerPanel, DockPanel.NORTH)
        innerPanel.add(self.scroller, DockPanel.CENTER)

        innerPanel.setCellHeight(self.scroller, "100%")
        panel.add(innerPanel)
        innerPanel.setSize("100%", "100%")
        self.scroller.setSize("100%", "100%")
        self.initWidget(panel)

        self.setStyleName("mail-Detail")
        headerPanel.setStyleName("mail-DetailHeader")
        innerPanel.setStyleName("mail-DetailInner")
        self.subject.setStyleName("mail-DetailSubject")
        self.sender.setStyleName("mail-DetailSender")
        self.recipient.setStyleName("mail-DetailRecipient")
        self.body.setStyleName("mail-DetailBody")
        Logger("Mail detail", " ")
Пример #43
0
class Bookreader:

    def onHistoryChanged(self, token):
        info = self.sink_list.find(token)
        if info:
            self.show(info, False)
        else:
            self.showInfo()

    def onModuleLoad(self):
        section = Window.getLocation().getSearchVar("section")
        if not section:
            self.loadChapters()
        else:
            loadSection(section)

    def loadChapters(self):

        self.curInfo = ''
        self.curSink = None
        self.description = HTML()
        self.sink_list = SinkList()
        self.panel = DockPanel()

        self.loadSinks()
        self.sinkContainer = DockPanel()
        self.sinkContainer.setStyleName("ks-Sink")

        #self.nf = NamedFrame("section")
        #self.nf.setWidth("100%")
        #self.nf.setHeight("10000")

        self.sp = ScrollPanel(self.sinkContainer)
        #self.sp = VerticalSplitPanel()
        self.sp.setWidth("100%")
        self.sp.setHeight("100%")

        #self.sp.setTopWidget(self.sinkContainer)
        #self.sp.setBottomWidget(self.nf)
        #self.sp.setSplitPosition(10000) # deliberately high - max out.

        vp = VerticalPanel()
        vp.setWidth("99%")
        vp.setHeight("100%")
        vp.add(self.description)
        vp.add(self.sp)

        authors = [
            ("2008, 2009", "Kenneth Casson Leighton", "*****@*****.**")
        ]
        for years, name, email in authors:
            authors_html = \
            '&copy; %s <a href="mailto:%s">%s</a><br />' %\
            (years, email, name)
        authors_panel = HTML()
        authors_panel.setStyleName("ks-Authors")
        authors_panel.setHTML(authors_html[:-6])

        left_panel = DockPanel(Height="100%")
        left_panel.add(self.sink_list, DockPanel.NORTH)
        left_panel.add(authors_panel, DockPanel.SOUTH)

        self.description.setStyleName("ks-Intro")

        self.panel.add(left_panel, DockPanel.WEST)
        self.panel.add(vp, DockPanel.CENTER)

        self.panel.setCellVerticalAlignment(self.sink_list,
                                            HasAlignment.ALIGN_TOP)
        self.panel.setCellWidth(vp, "100%")
        self.panel.setCellHeight(vp, "100%")

        Window.addWindowResizeListener(self)

        History.addHistoryListener(self)
        RootPanel().add(self.panel)

        self.onWindowResized(Window.getClientWidth(), Window.getClientHeight())

    def onWindowResized(self, width, height):
        self.panel.setWidth(width-20)
        self.sink_list.resize(width-20, height-130)
        self.sp.setHeight("%dpx" % (height-130))

    def show(self, info, affectHistory):
        if info == self.curInfo:
            return
        self.curInfo = info

        #Logger.write("showing " + info.getName())
        if self.curSink is not None:
            self.curSink.onHide()
            #Logger.write("removing " + self.curSink)
            self.sinkContainer.remove(self.curSink)

        self.curSink = info.getInstance()
        self.sink_list.setSinkSelection(info.getName())
        self.sink_list.sp.setScrollPosition(0)
        self.sink_list.sp.setHorizontalScrollPosition(0)
        self.description.setHTML(info.getDescription())

        if (affectHistory):
            History().newItem(info.getName())

        self.sinkContainer.add(self.curSink, DockPanel.CENTER)
        self.sinkContainer.setCellWidth(self.curSink, "100%")
        self.sinkContainer.setCellHeight(self.curSink, "100%")
        self.sinkContainer.setCellVerticalAlignment(self.curSink,
                                                    HasAlignment.ALIGN_TOP)
        self.curSink.onShow()

    def loadSinks(self):
        HTTPRequest().asyncGet("contents.txt", ChapterListLoader(self))

    def setChapters(self, chapters):
        for l in chapters:
            name = l[0]
            desc = l[1]
            self.sink_list.addSink(Chapter.init(name, desc))

        #Show the initial screen.
        initToken = History.getToken()
        if len(initToken):
            self.onHistoryChanged(initToken)
        else:
            self.showInfo()


    def showInfo(self):
        self.show(self.sink_list.sinks[0], False)
Пример #44
0
class Bookreader:
    def onHistoryChanged(self, token):
        info = self.sink_list.find(token)
        if info:
            self.show(info, False)
        else:
            self.showInfo()

    def onModuleLoad(self):
        section = Window.getLocation().getSearchVar("section")
        if not section:
            self.loadChapters()
        else:
            loadSection(section)

    def loadChapters(self):

        self.curInfo = ''
        self.curSink = None
        self.description = HTML()
        self.sink_list = SinkList()
        self.panel = DockPanel()

        self.loadSinks()
        self.sinkContainer = DockPanel()
        self.sinkContainer.setStyleName("ks-Sink")

        #self.nf = NamedFrame("section")
        #self.nf.setWidth("100%")
        #self.nf.setHeight("10000")

        height = Window.getClientHeight()

        self.sp = ScrollPanel(self.sinkContainer)
        #self.sp = VerticalSplitPanel()
        self.sp.setWidth("100%")
        self.sp.setHeight("%dpx" % (height - 110))

        #self.sp.setTopWidget(self.sinkContainer)
        #self.sp.setBottomWidget(self.nf)
        #self.sp.setSplitPosition(10000) # deliberately high - max out.

        vp = VerticalPanel()
        vp.setWidth("100%")
        vp.setHeight("100%")
        vp.add(self.description)
        vp.add(self.sp)

        self.description.setStyleName("ks-Intro")

        self.panel.add(self.sink_list, DockPanel.WEST)
        self.panel.add(vp, DockPanel.CENTER)

        self.panel.setCellVerticalAlignment(self.sink_list,
                                            HasAlignment.ALIGN_TOP)
        self.panel.setCellWidth(vp, "100%")
        self.panel.setCellHeight(vp, "100%")

        Window.addWindowResizeListener(self)

        History.addHistoryListener(self)
        RootPanel().add(self.panel)

    def onWindowResized(self, width, height):
        self.sink_list.resize(width, height)
        self.sp.setHeight("%dpx" % (height - 110))

    def show(self, info, affectHistory):
        if info == self.curInfo:
            return
        self.curInfo = info

        #Logger.write("showing " + info.getName())
        if self.curSink is not None:
            self.curSink.onHide()
            #Logger.write("removing " + self.curSink)
            self.sinkContainer.remove(self.curSink)

        self.curSink = info.getInstance()
        self.sink_list.setSinkSelection(info.getName())
        self.description.setHTML(info.getDescription())

        if (affectHistory):
            History().newItem(info.getName())

        self.sinkContainer.add(self.curSink, DockPanel.CENTER)
        self.sinkContainer.setCellWidth(self.curSink, "100%")
        self.sinkContainer.setCellHeight(self.curSink, "100%")
        self.sinkContainer.setCellVerticalAlignment(self.curSink,
                                                    HasAlignment.ALIGN_TOP)
        self.curSink.onShow()

    def loadSinks(self):
        HTTPRequest().asyncGet("contents.txt", ChapterListLoader(self))

    def setChapters(self, chapters):
        for l in chapters:
            name = l[0]
            desc = l[1]
            self.sink_list.addSink(Chapter.init(name, desc))

        #Show the initial screen.
        initToken = History.getToken()
        if len(initToken):
            self.onHistoryChanged(initToken)
        else:
            self.showInfo()

    def showInfo(self):
        self.show(self.sink_list.sinks[0], False)
Пример #45
0
class Bookreader:
    def onHistoryChanged(self, token):
        info = self.sink_list.find(token)
        if info:
            self.show(info, False)
        else:
            self.showInfo()

    def onModuleLoad(self):
        section = Window.getLocation().getSearchVar("section")
        if not section:
            self.loadChapters()
        else:
            loadSection(section)

    def loadChapters(self):

        self.curInfo = ''
        self.curSink = None
        self.description = HTML()
        self.sink_list = SinkList()
        self.panel = DockPanel()

        self.loadSinks()
        self.sinkContainer = DockPanel()
        self.sinkContainer.setStyleName("ks-Sink")

        #self.nf = NamedFrame("section")
        #self.nf.setWidth("100%")
        #self.nf.setHeight("10000")

        self.sp = ScrollPanel(self.sinkContainer)
        #self.sp = VerticalSplitPanel()
        self.sp.setWidth("100%")
        self.sp.setHeight("100%")

        #self.sp.setTopWidget(self.sinkContainer)
        #self.sp.setBottomWidget(self.nf)
        #self.sp.setSplitPosition(10000) # deliberately high - max out.

        vp = VerticalPanel()
        vp.setWidth("99%")
        vp.setHeight("100%")
        vp.add(self.description)
        vp.add(self.sp)

        authors = [("2008, 2009", "Kenneth Casson Leighton", "*****@*****.**")]
        for years, name, email in authors:
            authors_html = \
            '&copy; %s <a href="mailto:%s">%s</a><br />' %\
            (years, email, name)
        authors_panel = HTML()
        authors_panel.setStyleName("ks-Authors")
        authors_panel.setHTML(authors_html[:-6])

        left_panel = DockPanel(Height="100%")
        left_panel.add(self.sink_list, DockPanel.NORTH)
        left_panel.add(authors_panel, DockPanel.SOUTH)

        self.description.setStyleName("ks-Intro")

        self.panel.add(left_panel, DockPanel.WEST)
        self.panel.add(vp, DockPanel.CENTER)

        self.panel.setCellVerticalAlignment(self.sink_list,
                                            HasAlignment.ALIGN_TOP)
        self.panel.setCellWidth(vp, "100%")
        self.panel.setCellHeight(vp, "100%")

        Window.addWindowResizeListener(self)

        History.addHistoryListener(self)
        RootPanel().add(self.panel)

        self.onWindowResized(Window.getClientWidth(), Window.getClientHeight())

    def onWindowResized(self, width, height):
        self.panel.setWidth(width - 20)
        self.sink_list.resize(width - 20, height - 130)
        self.sp.setHeight("%dpx" % (height - 130))

    def show(self, info, affectHistory):
        if info == self.curInfo:
            return
        self.curInfo = info

        #Logger.write("showing " + info.getName())
        if self.curSink is not None:
            self.curSink.onHide()
            #Logger.write("removing " + self.curSink)
            self.sinkContainer.remove(self.curSink)

        self.curSink = info.getInstance()
        self.sink_list.setSinkSelection(info.getName())
        self.sink_list.sp.setScrollPosition(0)
        self.sink_list.sp.setHorizontalScrollPosition(0)
        self.description.setHTML(info.getDescription())

        if (affectHistory):
            History().newItem(info.getName())

        self.sinkContainer.add(self.curSink, DockPanel.CENTER)
        self.sinkContainer.setCellWidth(self.curSink, "100%")
        self.sinkContainer.setCellHeight(self.curSink, "100%")
        self.sinkContainer.setCellVerticalAlignment(self.curSink,
                                                    HasAlignment.ALIGN_TOP)
        self.curSink.onShow()

    def loadSinks(self):
        HTTPRequest().asyncGet("contents.txt", ChapterListLoader(self))

    def setChapters(self, chapters):
        for l in chapters:
            name = l[0]
            desc = l[1]
            self.sink_list.addSink(Chapter.init(name, desc))

        #Show the initial screen.
        initToken = History.getToken()
        if len(initToken):
            self.onHistoryChanged(initToken)
        else:
            self.showInfo()

    def showInfo(self):
        self.show(self.sink_list.sinks[0], False)
Пример #46
0
    def onModuleLoad(self):
        """ Dynamically build our user interface when the web page is loaded.
        """
        self._root = RootPanel()
        self._tree = Tree()
        self._rightPanel = SimplePanel()
        self._curContents = None

        intro = HTML(
            '<h3>Welcome to the Pyjamas User Interface Showcase</h3>' +
            '<p/>Please click on an item to start.')

        self._introPanel = VerticalPanel()
        self._introPanel.add(uiHelpers.indent(intro, left=20))

        self._demos = [
        ]  # List of all installed demos.  Each item in this list
        # is a dictionary with the following entries:
        #
        #     'name'
        #
        #         The name for this demo.
        #
        #     'section'
        #
        #         The name of the section of the demo tree
        #         this demo should be part of.
        #
        #     'doc'
        #
        #         The documentation for this demo.
        #
        #     'src'
        #
        #         The source code for this demo.
        #
        #     'example'
        #
        #         The Panel which holds the example output for
        #         this demo.

        self.loadDemos()
        self.buildTree()

        self._tree.setSize("0%", "100%")

        divider = VerticalPanel()
        divider.setSize("1px", "100%")
        divider.setBorderWidth(1)

        scroller = ScrollPanel(self._rightPanel)
        scroller.setSize("100%", "100%")

        hPanel = HorizontalPanel()
        hPanel.setSpacing(4)

        hPanel.add(self._tree)
        hPanel.add(divider)
        hPanel.add(scroller)

        hPanel.setHeight("100%")
        self._root.add(hPanel)

        self._tree.addTreeListener(self)
        self.showDemo(None)
Пример #47
0
    def __init__(self):
        Sink.__init__(self)

        text = """This is a <code>ScrollPanel</code> contained at 
        the center of a <code>DockPanel</code>. 
        By putting some fairly large contents 
        in the middle and setting its size explicitly, it becomes a 
        scrollable area within the page, but without requiring the use of 
        an IFRAME.
        Here's quite a bit more meaningless text that will serve primarily 
        to make this thing scroll off the bottom of its visible area.  
        Otherwise, you might have to make it really, really small in order 
        to see the nifty scroll bars!"""

        contents = HTML(text)
        scroller = ScrollPanel(contents, StyleName="ks-layouts-Scroller")

        dock = DockPanel(HorizontalAlignment=HasAlignment.ALIGN_CENTER,
                         Spacing=10)
        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(VerticalAlignment=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(HorizontalAlignment=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 
            components inside existing HTML, like this: <span id='%s' />
            Notice how the menu just fits snugly in there?  Cute.""" % id
        html = HTMLPanel(text)

        DOM.setStyleAttribute(menu.getElement(), "display", "inline")
        html.add(menu, id)

        disclose = DisclosurePanel("Click to disclose")
        disclose.add(
            HTML("""<b>Ta-daaaaa!</b><br />Ok - it could have
                             been<br />more of a surprise."""))

        panel = VerticalPanel(Spacing=8,
                              HorizontalAlignment=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)
        panel.add(self.makeLabel("Disclosure Panel"))
        panel.add(disclose)

        self.initWidget(panel)
        self.setStyleName("ks-layouts")
Пример #48
0
class Slideshow:
    def onHistoryChanged(self, token):
        info = self.sink_list.find(token)
        if info:
            self.show(info, False)
        else:
            self.showInfo()

    def onModuleLoad(self):
        self.curInfo = ''
        self.curSink = None
        self.description = HTML()
        self.sink_list = SinkList()
        self.panel = DockPanel()
        self.b = Button("load", self)

        self.sinkContainer = DockPanel()
        self.sinkContainer.setStyleName("ks-Sink")

        height = Window.getClientHeight()

        self.sp = ScrollPanel(self.sinkContainer)
        self.sp.setWidth("100%")
        self.sp.setHeight("%dpx" % (height - 110))

        vp = VerticalPanel()
        vp.setWidth("100%")
        vp.setHeight("100%")
        vp.add(self.description)
        vp.add(self.sp)

        self.description.setStyleName("ks-Intro")

        self.panel.add(self.sink_list, DockPanel.WEST)
        self.panel.add(vp, DockPanel.CENTER)

        self.panel.setCellVerticalAlignment(self.sink_list,
                                            HasAlignment.ALIGN_TOP)
        self.panel.setCellWidth(vp, "100%")
        self.panel.setCellHeight(vp, "100%")

        Window.addWindowResizeListener(self)

        History.addHistoryListener(self)
        RootPanel().add(self.panel)
        RootPanel().add(self.b)

        self.loadSinks()

    def onClick(self, sender):
        self.loadSinks()

    def onTimer(self, tid):
        self.loadSinks()

    def onWindowResized(self, width, height):
        self.sink_list.resize(width, height)
        self.sp.setHeight("%dpx" % (height - 110))

    def show(self, info, affectHistory):
        if info == self.curInfo: return
        self.curInfo = info

        #Logger.write("showing " + info.getName())
        if self.curSink <> None:
            self.curSink.onHide()
            #Logger.write("removing " + self.curSink)
            self.sinkContainer.remove(self.curSink)

        self.curSink = info.getInstance()
        self.sink_list.setSinkSelection(info.getName())
        self.description.setHTML(info.getDescription())

        if (affectHistory):
            History.newItem(info.getName())

        self.sinkContainer.add(self.curSink, DockPanel.CENTER)
        self.sinkContainer.setCellWidth(self.curSink, "100%")
        self.sinkContainer.setCellHeight(self.curSink, "100%")
        self.sinkContainer.setCellVerticalAlignment(self.curSink,
                                                    HasAlignment.ALIGN_TOP)
        self.curSink.onShow()

    def loadSinks(self):
        HTTPRequest().asyncGet("slides.txt", SlideListLoader(self))

    def setSlides(self, slides):
        for l in slides:
            name = l[0]
            desc = l[1]
            self.sink_list.addSink(Slide.init(name, desc))

        #Show the initial screen.
        initToken = History.getToken()
        if len(initToken):
            self.onHistoryChanged(initToken)
        else:
            self.showInfo()

    def showInfo(self):
        self.show(self.sink_list.sinks[0], False)
class SplitPanel(AbsolutePanel, MouseHandler, EventGenerator):
    """ Provides the SplitPanel baseclass functionality
        A SplitPanel is an AbsolutePanel containing an HTMLTable
        with three cells. The first cell holds the first ScrollPanel,
        while the center cell holds a Splitter, and the last cell
        holds the other ScrollPanel.
    """

    def __init__(self, vertical=False, **kwargs):
        # set defaults
        if not 'StyleName' in kwargs:
            if vertical:    # vertical split panel
                kwargs['StyleName'] = "gwt-VerticalSplitPanel"
            else:
                kwargs['StyleName'] = "gwt-HorizontalSplitPanel"
        # splitter drag state vars
        self._drag_start = None
        self._pos = "50%"
        # orientation
        self._vertical = vertical
        # now init the bases
        AbsolutePanel.__init__(self, **kwargs)
        MouseHandler.__init__(self)
        # add our event support?
        self.addListenedEvent("Resize")
        # create the top/left widget container
        self._container1 = ScrollPanel()
        # create the bottom/right widget container
        self._container2 = ScrollPanel()
        # create the splitter
        self._splitter = SplitPanelSplitter(self)
        # add splitter handling
        self._splitter.addMouseListener(self)
        # add mouse event handling
        self.addMouseListener(self)
        # add the parts
        AbsolutePanel.add(self, self._container1, 0, 0)
        AbsolutePanel.add(self, self._splitter, 0, 0)
        AbsolutePanel.add(self, self._container2, 0, 0)

        # set the layout
        if vertical:    # vertical split panel
            self._splitter.setStyleName("vsplitter")
            self._splitter.setWidth("100%")
            self._container1.setWidth("100%")
            self._container2.setWidth("100%")
            # set drag cursor
            DOM.setStyleAttribute(self._splitter.getElement(),
                                    "cursor", "n-resize")
        else:   # horizontal split panel
            self._splitter.setStyleName("hsplitter")
            self._splitter.setHeight("100%")
            self._container1.setHeight("100%")
            self._container2.setHeight("100%")
            # set drag cursor
            DOM.setStyleAttribute(self._splitter.getElement(),
                                    "cursor", "e-resize")

    def onAttach(self):
        AbsolutePanel.onAttach(self)
        self.setSplitPosition()

    # fixup the container 2 size and position
    def _finalizePositions(self, pos=None):
        finalized = False
        if self._vertical:
            if pos is None:
                pos = self._container1.getOffsetHeight()
            space = self.getOffsetHeight()
            sz = self._splitter.getOffsetHeight()
            if space > 0 and sz > 0 and pos > 0:
                # limit pos
                if pos > space - sz:
                    pos = space - sz
                    self._container1.setHeight(pos)
                self.setWidgetPosition(self._splitter, 0, pos)
                self.setWidgetPosition(self._container2, 0, pos + sz)
                self._container2.setHeight(space - (pos + sz))
                finalized = True
        else:
            if pos is None:
                pos = self._container1.getOffsetWidth()
            space = self.getOffsetWidth()
            sz = self._splitter.getOffsetWidth()
            if space > 0 and sz > 0 and pos > 0:
                # limit pos
                if pos > space - sz:
                    pos = space - sz
                    self._container1.setWidth(pos)
                self.setWidgetPosition(self._splitter, pos, 0)
                self.setWidgetPosition(self._container2, pos + sz, 0)
                self._container2.setWidth(space - (pos + sz))
                finalized = True
        if finalized:
            self.dispatchResizeEvent(self, pos)
        return finalized

    # end a drag operation
    def _stopDragging(self):
        if self._drag_start is not None:
            # we are no longer dragging
            self._drag_start = None
            # deactivate the transparent overlay
            GlassWidget.hide()
            # don't let a mouse-up become a click event
            DOM.eventCancelBubble(DOM.eventGetCurrentEvent(), True)

    def _isDragging(self):
        return self._drag_start is not None

    # start a drag operation (called by splitter)
    def startSplitterDrag(self, x, y):
        if self._drag_start is None:
            # remember where on the slider we are dragging
            if self._vertical:
                self._drag_start = y
            else:
                self._drag_start = x
            # activate the transparent overlay to keep mouse events flowing to
            # the splitter (and to us) even if the mouse leaves the splitter
            GlassWidget.show(self)

    # add handlers for mouse events to support dragging the slider
    # NOTE: the x,y positioni s relative to the splitter
    def onMouseMove(self, sender, x, y):
        # if dragging, then use current mouse position
        # to reset splitter position
        if not self._isDragging():
            return
        # remove the offset into the splitter
        # where we started dragging
        if self._vertical:
            self._pos = y - self._drag_start
        else:
            self._pos = x - self._drag_start
        # apply limit
        if self._pos < 1:
            self._pos = 1
        # apply new position
        self.setSplitPosition()

    def onMouseUp(self, sender, x, y):
        ev = DOM.eventGetCurrentEvent()
        # ignore right-button ups
        if DOM.eventGetButton(ev) != Event.BUTTON_LEFT:
            return
        DOM.eventPreventDefault(ev)
        # if we are dragging
        if self._isDragging():
            # stop dragging on mouse up
            self._stopDragging()

    # called when we start dragging
    def onMouseGlassEnter(self, sender):
        pass

    # called when we drag out of the window
    # (NOT called when we just stop dragging)
    def onMouseGlassLeave(self, sender):
        # we left the window, so stop dragging
        self._stopDragging()

    #
    # Start the inherited 'public' API
    #

    # specify splitter position in pix OR percentage
    # if pixels (number) specified, we can make change now
    # otherwise, we have to set the offset as specified, then
    # 'fixup' the remaining space after rendering
    def setSplitPosition(self, pos=None):
        if pos is not None:
            # remember last pos set
            self._pos = pos
        else:
            pos = self._pos
        if pos < 1:
            pos = 1
            self._pos = pos
        # change adjustable dimension
        if self._vertical:
            self._container1.setHeight(pos)
        else:
            self._container1.setWidth(pos)
        # if pix are given, we can try to finalize the positions
        finalized = False
        if isinstance(pos, int):
            finalized = self._finalizePositions(pos)
        # if needed, queue callback to finalize
        if not finalized:
            queue_Call(self._finalizePositions)

    def getWidget(self, index):
        if index == 0:
            return self._container1.getWidget()
        return self._container2.getWidget()

    def setWidget(self, index, widget):
        if index == 0:
            return self._container1.setWidget(widget)
        return self._container2.setWidget(widget)

    # Adds a widget to a pane
    def add(self, widget):
        if self.getWidget(0) == None:
            self.setWidget(0, widget)
        elif self.getWidget(1) == None:
            self.setWidget(1, widget)
        else:
            console.error("SimplePanel can only contain one child widget")

    # Removes a child widget.
    def remove(self, widget):
        if self.getWidget(0) == widget:
            self._container1.remove(widget)
        elif self.getWidget(1) == widget:
            self._container2.remove(widget)
        else:
            AbsolutePanel.remove(self, widget)

    # Gets the content element for the given index.
    def getElement(self, index=None):
        if index is None:
            return AbsolutePanel.getElement(self)
        return self.getWidget(index).getElement()

    # Gets the widget in the pane at end of the line direction for the layout
    def getEndOfLineWidget(self):
        return self.getWidget(1)

    # Gets the element that is acting as the splitter.
    def getSplitElement(self):
        return self._splitter.getElement()

    # Gets the widget in the pane at the start of line direction for the layout
    def getStartOfLineWidget(self):
        return self.getWidget(0)

    # Indicates whether the split panel is being resized.
    def isResizing(self):
        return False

    # Sets the widget in the pane at the end of line direction for the layout
    def setEndOfLineWidget(self, widget):
        self.setWidget(1, widget)

    def setStartOfLineWidget(self, widget):
        self.setWidget(0, widget)
Пример #50
0
class SplitPanel(AbsolutePanel, MouseHandler, EventGenerator):
    """ Provides the SplitPanel baseclass functionality
        A SplitPanel is an AbsolutePanel containing an HTMLTable
        with three cells. The first cell holds the first ScrollPanel,
        while the center cell holds a Splitter, and the last cell
        holds the other ScrollPanel.
    """

    def __init__(self, vertical=False, **kwargs):
        # set defaults
        if not 'StyleName' in kwargs:
            if vertical:    # vertical split panel
                kwargs['StyleName'] = "gwt-VerticalSplitPanel"
            else:
                kwargs['StyleName'] = "gwt-HorizontalSplitPanel"
        # splitter drag state vars
        self._drag_start = None
        self._pos = "50%"
        # orientation
        self._vertical = vertical
        # now init the bases
        AbsolutePanel.__init__(self, **kwargs)
        MouseHandler.__init__(self)
        # add our event support?
        self.addListenedEvent("Resize")
        # create the top/left widget container
        self._container1 = ScrollPanel()
        # create the bottom/right widget container
        self._container2 = ScrollPanel()
        # create the splitter
        self._splitter = SplitPanelSplitter(self)
        # add splitter handling
        self._splitter.addMouseListener(self)
        # add mouse event handling
        self.addMouseListener(self)
        # add the parts
        AbsolutePanel.add(self, self._container1, 0, 0)
        AbsolutePanel.add(self, self._splitter, 0, 0)
        AbsolutePanel.add(self, self._container2, 0, 0)

        # set the layout
        if vertical:    # vertical split panel
            self._splitter.setStyleName("vsplitter")
            self._splitter.setWidth("100%")
            self._container1.setWidth("100%")
            self._container2.setWidth("100%")
            # set drag cursor
            DOM.setStyleAttribute(self._splitter.getElement(),
                                    "cursor", "n-resize")
        else:   # horizontal split panel
            self._splitter.setStyleName("hsplitter")
            self._splitter.setHeight("100%")
            self._container1.setHeight("100%")
            self._container2.setHeight("100%")
            # set drag cursor
            DOM.setStyleAttribute(self._splitter.getElement(),
                                    "cursor", "e-resize")

    def onAttach(self):
        AbsolutePanel.onAttach(self)
        self.setSplitPosition()

    # fixup the container 2 size and position
    def _finalizePositions(self, pos=None):
        finalized = False
        if self._vertical:
            if pos is None:
                pos = self._container1.getOffsetHeight()
            space = self.getOffsetHeight()
            sz = self._splitter.getOffsetHeight()
            if space > 0 and sz > 0 and pos > 0:
                # limit pos
                if pos > space - sz:
                    pos = space - sz
                    self._container1.setHeight(pos)
                self.setWidgetPosition(self._splitter, 0, pos)
                self.setWidgetPosition(self._container2, 0, pos + sz)
                self._container2.setHeight(space - (pos + sz))
                finalized = True
        else:
            if pos is None:
                pos = self._container1.getOffsetWidth()
            space = self.getOffsetWidth()
            sz = self._splitter.getOffsetWidth()
            if space > 0 and sz > 0 and pos > 0:
                # limit pos
                if pos > space - sz:
                    pos = space - sz
                    self._container1.setWidth(pos)
                self.setWidgetPosition(self._splitter, pos, 0)
                self.setWidgetPosition(self._container2, pos + sz, 0)
                self._container2.setWidth(space - (pos + sz))
                finalized = True
        if finalized:
            self.dispatchResizeEvent(self, pos)
        return finalized

    # end a drag operation
    def _stopDragging(self):
        if self._drag_start is not None:
            # we are no longer dragging
            self._drag_start = None
            # deactivate the transparent overlay
            GlassWidget.hide()
            # don't let a mouse-up become a click event
            DOM.eventCancelBubble(DOM.eventGetCurrentEvent(), True)

    def _isDragging(self):
        return self._drag_start is not None

    # start a drag operation (called by splitter)
    def startSplitterDrag(self, x, y):
        if self._drag_start is None:
            # remember where on the slider we are dragging
            if self._vertical:
                self._drag_start = y
            else:
                self._drag_start = x
            # activate the transparent overlay to keep mouse events flowing to
            # the splitter (and to us) even if the mouse leaves the splitter
            GlassWidget.show(self)

    # add handlers for mouse events to support dragging the slider
    # NOTE: the x,y positioni s relative to the splitter
    def onMouseMove(self, sender, x, y):
        # if dragging, then use current mouse position
        # to reset splitter position
        if not self._isDragging():
            return
        # remove the offset into the splitter
        # where we started dragging
        if self._vertical:
            self._pos = y - self._drag_start
        else:
            self._pos = x - self._drag_start
        # apply limit
        if self._pos < 1:
            self._pos = 1
        # apply new position
        self.setSplitPosition()

    def onMouseUp(self, sender, x, y):
        ev = DOM.eventGetCurrentEvent()
        # ignore right-button ups
        if DOM.eventGetButton(ev) != Event.BUTTON_LEFT:
            return
        DOM.eventPreventDefault(ev)
        # if we are dragging
        if self._isDragging():
            # stop dragging on mouse up
            self._stopDragging()

    # called when we start dragging
    def onMouseGlassEnter(self, sender):
        pass

    # called when we drag out of the window
    # (NOT called when we just stop dragging)
    def onMouseGlassLeave(self, sender):
        # we left the window, so stop dragging
        self._stopDragging()

    #
    # Start the inherited 'public' API
    #

    # specify splitter position in pix OR percentage
    # if pixels (number) specified, we can make change now
    # otherwise, we have to set the offset as specified, then
    # 'fixup' the remaining space after rendering
    def setSplitPosition(self, pos=None):
        if pos is not None:
            # remember last pos set
            self._pos = pos
        else:
            pos = self._pos
        if pos < 1:
            pos = 1
            self._pos = pos
        # change adjustable dimension
        if self._vertical:
            self._container1.setHeight(pos)
        else:
            self._container1.setWidth(pos)
        # if pix are given, we can try to finalize the positions
        finalized = False
        if isinstance(pos, int):
            finalized = self._finalizePositions(pos)
        # if needed, queue callback to finalize
        if not finalized:
            DeferredCommand.add(self._finalizePositions)

    def getWidget(self, index):
        if index == 0:
            return self._container1.getWidget()
        return self._container2.getWidget()

    def setWidget(self, index, widget):
        if index == 0:
            return self._container1.setWidget(widget)
        return self._container2.setWidget(widget)

    # Adds a widget to a pane
    def add(self, widget):
        if self.getWidget(0) == None:
            self.setWidget(0, widget)
        elif self.getWidget(1) == None:
            self.setWidget(1, widget)
        else:
            console.error("SimplePanel can only contain one child widget")

    # Removes a child widget.
    def remove(self, widget):
        if self.getWidget(0) == widget:
            self._container1.remove(widget)
        elif self.getWidget(1) == widget:
            self._container2.remove(widget)
        else:
            AbsolutePanel.remove(self, widget)

    # Gets the content element for the given index.
    def getElement(self, index=None):
        if index is None:
            return AbsolutePanel.getElement(self)
        return self.getWidget(index).getElement()

    # Gets the widget in the pane at end of the line direction for the layout
    def getEndOfLineWidget(self):
        return self.getWidget(1)

    # Gets the element that is acting as the splitter.
    def getSplitElement(self):
        return self._splitter.getElement()

    # Gets the widget in the pane at the start of line direction for the layout
    def getStartOfLineWidget(self):
        return self.getWidget(0)

    # Indicates whether the split panel is being resized.
    def isResizing(self):
        return False

    # Sets the widget in the pane at the end of line direction for the layout
    def setEndOfLineWidget(self, widget):
        self.setWidget(1, widget)

    def setStartOfLineWidget(self, widget):
        self.setWidget(0, widget)
Пример #51
0
class InfoDirectory:
    def onModuleLoad(self):

        self.remote = InfoServicePython()

        self.tree_width = 200

        self.tp = HorizontalPanel()
        self.tp.setWidth("%dpx" % (self.tree_width))
        self.treeview = Trees()
        self.treeview.fTree.addTreeListener(self)
        self.sp = ScrollPanel()
        self.tp.add(self.treeview)
        self.sp.add(self.tp)
        self.sp.setHeight("100%")

        self.horzpanel1 = HorizontalPanel()
        self.horzpanel1.setSize("100%", "100%")
        self.horzpanel1.setBorderWidth(1)
        self.horzpanel1.setSpacing("10px")

        self.rp = RightPanel()
        self.rps = ScrollPanel()
        self.rps.add(self.rp)
        self.rps.setWidth("100%")
        self.rp.setWidth("100%")

        self.cp1 = CollapserPanel(self)
        self.cp1.setWidget(self.sp)
        self.cp1.setHTML("&nbsp;")

        self.midpanel = MidPanel(self)
        self.cp2 = CollapserPanel(self)
        self.cp2.setWidget(self.midpanel)
        self.cp2.setHTML("&nbsp;")

        self.horzpanel1.add(self.cp1)
        self.horzpanel1.add(self.cp2)
        self.horzpanel1.add(self.rps)

        self.cp1.setInitialWidth("%dpx" % self.tree_width)
        self.cp2.setInitialWidth("200px")

        RootPanel().add(self.horzpanel1)

        width = Window.getClientWidth()
        height = Window.getClientHeight()

        self.onWindowResized(width, height)
        Window.addWindowResizeListener(self)

    def setCollapserWidth(self, widget, width):
        self.horzpanel1.setCellWidth(widget, width)

    def onWindowResized(self, width, height):
        #self.hp.setWidth("%dpx" % (width - self.tree_width))
        #self.hp.setHeight("%dpx" % (height - 20))
        self.cp1.setHeight("%dpx" % (height - 30))
        self.cp2.setHeight("%dpx" % (height - 30))
        self.rps.setHeight("%dpx" % (height - 30))
        self.horzpanel1.setHeight("%dpx" % (height - 20))

    def onTreeItemStateChanged(self, item):
        if item.isSelected():
            self.onTreeItemSelected(item)

    def onTreeItemSelected(self, item):

        obj = item.getUserObject()
        if len(obj.children) != 0:
            self.clear_mid_panel()
            return

        self.remote.get_midpanel_data(obj.root + "/" + obj.text, self)
        self.cp2.setHTML(obj.text)
        self.clear_right_panel()

    def clear_right_panel(self):
        self.horzpanel1.remove(2)
        self.horzpanel1.insert(HTML(""), 2)
        self.rp.setTitle("&nbsp;")

    def clear_mid_panel(self):
        self.clear_right_panel()
        #self.horzpanel2.setLeftWidget(HTML(""))

    def set_mid_panel(self, response):

        self.midpanel.set_items(response)

        self.cp2.setWidget(self.midpanel)

    def select_right_grid(self, location, name):
        self.horzpanel1.remove(2)
        self.horzpanel1.insert(self.rps, 2)
        self.rp.setTitle(name)
        self.remote.get_rightpanel_datanames(location, self)

    def get_rightpanel_datasets(self, datasets):

        self.rp.clear_items()
        self.rp.setup_panels(datasets)

        for i in range(len(datasets)):
            item = datasets[i]
            fname = item[0]
            self.remote.get_rightpanel_data(fname, fname, i, self)

    def fill_right_grid(self, data):
        index = data.get('index')
        name = data.get('name')
        if data.has_key('items'):
            self.rp.add_items(data.get('items'), name, index)
        elif data.has_key('html'):
            self.rp.add_html(data.get('html'), name, index)

    def onRemoteResponse(self, response, request_info):
        method = request_info.method
        if method == "get_midpanel_data":
            self.set_mid_panel(response)
        elif method == "get_rightpanel_datanames":
            self.get_rightpanel_datasets(response)
        elif method == "get_rightpanel_data":
            self.fill_right_grid(response)

    def onRemoteError(self, code, message, request_info):
        RootPanel().add(HTML("Server Error or Invalid Response: ERROR " +
                             code))
        RootPanel().add(HTML(message))
Пример #52
0
class DataDictTree(Sink):
    pathdict = {}
    reduceFiles = None
    fTree = None
    
    def __init__(self, parent = None):
        Sink.__init__(self, parent)
        self.reduceFiles = []
        if True:
            HTTPRequest().asyncGet("datadir.xml", 
                                    DirDictLoader(self),
                                )
        dock = DockPanel(HorizontalAlignment=HasAlignment.ALIGN_LEFT, 
                            Spacing=10,
                             Size=("100%","100%"))
        self.dock = dock
        self.fProto = []

        self.fTree = Tree()
        self.treePanel = ScrollPanel()
        self.treePanel.setSize("100%", 
                                str(
                                 int(
                                  Window.getClientHeight()*.75
                                 )
                                )+"px")
        Window.addWindowResizeListener(self)
        
        self.treePanel.add(self.fTree)
        dock.add(self.treePanel, DockPanel.WEST)
        
        
        #self.treePanel.setBorderWidth(1)
        #self.treePanel.setWidth("100%")
        
        prPanel = self.createRightPanel()
        dock.add(prPanel,DockPanel.EAST)
        
        dock.setCellWidth(self.treePanel, "50%")
        dock.setCellWidth(prPanel, "50%")
        for i in range(len(self.fProto)):
            self.createItem(self.fProto[i])
            self.fTree.addItem(self.fProto[i].item)

        self.fTree.addTreeListener(self)
        self.initWidget(self.dock)
        
        if False: #self.parent.filexml != None:
            DirDictLoader(self).onCompletion(self.parent.filexml)

    def onWindowResized(self, width, height):
        self.treePanel.setSize("100%", 
                                str(
                                 int(
                                  height *.75
                                 )
                                )+"px")
    def onRecipeSelected(self, event):
        self.updateReduceCL()
    
    def onClearReduceFiles(self, event):
        self.reduceFiles.clear() 
        self.adInfo.setHTML("file info...") 
        self.updateReduceCL()
        
    def updateReduceCL(self):
        recipe = self.recipeList.getItemText(self.recipeList.getSelectedIndex())
        
        if recipe=="None":
            rstr = ""
        else:
            rstr = "-r "+recipe

        rfiles = []            
        for i in range(0, self.reduceFiles.getItemCount()):
            fname = self.reduceFiles.getItemText(i)
            rfiles.append(fname)
        filesstr = " ".join(rfiles)
        
                
        self.prepareReduce.setHTML('<b>reduce</b> %(recipe)s %(files)s' % 
                                        { "recipe":rstr, 
                                          "files":filesstr})

    def onTreeItemSelected(self, item):
        pathdict = self.pathdict
        
        tfile = item.getText()
        #check if already in
        if tfile in pathdict:
            ftype = pathdict[tfile]["filetype"]
            if ftype != "fileEntry":
                item.setState(True)
                return
        else:
            return
        for i in range(0, self.reduceFiles.getItemCount()):
            fname = self.reduceFiles.getItemText(i)
            if fname == tfile:
                return
        self.reduceFiles.addItem(tfile)
        self.updateReduceCL()
        
        filename = tfile
        if filename in pathdict:
            if pathdict[filename]["filetype"] == "fileEntry":
                HTTPRequest().asyncGet("adinfo?filename=%s" % self.pathdict[item.getText()]["path"], 
                               ADInfoLoader(self),
                              )
            else:
                self.adInfo.setHTML("""
                    <b style="font-size:200%%">%s</b>""" % pathdict[filename]["filetype"])
        else:
            self.adInfo.setHTML("unknown node")
        return
        
        # self.prepareReduce.setHTML('<a href="runreduce?p=-r&p=callen&p=%(fname)s">reduce -r callen %(fname)s</a>' %
        #                            {"fname":item.getText()})
        pass
    
    def onTreeItemStateChanged(self, item):
        child = item.getChild(0)
        if hasattr(child, "isPendingItem"):
            item.removeItem(child)
        
            proto = item.getUserObject()
            for i in range(len(proto.children)):
                self.createItem(proto.children[i])
                index = self.getSortIndex(item, proto.children[i].text)
                # demonstrate insertItem.  addItem is easy.
                item.insertItem(proto.children[i].item, index)
                item.setState(True)

    def getSortIndex(self, parent, text):
        nodes = parent.getChildCount()
        node = 0
        text = text.lower()

        while node < nodes:
            item = parent.getChild(node)
            if cmp(text, item.getText().lower()) < 0:
                break;
            else:
                node += 1
        
        return node
    
    def createProto(self, node, parent=None):
            #if node.nodeType != node.ELEMENT_NODE:
            #    return
            pathdict = self.pathdict
            if not node.hasChildNodes():
                if node.nodeType != 1:
                    return None
                nname = node.getAttribute("name")
                newproto = None

                newproto = Proto(str(node.getAttribute("name")))
                if node.tagName == "fileEntry":
                    pathdict.update({node.getAttribute("name"):
                                        { "path":node.getAttribute("fullpath"),
                                          "filetype": node.tagName }})
                elif node.tagName == "dirEntry":
                    pathdict.update({node.getAttribute("name"):
                                        { "path":node.getAttribute("name"),
                                          "filetype": node.tagName}})
                else:
                    pathdict.update({node.getAttribute("name"):
                                        { "path": "NOPATH",
                                          "filetype": node.tagName}})
                self.createItem(newproto)
                return newproto
            else:
                cprotos = []
                for i in range(0, node.childNodes.length):
                    childnode = node.childNodes.item(i)
                    if hasattr(childnode,"getAttribute") and childnode.getAttribute("name") == "files":
                        for j in range(0, childnode.childNodes.length):
                            childnodej = childnode.childNodes.item(j)
                            ncproto = self.createProto(childnodej)
                            if ncproto != None:
                                ncitem  = self.createItem(ncproto)
                                cprotos.append(ncproto)
                    else:
                        ncproto = self.createProto(childnode)
    
                    if ncproto != None:
                        ncitem  = self.createItem(ncproto)
                        cprotos.append(ncproto)
                  
                        
                        
                if len(cprotos)>0:
                    newproto = Proto(str(node.getAttribute("name")),cprotos)
                else:
                    newproto = Proto(str(node.getAttribute("name")))
                if node.tagName == "fileEntry":
                    pathdict.update({node.getAttribute("name"):
                                        { "path":node.getAttribute("fullpath"),
                                          "filetype": node.tagName }})
                elif node.tagName == "dirEntry":
                    pathdict.update({node.getAttribute("name"):
                                        { "path":node.getAttribute("name"),
                                          "filetype": node.tagName}})
                else:
                    pathdict.update({node.getAttribute("name"):
                                        { "path": "NOPATH",
                                          "filetype": node.tagName}})

                self.createItem(newproto)
            return newproto
    
    def fromXML(self,text):
        doc = create_xml_doc(text)
        #node = doc.firstChild
        
        #node = doc.getElementById("topDirectory")
        nodes = doc.getElementsByTagName("dirEntry")
        node = nodes.item(0)
        s = repr(node)
        
        newproto = self.createProto(node)    
        plist = [newproto]
        #plist = [Proto(node.tagName)]

        for i in range(len(plist)):
            num = str(len(plist))
            # self.createItem(plist[i])
            self.fTree.addItem(plist[i].item)
            plist[i].item.setState(True)

        
    def onShow(self):
        if False:
            for item in self.fTree.treeItemIterator():
                key = repr(item.tree)
                if key != "null":
                    item.setState(True)
                else:
                    JS("alert(item.getText())")

        pass

    def createItem(self, proto):
        proto.item = TreeItem(proto.text)
        proto.item.setUserObject(proto)
        if len(proto.children) > 0:
            proto.item.addItem(PendingItem())
Пример #53
0
class Slideshow:

    def onHistoryChanged(self, token):
        info = self.sink_list.find(token)
        if info:
            self.show(info, False)
        else:
            self.showInfo()

    def onModuleLoad(self):
        self.curInfo=''
        self.curSink=None
        self.description=HTML()
        self.sink_list=SinkList()
        self.panel=DockPanel()
        self.b=Button("load", self)
        
        self.sinkContainer = DockPanel()
        self.sinkContainer.setStyleName("ks-Sink")

        height = Window.getClientHeight()

        self.sp = ScrollPanel(self.sinkContainer)
        self.sp.setWidth("100%")
        self.sp.setHeight("%dpx" % (height-110))

        vp=VerticalPanel()
        vp.setWidth("100%")
        vp.setHeight("100%")
        vp.add(self.description)
        vp.add(self.sp)

        self.description.setStyleName("ks-Intro")

        self.panel.add(self.sink_list, DockPanel.WEST)
        self.panel.add(vp, DockPanel.CENTER)

        self.panel.setCellVerticalAlignment(self.sink_list, HasAlignment.ALIGN_TOP)
        self.panel.setCellWidth(vp, "100%")
        self.panel.setCellHeight(vp, "100%")

        Window.addWindowResizeListener(self)

        History.addHistoryListener(self)
        RootPanel().add(self.panel)
        #RootPanel().add(self.b)

        self.loadSinks()

    def onClick(self, sender):
        self.loadSinks()

    def onTimer(self, tid):
        self.loadSinks()

    def onWindowResized(self, width, height):
        #self.sink_list.resize(width, height)
        self.sp.setHeight("%dpx" % (height-110))

    def show(self, info, affectHistory):
        if info == self.curInfo: return
        self.curInfo = info

        #Logger.write("showing " + info.getName())
        if self.curSink <> None:
            self.curSink.onHide()
            #Logger.write("removing " + self.curSink)
            self.sinkContainer.remove(self.curSink)

        self.curSink = info.getInstance()
        self.sink_list.setSinkSelection(info.getName())
        self.description.setHTML(info.getDescription())

        if (affectHistory):
            History.newItem(info.getName())

        self.sinkContainer.add(self.curSink, DockPanel.CENTER)
        self.sinkContainer.setCellWidth(self.curSink, "100%")
        self.sinkContainer.setCellHeight(self.curSink, "100%")
        self.sinkContainer.setCellVerticalAlignment(self.curSink, HasAlignment.ALIGN_TOP)
        self.curSink.onShow()
        
    def loadSinks(self):
        HTTPRequest().asyncGet("slides.txt", SlideListLoader(self))


    def setSlides(self, slides):
        for l in slides:
            name = l[0]
            desc = l[1]
            self.sink_list.add(Slide.init(name, desc))

        #Show the initial screen.
        initToken = History.getToken()
        if len(initToken):
            self.onHistoryChanged(initToken)
        else:
            self.showInfo()


    def showInfo(self):
        self.show(self.sink_list.sinks[0], False)
Пример #54
0
    def loadChapters(self):

        self.curInfo = ''
        self.curSink = None
        self.description = HTML()
        self.sink_list = SinkList()
        self.panel = DockPanel()

        self.loadSinks()
        self.sinkContainer = DockPanel()
        self.sinkContainer.setStyleName("ks-Sink")

        #self.nf = NamedFrame("section")
        #self.nf.setWidth("100%")
        #self.nf.setHeight("10000")

        self.sp = ScrollPanel(self.sinkContainer)
        #self.sp = VerticalSplitPanel()
        self.sp.setWidth("100%")
        self.sp.setHeight("100%")

        #self.sp.setTopWidget(self.sinkContainer)
        #self.sp.setBottomWidget(self.nf)
        #self.sp.setSplitPosition(10000) # deliberately high - max out.

        vp = VerticalPanel()
        vp.setWidth("99%")
        vp.setHeight("100%")
        vp.add(self.description)
        vp.add(self.sp)

        authors = [
            ("2008, 2009", "Kenneth Casson Leighton", "*****@*****.**")
        ]
        for years, name, email in authors:
            authors_html = \
            '&copy; %s <a href="mailto:%s">%s</a><br />' %\
            (years, email, name)
        authors_panel = HTML()
        authors_panel.setStyleName("ks-Authors")
        authors_panel.setHTML(authors_html[:-6])

        left_panel = DockPanel(Height="100%")
        left_panel.add(self.sink_list, DockPanel.NORTH)
        left_panel.add(authors_panel, DockPanel.SOUTH)

        self.description.setStyleName("ks-Intro")

        self.panel.add(left_panel, DockPanel.WEST)
        self.panel.add(vp, DockPanel.CENTER)

        self.panel.setCellVerticalAlignment(self.sink_list,
                                            HasAlignment.ALIGN_TOP)
        self.panel.setCellWidth(vp, "100%")
        self.panel.setCellHeight(vp, "100%")

        Window.addWindowResizeListener(self)

        History.addHistoryListener(self)
        RootPanel().add(self.panel)

        self.onWindowResized(Window.getClientWidth(), Window.getClientHeight())