SlideShare a Scribd company logo
1 of 40
Download to read offline
Wednesday, November 2, 11
CUSTOM COMPONENTS
                            Sven Brunken



             sven@sencha.com               @svenbrunken




Wednesday, November 2, 11
Overview
                                    Widget vs Component
                            Important methods of the Widget class
                                 When to use the Cell class?
                              Important methods of the Cell class
                                         Questions




Wednesday, November 2, 11
Which Class To Start
                            From?




Wednesday, November 2, 11
Widget
       Build on top of a DOM Element
       Listens to browser events
       Needs to be attached and detached for event handling
       Does not solve the different sizing boxes
       Can fire custom events through its HandlerManager




Wednesday, November 2, 11
Component
       Extends the Widget class and so inherits all its features
       Solves the different sizing boxes
       Can be disabled directly
       Can be positioned




Wednesday, November 2, 11
Important Methods




Wednesday, November 2, 11
sinkEvents()
       Defines which events can be listened to
       Events not sunk cannot be listened to



   public void sinkEvents(int eventBitsToAdd) {
     if (isOrWasAttached()) {
       DOM.sinkEvents(getElement(), eventBitsToAdd|DOM.getEventsSunk(getElement()));
     } else {
       eventsToSink |= eventBitsToAdd;
     }
   }




Wednesday, November 2, 11
onAttach()
       Removes the event listener
       Mandatory to enable browser event handling
       Attaches the event listener of all its children widgets

                            protected void onAttach() {
                              attached = true;
                              DOM.setEventListener(getElement(), this);
                              int bitsToAdd = eventsToSink;
                              eventsToSink = -1;
                              if (bitsToAdd > 0) {
                                sinkEvents(bitsToAdd);
                              }
                              doAttachChildren();
                              onLoad();
                              AttachEvent.fire(this, true);
                            }


Wednesday, November 2, 11
onDetach()
       Removes the event listener added from onAttach()
       Browser events are no longer handled for this Widget
       Prevents memory leaks
       Detaches the event listener for all its children widgets

                            protected void onDetach() {
                              try {
                                onUnload();
                                AttachEvent.fire(this, false);
                              } finally {
                                try {
                                  doDetachChildren();
                                } finally {
                                  DOM.setEventListener(getElement(), null);
                                  attached = false;
                                }
                              }
                            }
Wednesday, November 2, 11
fireEvent()
       Fires a custom event through the HandlerManager
       Other classes could listen to these events



                            public void fireEvent(GwtEvent<?> event) {
                              if (handlerManager != null) {
                                handlerManager.fireEvent(event);
                              }
                            }




Wednesday, November 2, 11
onBrowserEvent()
       Only called when a Widget is attached
       Gets called with the browser event that occurred
       Refires the browser event through the HandlerManager




                public void onBrowserEvent(Event event) {
                  DomEvent.fireNativeEvent(event, this, this.getElement());
                }




Wednesday, November 2, 11
setElement()
       Sets the element for this Widget
       Mandatory to be called
       An Element can only be set once and not changed
       Needs to be called before calling getElement()




             protected void setElement(Element elem) {
               assert (element == null) : SETELEMENT_TWICE_ERROR;
               this.element = elem;
             }




Wednesday, November 2, 11
How To Start?




Wednesday, November 2, 11
Gathering Information
       What is the purpose of my custom widget?
       Which browser events are required?
       Can I extend an already existing class?




       Do I understand all my requirements?




Wednesday, November 2, 11
Implementation




Wednesday, November 2, 11
The Class
       Extending Component to overcome different sizing models




                            public class SquareWidget extends Component {

                            }




Wednesday, November 2, 11
Constructor
       Setting the Element
       Defining the events we want to listen to



           public SquareWidget(Data data) {
             this.data = data;
             SquareWidgetTemplate t = GWT.create(SquareWidgetTemplate.class);
             setElement(XDOM.create(t.render(data)));

                sinkEvents(Event.ONMOUSEOVER | Event.ONMOUSEOUT | Event.ONCLICK);

                setPixelSize(100, 100);
           }




Wednesday, November 2, 11
onBrowserEvent()
       Contains our event handling logic
       Should call the super method

                        @Override
                        public void onBrowserEvent(Event event) {
                          super.onBrowserEvent(event);

                            if (event.getTypeInt() == Event.ONMOUSEOUT) {
                              onMouseOut(event);
                            } else if (event.getTypeInt() == Event.ONMOUSEOVER) {
                              onMouseOver(event);
                            } else if (event.getTypeInt() == Event.ONCLICK) {
                              onClick(event);
                            }
                        }

Wednesday, November 2, 11
onMouseOver()
       getRelatedEventTarget returns the Element coming from
       Setting the mouse over value




      private void onMouseOver(Event event) {
        EventTarget t = event.getRelatedEventTarget();
        if (t == null || Element.is(t) && !getElement().isOrHasChild(Element.as(t))) {
          String s = SafeHtmlUtils.fromString(data.getMouseOverName()).asString();
          getContentElement().setInnerHTML(s);
        }
      }




