Beispiel #1
0
class Mailboxes(Composite):
    def __init__(self):
        Composite.__init__(self)

        self.tree = Tree()
        root = TreeItem(self.imageItemHTML("home.gif", "*****@*****.**"))
        self.tree.addItem(root)
        inboxItem = self.addImageItem(root, "Inbox")
        self.addImageItem(root, "Drafts")
        self.addImageItem(root, "Templates")
        self.addImageItem(root, "Sent")
        self.addImageItem(root, "Trash")

        root.setState(True)
        self.initWidget(self.tree)

    def addImageItem(self, root, title):
        item = TreeItem(self.imageItemHTML(title + ".gif", title))
        root.addItem(item)
        return item

    def imageItemHTML(self, imageUrl, title):
        value = "<span><img style='margin-right:4px' src='"
        value += "./"
        value += imageUrl.lower() + "'>" + title + "</span>"
        return value
Beispiel #2
0
class Mailboxes(Composite):
    def __init__(self):
        Composite.__init__(self)

        self.tree = Tree()
        root = TreeItem(self.imageItemHTML("home.gif", "*****@*****.**"))
        self.tree.addItem(root)
        inboxItem = self.addImageItem(root, "Inbox")
        self.addImageItem(root, "Drafts")
        self.addImageItem(root, "Templates")
        self.addImageItem(root, "Sent")
        self.addImageItem(root, "Trash")

        root.setState(True)
        self.initWidget(self.tree)

    def addImageItem(self, root, title):
        item = TreeItem(self.imageItemHTML(title + ".gif", title))
        root.addItem(item)
        return item

    def imageItemHTML(self, imageUrl, title):
        value  = "<span><img style='margin-right:4px' src='"
        value += "./"
        value += imageUrl.lower() + "'>" + title + "</span>"
        return value
Beispiel #3
0
    def __init__(self):

        Sink.__init__(self)

        self.formula = AX_REG
        self.image1 = Image(latex_to_url(self.formula.fill_with_placeholders().to_latex()))
        self.cnf=self.formula.simplify().to_cnf()
        self.image2 = Image(latex_to_url(self.cnf.to_latex()))
        self.vars=self.cnf.get_vars()

        self.vars_with_proto = [{"var": var, "proto": Proto(var.name)} for var in self.vars]
        self.fProto = [
            Proto("Beethoven", [x["proto"] for x in self.vars_with_proto])
        ]

        self.fTree = Tree()

        for i in range(len(self.fProto)):
            self.createItem(self.fProto[i])
            self.fTree.addItem(self.fProto[i].item)

        self.fTree.addTreeListener(self)

        self.panel = HorizontalPanel(VerticalAlignment=HasAlignment.ALIGN_TOP)
        self.panel.setSpacing(40)
        self.panel.add(self.fTree)

        self.panel.add(self.image1)
        self.panel.add(self.image2)

        self.initWidget(self.panel)
Beispiel #4
0
class LayersPanel(VerticalPanel):
    def __init__(self, *args, **kwargs):
        super(LayersPanel, self).__init__(*args, **kwargs)
        navbar = NavigationBar()
        navbar.add(HTML('<div class="brand">Layers</div>'))

        b = Button("Edit", StyleName="btn")
        b.addStyleName("btn-inverse")
        b.addStyleName("pull-right")
        navbar.add(b)

        self.add(navbar)

        self._tree = Tree()
        self.add(self._tree)

    def setLayersCollection(self, layers):
        layers.addLoadedListener(self._update_layers)
        self._update_layers(layers)

    def _update_layers(self, layers):
        self._tree.clear()

        if layers.items is None:
            # not yet loaded
            return

        for l in layers.items:
            item = TreeItem(Widget=LayerLabel(l))
            self._tree.addItem(item)
Beispiel #5
0
 def onClick(self, sender):
     global sent,recv
     self.status.setText('Button pressed')
     if sender == self.buttonupdate:
         self.commobj = AMS_Comm()
         self.status.setText('Updating data: Press Display list button to refesh')
     if sender == self.button:
         if sent > recv:
            self.status.setText('Press button again: sent '+str(sent)+' recv '+str(recv))
         if self.commobj.commname == 'No AMS publisher running':
            self.status.setText(self.commobj.commname)
         else:
            self.status.setText('Memories for AMS Comm: '+self.commobj.commname)
            result = self.commobj.get_memory_list()
            if self.tree: self.panel.remove(self.tree)
            self.tree = Tree()
            for i in result:
               subtree = TreeItem(i)
               memory = self.commobj.memory_attach(i)
               fields = memory.get_field_list()
               for j in fields:
                  field = memory.get_field_info(j)
                  subtree.addItem(j+' = '+str(field[4]))
               self.tree.addItem(subtree)
               self.panel.add(self.tree)
    def __init__(self):
        """ Constructs a new EditPanel.
        """
        self.TEXT_WAITING = "Waiting for response..."
        self.TEXT_ERROR = "Server Error"

        #        self.remote_py = RegionNamesServicePython()

        self.panel = VerticalPanel()

        top_panel = HorizontalPanel()
        top_panel.setSpacing(8)
        self.panel.add(top_panel)

        refresh = Button("Refresh", self)
        top_panel.add(refresh)

        self.status = Label()
        top_panel.add(self.status)

        edit_panel = HorizontalPanel()
        self.panel.add(edit_panel)

        self.tree = Tree()
        self.tree.addTreeListener(self)
        edit_panel.add(self.tree)

        upload_item = TreeItem("Upload")
        self.tree.add(upload_item)
        map_item = TreeItem("Map")
        self.tree.add(map_item)
Beispiel #7
0
    def __init__(self):
        Composite.__init__(self)

        self.fProto = []
        self.fTree = Tree()
        
        self.fTree.addTreeListener(self)
        self.initWidget(self.fTree)
        self.remote = InfoServicePython()
        self.remote.index("", 1, self)
Beispiel #8
0
def main():
    root = RootPanel()
    tree = Tree()
    cb1 = CheckBox('test 1')
    cb1.addClickListener(onCb1)
    root.add(cb1)
    cb2 = CheckBox('test 2')
    cb2.addClickListener(onCb2)
    item = TreeItem(cb2)
    tree.addItem(item)
    root.add(tree)
Beispiel #9
0
def main():
    root = RootPanel()
    tree = Tree()
    cb1 = CheckBox('test 1')
    cb1.addClickListener(onCb1)
    root.add(cb1)
    cb2 = CheckBox('test 2')
    cb2.addClickListener(onCb2)
    item = TreeItem(cb2)
    tree.addItem(item)
    root.add(tree)
