Search in sources :

Example 1 with DestinationFolderComboBox

use of com.intellij.refactoring.move.moveClassesOrPackages.DestinationFolderComboBox in project kotlin by JetBrains.

the class MoveKotlinTopLevelDeclarationsDialog method createUIComponents.

private void createUIComponents() {
    classPackageChooser = createPackageChooser();
    destinationFolderCB = new DestinationFolderComboBox() {

        @Override
        public String getTargetPackage() {
            return MoveKotlinTopLevelDeclarationsDialog.this.getTargetPackage();
        }
    };
}
Also used : DestinationFolderComboBox(com.intellij.refactoring.move.moveClassesOrPackages.DestinationFolderComboBox)

Example 2 with DestinationFolderComboBox

use of com.intellij.refactoring.move.moveClassesOrPackages.DestinationFolderComboBox in project intellij-community by JetBrains.

the class WrapReturnValueDialog method createUIComponents.

private void createUIComponents() {
    final com.intellij.openapi.editor.event.DocumentAdapter adapter = new com.intellij.openapi.editor.event.DocumentAdapter() {

        public void documentChanged(com.intellij.openapi.editor.event.DocumentEvent e) {
            validateButtons();
        }
    };
    packageTextField = new PackageNameReferenceEditorCombo("", myProject, RECENT_KEYS, RefactoringBundle.message("choose.destination.package"));
    packageTextField.getChildComponent().getDocument().addDocumentListener(adapter);
    existingClassField = new ReferenceEditorComboWithBrowseButton(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            final TreeClassChooser chooser = TreeClassChooserFactory.getInstance(getProject()).createWithInnerClassesScopeChooser(RefactorJBundle.message("select.wrapper.class"), GlobalSearchScope.allScope(myProject), null, null);
            final String classText = existingClassField.getText();
            final PsiClass currentClass = JavaPsiFacade.getInstance(myProject).findClass(classText, GlobalSearchScope.allScope(myProject));
            if (currentClass != null) {
                chooser.select(currentClass);
            }
            chooser.showDialog();
            final PsiClass selectedClass = chooser.getSelected();
            if (selectedClass != null) {
                existingClassField.setText(selectedClass.getQualifiedName());
            }
        }
    }, "", myProject, true, RECENT_KEYS);
    existingClassField.getChildComponent().getDocument().addDocumentListener(adapter);
    myDestinationCb = new DestinationFolderComboBox() {

        @Override
        public String getTargetPackage() {
            return getPackageName();
        }
    };
    ((DestinationFolderComboBox) myDestinationCb).setData(myProject, sourceMethod.getContainingFile().getContainingDirectory(), packageTextField.getChildComponent());
}
Also used : TreeClassChooser(com.intellij.ide.util.TreeClassChooser) ActionEvent(java.awt.event.ActionEvent) DocumentAdapter(com.intellij.ui.DocumentAdapter) DocumentEvent(javax.swing.event.DocumentEvent) PackageNameReferenceEditorCombo(com.intellij.refactoring.ui.PackageNameReferenceEditorCombo) ReferenceEditorComboWithBrowseButton(com.intellij.ui.ReferenceEditorComboWithBrowseButton) ActionListener(java.awt.event.ActionListener) DestinationFolderComboBox(com.intellij.refactoring.move.moveClassesOrPackages.DestinationFolderComboBox)

Example 3 with DestinationFolderComboBox

use of com.intellij.refactoring.move.moveClassesOrPackages.DestinationFolderComboBox in project intellij-community by JetBrains.

the class IntroduceParameterObjectDialog method createClassDescriptor.

@Override
protected JavaIntroduceParameterObjectClassDescriptor createClassDescriptor() {
    final boolean useExistingClass = useExistingClass();
    final String className;
    final String packageName;
    final boolean createInnerClass = myCreateInnerClassRadioButton.isSelected();
    if (createInnerClass) {
        className = getInnerClassName();
        packageName = "";
    } else if (useExistingClass) {
        final String existingClassName = getExistingClassName();
        className = StringUtil.getShortName(existingClassName);
        packageName = StringUtil.getPackageName(existingClassName);
    } else {
        packageName = getPackageName();
        className = getClassName();
    }
    final String newVisibility = myEscalateVisibilityCheckBox.isEnabled() && myEscalateVisibilityCheckBox.isSelected() ? VisibilityUtil.ESCALATE_VISIBILITY : null;
    final MoveDestination moveDestination = ((DestinationFolderComboBox) myDestinationCb).selectDirectory(new PackageWrapper(PsiManager.getInstance(myProject), packageName), false);
    final PsiParameterList parameterList = mySourceMethod.getParameterList();
    final List<ParameterInfoImpl> parameters = new ArrayList<>();
    for (VariableData data : myParameterTablePanel.getVariableData()) {
        if (data.passAsParameter) {
            parameters.add(new ParameterInfoImpl(parameterList.getParameterIndex((PsiParameter) data.variable), data.name, data.type));
        }
    }
    final ParameterInfoImpl[] infos = parameters.toArray(new ParameterInfoImpl[parameters.size()]);
    return new JavaIntroduceParameterObjectClassDescriptor(className, packageName, moveDestination, useExistingClass, createInnerClass, newVisibility, infos, mySourceMethod, myGenerateAccessorsCheckBox.isSelected());
}
Also used : ArrayList(java.util.ArrayList) DestinationFolderComboBox(com.intellij.refactoring.move.moveClassesOrPackages.DestinationFolderComboBox) ParameterInfoImpl(com.intellij.refactoring.changeSignature.ParameterInfoImpl) VariableData(com.intellij.refactoring.util.VariableData)