Wednesday, November 2, 11
onMouseOut()
       getRelatedEventTarget returns the Element moving to
       Clearing the background color
       Setting the standard value again


             private void onMouseOut(Event event) {
               EventTarget t = event.getRelatedEventTarget();
               if (t == null
                   || (Element.is(t) && !getElement().isOrHasChild(Element.as(t)))) {
                 getElement().getStyle().clearBackgroundColor();

                     String s = SafeHtmlUtils.fromString(data.getName()).asString();
                     getContentElement().setInnerHTML(s);
                 }
             }




Wednesday, November 2, 11
onClick()
       Sets the different background color




                            private void onClick(Event event) {
                              getElement().getStyle().setBackgroundColor("red");
                            }




Wednesday, November 2, 11
Demonstration




Wednesday, November 2, 11
But, Do We Really
                            Require a Widget?




Wednesday, November 2, 11
Introducing Cell
       Cells can handle browser events
       Cells can be used in data components
       Widgets cannot be used there
       Cells render a lot faster




Wednesday, November 2, 11
Context of the Cell
       Contains the relevant row and column index
       Important when used in data widgets
       Contains the key representing the value




Wednesday, November 2, 11
Important Methods




Wednesday, November 2, 11
onBrowserEvent()
       Gets called when an event for this cell occurred
       Gets passed in the parent Element
       Cell on its own does not know anything where it is displayed
       One Cell can be displayed in many places




             void onBrowserEvent(Context context, Element parent, C value,
                 NativeEvent event, ValueUpdater<C> valueUpdater);




Wednesday, November 2, 11
render()
       Called when a Cell should be rendered
       The output should be written to the SafeHtmlBuilder




                void render(Context context, C value, SafeHtmlBuilder sb);




Wednesday, November 2, 11
getConsumedEvents()
       Returns the events this cell requires
       Cannot change in the lifecycle of a Cell




                            Set<String> getConsumedEvents();




Wednesday, November 2, 11
Implementation




Wednesday, November 2, 11
The Class
       Extending AbstractCell
       Implementing the Cell interface directly works too



                        public class SquareCell extends AbstractCell<Data> {

                        }




Wednesday, November 2, 11
Constructor
       Defining the events this cell listens to




                            public SquareCell() {
                              super("click", "mouseover", "mouseout");
                            }




Wednesday, November 2, 11
onBrowserEvent()
       Contains our event handling logic

                public void onBrowserEvent(Context context, Element parent, Data value,
                    NativeEvent event, ValueUpdater<Data> valueUpdater) {
                  Element t = parent.getFirstChildElement();
                  Element target = event.getEventTarget().cast();
                  if (!t.isOrHasChild(target)) {
                    return;
                  }

                    if ("mouseout".equals(event.getType())) {
                      onMouseOut(context, parent, value, event);
                    } else if ("mouseover".equals(event.getType())) {
                      onMouseOver(context, parent, value, event);
                    } else if ("click".equals(event.getType())) {
                      onClick(context, parent, value, event);
                    }
                }
Wednesday, November 2, 11
onMouseOver()
       getRelatedEventTarget returns the Element coming from
       Setting the mouse over value



         private void onMouseOver(Context context, Element parent, Data value,
             NativeEvent event) {
           Element fc = parent.getFirstChildElement();
           EventTarget t = event.getRelatedEventTarget();
           if (t == null || (Element.is(t) && !fc.isOrHasChild(Element.as(t)))) {
             String s = SafeHtmlUtils.fromString(value.getMouseOverName()).asString();
             getContentElement(parent).setInnerHTML(s);
           }
         }




Wednesday, November 2, 11
onMouseOut()
       getRelatedEventTarget returns the Element moving to
       Clearing the background color
       Setting the standard value again
          private void onMouseOut(Context context, Element parent, Data value,
              NativeEvent event) {
            Element fc = parent.getFirstChildElement();
            EventTarget t = event.getRelatedEventTarget();
            if (t == null || (Element.is(t) && !fc.isOrHasChild(Element.as(t)))) {
              fc.getStyle().clearBackgroundColor();
              String s = SafeHtmlUtils.fromString(value.getName()).asString();
              getContentElement(parent).setInnerHTML(s);
            }
          }




Wednesday, November 2, 11
onClick()
       Sets the different background color




           private void onClick(Context context, Element parent, Data value,
               NativeEvent event) {
             parent.getFirstChildElement().getStyle().setBackgroundColor("red");
           }




Wednesday, November 2, 11
Demonstration




Wednesday, November 2, 11
Questions




Wednesday, November 2, 11
Thank You!




Wednesday, November 2, 11

More Related Content

What's hot

Knock, knock, who is there? Doze.
Knock, knock, who is there? Doze.Knock, knock, who is there? Doze.
Knock, knock, who is there? Doze.Yonatan Levin
 
Advanced Akka For Architects
Advanced Akka For ArchitectsAdvanced Akka For Architects
Advanced Akka For ArchitectsLightbend
 
Save System in Garden of the Sea: How to save the state of an open-ended gard...
Save System in Garden of the Sea: How to save the state of an open-ended gard...Save System in Garden of the Sea: How to save the state of an open-ended gard...
Save System in Garden of the Sea: How to save the state of an open-ended gard...DevGAMM Conference
 
YUI3 Modules
YUI3 ModulesYUI3 Modules
YUI3 Modulesa_pipkin
 
