SlideShare a Scribd company logo
1 of 19
Download to read offline
CONSTRUCCIÓN
DE INTERFACES
DE USUARIO
2do Cuatrimestre de 2018
4.1.
TRANSFORMERS
FILTERS
ADAPTERS
Problemas de Binding
@Accessors
@Observable
class TimeCounter {
int days
LocalDate now
LocalDate another
}
2
Modelo Vista
String
Problemas de Binding
3
Al querer bindear el input de la vista
con el atributo del modelo podemos
llegar a tener problemas
▶ De Model a View a veces funciona el
toString
▶ De View a Model explota por tipado
org.eclipse.cor
e.databinding -
0 - Could not
change value of
ar.unq.edu.ui.a
rena.ej_contado
r_dias.TimeCoun
ter@6850b758
.another
Java.lang.
IllegalArgument
Exception:
argument type
mismatch
¿Cómo se resuelve?
4
Utilizando un objeto que transforme:
▶ El objeto de modelo en String
▶ El String en objeto de modelo
O sea, un Transformer
Transformers ⇒ Definición
5
class DateTransformer implements ValueTransformer<LocalDate, String> {
override getModelType() { LocalDate }
override getViewType() { String }
override modelToView(LocalDate valueFromModel) {
valueFromModel.toString("dd/MM/yyyy")
}
override viewToModel(String valueFromView) {
try {
LocalDate.parse(
valueFromView,
DateTimeFormat.forPattern("dd/MM/yyyy")
)
} catch (IllegalArgumentException e) {
throw new UserException("Fecha incorrecta", e)
}
}
}
Transformers ⇒ Uso
6
class TimeCounterWindow extends MainWindow<TimeCounter> {
new(TimeCounter model) { ... }
static def void main(String[] arg) { ... }
override createContents(Panel mainPanel) {
this.title = "Días"
new ErrorsPanel(mainPanel, "Por ahora todo bien")
...
val datePanel = new Panel(mainPanel)
...
new Label(datePanel).text = "Ingresar Fecha:"
new TextBox(datePanel) => [
width = 80
(value <=> "another").transformer = new DateTransformer
// bindValueToProperty("another")
.setTransformer(new DateTransformer)
]
}
}
Transformers ⇒ Resultado
7
Problemas de Transformers
override viewToModel(String valueFromView) {
try {
LocalDate.parse(valueFromView, DateTimeFormat.forPattern("dd/MM/yyyy"))
} catch (IllegalArgumentException e) {
throw new UserException("Fecha incorrecta", e)
}
}
8
9
▶ Es necesario verificar que el valor a
transformar tengas las
características deseadas
▶ Si no cumple, ¿debería dar un valor
por defecto?
▶ El Transformer tiene más
responsabilidad de la necesaria
Problemas de Transformers
¿Cómo se resuelve?
10
Utilizando un objeto que filtre la
entrada, permitiendo exclusivamente
los valores correctos.
Filtros comunes:
▶ Sólo Números
▶ Sólo caracteres alfanuméricos
▶ Máximo X caracteres
▶ Etc...
Filters ⇒ Definición
11
class DateTextFilter implements TextFilter {
override accept(TextInputEvent event) {
val expected = new ArrayList(#[
"d", "d?", "/", "d", "d?", "/", "d{0,4}"
])
val regex = expected.reverse.fold("")[
result, element| '''(«element»«result»)?'''
]
event.potentialTextResult.matches(regex)
}
}
Regex Resultante
(d(d?(/(d(d?(/(d{0,4})?)?)?)?)?)?)?
01/12/2018
01/12/201
01/12/20
01/12/2
01/12/
01/12
01/1
01/
01
1
Filters ⇒ Uso
12
class DateBox extends TextBox {
new(Panel container) { super(container) }
override bindValueToProperty(String propertyName) {
val binding = super.bindValueToProperty(propertyName)
this.withFilter(new DateTextFilter)
binding
}
}
class TimeCounterWindow extends MainWindow<TimeCounter> {
...
override createContents(Panel mainPanel) {
...
new Label(datePanel).text = "Ingresar Fecha:"
new DateBox(datePanel).bindValueToProperty("another")
.setTransformer(new DateTransformer)
...
}
}
Filter + Transformer
13
No siempre se logra evitar el chequeo en el
Transformer
Manejo de Colecciones
14
Existen varios componentes que
permiten representar listados de datos:
▶ Selector (Dropdown)
▶ List
▶ Radio Selector
▶ Tables
Selectors
15
Adapters ⇒ Selectors
16
override createContents(Panel mainPanel) {
this.title = "Data"
mainPanel.layout = new HorizontalLayout
new List(mainPanel) => [
(items <=> "products")
.adaptWith(Product, "description")
]
new Panel(mainPanel) => [
new Selector<Product>(it) => [
(items <=> "products")
.adaptWith(Product, "description")
]
new Panel(it) => [
new RadioSelector<Product>(it) => [
(items <=> "products")
.adaptWith(Product, "description")
]]]
}
@Accessors
@Observable
class Product {
String name
int price
new(String name, int price) {
this.name = name
this.price = price
}
def description() {
'''«name» ($«price»)'''
}
}
Tablas
17
Tables ⇒ Columns
18
override createContents(Panel mainPanel) {
this.title = "Unquify"
val gridSongs = new Table(mainPanel, typeof(Song)) => [
numberVisibleRows = 5
items <=> "filterSongs"
]
new Column<Song>(gridSongs) => [
title = "Titulo"
bindContentsToProperty("name")
fixedSize = 200
]
new Column<Song>(gridSongs) => [
title = "Duración"
bindContentsToProperty("durationDescrip")
fixedSize = 150
]
}
Adapters + Lists ⇒ Demo
19