Beispiel #10
0
    def __init__(self):
        Composite.__init__(self)

        self.tree = Tree()
        root = TreeItem(self.imageItemHTML("home.gif", "*****@*****.**"))
        self.tree.addItem(root)
        inboxItem = self.addImageItem(root, "Inbox")
        self.addImageItem(root, "Drafts")
        self.addImageItem(root, "Templates")
        self.addImageItem(root, "Sent")
        self.addImageItem(root, "Trash")

        root.setState(True)
        self.initWidget(self.tree)
    def __init__(self):
        """ Constructs a new EditPanel.
        """
        self.TEXT_WAITING = "Waiting for response..."
        self.TEXT_ERROR = "Server Error"

#        self.remote_py = RegionNamesServicePython()

        self.panel = VerticalPanel()

        top_panel = HorizontalPanel()
        top_panel.setSpacing(8)
        self.panel.add(top_panel)

        refresh = Button("Refresh", self)
        top_panel.add(refresh)

        self.status = Label()
        top_panel.add(self.status)

        edit_panel = HorizontalPanel()
        self.panel.add(edit_panel)

        self.tree = Tree()
        self.tree.addTreeListener(self)
        edit_panel.add(self.tree)

        upload_item = TreeItem("Upload")
        self.tree.add(upload_item)
        map_item = TreeItem("Map")
        self.tree.add(map_item)
Beispiel #12
0
class EditPanel:
    """ Defines a panel for editing data store objects.
    """
    def __init__(self):
        """ Constructs a new EditPanel.
        """
        self.TEXT_WAITING = "Waiting for response..."
        self.TEXT_ERROR = "Server Error"

        #        self.remote_py = RegionNamesServicePython()

        self.panel = VerticalPanel()

        top_panel = HorizontalPanel()
        top_panel.setSpacing(8)
        self.panel.add(top_panel)

        refresh = Button("Refresh", self)
        top_panel.add(refresh)

        self.status = Label()
        top_panel.add(self.status)

        edit_panel = HorizontalPanel()
        self.panel.add(edit_panel)

        self.tree = Tree()
        self.tree.addTreeListener(self)
        edit_panel.add(self.tree)

        upload_item = TreeItem("Upload")
        self.tree.add(upload_item)
        map_item = TreeItem("Map")
        self.tree.add(map_item)

    def onTreeItemSelected(self, item):
        pass

    def onTreeItemStateChanged(self, item):
        child = item.getChild(0)

    def onClick(self, sender):
        self.status.setText(self.TEXT_WAITING)
        if self.remote_py.get_geographical_region_names(self) < 0:
            self.status.setText(self.TEXT_ERROR)

    def onRemoteResponse(self, response, request_info):
        for name in response:
            item = TreeItem(name)
            item.addItem(PendingItem())
            self.tree.addItem(item)

        self.status.setText('')

    def onRemoteError(self, code, message, request_info):
        self.status.setText("Server Error or Invalid Response: ERROR " + code +
                            " - " + message)
Beispiel #13
0
 def get_case_tree(self):
     tree = self.tree = Tree()
     case_item = TreeItem("Case_1")
     tree.addItem(case_item)
     buses = self.buses = TreeItem("Buses")
     case_item.addItem(buses)
     id = self.remote_case.buses("name", self)
     return tree
Beispiel #14
0
class AMSJavascriptExample:
    def onModuleLoad(self):
        self.status=Label()
        self.button = Button("Display list of all published memories and fields", self)
        self.buttonupdate = Button("Update data from AMS publisher", self)

        buttons = HorizontalPanel()
        buttons.add(self.button)
        buttons.add(self.buttonupdate)
        buttons.setSpacing(8)

        info = """<p>This example demonstrates the calling of the Memory Snooper in PETSc with Pyjamas and <a href="http://json-rpc.org/">JSON-RPC</a>.</p>"""

        self.panel = VerticalPanel()
        self.panel.add(HTML(info))
        self.panel.add(buttons)
        self.panel.add(self.status)
        RootPanel().add(self.panel)
        self.commobj = AMS_Comm()
        self.tree = None

    def onClick(self, sender):
        global sent,recv
        self.status.setText('Button pressed')
        if sender == self.buttonupdate:
            self.commobj = AMS_Comm()
            self.status.setText('Updating data: Press Display list button to refesh')
        if sender == self.button:
            if sent > recv:
               self.status.setText('Press button again: sent '+str(sent)+' recv '+str(recv))
            if self.commobj.commname == 'No AMS publisher running':
               self.status.setText(self.commobj.commname)
            else:
               self.status.setText('Memories for AMS Comm: '+self.commobj.commname)
               result = self.commobj.get_memory_list()
               if self.tree: self.panel.remove(self.tree)
               self.tree = Tree()
               for i in result:
                  subtree = TreeItem(i)
                  memory = self.commobj.memory_attach(i)
                  fields = memory.get_field_list()
                  for j in fields:
                     field = memory.get_field_info(j)
                     subtree.addItem(j+' = '+str(field[4]))
                  self.tree.addItem(subtree)
                  self.panel.add(self.tree)
Beispiel #15
0
 def onClick(self, sender):
     global statusbar, boxes
     statusbar.setText('Button pressed')
     pass
     if sender == self.buttonupdate:
         self.commobj = AMS.AMS_Comm()
         statusbar.setText(
             'Updating data: Press Display list button to refesh')
     if sender == self.button:
         if AMS.sent > AMS.recv:
             statusbar.setText('Press button again: sent ' + str(AMS.sent) +
                               ' recv ' + str(AMS.recv))
         if self.commobj.commname == 'No AMS publisher running' or not self.commobj.commname or self.commobj.comm == -1:
             if self.tree: self.panel.remove(self.tree)
         else:
             statusbar.setText('Memories for AMS Comm: ' +
                               self.commobj.commname)
             result = self.commobj.get_memory_list()
             if self.tree: self.panel.remove(self.tree)
             self.tree = Tree()
             for i in result:
                 if i == "Stack": continue
                 subtree = TreeItem(i)
                 memory = self.commobj.memory_attach(i)
                 fields = memory.get_field_list()
                 if not isinstance(fields, list): fields = [fields]
                 block = false
                 for j in fields:
                     field = memory.get_field_info(j)
                     if str(field[1]) == 'AMS_READ':
                         if j == "Publish Block":
                             if field[4] == "true": block = true
                         else:
                             subtree.addItem(j + ' = ' + str(field[4]))
                     else:
                         if j == "Block" and not block: continue
                         PN = HorizontalPanel()
                         PN.add(Label(Text=j + ' ='))
                         tb = TextBox(Text=str(field[4]))
                         boxes[tb] = [i, j, memory]
                         tb.addChangeListener(self.textboxlistener)
                         PN.add(tb)
                         subtree.addItem(PN)
                 self.tree.addItem(subtree)
                 self.panel.add(self.tree)
