Search in sources :

Example 21 with EditorTextField

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);
}
Also used : NonNls(org.jetbrains.annotations.NonNls) FileType(com.intellij.openapi.fileTypes.FileType) EditorTextField(com.intellij.ui.EditorTextField) Document(com.intellij.openapi.editor.Document)

Example 22 with EditorTextField

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);
    }
}
Also used : EditorTextField(com.intellij.ui.EditorTextField)

Example 23 with EditorTextField

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);
}
Also used : EditorEx(com.intellij.openapi.editor.ex.EditorEx) EditorTextField(com.intellij.ui.EditorTextField) PsiFile(com.intellij.psi.PsiFile) LanguageTextField(com.intellij.ui.LanguageTextField)

Example 24 with EditorTextField

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;
}
Also used : GuiTask(org.fest.swing.edt.GuiTask) EditorTextField(com.intellij.ui.EditorTextField) NotNull(org.jetbrains.annotations.NotNull)

Example 25 with EditorTextField

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));
}
Also used : Disposable(com.intellij.openapi.Disposable) EditorEx(com.intellij.openapi.editor.ex.EditorEx) DocumentAdapter(com.intellij.openapi.editor.event.DocumentAdapter) Document(com.intellij.openapi.editor.Document) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) DocumentEvent(com.intellij.openapi.editor.event.DocumentEvent) AnAction(com.intellij.openapi.actionSystem.AnAction) TransactionId(com.intellij.openapi.application.TransactionId) LanguageFileType(com.intellij.openapi.fileTypes.LanguageFileType) Language(com.intellij.lang.Language) EditorTextField(com.intellij.ui.EditorTextField) Alarm(com.intellij.util.Alarm)

Aggregations

EditorTextField (com.intellij.ui.EditorTextField)47 Document (com.intellij.openapi.editor.Document)11 NotNull (org.jetbrains.annotations.NotNull)11 DocumentEvent (com.intellij.openapi.editor.event.DocumentEvent)9 DocumentAdapter (com.intellij.openapi.editor.event.DocumentAdapter)7 EditorEx (com.intellij.openapi.editor.ex.EditorEx)5 EditorComboBoxEditor (com.intellij.ui.EditorComboBoxEditor)5 EditorComboBoxRenderer (com.intellij.ui.EditorComboBoxRenderer)5 StringComboboxEditor (com.intellij.ui.StringComboboxEditor)5 JBLabel (com.intellij.ui.components.JBLabel)4 Editor (com.intellij.openapi.editor.Editor)3 DocumentListener (com.intellij.openapi.editor.event.DocumentListener)3 ExternalSystemUiAware (com.intellij.openapi.externalSystem.ExternalSystemUiAware)3 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)3 Project (com.intellij.openapi.project.Project)3 ComboBox (com.intellij.openapi.ui.ComboBox)3 FixedSizeButton (com.intellij.openapi.ui.FixedSizeButton)3 CompletionResultSet (com.intellij.codeInsight.completion.CompletionResultSet)2 InlayParameterHintsProvider (com.intellij.codeInsight.hints.InlayParameterHintsProvider)2 Language (com.intellij.lang.Language)2