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

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;

import edu.colorado.csdms.wmt.client.control.DataManager;
import edu.colorado.csdms.wmt.client.data.Constants;
import edu.colorado.csdms.wmt.client.ui.widgets.DroplistDialogBox;

/**
 * Handles click on the "Delete" button in the ModelActionPanel. It presents an
 * instance of {@link DroplistDialogBox} with a "Delete" button. Events are sent
 * to {@link DeleteModelHandler} and {@link DialogCancelHandler}.
 * 
 * @author Mark Piper (mark.piper@colorado.edu)
 */
public class ModelActionPanelDeleteHandler implements ClickHandler {

  private DataManager data;
  private DroplistDialogBox deleteDialog;

  /**
   * Creates a new instance of {@link ModelActionPanelDeleteHandler}.
   * 
   * @param data the DataManager object for the WMT session
   */
  public ModelActionPanelDeleteHandler(DataManager data) {
    this.data = data;
  }
  
  @Override
  public void onClick(ClickEvent event) {

    // Hide the MoreActionsMenu.
    data.getPerspective().getActionButtonPanel().getMoreMenu().hide();

    deleteDialog = new DroplistDialogBox();
    deleteDialog.setText("Delete Model...");
    deleteDialog.getChoicePanel().getOkButton().setHTML(
        Constants.FA_DELETE + "Delete");

    // Populate the ModelDroplist with the available models on the server.
    for (int i = 0; i < data.modelNameList.size(); i++) {
      deleteDialog.getDroplistPanel().getDroplist().addItem(
          data.modelNameList.get(i));
    }

    deleteDialog.getChoicePanel().getOkButton().addClickHandler(
        new DeleteModelHandler(data, deleteDialog));
    deleteDialog.getChoicePanel().getCancelButton().addClickHandler(
        new DialogCancelHandler(deleteDialog));

    deleteDialog.center();
  }
}

@@ -164,24 +164,181 @@
 lickHandler;
+%0Aimport com.google.gwt.event.dom.client.KeyCodes;%0Aimport com.google.gwt.event.dom.client.KeyDownEvent;%0Aimport com.google.gwt.event.dom.client.KeyDownHandler;
 %0A%0Aimport edu
@@ -1167,18 +1167,16 @@
 ta;%0A  %7D%0A
-  
 %0A  @Over
@@ -1763,264 +1763,1017 @@
     
-deleteDialog.getChoicePanel().getOkButton().addClickHandler(%0A        new DeleteModelHandler(data, deleteDialog));%0A    deleteDialog.getChoicePanel().getCancelButton().addClickHandler(%0A        new DialogCancelHandler(deleteDialog));%0A%0A    deleteDialog.center(
+// Define handlers.%0A    final DeleteModelHandler deleteHandler =%0A        new DeleteModelHandler(data, deleteDialog);%0A    final DialogCancelHandler cancelHandler =%0A        new DialogCancelHandler(deleteDialog);%0A%0A    // Apply handlers to OK and Cancel buttons.%0A    deleteDialog.getChoicePanel().getOkButton().addClickHandler(deleteHandler);%0A    deleteDialog.getChoicePanel().getCancelButton().addClickHandler(%0A        cancelHandler);%0A%0A    // Also apply handlers to %22Enter%22 and %22Esc%22 keys.%0A    deleteDialog.addDomHandler(new KeyDownHandler() %7B%0A      @Override%0A      public void onKeyDown(KeyDownEvent event) %7B%0A        Integer keyCode = event.getNativeKeyCode();%0A        if (keyCode == KeyCodes.KEY_ESCAPE) %7B%0A          cancelHandler.onClick(null);%0A        %7D else if (keyCode == KeyCodes.KEY_ENTER) %7B%0A          deleteHandler.onClick(null);%0A        %7D%0A      %7D%0A    %7D, KeyDownEvent.getType());%0A%0A    deleteDialog.center();%0A%0A    // Give the droplist focus.%0A    deleteDialog.getDroplistPanel().getDroplist().setFocus(true
 );%0A 

Add "Enter" and "Esc" shortcuts to model delete dialog