/**
 * <License>
 */
package edu.colorado.csdms.wmt.client.ui;

import java.util.Iterator;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.PopupPanel.PositionCallback;
import com.google.gwt.user.client.ui.Widget;

import edu.colorado.csdms.wmt.client.Constants;
import edu.colorado.csdms.wmt.client.control.DataManager;
import edu.colorado.csdms.wmt.client.ui.handler.ParameterActionPanelResetHandler;

/**
 * Makes a row of action buttons ("Reset", "View input files", etc.) for working
 * with the parameters of a model component in WMT.
 * 
 * @author Mark Piper (mark.piper@colorado.edu)
 */
public class ParameterActionPanel extends HorizontalPanel {

  private DataManager data;
  private String componentId;
  private ViewInputFilesMenu inputFilesMenu;
  
  /**
   * Makes a new {@link ParameterActionPanel}.
   * 
   * @param data the DataManager instance for the WMT session
   */
  public ParameterActionPanel(DataManager data, String componentId) {

    this.data = data;
    this.componentId = componentId;
    this.setStyleName("wmt-ActionPanel");

    // Reset
    Button resetButton = new Button("<i class='fa fa-bolt'></i>");
    resetButton.setTitle(Constants.PARAMETER_RESET);
    resetButton.addClickHandler(new ParameterActionPanelResetHandler(this.data,
        this.componentId));
    this.add(resetButton);

    // View input files
    final Button viewFilesButton =
        new Button("<i class='fa fa-external-link'></i>");
    viewFilesButton.setTitle(Constants.PARAMETER_VIEW_FILE);
    this.add(viewFilesButton);
    inputFilesMenu = new ViewInputFilesMenu(this.data, this.componentId);
    viewFilesButton.addClickHandler(new ClickHandler() {
      @Override
      public void onClick(ClickEvent event) {
        inputFilesMenu.populateMenu();
        inputFilesMenu.setPopupPositionAndShow(new PositionCallback() {
          final Integer x = viewFilesButton.getElement().getAbsoluteLeft();
          final Integer y = viewFilesButton.getElement().getAbsoluteBottom();

          @Override
          public void setPosition(int offsetWidth, int offsetHeight) {
            inputFilesMenu.setPopupPosition(x, y);
          }
        });
      }
    });

    // Apply a style to each button.
    Iterator<Widget> iter = this.iterator();
    while (iter.hasNext()) {
      Button button = (Button) iter.next();
      button.setStyleName("wmt-ActionPanelButton");
    }
  }
}

@@ -587,16 +587,88 @@
 Handler;
+%0Aimport edu.colorado.csdms.wmt.client.ui.widgets.ComponentInfoDialogBox;
 %0A%0A/**%0A *
@@ -2257,17 +2257,16 @@
 ttom();%0A
-%0A
         
@@ -2436,24 +2436,646 @@
  %7D%0A    %7D);%0A%0A
+    // Component help%0A    Button helpButton = new Button(Constants.FA_HELP);%0A    helpButton.setTitle(Constants.COMPONENT_INFO);%0A    helpButton.addClickHandler(new ClickHandler() %7B%0A      @Override%0A      public void onClick(ClickEvent event) %7B%0A        ComponentInfoDialogBox componentInfoDialogBox =%0A            ParameterActionPanel.this.data.getPerspective()%0A                .getComponentInfoBox();%0A        componentInfoDialogBox.update(ParameterActionPanel.this.data%0A            .getComponent(ParameterActionPanel.this.componentId));%0A        componentInfoDialogBox.center();%0A      %7D%0A    %7D);%0A    this.add(helpButton);%0A    %0A
     // Apply

Add a help button to the ParameterActionPanel