Modeling tabular view columns
See the procedures on this page for modeling tabular view columns.
Prerequisites
The procedures for modeling tabular view columns described on this page can be used for modeling columns for predefined tabular view definitions, custom tabular view definitions, and individual tabular view usages. However, the following procedure, Redefining the inherited renderer, must be done in all cases.
Redefining the inherited renderer
To redefine the inherited renderer
- Ensure the package containing the view usage/definition for which you want to model columns imports KerML, SysML, and DS_Views packages.
package CustomTabularViews {
private import KerML::*;
private import SysML::*;
private import DS_Views::*;
} - Ensure the following steps are done based on whether you want to model table columns for a view usage or a custom view definition:
- For a view usage:
- The view is defined by the needed tabular view definition.
- The view has an expose relationship.
- (Optional) The view has filters.
- For a custom view definition:
- Ensure you have created the new view definition instance.
- For a view usage:
- Within the body of the view usage/definition, declare the keywords render rendering, (optionally) specify the name for the element, and do one of the following:
- Redefine the inherited asTable renderer. This applies to:
- View usages: views defined by predefined tabular view definitions.
- View definitions: new custom tabular view definitions created from scratch or those reusing predefined tabular view definitions.
All standard predefined tabular view definitions use the DS_Views::CoreViews::asTable renderer.
- Redefine the inherited renderer. This applies to:
- View usages: views defined by custom tabular view definitions.
- View definitions: new custom tabular view definitions that reuse custom-created tabular view definitions.
- Redefine the inherited asTable renderer. This applies to:
- Click the Synchronize button. Proceed to model table columns.
// ---------- view usages
// a view usage defined by a predefined tabular view definition:
view 'Drone Structure Table' : TabularViews::gt {
expose DroneStructure::**;
render rendering :>> asTable; // Generic Table has the rendering asTable
}
// a view usage defined by a custom tabular view definition:
view 'VCCU System Behavior Table' : 'System Behavior Table' {
expose DroneStructure::**;
render rendering :>> asNewTable1; // 'System Behavior Table' has the rendering asNewTable1, which redefines the asTable rendering
}
// ---------- view definitions
// a new view definition created from scratch:
view def 'System Behavior Table' :> CoreViews::bt {
render rendering asNewTable1 :>> asTable;
}
// a new view definition created by reusing a predefined view definition Generic Table:
view def 'System Components Taxonomy Table' :> TabularViews::gt {
render rendering asNewTable2 :>> asTable;
}
// a new view definition created by reusing a custom-created view definition 'System Behavior Table':
view def 'Variant Table' :> 'System Behavior Table' {
render rendering asNewTable3 :>> asNewTable1; // asNewTable3 redefines the 'System Behavior Table' view definition's asNewTable1 rendering, which itself redefines the Base Table view definition's asTable rendering
}
Modeling tabular view columns
Removing inherited table columns
To remove inherited table columns
- Ensure the inherited renderer is redefined.
- Within the body of the renderer, declare a view, redefine the column you want to remove, and set its multiplicity to zero.
The table columns that are inherited from the standard predefined tabular view definitions are indicated in the Tabular views table.
- Click the Synchronize button.
// ------ a view defined by a predefined tabular view:
view 'System Components Taxonomy Table' : TabularViews::gt {
expose DroneStructure::**;
render rendering :>> asTable {
view :>> 'Declared Short Name' [0]; // view redefines Declared Short Name inherited via Generic Table, specifying the redefining column's multiplicity to zero to remove it
}
}
// ------ a view defined by a custom tabular view:
view 'VCCU System Behavior Table' : 'System Behavior Table' {
expose DroneStructure::**;
render rendering :>> asNewTable1 {
view :>> 'Declared Short Name' [0]; // view redefines Declared Short Name inherited via 'System Behavior Table', specifying the redefining column's multiplicity to zero to remove it
}
}
Adding table columns
Adding table columns by feature
For more information, see the Column kinds table on the Tabular view columns page.
To add table columns by feature
- Within the body of the renderer, declare a view, specify the column name, define it by CoreViews::ColumnByFeatureView, and subset column.
- Within the column view's body, declare ref item, redefine columnFeature, and specify the expression for the targeted metadata feature.
- Click the Synchronize button.
view 'VCCU System Behavior Table' : 'System Behavior Table' {
expose DroneStructure::**;
render rendering :>> asNewTable1 {view 'Declared Name' : CoreViews::ColumnByFeatureView :> column { // new column
ref item :>> columnFeature = declaredName meta KerML::Core::Feature; // targets Declared Name
}view 'Declared Short Name' : CoreViews::ColumnByFeatureView :> column { // new column
ref item :>> columnFeature = declaredShortName meta KerML::Core::Feature; // targets Declared Short Name
}
view Documentation : CoreViews::ColumnByFeatureView :> column { // new column
ref item :>> columnFeature = documentation meta KerML::Core::Feature; // targets Documentation
}
view 'Qualified Name' : CoreViews::ColumnByFeatureView :> column { // new column
ref item :>> columnFeature = qualifiedName meta KerML::Core::Feature; // targets Qualified Name
}
view Owner : CoreViews::ColumnByFeatureView :> column { // new column
ref item :>> columnFeature = owner meta KerML::Core::Feature; // targets Owner
}
view 'Owned Element' : CoreViews::ColumnByFeatureView :> column { // new column
ref item :>> columnFeature = ownedElement meta KerML::Core::Feature; // targets for Owned Element
}
}
}// the following expressions are equivalent:
ref item :>> columnFeature = declaredShortName meta KerML::Core::Feature;
ref item :>> columnFeature = declaredShortName.metadata as KerML::Core::Feature;
Adding table columns by expression
For more information, see the Column kinds table on the Tabular view columns page.
To add table columns by expression
- Within the body of the renderer, declare a view, specify the element name, define it by CoreViews::ColumnByExpressionView, and subset column.
- Within the column view's body, declare the keywords render rendering, specify the name for the element, define it by the needed cell rendering definition, and subset CoreViews::asTableCell.
The available table cell rendering can be found in the CoreViews package.
rendering def BooleanCellRendering :> TableCellRendering;
rendering def ElementCellRendering :> TableCellRendering;
rendering def EnumCellRendering :> TableCellRendering;
rendering def IntegerCellRendering :> TableCellRendering;
rendering def MetaobjectCellRendering :> TableCellRendering;
rendering def RealCellRendering :> TableCellRendering;
rendering def StringCellRendering :> TableCellRendering;rendering def TableCellRendering {
calc getValue { in rowElement [0..1] : Metaobjects::Metaobject; }
attribute isMultiValued [0..1] : ScalarValues::Boolean;
} - Within the body of the rendering, declare a calculation and redefine getValue. Specify the in direction, redefine the rowElement. Specify the needed expression. See the example below.
- Click the Synchronize button.
view def 'Drone Structure Table' :> TabularViews::gt, SymbolicViewsByExpression::NonStandardLibraryElementFilter { // custom view definition reusing Generic Table
filter hastype SysML::Systems::PartDefinition | hastype SysML::Systems::PartUsage;
render rendering newTable :>> asTable { // redefining the inherited table rendering
view Weight : CoreViews::ColumnByExpressionView :> column { // new custom column Weight
render rendering asTableCell : CoreViews::RealCellRendering :> CoreViews::asTableCell { // specifying the table column's cell rendering as Real
calc :>> getValue {
in :>> rowElement : KerML::Root::Element;
if getWeight(rowElement) @KerML::Kernel::LiteralInteger ? (getWeight(rowElement) as KerML::Kernel::LiteralInteger).value else
(getWeight(rowElement) as KerML::Kernel::LiteralRational).value
}
calc getWeight {
in e : KerML::Root::Element;
(((e.ownedElement as SysML::Systems::AttributeUsage)->ControlFunctions::select {
in ee;
(ee as KerML::Root::Element).name == "weight"
} as SysML::Systems::AttributeUsage).ownedRelationship as KerML::Kernel::FeatureValue).value
}
}
}
}
}
Modifying table columns
Modifying table column attributes
To modify table column attributes
- (Conditional) For inherited columns, redefine the column whose attributes you want to modify.
- Within the column view's body, redefine the needed attribute and set its value.
Predefined column attributes are:
- isMultiline. Learn more >>
- Click the Synchronize button.
view 'VCCU System Behavior Table' : TabularViews::gt {
expose DroneStructure::**;
render rendering :>> asTable {
// new column
view 'Qualified Name' : CoreViews::ColumnByFeatureView :> column { // new column
attribute :>> isMultiline default true; // setting multiline to true to wrap long qualified name
ref item :>> columnFeature = qualifiedName meta KerML::Core::Feature; // targets Qualified Name
}
// redefining an inherited column
view :>> 'Qualified Name' { // redefining an inherited column
attribute :>> isMultiline default true; // setting multiline to true to wrap a long qualified name
}
}
}