private makeCard()

in subprojects/groovy-console/src/main/groovy/groovy/console/ui/ObjectBrowser.groovy [130:303]


    private makeCard(builder, inspector, String path) {
        builder.panel {
            borderLayout()
            panel(name: 'Class Info',
                    border: titledBorder('Class Info'),
                    constraints: NORTH) {
                flowLayout(alignment: FlowLayout.LEFT)
                def props = inspector.classProps.findAll { it != 'implements ' }
                try {
                    def module = inspector.object.class.module.name
                    if (module) props.add(0, "module ${module}")
                } catch(Exception ignore) {}

                final implementsPrefix = 'implements '
                def content = props.collect {
                    String p = it.trim()
                    if (p.startsWith(implementsPrefix)) {
                        return "${implementsPrefix}${p.substring(implementsPrefix.length()).replace(' ', ', ')}"
                    }
                    if (p.startsWith('is ')) {
                        return "(${p})"
                    }
                    return p
                }.join('\n').trim()

                for (def ln in (HIGHLIGHTED_TOKEN_TYPE_LIST.collect {
                                    VOCABULARY.getLiteralName(it)?.replace("'", '')
                                }.grep { it } + ['module', 'true', 'false'])) {
                    content = content.replaceAll(/\b(${ln})\b/, '<b>$1</b>')
                }
                content = content.replace('\n', '<br/>').replace(',', '<b>,</b>').replace(':', '<b>:</b>')
                def classLabel = "<html>${content}</html>"
                label(classLabel)
            }
            tabbedPane(constraints: CENTER) {
                if (inspector.object?.class?.array) {
                    scrollPane(name: ' Array data ') {
                        arrayTable = table(new CellValueToolTipJTable(), selectionMode: SINGLE_SELECTION) {
                            tableModel(list: inspector.object.toList().withIndex()) {
                                closureColumn(header: 'Index', read: { it[1] })
                                closureColumn(header: 'Value', read: { it[0] })
                                closureColumn(header: 'Raw Value', read: { it[0] })
                            }
                        }
                        arrayTable.columnModel.with {
                            getColumn(2).with {
                                minWidth = 0
                                maxWidth = 0
                                width = 0
                                preferredWidth = 0
                            }
                            getColumn(0).preferredWidth = 50
                            getColumn(1).preferredWidth = 400
                        }

                        arrayTable.addMouseListener(mouseListener(2) { row ->
                            path + "[${arrayTable.model.getValueAt(row, 0)}]"
                        })
                    }
                } else if (inspector.object instanceof Collection) {
                    scrollPane(name: ' Collection data ') {
                        collectionTable = table(new CellValueToolTipJTable(), selectionMode: SINGLE_SELECTION) {
                            tableModel(list: inspector.object.withIndex()) {
                                closureColumn(header: 'Index', read: { it[1] })
                                closureColumn(header: 'Value', read: { it[0] })
                                closureColumn(header: 'Raw Value', read: { it[0] })
                            }
                        }
                        collectionTable.columnModel.with {
                            getColumn(2).with {
                                minWidth = 0
                                maxWidth = 0
                                width = 0
                                preferredWidth = 0
                            }
                            getColumn(0).preferredWidth = 50
                            getColumn(1).preferredWidth = 400
                        }
                        collectionTable.addMouseListener(mouseListener(2) { row ->
                            path + "[${collectionTable.model.getValueAt(row, 0)}]"
                        })
                    }
                } else if (inspector.object instanceof Map) {
                    scrollPane(name: ' Map data ') {
                        mapTable = table(new CellValueToolTipJTable(), selectionMode: SINGLE_SELECTION) {
                            tableModel(list: inspector.object.entrySet().withIndex()) {
                                closureColumn(header: 'Index', read: { it[1] })
                                closureColumn(header: 'Key', read: { it[0].key })
                                closureColumn(header: 'Value', read: { it[0].value })
                                closureColumn(header: 'Raw Value', read: { it[0].value })
                            }
                        }
                        ToolTipManager.sharedInstance().registerComponent(mapTable)
                        mapTable.columnModel.with {
                            getColumn(3).with {
                                minWidth = 0
                                maxWidth = 0
                                width = 0
                                preferredWidth = 0
                            }
                            getColumn(0).preferredWidth = 50
                            getColumn(1).preferredWidth = 200
                            getColumn(2).preferredWidth = 400
                        }
                        mapTable.addMouseListener(mouseListener(2) { row ->
                            path + "[${mapTable.model.getValueAt(row, 1)}]"
                        })
                    }
                }
                scrollPane(name: ' Properties (includes public fields) ') {
                    def data = Inspector.sort(inspector.propertiesWithInfo.toList(), comparator)
                    fieldTable = table(new CellValueToolTipJTable(), selectionMode: SINGLE_SELECTION) {
                        tableModel(list: data) {
                            closureColumn(header: 'Name', read: { it.v2[MEMBER_NAME_IDX] })
                            closureColumn(header: 'Value', read: { it.v2[MEMBER_VALUE_IDX] })
                            closureColumn(header: 'Type', read: { it.v2[MEMBER_TYPE_IDX] })
                            closureColumn(header: 'Origin', read: { it.v2[MEMBER_ORIGIN_IDX] })
                            closureColumn(header: 'Modifier', read: { it.v2[MEMBER_MODIFIER_IDX] })
                            closureColumn(header: 'Declarer', read: { it.v2[MEMBER_DECLARER_IDX] })
                            closureColumn(header: 'Raw Value', read: { it.v1 })
                        }
                    }
                    fieldTable.columnModel.getColumn(6).with {
                        minWidth = 0
                        maxWidth = 0
                        width = 0
                    }
                    fieldTable.addMouseListener(mouseListener(6) { row ->
                        path + (path.size() == 0 ? '' : '.') + "${fieldTable.model.getValueAt(row, 0)}"
                    })
                }
                scrollPane(name: ' (Meta) Methods ') {
                    methodTable = table(new CellValueToolTipJTable(), selectionMode: SINGLE_SELECTION) {
                        def data = Inspector.sort(inspector.methodsWithInfo.toList(), comparator)
                        data.addAll(Inspector.sort(inspector.metaMethodsWithInfo.toList(), comparator))
                        tableModel(list: data) {
                            closureColumn(header: 'Name', read: { it.v2[MEMBER_NAME_IDX] })
                            closureColumn(header: 'Params', read: { it.v2[MEMBER_PARAMS_IDX] })
                            closureColumn(header: 'Type', read: { it.v2[MEMBER_TYPE_IDX] })
                            closureColumn(header: 'Origin', read: { it.v2[MEMBER_ORIGIN_IDX] })
                            closureColumn(header: 'Modifier', read: { it.v2[MEMBER_MODIFIER_IDX] })
                            closureColumn(header: 'Declarer', read: { it.v2[MEMBER_DECLARER_IDX] })
                            closureColumn(header: 'Exceptions', read: { it.v2[MEMBER_EXCEPTIONS_IDX] })
                            closureColumn(header: 'Raw Value', read: { it.v1 })
                        }
                    }
                    methodTable.columnModel.getColumn(7).with {
                        minWidth = 0
                        maxWidth = 0
                        width = 0
                    }
                    methodTable.addMouseListener(mouseListener(7) { row ->
                        path + (path.size() == 0 ? '' : ".method['") + "${methodTable.model.getValueAt(row, 0)}']"
                    })
                }
            }
            panel(name: 'Path',
                    border: emptyBorder([5, 10, 5, 10]),
                    constraints: SOUTH) {
                boxLayout(axis: 2)
                button(icon: imageIcon(resource: 'icons/resultset_previous.png', class: this),
                        margin: [5, 5, 5, 5] as Insets,
                        actionPerformed: { tracker.current--; show() },
                        enabled: bind { tracker.current > 0 })
                label('Path:  ')
                textField(editable: false, text: path)
                button(icon: imageIcon(resource: 'icons/resultset_next.png', class: this),
                        margin: [5, 5, 5, 5] as Insets,
                        actionPerformed: { tracker.current++; show() },
                        enabled: bind { tracker.current < pathCount - 1 }
                )
            }
        }
    }