Search in sources :

Example 1 with MemberSelectionTable

use of com.intellij.refactoring.ui.MemberSelectionTable in project intellij-community by JetBrains.

the class RemoveMiddlemanDialog method createCenterPanel.

protected JComponent createCenterPanel() {
    final JPanel panel = new JPanel(new BorderLayout());
    panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 5, 0));
    final MemberSelectionPanel selectionPanel = new MemberSelectionPanel("&Methods to inline", delegateMethods, "Delete");
    final MemberSelectionTable table = selectionPanel.getTable();
    table.setMemberInfoModel(new DelegatingMemberInfoModel<PsiMember, MemberInfo>(table.getMemberInfoModel()) {

        @Override
        public int checkForProblems(@NotNull final MemberInfo member) {
            return hasSuperMethods(member) ? ERROR : OK;
        }

        @Override
        public String getTooltipText(final MemberInfo member) {
            if (hasSuperMethods(member))
                return "Deletion will break type hierarchy";
            return super.getTooltipText(member);
        }

        private boolean hasSuperMethods(final MemberInfo member) {
            if (member.isChecked() && member.isToAbstract()) {
                final PsiMember psiMember = member.getMember();
                if (psiMember instanceof PsiMethod && ((PsiMethod) psiMember).findDeepestSuperMethods().length > 0) {
                    return true;
                }
            }
            return false;
        }
    });
    panel.add(selectionPanel, BorderLayout.CENTER);
    return panel;
}
Also used : MemberSelectionTable(com.intellij.refactoring.ui.MemberSelectionTable) MemberInfo(com.intellij.refactoring.util.classMembers.MemberInfo) PsiMethod(com.intellij.psi.PsiMethod) MemberSelectionPanel(com.intellij.refactoring.ui.MemberSelectionPanel) PsiMember(com.intellij.psi.PsiMember)

Example 2 with MemberSelectionTable

use of com.intellij.refactoring.ui.MemberSelectionTable in project intellij-community by JetBrains.

the class MissedTestsDialog method createCenterPanel.

@Nullable
@Override
protected JComponent createCenterPanel() {
    final List<MemberInfo> info = TestIntegrationUtils.extractClassMethods(mySourceClass, false);
    disableMethodsWithTests(info);
    final JPanel panel = new JPanel(new BorderLayout());
    myTable = new MemberSelectionTable(info, null);
    panel.add(ScrollPaneFactory.createScrollPane(myTable), BorderLayout.CENTER);
    panel.add(myIncludeInheritedCb, BorderLayout.NORTH);
    myIncludeInheritedCb.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            updateMethodsTable();
        }
    });
    return panel;
}
Also used : MemberSelectionTable(com.intellij.refactoring.ui.MemberSelectionTable) MemberInfo(com.intellij.refactoring.util.classMembers.MemberInfo) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

MemberSelectionTable (com.intellij.refactoring.ui.MemberSelectionTable)2 MemberInfo (com.intellij.refactoring.util.classMembers.MemberInfo)2 PsiMember (com.intellij.psi.PsiMember)1 PsiMethod (com.intellij.psi.PsiMethod)1 MemberSelectionPanel (com.intellij.refactoring.ui.MemberSelectionPanel)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 Nullable (org.jetbrains.annotations.Nullable)1