/*
 * Copyright 2000-2014 JetBrains s.r.o.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.intellij.openapi.wm.impl.welcomeScreen;

import com.intellij.ide.ReopenProjectAction;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.util.io.UniqueNameBuilder;
import com.intellij.openapi.wm.WelcomeScreen;
import com.intellij.ui.components.JBList;
import com.intellij.ui.speedSearch.ListWithFilter;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.Nullable;

import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;

/**
 * @author Konstantin Bulenkov
 */
public class NewRecentProjectPanel extends RecentProjectPanel {
  public NewRecentProjectPanel(WelcomeScreen screen) {
    super(screen);
    setBorder(null);
    setBackground(FlatWelcomeFrame.getProjectsBackGround());
    JScrollPane scrollPane = UIUtil.findComponentOfType(this, JScrollPane.class);
    if (scrollPane != null) {
      scrollPane.setBackground(FlatWelcomeFrame.getProjectsBackGround());
    }
    ListWithFilter panel = UIUtil.findComponentOfType(this, ListWithFilter.class);
    if (panel != null) {
      panel.setBackground(FlatWelcomeFrame.getProjectsBackGround());
    }
  }

  protected Dimension getPreferredScrollableViewportSize() {
    return new Dimension(250, 420);
  }

  @Override
  protected void addMouseMotionListener() {
  }

  @Override
  protected JBList createList(AnAction[] recentProjectActions, Dimension size) {
    JBList list = super.createList(recentProjectActions, size);
    list.setBackground(FlatWelcomeFrame.getProjectsBackGround());
    return list;
  }

  @Override
  protected ListCellRenderer createRenderer(UniqueNameBuilder<ReopenProjectAction> pathShortener) {
    return new RecentProjectItemRenderer(myPathShortener) {
      {
        setBorder(new EmptyBorder(0, 10, 0, 0));
      }
      @Override
      protected Color getListBackground(boolean isSelected, boolean hasFocus) {
        return isSelected && hasFocus ? new Color(0x2484fd) : FlatWelcomeFrame.getProjectsBackGround();
      }

      @Override
      protected Color getListForeground(boolean isSelected, boolean hasFocus) {
        return UIUtil.getListForeground(isSelected && hasFocus);
      }
    };
  }
  
  

  @Nullable
  @Override
  protected JPanel createTitle() {
    return null;
  }

  
}

@@ -1096,16 +1096,82 @@
 a.awt.*;
+%0Aimport java.awt.event.KeyAdapter;%0Aimport java.awt.event.KeyEvent;
 %0A%0A/**%0A *
@@ -2063,16 +2063,22 @@
 ) %7B%0A    
+final 
 JBList l
@@ -2191,24 +2191,615 @@
 kGround());%0A
+    list.addKeyListener(new KeyAdapter() %7B%0A      @Override%0A      public void keyPressed(KeyEvent e) %7B%0A        if (e.getKeyCode() == KeyEvent.VK_RIGHT) %7B%0A          FlatWelcomeFrame frame = UIUtil.getParentOfType(FlatWelcomeFrame.class, list);%0A          if (frame != null) %7B%0A            FocusTraversalPolicy policy = frame.getFocusTraversalPolicy();%0A            if (policy != null) %7B%0A              Component next = policy.getComponentAfter(frame, list);%0A              if (next != null) %7B%0A                next.requestFocus();%0A              %7D%0A            %7D%0A          %7D%0A        %7D%0A      %7D%0A    %7D);%0A
     return l

move focus to action group by pressing Right Arrow