use of com.intellij.refactoring.move.moveClassesOrPackages.DestinationFolderComboBox in project intellij-community by JetBrains.
the class ReplaceConstructorWithBuilderDialog method doAction.
protected void doAction() {
TableUtil.stopEditing(myTable);
final String className;
final String packageName;
if (myCreateBuilderClassRadioButton.isSelected()) {
className = myNewClassName.getText().trim();
packageName = myPackageTextField.getText().trim();
} else {
final String fqName = myExistentClassTF.getText().trim();
className = StringUtil.getShortName(fqName);
packageName = StringUtil.getPackageName(fqName);
final PsiClass builderClass = JavaPsiFacade.getInstance(myProject).findClass(StringUtil.getQualifiedName(packageName, className), GlobalSearchScope.projectScope(myProject));
if (builderClass != null && !CommonRefactoringUtil.checkReadOnlyStatus(myProject, builderClass))
return;
}
invokeRefactoring(new ReplaceConstructorWithBuilderProcessor(getProject(), myConstructors, myParametersMap, className, packageName, ((DestinationFolderComboBox) myDestinationCb).selectDirectory(new PackageWrapper(myConstructors[0].getManager(), packageName), false), myCreateBuilderClassRadioButton.isSelected()));
}
use of com.intellij.refactoring.move.moveClassesOrPackages.DestinationFolderComboBox in project intellij-community by JetBrains.
the class IntroduceParameterObjectDialog method createUIComponents.
private void createUIComponents() {
final PsiFile file = mySourceMethod.getContainingFile();
packageTextField = new PackageNameReferenceEditorCombo(file instanceof PsiJavaFile ? ((PsiJavaFile) file).getPackageName() : "", myProject, RECENTS_KEY, RefactoringBundle.message("choose.destination.package"));
final Document document = packageTextField.getChildComponent().getDocument();
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();
}
};
document.addDocumentListener(adapter);
existingClassField = new ReferenceEditorComboWithBrowseButton(new ActionListener() {
public void actionPerformed(ActionEvent e) {
final Project project = mySourceMethod.getProject();
final GlobalSearchScope scope = GlobalSearchScope.allScope(project);
final TreeJavaClassChooserDialog chooser = new TreeJavaClassChooserDialog(RefactorJBundle.message("select.wrapper.class"), project, scope, null, null);
final String classText = existingClassField.getText();
final PsiClass currentClass = JavaPsiFacade.getInstance(project).findClass(classText, GlobalSearchScope.allScope(project));
if (currentClass != null) {
chooser.select(currentClass);
}
chooser.show();
final PsiClass selectedClass = chooser.getSelected();
if (selectedClass != null) {
final String className = selectedClass.getQualifiedName();
existingClassField.setText(className);
RecentsManager.getInstance(myProject).registerRecentEntry(EXISTING_KEY, className);
}
}
}, "", myProject, true, EXISTING_KEY);
existingClassField.getChildComponent().getDocument().addDocumentListener(new com.intellij.openapi.editor.event.DocumentAdapter() {
@Override
public void documentChanged(com.intellij.openapi.editor.event.DocumentEvent e) {
validateButtons();
enableGenerateAccessors();
}
});
myDestinationCb = new DestinationFolderComboBox() {
@Override
public String getTargetPackage() {
return getPackageName();
}
};
((DestinationFolderComboBox) myDestinationCb).setData(myProject, mySourceMethod.getContainingFile().getContainingDirectory(), packageTextField.getChildComponent());
}
use of com.intellij.refactoring.move.moveClassesOrPackages.DestinationFolderComboBox in project kotlin by JetBrains.
the class MoveKotlinTopLevelDeclarationsDialog method initPackageChooser.
private void initPackageChooser(String targetPackageName, PsiDirectory targetDirectory, List<KtFile> sourceFiles) {
if (targetPackageName != null) {
classPackageChooser.prependItem(targetPackageName);
}
((DestinationFolderComboBox) destinationFolderCB).setData(myProject, targetDirectory, new Pass<String>() {
@Override
public void pass(String s) {
setErrorText(s);
}
}, classPackageChooser.getChildComponent());
cbSpecifyFileNameInPackage.addActionListener(new ActionListener() {
@Override
public void actionPerformed(@NotNull ActionEvent e) {
updateFileNameInPackageField();
}
});
cbUpdatePackageDirective.setSelected(arePackagesAndDirectoryMatched(sourceFiles));
}
Aggregations