Beispiel #16
0
    def __init__(self):
        Composite.__init__(self)

        self.fProto = []
        self.fTree = Tree()
        
        self.fTree.addTreeListener(self)
        self.initWidget(self.fTree)
        self.remote = InfoServicePython()
        self.remote.index("", 1, self)
Beispiel #17
0
 def onClick(self, sender):
     global statusbar, boxes
     statusbar.setText("Button pressed")
     pass
     if sender == self.buttonupdate:
         self.commobj = AMS.AMS_Comm()
         statusbar.setText("Updating data: Press Display list button to refesh")
     if sender == self.button:
         if AMS.sent > AMS.recv:
             statusbar.setText("Press button again: sent " + str(AMS.sent) + " recv " + str(AMS.recv))
         if (
             self.commobj.commname == "No AMS publisher running"
             or not self.commobj.commname
             or self.commobj.comm == -1
         ):
             if self.tree:
                 self.panel.remove(self.tree)
         else:
             statusbar.setText("Memories for AMS Comm: " + self.commobj.commname)
             result = self.commobj.get_memory_list()
             if self.tree:
                 self.panel.remove(self.tree)
             self.tree = Tree()
             for i in result:
                 if i == "Stack":
                     continue
                 subtree = TreeItem(i)
                 memory = self.commobj.memory_attach(i)
                 fields = memory.get_field_list()
                 if not isinstance(fields, list):
                     fields = [fields]
                 block = false
                 for j in fields:
                     field = memory.get_field_info(j)
                     if str(field[1]) == "AMS_READ":
                         if j == "Publish Block":
                             if field[4] == "true":
                                 block = true
                         else:
                             subtree.addItem(j + " = " + str(field[4]))
                     else:
                         if j == "Block" and not block:
                             continue
                         PN = HorizontalPanel()
                         PN.add(Label(Text=j + " ="))
                         tb = TextBox(Text=str(field[4]))
                         boxes[tb] = [i, j, memory]
                         tb.addChangeListener(self.textboxlistener)
                         PN.add(tb)
                         subtree.addItem(PN)
                 self.tree.addItem(subtree)
                 self.panel.add(self.tree)
Beispiel #18
0
    def __init__(self, *args, **kwargs):
        super(LayersPanel, self).__init__(*args, **kwargs)
        navbar = NavigationBar()
        navbar.add(HTML('<div class="brand">Layers</div>'))

        b = Button("Edit", StyleName="btn")
        b.addStyleName("btn-inverse")
        b.addStyleName("pull-right")
        navbar.add(b)

        self.add(navbar)

        self._tree = Tree()
        self.add(self._tree)
Beispiel #19
0
    def __init__(self):
        Composite.__init__(self)

        self.tree = Tree()
        root = TreeItem(self.imageItemHTML("home.gif", "*****@*****.**"))
        self.tree.addItem(root)
        inboxItem = self.addImageItem(root, "Inbox")
        self.addImageItem(root, "Drafts")
        self.addImageItem(root, "Templates")
        self.addImageItem(root, "Sent")
        self.addImageItem(root, "Trash")

        root.setState(True)
        self.initWidget(self.tree)
Beispiel #20
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)
Beispiel #21
0
    def __init__(self):
        SimplePanel.__init__(self)

        tree = Tree()
        tree.addTreeListener(self)

        s1 = self.createItem("Section 1")
        s1.addItem(self.createItem("Item 1.1", value=11))
        s1.addItem(self.createItem("Item 1.2", value=12))

        s2 = self.createItem("Section 2")
        s2.addItem(self.createItem("Item 2.1", value=21))
        s2.addItem(self.createItem("Item 2.2", value=22))

        s1.setState(True, fireEvents=False)
        s2.setState(True, fireEvents=False)

        tree.addItem(s1)
        tree.addItem(s2)
        self.add(tree)
Beispiel #22
0
    def onModuleLoad(self):

        loggedInUser = getCookie("LoggedInUser")
        self.loggedInUserJsonData = json.loads(loggedInUser)

        self.remote_py = MyBlogService()

        dockPanel = DockPanel(BorderWidth=0,
                              Padding=0,
                              HorizontalAlignment=HasAlignment.ALIGN_LEFT,
                              VerticalAlignment=HasAlignment.ALIGN_TOP)

        dockPanel.setSize('100%', '100%')

        headerDockPanel = DockPanel(
            BorderWidth=0,
            Padding=0,
            HorizontalAlignment=HasAlignment.ALIGN_LEFT,
            VerticalAlignment=HasAlignment.ALIGN_CENTER)
        headerDockPanel.setStyleName('header')
        headerDockPanel.setWidth('100%')

        dockPanel.add(headerDockPanel, DockPanel.NORTH)
        dockPanel.setCellHeight(headerDockPanel, '60px')

        self.siteImage = Image("/images/Testware_logo.png")
        self.siteImage.setStyleName('logo-image')
        headerDockPanel.add(self.siteImage, DockPanel.WEST)
        headerDockPanel.setCellWidth(self.siteImage, '30%')

        self.pageTitle = Label('All Blogs')
        self.pageTitle.setStyleName('center-header')
        headerDockPanel.add(self.pageTitle, DockPanel.CENTER)
        headerDockPanel.setCellWidth(self.pageTitle, '40%')

        rightHeaderPanel = VerticalPanel(StyleName='right-header')
        headerDockPanel.add(rightHeaderPanel, DockPanel.EAST)
        headerDockPanel.setCellWidth(rightHeaderPanel, '30%')

        welcomeNoteLabel = Label('Hi %s %s!' %
                                 (self.loggedInUserJsonData["first_name"],
                                  self.loggedInUserJsonData["last_name"]))
        rightHeaderPanel.add(welcomeNoteLabel)

        logoutAnchor = Anchor(Widget=HTML('Logout'), Href='/', Title='Logout')
        logoutAnchor.setStyleName('logout')
        rightHeaderPanel.add(logoutAnchor)

        newBlogAnchor = Anchor(Widget=HTML('Create New Blog'),
                               Href='/newblog.html',
                               Title='NewBlog')
        newBlogAnchor.setStyleName('logout')
        rightHeaderPanel.add(newBlogAnchor)

        tree = Tree()
        tree.addTreeListener(self)
        tree.setStyleName('side-menu')
        dockPanel.add(tree, DockPanel.WEST)
        dockPanel.setCellWidth(tree, '60px')

        s1 = self.createItem("Blogs")
        allItem = self.createItem("All", value=0)
        self.selectedItem = allItem
        s1.addItem(allItem)
        s1.addItem(self.createItem("Published", value=1))
        s1.addItem(self.createItem("Unpublished", value=2))

        s2 = self.createItem("Other's Blog")

        s1.setState(True, fireEvents=False)

        tree.addItem(s1)
        tree.addItem(s2)

        self.absolultutePanel = AbsolutePanel(StyleName='detail-style')
        dockPanel.add(self.absolultutePanel, DockPanel.CENTER)

        self.blogs = []
        self.g = Grid()

        RootPanel().add(dockPanel)

        self.remote_py.callMethod('getBlogs',
                                  [self.loggedInUserJsonData["username"]],
                                  self)
