Package com.nomagic.generictable
Class GenericTableManager
java.lang.Object
com.nomagic.generictable.GenericTableManager
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
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
addColumnsById
(Diagram diagram, List<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, String genericTableDiagramName) Creates generic table diagram in given project with given namestatic Property
getCellValue
(Diagram diagram, Element element, String columnId) Returns cell value by row element and column id.getCellValues
(Diagram diagram) Returns all cell values by row element and column id.static String
getColumnIDByPropertyName
(String propertyName) Creates Column ID for table from property namestatic String
getColumnIDByTag
(String tagName, Stereotype stereotype) Creates Column ID for table from stereotype tag namegetColumnIds
(Diagram diagram) Returns column ids from a generic table diagramstatic String
getColumnNameById
(Diagram diagram, String columnId) Returns column name by id from a generic table diagramgetColumnNames
(Diagram diagram) Returns column names from a generic table diagramgetPossibleColumnIDs
(Element type) Returns all possible column ids for a generic table element typesgetRowElements
(Diagram diagram) Returns row elements of generic table diagramstatic Collection<Element>
Gets the scope elements from the table.getSelectedElements
(Diagram diagram) Gets currently selected elements from the diagram table.getTableElementTypes
(Diagram diagram) Return generic table diagram element typesgetVisibleColumnIds
(Diagram diagram) Returns visible column ids from a generic table diagram.getVisibleRowElements
(Diagram diagram) Returns visible row elements of generic table diagram.static void
refreshTable
(Diagram diagram) Refresh diagram table.static void
registerToolbarActionsConfigurator
(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, Collection<Element> scope) Sets the scope elements for the table.static void
setSelectedElements
(Diagram diagram, List<Element> elements) Selects rows which represent given model elements.static void
setTableElementTypes
(Diagram diagram, List<Object> tableElementTypes) Sets generic table diagram element types Element types specify what elements can be added to table.static void
waitForCellValuesLoad
(Diagram diagram) Waits until all cell values are loaded.
-
Constructor Details
-
GenericTableManager
public GenericTableManager()
-
-
Method Details
-
createGenericTable
public static Diagram createGenericTable(Project project, 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
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
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:
-
addColumnsById
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
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:
-
getCellValue
@CheckForNull public static Property getCellValue(Diagram diagram, Element element, 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:
-
getCellValues
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
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
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:
-
getColumnNames
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
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:
-
getRowElements
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:
-
getVisibleRowElements
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
Adds an element into generic table diagram as row- Parameters:
diagram
- generic table diagram to add element toelement
- element to add- See Also:
-
removeRowElement
Removes row element from a generic table diagram- Parameters:
diagram
- generic table diagram from which to remove elementelement
- element to remove- See Also:
-
registerToolbarActionsConfigurator
public static void registerToolbarActionsConfigurator(String diagramType, AMConfigurator configurator) Registers toolbar actions configurator.- Parameters:
diagramType
- diagram type.configurator
-DTConfigurator
.
-
getColumnIDByPropertyName
Creates Column ID for table from property name- Parameters:
propertyName
- propertyName- Returns:
- Column ID
- See Also:
-
getColumnIDByTag
Creates Column ID for table from stereotype tag name- Parameters:
tagName
- tagName of stereotypestereotype
- stereotype- Returns:
- Column ID
-
addGenericTableToolbarConfigurator
Adds generic table toolbar configurator. It allows to configure toolbar actions: add, remove, modify them.- Parameters:
configurator
- configurator to add.
-
getSelectedElements
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
Selects rows which represent given model elements.- Parameters:
diagram
- diagram model element which represents the generic table.elements
- model elements to select.
-
refreshTable
Refresh diagram table.- Parameters:
diagram
- diagram element which represents the table.
-
setScope
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
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.
-
waitForCellValuesLoad
public static void waitForCellValuesLoad(Diagram diagram) throws TimeoutException, InterruptedException Waits until all cell values are loaded.- Parameters:
diagram
- diagram element which represents the table, which values are loading.- Throws:
TimeoutException
- thrown when within specified time cell values loading tasks show no progress.InterruptedException
- thrown when thread is interrupted.
-