Example usage for java.beans BeanInfo ICON_COLOR_16x16

List of usage examples for java.beans BeanInfo ICON_COLOR_16x16

Introduction

In this page you can find the example usage for java.beans BeanInfo ICON_COLOR_16x16.

Prototype

int ICON_COLOR_16x16

To view the source code for java.beans BeanInfo ICON_COLOR_16x16.

Click Source Link

Document

Constant to indicate a 16 x 16 color icon.

Usage

From source file:com.twinsoft.convertigo.engine.admin.services.database_objects.GetIcon.java

@Override
protected void writeResponseResult(HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServiceException {

    String className = request.getParameter("className");

    if (className == null || !className.startsWith("com.twinsoft.convertigo.beans"))
        throw new ServiceException("Must provide className parameter", null);

    try {//  ww  w  .j  ava  2s.  c  o m
        BeanInfo bi = CachedIntrospector
                .getBeanInfo(GenericUtils.<Class<? extends DatabaseObject>>cast(Class.forName(className)));
        IOUtils.copy(
                bi.getBeanDescriptor().getBeanClass()
                        .getResourceAsStream(MySimpleBeanInfo.getIconName(bi, BeanInfo.ICON_COLOR_16x16)),
                response.getOutputStream());
    } catch (Exception e) {
        throw new ServiceException("Icon unreachable", e);
    }

    Engine.logAdmin.info("The image has been exported");
}

From source file:com.twinsoft.convertigo.beans.core.MySimpleBeanInfo.java

@Override
public BeanDescriptor getBeanDescriptor() {
    BeanDescriptor beanDescriptor = new BeanDescriptor(beanClass, null);
    beanDescriptor.setDisplayName(displayName);
    beanDescriptor.setShortDescription(shortDescription);
    if (iconNameC16 != null) {
        beanDescriptor.setValue("icon" + BeanInfo.ICON_COLOR_16x16, iconNameC16);
    }/*from   w  w w  .j  a va2 s.co m*/
    if (iconNameC32 != null) {
        beanDescriptor.setValue("icon" + BeanInfo.ICON_COLOR_32x32, iconNameC32);
    }
    if (iconNameM16 != null) {
        beanDescriptor.setValue("icon" + BeanInfo.ICON_MONO_16x16, iconNameM16);
    }
    if (iconNameM32 != null) {
        beanDescriptor.setValue("icon" + BeanInfo.ICON_MONO_32x32, iconNameM32);
    }
    return beanDescriptor;
}

From source file:com.twinsoft.convertigo.eclipse.ConvertigoPlugin.java

private Image getDefaultBeanIcon(Class<?> beanClass, int iconKind) {
    String iconBaseName, iconType;

    if (Criteria.class.isAssignableFrom(beanClass)) {
        iconBaseName = "criteria";
    } else if (ExtractionRule.class.isAssignableFrom(beanClass)) {
        iconBaseName = "extractionrule";
    } else if (Transaction.class.isAssignableFrom(beanClass)) {
        iconBaseName = "transaction";
    } else if (BlockFactory.class.isAssignableFrom(beanClass)) {
        iconBaseName = "blockfactory";
    } else if (Project.class.isAssignableFrom(beanClass)) {
        iconBaseName = "project";
    } else if (ScreenClass.class.isAssignableFrom(beanClass)) {
        iconBaseName = "screenclass";
    } else if (Sheet.class.isAssignableFrom(beanClass)) {
        iconBaseName = "sheet";
    } else if (Pool.class.isAssignableFrom(beanClass)) {
        iconBaseName = "pool";
    } else {//from   w  w w  . ja  va 2 s. c  om
        iconBaseName = "default";
    }

    switch (iconKind) {
    case java.beans.BeanInfo.ICON_COLOR_16x16:
        iconType = "_color_16x16.png";
        break;
    default:
    case java.beans.BeanInfo.ICON_COLOR_32x32:
        iconType = "_color_32x32.png";
        break;
    case java.beans.BeanInfo.ICON_MONO_16x16:
        iconType = "_mono_16x16.png";
        break;
    case java.beans.BeanInfo.ICON_MONO_32x32:
        iconType = "_mono_32x32.png";
        break;
    }

    Image beanIcon = (Image) icons.get(iconBaseName + iconType);

    if (beanIcon == null) {
        ConvertigoPlugin.studioLog.debug("Getting default icon: " + iconBaseName + iconType);
        String iconName = "/com/twinsoft/convertigo/beans/core/images/" + iconBaseName + iconType;
        Device device = getDisplay();
        InputStream inputStream = ConvertigoPlugin.class.getResourceAsStream(iconName);
        beanIcon = new Image(device, inputStream);
        icons.put(iconBaseName + iconType, beanIcon);
    }

    return beanIcon;
}

From source file:org.eclipse.wb.internal.rcp.databinding.model.beans.bindables.BeanSupport.java

/**
 * @return {@link Image} represented given bean class.
 *//*from  w  w  w  .  j  a v a2 s . c  o m*/
public Image getBeanImage(Class<?> beanClass, ObjectInfo javaInfo) throws Exception {
    // check java info
    if (javaInfo != null) {
        return null;
    }
    // prepare cached image
    Image beanImage = m_classToImage.get(beanClass);
    // check load image
    if (beanImage == null) {
        try {
            // load AWT image
            BeanInfo beanInfo = Introspector.getBeanInfo(beanClass);
            java.awt.Image awtBeanIcon = beanInfo.getIcon(BeanInfo.ICON_COLOR_16x16);
            if (awtBeanIcon == null) {
                // set default
                beanImage = Activator.getImage("javabean.gif");
            } else {
                // convert to SWT image
                // FIXME: memory leak
                beanImage = ImageUtils.convertToSWT(awtBeanIcon);
            }
        } catch (Throwable e) {
            // set default
            beanImage = Activator.getImage("javabean.gif");
        }
        m_classToImage.put(beanClass, beanImage);
    }
    return beanImage;
}

From source file:org.eclipse.wb.internal.swing.databinding.model.beans.BeanSupport.java

/**
 * @return {@link Image} represented given bean class.
 *//*from www  .ja  v a 2 s .  c om*/
public Image getBeanImage(Class<?> beanClass, JavaInfo javaInfo, boolean useDefault) throws Exception {
    // check java info
    if (javaInfo != null) {
        return null;
    }
    // prepare cached image
    Image beanImage = m_classToImage.get(beanClass);
    // check load image
    if (beanImage == null) {
        try {
            // load AWT image
            BeanInfo beanInfo = Introspector.getBeanInfo(beanClass);
            java.awt.Image awtBeanIcon = beanInfo.getIcon(BeanInfo.ICON_COLOR_16x16);
            if (awtBeanIcon == null) {
                // set default
                beanImage = useDefault ? Activator.getImage("javabean.gif") : null;
            } else {
                // convert to SWT image
                // FIXME: memory leak
                beanImage = SwingImageUtils.convertImage_AWT_to_SWT(awtBeanIcon);
            }
        } catch (Throwable e) {
            // set default
            beanImage = useDefault ? Activator.getImage("javabean.gif") : null;
        }
        m_classToImage.put(beanClass, beanImage);
    }
    return beanImage;
}