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 TextControl method createMainComponent.
@Override
protected TextPanel createMainComponent(TextPanel boundedComponent, final Project project) {
if (boundedComponent == null) {
boundedComponent = new TextPanel();
}
boundedComponent.removeAll();
final Function<String, Document> factory = s -> PsiDocumentManager.getInstance(project).getDocument(PsiFileFactory.getInstance(project).createFileFromText("a.txt", PlainTextLanguage.INSTANCE, "", true, false));
final TextPanel boundedComponent1 = boundedComponent;
final EditorTextField editorTextField = new EditorTextField(factory.fun(""), project, FileTypes.PLAIN_TEXT) {
@Override
protected EditorEx createEditor() {
final EditorEx editor = super.createEditor();
return boundedComponent1 instanceof MultiLineTextPanel ? makeBigEditor(editor, ((MultiLineTextPanel) boundedComponent1).getRowCount()) : editor;
}
@Override
protected boolean isOneLineMode() {
return false;
}
};
if (boundedComponent instanceof BigTextPanel) {
final ReferenceEditorWithBrowseButton editor = new ReferenceEditorWithBrowseButton(null, editorTextField, factory);
boundedComponent.add(editor);
editor.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
EditorTextField textArea = new EditorTextField(editorTextField.getDocument(), project, FileTypes.PLAIN_TEXT) {
@Override
protected EditorEx createEditor() {
final EditorEx editor = super.createEditor();
editor.setEmbeddedIntoDialogWrapper(true);
return makeBigEditor(editor, 5);
}
@Override
protected boolean isOneLineMode() {
return false;
}
};
DialogBuilder builder = new DialogBuilder(project);
builder.setDimensionServiceKey("TextControl");
builder.setCenterPanel(textArea);
builder.setPreferredFocusComponent(textArea);
builder.setTitle(UIBundle.message("big.text.control.window.title"));
builder.addCloseButton();
builder.show();
}
});
return boundedComponent;
}
boundedComponent.add(editorTextField);
return boundedComponent;
}
use of com.intellij.ui.EditorTextField in project intellij-community by JetBrains.
the class EditorTextFieldControl method doReset.
@Override
protected void doReset() {
final EditorTextField textField = getEditorTextField(getComponent());
textField.getDocument().removeDocumentListener(myListener);
super.doReset();
textField.getDocument().addDocumentListener(myListener);
}
Aggregations