Ejercicio sql server vs visual .net
Ejercicio sql server vs visual .netEjercicio sql server vs visual .net
Ejercicio sql server vs visual .netAyuda Universidad
 
Kivy Talk Python Meetup Innsbruck 2017.04.25
Kivy Talk Python Meetup Innsbruck 2017.04.25Kivy Talk Python Meetup Innsbruck 2017.04.25
Kivy Talk Python Meetup Innsbruck 2017.04.25Robert Niederreiter
 
The Ring programming language version 1.6 book - Part 72 of 189
The Ring programming language version 1.6 book - Part 72 of 189The Ring programming language version 1.6 book - Part 72 of 189
The Ring programming language version 1.6 book - Part 72 of 189Mahmoud Samir Fayed
 
The Ring programming language version 1.5.1 book - Part 66 of 180
The Ring programming language version 1.5.1 book - Part 66 of 180The Ring programming language version 1.5.1 book - Part 66 of 180
The Ring programming language version 1.5.1 book - Part 66 of 180Mahmoud Samir Fayed
 

What's hot (18)

Unity3 d devfest-2014
Unity3 d devfest-2014Unity3 d devfest-2014
Unity3 d devfest-2014
 
Knock, knock, who is there? Doze.
Knock, knock, who is there? Doze.Knock, knock, who is there? Doze.
Knock, knock, who is there? Doze.
 
Ms Ajax Dom Event Class
Ms Ajax Dom Event ClassMs Ajax Dom Event Class
Ms Ajax Dom Event Class
 
Advanced Akka For Architects
Advanced Akka For ArchitectsAdvanced Akka For Architects
Advanced Akka For Architects
 
Data Storage
Data StorageData Storage
Data Storage
 
Ouce2013-RBEM-WS
Ouce2013-RBEM-WSOuce2013-RBEM-WS
Ouce2013-RBEM-WS
 
OUCE2013-RBEM-PT
OUCE2013-RBEM-PTOUCE2013-RBEM-PT
OUCE2013-RBEM-PT
 
What's new in CDI 2.0
What's new in CDI 2.0What's new in CDI 2.0
What's new in CDI 2.0
 
Metode
MetodeMetode
Metode
 
Network
NetworkNetwork
Network
 
Save System in Garden of the Sea: How to save the state of an open-ended gard...
Save System in Garden of the Sea: How to save the state of an open-ended gard...Save System in Garden of the Sea: How to save the state of an open-ended gard...
Save System in Garden of the Sea: How to save the state of an open-ended gard...
 
YUI3 Modules
YUI3 ModulesYUI3 Modules
YUI3 Modules
 
Ejercicio sql server vs visual .net
Ejercicio sql server vs visual .netEjercicio sql server vs visual .net
Ejercicio sql server vs visual .net
 
Kivy Talk Python Meetup Innsbruck 2017.04.25
Kivy Talk Python Meetup Innsbruck 2017.04.25Kivy Talk Python Meetup Innsbruck 2017.04.25
Kivy Talk Python Meetup Innsbruck 2017.04.25
 
menu strip - visual basic
menu strip - visual basicmenu strip - visual basic
menu strip - visual basic
 
The Ring programming language version 1.6 book - Part 72 of 189
The Ring programming language version 1.6 book - Part 72 of 189The Ring programming language version 1.6 book - Part 72 of 189
The Ring programming language version 1.6 book - Part 72 of 189
 
Final_Project
Final_ProjectFinal_Project
Final_Project
 
The Ring programming language version 1.5.1 book - Part 66 of 180
The Ring programming language version 1.5.1 book - Part 66 of 180The Ring programming language version 1.5.1 book - Part 66 of 180
The Ring programming language version 1.5.1 book - Part 66 of 180
 

Similar to Custom Components: Widget vs Cell Class

Ext GWT 3.0 Data Binding and Editors
Ext GWT 3.0 Data Binding and EditorsExt GWT 3.0 Data Binding and Editors
Ext GWT 3.0 Data Binding and EditorsSencha
 
EventBus for Android
EventBus for AndroidEventBus for Android
EventBus for Androidgreenrobot
 
event handling new.ppt
event handling new.pptevent handling new.ppt
event handling new.pptusama537223
 
A Series of Fortunate Events - Symfony Camp Sweden 2014
A Series of Fortunate Events - Symfony Camp Sweden 2014A Series of Fortunate Events - Symfony Camp Sweden 2014
A Series of Fortunate Events - Symfony Camp Sweden 2014Matthias Noback
 
Synapseindia dotnet development chapter 14 event-driven programming
Synapseindia dotnet development  chapter 14 event-driven programmingSynapseindia dotnet development  chapter 14 event-driven programming
Synapseindia dotnet development chapter 14 event-driven programmingSynapseindiappsdevelopment
 
Graphical User Interface (GUI) - 2
Graphical User Interface (GUI) - 2Graphical User Interface (GUI) - 2
Graphical User Interface (GUI) - 2PRN USM
 
Java gui event
Java gui eventJava gui event
Java gui eventSoftNutx
 
