EMF table
The key specificity of EMF tables is that each editable field must have a corresponding EMF feature assignment.
EMFTable<PersonEMF> table = Tables
.emf(peopleList) // required! List objects shown in the table
.parent(parent) // required! Specifies the parent container where the table will be placed
.create();
As with read-only tables, all other configuration methods are optional and can be specified in any order. See the Creating a read-only table section for details.
Since EmfTable extends the base Table class, all methods covered in the Table class API overview section (selection handling, checkbox functionality, context menu, sorting, filtering, etc.) are also available for emf tables.
1. EMF text editor
The EMF text editor supports multiple value types, mirroring the functionality of the standard editable table text editor.
table
.column(PersonEMF::getName)
.name("Name")
.emfTextEditor()
.feature(DatamodelPackage.Literals.PERSON_EMF__NAME) // corresponding EMF feature
.strategy(ValidationStrategies.stringIsNotEmpty()) // validation strategy
.build();
2. EMF combo editor
A basic EMF combo editor is created as follows:
table
.column(PersonEMF::getMainCar)
.name("Car")
.format(car -> String.valueOf(car.getNumber()))
.emfComboEditor()
.elements(carsObservable)
.feature(DatamodelPackage.Literals.PERSON_EMF__MAIN_CAR) // corresponding EMF feature
.format(car -> String.valueOf(car.getNumber()))
.build();
A field can be marked non-editable. See also possible combo editor settings.
An auto-complete EMF combo editor allows selecting combo box elements using the "↓ Down" and "↑ Up" keys or pressing Ctrl+Space to open the dropdown list. See also possible combo editor settings.
table
.column(PersonEMF::getMainCar)
.name("Car")
.format(car -> String.valueOf(car.getNumber()))
.emfAutoCompleteComboEditor()
.elements(carsObservable)
.feature(DatamodelPackage.Literals.PERSON_EMF__MAIN_CAR) // corresponding EMF feature
.format(car -> String.valueOf(car.getNumber()))
.build();
A dynamic auto-complete EMF combo editor has similar specificity as dynamic auto complete combo editor of an editable table. A field can be marked non-editable. See also possible combo editor settings.
table
.column(PersonEMF::getMainCar)
.name("Car")
.format(car -> String.valueOf(car.getNumber()))
.emfDynamicAutoCompleteComboEditor()
.elements(carsObservable)
.feature(DatamodelPackage.Literals.PERSON_EMF__MAIN_CAR) // corresponding EMF feature
.format(car -> String.valueOf(car.getNumber()))
.build();
An enum combo editor is similar to other combo editor types. A field can be marked non-editable.
table
.column(PersonEMF::getCountry)
.name("Country")
.emfEnumComboEditor()
.elements(Country.values())
.feature(DatamodelPackage.Literals.PERSON_EMF__COUNTRY) // corresponding EMF feature
.format(Country::getName)
.build();
3. EMF auto complete text editor
It shares the same core behavior as the auto-complete text editor from editable tables. Like for all EMF editors, its field can be marked as non-editable when needed.
table
.column(PersonEMF::getMainCar)
.name("Car")
.format(car -> String.valueOf(car.getNumber()))
.emfAutoCompleteTextEditor()
.elements(carsObservable)
.feature(DatamodelPackage.Literals.PERSON_EMF__MAIN_CAR) // corresponding EMF feature
.format(car -> String.valueOf(car.getNumber()))
.build();
4. EMF checkbox editor
Create a checkbox column bound to a boolean field:
table
.column(PersonEMF::isIsPreferential)
.name("Preferential")
.emfCheckBoxEditor()
.feature(DatamodelPackage.Literals.PERSON_EMF__IS_PREFERENTIAL) // corresponding EMF feature
.build();
5. EMF date and time editor
Create a column with a date-time editor that works exclusively with the LocalDateTime class.
Amalgama Platform provides the Formats class. Its Formats.getDefaultFormats() method returns several standard formatters, including date-time formatters, currency formatters, and other unit measurements formatters based on the current locale. In the example below, dayMonthHoursMinutes formatter is used.
Additionally, you can mark a field as non-editable and customize the button appearance.
table
.column(PersonEMF::getPurchaseDate)
.name("Purchase date")
.emfLocalDateTimeEditor()
.feature(DatamodelPackage.Literals.PERSON_EMF__PURCHASE_DATE) // corresponding EMF feature
.build();
Editor of LocalTime shares all methods with the date-time editor.
Fields can be marked as non-editable and the button appearance can be customized.
See additional date/time settings for configuration options.
table
.column(PersonEMF::getArriveTime)
.name("Arrive time")
.emfLocalTimeEditor()
.feature(DatamodelPackage.Literals.PERSON_EMF__ARRIVE_TIME) // corresponding EMF feature
.build();
6. EMF color editor
Color editor column works with Color class.
A field can be marked non-editable.
table
.column(PersonEMF::getFavouriteColor)
.name("Favourite color")
.emfColorEditor()
.feature(DatamodelPackage.Literals.PERSON_EMF__FAVOURITE_COLOR) // corresponding EMF feature
.build();
7. Time series editor
Amalgama Library class TimeSeries represents a finite or potentially infinite ordered sequence of discrete instants in calendar time.
Use the timeSeriesEditor() method to create an editor for a field with such type.
A field can be marked non-editable.
table
.column(PersonEMF::getVisit)
.name("Visit time series")
.timeSeriesEditor()
.feature(DatamodelPackage.Literals.PERSON_EMF__VISIT) // corresponding EMF feature
.build();
8. RealDistribution editor
Create a column for the RealDistribution field type using the realDistributionEditor() method.
Like all editors, this one supports marking fields as non-editable when needed.
table
.column(PersonEMF::getVisitDistribution)
.name("Visit distribution")
.format(p -> Distributions.toString(p))
.realDistributionEditor()
.feature(DatamodelPackage.Literals.PERSON_EMF__VISIT_DISTRIBUTION) // corresponding EMF feature
.build();
9. EMF object selection dialog editor
emfObjectSelectionDialogEditor() provides functionality similar to that of object selection dialog editor in editable tables, supporting the same interaction patterns and selection mechanics.
table
.column(PersonEMF::getMainCar)
.name("Car")
.format(car -> String.valueOf(car.getNumber()))
.emfObjectSelectionDialogEditor()
.elements(carsObservable)
.columns(dialogTable -> dialogTable
.column(CarEMF::getNumber)
.name("Car number"))
.feature(DatamodelPackage.Literals.PERSON_EMF__MAIN_CAR) // corresponding EMF feature
.dialogTitle("Car selection dialog")
.dialogSubTitle("Select car and confirm selection")
.build();
Different columns() signatures:
.columns((person, dialogTable) -> {})
10. EMF multiple objects selection dialog editor
It has similar functionality as multiple objects selection dialog editor of editable tables.
table
.column(PersonEMF::getCars)
.name("Cars list")
.format(this::listAsString)
.<CarEMF>emfMultiObjectsSelectionDialogEditor()
.elements(carsObservable)
.feature(DatamodelPackage.Literals.PERSON_EMF__CARS) // corresponding EMF feature
.columns(dialogTable -> dialogTable
.column(CarEMF::getNumber)
.name("Car number")
)
.dialogTitle("Car selection dialog")
.dialogSubTitle("Select cars and confirm selection")
.build();
Different columns() signatures:
.columns((person, dialogTable) -> {})
11. EMF multiple tool list dialog editor
The EMF multiple tool list dialog editor mirrors the functionality of a standard multiple objects selection dialog, but with a key difference: it also enables dynamic creation of new list items rather than only selecting from existing elements. This requires column configuration to include a creation function passed as an argument to the creater() method.
table
.column(PersonEMF::getCars)
.name("Cars list")
.format(this::listAsString)
.<CarEMF>emfMultiToolListDialogEditor()
.creater(DatamodelFactory.eINSTANCE::createCarEMF) // datamodel method of creating new EMF object
.feature(DatamodelPackage.Literals.PERSON_EMF__CARS) // corresponding EMF feature
.columns(dialogTable -> dialogTable
.column(CarEMF::getNumber)
.name("Car number")
.emfTextEditor()
.feature(DatamodelPackage.Literals.CAR_EMF__NUMBER)
.strategy(ValidationStrategies.integerPositive())
.handler((car, number) -> car.setNumber(number))
.build()
)
.copyAction(car -> EcoreUtil.copy(car)) // datamodel method of coping EMF object
.dialogSize(500, 400)
.dialogTitle("Dialog for creating and editing cars")
.dialogSubTitle("Create and edit a cars and confirm selection")
.build();