Beispiel #23
0
class Showcase:
    """ Our main application object.
    """
    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)

    def loadDemos(self):
        """ Load our various demos, in preparation for showing them.

            We insert the demos into self._demos.
        """
        self._demos = demoInfo.getDemos()

    def buildTree(self):
        """ Build the contents of our tree.

            Note that, for now, we highlight the demos which haven't been
            written yet.
        """
        sections = {}  # Maps section name to TreeItem object.

        for demo in self._demos:
            if demo['section'] not in sections:
                section = TreeItem('<b>' + demo['section'] + '</b>')
                DOM.setStyleAttribute(section.getElement(), "cursor",
                                      "pointer")
                DOM.setAttribute(section.itemTable, "cellPadding", "0")
                DOM.setAttribute(section.itemTable, "cellSpacing", "1")
                self._tree.addItem(section)
                sections[demo['section']] = section

            section = sections[demo['section']]

            if demo['doc'][:26] == "Documentation goes here...":
                item = TreeItem('<font style="color:#808080">' +
                                demo['title'] + '</font>')
            else:
                item = TreeItem(demo['title'])
            DOM.setStyleAttribute(item.getElement(), "cursor", "pointer")
            DOM.setAttribute(item.itemTable, "cellPadding", "0")
            DOM.setAttribute(item.itemTable, "cellSpacing", "1")
            item.setUserObject(demo)
            section.addItem(item)

        # Open the branches of the tree.

        for section in sections.keys():
            sections[section].setState(True, fireEvents=False)

    def onTreeItemSelected(self, item):
        """ Respond to the user selecting an item in our tree.
        """
        demo = item.getUserObject()
        if demo is None:
            self.showDemo(None)
        else:
            self.showDemo(demo['name'])

    def onTreeItemStateChanged(self, item):
        """ Respond to the user opening or closing a branch of the tree.
        """
        pass  # Nothing to do.

    def showDemo(self, name):
        """ Show the demonstration with the given name.
        """
        if self._curContents is not None:
            self._rightPanel.remove(self._curContents)
            self._curContents = None

        demo = None
        for d in self._demos:
            if d['name'] == name:
                demo = d
                break

        if demo is not None:
            exampleID = HTMLPanel.createUniqueId()

            html = []
            html.append('<div style="padding:20px">')
            html.append('<b>' + demo['title'] + '</b>')
            html.append('<p/>')
            html.append(self.docToHTML(demo['doc']))
            html.append('<p/>')
            html.append('<hr/>')
            html.append('<b>Working Example</b>')
            html.append('<p/>')
            html.append('<div style="padding-left:20px">')
            html.append('<span id="' + exampleID + '"></span>')
            html.append('</div>')
            html.append('<p/>')
            html.append('<hr/>')
            html.append('<b>Source Code</b>')
            html.append('<p/>')
            html.append(self.srcToHTML(demo['src']))
            html.append('</div>')

            panel = HTMLPanel("\n".join(html))
            panel.add(demo['example'], exampleID)

            self._rightPanel.add(panel)
            self._curContents = panel
        else:
            self._rightPanel.add(self._introPanel)
            self._curContents = self._introPanel

    def docToHTML(self, doc):
        """ Convert the given documentation string to HTML.
        """
        doc = doc.replace('\n\n', '<p/>')

        isBold = False
        while True:
            i = doc.find("``")
            if i == -1: break
            if isBold:
                doc = doc[:i] + '</b></font>' + doc[i + 2:]
            else:
                doc = doc[:i] + '<font face="monospace"><b>' + doc[i + 2:]
            isBold = not isBold

        return doc

    def srcToHTML(self, src):
        """ Convert the given source code to HTML.

            The source code is already in HTML format, but has extra tags to
            make it a complete HTML file.  We extract and return just the text
            between the <body> tags.
        """
        i = src.find('<body')
        i = src.find('>', i)
        j = src.find('</body>')
        return src[i + 1:j]