More Related Content

What's hot

JavaScript objects and functions
JavaScript objects and functionsJavaScript objects and functions
JavaScript objects and functionsVictor Verhaagen
 
Lecture 2, c++(complete reference,herbet sheidt)chapter-12
Lecture 2, c++(complete reference,herbet sheidt)chapter-12Lecture 2, c++(complete reference,herbet sheidt)chapter-12
Lecture 2, c++(complete reference,herbet sheidt)chapter-12Abu Saleh
 
Class object method constructors in java
Class object method constructors in javaClass object method constructors in java
Class object method constructors in javaRaja Sekhar
 
Core Java Programming Language (JSE) : Chapter VI - Class Design
Core Java Programming Language (JSE) : Chapter VI - Class DesignCore Java Programming Language (JSE) : Chapter VI - Class Design
Core Java Programming Language (JSE) : Chapter VI - Class DesignWebStackAcademy
 
JavaScript Getting Started
JavaScript Getting StartedJavaScript Getting Started
JavaScript Getting StartedHazem Hagrass
 
Constructor and Destructor
Constructor and DestructorConstructor and Destructor
Constructor and DestructorKamal Acharya
 
An Overview of the Java Programming Language
An Overview of the Java Programming LanguageAn Overview of the Java Programming Language
An Overview of the Java Programming LanguageSalaam Kehinde
 
constructor and destructor
constructor and destructorconstructor and destructor
constructor and destructorVENNILAV6
 
Macros excel contar celdas de color
Macros excel contar celdas de  colorMacros excel contar celdas de  color
Macros excel contar celdas de colorVeronica Marquez
 
Type casting in java
Type casting in javaType casting in java
Type casting in javaFarooq Baloch
 
Constructor and Types of Constructors
Constructor and Types of ConstructorsConstructor and Types of Constructors
Constructor and Types of ConstructorsDhrumil Panchal
 

What's hot (20)

Javascript ch7
Javascript ch7Javascript ch7
Javascript ch7
 
JavaScript objects and functions
JavaScript objects and functionsJavaScript objects and functions
JavaScript objects and functions
 
