# Exposing properties of subcomponents in a custom component

**URL:** <https://forum.inductiveautomation.com/t/exposing-properties-of-subcomponents-in-a-custom-component/12588>\
**Category:** Module Development\
**Created:** [January 21, 2017, 8:20pm UTC](https://forum.inductiveautomation.com/t/exposing-properties-of-subcomponents-in-a-custom-component/12588 "2017-01-21T20:20:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![JimBranKelly1](https://avatars.discourse-cdn.com/v4/letter/j/7feea3/32.png) [@JimBranKelly1](https://forum.inductiveautomation.com/u/JimBranKelly1)\
**Post date:** [January 21, 2017, 8:20pm UTC](https://forum.inductiveautomation.com/t/exposing-properties-of-subcomponents-in-a-custom-component/12588/1 "2017-01-21T20:20:17Z")

</div>

Following code gives me a custom version of the TreeView component. If I don’t provide a TreeComponentBeanInfo Class, the new component works fine in the designer and client scopes and all the properties of the TreeView are correctly exposed.

```auto
public class TreeComponent extends PMITreeView {
    public TreeComponent() {
        super();
    }
}
```

If I provide the TreeComponentBeanInfo class, is there a way to get the TreeView properties exposed without having to individually specify bean style getters and setters in the class TreeComponent and then add them to the BeanInfo class?

---

<div class="post-metadata">

**Author:** ![JimBranKelly1](https://avatars.discourse-cdn.com/v4/letter/j/7feea3/32.png) [@JimBranKelly1](https://forum.inductiveautomation.com/u/JimBranKelly1)\
**Post date:** [January 22, 2017, 12:03am UTC](https://forum.inductiveautomation.com/t/exposing-properties-of-subcomponents-in-a-custom-component/12588/2 "2017-01-22T00:03:51Z")

</div>

A walk by Love Canal suggested an answer which seems to work:

```auto
public class ChartComponentBeanInfo extends PMIEasyChartBeanInfo {
    public ChartComponentBeanInfo() {
        //super(ChartComponent.class, DynamicPropertyProviderCustomizer.VALUE_DESCRIPTOR, StyleCustomizer.VALUE_DESCRIPTOR);
        super();
    }

    @Override
    protected void initProperties() throws IntrospectionException {
        super.initProperties();
        addProp("title", "Title", "The title of the chart", CAT_DATA, PREFERRED_MASK | BOUND_MASK);
    }
```

But as a lady in a small town in the interior of Brazil said to her husband about me: Esse gringo aqui fala muito bem, mas ele nao intende nada. In other words, I’m not sure where this might bite me.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [January 22, 2017, 12:37am UTC](https://forum.inductiveautomation.com/t/exposing-properties-of-subcomponents-in-a-custom-component/12588/3 "2017-01-22T00:37:05Z")

</div>

You can import PMITreeView’s beaninfo for your subclass. Here’s the BeanInfo code for the [NoteChart](https://www.automation-pros.com/modulesales.html) class for your edification, and likely pre-emption of your next question. (-:[code]/\* Filename: NoteChartBeanInfo.java

- Created on Jan 3, 2015
- Author: Phil Turmel [pturmel@automation-pros.com](mailto:pturmel@automation-pros.com)
- Copyright Automation Professionals, LLC 2015
- Project: NoteChart\_Designer  
\*/  
package com.automation\_pros.notechart.beaninfos;

import java.awt.Image;  
import java.beans.BeanDescriptor;  
import java.beans.BeanInfo;  
import java.beans.IntrospectionException;  
import java.beans.SimpleBeanInfo;

import javax.swing.ImageIcon;

import com.automation\_pros.notechart.components.NoteChart;  
import com.inductiveautomation.factorypmi.designer.beaninfo.PMIChartBeanInfo;  
import com.inductiveautomation.factorypmi.designer.property.customizers.ChartCustomizer;  
import com.inductiveautomation.vision.api.designer.beans.CommonBeanInfo;  
import com.inductiveautomation.vision.api.designer.beans.CustomizerDescriptor;  
import com.inductiveautomation.vision.api.designer.beans.VisionBeanDescriptor;

public class NoteChartBeanInfo extends CommonBeanInfo {

```
public NoteChartBeanInfo() {
	super(NoteChart.class, new CustomizerDescriptor[] {
		ChartCustomizer.VALUE_DESCRIPTOR });
	getBeanDescriptor().setValue("dbl-click-customizer", ChartCustomizer.VALUE_DESCRIPTOR.getValueName());
}

@Override
protected void initProperties() throws IntrospectionException {
	// Adds common properties
	super.initProperties();

	// Remove properties that NoteChart will define differently from CommonBeanInfo
	removeProp("opaque");

	// Add all notechart-specific properties
	addProp("notes", "Notes", "Dataset of text annotations to display",
			CAT_DATA, PREFERRED_MASK | BOUND_MASK);
	addProp("altNotes", "Alternate Notes", "Dataset of alternate annotations for live modifications",
			CAT_DATA, PREFERRED_MASK | BOUND_MASK);
	addProp("samples", "Pen Value Samples", "Dataset of pen values at the Trace timestamp (when visible)",
			CAT_DATA, PREFERRED_MASK | BOUND_MASK);
	addProp("traceTS", "Trace Timestamp", "Timestamp for the selected annotation, or independent trace if no selection",
			CAT_DATA, PREFERRED_MASK | BOUND_MASK);
	addProp("selectedNote", "Selected Note", "Row Number of the selected Note within the Notes dataset",
			CAT_DATA, PREFERRED_MASK | BOUND_MASK);
	addProp("selectedAltNote", "Selected Alternate Note", "Row Number of the selected Alternate Note within the Alternate Notes dataset",
			CAT_DATA, PREFERRED_MASK | BOUND_MASK);
	addProp("noteFont", "Annotation Font", "Font for all text annotations",
			CAT_APPEARANCE, PREFERRED_MASK);
	addProp("noteColor", "Annotation Color", "Color of text annotations that lack a specified color",
			CAT_APPEARANCE, NO_MASK);
	addProp("noteStroke", "Annotation Stroke", "Line Style for all unselected text annotations",
			CAT_APPEARANCE, EXPERT_MASK);
	addProp("selNoteColor", "Selected Annotation Color", "Color for a selected annotation",
			CAT_APPEARANCE, NO_MASK);
	addProp("selNoteStroke", "Selected Annotation Stroke", "Line Style for a selected annotation",
			CAT_APPEARANCE, EXPERT_MASK);
	addProp("prioThreshold", "Priority Threshold", "Maximum Number of Notes to Display without priority filtering",
			CAT_BEHAVIOR, EXPERT_MASK);
	addProp("enableNoteSelect", "Enable Note Selection", "Annotations can clicked (at their text) to set selectedNote or selectedAltNote",
			CAT_BEHAVIOR, EXPERT_MASK);

	/* Hide properties from PMIChart that NoteChart can't use. They
	 * would show up from getAdditionalBeanInfo().
	 */
	addProp("chartType", "Must be an XY Chart", "", CAT_BEHAVIOR, HIDDEN_MASK);
	addProp("subplotMode", "Must be Combined Domain", "", CAT_BEHAVIOR, HIDDEN_MASK);
}

@Override
public Image getIcon(int kind) {
	switch (kind) {
		case BeanInfo.ICON_COLOR_16x16:
		case BeanInfo.ICON_MONO_16x16:
			return new ImageIcon(getClass().getResource("/images/note-chart_16.png")).getImage();
		case SimpleBeanInfo.ICON_COLOR_32x32:
		case SimpleBeanInfo.ICON_MONO_32x32:
			return new ImageIcon(getClass().getResource("/images/note-chart_32.png")).getImage();
	}
	return null;
}

@Override
protected void initDesc() {
	VisionBeanDescriptor bean = getBeanDescriptor();
	bean.setName("Classic Note Chart");
	bean.setDisplayName("Classic Note Chart");
	bean.setShortDescription("A component that displays time-series Plots with annotation marks.");
	BeanInfo superbi = new PMIChartBeanInfo();
	BeanDescriptor superbean = superbi.getBeanDescriptor();
	bean.setValue("vision-extension-functions", superbean.getValue("vision-extension-functions"));
}

@Override
public BeanInfo[] getAdditionalBeanInfo() {
	BeanInfo[] superbi = { new PMIChartBeanInfo() };
	return superbi;
}

```

}[/code]

---

<div class="post-metadata">

**Author:** ![JimBranKelly1](https://avatars.discourse-cdn.com/v4/letter/j/7feea3/32.png) [@JimBranKelly1](https://forum.inductiveautomation.com/u/JimBranKelly1)\
**Post date:** [January 23, 2017, 5:57pm UTC](https://forum.inductiveautomation.com/t/exposing-properties-of-subcomponents-in-a-custom-component/12588/4 "2017-01-23T17:57:04Z")

</div>

😃 magic, thanks Phil.

The tag drop works on the client, but it doesn’t work in the designer. I’ll take it as an exercise to see if I can figure out why.