Beispiel #24
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)
Beispiel #25
0
class Showcase:
    """ Our main application object.
    """
    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)


    def loadDemos(self):
        """ Load our various demos, in preparation for showing them.

            We insert the demos into self._demos.
        """
        self._demos = demoInfo.getDemos()


    def buildTree(self):
        """ Build the contents of our tree.

            Note that, for now, we highlight the demos which haven't been
            written yet.
        """
        sections = {} # Maps section name to TreeItem object.

        for demo in self._demos:
            if demo['section'] not in sections:
                section = TreeItem('<b>' + demo['section'] + '</b>')
                DOM.setStyleAttribute(section.getElement(),
                                      "cursor", "pointer")
                DOM.setAttribute(section.itemTable, "cellPadding", "0")
                DOM.setAttribute(section.itemTable, "cellSpacing", "1")
                self._tree.addItem(section)
                sections[demo['section']] = section

            section = sections[demo['section']]

            if demo['doc'][:26] == "Documentation goes here...":
                item = TreeItem('<font style="color:#808080">' +
                                demo['title'] + '</font>')
            else:
                item = TreeItem(demo['title'])
            DOM.setStyleAttribute(item.getElement(), "cursor", "pointer")
            DOM.setAttribute(item.itemTable, "cellPadding", "0")
            DOM.setAttribute(item.itemTable, "cellSpacing", "1")
            item.setUserObject(demo)
            section.addItem(item)

        # Open the branches of the tree.

        for section in sections.keys():
            sections[section].setState(True, fireEvents=False)


    def onTreeItemSelected(self, item):
        """ Respond to the user selecting an item in our tree.
        """
        demo = item.getUserObject()
        if demo is None:
            self.showDemo(None)
        else:
            self.showDemo(demo['name'])


    def onTreeItemStateChanged(self, item):
        """ Respond to the user opening or closing a branch of the tree.
        """
        pass # Nothing to do.


    def showDemo(self, name):
        """ Show the demonstration with the given name.
        """
        if self._curContents is not None:
            self._rightPanel.remove(self._curContents)
            self._curContents = None

        demo = None
        for d in self._demos:
            if d['name'] == name:
                demo = d
                break

        if demo is not None:
            exampleID = HTMLPanel.createUniqueId()

            html = []
            html.append('<div style="padding:20px">')
            html.append('<b>' + demo['title'] + '</b>')
            html.append('<p/>')
            html.append(self.docToHTML(demo['doc']))
            html.append('<p/>')
            html.append('<hr/>')
            html.append('<b>Working Example</b>')
            html.append('<p/>')
            html.append('<div style="padding-left:20px">')
            html.append('<span id="' + exampleID + '"></span>')
            html.append('</div>')
            html.append('<p/>')
            html.append('<hr/>')
            html.append('<b>Source Code</b>')
            html.append('<p/>')
            html.append(self.srcToHTML(demo['src']))
            html.append('</div>')

            panel = HTMLPanel("\n".join(html))
            panel.add(demo['example'], exampleID)

            self._rightPanel.add(panel)
            self._curContents = panel
        else:
            self._rightPanel.add(self._introPanel)
            self._curContents = self._introPanel


    def docToHTML(self, doc):
        """ Convert the given documentation string to HTML.
        """
        doc = doc.replace('\n\n', '<p/>')

        isBold = False
        while True:
            i = doc.find("``")
            if i == -1: break
            if isBold:
                doc = doc[:i] + '</b></font>' + doc[i+2:]
            else:
                doc = doc[:i] + '<font face="monospace"><b>' + doc[i+2:]
            isBold = not isBold

        return doc


    def srcToHTML(self, src):
        """ Convert the given source code to HTML.

            The source code is already in HTML format, but has extra tags to
            make it a complete HTML file.  We extract and return just the text
            between the <body> tags.
        """
        i = src.find('<body')
        i = src.find('>', i)
        j = src.find('</body>')
        return src[i+1:j]
Beispiel #26
0
class Trees(Sink):
    def __init__(self):
        Sink.__init__(self)
        self.fProto = [
            Proto("Beethoven", [
                Proto("Concertos", [
                    Proto("No. 1 - C"), 
                    Proto("No. 2 - B-Flat Major"), 
                    Proto("No. 3 - C Minor"), 
                    Proto("No. 4 - G Major"), 
                    Proto("No. 5 - E-Flat Major")
                ]),
                Proto("Quartets", [
                    Proto("Six String Quartets"), 
                    Proto("Three String Quartets"), 
                    Proto("Grosse Fugue for String Quartets")
                ]),
                Proto("Sonatas", [
                    Proto("Sonata in A Minor"), 
                    Proto("Sonata in F Major")
                ]),
                Proto("Symphonies", [
                    Proto("No. 1 - C Major"), 
                    Proto("No. 2 - D Major"), 
                    Proto("No. 3 - E-Flat Major"), 
                    Proto("No. 4 - B-Flat Major"), 
                    Proto("No. 5 - C Minor"), 
                    Proto("No. 6 - F Major"), 
                    Proto("No. 7 - A Major"), 
                    Proto("No. 8 - F Major"), 
                    Proto("No. 9 - D Minor")
                ])
            ]),
        
            Proto("Brahms", [
                Proto("Concertos", [
                    Proto("Violin Concerto"),
                    Proto("Double Concerto - A Minor"),
                    Proto("Piano Concerto No. 1 - D Minor"),
                    Proto("Piano Concerto No. 2 - B-Flat Major")
                ]),
                Proto("Quartets", [
                    Proto("Piano Quartet No. 1 - G Minor"),
                    Proto("Piano Quartet No. 2 - A Major"),
                    Proto("Piano Quartet No. 3 - C Minor"),
                    Proto("String Quartet No. 3 - B-Flat Minor")
                ]),
                Proto("Sonatas", [
                    Proto("Two Sonatas for Clarinet - F Minor"),
                    Proto("Two Sonatas for Clarinet - E-Flat Major")
                ]),
                Proto("Symphonies", [
                    Proto("No. 1 - C Minor"),
                    Proto("No. 2 - D Minor"),
                    Proto("No. 3 - F Major"),
                    Proto("No. 4 - E Minor")
                ])      
            ]),
        
            Proto("Mozart", [
                Proto("Concertos", [
                    Proto("Piano Concerto No. 12"),
                    Proto("Piano Concerto No. 17"),
                    Proto("Clarinet Concerto"),
                    Proto("Violin Concerto No. 5"),
                    Proto("Violin Concerto No. 4")
                ]),
            ])
        ]

        self.fTree = Tree()
        
        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.fTree)
        
    def onTreeItemSelected(self, item):
        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)

    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 createItem(self, proto):
        proto.item = TreeItem(proto.text)
        proto.item.setUserObject(proto)
        if len(proto.children) > 0:
            proto.item.addItem(PendingItem())
    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.prPanel = VerticalPanel(Size=("50%", ""))
        self.treePanel = HorizontalPanel(Size=("50%", "100%"))
        self.treePanel.add(self.fTree)
        dock.add(self.treePanel, DockPanel.WEST)
        
        self.treePanel.setBorderWidth(1)
        self.treePanel.setWidth("100%")
        self.prPanel.setBorderWidth(1)
        self.prPanel.setWidth("100%")
        # prepare panel
        self.prepareReduce = HTML("<tt> .. none yet .. </tt>", True, )
        
        self.recipeList = ListBox()
        self.recipeList.addChangeListener(getattr(self, "onRecipeSelected"))
        self.recipeList.addItem("None")
        HTTPRequest().asyncGet("recipes.xml",
                                RecipeListLoader(self))

        #EO prepare panel
        self.reduceCLPanel = DockPanel(Spacing = 5)
        self.reduceCLPanel.add(HTML("<i>Reduce Command Line</i>:"), DockPanel.NORTH)                        
        self.reduceCLPanel.add(self.prepareReduce, DockPanel.NORTH)

        self.reduceFilesPanel = DockPanel(Spacing = 5)
        self.reduceFilesPanel.add(HTML("<b>Datasets</b>:"), DockPanel.WEST)
        
        self.reduceFiles = ListBox()
        self.reduceFiles.setVisibleItemCount(5)
        self.reduceFilesPanel.add(self.reduceFiles, DockPanel.WEST)
        self.clearReduceFilesButton = Button("<b>Clear List</b>", listener = getattr(self, "onClearReduceFiles"))
        self.reduceFilesPanel.add(self.clearReduceFilesButton, DockPanel.SOUTH)

        self.recipeListPanel = DockPanel(Spacing = 5)
        self.recipeListPanel.add(HTML("<b>Recipes List</b>:"),DockPanel.WEST)
        self.recipeListPanel.add(self.recipeList, DockPanel.WEST)
        
        self.runReduceButton = Button("<b>RUN REDUCE</b>", listener = getattr(self, "onRunReduce"))
        
        self.adInfo = HTML("file info...")
        # major sub panels
        self.prPanel.add(self.reduceCLPanel)
        self.prPanel.add(self.reduceFilesPanel)
        self.prPanel.add(self.recipeListPanel)
        self.prPanel.add(self.runReduceButton)
        self.prPanel.add(self.adInfo)
       
        
        dock.add(self.prPanel,DockPanel.EAST)
        
        dock.setCellWidth(self.treePanel, "50%")
        dock.setCellWidth(self.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)