Lecture 2, c++(complete reference,herbet sheidt)chapter-12
Lecture 2, c++(complete reference,herbet sheidt)chapter-12Lecture 2, c++(complete reference,herbet sheidt)chapter-12
Lecture 2, c++(complete reference,herbet sheidt)chapter-12
 
Class object method constructors in java
Class object method constructors in javaClass object method constructors in java
Class object method constructors in java
 
C++Constructors
C++ConstructorsC++Constructors
C++Constructors
 
Core Java Programming Language (JSE) : Chapter VI - Class Design
Core Java Programming Language (JSE) : Chapter VI - Class DesignCore Java Programming Language (JSE) : Chapter VI - Class Design
Core Java Programming Language (JSE) : Chapter VI - Class Design
 
Constructor ppt
Constructor pptConstructor ppt
Constructor ppt
 
Constructors and Destructors
Constructors and DestructorsConstructors and Destructors
Constructors and Destructors
 
JavaScript Getting Started
JavaScript Getting StartedJavaScript Getting Started
JavaScript Getting Started
 
Design pattern in action
Design pattern in actionDesign pattern in action
Design pattern in action
 
Constructor and Destructor
Constructor and DestructorConstructor and Destructor
Constructor and Destructor
 
mediator
mediatormediator
mediator
 
An Overview of the Java Programming Language
An Overview of the Java Programming LanguageAn Overview of the Java Programming Language
An Overview of the Java Programming Language
 
Constructor and destructor
Constructor  and  destructor Constructor  and  destructor
Constructor and destructor
 
constructor and destructor
constructor and destructorconstructor and destructor
constructor and destructor
 
Java constructors
Java constructorsJava constructors
Java constructors
 
Constructors
ConstructorsConstructors
Constructors
 
Macros excel contar celdas de color
Macros excel contar celdas de  colorMacros excel contar celdas de  color
Macros excel contar celdas de color
 
Type casting in java
Type casting in javaType casting in java
Type casting in java
 
Constructor and Types of Constructors
Constructor and Types of ConstructorsConstructor and Types of Constructors
Constructor and Types of Constructors
 

Similar to 4.trasformers filters-adapters

NDC 2011, C++ 프로그래머를 위한 C#
NDC 2011, C++ 프로그래머를 위한 C#NDC 2011, C++ 프로그래머를 위한 C#
NDC 2011, C++ 프로그래머를 위한 C#tcaesvk
 
C++ Generators and Property-based Testing
C++ Generators and Property-based TestingC++ Generators and Property-based Testing
C++ Generators and Property-based TestingSumant Tambe
 
Generics in .NET, C++ and Java
Generics in .NET, C++ and JavaGenerics in .NET, C++ and Java
Generics in .NET, C++ and JavaSasha Goldshtein
 
Alexander Makarov "Let’s talk about code"
Alexander Makarov "Let’s talk about code"Alexander Makarov "Let’s talk about code"
Alexander Makarov "Let’s talk about code"Fwdays
 
Back-2-Basics: .NET Coding Standards For The Real World (2011)
Back-2-Basics: .NET Coding Standards For The Real World (2011)Back-2-Basics: .NET Coding Standards For The Real World (2011)
Back-2-Basics: .NET Coding Standards For The Real World (2011)David McCarter
 
Visual studio 2008
Visual studio 2008Visual studio 2008
Visual studio 2008Luis Enrique
 
Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...
Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...
Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...Jitendra Bafna
 
Introduction to Spring MVC
Introduction to Spring MVCIntroduction to Spring MVC
Introduction to Spring MVCRichard Paul
 
Introduction to Client-Side Javascript
Introduction to Client-Side JavascriptIntroduction to Client-Side Javascript
Introduction to Client-Side JavascriptJulie Iskander
 
Clean code _v2003
 Clean code _v2003 Clean code _v2003
Clean code _v2003R696
 
DITEC - Programming with C#.NET
DITEC - Programming with C#.NETDITEC - Programming with C#.NET
DITEC - Programming with C#.NETRasan Samarasinghe
 
