use of com.intellij.ui.EditorTextField in project intellij-community by JetBrains.
the class EditVarConstraintsDialog method createRegexComponent.
private static EditorTextField createRegexComponent() {
@NonNls final String fileName = "1.regexp";
final FileType fileType = getFileType(fileName);
final Document doc = createDocument(fileName, fileType, "");
return new EditorTextField(doc, myProject, fileType);
}
use of com.intellij.ui.EditorTextField in project intellij-community by JetBrains.
the class DebuggerUIUtil method showValuePopup.
public static void showValuePopup(@NotNull XFullValueEvaluator evaluator, @NotNull MouseEvent event, @NotNull Project project, @Nullable Editor editor) {
EditorTextField textArea = new TextViewer("Evaluating...", project);
textArea.setBackground(HintUtil.getInformationColor());
final FullValueEvaluationCallbackImpl callback = new FullValueEvaluationCallbackImpl(textArea);
evaluator.startEvaluation(callback);
Dimension size = DimensionService.getInstance().getSize(FULL_VALUE_POPUP_DIMENSION_KEY, project);
if (size == null) {
Dimension frameSize = WindowManager.getInstance().getFrame(project).getSize();
size = new Dimension(frameSize.width / 2, frameSize.height / 2);
}
textArea.setPreferredSize(size);
JBPopup popup = createValuePopup(project, textArea, callback);
if (editor == null) {
Rectangle bounds = new Rectangle(event.getLocationOnScreen(), size);
ScreenUtil.fitToScreenVertical(bounds, 5, 5, true);
if (size.width != bounds.width || size.height != bounds.height) {
size = bounds.getSize();
textArea.setPreferredSize(size);
}
popup.showInScreenCoordinates(event.getComponent(), bounds.getLocation());
} else {
popup.showInBestPositionFor(editor);
}
}
use of com.intellij.ui.EditorTextField in project android by JetBrains.
the class SpecificActivityConfigurable method createUIComponents.
private void createUIComponents() {
final EditorTextField editorTextField = new LanguageTextField(PlainTextLanguage.INSTANCE, myProject, "") {
@Override
protected EditorEx createEditor() {
final EditorEx editor = super.createEditor();
final PsiFile file = PsiDocumentManager.getInstance(myProject).getPsiFile(editor.getDocument());
if (file != null) {
DaemonCodeAnalyzer.getInstance(myProject).setHighlightingEnabled(file, false);
}
editor.putUserData(LaunchOptionConfigurableContext.KEY, myContext);
return editor;
}
};
myActivityField = new ComponentWithBrowseButton<EditorTextField>(editorTextField, null);
}
use of com.intellij.ui.EditorTextField in project android by JetBrains.
the class RenameRefactoringDialogFixture method setNewName.
@NotNull
public RenameRefactoringDialogFixture setNewName(@NotNull final String newName) {
final EditorTextField field = robot().finder().findByType(target(), EditorTextField.class);
GuiActionRunner.execute(new GuiTask() {
@Override
protected void executeInEDT() throws Throwable {
IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> {
IdeFocusManager.getGlobalInstance().requestFocus(field, true);
});
}
});
// to make sure we don't append to existing item on Linux
robot().pressAndReleaseKey(KeyEvent.VK_BACK_SPACE);
robot().enterText(newName);
Wait.seconds(1).expecting("EditorTextField to show new name").until(() -> newName.equals(field.getText()));
return this;
}
use of com.intellij.ui.EditorTextField in project intellij-community by JetBrains.
the class CheckRegExpForm method createUIComponents.
private void createUIComponents() {
myProject = myRegexpFile.getProject();
Document document = PsiDocumentManager.getInstance(myProject).getDocument(myRegexpFile);
final Language language = myRegexpFile.getLanguage();
final LanguageFileType fileType;
if (language instanceof RegExpLanguage) {
fileType = RegExpLanguage.INSTANCE.getAssociatedFileType();
} else {
// for correct syntax highlighting
fileType = new RegExpFileType(language);
}
myRegExp = new EditorTextField(document, myProject, fileType);
final String sampleText = PropertiesComponent.getInstance(myProject).getValue(LAST_EDITED_REGEXP, "Sample Text");
mySampleText = new EditorTextField(sampleText, myProject, PlainTextFileType.INSTANCE) {
@Override
protected void updateBorder(@NotNull EditorEx editor) {
setupBorder(editor);
}
};
mySampleText.setOneLineMode(false);
int preferredWidth = Math.max(JBUI.scale(250), myRegExp.getPreferredSize().width);
myRegExp.setPreferredWidth(preferredWidth);
mySampleText.setPreferredWidth(preferredWidth);
myRootPanel = new JPanel(new BorderLayout()) {
Disposable disposable;
Alarm updater;
@Override
public void addNotify() {
super.addNotify();
disposable = Disposer.newDisposable();
IdeFocusManager.getGlobalInstance().requestFocus(mySampleText, true);
new AnAction() {
@Override
public void actionPerformed(AnActionEvent e) {
IdeFocusManager.findInstance().requestFocus(myRegExp.getFocusTarget(), true);
}
}.registerCustomShortcutSet(CustomShortcutSet.fromString("shift TAB"), mySampleText);
updater = new Alarm(Alarm.ThreadToUse.POOLED_THREAD, disposable);
DocumentAdapter documentListener = new DocumentAdapter() {
@Override
public void documentChanged(DocumentEvent e) {
update();
}
};
myRegExp.addDocumentListener(documentListener);
mySampleText.addDocumentListener(documentListener);
update();
mySampleText.selectAll();
}
public void update() {
final TransactionId transactionId = TransactionGuard.getInstance().getContextTransaction();
updater.cancelAllRequests();
if (!updater.isDisposed()) {
updater.addRequest(() -> {
final RegExpMatchResult result = isMatchingText(myRegexpFile, mySampleText.getText());
TransactionGuard.getInstance().submitTransaction(myProject, transactionId, () -> setBalloonState(result));
}, 200);
}
}
@Override
public void removeNotify() {
super.removeNotify();
Disposer.dispose(disposable);
PropertiesComponent.getInstance(myProject).setValue(LAST_EDITED_REGEXP, mySampleText.getText());
}
};
myRootPanel.setBorder(JBUI.Borders.empty(UIUtil.DEFAULT_VGAP, UIUtil.DEFAULT_HGAP));
}
Aggregations