Examples of Editor


Examples of com.intellij.openapi.editor.Editor

    return new AnAction()
    {
      @Override
      public void actionPerformed(AnActionEvent e)
      {
        Editor editor = e.getData(PlatformDataKeys.EDITOR);
        if (editor != null)
        {
          editor.getCaretModel().moveToOffset(editor.getDocument().getLineStartOffset(lineStart));
        }

        // Could also be managed through a listener...
        Project project = e.getData(PlatformDataKeys.PROJECT);
        if (project != null)
View Full Code Here

Examples of com.intellij.openapi.editor.Editor

  private class CustomEditorFactoryListener implements EditorFactoryListener
  {
    public void editorCreated(EditorFactoryEvent event)
    {
      final Editor editor = event.getEditor();

      VirtualFile vFile = FileDocumentManager.getInstance().getFile(editor.getDocument());
      if (vFile == null)
      {
        return;
      }

      DocumentChangeTracker documentChangeTracker = changeTrackers.get(vFile);
      if (documentChangeTracker == null)
      {
        documentChangeTracker = new DocumentChangeTracker(editor.getDocument());
        changeTrackers.put(vFile, documentChangeTracker);
      }
      documentChangeTracker.getEditors().add(editor);

      for (Review review : RevuUtils.getActiveReviewsForCurrentUser(project))
View Full Code Here

Examples of com.intellij.openapi.editor.Editor

      }
    }

    public void editorReleased(EditorFactoryEvent event)
    {
      Editor editor = event.getEditor();

      VirtualFile vFile = FileDocumentManager.getInstance().getFile(editor.getDocument());
      if (vFile == null)
      {
        return;
      }
View Full Code Here

Examples of com.intellij.openapi.editor.Editor

  public static VirtualFile getVirtualFile(AnActionEvent e)
  {
    VirtualFile result = e.getData(PlatformDataKeys.VIRTUAL_FILE);
    if (result == null)
    {
      Editor editor = e.getData(PlatformDataKeys.EDITOR);
      if (editor != null)
      {
        result = FileDocumentManager.getInstance().getFile(editor.getDocument());
      }
    }

    return result;
  }
View Full Code Here

Examples of com.intellij.openapi.editor.Editor

        FileEditorManager.getInstance(project);
    final HighlightManager highlightManager =
        HighlightManager.getInstance(project);
    final EditorColorsManager editorColorsManager =
        EditorColorsManager.getInstance();
    final Editor editor = editorManager.getSelectedTextEditor();
    final EditorColorsScheme globalScheme =
        editorColorsManager.getGlobalScheme();
    final TextAttributes textattributes =
        globalScheme.getAttributes(
            EditorColors.SEARCH_RESULT_ATTRIBUTES);

    assert editor != null;
    assert project != null;
    final PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
    assert psiFile != null;

    //region Interesting part where I track down usages
    PsiElement element = psiFile.findElementAt(editor.getCaretModel().getOffset());
    element = (element != null) ? element.getParent() : null;
    final List<PsiElement> usages = new ArrayList<PsiElement>();
    if (element instanceof Symbol) {
//      usages.add(element);
View Full Code Here

Examples of com.intellij.openapi.editor.Editor

  private static String printIndent(Indent indent) {
    return indent.toString();
  }

  public void actionPerformed(AnActionEvent event) {
    Editor editor = event.getData(PlatformDataKeys.EDITOR);
    Project project = event.getData(PlatformDataKeys.PROJECT);

    DialogBuilder dialogBuilder = new DialogBuilder(project);
    dialogBuilder.setTitle("Formatting Block structure");

    final String text = editor != null ? editor.getDocument().getText() : "";
    final CodeStyleSettings settings = CodeStyleSettingsManager.getInstance(project).getCurrentSettings();
    MathematicaFormattingModelBuilder modelBuilder = new MathematicaFormattingModelBuilder();
    final PsiFile file = PsiFileFactory.getInstance(project).createFileFromText("a.m", MathematicaLanguage.INSTANCE, text);
    final FormattingModel model = modelBuilder.createModel(file.getNode().getPsi(), settings);
    final Block rootBlock = model.getRootBlock();
View Full Code Here

Examples of com.intellij.openapi.editor.Editor

    return (element != null) && text.equals(element.getText());
  }

  @Override
  public void handleInsert(InsertionContext context, LookupElement item) {
    Editor editor = context.getEditor();
    Document document = editor.getDocument();
    context.commitDocument();

    char completionChar = context.getCompletionChar();
    context.setAddCompletionChar(false);

//        if (completionChar == Lookup.NORMAL_SELECT_CHAR) {
////            editor.getCaretModel().moveToOffset(context.getTailOffset());
//        }

    if (completionChar == Lookup.COMPLETE_STATEMENT_SELECT_CHAR) {
      SymbolInformationProvider.SymbolInformation symbol = SymbolInformationProvider.getSymbolNames().get(item.getLookupString());
      boolean insertBrackets = (symbol != null) && symbol.function;
      if (insertBrackets) {
        document.insertString(context.getTailOffset(), Character.toString(OPEN_BRACKET));
        editor.getCaretModel().moveToOffset(context.getTailOffset());
        document.insertString(context.getTailOffset(), Character.toString(CLOSING_BRACKET));
      } else {
        document.insertString(context.getTailOffset(), " ");
        editor.getCaretModel().moveToOffset(context.getTailOffset());
      }

    }

    if (completionChar == ' ') {
View Full Code Here

Examples of com.intellij.openapi.editor.Editor

        JBPopupFactory.getInstance().guessBestPopupLocation(e.getDataContext());
    PsiDocumentManager.getInstance(project).commitAllDocuments();
    FeatureUsageTracker.getInstance().triggerFeatureUsed("navigation.goto.usages");

    UsageTarget[] usageTargets = e.getData(UsageView.USAGE_TARGETS_KEY);
    final Editor editor = e.getData(PlatformDataKeys.EDITOR);
    if (usageTargets == null) {
      chooseAmbiguousTargetAndPerform(project, editor, new PsiElementProcessor<PsiElement>() {
        @Override
        public boolean execute(@NotNull final PsiElement element) {
          startFindUsages(element, popupPosition, editor, USAGES_PAGE_SIZE);
View Full Code Here

Examples of com.intellij.openapi.editor.Editor

    return element.getTextRange().getStartOffset();
  }

  private static boolean areAllUsagesInOneLine(@NotNull Usage visibleUsage,
      @NotNull List<Usage> usages) {
    Editor editor = getEditorFor(visibleUsage);
    if (editor == null) return false;
    int offset = getUsageOffset(visibleUsage);
    if (offset == -1) return false;
    int lineNumber = editor.getDocument().getLineNumber(offset);
    for (Usage other : usages) {
      Editor otherEditor = getEditorFor(other);
      if (otherEditor != editor) return false;
      int otherOffset = getUsageOffset(other);
      if (otherOffset == -1) return false;
      int otherLine = otherEditor.getDocument().getLineNumber(otherOffset);
      if (otherLine != lineNumber) return false;
    }
    return true;
  }
View Full Code Here

Examples of com.intellij.openapi.editor.Editor

  private void navigateAndHint(@NotNull Usage usage, @Nullable final String hint,
      @NotNull final FindUsagesHandler handler, @NotNull final RelativePoint popupPosition,
      final int maxUsages, @NotNull final FindUsagesOptions options) {
    usage.navigate(true);
    if (hint == null) return;
    final Editor newEditor = getEditorFor(usage);
    if (newEditor == null) return;
    final Project project = handler.getProject();
    //opening editor is performing in invokeLater
    IdeFocusManager.getInstance(project).doWhenFocusSettlesDown(new Runnable() {
      @Override
      public void run() {
        newEditor.getScrollingModel().runActionOnScrollingFinished(new Runnable() {
          @Override
          public void run() {
            // after new editor created, some editor resizing events are still bubbling. To prevent hiding hint, invokeLater this
            IdeFocusManager.getInstance(project).doWhenFocusSettlesDown(new Runnable() {
              @Override
              public void run() {
                if (newEditor.getComponent().isShowing()) {
                  showHint(hint, newEditor, popupPosition, handler, maxUsages, options);
                }
              }
            });
          }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.