use of com.intellij.ui.EditorTextField in project intellij-community by JetBrains.
the class CopyClassDialog method createNorthPanel.
protected JComponent createNorthPanel() {
myNameField = new EditorTextField("");
String qualifiedName = getQualifiedName();
myTfPackage = new PackageNameReferenceEditorCombo(qualifiedName, myProject, RECENTS_KEY, RefactoringBundle.message("choose.destination.package"));
myTfPackage.setTextFieldPreferredWidth(Math.max(qualifiedName.length() + 5, 40));
myPackageLabel.setText(RefactoringBundle.message("destination.package"));
myPackageLabel.setLabelFor(myTfPackage);
if (myDoClone) {
myTfPackage.setVisible(false);
myPackageLabel.setVisible(false);
}
final JLabel label = new JLabel(RefactoringBundle.message("target.destination.folder"));
final boolean isMultipleSourceRoots = JavaProjectRootsUtil.getSuitableDestinationSourceRoots(myProject).size() > 1;
myDestinationCB.setVisible(!myDoClone && isMultipleSourceRoots);
label.setVisible(!myDoClone && isMultipleSourceRoots);
label.setLabelFor(myDestinationCB);
final JPanel panel = new JPanel(new BorderLayout());
panel.add(myOpenInEditorCb, BorderLayout.EAST);
return FormBuilder.createFormBuilder().addComponent(myInformationLabel).addLabeledComponent(RefactoringBundle.message("copy.files.new.name.label"), myNameField, UIUtil.LARGE_VGAP).addLabeledComponent(myPackageLabel, myTfPackage).addLabeledComponent(label, myDestinationCB).addComponent(panel).getPanel();
}
use of com.intellij.ui.EditorTextField in project intellij-community by JetBrains.
the class ExternalProjectPathField method createPanel.
@NotNull
public static MyPathAndProjectButtonPanel createPanel(@NotNull final Project project, @NotNull final ProjectSystemId externalSystemId) {
final EditorTextField textField = createTextField(project, externalSystemId);
final FixedSizeButton selectRegisteredProjectButton = new FixedSizeButton();
selectRegisteredProjectButton.setIcon(AllIcons.Actions.Module);
String tooltipText = ExternalSystemBundle.message("run.configuration.tooltip.choose.registered.project", externalSystemId.getReadableName());
selectRegisteredProjectButton.setToolTipText(tooltipText);
selectRegisteredProjectButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
final Ref<JBPopup> popupRef = new Ref<>();
final Tree tree = buildRegisteredProjectsTree(project, externalSystemId);
tree.setBorder(IdeBorderFactory.createEmptyBorder(8));
Runnable treeSelectionCallback = () -> {
TreePath path = tree.getSelectionPath();
if (path != null) {
Object lastPathComponent = path.getLastPathComponent();
if (lastPathComponent instanceof ExternalSystemNode) {
Object e1 = ((ExternalSystemNode) lastPathComponent).getDescriptor().getElement();
if (e1 instanceof ExternalProjectPojo) {
ExternalProjectPojo pojo = (ExternalProjectPojo) e1;
textField.setText(pojo.getPath());
Editor editor = textField.getEditor();
if (editor != null) {
collapseIfPossible(editor, externalSystemId, project);
}
}
}
}
popupRef.get().closeOk(null);
};
JBPopup popup = new PopupChooserBuilder(tree).setTitle(ExternalSystemBundle.message("run.configuration.title.choose.registered.project", externalSystemId.getReadableName())).setResizable(true).setItemChoosenCallback(treeSelectionCallback).setAutoselectOnMouseMove(true).setCloseOnEnter(false).createPopup();
popupRef.set(popup);
popup.showUnderneathOf(selectRegisteredProjectButton);
}
});
return new MyPathAndProjectButtonPanel(textField, selectRegisteredProjectButton);
}
use of com.intellij.ui.EditorTextField in project intellij-community by JetBrains.
the class ExternalProjectPathField method createTextField.
@NotNull
private static EditorTextField createTextField(@NotNull final Project project, @NotNull final ProjectSystemId externalSystemId) {
ExternalSystemManager<?, ?, ?, ?, ?> manager = ExternalSystemApiUtil.getManager(externalSystemId);
assert manager != null;
final AbstractExternalSystemLocalSettings settings = manager.getLocalSettingsProvider().fun(project);
final ExternalSystemUiAware uiAware = ExternalSystemUiUtil.getUiAware(externalSystemId);
TextFieldCompletionProvider provider = new TextFieldCompletionProviderDumbAware() {
@Override
protected void addCompletionVariants(@NotNull String text, int offset, @NotNull String prefix, @NotNull CompletionResultSet result) {
for (Map.Entry<ExternalProjectPojo, Collection<ExternalProjectPojo>> entry : settings.getAvailableProjects().entrySet()) {
String rootProjectPath = entry.getKey().getPath();
String rootProjectName = uiAware.getProjectRepresentationName(rootProjectPath, null);
ExternalProjectPathLookupElement rootProjectElement = new ExternalProjectPathLookupElement(rootProjectName, rootProjectPath);
result.addElement(rootProjectElement);
for (ExternalProjectPojo subProject : entry.getValue()) {
String p = subProject.getPath();
if (rootProjectPath.equals(p)) {
continue;
}
String subProjectName = uiAware.getProjectRepresentationName(p, rootProjectPath);
ExternalProjectPathLookupElement subProjectElement = new ExternalProjectPathLookupElement(subProjectName, p);
result.addElement(subProjectElement);
}
}
result.stopHere();
}
};
EditorTextField result = provider.createEditor(project, false, editor -> {
collapseIfPossible(editor, externalSystemId, project);
editor.getSettings().setShowIntentionBulb(false);
});
result.setBorder(UIUtil.getTextFieldBorder());
result.setOneLineMode(true);
result.setOpaque(true);
result.setBackground(UIUtil.getTextFieldBackground());
return result;
}
use of com.intellij.ui.EditorTextField in project intellij-community by JetBrains.
the class MoveInstanceMethodDialog method doAction.
protected void doAction() {
Map<PsiClass, String> parameterNames = new LinkedHashMap<>();
for (final PsiClass aClass : myThisClassesMap.keySet()) {
EditorTextField field = myOldClassParameterNameFields.get(aClass);
if (field.isEnabled()) {
String parameterName = field.getText().trim();
if (!PsiNameHelper.getInstance(myMethod.getProject()).isIdentifier(parameterName)) {
Messages.showErrorDialog(getProject(), RefactoringBundle.message("move.method.enter.a.valid.name.for.parameter"), myRefactoringName);
return;
}
parameterNames.put(aClass, parameterName);
}
}
final PsiVariable targetVariable = (PsiVariable) myList.getSelectedValue();
if (targetVariable == null)
return;
final MoveInstanceMethodProcessor processor = new MoveInstanceMethodProcessor(myMethod.getProject(), myMethod, targetVariable, myVisibilityPanel.getVisibility(), isOpenInEditor(), parameterNames);
if (!verifyTargetClass(processor.getTargetClass()))
return;
saveOpenInEditorOption();
invokeRefactoring(processor);
}
use of com.intellij.ui.EditorTextField in project intellij-community by JetBrains.
the class MoveInstanceMethodDialog method validateTextFields.
private void validateTextFields(final int selectedIndex) {
for (EditorTextField textField : myOldClassParameterNameFields.values()) {
textField.setEnabled(true);
}
final PsiVariable variable = myVariables[selectedIndex];
if (variable instanceof PsiField) {
final PsiField field = (PsiField) variable;
final PsiClass hisClass = field.getContainingClass();
final Set<PsiMember> members = myThisClassesMap.get(hisClass);
if (members != null && members.size() == 1 && members.contains(field)) {
//Just the field is referenced
myOldClassParameterNameFields.get(hisClass).setEnabled(false);
}
}
}
Aggregations