/*******************************************************************************
 * 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.ext.java.client.search;

import com.google.gwt.dom.client.Style;
import com.google.gwt.user.client.ui.DockLayoutPanel;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.inject.Inject;
import com.google.inject.Singleton;

import org.eclipse.che.ide.api.parts.PartStackUIResources;
import org.eclipse.che.ide.api.parts.base.BaseView;
import org.eclipse.che.ide.api.project.node.Node;
import org.eclipse.che.ide.api.project.node.interceptor.NodeInterceptor;
import org.eclipse.che.ide.ext.java.client.JavaLocalizationConstant;
import org.eclipse.che.ide.ext.java.client.search.node.NodeFactory;
import org.eclipse.che.ide.ext.java.shared.dto.search.FindUsagesResponse;
import org.eclipse.che.ide.ui.smartTree.NodeUniqueKeyProvider;
import org.eclipse.che.ide.ui.smartTree.Tree;
import org.eclipse.che.ide.ui.smartTree.NodeLoader;
import org.eclipse.che.ide.ui.smartTree.NodeStorage;

import javax.validation.constraints.NotNull;
import java.util.Collections;

/**
 * Implementation for FindUsages view.
 * Uses tree for presenting search results.
 *
 * @author Evgen Vidolob
 */
@Singleton
class FindUsagesViewImpl extends BaseView<FindUsagesView.ActionDelegate> implements FindUsagesView {

    private final Tree        tree;
    private       NodeFactory nodeFactory;

    @Inject
    public FindUsagesViewImpl(PartStackUIResources resources, NodeFactory nodeFactory, JavaLocalizationConstant localizationConstant) {
        super(resources);
        this.nodeFactory = nodeFactory;
        setTitle(localizationConstant.findUsagesPartTitle());
        DockLayoutPanel panel = new DockLayoutPanel(Style.Unit.PX);
        panel.addWest(new FlowPanel(), 22);

        NodeStorage storage = new NodeStorage(new NodeUniqueKeyProvider() {
            @Override
            public String getKey(@NotNull Node item) {
                return String.valueOf(item.hashCode());
            }
        });
        NodeLoader loader = new NodeLoader(Collections.<NodeInterceptor>emptySet());
        tree = new Tree(storage, loader);
        panel.add(new ScrollPanel(tree));
        setContentWidget(panel);
        panel.ensureDebugId("findUsages-panel");
    }

    @Override
    public void showUsages(final FindUsagesResponse usagesResponse) {
        tree.getNodeStorage().clear();
        tree.getNodeStorage().add(nodeFactory.create(usagesResponse));
        tree.expandAll();
    }
}

@@ -714,58 +714,8 @@
 el;%0A
-import com.google.gwt.user.client.ui.ScrollPanel;%0A
 impo
@@ -1269,30 +1269,19 @@
 ree.Node
-UniqueKeyProvi
+Loa
 der;%0Aimp
@@ -1317,19 +1317,26 @@
 artTree.
-Tre
+NodeStorag
 e;%0Aimpor
@@ -1366,35 +1366,46 @@
 i.smartTree.Node
-Loa
+UniqueKeyProvi
 der;%0Aimport org.
@@ -1433,26 +1433,19 @@
 artTree.
-NodeStorag
+Tre
 e;%0A%0Aimpo
@@ -1796,21 +1796,21 @@
 private 
-     
+final
  NodeFac
@@ -2601,30 +2601,13 @@
 add(
-new ScrollPanel(
 tree)
-)
 ;%0A  
@@ -2693,16 +2693,99 @@
 %0A    %7D%0A%0A
+    @Override%0A    protected void focusView() %7B%0A        tree.setFocus(true);%0A    %7D%0A%0A
     @Ove
@@ -2966,24 +2966,25 @@
 Response));%0A
+%0A
         tree
@@ -2996,16 +2996,153 @@
 ndAll();
+%0A%0A        if (!tree.getRootNodes().isEmpty()) %7B%0A            tree.getSelectionModel().select(tree.getRootNodes().get(0), false);%0A        %7D
 %0A    %7D%0A%7D

Fix focus on 'Usages' panel after calling 'Find Usages' feature