Beispiel #28
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())
Beispiel #29
0
class Trees(Sink):
    def __init__(self):

        Sink.__init__(self)

        self.formula = AX_REG
        self.image1 = Image(latex_to_url(self.formula.fill_with_placeholders().to_latex()))
        self.cnf=self.formula.simplify().to_cnf()
        self.image2 = Image(latex_to_url(self.cnf.to_latex()))
        self.vars=self.cnf.get_vars()

        self.vars_with_proto = [{"var": var, "proto": Proto(var.name)} for var in self.vars]
        self.fProto = [
            Proto("Beethoven", [x["proto"] for x in self.vars_with_proto])
        ]

        self.fTree = Tree()

        for i in range(len(self.fProto)):
            self.createItem(self.fProto[i])
            self.fTree.addItem(self.fProto[i].item)

        self.fTree.addTreeListener(self)

        self.panel = HorizontalPanel(VerticalAlignment=HasAlignment.ALIGN_TOP)
        self.panel.setSpacing(40)
        self.panel.add(self.fTree)

        self.panel.add(self.image1)
        self.panel.add(self.image2)

        self.initWidget(self.panel)

    def onTreeItemSelected(self, item):
        var=None
        for vwb in self.vars_with_proto:
            if vwb['proto'] == item.userObject:
                var=vwb['var']

        def after(formula):
            self.cnf=self.cnf.substitute(Formula([var]),formula)
            self.image2.setUrl(latex_to_url(self.cnf.to_latex()))

        dlg = FormulaBuilder([op for op in operations if op.available and op.type==Operation.EXPRESSION],after,type='expr')

        dlg.show()

    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)

    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 createItem(self, proto):
        proto.item = TreeItem(proto.text)
        proto.item.setUserObject(proto)
        if len(proto.children) > 0:
            proto.item.addItem(PendingItem())
Beispiel #30
0
class Trees(Composite):
    def __init__(self):
        Composite.__init__(self)

        self.fProto = []
        self.fTree = Tree()
        
        self.fTree.addTreeListener(self)
        self.initWidget(self.fTree)
        self.remote = InfoServicePython()
        self.remote.index("", 1, self)
        
    def protoise_tree(self, data):

        if not data:
            return []

        res = []
        for i in range(len(data)):
            d = data[i]
            name = d[0]
            children = d[1]

            res.append(Proto(name, self.protoise_tree(children)))
        return res

    def create_tree(self, data):

        self.fProto = self.protoise_tree(data)
        
        for i in range(len(self.fProto)):
            p = self.fProto[i]
            p.pathify()
            self.createItem(p)
            self.fTree.addItem(p.item)

    def onRemoteResponse(self, response, request_info):
        if request_info.method == "index":
            self.create_tree(response)

    def onRemoteError(self, code, message, request_info):
        RootPanel().add(HTML("Server Error or Invalid Response: ERROR " + code + " - " + message))

    def onTreeItemSelected(self, item):
        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])
                item.addItem(proto.children[i].item)

    def createItem(self, proto):
        proto.item = TreeItem(proto.text)
        proto.item.setUserObject(proto)
        if len(proto.children) > 0:
            proto.item.addItem(PendingItem())
Beispiel #31
0
class AMSSnoopObjects:
    def onModuleLoad(self):
        global statusbar
        statusbar = Label()
        self.button = Button("Display list of all published memories and fields", self)
        self.buttonupdate = Button("Update data from AMS publisher", self)

        buttons = HorizontalPanel()
        buttons.add(self.button)
        buttons.add(self.buttonupdate)
        buttons.setSpacing(8)

        info = """<p>This example demonstrates the calling of the Memory Snooper in PETSc with Pyjamas and <a href="http://json-rpc.org/">JSON-RPC</a>.</p>"""

        self.panel = VerticalPanel()
        self.panel.add(HTML(info))
        self.panel.add(buttons)
        self.panel.add(statusbar)
        RootPanel().add(self.panel)
        self.commobj = AMS.AMS_Comm()
        self.tree = None

    def textboxlistener(self, arg):
        global boxes, statusbar
        statusbar.setText("User changed value in text box to " + str(arg.getText()) + " " + str(boxes[arg]))
        # the user has changed this value we should send it back to the AMS program
        boxes[arg][2].set_field_info(boxes[arg][1], arg.getText())

    def onClick(self, sender):
        global statusbar, boxes
        statusbar.setText("Button pressed")
        pass
        if sender == self.buttonupdate:
            self.commobj = AMS.AMS_Comm()
            statusbar.setText("Updating data: Press Display list button to refesh")
        if sender == self.button:
            if AMS.sent > AMS.recv:
                statusbar.setText("Press button again: sent " + str(AMS.sent) + " recv " + str(AMS.recv))
            if (
                self.commobj.commname == "No AMS publisher running"
                or not self.commobj.commname
                or self.commobj.comm == -1
            ):
                if self.tree:
                    self.panel.remove(self.tree)
            else:
                statusbar.setText("Memories for AMS Comm: " + self.commobj.commname)
                result = self.commobj.get_memory_list()
                if self.tree:
                    self.panel.remove(self.tree)
                self.tree = Tree()
                for i in result:
                    if i == "Stack":
                        continue
                    subtree = TreeItem(i)
                    memory = self.commobj.memory_attach(i)
                    fields = memory.get_field_list()
                    if not isinstance(fields, list):
                        fields = [fields]
                    block = false
                    for j in fields:
                        field = memory.get_field_info(j)
                        if str(field[1]) == "AMS_READ":
                            if j == "Publish Block":
                                if field[4] == "true":
                                    block = true
                            else:
                                subtree.addItem(j + " = " + str(field[4]))
                        else:
                            if j == "Block" and not block:
                                continue
                            PN = HorizontalPanel()
                            PN.add(Label(Text=j + " ="))
                            tb = TextBox(Text=str(field[4]))
                            boxes[tb] = [i, j, memory]
                            tb.addChangeListener(self.textboxlistener)
                            PN.add(tb)
                            subtree.addItem(PN)
                    self.tree.addItem(subtree)
                    self.panel.add(self.tree)