Android Event and IntentAndroid Event and Intent
Android Event and IntentAndroid Event and IntentAndroid Event and IntentAndroid Event and Intent
Android Event and IntentAndroid Event and Intentadmin220812
 
Using UIBinder with Ext GWT 3.0
Using UIBinder with Ext GWT 3.0Using UIBinder with Ext GWT 3.0
Using UIBinder with Ext GWT 3.0Sencha
 
CQRS and Event Sourcing in a Symfony application
CQRS and Event Sourcing in a Symfony applicationCQRS and Event Sourcing in a Symfony application
CQRS and Event Sourcing in a Symfony applicationSamuel ROZE
 
A Series of Fortunate Events - Drupalcon Europe, Amsterdam 2014
A Series of Fortunate Events - Drupalcon Europe, Amsterdam 2014A Series of Fortunate Events - Drupalcon Europe, Amsterdam 2014
A Series of Fortunate Events - Drupalcon Europe, Amsterdam 2014Matthias Noback
 
Unit-3 event handling
Unit-3 event handlingUnit-3 event handling
Unit-3 event handlingAmol Gaikwad
 
Chapter 11.5
Chapter 11.5Chapter 11.5
Chapter 11.5sotlsoc
 
JEDI Slides-Intro2-Chapter20-GUI Event Handling.pdf
JEDI Slides-Intro2-Chapter20-GUI Event Handling.pdfJEDI Slides-Intro2-Chapter20-GUI Event Handling.pdf
JEDI Slides-Intro2-Chapter20-GUI Event Handling.pdfMarlouFelixIIICunana
 
openFrameworks 007 - events
openFrameworks 007 - eventsopenFrameworks 007 - events
openFrameworks 007 - eventsroxlu
 

Similar to Custom Components: Widget vs Cell Class (20)

Javascript Browser Events.pdf
Javascript Browser Events.pdfJavascript Browser Events.pdf
Javascript Browser Events.pdf
 
Ext GWT 3.0 Data Binding and Editors
Ext GWT 3.0 Data Binding and EditorsExt GWT 3.0 Data Binding and Editors
Ext GWT 3.0 Data Binding and Editors
 
EventBus for Android
EventBus for AndroidEventBus for Android
EventBus for Android
 
event handling new.ppt
event handling new.pptevent handling new.ppt
event handling new.ppt
 
Events
EventsEvents
Events
 
A Series of Fortunate Events - Symfony Camp Sweden 2014
A Series of Fortunate Events - Symfony Camp Sweden 2014A Series of Fortunate Events - Symfony Camp Sweden 2014
A Series of Fortunate Events - Symfony Camp Sweden 2014
 
Synapseindia dotnet development chapter 14 event-driven programming
Synapseindia dotnet development  chapter 14 event-driven programmingSynapseindia dotnet development  chapter 14 event-driven programming
Synapseindia dotnet development chapter 14 event-driven programming
 
Graphical User Interface (GUI) - 2
Graphical User Interface (GUI) - 2Graphical User Interface (GUI) - 2
Graphical User Interface (GUI) - 2
 
Java gui event
Java gui eventJava gui event
Java gui event
 
Android Event and IntentAndroid Event and Intent
Android Event and IntentAndroid Event and IntentAndroid Event and IntentAndroid Event and Intent
Android Event and IntentAndroid Event and Intent
 
Using UIBinder with Ext GWT 3.0
Using UIBinder with Ext GWT 3.0Using UIBinder with Ext GWT 3.0
Using UIBinder with Ext GWT 3.0
 
GreenRobot-Eventbus
GreenRobot-EventbusGreenRobot-Eventbus
GreenRobot-Eventbus
 
CQRS and Event Sourcing in a Symfony application
CQRS and Event Sourcing in a Symfony applicationCQRS and Event Sourcing in a Symfony application
CQRS and Event Sourcing in a Symfony application
 
A Series of Fortunate Events - Drupalcon Europe, Amsterdam 2014
A Series of Fortunate Events - Drupalcon Europe, Amsterdam 2014A Series of Fortunate Events - Drupalcon Europe, Amsterdam 2014
A Series of Fortunate Events - Drupalcon Europe, Amsterdam 2014
 
Unit-3 event handling
Unit-3 event handlingUnit-3 event handling
Unit-3 event handling
 
Chapter 11.5
Chapter 11.5Chapter 11.5
Chapter 11.5
 
JEDI Slides-Intro2-Chapter20-GUI Event Handling.pdf
JEDI Slides-Intro2-Chapter20-GUI Event Handling.pdfJEDI Slides-Intro2-Chapter20-GUI Event Handling.pdf
JEDI Slides-Intro2-Chapter20-GUI Event Handling.pdf
 
Ext J S Observable
Ext J S ObservableExt J S Observable
Ext J S Observable
 
openFrameworks 007 - events
openFrameworks 007 - eventsopenFrameworks 007 - events
openFrameworks 007 - events
 
Events - Part 2
Events - Part 2Events - Part 2
Events - Part 2
 

More from Sencha

Breathe New Life into Your Existing JavaScript Applications with Web Components
Breathe New Life into Your Existing JavaScript Applications with Web ComponentsBreathe New Life into Your Existing JavaScript Applications with Web Components
Breathe New Life into Your Existing JavaScript Applications with Web ComponentsSencha
 
