Exemplo n.º 1
0
 def makeTree(self):
     #-----------------------------------------------------------------------
     # First, build the hierarchy of Tree nodes
     #-----------------------------------------------------------------------
     root = DefaultMutableTreeNode('Root Node')
     for name in 'Parent 1,Parent 2'.split(','):
         here = DefaultMutableTreeNode(name)
         for child in 'Child 1,Child 2'.split(','):
             here.add(DefaultMutableTreeNode(child))
         root.add(here)
     #-----------------------------------------------------------------------
     # Next, use the hierarchy to create a Tree Model, with a listener
     #-----------------------------------------------------------------------
     model = DefaultTreeModel(root, treeModelListener=myTreeModelListener())
     #-----------------------------------------------------------------------
     # Then, build our editable JTree() using this model
     #-----------------------------------------------------------------------
     tree = JTree(model,
                  editable=1,
                  showsRootHandles=1,
                  valueChanged=self.select)
     #-----------------------------------------------------------------------
     # Only allow one node to be selectable at a time
     #-----------------------------------------------------------------------
     tree.getSelectionModel().setSelectionMode(
         TreeSelectionModel.SINGLE_TREE_SELECTION)
     return tree
Exemplo n.º 2
0
    def groupTree(self):
        data = AdminTask.help('-commandGroups').expandtabs().splitlines()
        root = DefaultMutableTreeNode('command groups')

        for line in data[1:]:
            mo = re.match('([a-zA-Z ]+) -', line)
            if mo:
                groupName = mo.group(1)
                group = None
                text = AdminTask.help(groupName)
                cmds = text.find('Commands:')
                if cmds > 0:
                    for line in text[cmds + 9:].splitlines():
                        mo = re.match('([a-zA-Z_2]+) -', line)
                        if mo:
                            if not group:
                                group = DefaultMutableTreeNode(groupName)
                            group.add(DefaultMutableTreeNode(mo.group(1)))
                    if group:
                        root.add(group)
                    else:
                        print 'Empty group:', groupName

        return JTree(
            root,
            rootVisible=0  #,
            #           valueChanged = self.select
        )
Exemplo n.º 3
0
 def gui(self):
   xnode = self.xdoc.getDocumentElement()
   tnode = self.createTree(xnode)  
   # create tree and display
   jt = JTree(tnode)
   jsp = JScrollPane(jt)
   tree_box = Box(BoxLayout.Y_AXIS)
   tree_box.add(jsp)
   tree_box.add(Box.createHorizontalStrut(10))
   headerSorter = TableSorter(DefaultTableModel())
   jtb = JTable(headerSorter)
   headerSorter.addMouseListenerToHeaderInTable(jtb)
   jtb.setAutoResizeMode(JTable.AUTO_RESIZE_OFF)
   jsp2 = JScrollPane(jtb)
   table_box = Box(BoxLayout.Y_AXIS)
   table_box.add(jsp2)
   table_box.add(Box.createHorizontalStrut(500))
   mp = JPanel()
   mp.setLayout(BoxLayout(mp,BoxLayout.X_AXIS))
   mp.add(tree_box)
   mp.add(table_box)
   # add listeners
   nsl = NodeSelectionListener(jtb,xnode)
   jt.addTreeSelectionListener(nsl)
   #
   return mp
