Source:
public LeftMenuItem(MenuItem menuItem, LeftMenuItemResources resources){ this.resources = resources; this.resources.leftMenuItemStyle().ensureInjected(); if (menuItem != null) { notSelectedImage = new Image(menuItem.getUnSelectedImage()); selectedImage = new Image(menuItem.getSelectedImage()); this.initWidget(uiBinder.createAndBindUi(this)); leftMenuItem.setStyleName(resources.leftMenuItemStyle().leftMenuItem()); notSelectedPanel.setStyleName(resources.leftMenuItemStyle().notSelectedPanel()); notSelectedPanel.addMouseUpHandler(new MouseUpHandler() { @Override public void onMouseUp(MouseUpEvent event) { setSelected(); } }); notSelectedImage.setStyleName(resources.leftMenuItemStyle().notSelectedImage()); notSelectedLabel.setStyleName(resources.leftMenuItemStyle().notSelectedLabel()); notSelectedLabel.setText(menuItem.getLabel()); selectedImage.setStyleName(resources.leftMenuItemStyle().selectedImage()); selectedLabel.setStyleName(resources.leftMenuItemStyle().selectedLabel()); selectedLabel.setText(menuItem.getLabel()); selectedPanel.setStyleName(resources.leftMenuItemStyle().selectedPanel()); leftMenuItem.forceLayout(); } }

Target:
public LeftMenuItem(MenuItem menuItem, LeftMenuItemResources resources) { this.resources = resources; this.resources.leftMenuItemStyle().ensureInjected(); handlerManager = new HandlerManager(this); if (menuItem != null) { this.menuItem = menuItem; notSelectedImage = new Image(menuItem.getUnSelectedImage()); selectedImage = new Image(menuItem.getSelectedImage()); this.initWidget(uiBinder.createAndBindUi(this)); leftMenuItem.setStyleName(resources.leftMenuItemStyle().leftMenuItem()); notSelectedPanel.setStyleName(resources.leftMenuItemStyle().notSelectedPanelOutState()); notSelectedPanel.addMouseUpHandler(new MouseUpHandler() { @Override public void onMouseUp(MouseUpEvent event) { notSelectedPanel.setStyleName(LeftMenuItem.this.resources.leftMenuItemStyle().notSelectedPanelUpState()); if (isClickable) { isClickable = false; setSelected(); LeftMenuItem.this.menuItem.getCommand().execute(); fireEvent(new LeftMenuItemSelectEvent()); } } }); notSelectedPanel.addMouseDownHandler(new MouseDownHandler() { @Override public void onMouseDown(MouseDownEvent event) { notSelectedPanel.setStyleName(LeftMenuItem.this.resources.leftMenuItemStyle().notSelectedPanelDownState()); } }); notSelectedPanel.addMouseOverHandler(new MouseOverHandler() { @Override public void onMouseOver(MouseOverEvent event) { notSelectedPanel.setStyleName(LeftMenuItem.this.resources.leftMenuItemStyle().notSelectedPanelOverState()); } }); notSelectedPanel.addMouseOutHandler(new MouseOutHandler() { @Override public void onMouseOut(MouseOutEvent event) { notSelectedPanel.setStyleName(LeftMenuItem.this.resources.leftMenuItemStyle().notSelectedPanelOutState()); } }); notSelectedImage.setStyleName(resources.leftMenuItemStyle().notSelectedImage()); notSelectedLabel.setStyleName(resources.leftMenuItemStyle().notSelectedLabel()); notSelectedLabel.setText(menuItem.getLabel()); selectedImage.setStyleName(resources.leftMenuItemStyle().selectedImage()); selectedLabel.setStyleName(resources.leftMenuItemStyle().selectedLabel()); selectedLabel.setText(menuItem.getLabel()); selectedPanel.setStyleName(resources.leftMenuItemStyle().selectedPanel()); leftMenuItem.forceLayout(); } }