Ext JS 6.6 Highlights
Ext JS 6.6 HighlightsExt JS 6.6 Highlights
Ext JS 6.6 HighlightsSencha
 
Sencha Roadshow 2017: BufferedStore Internals featuring eyeworkers interactiv...
Sencha Roadshow 2017: BufferedStore Internals featuring eyeworkers interactiv...Sencha Roadshow 2017: BufferedStore Internals featuring eyeworkers interactiv...
Sencha Roadshow 2017: BufferedStore Internals featuring eyeworkers interactiv...Sencha
 
Sencha Roadshow 2017: Build Progressive Web Apps with Ext JS and Cmd
Sencha Roadshow 2017: Build Progressive Web Apps with Ext JS and Cmd Sencha Roadshow 2017: Build Progressive Web Apps with Ext JS and Cmd
Sencha Roadshow 2017: Build Progressive Web Apps with Ext JS and Cmd Sencha
 
Sencha Roadshow 2017: Best Practices for Implementing Continuous Web App Testing
Sencha Roadshow 2017: Best Practices for Implementing Continuous Web App TestingSencha Roadshow 2017: Best Practices for Implementing Continuous Web App Testing
Sencha Roadshow 2017: Best Practices for Implementing Continuous Web App TestingSencha
 
Sencha Roadshow 2017: What's New in Sencha Test
Sencha Roadshow 2017: What's New in Sencha TestSencha Roadshow 2017: What's New in Sencha Test
Sencha Roadshow 2017: What's New in Sencha TestSencha
 
Sencha Roadshow 2017: Sencha Upgrades - The Good. The Bad. The Ugly - Eva Luc...
Sencha Roadshow 2017: Sencha Upgrades - The Good. The Bad. The Ugly - Eva Luc...Sencha Roadshow 2017: Sencha Upgrades - The Good. The Bad. The Ugly - Eva Luc...
Sencha Roadshow 2017: Sencha Upgrades - The Good. The Bad. The Ugly - Eva Luc...Sencha
 
Sencha Roadshow 2017: Modernizing the Ext JS Class System and Tooling
Sencha Roadshow 2017: Modernizing the Ext JS Class System and ToolingSencha Roadshow 2017: Modernizing the Ext JS Class System and Tooling
Sencha Roadshow 2017: Modernizing the Ext JS Class System and ToolingSencha
 
Sencha Roadshow 2017: Sencha Best Practices: Coworkee App
Sencha Roadshow 2017: Sencha Best Practices: Coworkee App Sencha Roadshow 2017: Sencha Best Practices: Coworkee App
Sencha Roadshow 2017: Sencha Best Practices: Coworkee App Sencha
 
Sencha Roadshow 2017: Mobile First or Desktop First
Sencha Roadshow 2017: Mobile First or Desktop FirstSencha Roadshow 2017: Mobile First or Desktop First
Sencha Roadshow 2017: Mobile First or Desktop FirstSencha
 
Sencha Roadshow 2017: Innovations in Ext JS 6.5 and Beyond
Sencha Roadshow 2017: Innovations in Ext JS 6.5 and BeyondSencha Roadshow 2017: Innovations in Ext JS 6.5 and Beyond
Sencha Roadshow 2017: Innovations in Ext JS 6.5 and BeyondSencha
 
Leveraging React and GraphQL to Create a Performant, Scalable Data Grid
Leveraging React and GraphQL to Create a Performant, Scalable Data GridLeveraging React and GraphQL to Create a Performant, Scalable Data Grid
Leveraging React and GraphQL to Create a Performant, Scalable Data GridSencha
 
Learn Key Insights from The State of Web Application Testing Research Report
Learn Key Insights from The State of Web Application Testing Research ReportLearn Key Insights from The State of Web Application Testing Research Report
Learn Key Insights from The State of Web Application Testing Research ReportSencha
 
Introducing ExtReact: Adding Powerful Sencha Components to React Apps
Introducing ExtReact: Adding Powerful Sencha Components to React AppsIntroducing ExtReact: Adding Powerful Sencha Components to React Apps
Introducing ExtReact: Adding Powerful Sencha Components to React AppsSencha
 
SenchaCon 2016: Keynote Presentation - Art Landro, Gautam Agrawal, Mark Brocato
SenchaCon 2016: Keynote Presentation - Art Landro, Gautam Agrawal, Mark BrocatoSenchaCon 2016: Keynote Presentation - Art Landro, Gautam Agrawal, Mark Brocato
SenchaCon 2016: Keynote Presentation - Art Landro, Gautam Agrawal, Mark BrocatoSencha
 
SenchaCon 2016: Add Magic to Your Ext JS Apps with D3 Visualizations - Vitaly...
SenchaCon 2016: Add Magic to Your Ext JS Apps with D3 Visualizations - Vitaly...SenchaCon 2016: Add Magic to Your Ext JS Apps with D3 Visualizations - Vitaly...
SenchaCon 2016: Add Magic to Your Ext JS Apps with D3 Visualizations - Vitaly...Sencha
 
SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rou...
SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rou...SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rou...
SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rou...Sencha
 
