/*
 * Copyright 2000-2009 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.
 */

/*
 * Created by IntelliJ IDEA.
 * User: dsl
 * Date: 18.06.2002
 * Time: 13:19:44
 * To change template for new class use
 * Code Style | Class Templates options (Tools | IDE Options).
 */
package com.intellij.refactoring.ui;

import com.intellij.refactoring.util.classMembers.MemberInfo;
import com.intellij.ui.IdeBorderFactory;
import com.intellij.ui.ScrollPaneFactory;

import javax.swing.*;
import javax.swing.border.Border;
import java.awt.*;
import java.util.List;

public class MemberSelectionPanel extends JPanel {
  private final MemberSelectionTable myTable;

  public MemberSelectionPanel(String title, List<MemberInfo> memberInfo, String abstractColumnHeader) {
    super();
    Border titledBorder = IdeBorderFactory.createTitledBorder(title);
    Border emptyBorder = BorderFactory.createEmptyBorder(0, 5, 5, 5);
    Border border = BorderFactory.createCompoundBorder(titledBorder, emptyBorder);
    setBorder(border);
    setLayout(new BorderLayout());

    myTable = createMemberSelectionTable(memberInfo, abstractColumnHeader);
    JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myTable);


    add(scrollPane, BorderLayout.CENTER);
  }

  protected MemberSelectionTable createMemberSelectionTable(List<MemberInfo> memberInfo, String abstractColumnHeader) {
    return new MemberSelectionTable(memberInfo, abstractColumnHeader);
  }

  public MemberSelectionTable getTable() {
    return myTable;
  }


}

@@ -823,16 +823,61 @@
 ng.ui;%0A%0A
+import com.intellij.openapi.util.SystemInfo;%0A
 import c
@@ -953,25 +953,26 @@
 llij.ui.
-IdeBorder
+ScrollPane
 Factory;
@@ -995,33 +995,74 @@
 llij.ui.
-ScrollPaneFactory
+TableUtil;%0Aimport com.intellij.ui.TitledBorderWithMnemonic
 ;%0A%0Aimpor
@@ -1127,24 +1127,163 @@
 java.awt.*;%0A
+import java.awt.event.ActionEvent;%0Aimport java.awt.event.ActionListener;%0Aimport java.awt.event.InputEvent;%0Aimport java.awt.event.KeyEvent;%0A
 import java.
@@ -1392,16 +1392,105 @@
 Table;%0A%0A
+  /**%0A   * @param title if title contains 'm' - it would look and feel as mnemonic%0A   */%0A
   public
@@ -1606,53 +1606,83 @@
     
-Border titledBorder = IdeBorderFactory.create
+TitledBorderWithMnemonic titledBorder = new TitledBorderWithMnemonic(append
 Titl
@@ -1693,15 +1693,24 @@
 rder
+Mnemonic
 (title)
+)
 ;%0A  
@@ -2070,17 +2070,16 @@
 able);%0A%0A
-%0A
     add(
@@ -2111,16 +2111,738 @@
 CENTER);
+%0A%0A    registerKeyboardAction(new ActionListener() %7B%0A      public void actionPerformed(ActionEvent e) %7B%0A        TableUtil.ensureSelectionExists(myTable);%0A        myTable.requestFocus();%0A      %7D%0A    %7D, KeyStroke.getKeyStroke(KeyEvent.VK_M, SystemInfo.isMac ? InputEvent.META_DOWN_MASK : InputEvent.ALT_DOWN_MASK),%0A                              JComponent.WHEN_IN_FOCUSED_WINDOW);%0A  %7D%0A%0A  private static String appendTitledBorderMnemonic(String title) %7B%0A    int membersIdx = title.indexOf('M');%0A    if (membersIdx %3E= 0) %7B%0A      title = title.replaceFirst(%22M%22, %22&M%22);%0A    %7D else %7B%0A      membersIdx = title.indexOf('m');%0A      if (membersIdx %3E= 0) %7B%0A        title = title.replaceFirst(%22m%22, %22&m%22);%0A      %7D%0A    %7D%0A    return title;
 %0A  %7D%0A%0A  

add m mnemonic for all members selections panels (IDEA-70619 )