Exemplo n.º 4
0
    def make_tree(self):
        print('make_tree')
        root = DefaultMutableTreeNode(self.exper.name)

        sb = br.SimilarityBuilder()

        for hseg in self.exper.hsegs():
            all_file_dict = hseg.file_dict()
            all_file_dict.update(hseg.cell_file_dict())
            all_file_dict.update(hseg.bin_file_dict())
            sb.add_group(hseg.name, all_file_dict)

        simprofile, comparisons = sb.simprofile_comparison()

        sim_str = ''
        for val in simprofile:
            sim_str += str(val) + '\n'

        tp = JTextArea(sim_str)

        stp = JScrollPane()
        stp.getViewport().setView(tp)
        #
        # stp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
        # stp.setPreferredSize(Dimension(250, 250));
        # tp.setPreferredSize(Dimension(250, 250))
        stp_panel = JPanel(BorderLayout())
        stp_panel.add(tp, BorderLayout.CENTER)

        # self.add(stp_panel, 'grow')

        for hseg in self.exper.hsegs():
            hseg_node = DefaultMutableTreeNode(hseg.name)
            root.add(hseg_node)
            if len(comparisons[hseg.name]) > 0:
                for definer, file_names in comparisons[hseg.name].items():
                    for file_name in file_names:
                        node_str = definer + ': ' + file_name
                        hseg_node.add(DefaultMutableTreeNode(node_str))
            # for file_suf in hseg.file_dict() :
            # hseg_node.add(DefaultMutableTreeNode(file_suf))

        self.tree = JTree(root)
        scrollPane = JScrollPane()
        scrollPane.getViewport().setView((self.tree))
        # scrollPan
        # scrollPane.setPreferredSize(Dimension(300,250))

        tree_panel = JPanel(BorderLayout())
        tree_panel.add(scrollPane, BorderLayout.CENTER)

        combo_panel = JPanel(GridLayout(0, 2, 10, 10))
        # combo_panel.setLayout(BoxLayout(combo_panel, BoxLayout.X_AXIS))
        combo_panel.add(stp_panel)  #, BorderLayout.LINE_START)
        combo_panel.add(tree_panel)  #, BorderLayout.LINE_END)
        self.panel.add(combo_panel)
        # self.add(scrollPane, 'grow')
        self.revalidate()
Exemplo n.º 5
0
 def __initTree(self):
     ''' construct the suite tree '''
     top = DefaultMutableTreeNode("RootSuite")
     self.__createNodes(top)
     self.tree = JTree(top)
     self.__setupRenderer()
     self.scrollpane = JScrollPane(self.tree)
     self.add(self.scrollpane,self.__setupLayout())
     self.tree.addTreeSelectionListener(NodeHighlighter())
     self.tree.addMouseListener(TreeMouseListener())
Exemplo n.º 6
0
	def issuesTab(self):
		self.root = DefaultMutableTreeNode('Issues')

		frame = JFrame("Issues Tree")

		self.tree = JTree(self.root)
		self.rowSelected = ''
		self.tree.addMouseListener(mouseclick(self))
		self.issuepanel = JScrollPane()
		self.issuepanel.setPreferredSize(Dimension(300,450))
		self.issuepanel.getViewport().setView((self.tree))
		frame.add(self.issuepanel,BorderLayout.CENTER)
Exemplo n.º 7
0
    def cellTree(self):
        # Use the cellName as the tree root node
        cell = AdminConfig.list('Cell')
        root = DefaultMutableTreeNode(self.getName(cell))

        for node in AdminConfig.list('Node').splitlines():
            here = DefaultMutableTreeNode(self.getName(node))
            servers = AdminConfig.list('Server', node)
            for server in servers.splitlines():
                leaf = DefaultMutableTreeNode(self.getName(server))
                here.add(leaf)
            root.add(here)

        return JTree(root, editable=1)
Exemplo n.º 8
0
    def make_tree(self):
        root = DefaultMutableTreeNode(self.exper.name)
        for hseg in self.exper.hsegs():
            hseg_node = DefaultMutableTreeNode(hseg.name)
            root.add(hseg_node)
            for file_suf in hseg.file_dict():
                hseg_node.add(DefaultMutableTreeNode(file_suf))
        self.tree = JTree(root)
        scrollPane = JScrollPane()
        scrollPane.getViewport().setView((self.tree))
        # scrollPane.setPreferredSize(Dimension(300,250))

        tree_panel = JPanel()
        tree_panel.add(scrollPane)
        box_layout = BoxLayout(self.panel, BoxLayout.Y_AXIS)
        self.panel.setLayout(box_layout)
        self.panel.add(tree_panel)
        self.revalidate()
Exemplo n.º 9
0
    def load_data(self, file_name):
        self.view.set_checklist(file_name)
        checklist = self.view.get_checklist()
        self.view.set_checklist_tree()
        checklist_tree = self.view.get_checklist_tree()

        new_tree = JTree(checklist_tree)
        model = new_tree.getModel()
        old_tree = self.view.get_tree()
        old_tree.setModel(model)

        tabbed_panes = self.view.get_tabbed_panes()
        del tabbed_panes
        self.view.set_tabbed_panes()

        old_tsl = self.view.get_tsl()
        old_tree.removeTreeSelectionListener(old_tsl)
        tsl = TSL(self.view)
        old_tree.addTreeSelectionListener(tsl)