SenchaCon 2016: Expect the Unexpected - Dealing with Errors in Web Apps
SenchaCon 2016: Expect the Unexpected - Dealing with Errors in Web AppsSenchaCon 2016: Expect the Unexpected - Dealing with Errors in Web Apps
SenchaCon 2016: Expect the Unexpected - Dealing with Errors in Web AppsSencha
 
Ext JS Architecture Best Practices - Mitchell Simeons
Ext JS Architecture Best Practices - Mitchell SimeonsExt JS Architecture Best Practices - Mitchell Simeons
Ext JS Architecture Best Practices - Mitchell SimeonsSencha
 
SenchaCon 2016: Mobile First? Desktop First? Or Should you Think Universal Ap...
SenchaCon 2016: Mobile First? Desktop First? Or Should you Think Universal Ap...SenchaCon 2016: Mobile First? Desktop First? Or Should you Think Universal Ap...
SenchaCon 2016: Mobile First? Desktop First? Or Should you Think Universal Ap...Sencha
 

More from Sencha (20)

Breathe New Life into Your Existing JavaScript Applications with Web Components
Breathe New Life into Your Existing JavaScript Applications with Web ComponentsBreathe New Life into Your Existing JavaScript Applications with Web Components
Breathe New Life into Your Existing JavaScript Applications with Web Components
 
Ext JS 6.6 Highlights
Ext JS 6.6 HighlightsExt JS 6.6 Highlights
Ext JS 6.6 Highlights
 
Sencha Roadshow 2017: BufferedStore Internals featuring eyeworkers interactiv...
Sencha Roadshow 2017: BufferedStore Internals featuring eyeworkers interactiv...Sencha Roadshow 2017: BufferedStore Internals featuring eyeworkers interactiv...
Sencha Roadshow 2017: BufferedStore Internals featuring eyeworkers interactiv...
 
Sencha Roadshow 2017: Build Progressive Web Apps with Ext JS and Cmd
Sencha Roadshow 2017: Build Progressive Web Apps with Ext JS and Cmd Sencha Roadshow 2017: Build Progressive Web Apps with Ext JS and Cmd
Sencha Roadshow 2017: Build Progressive Web Apps with Ext JS and Cmd
 
Sencha Roadshow 2017: Best Practices for Implementing Continuous Web App Testing
Sencha Roadshow 2017: Best Practices for Implementing Continuous Web App TestingSencha Roadshow 2017: Best Practices for Implementing Continuous Web App Testing
Sencha Roadshow 2017: Best Practices for Implementing Continuous Web App Testing
 
Sencha Roadshow 2017: What's New in Sencha Test
Sencha Roadshow 2017: What's New in Sencha TestSencha Roadshow 2017: What's New in Sencha Test
Sencha Roadshow 2017: What's New in Sencha Test
 
Sencha Roadshow 2017: Sencha Upgrades - The Good. The Bad. The Ugly - Eva Luc...
Sencha Roadshow 2017: Sencha Upgrades - The Good. The Bad. The Ugly - Eva Luc...Sencha Roadshow 2017: Sencha Upgrades - The Good. The Bad. The Ugly - Eva Luc...
Sencha Roadshow 2017: Sencha Upgrades - The Good. The Bad. The Ugly - Eva Luc...
 
Sencha Roadshow 2017: Modernizing the Ext JS Class System and Tooling
Sencha Roadshow 2017: Modernizing the Ext JS Class System and ToolingSencha Roadshow 2017: Modernizing the Ext JS Class System and Tooling
Sencha Roadshow 2017: Modernizing the Ext JS Class System and Tooling
 
Sencha Roadshow 2017: Sencha Best Practices: Coworkee App
Sencha Roadshow 2017: Sencha Best Practices: Coworkee App Sencha Roadshow 2017: Sencha Best Practices: Coworkee App
Sencha Roadshow 2017: Sencha Best Practices: Coworkee App
 
Sencha Roadshow 2017: Mobile First or Desktop First
Sencha Roadshow 2017: Mobile First or Desktop FirstSencha Roadshow 2017: Mobile First or Desktop First
Sencha Roadshow 2017: Mobile First or Desktop First
 
Sencha Roadshow 2017: Innovations in Ext JS 6.5 and Beyond
Sencha Roadshow 2017: Innovations in Ext JS 6.5 and BeyondSencha Roadshow 2017: Innovations in Ext JS 6.5 and Beyond
Sencha Roadshow 2017: Innovations in Ext JS 6.5 and Beyond
 
Leveraging React and GraphQL to Create a Performant, Scalable Data Grid
Leveraging React and GraphQL to Create a Performant, Scalable Data GridLeveraging React and GraphQL to Create a Performant, Scalable Data Grid
Leveraging React and GraphQL to Create a Performant, Scalable Data Grid
 
Learn Key Insights from The State of Web Application Testing Research Report
Learn Key Insights from The State of Web Application Testing Research ReportLearn Key Insights from The State of Web Application Testing Research Report
Learn Key Insights from The State of Web Application Testing Research Report
 
Introducing ExtReact: Adding Powerful Sencha Components to React Apps
Introducing ExtReact: Adding Powerful Sencha Components to React AppsIntroducing ExtReact: Adding Powerful Sencha Components to React Apps
Introducing ExtReact: Adding Powerful Sencha Components to React Apps
 
