use of com.intellij.util.TextFieldCompletionProvider in project intellij-community by JetBrains.
the class MvcRunTargetDialog method createUIComponents.
private void createUIComponents() {
myTargetField = new ComboBox(MvcRunTargetHistoryService.getInstance().getHistory());
myTargetField.setLightWeightPopupEnabled(false);
EditorComboBoxEditor editor = new StringComboboxEditor(myModule.getProject(), PlainTextFileType.INSTANCE, myTargetField);
myTargetField.setRenderer(new EditorComboBoxRenderer(editor));
myTargetField.setEditable(true);
myTargetField.setEditor(editor);
EditorTextField editorTextField = editor.getEditorComponent();
myFakePanel = new JPanel(new BorderLayout());
myFakePanel.add(myTargetField, BorderLayout.CENTER);
TextFieldCompletionProvider vmOptionCompletionProvider = new TextFieldCompletionProviderDumbAware() {
@NotNull
@Override
protected String getPrefix(@NotNull String currentTextPrefix) {
return MvcRunTargetDialog.getPrefix(currentTextPrefix);
}
@Override
protected void addCompletionVariants(@NotNull String text, int offset, @NotNull String prefix, @NotNull CompletionResultSet result) {
if (prefix.endsWith("-D")) {
result.addAllElements(MvcTargetDialogCompletionUtils.getSystemPropertiesVariants());
}
}
};
myVmOptionsField = vmOptionCompletionProvider.createEditor(myModule.getProject());
new TextFieldCompletionProviderDumbAware() {
@NotNull
@Override
protected String getPrefix(@NotNull String currentTextPrefix) {
return MvcRunTargetDialog.getPrefix(currentTextPrefix);
}
@Override
protected void addCompletionVariants(@NotNull String text, int offset, @NotNull String prefix, @NotNull CompletionResultSet result) {
for (LookupElement variant : MvcTargetDialogCompletionUtils.collectVariants(myModule, text, offset, prefix)) {
result.addElement(variant);
}
}
}.apply(editorTextField);
editorTextField.getDocument().addDocumentListener(new DocumentAdapter() {
@Override
public void documentChanged(DocumentEvent e) {
setOKActionEnabled(!StringUtil.isEmptyOrSpaces(e.getDocument().getText()));
}
});
setOKActionEnabled(false);
}
use of com.intellij.util.TextFieldCompletionProvider 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;
}
Aggregations