Example 4 with DestinationFolderComboBox

use of com.intellij.refactoring.move.moveClassesOrPackages.DestinationFolderComboBox in project intellij-community by JetBrains.

the class WrapReturnValueDialog method doAction.

protected void doAction() {
    final boolean useExistingClass = useExistingClassButton.isSelected();
    final boolean createInnerClass = myCreateInnerClassButton.isSelected();
    final String existingClassName = existingClassField.getText().trim();
    final String className;
    final String packageName;
    if (useExistingClass) {
        className = StringUtil.getShortName(existingClassName);
        packageName = StringUtil.getPackageName(existingClassName);
    } else if (createInnerClass) {
        className = getInnerClassName();
        packageName = "";
    } else {
        className = getClassName();
        packageName = getPackageName();
    }
    invokeRefactoring(new WrapReturnValueProcessor(className, packageName, ((DestinationFolderComboBox) myDestinationCb).selectDirectory(new PackageWrapper(sourceMethod.getManager(), packageName), false), sourceMethod, useExistingClass, createInnerClass, (PsiField) myFieldsCombo.getSelectedItem()));
}
Also used : DestinationFolderComboBox(com.intellij.refactoring.move.moveClassesOrPackages.DestinationFolderComboBox) PackageWrapper(com.intellij.refactoring.PackageWrapper)

Example 5 with DestinationFolderComboBox

use of com.intellij.refactoring.move.moveClassesOrPackages.DestinationFolderComboBox in project intellij-community by JetBrains.

the class ReplaceConstructorWithBuilderDialog method createUIComponents.

private void createUIComponents() {
    final com.intellij.openapi.editor.event.DocumentAdapter adapter = new com.intellij.openapi.editor.event.DocumentAdapter() {

        public void documentChanged(com.intellij.openapi.editor.event.DocumentEvent e) {
            validateButtons();
        }
    };
    myPackageTextField = new PackageNameReferenceEditorCombo(((PsiJavaFile) myConstructors[0].getContainingFile()).getPackageName(), myProject, RECENT_KEYS, RefactoringBundle.message("choose.destination.package"));
    myPackageTextField.getChildComponent().getDocument().addDocumentListener(adapter);
    myDestinationCb = new DestinationFolderComboBox() {

        @Override
        public String getTargetPackage() {
            return myPackageTextField.getText().trim();
        }
    };
    ((DestinationFolderComboBox) myDestinationCb).setData(myProject, myConstructors[0].getContainingFile().getContainingDirectory(), myPackageTextField.getChildComponent());
    myExistentClassTF = new ReferenceEditorComboWithBrowseButton(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            final TreeClassChooser chooser = TreeClassChooserFactory.getInstance(getProject()).createWithInnerClassesScopeChooser("Select Builder Class", GlobalSearchScope.projectScope(myProject), null, null);
            final String classText = myExistentClassTF.getText();
            final PsiClass currentClass = JavaPsiFacade.getInstance(myProject).findClass(classText, GlobalSearchScope.allScope(myProject));
            if (currentClass != null) {
                chooser.select(currentClass);
            }
            chooser.showDialog();
            final PsiClass selectedClass = chooser.getSelected();
            if (selectedClass != null) {
                myExistentClassTF.setText(selectedClass.getQualifiedName());
            }
        }
    }, "", myProject, true, RECENT_KEYS);
    myExistentClassTF.getChildComponent().getDocument().addDocumentListener(adapter);
}
Also used : TreeClassChooser(com.intellij.ide.util.TreeClassChooser) ActionEvent(java.awt.event.ActionEvent) DocumentEvent(javax.swing.event.DocumentEvent) PackageNameReferenceEditorCombo(com.intellij.refactoring.ui.PackageNameReferenceEditorCombo) ActionListener(java.awt.event.ActionListener) DestinationFolderComboBox(com.intellij.refactoring.move.moveClassesOrPackages.DestinationFolderComboBox)

Aggregations

DestinationFolderComboBox (com.intellij.refactoring.move.moveClassesOrPackages.DestinationFolderComboBox)8 ActionEvent (java.awt.event.ActionEvent)4 ActionListener (java.awt.event.ActionListener)4 PackageNameReferenceEditorCombo (com.intellij.refactoring.ui.PackageNameReferenceEditorCombo)3 DocumentEvent (javax.swing.event.DocumentEvent)3 TreeClassChooser (com.intellij.ide.util.TreeClassChooser)2 PackageWrapper (com.intellij.refactoring.PackageWrapper)2 DocumentAdapter (com.intellij.ui.DocumentAdapter)2 ReferenceEditorComboWithBrowseButton (com.intellij.ui.ReferenceEditorComboWithBrowseButton)2 TreeJavaClassChooserDialog (com.intellij.ide.util.TreeJavaClassChooserDialog)1 Document (com.intellij.openapi.editor.Document)1 Project (com.intellij.openapi.project.Project)1 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)1 ParameterInfoImpl (com.intellij.refactoring.changeSignature.ParameterInfoImpl)1 VariableData (com.intellij.refactoring.util.VariableData)1 ArrayList (java.util.ArrayList)1