SenchaCon 2016: Keynote Presentation - Art Landro, Gautam Agrawal, Mark Brocato
SenchaCon 2016: Keynote Presentation - Art Landro, Gautam Agrawal, Mark BrocatoSenchaCon 2016: Keynote Presentation - Art Landro, Gautam Agrawal, Mark Brocato
SenchaCon 2016: Keynote Presentation - Art Landro, Gautam Agrawal, Mark Brocato
 
SenchaCon 2016: Add Magic to Your Ext JS Apps with D3 Visualizations - Vitaly...
SenchaCon 2016: Add Magic to Your Ext JS Apps with D3 Visualizations - Vitaly...SenchaCon 2016: Add Magic to Your Ext JS Apps with D3 Visualizations - Vitaly...
SenchaCon 2016: Add Magic to Your Ext JS Apps with D3 Visualizations - Vitaly...
 
SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rou...
SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rou...SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rou...
SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rou...
 
SenchaCon 2016: Expect the Unexpected - Dealing with Errors in Web Apps
SenchaCon 2016: Expect the Unexpected - Dealing with Errors in Web AppsSenchaCon 2016: Expect the Unexpected - Dealing with Errors in Web Apps
SenchaCon 2016: Expect the Unexpected - Dealing with Errors in Web Apps
 
Ext JS Architecture Best Practices - Mitchell Simeons
Ext JS Architecture Best Practices - Mitchell SimeonsExt JS Architecture Best Practices - Mitchell Simeons
Ext JS Architecture Best Practices - Mitchell Simeons
 
SenchaCon 2016: Mobile First? Desktop First? Or Should you Think Universal Ap...
SenchaCon 2016: Mobile First? Desktop First? Or Should you Think Universal Ap...SenchaCon 2016: Mobile First? Desktop First? Or Should you Think Universal Ap...
SenchaCon 2016: Mobile First? Desktop First? Or Should you Think Universal Ap...
 

Recently uploaded

TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 

Recently uploaded (20)

TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 

