Package com.nomagic.generictable
Class GenericTableManager
- java.lang.Object
-
- com.nomagic.generictable.GenericTableManager
-
@OpenApiAll public class GenericTableManager extends java.lang.Object
Helps manage a generic table: create a new table, add, get and remove rows, add and get columns, get column values, get currently selected elements.
-
-
Constructor Summary
Constructors Constructor Description GenericTableManager()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
addColumnsById(Diagram diagram, java.util.List<java.lang.String> columnIDs)
Adds generic table columns by idstatic void
addGenericTableToolbarConfigurator(DTConfigurator configurator)
Adds generic table toolbar configurator.static void
addRowElement(Diagram diagram, Element element)
Adds an element into generic table diagram as rowstatic Diagram
createGenericTable(Project project, java.lang.String genericTableDiagramName)
Creates generic table diagram in given project with given namestatic Property
getCellValue(Diagram diagram, Element element, java.lang.String columnId)
Returns cell value by row element and column id.static java.util.Map<Element,java.util.Map<java.lang.String,Property>>
getCellValues(Diagram diagram)
Returns all cell values by row element and column id.static java.lang.String
getColumnIDByPropertyName(java.lang.String propertyName)
Creates Column ID for table from property namestatic java.lang.String
getColumnIDByTag(java.lang.String tagName, Stereotype stereotype)
Creates Column ID for table from stereotype tag namestatic java.util.List<java.lang.String>
getColumnIds(Diagram diagram)
Returns column ids from a generic table diagramstatic java.lang.String
getColumnNameById(Diagram diagram, java.lang.String columnId)
Returns column name by id from a generic table diagramstatic java.util.List<java.lang.String>
getColumnNames(Diagram diagram)
Returns column names from a generic table diagramstatic java.util.List<java.lang.String>
getPossibleColumnIDs(Element type)
Returns all possible column ids for a generic table element typesstatic java.util.List<Element>
getRowElements(Diagram diagram)
Returns row elements of generic table diagramstatic java.util.Collection<Element>
getScope(Diagram diagram)
Gets the scope elements from the table.static java.util.List<Element>
getSelectedElements(Diagram diagram)
Gets currently selected elements from the diagram table.static java.util.List<java.lang.Object>
getTableElementTypes(Diagram diagram)
Return generic table diagram element typesstatic java.util.List<java.lang.String>
getVisibleColumnIds(Diagram diagram)
Returns visible column ids from a generic table diagram.static java.util.List<Element>
getVisibleRowElements(Diagram diagram)
Returns visible row elements of generic table diagram.static void
refreshTable(Diagram diagram)
Refresh diagram table.static void
registerToolbarActionsConfigurator(java.lang.String diagramType, AMConfigurator configurator)
Registers toolbar actions configurator.static void
removeRowElement(Diagram diagram, Element element)
Removes row element from a generic table diagramstatic void
setScope(Diagram diagram, java.util.Collection<Element> scope)
Sets the scope elements for the table.static void
setSelectedElements(Diagram diagram, java.util.List<Element> elements)
Selects rows which represent given model elements.static void
setTableElementTypes(Diagram diagram, java.util.List<java.lang.Object> tableElementTypes)
Sets generic table diagram element types Element types specify what elements can be added to table.
-
-
-
Method Detail
-
createGenericTable
public static Diagram createGenericTable(Project project, java.lang.String genericTableDiagramName) throws ReadOnlyElementException
Creates generic table diagram in given project with given name- Parameters:
project
- project in which to create generic table diagramgenericTableDiagramName
- generic table diagram name- Returns:
- created generic table diagram
- Throws:
ReadOnlyElementException
- if project is read only throws exception
-
setTableElementTypes
public static void setTableElementTypes(Diagram diagram, java.util.List<java.lang.Object> tableElementTypes)
Sets generic table diagram element types Element types specify what elements can be added to table. For example, if you specify only class element types, only class elements can be added to table.- Parameters:
diagram
- generic table diagram to set element typestableElementTypes
- object list with elements or classes, to use as table element types. Element types can be classes, metaclasses and stereotypes.- See Also:
getTableElementTypes(com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Diagram)
-
getTableElementTypes
public static java.util.List<java.lang.Object> getTableElementTypes(Diagram diagram)
Return generic table diagram element types- Parameters:
diagram
- generic table diagram for which to return element types- Returns:
- generic table diagram element types list of objects representing the element types
- See Also:
setTableElementTypes(com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Diagram, java.util.List)
-
addColumnsById
public static void addColumnsById(Diagram diagram, java.util.List<java.lang.String> columnIDs)
Adds generic table columns by id- Parameters:
diagram
- generic table diagram in which to add columnscolumnIDs
- column ids - column id's must be created usinggetColumnIDByPropertyName
,getColumnIDByTagName
- See Also:
getPossibleColumnIDs(com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element)
-
getPossibleColumnIDs
public static java.util.List<java.lang.String> getPossibleColumnIDs(Element type)
Returns all possible column ids for a generic table element types- Parameters:
type
- type of the element for which to get property IDs- Returns:
- property IDs of the given element type as list
- See Also:
addColumnsById(com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Diagram, java.util.List)
-
getCellValue
@CheckForNull public static Property getCellValue(Diagram diagram, Element element, java.lang.String columnId)
Returns cell value by row element and column id. To get all cell values usegetCellValues(Diagram)
.- Parameters:
diagram
- generic table diagram from which to get cell valueelement
- row element (used to find table row)columnId
- column id- Returns:
- if found - generic table cell value
Property
, else null - See Also:
getPossibleColumnIDs(com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element)
,addColumnsById(com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Diagram, java.util.List)
-
getCellValues
public static java.util.Map<Element,java.util.Map<java.lang.String,Property>> getCellValues(Diagram diagram)
Returns all cell values by row element and column id.- Parameters:
diagram
- table diagram from which to get cell values.- Returns:
- all cell values by row element and column id.
-
getColumnIds
public static java.util.List<java.lang.String> getColumnIds(Diagram diagram)
Returns column ids from a generic table diagram- Parameters:
diagram
- generic table diagram from which to get column ids- Returns:
- column ids as list
- See Also:
getVisibleColumnIds(com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Diagram)
,getPossibleColumnIDs(com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element)
,addColumnsById(com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Diagram, java.util.List)
-
getVisibleColumnIds
public static java.util.List<java.lang.String> getVisibleColumnIds(Diagram diagram)
Returns visible column ids from a generic table diagram.- Parameters:
diagram
- generic table diagram from which to get visible column ids.- Returns:
- column ids as list.
- See Also:
getColumnIds(com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Diagram)
,getPossibleColumnIDs(com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element)
,addColumnsById(com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Diagram, java.util.List)
-
getColumnNames
public static java.util.List<java.lang.String> getColumnNames(Diagram diagram)
Returns column names from a generic table diagram- Parameters:
diagram
- generic table diagram from which to get column names- Returns:
- If any columns found - list with column names, else - empty list
-
getColumnNameById
@CheckForNull public static java.lang.String getColumnNameById(Diagram diagram, java.lang.String columnId)
Returns column name by id from a generic table diagram- Parameters:
diagram
- generic table diagram to look for columncolumnId
- column id to look for- Returns:
- if found - column name, else null
- See Also:
addColumnsById(com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Diagram, java.util.List)
,getPossibleColumnIDs(com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element)
-
getRowElements
public static java.util.List<Element> getRowElements(Diagram diagram)
Returns row elements of generic table diagram- Parameters:
diagram
- generic table diagram to get rows from- Returns:
- if diagram has any rows - list of elements, else - empty list
- See Also:
addRowElement(com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Diagram, com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element)
,removeRowElement(com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Diagram, com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element)
-
getVisibleRowElements
public static java.util.List<Element> getVisibleRowElements(Diagram diagram)
Returns visible row elements of generic table diagram. Result will not contain elements of the rows which are not satisfied by the table filter.- Parameters:
diagram
- generic table diagram to get rows from- Returns:
- if diagram has visible rows - list of elements, else - empty list
- See Also:
addRowElement(com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Diagram, com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element)
,removeRowElement(com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Diagram, com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element)
-
addRowElement
public static void addRowElement(Diagram diagram, Element element)
Adds an element into generic table diagram as row- Parameters:
diagram
- generic table diagram to add element toelement
- element to add- See Also:
getRowElements(com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Diagram)
,removeRowElement(com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Diagram, com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element)
-
removeRowElement
public static void removeRowElement(Diagram diagram, Element element)
Removes row element from a generic table diagram- Parameters:
diagram
- generic table diagram from which to remove elementelement
- element to remove- See Also:
getRowElements(com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Diagram)
,addRowElement(com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Diagram, com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element)
-
registerToolbarActionsConfigurator
public static void registerToolbarActionsConfigurator(java.lang.String diagramType, AMConfigurator configurator)
Registers toolbar actions configurator.- Parameters:
diagramType
- diagram type.configurator
-DTConfigurator
.
-
getColumnIDByPropertyName
public static java.lang.String getColumnIDByPropertyName(java.lang.String propertyName)
Creates Column ID for table from property name- Parameters:
propertyName
- propertyName- Returns:
- Column ID
- See Also:
PropertyNames
-
getColumnIDByTag
public static java.lang.String getColumnIDByTag(java.lang.String tagName, Stereotype stereotype)
Creates Column ID for table from stereotype tag name- Parameters:
tagName
- tagName of stereotypestereotype
- stereotype- Returns:
- Column ID
-
addGenericTableToolbarConfigurator
public static void addGenericTableToolbarConfigurator(DTConfigurator configurator)
Adds generic table toolbar configurator. It allows to configure toolbar actions: add, remove, modify them.- Parameters:
configurator
- configurator to add.
-
getSelectedElements
public static java.util.List<Element> getSelectedElements(Diagram diagram)
Gets currently selected elements from the diagram table. If columns are sorted, the elements are sorted and returned as displayed in GUI. If generic table is not open, empty list is returned.- Parameters:
diagram
- diagram model element which represents the generic table.- Returns:
- currently selected elements in the generic table or empty list if diagram is not open.
-
setSelectedElements
public static void setSelectedElements(Diagram diagram, java.util.List<Element> elements)
Selects rows which represent given model elements.- Parameters:
diagram
- diagram model element which represents the generic table.elements
- model elements to select.
-
refreshTable
public static void refreshTable(Diagram diagram)
Refresh diagram table.- Parameters:
diagram
- diagram element which represents the table.
-
setScope
public static void setScope(Diagram diagram, java.util.Collection<Element> scope)
Sets the scope elements for the table.- Parameters:
diagram
- diagram element which represents the table, for which scope should be set.scope
- elements which should be set as the scope for table.
-
getScope
public static java.util.Collection<Element> getScope(Diagram diagram)
Gets the scope elements from the table.- Parameters:
diagram
- diagram element which represents the table, from which scope elements should be returned.- Returns:
- collection of all the elements that are set as scope for the table.
-
-