Example usage for javax.management.openmbean OpenType isArray

List of usage examples for javax.management.openmbean OpenType isArray

Introduction

In this page you can find the example usage for javax.management.openmbean OpenType isArray.

Prototype

boolean isArray

To view the source code for javax.management.openmbean OpenType isArray.

Click Source Link

Document

Tells if this type describes an array (checked in constructor).

Usage

From source file:org.wso2.andes.management.ui.views.ViewUtility.java

/**
 * Populates the given composite with the CompositeData. Creates required widgets to hold the data types
 * @param toolkit//from  ww w .  jav a 2 s. com
 * @param parent
 * @param data CompositeData
 */
@SuppressWarnings("unchecked")
private static void populateCompositeWithCompositeData(FormToolkit toolkit, Composite parent,
        CompositeData data) {
    Control[] oldControls = parent.getChildren();
    for (int i = 0; i < oldControls.length; i++) {
        oldControls[i].dispose();
    }

    Composite compositeHolder = toolkit.createComposite(parent, SWT.NONE);
    GridLayout layout = new GridLayout(4, false);
    layout.horizontalSpacing = 10;
    compositeHolder.setLayout(layout);
    compositeHolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    // ItemNames in composite data
    List<String> itemNames = new ArrayList<String>(data.getCompositeType().keySet());

    for (String itemName : itemNames) {
        OpenType itemType = data.getCompositeType().getType(itemName);
        Label keyLabel = toolkit.createLabel(compositeHolder, itemName, SWT.TRAIL);
        GridData layoutData = new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1);
        layoutData.minimumWidth = 70;
        keyLabel.setLayoutData(layoutData);

        if (itemType.isArray()) {
            OpenType type = ((ArrayType) itemType).getElementOpenType();
            //  If Byte array and mimetype is text, convert to text string
            if (type.getClassName().equals(Byte.class.getName())) {
                String mimeType = null;
                String encoding = null;
                if (data.containsKey("MimeType")) {
                    mimeType = (String) data.get("MimeType");
                }
                if (data.containsKey("Encoding")) {
                    encoding = (String) data.get("Encoding");
                }

                if (encoding == null || encoding.length() == 0) {
                    encoding = Charset.defaultCharset().name();
                }

                if ("text/plain".equals(mimeType)) {
                    convertByteArray(toolkit, compositeHolder, data, itemName, encoding);
                } else {
                    handleBinaryMessageContent(toolkit, compositeHolder, data, itemName, encoding);
                }
            }
            // If array of any other supported type, show as a list of String array
            else if (SUPPORTED_ARRAY_DATATYPES.contains(type.getClassName())) {
                convertArrayItemForDisplay(compositeHolder, data, itemName);
            } else {
                setNotSupportedDataType(toolkit, compositeHolder);
            }
        } else if (itemType instanceof TabularType) {
            Composite composite = toolkit.createComposite(compositeHolder, SWT.NONE);
            composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 3, 1));
            layout = new GridLayout();
            layout.marginHeight = 0;
            layout.marginWidth = 0;
            composite.setLayout(layout);
            createTabularDataHolder(toolkit, composite, (TabularDataSupport) data.get(itemName));
        } else {
            Text valueText = toolkit.createText(compositeHolder, String.valueOf(data.get(itemName)),
                    SWT.READ_ONLY | SWT.BORDER);
            valueText.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 3, 1));
        }
    }

    // layout the composite after creating new widgets.
    parent.layout();
}