Search in sources :

Example 41 with EditorEx

use of com.intellij.openapi.editor.ex.EditorEx 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 42 with EditorEx

use of com.intellij.openapi.editor.ex.EditorEx in project intellij-community by JetBrains.

the class CodeStyleAbstractPanel method createEditor.

@Nullable
private Editor createEditor() {
    if (getPreviewText() == null)
        return null;
    EditorFactory editorFactory = EditorFactory.getInstance();
    Document editorDocument = editorFactory.createDocument("");
    EditorEx editor = (EditorEx) editorFactory.createEditor(editorDocument);
    fillEditorSettings(editor.getSettings());
    myLastDocumentModificationStamp = editor.getDocument().getModificationStamp();
    return editor;
}
Also used : EditorEx(com.intellij.openapi.editor.ex.EditorEx) Nullable(org.jetbrains.annotations.Nullable)

Example 43 with EditorEx

use of com.intellij.openapi.editor.ex.EditorEx in project intellij-community by JetBrains.

the class ImplementationViewComponent method update.

public void update(@NotNull final PsiElement[] elements, final int index) {
    update(elements, (psiElements, fileDescriptors) -> {
        if (myEditor.isDisposed())
            return false;
        if (psiElements.length == 0)
            return false;
        final Project project = psiElements[0].getProject();
        myElements = psiElements;
        myIndex = index < myElements.length ? index : 0;
        PsiFile psiFile = getContainingFile(myElements[myIndex]);
        VirtualFile virtualFile = psiFile.getVirtualFile();
        EditorHighlighter highlighter;
        if (virtualFile != null)
            highlighter = HighlighterFactory.createHighlighter(project, virtualFile);
        else {
            // some artificial psi file, lets do best we can
            String fileName = psiFile.getName();
            highlighter = HighlighterFactory.createHighlighter(project, fileName);
        }
        ((EditorEx) myEditor).setHighlighter(highlighter);
        if (myElements.length > 1) {
            myFileChooser.setVisible(true);
            myCountLabel.setVisible(true);
            myLabel.setVisible(false);
            myFileChooser.setModel(new DefaultComboBoxModel(fileDescriptors.toArray(new FileDescriptor[fileDescriptors.size()])));
            updateRenderer(project);
        } else {
            myFileChooser.setVisible(false);
            myCountLabel.setVisible(false);
            VirtualFile file = psiFile.getVirtualFile();
            if (file != null) {
                myLabel.setIcon(getIconForFile(psiFile));
                myLabel.setForeground(FileStatusManager.getInstance(project).getStatus(file).getColor());
                myLabel.setText(file.getPresentableName());
                myLabel.setBorder(new CompoundBorder(IdeBorderFactory.createRoundedBorder(), IdeBorderFactory.createEmptyBorder(0, 0, 0, 5)));
                myLabel.setVisible(true);
            }
        }
        updateControls();
        revalidate();
        repaint();
        return true;
    });
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) EditorEx(com.intellij.openapi.editor.ex.EditorEx) CompoundBorder(javax.swing.border.CompoundBorder) EditorHighlighter(com.intellij.openapi.editor.highlighter.EditorHighlighter)

Example 44 with EditorEx

use of com.intellij.openapi.editor.ex.EditorEx in project intellij-community by JetBrains.

the class InspectionResultsView method showInRightPanel.

private void showInRightPanel(@Nullable final RefEntity refEntity) {
    Cursor currentCursor = getCursor();
    try {
        setCursor(new Cursor(Cursor.WAIT_CURSOR));
        final JPanel editorPanel = new JPanel();
        editorPanel.setLayout(new BorderLayout());
        final int problemCount = myTree.getSelectedProblemCount(true);
        JComponent previewPanel = null;
        final InspectionToolWrapper tool = myTree.getSelectedToolWrapper(true);
        if (tool != null && refEntity != null && refEntity.isValid()) {
            final TreePath path = myTree.getSelectionPath();
            if (path == null || !(path.getLastPathComponent() instanceof ProblemDescriptionNode)) {
                final InspectionToolPresentation presentation = myGlobalInspectionContext.getPresentation(tool);
                previewPanel = presentation.getCustomPreviewPanel(refEntity);
            }
        }
        EditorEx previewEditor = null;
        if (previewPanel == null) {
            final Pair<JComponent, EditorEx> panelAndEditor = createBaseRightComponentFor(problemCount, refEntity);
            previewPanel = panelAndEditor.getFirst();
            previewEditor = panelAndEditor.getSecond();
        }
        editorPanel.add(previewPanel, BorderLayout.CENTER);
        if (problemCount > 0) {
            final JComponent fixToolbar = QuickFixPreviewPanelFactory.create(this);
            if (fixToolbar != null) {
                if (fixToolbar instanceof InspectionTreeLoadingProgressAware) {
                    myLoadingProgressPreview = (InspectionTreeLoadingProgressAware) fixToolbar;
                }
                if (previewEditor != null) {
                    previewPanel.setBorder(IdeBorderFactory.createBorder(SideBorder.TOP));
                }
                editorPanel.add(fixToolbar, BorderLayout.NORTH);
            }
        }
        if (previewEditor != null) {
            new ProblemPreviewEditorPresentation(previewEditor, this);
        }
        mySplitter.setSecondComponent(editorPanel);
    } finally {
        setCursor(currentCursor);
    }
}
Also used : EditorEx(com.intellij.openapi.editor.ex.EditorEx) TreePath(javax.swing.tree.TreePath)

Example 45 with EditorEx

use of com.intellij.openapi.editor.ex.EditorEx in project intellij-community by JetBrains.

the class MethodSignatureComponent method setSignature.

public void setSignature(String signature) {
    setText(signature);
    final EditorEx editor = (EditorEx) getEditor();
    if (editor != null) {
        editor.getScrollingModel().scrollVertically(0);
        editor.getScrollingModel().scrollHorizontally(0);
    }
}
Also used : EditorEx(com.intellij.openapi.editor.ex.EditorEx)

Aggregations

EditorEx (com.intellij.openapi.editor.ex.EditorEx)164 EditorHighlighter (com.intellij.openapi.editor.highlighter.EditorHighlighter)36 Editor (com.intellij.openapi.editor.Editor)35 HighlighterIterator (com.intellij.openapi.editor.highlighter.HighlighterIterator)33 Document (com.intellij.openapi.editor.Document)29 NotNull (org.jetbrains.annotations.NotNull)26 IElementType (com.intellij.psi.tree.IElementType)14 Nullable (org.jetbrains.annotations.Nullable)13 Project (com.intellij.openapi.project.Project)12 PsiFile (com.intellij.psi.PsiFile)12 EditorFactory (com.intellij.openapi.editor.EditorFactory)11 VirtualFile (com.intellij.openapi.vfs.VirtualFile)11 TextRange (com.intellij.openapi.util.TextRange)10 FileType (com.intellij.openapi.fileTypes.FileType)8 LogicalPosition (com.intellij.openapi.editor.LogicalPosition)7 EditorColorsScheme (com.intellij.openapi.editor.colors.EditorColorsScheme)7 BraceMatcher (com.intellij.codeInsight.highlighting.BraceMatcher)6 Language (com.intellij.lang.Language)6 CaretModel (com.intellij.openapi.editor.CaretModel)6 EditorGutterComponentEx (com.intellij.openapi.editor.ex.EditorGutterComponentEx)6