use of com.intellij.ui.EditorComboBoxRenderer 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.ui.EditorComboBoxRenderer in project intellij-community by JetBrains.
the class PyIntroduceDialog method setUpNameComboBox.
private void setUpNameComboBox(Collection<String> possibleNames) {
final EditorComboBoxEditor comboEditor = new StringComboboxEditor(myProject, PythonFileType.INSTANCE, myNameComboBox);
myNameComboBox.setEditor(comboEditor);
myNameComboBox.setRenderer(new EditorComboBoxRenderer(comboEditor));
myNameComboBox.setEditable(true);
myNameComboBox.setMaximumRowCount(8);
myNameComboBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
updateControls();
}
});
((EditorTextField) myNameComboBox.getEditor().getEditorComponent()).addDocumentListener(new DocumentListener() {
public void beforeDocumentChange(DocumentEvent event) {
}
public void documentChanged(DocumentEvent event) {
updateControls();
}
});
myContentPane.registerKeyboardAction(new ActionListener() {
public void actionPerformed(ActionEvent e) {
IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> {
IdeFocusManager.getGlobalInstance().requestFocus(myNameComboBox, true);
});
}
}, KeyStroke.getKeyStroke(KeyEvent.VK_N, KeyEvent.ALT_MASK), JComponent.WHEN_IN_FOCUSED_WINDOW);
for (String possibleName : possibleNames) {
myNameComboBox.addItem(possibleName);
}
}
use of com.intellij.ui.EditorComboBoxRenderer in project intellij-community by JetBrains.
the class XDebuggerExpressionComboBox method initEditor.
private void initEditor() {
myEditor = new XDebuggerComboBoxEditor();
myComboBox.setEditor(myEditor);
//myEditor.setItem(myExpression);
myComboBox.setRenderer(new EditorComboBoxRenderer(myEditor));
myComboBox.setMaximumRowCount(XDebuggerHistoryManager.MAX_RECENT_EXPRESSIONS);
}
use of com.intellij.ui.EditorComboBoxRenderer in project intellij-community by JetBrains.
the class NameSuggestionsField method setupComboBox.
private void setupComboBox(final ComboBox combobox, FileType fileType) {
final EditorComboBoxEditor comboEditor = new StringComboboxEditor(myProject, fileType, combobox) {
@Override
public void setItem(Object anObject) {
myNonHumanChange = true;
super.setItem(anObject);
}
};
combobox.setEditor(comboEditor);
combobox.setRenderer(new EditorComboBoxRenderer(comboEditor));
combobox.setEditable(true);
combobox.setMaximumRowCount(8);
comboEditor.selectAll();
}
use of com.intellij.ui.EditorComboBoxRenderer in project intellij-community by JetBrains.
the class MavenEditGoalDialog method setUpDialog.
private void setUpDialog() {
JComponent goalComponent;
if (myHistory == null) {
goalsEditor = new EditorTextField("", myProject, PlainTextFileType.INSTANCE);
goalComponent = goalsEditor;
goalsLabel.setLabelFor(goalsEditor);
} else {
goalsComboBox = new ComboBox(ArrayUtilRt.toStringArray(myHistory));
goalComponent = goalsComboBox;
goalsLabel.setLabelFor(goalsComboBox);
goalsComboBox.setLightWeightPopupEnabled(false);
EditorComboBoxEditor editor = new StringComboboxEditor(myProject, PlainTextFileType.INSTANCE, goalsComboBox);
goalsComboBox.setRenderer(new EditorComboBoxRenderer(editor));
goalsComboBox.setEditable(true);
goalsComboBox.setEditor(editor);
goalsComboBox.setFocusable(true);
goalsEditor = editor.getEditorComponent();
}
goalsPanel.add(goalComponent);
new MavenArgumentsCompletionProvider(myProject).apply(goalsEditor);
MavenProjectsManager projectsManager = MavenProjectsManager.getInstance(myProject);
showProjectTreeButton.setIcon(AllIcons.Actions.Module);
MavenSelectProjectPopup.attachToWorkingDirectoryField(projectsManager, workDirectoryField.getTextField(), showProjectTreeButton, goalsComboBox != null ? goalsComboBox : goalsEditor);
workDirectoryField.addBrowseFolderListener(RunnerBundle.message("maven.select.maven.project.file"), "", myProject, new FileChooserDescriptor(false, true, false, false, false, false) {
@Override
public boolean isFileSelectable(VirtualFile file) {
if (!super.isFileSelectable(file))
return false;
for (VirtualFile child : file.getChildren()) {
if (MavenUtil.isPomFileName(child.getName()))
return true;
}
return false;
}
});
}
Aggregations