当前位置: 首页>>代码示例>>Java>>正文


Java Editor类代码示例

本文整理汇总了Java中com.intellij.openapi.editor.Editor的典型用法代码示例。如果您正苦于以下问题:Java Editor类的具体用法?Java Editor怎么用?Java Editor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Editor类属于com.intellij.openapi.editor包,在下文中一共展示了Editor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: drawAllAnswerPlaceholders

import com.intellij.openapi.editor.Editor; //导入依赖的package包/类
public static void drawAllAnswerPlaceholders(Editor editor, TaskFile taskFile) {
  editor.getMarkupModel().removeAllHighlighters();
  final Project project = editor.getProject();
  if (project == null) return;
  final StudyTaskManager taskManager = StudyTaskManager.getInstance(project);
  for (AnswerPlaceholder answerPlaceholder : taskFile.getAnswerPlaceholders()) {
    final JBColor color = taskManager.getColor(answerPlaceholder);
    EduAnswerPlaceholderPainter.drawAnswerPlaceholder(editor, answerPlaceholder, color);
  }

  final Document document = editor.getDocument();
  EditorActionManager.getInstance()
    .setReadonlyFragmentModificationHandler(document, new EduAnswerPlaceholderDeleteHandler(editor));
  EduAnswerPlaceholderPainter.createGuardedBlocks(editor, taskFile);
  editor.getColorsScheme().setColor(EditorColors.READONLY_FRAGMENT_BACKGROUND_COLOR, null);
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:17,代码来源:StudyUtils.java

示例2: drawAnswerPlaceholder

import com.intellij.openapi.editor.Editor; //导入依赖的package包/类
public static void drawAnswerPlaceholder(@NotNull final Editor editor, @NotNull final AnswerPlaceholder placeholder,
                                         @NotNull final JBColor color) {
  EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
  final TextAttributes textAttributes = new TextAttributes(scheme.getDefaultForeground(), scheme.getDefaultBackground(), null,
                                                           EffectType.BOXED, Font.PLAIN);
  textAttributes.setEffectColor(color);
  int startOffset = placeholder.getOffset();
  if (startOffset == -1) {
    return;
  }
  final int length =
    placeholder.isActive() ? placeholder.getRealLength() : placeholder.getVisibleLength(placeholder.getActiveSubtaskIndex());
  Pair<Integer, Integer> offsets = StudyUtils.getPlaceholderOffsets(placeholder, editor.getDocument());
  startOffset = offsets.first;
  int endOffset = offsets.second;
  if (placeholder.isActive()) {
    drawAnswerPlaceholder(editor, startOffset, endOffset, textAttributes, PLACEHOLDERS_LAYER);
  }
  else if (!placeholder.getUseLength() && length != 0) {
    drawAnswerPlaceholderFromPrevStep(editor, startOffset, endOffset);
  }
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:23,代码来源:EduAnswerPlaceholderPainter.java

示例3: build

import com.intellij.openapi.editor.Editor; //导入依赖的package包/类
private void build(int type, PsiFile psiFile, Project project, Editor editor) {
    switch (type){
        case 1:
            new ParamsStringBuilder().build(psiFile, project, editor);
            break;
        case 2:
            new ParamsFileMapBuilder().build(psiFile, project, editor);
            break;
        case 3:
            new ParamsFilePartBuilder().build(psiFile, project, editor);
            break;
        case 4:
            new ParamsFileBodyBuilder().build(psiFile, project, editor);
            break;
    }
}
 
开发者ID:kingwang666,项目名称:OkHttpParamsGet,代码行数:17,代码来源:GetParamsAction.java

示例4: createRenameDialog

import com.intellij.openapi.editor.Editor; //导入依赖的package包/类
@Override
public RenameDialog createRenameDialog( Project project, PsiElement element, PsiElement nameSuggestionContext, Editor editor )
{
  return new PsiFileRenameDialog( project, element, nameSuggestionContext, editor ) {
    protected void createNewNameComponent() {
      super.createNewNameComponent();
      getNameSuggestionsField().selectNameWithoutExtension();
    }

    @Override
    protected NameSuggestionsField getNameSuggestionsField()
    {
      return super.getNameSuggestionsField();
    }
  };
}
 
开发者ID:manifold-systems,项目名称:manifold-ij,代码行数:17,代码来源:RenameTypeManifoldFileProcessor.java

示例5: actionPerformed

import com.intellij.openapi.editor.Editor; //导入依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
    final Project project = e.getRequiredData(CommonDataKeys.PROJECT);
    final Editor editor = e.getRequiredData(CommonDataKeys.EDITOR);
    
    final HighlightManager highlightManager = HighlightManager.getInstance(project);
    final RangeHighlighter[] highlighters =
            ((HighlightManagerImpl) highlightManager).getHighlighters(editor);
    for (RangeHighlighter highlighter : highlighters) {
        final TextAttributes ta = highlighter.getTextAttributes();
        if (ta != null && ta instanceof NamedTextAttr
                && highlighter.getLayer() == HighlighterLayer.SELECTION - 1) {
            highlightManager.removeSegmentHighlighter(editor, highlighter);
        }
    }
}
 
开发者ID:huoguangjin,项目名称:MultiHighlight,代码行数:17,代码来源:MultiHighlightClearAction.java

示例6: getHeaderOfValueGroupUnderCaret

import com.intellij.openapi.editor.Editor; //导入依赖的package包/类
public static PsiElement getHeaderOfValueGroupUnderCaret(@NotNull final Editor editor) {
    Validate.notNull(editor);

    final PsiElement psiElementUnderCaret = PsiUtilBase.getElementAtCaret(editor);
    if (null == psiElementUnderCaret) {
        return null;
    }

    final ImpexValueGroup valueGroup = ImpexPsiUtils.getClosestSelectedValueGroupFromTheSameLine(
        psiElementUnderCaret);
    if (null != valueGroup) {

        final PsiElement header = ImpexPsiUtils.getHeaderForValueGroup(valueGroup);
        if (null != header) {

            return header;
        }
    }

    return null;
}
 
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:22,代码来源:ImpexPsiUtils.java

示例7: actionPerformed

import com.intellij.openapi.editor.Editor; //导入依赖的package包/类
public void actionPerformed( AnActionEvent e ) {
    Editor editor = ( Editor ) e.getDataContext().getData( "editor" );
    SelectionModel selectionModel = editor.getSelectionModel();
    if ( selectionModel != null ) {
        String selectedText = selectionModel.getSelectedText();
        if ( selectedText != null && selectedText.trim().length() > 0 ) {
            Project project = ( Project ) e.getDataContext().getData( DataConstants.PROJECT );
            String panelid = ( String ) project.getUserData( QuickNotes.KEY_PANELID );
            QuickNotesPanel quickNotesPanel = QuickNotesManager.getInstance().getQuickNotesPanel( panelid );
            if ( quickNotesPanel != null ) {
                FileDocumentManager manager = FileDocumentManager.getInstance();
                VirtualFile virtualFile = manager.getFile( editor.getDocument() );
                quickNotesPanel.addNewNote( "[File: " + virtualFile.getPath() + "]\n" + selectedText );
            }
        }
    }
}
 
开发者ID:jrana,项目名称:quicknotes,代码行数:18,代码来源:AddToQuickNotes.java

示例8: insertToEditor

import com.intellij.openapi.editor.Editor; //导入依赖的package包/类
public void insertToEditor(Project project, SearchResultElement element) {
    CommandProcessor.getInstance().executeCommand(project, () -> getApplication().runWriteAction(() -> {
        Editor editor = FileEditorManager.getInstance(project).getSelectedTextEditor();
        if (editor != null) {
            int offset = editor.getCaretModel().getOffset();
            Document document = editor.getDocument();
            String key = isXmlFile ?
                    "@" + element.getTag() + "/" + element.getName()
                    : "R." + element.getTag() + "." + element.getName();
            if (key != null) {
                document.insertString(offset, key);
                editor.getCaretModel().moveToOffset(offset + key.length());
            }
        }
    }), "InsertResultToEditor", "", UndoConfirmationPolicy.DO_NOT_REQUEST_CONFIRMATION);
}
 
开发者ID:hoai265,项目名称:SearchResourcePlugin,代码行数:17,代码来源:SearchResourcesAction.java

示例9: GCMStructureViewModel

import com.intellij.openapi.editor.Editor; //导入依赖的package包/类
public GCMStructureViewModel(@NotNull PsiFile psiFile, @NotNull final GCMStructureViewRootElement root, Editor editor) {
    super(psiFile, root);
    withSorters(typeSorter, Sorter.ALPHA_SORTER);
    editor.getDocument().addDocumentListener(new DocumentAdapter() {
        @Override
        public void documentChanged(DocumentEvent event) {
            synchronized (needRefresh) {
                needRefresh = true;
            }
        }
    });
    executor.scheduleAtFixedRate(new Runnable() {
        @Override
        public void run() {
            GCMStructureViewModel.this.refreshView();
        }
    }, 15, 5, TimeUnit.SECONDS);

}
 
开发者ID:datathings,项目名称:greycat-idea-plugin,代码行数:20,代码来源:GCMStructureViewModel.java

示例10: processSubDec

import com.intellij.openapi.editor.Editor; //导入依赖的package包/类
private void processSubDec(GCMClassDeclaration o, GCMStructureViewClassElement classElement, Editor editor) {
    /*
    for (GCMClassElemDeclaration relDec : o.getClassElemDeclarationList()) {
        if (relDec.getRelationDeclaration() != null) {
            GCMStructureViewReferenceElement referenceElement = new GCMStructureViewReferenceElement(relDec.getRelationDeclaration(), editor);
            classElement.references.add(referenceElement);
        } else if (relDec.getAttributeDeclaration() != null) {
            GCMStructureViewAttributeElement attributeElement = new GCMStructureViewAttributeElement(relDec.getAttributeDeclaration(), editor);
            classElement.attributes.add(attributeElement);
        } else {
            System.err.println("Could not find appropriate ClassElem declaration type in processReference for Structure view");
        }
    }
    */


}
 
开发者ID:datathings,项目名称:greycat-idea-plugin,代码行数:18,代码来源:GCMStructureViewRootElement.java

示例11: isAvailable

import com.intellij.openapi.editor.Editor; //导入依赖的package包/类
@Override
public boolean isAvailable(@NotNull Project project, Editor editor, @NotNull PsiElement element) {
    if (!element.isWritable()) return false;
    boolean isTwigFile = GravFileTemplateUtil.isTwigTemplateFile(element.getContainingFile()) || element.getContainingFile() instanceof HtmlFileImpl;
    boolean isXmlAttribute = false;
    if (!isTwigFile) return false;
    if (element.getParent() instanceof XmlAttributeValueImpl) {
        XmlAttributeValueImpl parent0 = ((XmlAttributeValueImpl) element.getParent());
        boolean hasTwigElement = PsiTreeUtil.findChildOfType(parent0, OuterLanguageElement.class) != null;
        if (!hasTwigElement && parent0.getParent() instanceof XmlAttributeImpl) {
            XmlAttributeImpl parent1 = (XmlAttributeImpl) parent0.getParent();
            if (parent1.getName().equalsIgnoreCase("href") || parent1.getName().equalsIgnoreCase("src"))
                isXmlAttribute = true;
        }
    }
    return isXmlAttribute;
}
 
开发者ID:PioBeat,项目名称:GravSupport,代码行数:18,代码来源:ConvertTwigResource.java

示例12: generateGherkinRunIcons

import com.intellij.openapi.editor.Editor; //导入依赖的package包/类
public void generateGherkinRunIcons(Document rootDocument, Editor rootEditor) {
    for (int i = 0; i < rootDocument.getLineCount(); i++) {
        int startOffset = rootDocument.getLineStartOffset(i);
        int endOffset = rootDocument.getLineEndOffset(i);

        String lineText = rootDocument.getText(new TextRange(startOffset, endOffset)).trim();

        Icon icon;
        if (lineText.matches(SCENARIO_REGEX)) {
            icon = GherkinIconRenderer.SCENARIO_ICON;
        } else if (lineText.matches(FEATURE_REGEX)) {
            icon = GherkinIconRenderer.FEATURE_ICON;
        } else {
            // System.out.println();
             continue;
        }
        GherkinIconRenderer gherkinIconRenderer = new GherkinIconRenderer(rootEditor.getProject(), fileName);
        gherkinIconRenderer.setLine(i);
        gherkinIconRenderer.setIcon(icon);

        RangeHighlighter rangeHighlighter = createRangeHighlighter(rootDocument, rootEditor, i, i, new TextAttributes());
        rangeHighlighter.setGutterIconRenderer(gherkinIconRenderer);
    }
}
 
开发者ID:KariiO,项目名称:Gherkin-TS-Runner,代码行数:25,代码来源:GherkinIconUtils.java

示例13: actionPerformed

import com.intellij.openapi.editor.Editor; //导入依赖的package包/类
/**
 * Inserts the string generated by {@link #generateString()} at the caret(s) in the editor.
 *
 * @param event the performed action
 */
@Override
public final void actionPerformed(final AnActionEvent event) {
    final Editor editor = event.getData(CommonDataKeys.EDITOR);
    if (editor == null) {
        return;
    }
    final Project project = event.getData(CommonDataKeys.PROJECT);
    final Document document = editor.getDocument();
    final CaretModel caretModel = editor.getCaretModel();

    final Runnable replaceCaretSelections = () -> caretModel.getAllCarets().forEach(caret -> {
        final int start = caret.getSelectionStart();
        final int end = caret.getSelectionEnd();

        final String string = generateString();
        final int newEnd = start + string.length();

        document.replaceString(start, end, string);
        caret.setSelection(start, newEnd);
    });

    WriteCommandAction.runWriteCommandAction(project, replaceCaretSelections);
}
 
开发者ID:FWDekker,项目名称:intellij-randomness,代码行数:29,代码来源:DataInsertAction.java

示例14: preprocessEnter

import com.intellij.openapi.editor.Editor; //导入依赖的package包/类
@Override
public Result preprocessEnter(
    @NotNull PsiFile psiFile,
    @NotNull Editor editor,
    @NotNull Ref<Integer> caretOffset,
    @NotNull Ref<Integer> caretOffsetChange,
    @NotNull DataContext dataContext,
    @Nullable EditorActionHandler originalHandler) {
  if (psiFile instanceof SoyFile && isBetweenSiblingTags(psiFile, caretOffset.get())) {
    if (originalHandler != null) {
      originalHandler.execute(editor, dataContext);
    }
    return Result.Default;
  }
  return Result.Continue;
}
 
开发者ID:google,项目名称:bamboo-soy,代码行数:17,代码来源:EnterHandler.java

示例15: isClearHighlights

import com.intellij.openapi.editor.Editor; //导入依赖的package包/类
private static boolean isClearHighlights(@NotNull Editor editor) {
    if (editor instanceof EditorWindow) {
        editor = ((EditorWindow) editor).getDelegate();
    }
    
    final Project project = editor.getProject();
    if (project == null) {
        Log.error("isClearHighlights: editor.getProject() == null");
        return false;
    }
    
    int caretOffset = editor.getCaretModel().getOffset();
    final RangeHighlighter[] highlighters =
            ((HighlightManagerImpl) HighlightManager.getInstance(project)).getHighlighters(
                    editor);
    for (RangeHighlighter highlighter : highlighters) {
        if (TextRange.create(highlighter).grown(1).contains(caretOffset)) {
            return true;
        }
    }
    
    return false;
}
 
开发者ID:huoguangjin,项目名称:MultiHighlight,代码行数:24,代码来源:MultiHighlightHandler.java


注:本文中的com.intellij.openapi.editor.Editor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。