Skip to content

Enhancements

Mykola Zakharchuk edited this page Jul 30, 2018 · 6 revisions

Table generation

The main feature of SBTabEditor is high extensibility of its components especially table views. End-user has the opportunity to enhance the editor with a new kind of tables in the shortest possible time. In the abstract sense, the editor implements MVC model for every single table. Each [M]model is defined using a separate wrapper class in which all the necessary fields are defined and certain checks can be made when initializing the fields. The process of reverse storage of changed information into the corresponding entity is defined in the wrapper.

Schematic system for generating tables can be seen in this diagram:

[!] To implement a new table user must define a new TableType that will match the name of the displayed item in the navigation pane(TreeItem). More information about you can find in TableType class description.

If the name of the new table is set correctly: when you click on the tree element with the appropriate name - new table of this type will be generated and shown. All the listed fields of the table correspond to those specified in the specific table factory. The data displayed in the table was obtained from the corresponding wrapper.

TreeItem lable name to TableType enum conversion is done in following getEnumFromString(Class<T> c, String string) method of SBTabTreeController:

	/**
	 * A common method for all enums since they can't have another base class
	 */
	public static <T extends Enum<T>> T getEnumFromString(Class<T> c, String string) {
		if (c != null && string != null) {
			try {
				return Enum.valueOf(c, string.trim().replaceAll(" ", "_").toUpperCase());
			} catch (IllegalArgumentException ex) {
				//
			}
		}
		return null;
	}

Menu bar

The simple menu bar can be created with help of SBTabMenuBar. The addMenuBarItem() method returns the decorated instance of the class, which makes it possible to proceed with the extension without any need to refer to the corresponding variable while adding new items to the menu bar. Final context can be retrieved with getContext() method.

Tabs generation

The process of generating tabs is relatively trivial. For a more detailed description see SBTabTabsComposer.