Exemplo n.º 10
0
    def __init__(self, dir=None, label=None):
        if not dir: dir = os.getcwd()
        if not label: label = "FileTree"
        dir = File(dir)
        self._dir = dir
        self.this = JPanel()
        self.this.setLayout(BorderLayout())

        # Add a label
        self.this.add(BorderLayout.PAGE_START, JLabel(label))

        # Make a tree list with all the nodes, and make it a JTree
        tree = JTree(self._add_nodes(None, dir))
        tree.setRootVisible(False)
        self._tree = tree

        # Lastly, put the JTree into a JScrollPane.
        scrollpane = JScrollPane()
        scrollpane.getViewport().add(tree)
        self.this.add(BorderLayout.CENTER, scrollpane)
Exemplo n.º 11
0
    def cellTree(self):
        #-----------------------------------------------------------------------
        # Use the cellName as the tree root node
        #-----------------------------------------------------------------------
        cell = AdminConfig.list('Cell')
        cellName = self.getName(cell)
        root = DefaultMutableTreeNode(cellName)
        #-----------------------------------------------------------------------
        # Build an item name to configId dictionary
        #-----------------------------------------------------------------------
        result = {cellName: cell}

        #-----------------------------------------------------------------------
        # Use the node name for the branches
        #-----------------------------------------------------------------------
        for node in AdminConfig.list('Node').splitlines():
            nodeName = self.getName(node)
            here = DefaultMutableTreeNode(nodeName)
            #-------------------------------------------------------------------
            # Add this node to the dictionary
            #-------------------------------------------------------------------
            result[nodeName] = node
            #-------------------------------------------------------------------
            # and the server name for each leaf
            #-------------------------------------------------------------------
            servers = AdminConfig.list('Server', node)
            for server in servers.splitlines():
                name = self.getName(server)
                leaf = DefaultMutableTreeNode(name)
                #---------------------------------------------------------------
                # Add this server to the dictionary
                # Note: Server names are not guaranteed to be unique in the cell
                #---------------------------------------------------------------
                result[(nodeName, name)] = server
                here.add(leaf)
            root.add(here)

        return JTree(root), result
Exemplo n.º 12
0
    def __init__(self, title=""):
        JFrame.__init__(self, title)
        self.size = 400, 500
        self.windowClosing = self.closing

        label = JLabel(text="Class Name:")
        label.horizontalAlignment = JLabel.RIGHT
        tpanel = JPanel(layout=awt.FlowLayout())
        self.text = JTextField(20, actionPerformed=self.entered)
        btn = JButton("Enter", actionPerformed=self.entered)
        tpanel.add(label)
        tpanel.add(self.text)
        tpanel.add(btn)

        bpanel = JPanel()
        self.tree = JTree(default_tree())
        scrollpane = JScrollPane(self.tree)
        scrollpane.setMinimumSize(awt.Dimension(200, 200))
        scrollpane.setPreferredSize(awt.Dimension(350, 400))
        bpanel.add(scrollpane)

        bag = GridBag(self.contentPane)
        bag.addRow(tpanel, fill='HORIZONTAL', weightx=1.0, weighty=0.5)
        bag.addRow(bpanel, fill='BOTH', weightx=0.5, weighty=1.0)
Exemplo n.º 13
0
    def make_hseg_tree_panel(self):
        root = DefaultMutableTreeNode(self.exper.name)

        for hseg in self.exper.hsegs():
            hseg_node = DefaultMutableTreeNode(hseg.name)
            root.add(hseg_node)
            hseg_at_deviations = self.exper.hseg_files_cab(
            ).archetype_deviations
            if len(hseg_at_deviations[hseg.name]) > 0:
                for definer, file_names in hseg_at_deviations[
                        hseg.name].items():
                    for file_name in file_names:
                        node_str = definer + ': ' + file_name

                        temp = DefaultMutableTreeNode(node_str)
                        hseg_node.add(temp)

        hseg_tree = JTree(root)
        hseg_tree.setCellRenderer(BobPyTreeCellRenderer())

        hseg_scroll_pane = JScrollPane()
        hseg_scroll_pane.getViewport().setView((hseg_tree))

        hseg_panel = JPanel(MigLayout('insets 0'))
        hseg_panel.add(hseg_scroll_pane, 'grow, span, push, wrap')

        run_button = JButton('Run')
        run_button.addActionListener(ActionListenerFactory(self, self.run_al))
        rerun_button = JButton('Rerun')
        rerun_button.addActionListener(
            ActionListenerFactory(self, self.rerun_al))

        hseg_panel.add(run_button)
        hseg_panel.add(rerun_button)

        return hseg_panel