class EditPanel:
    """ Defines a panel for editing data store objects.
    """
    def __init__(self):
        """ Constructs a new EditPanel.
        """
        self.TEXT_WAITING = "Waiting for response..."
        self.TEXT_ERROR = "Server Error"

#        self.remote_py = RegionNamesServicePython()

        self.panel = VerticalPanel()

        top_panel = HorizontalPanel()
        top_panel.setSpacing(8)
        self.panel.add(top_panel)

        refresh = Button("Refresh", self)
        top_panel.add(refresh)

        self.status = Label()
        top_panel.add(self.status)

        edit_panel = HorizontalPanel()
        self.panel.add(edit_panel)

        self.tree = Tree()
        self.tree.addTreeListener(self)
        edit_panel.add(self.tree)

        upload_item = TreeItem("Upload")
        self.tree.add(upload_item)
        map_item = TreeItem("Map")
        self.tree.add(map_item)


    def onTreeItemSelected(self, item):
        pass


    def onTreeItemStateChanged(self, item):
        child = item.getChild(0)


    def onClick(self, sender):
        self.status.setText(self.TEXT_WAITING)
        if self.remote_py.get_geographical_region_names(self) < 0:
            self.status.setText(self.TEXT_ERROR)


    def onRemoteResponse(self, response, request_info):
        for name in response:
            item = TreeItem(name)
            item.addItem(PendingItem())
            self.tree.addItem(item)

        self.status.setText('')


    def onRemoteError(self, code, message, request_info):
        self.status.setText("Server Error or Invalid Response: ERROR " +
                            code + " - " + message)
class Trees(Sink):
    pathdict = {}
    reduceFiles = 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.prPanel = VerticalPanel(Size=("50%", ""))
        self.treePanel = HorizontalPanel(Size=("50%", "100%"))
        self.treePanel.add(self.fTree)
        dock.add(self.treePanel, DockPanel.WEST)
        
        self.treePanel.setBorderWidth(1)
        self.treePanel.setWidth("100%")
        self.prPanel.setBorderWidth(1)
        self.prPanel.setWidth("100%")
        # prepare panel
        self.prepareReduce = HTML("<tt> .. none yet .. </tt>", True, )
        
        self.recipeList = ListBox()
        self.recipeList.addChangeListener(getattr(self, "onRecipeSelected"))
        self.recipeList.addItem("None")
        HTTPRequest().asyncGet("recipes.xml",
                                RecipeListLoader(self))

        #EO prepare panel
        self.reduceCLPanel = DockPanel(Spacing = 5)
        self.reduceCLPanel.add(HTML("<i>Reduce Command Line</i>:"), DockPanel.NORTH)                        
        self.reduceCLPanel.add(self.prepareReduce, DockPanel.NORTH)

        self.reduceFilesPanel = DockPanel(Spacing = 5)
        self.reduceFilesPanel.add(HTML("<b>Datasets</b>:"), DockPanel.WEST)
        
        self.reduceFiles = ListBox()
        self.reduceFiles.setVisibleItemCount(5)
        self.reduceFilesPanel.add(self.reduceFiles, DockPanel.WEST)
        self.clearReduceFilesButton = Button("<b>Clear List</b>", listener = getattr(self, "onClearReduceFiles"))
        self.reduceFilesPanel.add(self.clearReduceFilesButton, DockPanel.SOUTH)

        self.recipeListPanel = DockPanel(Spacing = 5)
        self.recipeListPanel.add(HTML("<b>Recipes List</b>:"),DockPanel.WEST)
        self.recipeListPanel.add(self.recipeList, DockPanel.WEST)
        
        self.runReduceButton = Button("<b>RUN REDUCE</b>", listener = getattr(self, "onRunReduce"))
        
        self.adInfo = HTML("file info...")
        # major sub panels
        self.prPanel.add(self.reduceCLPanel)
        self.prPanel.add(self.reduceFilesPanel)
        self.prPanel.add(self.recipeListPanel)
        self.prPanel.add(self.runReduceButton)
        self.prPanel.add(self.adInfo)
       
        
        dock.add(self.prPanel,DockPanel.EAST)
        
        dock.setCellWidth(self.treePanel, "50%")
        dock.setCellWidth(self.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 onTreeItemSelected(self, item):
        pathdict = self.pathdict
        
        tfile = item.getText()
        #check if already in

        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 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 onRunReduce(self):
        recipe = self.recipeList.getItemText(self.recipeList.getSelectedIndex())
        
        if recipe=="None":
            rstr = ""
        else:
            rstr = "p=-r"+recipe

        rfiles = []            
        for i in range(0, self.reduceFiles.getItemCount()):
            fname = self.reduceFiles.getItemText(i)
            rfiles.append(quote(self.pathdict[fname]["path"]))
        filesstr = "&p=".join(rfiles)
                
        cl = "/runreduce?%s&p=%s" % (rstr, filesstr)
        JS("window.open(cl)")

        
    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):
            #if node.nodeType != node.ELEMENT_NODE:
            #    return
            pathdict = self.pathdict
            if not node.hasChildNodes():
                if node.nodeType != 1:
                    return 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)
                    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())
