close

Filter

loading table of contents...

Studio Developer Manual / Version 2201

Table Of Contents

9.27.6.2 Custom Columns

The Content Hub allows adding custom columns to the Studio library by implementing the interface ColumnProvider. The "Type" is always displayed as first column, regardless of any ColumnProvider.

Implementing ColumnProviders

By default, the Content Hub displays the columns "Type" and "Name". The "Name" Column is provided by a default ColumnModelProvider. In order to display custom columns you can add a ColumnModelProvider for your Adapter. This enables you to add Columns that show data in form of String, Date or Icon (with or without Text). The following code shows an example implementation for the CoreMedia adapter:

public class CoreMediaColumnModelProvider implements ColumnModelProvider {
  @Override
  public Boolean isApplicable(String factoryId) {
    return "coremedia".equals(factoryId);
  }

  @Override
  public List<Column> getColumns(Folder folder) {
    List<Column> columns = new ArrayList<>();
    //we should set at least one column to flex, so the collection view's width will be filled.
    columns.add(new DefaultAdapterColumn("name", "nameValue", 100, -1, false, false, false, true, false));
    columns.add(new DefaultAdapterColumn("name", "name", 150, -1));
    columns.add(new DefaultAdapterColumn("status", "status", 100, -1));
    return columns;
  }

  @Override
  public List<ColumnValue> getColumnValues(ContentHubObject hubObject) {
    //note that a folder or item may be passed here
    CoreMediaContentHubObject coreMediaEntity = (CoreMediaContentHubObject) hubObject;
    //the backing entity is content, so we don't have to care about the concrete type
    Content content = coreMediaEntity.getContent();

    List<ColumnValue> columnValues = new ArrayList<>();
    columnValues.add(new DefaultAdapterColumnValue("name", hubObject.getDisplayName(), null, null));
    columnValues.add(new DefaultAdapterColumnValue("status", getLifecycle(hubObject), null, null));

    return columnValues;
  }
}

Example 9.126. Defining a Custom ColumnModelProvider


The example adds two columns name and status, using the DefaultAdapterColumn class. The index for the column is set to '1' and '2' which ensures that the "name" column is located before the "status" column. It is also possible to set a width. However, there should be at least one column that has a flexValue set. This will ensure the columns will fill the width of the library.

The header of the column model can be localized through the properties file ContentHub_properties.ts:

<COLUMN_TITLE>_header : "<COLUMN_LABEL>"

If no matching label was found, the original title value will be used as fallback.

Search Results

Table Of Contents
warning

Your Internet Explorer is no longer supported.

Please use Mozilla Firefox, Google Chrome, or Microsoft Edge.