Core2 Document - Java SCORE Overview.pptx.pdf
Core2 Document - Java SCORE Overview.pptx.pdfCore2 Document - Java SCORE Overview.pptx.pdf
Core2 Document - Java SCORE Overview.pptx.pdfThchTrngGia
 
Java 5 6 Generics, Concurrency, Garbage Collection, Tuning
Java 5 6 Generics, Concurrency, Garbage Collection, TuningJava 5 6 Generics, Concurrency, Garbage Collection, Tuning
Java 5 6 Generics, Concurrency, Garbage Collection, TuningCarol McDonald
 
.Net Classes and Objects | UiPath Community
.Net Classes and Objects | UiPath Community.Net Classes and Objects | UiPath Community
.Net Classes and Objects | UiPath CommunityRohit Radhakrishnan
 

Similar to 4.trasformers filters-adapters (20)

NDC 2011, C++ 프로그래머를 위한 C#
NDC 2011, C++ 프로그래머를 위한 C#NDC 2011, C++ 프로그래머를 위한 C#
NDC 2011, C++ 프로그래머를 위한 C#
 
WD programs descriptions.docx
WD programs descriptions.docxWD programs descriptions.docx
WD programs descriptions.docx
 
Java Generics
Java GenericsJava Generics
Java Generics
 
C++ Generators and Property-based Testing
C++ Generators and Property-based TestingC++ Generators and Property-based Testing
C++ Generators and Property-based Testing
 
Generics in .NET, C++ and Java
Generics in .NET, C++ and JavaGenerics in .NET, C++ and Java
Generics in .NET, C++ and Java
 
Eugene Burmako
Eugene BurmakoEugene Burmako
Eugene Burmako
 
Alexander Makarov "Let’s talk about code"
Alexander Makarov "Let’s talk about code"Alexander Makarov "Let’s talk about code"
Alexander Makarov "Let’s talk about code"
 
Back-2-Basics: .NET Coding Standards For The Real World (2011)
Back-2-Basics: .NET Coding Standards For The Real World (2011)Back-2-Basics: .NET Coding Standards For The Real World (2011)
Back-2-Basics: .NET Coding Standards For The Real World (2011)
 
Visual studio 2008
Visual studio 2008Visual studio 2008
Visual studio 2008
 
Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...
Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...
Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...
 
Introduction to Spring MVC
Introduction to Spring MVCIntroduction to Spring MVC
Introduction to Spring MVC
 
Java Lab Manual
Java Lab ManualJava Lab Manual
Java Lab Manual
 
Presentation_1370675757603
Presentation_1370675757603Presentation_1370675757603
Presentation_1370675757603
 
Introduction to Client-Side Javascript
Introduction to Client-Side JavascriptIntroduction to Client-Side Javascript
Introduction to Client-Side Javascript
 
Clean code _v2003
 Clean code _v2003 Clean code _v2003
Clean code _v2003
 
DITEC - Programming with C#.NET
DITEC - Programming with C#.NETDITEC - Programming with C#.NET
DITEC - Programming with C#.NET
 
Diifeerences In C#
Diifeerences In C#Diifeerences In C#
Diifeerences In C#
 
Core2 Document - Java SCORE Overview.pptx.pdf
Core2 Document - Java SCORE Overview.pptx.pdfCore2 Document - Java SCORE Overview.pptx.pdf
Core2 Document - Java SCORE Overview.pptx.pdf
 
Java 5 6 Generics, Concurrency, Garbage Collection, Tuning
Java 5 6 Generics, Concurrency, Garbage Collection, TuningJava 5 6 Generics, Concurrency, Garbage Collection, Tuning
Java 5 6 Generics, Concurrency, Garbage Collection, Tuning
 
.Net Classes and Objects | UiPath Community
.Net Classes and Objects | UiPath Community.Net Classes and Objects | UiPath Community
.Net Classes and Objects | UiPath Community
 

