SlideShare a Scribd company logo
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 ch7
Javascript ch7Javascript ch7
Javascript ch7
Brady Cheng
 
JavaScript objects and functions
JavaScript objects and functionsJavaScript objects and functions
JavaScript objects and functions
Victor 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-12
Abu Saleh
 
Class object method constructors in java
Class object method constructors in javaClass object method constructors in java
Class object method constructors in java
Raja Sekhar
 
C++Constructors
C++ConstructorsC++Constructors
C++Constructors
Nusrat Gulbarga
 
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
WebStackAcademy
 
Constructor ppt
Constructor pptConstructor ppt
Constructor ppt
Vinod Kumar
 
Constructors and Destructors
Constructors and DestructorsConstructors and Destructors
Constructors and Destructors
Dr Sukhpal Singh Gill
 
JavaScript Getting Started
JavaScript Getting StartedJavaScript Getting Started
JavaScript Getting Started
Hazem Hagrass
 
Design pattern in action
Design pattern in actionDesign pattern in action
Design pattern in action
Tho Q Luong Luong
 
Constructor and Destructor
Constructor and DestructorConstructor and Destructor
Constructor and Destructor
Kamal Acharya
 
mediator
mediatormediator
mediator
guestb37335
 
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
Salaam Kehinde
 
Constructor and destructor
Constructor  and  destructor Constructor  and  destructor
Constructor and destructor
Shubham Vishwambhar
 
constructor and destructor
constructor and destructorconstructor and destructor
constructor and destructor
VENNILAV6
 
Java constructors
Java constructorsJava constructors
Java constructors
QUONTRASOLUTIONS
 
Constructors
ConstructorsConstructors
Constructors
shravani2191
 
Macros excel contar celdas de color
Macros excel contar celdas de  colorMacros excel contar celdas de  color
Macros excel contar celdas de color
Veronica Marquez
 
Type casting in java
Type casting in javaType casting in java
Type casting in java
Farooq Baloch
 
Constructor and Types of Constructors
Constructor and Types of ConstructorsConstructor and Types of Constructors
Constructor and Types of Constructors
Dhrumil 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
 
WD programs descriptions.docx
WD programs descriptions.docxWD programs descriptions.docx
WD programs descriptions.docx
anjani pavan kumar
 
Java Generics
Java GenericsJava Generics
Java Generics
Carol McDonald
 
C++ Generators and Property-based Testing
C++ Generators and Property-based TestingC++ Generators and Property-based Testing
C++ Generators and Property-based Testing
Sumant Tambe
 
Generics in .NET, C++ and Java
Generics in .NET, C++ and JavaGenerics in .NET, C++ and Java
Generics in .NET, C++ and Java
Sasha Goldshtein
 
Eugene Burmako
Eugene BurmakoEugene Burmako
Eugene Burmako
Volha Banadyseva
 
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 2008
Luis 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 MVC
Richard Paul
 
Java Lab Manual
Java Lab ManualJava Lab Manual
Java Lab Manual
Naveen Sagayaselvaraj
 
Presentation_1370675757603
Presentation_1370675757603Presentation_1370675757603
Presentation_1370675757603
Alexander Nevidimov
 
Introduction to Client-Side Javascript
Introduction to Client-Side JavascriptIntroduction to Client-Side Javascript
Introduction to Client-Side Javascript
Julie Iskander
 
Clean code _v2003
 Clean code _v2003 Clean code _v2003
Clean code _v2003
R696
 
DITEC - Programming with C#.NET
DITEC - Programming with C#.NETDITEC - Programming with C#.NET
DITEC - Programming with C#.NET
Rasan Samarasinghe
 
Diifeerences In C#
Diifeerences In C#Diifeerences In C#
Diifeerences In C#
rohit_gupta_mrt
 
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
ThchTrngGia
 
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
Carol McDonald
 
.Net Classes and Objects | UiPath Community
.Net Classes and Objects | UiPath Community.Net Classes and Objects | UiPath Community
.Net Classes and Objects | UiPath Community
Rohit 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 dumping
xavazque2
 
380914324 poo-kotlin
380914324 poo-kotlin380914324 poo-kotlin
380914324 poo-kotlin
xavazque2
 
146817358 android
146817358 android146817358 android
146817358 android
xavazque2
 
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
xavazque2
 
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
xavazque2
 
325940441 motion-ui
325940441 motion-ui325940441 motion-ui
325940441 motion-ui
xavazque2
 
371081023 curso-desarrollo-android
371081023 curso-desarrollo-android371081023 curso-desarrollo-android
371081023 curso-desarrollo-android
xavazque2
 
4.1. validaciones-y-excepciones
4.1. validaciones-y-excepciones4.1. validaciones-y-excepciones
4.1. validaciones-y-excepciones
xavazque2
 
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
xavazque2
 
5.1. stateles stateful-protocolo_http
5.1. stateles stateful-protocolo_http5.1. stateles stateful-protocolo_http
5.1. stateles stateful-protocolo_http
xavazque2
 
435338801 programacion-mobile-android
435338801 programacion-mobile-android435338801 programacion-mobile-android
435338801 programacion-mobile-android
xavazque2
 
457126889 android-pdf
457126889 android-pdf457126889 android-pdf
457126889 android-pdf
xavazque2
 
266521557 apuntes-unidad-formativa-app-inventor
266521557 apuntes-unidad-formativa-app-inventor266521557 apuntes-unidad-formativa-app-inventor
266521557 apuntes-unidad-formativa-app-inventor
xavazque2
 
7. react js-1
7. react js-17. react js-1
7. react js-1
xavazque2
 
Tp1
Tp1Tp1
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
xavazque2
 
484717855 transmutacion-de-energias-pdf
484717855 transmutacion-de-energias-pdf484717855 transmutacion-de-energias-pdf
484717855 transmutacion-de-energias-pdf
xavazque2
 
5.layouts
5.layouts5.layouts
5.layouts
xavazque2
 
6.2. js
6.2. js6.2. js
6.2. js
xavazque2
 
2.1. arena-y-binding
2.1. arena-y-binding2.1. arena-y-binding
2.1. arena-y-binding
xavazque2
 

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

Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Speck&Tech
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems S.M.S.A.
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
Daiki Mogmet Ito
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
Neo4j
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
Zilliz
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 

Recently uploaded (20)

Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 

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