Beispiel #1
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
Beispiel #2
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
Beispiel #3
0
class TestSuitePanel(JPanel, Dockable, GraphMouseListener):
    ''' Show an expandable list of the test entites {suites,cases,methods} '''

    #
    # Constructor
    #

    def __init__(self):
        self.myParent = None
        #com.hp.hpl.guess.ui.GraphEvents.getGraphEvents().addGraphMouseListener(self)
        self.__initTree()
        self.setBounds(self.getDefaultFrameBounds())
        ui.dock(self)

    #
    # JTree Setup
    #

    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())

    def __setupRenderer(self):
        renderer = DefaultTreeCellRenderer()
        renderer.setOpenIcon(None)
        renderer.setClosedIcon(None)
        renderer.setLeafIcon(None)
        self.tree.setCellRenderer(renderer);

    def __setupLayout(self):
        self.setLayout(GridBagLayout())
        constr = GridBagConstraints()
        constr.weighty = 1
        constr.weightx = 1
        constr.gridx = 0
        constr.gridy = 1
        constr.fill = GridBagConstraints.BOTH
        return constr

    def __createNodes(self, top):
        ''' build the tree, by adding packages, testcases and commands '''
        for pkg in (entity == 'package'):
            pkgNode = DefaultMutableTreeNode(pkg.name)
            top.add(pkgNode)
            self.__appendCases(pkg, pkgNode)

    #
    # Node builders
    #

    def __appendCases(self, pkg, pkgNode):
        ''' append the test cases of a single package to the tree '''
        testcases = [edge.getNode2() for edge in (pkg->g.nodes)]
        testcases.sort(cmpTc)
        for tc in testcases:
            tcNode = DefaultMutableTreeNode(tc.label.split('::')[-1])
            pkgNode.add(tcNode)
            self.__appendCommands(tc, tcNode)
            self.__appendFixture(tc, tcNode)
            self.__appendHelpers(tc, tcNode)

    def __appendCaseMethodsHelper(self, case, caseNode, metaName, entityName):
        ''' helper for appendCommands, appendFixture & appendHelpers '''
        mtdMeta = DefaultMutableTreeNode(metaName)
        caseNode.add(mtdMeta)
        mtds = [edge.getNode2() for edge in case->(entity == entityName)]
        mtds.sort(cmpTc)
        for mtd in mtds:
            mtdNode = DefaultMutableTreeNode(mtd.label)
            mtdMeta.add(mtdNode)

    def __appendCommands(self, case, caseNode):
        ''' append the test commands of a single testcase to the tree '''
        self.__appendCaseMethodsHelper(case, caseNode, "commands", "testcommand")

    def __appendFixture(self, case, caseNode):
        ''' append the test fixture methods of a single testcase to the tree'''
        self.__appendCaseMethodsHelper(case, caseNode, "fixture", "testfixture")

    def __appendHelpers(self, case, caseNode):
        #''' append the test helper methods of a single testcase to the tree'''
        self.__appendCaseMethodsHelper(case, caseNode, "helpers", "testhelper")

    #
    # Implementation of Dockable interface
    #

    def getDefaultFrameBounds(self):
        return Rectangle(50, 50, 300, 600)

    def getPreferredSize(self):
        return Dimension(200,600)

    def getDirectionPreference(self):
        return 2 # vertical

    def opening(self, state):
        self.visible = state

    def attaching(self, state):
        pass

    def getTitle(self):
        return("testcases")

    def getWindow(self):
        return self.myParent

    def setWindow(self,gjf):
        self.myParent = gjf
Beispiel #4
0
class TestSuitePanel(JPanel, Dockable, GraphMouseListener):
    ''' Show an expandable list of the test entites {suites,cases,methods} '''

    #
    # Constructor
    #

    def __init__(self):
        self.myParent = None
        #com.hp.hpl.guess.ui.GraphEvents.getGraphEvents().addGraphMouseListener(self)
        self.__initTree()
        self.setBounds(self.getDefaultFrameBounds())
        ui.dock(self)

    #
    # JTree Setup
    #

    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())

    def __setupRenderer(self):
        renderer = DefaultTreeCellRenderer()
        renderer.setOpenIcon(None)
        renderer.setClosedIcon(None)
        renderer.setLeafIcon(None)
        self.tree.setCellRenderer(renderer);

    def __setupLayout(self):
        self.setLayout(GridBagLayout())
        constr = GridBagConstraints()
        constr.weighty = 1
        constr.weightx = 1
        constr.gridx = 0
        constr.gridy = 1
        constr.fill = GridBagConstraints.BOTH
        return constr

    def __createNodes(self, top):
        ''' build the tree, by adding packages, testcases and commands '''
        for pkg in (entity == 'package'):
            pkgNode = DefaultMutableTreeNode(pkg.name)
            top.add(pkgNode)
            self.__appendCases(pkg, pkgNode)

    #
    # Node builders
    #

    def __appendCases(self, pkg, pkgNode):
        ''' append the test cases of a single package to the tree '''
        testcases = [edge.getNode2() for edge in (pkg->g.nodes)]
        testcases.sort(cmpTc)
        for tc in testcases:
            tcNode = DefaultMutableTreeNode(tc.label.split('::')[-1])
            pkgNode.add(tcNode)
            self.__appendCommands(tc, tcNode)
            self.__appendFixture(tc, tcNode)
            self.__appendHelpers(tc, tcNode)

    def __appendCaseMethodsHelper(self, case, caseNode, metaName, entityName):
        ''' helper for appendCommands, appendFixture & appendHelpers '''
        mtdMeta = DefaultMutableTreeNode(metaName)
        caseNode.add(mtdMeta)
        mtds = [edge.getNode2() for edge in case->(entity == entityName)]
        mtds.sort(cmpTc)
        for mtd in mtds:
            mtdNode = DefaultMutableTreeNode(mtd.label)
            mtdMeta.add(mtdNode)