More from xavazque2

258939538 dumping
258939538 dumping258939538 dumping
258939538 dumpingxavazque2
 
380914324 poo-kotlin
380914324 poo-kotlin380914324 poo-kotlin
380914324 poo-kotlinxavazque2
 
146817358 android
146817358 android146817358 android
146817358 androidxavazque2
 
Curso profesional-de-desarrollo-de-aplicaciones-android-con-kotlin
Curso profesional-de-desarrollo-de-aplicaciones-android-con-kotlinCurso profesional-de-desarrollo-de-aplicaciones-android-con-kotlin
Curso profesional-de-desarrollo-de-aplicaciones-android-con-kotlinxavazque2
 
364196144 hogan-pensamiento-no-verbal-comunicacion-y-juego
364196144 hogan-pensamiento-no-verbal-comunicacion-y-juego364196144 hogan-pensamiento-no-verbal-comunicacion-y-juego
364196144 hogan-pensamiento-no-verbal-comunicacion-y-juegoxavazque2
 
325940441 motion-ui
325940441 motion-ui325940441 motion-ui
325940441 motion-uixavazque2
 
371081023 curso-desarrollo-android
371081023 curso-desarrollo-android371081023 curso-desarrollo-android
371081023 curso-desarrollo-androidxavazque2
 
4.1. validaciones-y-excepciones
4.1. validaciones-y-excepciones4.1. validaciones-y-excepciones
4.1. validaciones-y-excepcionesxavazque2
 
3.1 mvc-mvvm-app model-binding
3.1 mvc-mvvm-app model-binding3.1 mvc-mvvm-app model-binding
3.1 mvc-mvvm-app model-bindingxavazque2
 
5.1. stateles stateful-protocolo_http
5.1. stateles stateful-protocolo_http5.1. stateles stateful-protocolo_http
5.1. stateles stateful-protocolo_httpxavazque2
 
435338801 programacion-mobile-android
435338801 programacion-mobile-android435338801 programacion-mobile-android
435338801 programacion-mobile-androidxavazque2
 
457126889 android-pdf
457126889 android-pdf457126889 android-pdf
457126889 android-pdfxavazque2
 
266521557 apuntes-unidad-formativa-app-inventor
266521557 apuntes-unidad-formativa-app-inventor266521557 apuntes-unidad-formativa-app-inventor
266521557 apuntes-unidad-formativa-app-inventorxavazque2
 
7. react js-1
7. react js-17. react js-1
7. react js-1xavazque2
 
484719815 pidiendo-ayuda-a-los-angeles-pdf
484719815 pidiendo-ayuda-a-los-angeles-pdf484719815 pidiendo-ayuda-a-los-angeles-pdf
484719815 pidiendo-ayuda-a-los-angeles-pdfxavazque2
 
484717855 transmutacion-de-energias-pdf
484717855 transmutacion-de-energias-pdf484717855 transmutacion-de-energias-pdf
484717855 transmutacion-de-energias-pdfxavazque2
 
2.1. arena-y-binding
2.1. arena-y-binding2.1. arena-y-binding
2.1. arena-y-bindingxavazque2
 

More from xavazque2 (20)

258939538 dumping
258939538 dumping258939538 dumping
258939538 dumping
 
380914324 poo-kotlin
380914324 poo-kotlin380914324 poo-kotlin
380914324 poo-kotlin
 
146817358 android
146817358 android146817358 android
146817358 android
 
Curso profesional-de-desarrollo-de-aplicaciones-android-con-kotlin
Curso profesional-de-desarrollo-de-aplicaciones-android-con-kotlinCurso profesional-de-desarrollo-de-aplicaciones-android-con-kotlin
Curso profesional-de-desarrollo-de-aplicaciones-android-con-kotlin
 
364196144 hogan-pensamiento-no-verbal-comunicacion-y-juego
364196144 hogan-pensamiento-no-verbal-comunicacion-y-juego364196144 hogan-pensamiento-no-verbal-comunicacion-y-juego
364196144 hogan-pensamiento-no-verbal-comunicacion-y-juego
 
