java类java.beans.DesignMode的实例源码

ComponentInfoFromBeanContext.java 文件源码 项目:incubator-netbeans 阅读 22 收藏 0 点赞 0 评论 0
static List<ComponentInfo> transform(List<? extends BeanContextChildComponentProxy> componentProxies) {
    try {
        Class.forName(ComponentInfo.class.getName(), true, ComponentInfo.class.getClassLoader()); // Initializes TRANSFORM
    } catch (ClassNotFoundException cnfex) {}
    List<ComponentInfo> cinfos = new ArrayList<ComponentInfo>(componentProxies.size());
    for (final BeanContextChildComponentProxy cp : componentProxies) {
        final Component[] c = new Component[] { null };
        final boolean[] doOpen = new boolean[] { false };
        try {
            SwingUtilities.invokeAndWait(new Runnable() {
                @Override
                public void run() {
                    c[0] = cp.getComponent();
                    doOpen[0] = (cp instanceof DesignMode) ? ((DesignMode) cp).isDesignTime() : true;
                }
            });
            if (c[0] == null) {
                //throw new NullPointerException("No component from "+cp);
                continue;
            }
        } catch (Exception ex) {
            Exceptions.printStackTrace(ex);
            continue;
        }
        //cs.add(c[0]);
        boolean open = doOpen[0];
        boolean minimized = false;
        if (c[0] instanceof TopComponent) {
            final TopComponent tc = (TopComponent) c[0];
            boolean wasClosed = Properties.getDefault().getProperties(DebuggerManagerListener.class.getName()).
                    getProperties(PROPERTY_CLOSED_TC).getBoolean(tc.getName(), false);
            boolean wasOpened = !Properties.getDefault().getProperties(DebuggerManagerListener.class.getName()).
                    getProperties(PROPERTY_CLOSED_TC).getBoolean(tc.getName(), true);
            open = (doOpen[0] && !wasClosed || !doOpen[0] && wasOpened);
            boolean wasMinimized = Properties.getDefault().getProperties(DebuggerManagerListener.class.getName()).
                    getProperties(PROPERTY_MINIMIZED_TC).getBoolean(tc.getName(), false);
            minimized = wasMinimized;
        }
        ComponentInfo ci = TRANSFORM.transform(c[0], open, minimized);
        cinfos.add(ci);
    }

    return cinfos;
}


问题


面经


文章

微信
公众号

扫码关注公众号