public void setTarget()

in src/main/java/idea/plugin/psiviewer/view/PropertySheetPanel.java [42:87]


    public void setTarget(Object bean, @Nullable Runnable callback) {
        debug("setTarget=" + bean);
        setBackground(Color.WHITE);
        setVisible(false);
        setLayout(new BorderLayout(0, 0));
        removeAll();

        myTarget = bean;
        if (myTarget == null) return;

        ApplicationManager.getApplication().executeOnPooledThread(() -> {
            List<PropertyDescriptor> properties = getReadProperties();

            Object[][] tableData = new Object[properties.size()][2];
            Object[] columnTitles = new String[]{"Property", "Value"};

            Map<Object, String> map = new TreeMap<>(); // Guarantees ascending natural key sort order
            for (PropertyDescriptor property : properties) {
                String key = property.getDisplayName();
                String value = ReadAction.compute(() -> formattedToString(IntrospectionUtil.getValue(myTarget, property)));

                if (StringUtil.isNotEmpty(value) && StringUtil.startsWithIgnoreCase(value, "<html>")) {
                    value = "<html>" + XmlUtil.escape(value) + "</html>";
                }

                map.put(key, value);
            }

            int i = 0;
            for (Iterator<Map.Entry<Object, String>> it = map.entrySet().iterator(); it.hasNext(); i++) {
                Map.Entry<Object, String> entry = it.next();
                Object[] rowData = tableData[i];
                rowData[0] = entry.getKey();
                rowData[1] = entry.getValue();
            }

            ApplicationManager.getApplication().invokeLater(() -> {
                add(createTable(tableData, columnTitles));
                setVisible(true);
                if (callback != null) {
                    callback.run();
                }
            });
        });

    }