Custom Components: Widget vs Cell Class

  • 2. CUSTOM COMPONENTS Sven Brunken sven@sencha.com @svenbrunken Wednesday, November 2, 11
  • 3. Overview Widget vs Component Important methods of the Widget class When to use the Cell class? Important methods of the Cell class Questions Wednesday, November 2, 11
  • 4. Which Class To Start From? Wednesday, November 2, 11
  • 5. Widget Build on top of a DOM Element Listens to browser events Needs to be attached and detached for event handling Does not solve the different sizing boxes Can fire custom events through its HandlerManager Wednesday, November 2, 11
  • 6. Component Extends the Widget class and so inherits all its features Solves the different sizing boxes Can be disabled directly Can be positioned Wednesday, November 2, 11
  • 8. sinkEvents() Defines which events can be listened to Events not sunk cannot be listened to public void sinkEvents(int eventBitsToAdd) { if (isOrWasAttached()) { DOM.sinkEvents(getElement(), eventBitsToAdd|DOM.getEventsSunk(getElement())); } else { eventsToSink |= eventBitsToAdd; } } Wednesday, November 2, 11
  • 9. onAttach() Removes the event listener Mandatory to enable browser event handling Attaches the event listener of all its children widgets protected void onAttach() { attached = true; DOM.setEventListener(getElement(), this); int bitsToAdd = eventsToSink; eventsToSink = -1; if (bitsToAdd > 0) { sinkEvents(bitsToAdd); } doAttachChildren(); onLoad(); AttachEvent.fire(this, true); } Wednesday, November 2, 11
  • 10. onDetach() Removes the event listener added from onAttach() Browser events are no longer handled for this Widget Prevents memory leaks Detaches the event listener for all its children widgets protected void onDetach() { try { onUnload(); AttachEvent.fire(this, false); } finally { try { doDetachChildren(); } finally { DOM.setEventListener(getElement(), null); attached = false; } } } Wednesday, November 2, 11
  • 11. fireEvent() Fires a custom event through the HandlerManager Other classes could listen to these events public void fireEvent(GwtEvent<?> event) { if (handlerManager != null) { handlerManager.fireEvent(event); } } Wednesday, November 2, 11
  • 12. onBrowserEvent() Only called when a Widget is attached Gets called with the browser event that occurred Refires the browser event through the HandlerManager public void onBrowserEvent(Event event) { DomEvent.fireNativeEvent(event, this, this.getElement()); } Wednesday, November 2, 11
  • 13. setElement() Sets the element for this Widget Mandatory to be called An Element can only be set once and not changed Needs to be called before calling getElement() protected void setElement(Element elem) { assert (element == null) : SETELEMENT_TWICE_ERROR; this.element = elem; } Wednesday, November 2, 11
  • 14. How To Start? Wednesday, November 2, 11
  • 15. Gathering Information What is the purpose of my custom widget? Which browser events are required? Can I extend an already existing class? Do I understand all my requirements? Wednesday, November 2, 11
  • 17. The Class Extending Component to overcome different sizing models public class SquareWidget extends Component { } Wednesday, November 2, 11
  • 18. Constructor Setting the Element Defining the events we want to listen to public SquareWidget(Data data) { this.data = data; SquareWidgetTemplate t = GWT.create(SquareWidgetTemplate.class); setElement(XDOM.create(t.render(data))); sinkEvents(Event.ONMOUSEOVER | Event.ONMOUSEOUT | Event.ONCLICK); setPixelSize(100, 100); } Wednesday, November 2, 11
  • 19. onBrowserEvent() Contains our event handling logic Should call the super method @Override public void onBrowserEvent(Event event) { super.onBrowserEvent(event); if (event.getTypeInt() == Event.ONMOUSEOUT) { onMouseOut(event); } else if (event.getTypeInt() == Event.ONMOUSEOVER) { onMouseOver(event); } else if (event.getTypeInt() == Event.ONCLICK) { onClick(event); } } Wednesday, November 2, 11
  • 20. onMouseOver() getRelatedEventTarget returns the Element coming from Setting the mouse over value private void onMouseOver(Event event) { EventTarget t = event.getRelatedEventTarget(); if (t == null || Element.is(t) && !getElement().isOrHasChild(Element.as(t))) { String s = SafeHtmlUtils.fromString(data.getMouseOverName()).asString(); getContentElement().setInnerHTML(s); } } Wednesday, November 2, 11
  • 21. onMouseOut() getRelatedEventTarget returns the Element moving to Clearing the background color Setting the standard value again private void onMouseOut(Event event) { EventTarget t = event.getRelatedEventTarget(); if (t == null || (Element.is(t) && !getElement().isOrHasChild(Element.as(t)))) { getElement().getStyle().clearBackgroundColor(); String s = SafeHtmlUtils.fromString(data.getName()).asString(); getContentElement().setInnerHTML(s); } } Wednesday, November 2, 11
  • 22. onClick() Sets the different background color private void onClick(Event event) { getElement().getStyle().setBackgroundColor("red"); } Wednesday, November 2, 11
  • 24. But, Do We Really Require a Widget? Wednesday, November 2, 11
  • 25. Introducing Cell Cells can handle browser events Cells can be used in data components Widgets cannot be used there Cells render a lot faster Wednesday, November 2, 11
  • 26. Context of the Cell Contains the relevant row and column index Important when used in data widgets Contains the key representing the value Wednesday, November 2, 11
  • 28. onBrowserEvent() Gets called when an event for this cell occurred Gets passed in the parent Element Cell on its own does not know anything where it is displayed One Cell can be displayed in many places void onBrowserEvent(Context context, Element parent, C value, NativeEvent event, ValueUpdater<C> valueUpdater); Wednesday, November 2, 11
  • 29. render() Called when a Cell should be rendered The output should be written to the SafeHtmlBuilder void render(Context context, C value, SafeHtmlBuilder sb); Wednesday, November 2, 11
  • 30. getConsumedEvents() Returns the events this cell requires Cannot change in the lifecycle of a Cell Set<String> getConsumedEvents(); Wednesday, November 2, 11
  • 32. The Class Extending AbstractCell Implementing the Cell interface directly works too public class SquareCell extends AbstractCell<Data> { } Wednesday, November 2, 11
  • 33. Constructor Defining the events this cell listens to public SquareCell() { super("click", "mouseover", "mouseout"); } Wednesday, November 2, 11
  • 34. onBrowserEvent() Contains our event handling logic public void onBrowserEvent(Context context, Element parent, Data value, NativeEvent event, ValueUpdater<Data> valueUpdater) { Element t = parent.getFirstChildElement(); Element target = event.getEventTarget().cast(); if (!t.isOrHasChild(target)) { return; } if ("mouseout".equals(event.getType())) { onMouseOut(context, parent, value, event); } else if ("mouseover".equals(event.getType())) { onMouseOver(context, parent, value, event); } else if ("click".equals(event.getType())) { onClick(context, parent, value, event); } } Wednesday, November 2, 11
  • 35. onMouseOver() getRelatedEventTarget returns the Element coming from Setting the mouse over value private void onMouseOver(Context context, Element parent, Data value, NativeEvent event) { Element fc = parent.getFirstChildElement(); EventTarget t = event.getRelatedEventTarget(); if (t == null || (Element.is(t) && !fc.isOrHasChild(Element.as(t)))) { String s = SafeHtmlUtils.fromString(value.getMouseOverName()).asString(); getContentElement(parent).setInnerHTML(s); } } Wednesday, November 2, 11
  • 36. onMouseOut() getRelatedEventTarget returns the Element moving to Clearing the background color Setting the standard value again private void onMouseOut(Context context, Element parent, Data value, NativeEvent event) { Element fc = parent.getFirstChildElement(); EventTarget t = event.getRelatedEventTarget(); if (t == null || (Element.is(t) && !fc.isOrHasChild(Element.as(t)))) { fc.getStyle().clearBackgroundColor(); String s = SafeHtmlUtils.fromString(value.getName()).asString(); getContentElement(parent).setInnerHTML(s); } } Wednesday, November 2, 11
  • 37. onClick() Sets the different background color private void onClick(Context context, Element parent, Data value, NativeEvent event) { parent.getFirstChildElement().getStyle().setBackgroundColor("red"); } Wednesday, November 2, 11