325940441 motion-ui
325940441 motion-ui325940441 motion-ui
325940441 motion-ui
 
371081023 curso-desarrollo-android
371081023 curso-desarrollo-android371081023 curso-desarrollo-android
371081023 curso-desarrollo-android
 
4.1. validaciones-y-excepciones
4.1. validaciones-y-excepciones4.1. validaciones-y-excepciones
4.1. validaciones-y-excepciones
 
3.1 mvc-mvvm-app model-binding
3.1 mvc-mvvm-app model-binding3.1 mvc-mvvm-app model-binding
3.1 mvc-mvvm-app model-binding
 
5.1. stateles stateful-protocolo_http
5.1. stateles stateful-protocolo_http5.1. stateles stateful-protocolo_http
5.1. stateles stateful-protocolo_http
 
435338801 programacion-mobile-android
435338801 programacion-mobile-android435338801 programacion-mobile-android
435338801 programacion-mobile-android
 
457126889 android-pdf
457126889 android-pdf457126889 android-pdf
457126889 android-pdf
 
266521557 apuntes-unidad-formativa-app-inventor
266521557 apuntes-unidad-formativa-app-inventor266521557 apuntes-unidad-formativa-app-inventor
266521557 apuntes-unidad-formativa-app-inventor
 
7. react js-1
7. react js-17. react js-1
7. react js-1
 
Tp1
Tp1Tp1
Tp1
 
484719815 pidiendo-ayuda-a-los-angeles-pdf
484719815 pidiendo-ayuda-a-los-angeles-pdf484719815 pidiendo-ayuda-a-los-angeles-pdf
484719815 pidiendo-ayuda-a-los-angeles-pdf
 
484717855 transmutacion-de-energias-pdf
484717855 transmutacion-de-energias-pdf484717855 transmutacion-de-energias-pdf
484717855 transmutacion-de-energias-pdf
 
5.layouts
5.layouts5.layouts
5.layouts
 
6.2. js
6.2. js6.2. js
6.2. js
 
2.1. arena-y-binding
2.1. arena-y-binding2.1. arena-y-binding
2.1. arena-y-binding
 

Recently uploaded

Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdfChristopherTHyatt
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 

Recently uploaded (20)

Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 