Exemplo n.º 14
0
    def make_hseg_tree_panel(self):
        root = DefaultMutableTreeNode(self.exper.name)

        for hseg in self.exper.hsegs():
            hseg_node = DefaultMutableTreeNode(hseg.name)
            root.add(hseg_node)
            hseg_at_deviations = self.exper.hseg_all_files_cab(
            ).archetype_deviations
            if len(hseg_at_deviations[hseg.name]) > 0:
                for definer, file_names in hseg_at_deviations[
                        hseg.name].items():
                    for file_name in file_names:
                        node_str = definer + ': ' + file_name

                        temp = DefaultMutableTreeNode(node_str)
                        hseg_node.add(temp)

        hseg_tree = JTree(root)
        hseg_tree.setCellRenderer(BobPyTreeCellRenderer())

        hseg_scroll_pane = JScrollPane()
        hseg_scroll_pane.getViewport().setView((hseg_tree))

        return hseg_scroll_pane
def main(*args):
  model = createNewModel()
  jtree = JTree(model)
  l = Tabed1(model)
  l.showTool("JTREE")
Exemplo n.º 16
0
 def set_tree(self):
     self.tree = JTree(self.checklist_tree)
     self.tree.getSelectionModel().setSelectionMode(
         TreeSelectionModel.SINGLE_TREE_SELECTION)
Exemplo n.º 17
0
 def __init__(self):
     self.setName('Jython Explorer')
     self.setLayout(BorderLayout())
     self.add(JScrollPane(JTree()),
              BorderLayout.CENTER)
Exemplo n.º 18
0
 def __init__(self, view):
     model = DefaultTreeModel(PathBrowserTreeItem())
     self.tree = JTree(model, mousePressed=self.__mousePressed)
     self.tree.cellRenderer = BrowserCellRenderer()
     self.panel = JScrollPane(self.tree)
Exemplo n.º 19
0
    def cellTree(self, data):

        #-----------------------------------------------------------------------
        # Use the cellName as the tree root node
        #-----------------------------------------------------------------------
        cell = AdminConfig.list('Cell')
        cellName = self.getName(cell)

        #-----------------------------------------------------------------------
        # Note: data is the one and only instance of the inner cellInfo class
        #-----------------------------------------------------------------------
        data.addInfoValue(
            cellName, CELLINFO %
            (cellName, WAShome(cell), WASversion(cell), WASprofileName(cell)))

        root = DefaultMutableTreeNode(cellName)

        #-----------------------------------------------------------------------
        # Build an item name to configId dictionary
        #-----------------------------------------------------------------------
        result = {cellName: cell}

        #-----------------------------------------------------------------------
        # Use the node name for the branches
        #-----------------------------------------------------------------------
        for node in AdminConfig.list('Node').splitlines():
            nodeName = self.getName(node)
            here = DefaultMutableTreeNode(nodeName)

            #-------------------------------------------------------------------
            # Add this node to the dictionary
            #-------------------------------------------------------------------
            result[nodeName] = node
            #-------------------------------------------------------------------
            # and the server name for each leaf
            #-------------------------------------------------------------------
            servers = AdminConfig.list('Server', node)
            for server in servers.splitlines():
                servName = self.getName(server)
                leaf = DefaultMutableTreeNode(servName)
                #---------------------------------------------------------------
                # Add this server to the dictionary
                # Note: Server names are not guaranteed to be unique in the cell
                #---------------------------------------------------------------
                result[(nodeName, servName)] = server
                here.add(leaf)

                hostnames = getHostnames(nodeName, servName)
                ipaddr = getIPaddresses(hostnames)

                data.addInfoValue(
                    nodeName,
                    NODEINFO % (cellName, nodeName, WAShome(node),
                                WASversion(node), WASprofileName(node),
                                ', '.join(hostnames), ', '.join(ipaddr)))
                PortLookupTask(nodeName, servName, data).execute()

            root.add(here)

        #-----------------------------------------------------------------------
        # Note: data is the one and only instance of the inner cellInfo class
        #-----------------------------------------------------------------------
        data.setNames(result)

        return JTree(root)