gt:                 categoryTargets = new ArrayList<>();
context: /*******************************************************************************
   * Copyright (c) 2012-2016 Codenvy, S.A.
   * All rights reserved. This program and the accompanying materials
   * are made available under the terms of the Eclipse Public License v1.0
   * which accompanies this distribution, and is available at
   * http://www.eclipse.org/legal/epl-v10.html
   *
   * Contributors:
   *   Codenvy, S.A. - initial API and implementation
   *******************************************************************************/
  package org.eclipse.che.ide.extension.machine.client.targets;
  
  import com.google.gwt.dom.client.DivElement;
  import com.google.gwt.dom.client.Document;
  import com.google.gwt.dom.client.Element;
  import com.google.gwt.dom.client.SpanElement;
  import com.google.gwt.dom.client.Style;
  import com.google.gwt.event.dom.client.ChangeEvent;
  import com.google.gwt.event.dom.client.ChangeHandler;
  import com.google.gwt.event.dom.client.ClickEvent;
  import com.google.gwt.event.dom.client.ClickHandler;
  import com.google.gwt.event.dom.client.KeyDownEvent;
  import com.google.gwt.event.dom.client.KeyDownHandler;
  import com.google.gwt.event.dom.client.KeyUpEvent;
  import com.google.gwt.event.dom.client.KeyUpHandler;
  import com.google.gwt.uibinder.client.UiBinder;
  import com.google.gwt.uibinder.client.UiField;
  import com.google.gwt.user.client.Event;
  import com.google.gwt.user.client.EventListener;
  import com.google.gwt.user.client.ui.Button;
  import com.google.gwt.user.client.ui.FlowPanel;
  import com.google.gwt.user.client.ui.PasswordTextBox;
  import com.google.gwt.user.client.ui.SimplePanel;
  import com.google.gwt.user.client.ui.TextBox;
  import com.google.gwt.user.client.ui.Widget;
  import com.google.inject.Inject;
  import com.google.inject.Singleton;
  import elemental.events.KeyboardEvent;
  import org.eclipse.che.ide.CoreLocalizationConstant;
  import org.eclipse.che.ide.api.icon.Icon;
  import org.eclipse.che.ide.api.icon.IconRegistry;
  import org.eclipse.che.ide.extension.machine.client.MachineLocalizationConstant;
  import org.eclipse.che.ide.extension.machine.client.MachineResources;
  import org.eclipse.che.ide.extension.machine.client.command.edit.EditCommandResources;
  import org.eclipse.che.ide.ui.Tooltip;
  import org.eclipse.che.ide.ui.list.CategoriesList;
  import org.eclipse.che.ide.ui.list.Category;
  import org.eclipse.che.ide.ui.list.CategoryRenderer;
  import org.eclipse.che.ide.ui.listbox.CustomListBox;
  import org.eclipse.che.ide.ui.window.Window;
  
  import java.util.ArrayList;
  import java.util.Collections;
  import java.util.Comparator;
  import java.util.HashMap;
  import java.util.List;
  import java.util.Map;
  
  import static org.eclipse.che.ide.extension.machine.client.processes.ProcessTreeRenderer.MACHINE_LABELS_BY_CATEGORY_MAP;
  import static org.eclipse.che.ide.extension.machine.client.targets.TargetsPresenter.SSH_CATEGORY;
  import static org.eclipse.che.ide.ui.menu.PositionController.HorizontalAlign.MIDDLE;
  import static org.eclipse.che.ide.ui.menu.PositionController.VerticalAlign.BOTTOM;
  import static com.google.gwt.dom.client.Style.Unit.PX;
  
  /**
   * @author Vitaliy Guliy
   */
  @Singleton
  public class TargetsViewImpl extends Window implements TargetsView {
  
      interface TargetsViewImplUiBinder extends UiBinder<Widget, TargetsViewImpl> {
      }
  
      private EditCommandResources    commandResources;
      private MachineResources     	machineResources;
      private IconRegistry            iconRegistry;
  
      private ActionDelegate          delegate;
  
      @UiField(provided = true)
      MachineLocalizationConstant     machineLocale;
  
      @UiField
      TextBox                         filterTargets;
  
      @UiField
      SimplePanel                     targetsPanel;
  
      private CategoriesList          list;
  
      @UiField
      FlowPanel                       hintPanel;
  
      @UiField
      FlowPanel                       infoPanel;
  
      @UiField
      FlowPanel                       propertiesPanel;
  
      @UiField
      org.eclipse.che.ide.ui.TextBox  targetName;
  
      @UiField
      org.eclipse.che.ide.ui.TextBox  host;
  
      @UiField
      org.eclipse.che.ide.ui.TextBox  port;
  
      @UiField
      TextBox                         userName;
  
      @UiField
      PasswordTextBox                 password;
  
      @UiField
      FlowPanel                       footer;
  
      private Button                  closeButton;
  
      private Button                  saveButton;
      private Button                  cancelButton;
      private Button                  connectButton;
  
      @Inject
      public TargetsViewImpl(org.eclipse.che.ide.Resources resources,
                             MachineLocalizationConstant machineLocale,
                             MachineResources machineResources,
                             CoreLocalizationConstant coreLocale,
                             EditCommandResources commandResources,
                             IconRegistry iconRegistry,
                             TargetsViewImplUiBinder uiBinder) {
          this.machineLocale = machineLocale;
          this.machineResources = machineResources;
          this.commandResources = commandResources;
          this.iconRegistry = iconRegistry;
  
          setWidget(uiBinder.createAndBindUi(this));
          getWidget().getElement().getStyle().setPadding(0, Style.Unit.PX);
          setTitle(machineLocale.targetsViewTitle());
  
          filterTargets.getElement().setAttribute("placeholder", machineLocale.editCommandsViewPlaceholder());
          filterTargets.getElement().addClassName(commandResources.getCss().filterPlaceholder());
  
          list = new CategoriesList(resources);
          list.addDomHandler(new KeyDownHandler() {
              @Override
              public void onKeyDown(KeyDownEvent event) {
                  switch (event.getNativeKeyCode()) {
                      case KeyboardEvent.KeyCode.INSERT:
                          break;
                      case KeyboardEvent.KeyCode.DELETE:
                          break;
                  }
              }
          }, KeyDownEvent.getType());
          targetsPanel.add(list);
  
          closeButton = createButton(coreLocale.close(), "targets.button.close",
                  new ClickHandler() {
                      @Override
                      public void onClick(ClickEvent event) {
                          delegate.onCloseClicked();
                      }
                  });
          addButtonToFooter(closeButton);
  
          saveButton = createButton(coreLocale.save(), "targets.button.save", new ClickHandler() {
              @Override
              public void onClick(ClickEvent event) {
                  delegate.onSaveClicked();
              }
          });
          saveButton.addStyleName(Window.resources.windowCss().primaryButton());
          footer.add(saveButton);
  
          cancelButton = createButton(coreLocale.cancel(), "targets.button.cancel", new ClickHandler() {
              @Override
              public void onClick(ClickEvent event) {
                  delegate.onCancelClicked();
              }
          });
          footer.add(cancelButton);
  
          connectButton = createButton("Connect", "targets.button.connect", new ClickHandler() {
              @Override
              public void onClick(ClickEvent event) {
                  delegate.onConnectClicked();
              }
          });
          connectButton.addStyleName(Window.resources.windowCss().primaryButton());
          connectButton.addStyleName(resources.Css().buttonLoader());
          footer.add(connectButton);
  
          targetName.addKeyUpHandler(new KeyUpHandler() {
              @Override
              public void onKeyUp(KeyUpEvent keyUpEvent) {
                  delegate.onTargetNameChanged(targetName.getValue());
              }
          });
  
          host.addKeyUpHandler(new KeyUpHandler() {
              @Override
              public void onKeyUp(KeyUpEvent keyUpEvent) {
                  delegate.onHostChanged(host.getValue());
              }
          });
  
          port.addKeyUpHandler(new KeyUpHandler() {
              @Override
              public void onKeyUp(KeyUpEvent keyUpEvent) {
                  delegate.onPortChanged(port.getValue());
              }
          });
  
          userName.addKeyUpHandler(new KeyUpHandler() {
              @Override
              public void onKeyUp(KeyUpEvent keyUpEvent) {
                  delegate.onUserNameChanged(userName.getValue());
              }
          });
  
          password.addKeyUpHandler(new KeyUpHandler() {
              @Override
              public void onKeyUp(KeyUpEvent keyUpEvent) {
                  delegate.onPasswordChanged(password.getValue());
              }
          });
      }
  
      @Override
      public void setDelegate(ActionDelegate delegate) {
          this.delegate = delegate;
      }
  
      @Override
      public void clear() {
          list.clear();
  
          hintPanel.setVisible(true);
          infoPanel.setVisible(false);
          propertiesPanel.setVisible(false);
      }
  
      @Override
      public void showHintPanel() {
          hintPanel.setVisible(true);
          infoPanel.setVisible(false);
          propertiesPanel.setVisible(false);
      }
  
      @Override
      public void showInfoPanel() {
          hintPanel.setVisible(false);
          infoPanel.setVisible(true);
          propertiesPanel.setVisible(false);
      }
  
      @Override
      public void showPropertiesPanel() {
          hintPanel.setVisible(false);
          infoPanel.setVisible(false);
          propertiesPanel.setVisible(true);
      }
  
      @Override
      public void showTargets(List<Target> targets) {
          Collections.sort(targets, new Comparator<Target>() {
              @Override
              public int compare(Target target1, Target target2) {
                  return target1.getName().compareTo(target2.getName());
              }
          });
  
          HashMap<String, List<Target>> categories = new HashMap<>();
          for (Target target : targets) {
              List<Target> categoryTargets = categories.get(target.getType());
              if (categoryTargets == null) {
  