4.trasformers filters-adapters

  • 1. CONSTRUCCIÓN DE INTERFACES DE USUARIO 2do Cuatrimestre de 2018 4.1. TRANSFORMERS FILTERS ADAPTERS
  • 2. Problemas de Binding @Accessors @Observable class TimeCounter { int days LocalDate now LocalDate another } 2 Modelo Vista String
  • 3. Problemas de Binding 3 Al querer bindear el input de la vista con el atributo del modelo podemos llegar a tener problemas ▶ De Model a View a veces funciona el toString ▶ De View a Model explota por tipado org.eclipse.cor e.databinding - 0 - Could not change value of ar.unq.edu.ui.a rena.ej_contado r_dias.TimeCoun ter@6850b758 .another Java.lang. IllegalArgument Exception: argument type mismatch
  • 4. ¿Cómo se resuelve? 4 Utilizando un objeto que transforme: ▶ El objeto de modelo en String ▶ El String en objeto de modelo O sea, un Transformer
  • 5. Transformers ⇒ Definición 5 class DateTransformer implements ValueTransformer<LocalDate, String> { override getModelType() { LocalDate } override getViewType() { String } override modelToView(LocalDate valueFromModel) { valueFromModel.toString("dd/MM/yyyy") } override viewToModel(String valueFromView) { try { LocalDate.parse( valueFromView, DateTimeFormat.forPattern("dd/MM/yyyy") ) } catch (IllegalArgumentException e) { throw new UserException("Fecha incorrecta", e) } } }
  • 6. Transformers ⇒ Uso 6 class TimeCounterWindow extends MainWindow<TimeCounter> { new(TimeCounter model) { ... } static def void main(String[] arg) { ... } override createContents(Panel mainPanel) { this.title = "Días" new ErrorsPanel(mainPanel, "Por ahora todo bien") ... val datePanel = new Panel(mainPanel) ... new Label(datePanel).text = "Ingresar Fecha:" new TextBox(datePanel) => [ width = 80 (value <=> "another").transformer = new DateTransformer // bindValueToProperty("another") .setTransformer(new DateTransformer) ] } }
  • 8. Problemas de Transformers override viewToModel(String valueFromView) { try { LocalDate.parse(valueFromView, DateTimeFormat.forPattern("dd/MM/yyyy")) } catch (IllegalArgumentException e) { throw new UserException("Fecha incorrecta", e) } } 8
  • 9. 9 ▶ Es necesario verificar que el valor a transformar tengas las características deseadas ▶ Si no cumple, ¿debería dar un valor por defecto? ▶ El Transformer tiene más responsabilidad de la necesaria Problemas de Transformers
  • 10. ¿Cómo se resuelve? 10 Utilizando un objeto que filtre la entrada, permitiendo exclusivamente los valores correctos. Filtros comunes: ▶ Sólo Números ▶ Sólo caracteres alfanuméricos ▶ Máximo X caracteres ▶ Etc...
  • 11. Filters ⇒ Definición 11 class DateTextFilter implements TextFilter { override accept(TextInputEvent event) { val expected = new ArrayList(#[ "d", "d?", "/", "d", "d?", "/", "d{0,4}" ]) val regex = expected.reverse.fold("")[ result, element| '''(«element»«result»)?''' ] event.potentialTextResult.matches(regex) } } Regex Resultante (d(d?(/(d(d?(/(d{0,4})?)?)?)?)?)?)? 01/12/2018 01/12/201 01/12/20 01/12/2 01/12/ 01/12 01/1 01/ 01 1
  • 12. Filters ⇒ Uso 12 class DateBox extends TextBox { new(Panel container) { super(container) } override bindValueToProperty(String propertyName) { val binding = super.bindValueToProperty(propertyName) this.withFilter(new DateTextFilter) binding } } class TimeCounterWindow extends MainWindow<TimeCounter> { ... override createContents(Panel mainPanel) { ... new Label(datePanel).text = "Ingresar Fecha:" new DateBox(datePanel).bindValueToProperty("another") .setTransformer(new DateTransformer) ... } }
  • 13. Filter + Transformer 13 No siempre se logra evitar el chequeo en el Transformer
  • 14. Manejo de Colecciones 14 Existen varios componentes que permiten representar listados de datos: ▶ Selector (Dropdown) ▶ List ▶ Radio Selector ▶ Tables
  • 16. Adapters ⇒ Selectors 16 override createContents(Panel mainPanel) { this.title = "Data" mainPanel.layout = new HorizontalLayout new List(mainPanel) => [ (items <=> "products") .adaptWith(Product, "description") ] new Panel(mainPanel) => [ new Selector<Product>(it) => [ (items <=> "products") .adaptWith(Product, "description") ] new Panel(it) => [ new RadioSelector<Product>(it) => [ (items <=> "products") .adaptWith(Product, "description") ]]] } @Accessors @Observable class Product { String name int price new(String name, int price) { this.name = name this.price = price } def description() { '''«name» ($«price»)''' } }
  • 18. Tables ⇒ Columns 18 override createContents(Panel mainPanel) { this.title = "Unquify" val gridSongs = new Table(mainPanel, typeof(Song)) => [ numberVisibleRows = 5 items <=> "filterSongs" ] new Column<Song>(gridSongs) => [ title = "Titulo" bindContentsToProperty("name") fixedSize = 200 ] new Column<Song>(gridSongs) => [ title = "Duración" bindContentsToProperty("durationDescrip") fixedSize = 150 ] }
  • 19. Adapters + Lists ⇒ Demo 19