public void update() {
   LayerTreeTreeNode selected = tree.getSelectedLayerTreeNode();
   if (selected != null && action.isEnabled(selected.getLayer())) {
     setDisabled(false);
     setIcon(action.getIcon());
     setTooltip(action.getTooltip());
   } else {
     setDisabled(true);
     setIcon(action.getDisabledIcon());
     setTooltip("");
   }
 }
    public LayerTreeButton(final LayerTree tree, final LayerTreeAction action) {
      this.tree = tree;
      this.action = action;
      setWidth(WidgetLayout.layerTreeButtonSize);
      setHeight(WidgetLayout.layerTreeButtonSize);
      setIconSize(WidgetLayout.layerTreeButtonSize - WidgetLayout.layerTreeStripHeight);
      setIcon(action.getIcon());
      setTooltip(action.getTooltip());
      setActionType(SelectionType.BUTTON);
      setShowDisabledIcon(false);
      addClickHandler(
          new ClickHandler() {

            public void onClick(ClickEvent event) {
              try {
                action.onClick(tree.getSelectedLayerTreeNode().getLayer());
                update();
              } catch (Throwable t) {
                Log.logError("LayerTreeButton onClick error", t);
              }
            }
          });
    }