EMF table
Let’s create an EMF table based on a list of Person objects.
The key specificity of EMF tables is that each editable field must have a corresponding EMF feature assignment.
EMFTable<PersonEMF> table = Tables
.emf(peopleList)
.parent(parent)
.create();
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
.handler((person, string) -> {person.setName(string);})
.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 -> car == null ? "" : 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 -> car == null ? "" : 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 -> car == null ? "" : 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
.handler((person, value) -> {person.setIsPreferential(value);})
.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")
.format(Formats.getDefaultFormats()::dayMonthHoursMinutes)
.emfLocalDateTimeEditor()
.feature(DatamodelPackage.Literals.PERSON_EMF__PURCHASE_DATE) // corresponding EMF feature
.handler((person, date) -> {
person.setPurchaseDate(date);
table.refresh();
})
.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
.handler((person, time) -> {
person.setArriveTime(time);
table.refresh();
})
.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
.handler((person, color) -> {person.setFavouriteColor(color);})
.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. Distribution editor
Create a column for the Distribution
field type using the distributionEditor()
method.
Like all editors, this one supports marking fields as non-editable when needed.
table
.column(PersonEMF::getVisitDistribution)
.name("Visit distribution")
.distributionEditor()
.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
.build();

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")
)
.build();

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()
)
.build();
