Search in sources :

Example 1 with MemberSelectionPanel

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

the class ExtractInterfaceDialog method createCenterPanel.

protected JComponent createCenterPanel() {
    JPanel panel = new JPanel(new BorderLayout());
    final MemberSelectionPanel memberSelectionPanel = new MemberSelectionPanel(RefactoringBundle.message("members.to.form.interface"), myMemberInfos, RefactoringBundle.message("make.abstract"));
    memberSelectionPanel.getTable().setMemberInfoModel(new DelegatingMemberInfoModel<PsiMember, MemberInfo>(memberSelectionPanel.getTable().getMemberInfoModel()) {

        public Boolean isFixedAbstract(MemberInfo member) {
            return Boolean.TRUE;
        }
    });
    panel.add(memberSelectionPanel, BorderLayout.CENTER);
    panel.add(myDocCommentPanel, BorderLayout.EAST);
    return panel;
}
Also used : MemberInfo(com.intellij.refactoring.util.classMembers.MemberInfo) MemberSelectionPanel(com.intellij.refactoring.ui.MemberSelectionPanel)

Example 2 with MemberSelectionPanel

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

the class InheritanceToDelegationDialog method createCenterPanel.

protected JComponent createCenterPanel() {
    JPanel panel = new JPanel(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.BOTH;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.gridy = 0;
    gbc.gridx = 0;
    gbc.weightx = 1.0;
    gbc.weighty = 1.0;
    gbc.gridwidth = 1;
    gbc.insets = JBUI.insets(4, 0, 4, 4);
    myMemberSelectionPanel = new MemberSelectionPanel(RefactoringBundle.message("delegate.members"), Collections.<MemberInfo>emptyList(), null);
    panel.add(myMemberSelectionPanel, gbc);
    MyMemberInfoModel memberInfoModel = new InheritanceToDelegationDialog.MyMemberInfoModel();
    myMemberSelectionPanel.getTable().setMemberInfoModel(memberInfoModel);
    myMemberSelectionPanel.getTable().addMemberInfoChangeListener(memberInfoModel);
    gbc.gridy++;
    gbc.insets = JBUI.insets(4, 8, 0, 8);
    gbc.weighty = 0.0;
    myCbGenerateGetter = new JCheckBox(RefactoringBundle.message("generate.getter.for.delegated.component"));
    myCbGenerateGetter.setFocusable(false);
    panel.add(myCbGenerateGetter, gbc);
    myCbGenerateGetter.setSelected(JavaRefactoringSettings.getInstance().INHERITANCE_TO_DELEGATION_DELEGATE_OTHER);
    updateTargetClass();
    return panel;
}
Also used : MemberInfo(com.intellij.refactoring.util.classMembers.MemberInfo) MemberSelectionPanel(com.intellij.refactoring.ui.MemberSelectionPanel)

Example 3 with MemberSelectionPanel

use of com.intellij.refactoring.ui.MemberSelectionPanel 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 4 with MemberSelectionPanel

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

the class MoveMembersDialog method createCenterPanel.

protected JComponent createCenterPanel() {
    JPanel panel = new JPanel(new BorderLayout());
    final String title = RefactoringBundle.message("move.members.members.to.be.moved.border.title");
    final MemberSelectionPanel selectionPanel = new MemberSelectionPanel(title, myMemberInfos, null);
    myTable = selectionPanel.getTable();
    myMemberInfoModel = new MyMemberInfoModel();
    myMemberInfoModel.memberInfoChanged(new MemberInfoChange<>(myMemberInfos));
    selectionPanel.getTable().setMemberInfoModel(myMemberInfoModel);
    selectionPanel.getTable().addMemberInfoChangeListener(myMemberInfoModel);
    panel.add(selectionPanel, BorderLayout.CENTER);
    myVisibilityPanel = new JavaVisibilityPanel(true, true);
    myVisibilityPanel.setVisibility(null);
    panel.add(myVisibilityPanel, BorderLayout.EAST);
    panel.add(initOpenInEditorCb(), BorderLayout.SOUTH);
    return panel;
}
Also used : MemberSelectionPanel(com.intellij.refactoring.ui.MemberSelectionPanel) JavaVisibilityPanel(com.intellij.refactoring.ui.JavaVisibilityPanel)

Example 5 with MemberSelectionPanel

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

the class ExtractMethodObjectProcessor method moveUsedMethodsToInner.

void moveUsedMethodsToInner() {
    if (!myUsages.isEmpty()) {
        if (ApplicationManager.getApplication().isUnitTestMode()) {
            WriteAction.run(() -> {
                for (MethodToMoveUsageInfo usage : myUsages) {
                    final PsiMember member = (PsiMember) usage.getElement();
                    LOG.assertTrue(member != null);
                    myInnerClass.add(member.copy());
                    member.delete();
                }
            });
            return;
        }
        final List<MemberInfo> memberInfos = new ArrayList<>();
        for (MethodToMoveUsageInfo usage : myUsages) {
            memberInfos.add(new MemberInfo((PsiMethod) usage.getElement()));
        }
        final MemberSelectionPanel panel = new MemberSelectionPanel("&Methods to move to the extracted class", memberInfos, null);
        DialogWrapper dlg = new DialogWrapper(myProject, false) {

            {
                init();
                setTitle("Move Methods Used in Extracted Block Only");
            }

            @Override
            protected JComponent createCenterPanel() {
                return panel;
            }
        };
        if (dlg.showAndGet()) {
            WriteAction.run(() -> {
                for (MemberInfoBase<PsiMember> memberInfo : panel.getTable().getSelectedMemberInfos()) {
                    if (memberInfo.isChecked()) {
                        myInnerClass.add(memberInfo.getMember().copy());
                        memberInfo.getMember().delete();
                    }
                }
            });
        }
    }
}
Also used : MemberInfo(com.intellij.refactoring.util.classMembers.MemberInfo) MemberSelectionPanel(com.intellij.refactoring.ui.MemberSelectionPanel) DialogWrapper(com.intellij.openapi.ui.DialogWrapper)

Aggregations

MemberSelectionPanel (com.intellij.refactoring.ui.MemberSelectionPanel)6 MemberInfo (com.intellij.refactoring.util.classMembers.MemberInfo)5 PsiMember (com.intellij.psi.PsiMember)2 DialogWrapper (com.intellij.openapi.ui.DialogWrapper)1 PsiMethod (com.intellij.psi.PsiMethod)1 JavaVisibilityPanel (com.intellij.refactoring.ui.JavaVisibilityPanel)1 MemberSelectionTable (com.intellij.refactoring.ui.MemberSelectionTable)1 UsesAndInterfacesDependencyMemberInfoModel (com.intellij.refactoring.util.classMembers.UsesAndInterfacesDependencyMemberInfoModel)1