The inheritance tab

Overview

The tutorial on element attributes offered an introduction to the inheritence mechanism of elements. It's clear that there isn't a limit on how long the inheritance chain can be , and for this reason can be difficult to determine which attributes are inherited, and where they are inherited from.

The Inheritance Tab

Most elements have an Inheritance tab, found in the Properties tab. In the Inheritance tab you can find the attributes of the selected element that can be inherited, and the inheritance hierarchy. It also displays the attributes of the styles in the hierarchy, as well as the inheritable default attributes. Each style in the hierarchy of the selected element are displayed with the attributes that can be inherited, the values of those attributes, the values that are inherited, and those that are overrided by other attributes. Overrided attributes are displayed with a black bar on them. The hierarchy is displayed from the upper level to the lower so in the top position there are the attributes of the selected element and in the bottom position there will be the default attributes. 

In the Figure above there is an example of one such Property tab. This is a default report template that comes with Jaspersoft Studio, called "Cherry" or "Cherry Landscape". In this report there are five styles defined, and no defined default style.

In this example the element "Cherry Title" is selected. In its Inheritance tab we can see the hierarchy.  From there we can see that element inherits only one style, called "Title". From the "Title" style, the attribute inherits other attributes: "Font Name", "Font Size", "Bold" and "Forecolor".  But "Bold" has a black bar on it, indicating that it is overrided by an attribute with the same name defined at an higher level. In fact, the "Bold" attribute is also defined directly by the selected element, and this instance of the attribute takes precedence over every other "Bold" attribute from a higher level. All the other attributes defined by the style "Title" are used to define the element "Cherry Title" because they aren't overridden by attributes with the same name on a higher level. At the bottom are visible the attributes inherited from the default values. The overrided attributes in this case are:

  • Font Name, defined by the style.
  • Bold, defined by the style and also by the element (so even if the element dosen't have a Bold attribute defined the one from the default values will be still overrided by the one in the style).
  • Font Size, defined by the style.
  • Forecolor, defined by the style.
  • Vertical alignement, defined by the element.

Using this tab makes it easy to see the hierarchy of an element and from which the attributes are inherited.

Removing an Attribute from the Hierarchy

Besides viewing the hierarchy, you can use the Inheritance tab for other things. From here, you can remove an attribute from the hierarchy. This can be done by clicking on the remove button, that appears on the left of every removable attribute when the mouse hovers over it. This is shown in the following figure.

Not all the attributes can be removed. Default attributes are those values inherited when any other value in hierarchy is undefined, so they can't be removed.

When you remove  an attribute, it is removed  from the element in which it is defined, and the value will be re-inherited from the next  level down where it is defined. 

Particular caution is needed when an attribute is removed from a style, because this dosen't influence only the selected element, but every element that use that style. Because of this when the user try to remove an attribute from a style a confirmation message is shown, informing on the possible side effects. Anyway when an attribute is removed the undo command (with the shourtcut Ctrl+Z) is aviable to restore it.

Feedback