Beispiel #34
0
    def __init__(self):
        Sink.__init__(self)
        self.fProto = [
            Proto("Beethoven", [
                Proto("Concertos", [
                    Proto("No. 1 - C"), 
                    Proto("No. 2 - B-Flat Major"), 
                    Proto("No. 3 - C Minor"), 
                    Proto("No. 4 - G Major"), 
                    Proto("No. 5 - E-Flat Major")
                ]),
                Proto("Quartets", [
                    Proto("Six String Quartets"), 
                    Proto("Three String Quartets"), 
                    Proto("Grosse Fugue for String Quartets")
                ]),
                Proto("Sonatas", [
                    Proto("Sonata in A Minor"), 
                    Proto("Sonata in F Major")
                ]),
                Proto("Symphonies", [
                    Proto("No. 1 - C Major"), 
                    Proto("No. 2 - D Major"), 
                    Proto("No. 3 - E-Flat Major"), 
                    Proto("No. 4 - B-Flat Major"), 
                    Proto("No. 5 - C Minor"), 
                    Proto("No. 6 - F Major"), 
                    Proto("No. 7 - A Major"), 
                    Proto("No. 8 - F Major"), 
                    Proto("No. 9 - D Minor")
                ])
            ]),
        
            Proto("Brahms", [
                Proto("Concertos", [
                    Proto("Violin Concerto"),
                    Proto("Double Concerto - A Minor"),
                    Proto("Piano Concerto No. 1 - D Minor"),
                    Proto("Piano Concerto No. 2 - B-Flat Major")
                ]),
                Proto("Quartets", [
                    Proto("Piano Quartet No. 1 - G Minor"),
                    Proto("Piano Quartet No. 2 - A Major"),
                    Proto("Piano Quartet No. 3 - C Minor"),
                    Proto("String Quartet No. 3 - B-Flat Minor")
                ]),
                Proto("Sonatas", [
                    Proto("Two Sonatas for Clarinet - F Minor"),
                    Proto("Two Sonatas for Clarinet - E-Flat Major")
                ]),
                Proto("Symphonies", [
                    Proto("No. 1 - C Minor"),
                    Proto("No. 2 - D Minor"),
                    Proto("No. 3 - F Major"),
                    Proto("No. 4 - E Minor")
                ])      
            ]),
        
            Proto("Mozart", [
                Proto("Concertos", [
                    Proto("Piano Concerto No. 12"),
                    Proto("Piano Concerto No. 17"),
                    Proto("Clarinet Concerto"),
                    Proto("Violin Concerto No. 5"),
                    Proto("Violin Concerto No. 4")
                ]),
            ])
        ]

        self.fTree = Tree()
        
        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.fTree)
Beispiel #35
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)
Beispiel #36
0
class Trees(Composite):
    def __init__(self):
        Composite.__init__(self)

        self.fProto = []
        self.fTree = Tree()
        
        self.fTree.addTreeListener(self)
        self.initWidget(self.fTree)
        self.remote = InfoServicePython()
        self.remote.index("", 1, self)
        
    def protoise_tree(self, data):

        if not data:
            return []

        res = []
        for i in range(len(data)):
            d = data[i]
            name = d[0]
            children = d[1]

            res.append(Proto(name, self.protoise_tree(children)))
        return res

    def create_tree(self, data):

        self.fProto = self.protoise_tree(data)
        
        for i in range(len(self.fProto)):
            p = self.fProto[i]
            p.pathify()
            self.createItem(p)
            self.fTree.addItem(p.item)

    def onRemoteResponse(self, response, request_info):
        if request_info.method == "index":
            self.create_tree(response)

    def onRemoteError(self, code, message, request_info):
        RootPanel().add(HTML(
            "Server Error or Invalid Response: ERROR %s - %s" % (
                code, message,
            ),
        ))

    def onTreeItemSelected(self, item):
        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])
                item.addItem(proto.children[i].item)

    def createItem(self, proto):
        proto.item = TreeItem(proto.text)
        proto.item.setUserObject(proto)
        if len(proto.children) > 0:
            proto.item.addItem(PendingItem())
Beispiel #37
0
class AMSSnoopObjects:
    def onModuleLoad(self):
        global statusbar
        statusbar = Label()
        self.button = Button(
            "Display list of all published memories and fields", self)
        self.buttonupdate = Button("Update data from AMS publisher", self)

        buttons = HorizontalPanel()
        buttons.add(self.button)
        buttons.add(self.buttonupdate)
        buttons.setSpacing(8)

        info = """<p>This example demonstrates the calling of the Memory Snooper in PETSc with Pyjamas and <a href="http://json-rpc.org/">JSON-RPC</a>.</p>"""

        self.panel = VerticalPanel()
        self.panel.add(HTML(info))
        self.panel.add(buttons)
        self.panel.add(statusbar)
        RootPanel().add(self.panel)
        self.commobj = AMS.AMS_Comm()
        self.tree = None

    def textboxlistener(self, arg):
        global boxes, statusbar
        statusbar.setText('User changed value in text box to ' +
                          str(arg.getText()) + " " + str(boxes[arg]))
        # the user has changed this value we should send it back to the AMS program
        boxes[arg][2].set_field_info(boxes[arg][1], arg.getText())

    def onClick(self, sender):
        global statusbar, boxes
        statusbar.setText('Button pressed')
        pass
        if sender == self.buttonupdate:
            self.commobj = AMS.AMS_Comm()
            statusbar.setText(
                'Updating data: Press Display list button to refesh')
        if sender == self.button:
            if AMS.sent > AMS.recv:
                statusbar.setText('Press button again: sent ' + str(AMS.sent) +
                                  ' recv ' + str(AMS.recv))
            if self.commobj.commname == 'No AMS publisher running' or not self.commobj.commname or self.commobj.comm == -1:
                if self.tree: self.panel.remove(self.tree)
            else:
                statusbar.setText('Memories for AMS Comm: ' +
                                  self.commobj.commname)
                result = self.commobj.get_memory_list()
                if self.tree: self.panel.remove(self.tree)
                self.tree = Tree()
                for i in result:
                    if i == "Stack": continue
                    subtree = TreeItem(i)
                    memory = self.commobj.memory_attach(i)
                    fields = memory.get_field_list()
                    if not isinstance(fields, list): fields = [fields]
                    block = false
                    for j in fields:
                        field = memory.get_field_info(j)
                        if str(field[1]) == 'AMS_READ':
                            if j == "Publish Block":
                                if field[4] == "true": block = true
                            else:
                                subtree.addItem(j + ' = ' + str(field[4]))
                        else:
                            if j == "Block" and not block: continue
                            PN = HorizontalPanel()
                            PN.add(Label(Text=j + ' ='))
                            tb = TextBox(Text=str(field[4]))
                            boxes[tb] = [i, j, memory]
                            tb.addChangeListener(self.textboxlistener)
                            PN.add(tb)
                            subtree.addItem(PN)
                    self.tree.addItem(subtree)
                    self.panel.add(self.tree)