Java 类com.intellij.openapi.editor.impl.EditorFactoryImpl 实例源码

项目:intellij-ce-playground    文件:ExportToFileUtil.java   
protected JComponent createCenterPanel() {
  final Document document = ((EditorFactoryImpl)EditorFactory.getInstance()).createDocument(true);
  ((DocumentImpl)document).setAcceptSlashR(true);

  myTextArea = EditorFactory.getInstance().createEditor(document, myProject, FileTypes.PLAIN_TEXT, true);
  final EditorSettings settings = myTextArea.getSettings();
  settings.setLineNumbersShown(false);
  settings.setLineMarkerAreaShown(false);
  settings.setFoldingOutlineShown(false);
  settings.setRightMarginShown(false);
  settings.setAdditionalLinesCount(0);
  settings.setAdditionalColumnsCount(0);
  settings.setAdditionalPageAtBottom(false);
  ((EditorEx)myTextArea).setBackgroundColor(UIUtil.getInactiveTextFieldBackgroundColor());
  myTextArea.getComponent().setPreferredSize(new Dimension(700, 400));
  return myTextArea.getComponent();
}
项目:intellij-ce-playground    文件:LanguageConsoleImpl.java   
public LanguageConsoleImpl(@NotNull Helper helper) {
  super(helper.project, GlobalSearchScope.allScope(helper.project), true, true);
  myHelper = helper;
  EditorFactory editorFactory = EditorFactory.getInstance();
  myEditorDocument = helper.getDocument();
  myConsoleEditor = (EditorEx)editorFactory.createEditor(myEditorDocument, getProject());
  myConsoleEditor.addFocusListener(myFocusListener);
  myCurrentEditor = myConsoleEditor;
  myHistoryViewer = (EditorEx)editorFactory.createViewer(((EditorFactoryImpl)editorFactory).createDocument(true), getProject());

  myBusConnection = getProject().getMessageBus().connect();
  // action shortcuts are not yet registered
  ApplicationManager.getApplication().invokeLater(new Runnable() {
    @Override
    public void run() {
      installEditorFactoryListener();
    }
  }, getProject().getDisposed());
}
项目:tools-idea    文件:ExportToFileUtil.java   
protected JComponent createCenterPanel() {
  final Document document = ((EditorFactoryImpl)EditorFactory.getInstance()).createDocument(true);
  ((DocumentImpl)document).setAcceptSlashR(true);

  myTextArea = EditorFactory.getInstance().createEditor(document, myProject, StdFileTypes.PLAIN_TEXT, true);
  final EditorSettings settings = myTextArea.getSettings();
  settings.setLineNumbersShown(false);
  settings.setLineMarkerAreaShown(false);
  settings.setFoldingOutlineShown(false);
  settings.setRightMarginShown(false);
  settings.setAdditionalLinesCount(0);
  settings.setAdditionalColumnsCount(0);
  settings.setAdditionalPageAtBottom(false);
  ((EditorEx)myTextArea).setBackgroundColor(UIUtil.getInactiveTextFieldBackgroundColor());
  return myTextArea.getComponent();
}
项目:consulo    文件:ExportToFileUtil.java   
@Override
protected JComponent createCenterPanel() {
  final Document document = ((EditorFactoryImpl)EditorFactory.getInstance()).createDocument(true);
  ((DocumentImpl)document).setAcceptSlashR(true);

  myTextArea = EditorFactory.getInstance().createEditor(document, myProject, PlainTextFileType.INSTANCE, true);
  final EditorSettings settings = myTextArea.getSettings();
  settings.setLineNumbersShown(false);
  settings.setLineMarkerAreaShown(false);
  settings.setFoldingOutlineShown(false);
  settings.setRightMarginShown(false);
  settings.setAdditionalLinesCount(0);
  settings.setAdditionalColumnsCount(0);
  settings.setAdditionalPageAtBottom(false);
  ((EditorEx)myTextArea).setBackgroundColor(UIUtil.getInactiveTextFieldBackgroundColor());
  return myTextArea.getComponent();
}
项目:consulo    文件:LanguageConsoleImpl.java   
public LanguageConsoleImpl(@Nonnull Helper helper) {
  super(helper.project, GlobalSearchScope.allScope(helper.project), true, true);
  myHelper = helper;
  EditorFactory editorFactory = EditorFactory.getInstance();
  myEditorDocument = helper.getDocument();
  myConsoleEditor = (EditorEx)editorFactory.createEditor(myEditorDocument, getProject());
  myConsoleEditor.getDocument().addDocumentListener(myDocumentAdapter);
  myConsoleEditor.getScrollPane().getHorizontalScrollBar().setEnabled(false);
  myConsoleEditor.addFocusListener(myFocusListener);
  myCurrentEditor = myConsoleEditor;
  Document historyDocument = ((EditorFactoryImpl)editorFactory).createDocument(true);
  UndoUtil.disableUndoFor(historyDocument);
  myHistoryViewer = (EditorEx)editorFactory.createViewer(historyDocument, getProject());
  myHistoryViewer.getDocument().addDocumentListener(myDocumentAdapter);

  myScrollBar.setOpaque(false);
  myScrollBar.setModel(new MyModel(myScrollBar, myHistoryViewer, myConsoleEditor));
  //myScrollBar.putClientProperty(Alignment.class, Alignment.BOTTOM);

  myBusConnection = getProject().getMessageBus().connect();
  // action shortcuts are not yet registered
  ApplicationManager.getApplication().invokeLater(() -> installEditorFactoryListener(), getProject().getDisposed());
}
项目:intellij-ce-playground    文件:ConsoleViewUtil.java   
public static EditorEx setupConsoleEditor(Project project, final boolean foldingOutlineShown, final boolean lineMarkerAreaShown) {
  EditorFactory editorFactory = EditorFactory.getInstance();
  Document document = ((EditorFactoryImpl)editorFactory).createDocument(true);
  UndoUtil.disableUndoFor(document);
  EditorEx editor = (EditorEx) editorFactory.createViewer(document, project);
  setupConsoleEditor(editor, foldingOutlineShown, lineMarkerAreaShown);
  return editor;
}
项目:intellij-ce-playground    文件:VcsAwareFormatChangedTextUtil.java   
@NotNull
private static List<Range> getRanges(@NotNull Document document,
                                     @NotNull CharSequence contentFromVcs) throws FilesTooBigForDiffException
{
  Document documentFromVcs = ((EditorFactoryImpl)EditorFactory.getInstance()).createDocument(contentFromVcs, true, false);
  return new RangesBuilder(document, documentFromVcs).getRanges();
}
项目:intellij-ce-playground    文件:ByteCodeViewerComponent.java   
public ByteCodeViewerComponent(Project project, AnAction[] additionalActions) {
  super(new BorderLayout());
  final EditorFactory factory = EditorFactory.getInstance();
  final Document doc = ((EditorFactoryImpl)factory).createDocument("", true, false);
  doc.setReadOnly(true);
  myEditor = factory.createEditor(doc, project);
  EditorHighlighterFactory editorHighlighterFactory = EditorHighlighterFactory.getInstance();
  final SyntaxHighlighter syntaxHighlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(StdFileTypes.JAVA, project, null);
  ((EditorEx)myEditor).setHighlighter(editorHighlighterFactory.createEditorHighlighter(syntaxHighlighter, EditorColorsManager.getInstance().getGlobalScheme()));
  ((EditorEx)myEditor).setCaretVisible(true);

  final EditorSettings settings = myEditor.getSettings();
  settings.setLineMarkerAreaShown(false);
  settings.setIndentGuidesShown(false);
  settings.setLineNumbersShown(false);
  settings.setFoldingOutlineShown(false);

  myEditor.setBorder(null);
  add(myEditor.getComponent(), BorderLayout.CENTER);
  final ActionManager actionManager = ActionManager.getInstance();
  final DefaultActionGroup actions = new DefaultActionGroup();
  if (additionalActions != null) {
    for (final AnAction action : additionalActions) {
      actions.add(action);
    }
  }
  add(actionManager.createActionToolbar(ActionPlaces.JAVADOC_TOOLBAR, actions, true).getComponent(), BorderLayout.NORTH);
}
项目:intellij    文件:ProjectViewUi.java   
private static EditorEx createEditor(String tooltip) {
  Project project = getProject();
  LightVirtualFile virtualFile =
      new LightVirtualFile("mockProjectViewFile", ProjectViewLanguage.INSTANCE, "");
  final Document document =
      ((EditorFactoryImpl) EditorFactory.getInstance()).createDocument(true);
  ((DocumentImpl) document).setAcceptSlashR(true);
  FileDocumentManagerImpl.registerDocument(document, virtualFile);

  FileManager fileManager = ((PsiManagerEx) PsiManager.getInstance(project)).getFileManager();
  fileManager.setViewProvider(virtualFile, fileManager.createFileViewProvider(virtualFile, true));

  if (project.isDefault()) {
    // Undo-redo doesn't work with the default project.
    // Explicitly turn it off to avoid error dialogs.
    UndoUtil.disableUndoFor(document);
  }

  EditorEx editor =
      (EditorEx)
          EditorFactory.getInstance()
              .createEditor(document, project, ProjectViewFileType.INSTANCE, false);
  final EditorSettings settings = editor.getSettings();
  settings.setLineNumbersShown(false);
  settings.setLineMarkerAreaShown(false);
  settings.setFoldingOutlineShown(false);
  settings.setRightMarginShown(false);
  settings.setAdditionalPageAtBottom(false);
  editor.getComponent().setMinimumSize(getEditorSize());
  editor.getComponent().setPreferredSize(getEditorSize());
  editor.getComponent().setToolTipText(tooltip);
  editor.getComponent().setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, null);
  editor.getComponent().setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, null);
  return editor;
}
项目:consulo    文件:ConsoleViewUtil.java   
@Nonnull
public static EditorEx setupConsoleEditor(Project project, final boolean foldingOutlineShown, final boolean lineMarkerAreaShown) {
  EditorFactory editorFactory = EditorFactory.getInstance();
  Document document = ((EditorFactoryImpl)editorFactory).createDocument(true);
  UndoUtil.disableUndoFor(document);
  EditorEx editor = (EditorEx)editorFactory.createViewer(document, project);
  setupConsoleEditor(editor, foldingOutlineShown, lineMarkerAreaShown);
  return editor;
}
项目:consulo    文件:VcsAwareFormatChangedTextUtil.java   
@Nonnull
private static List<Range> getRanges(@Nonnull Document document,
                                     @Nonnull CharSequence contentFromVcs) throws FilesTooBigForDiffException
{
  Document documentFromVcs = ((EditorFactoryImpl)EditorFactory.getInstance()).createDocument(contentFromVcs, true, false);
  return RangesBuilder.createRanges(document, documentFromVcs);
}
项目:intellij-ce-playground    文件:FileDocumentManagerImpl.java   
private static Document createDocument(final CharSequence text, VirtualFile file) {
  boolean acceptSlashR = file instanceof LightVirtualFile && StringUtil.indexOf(text, '\r') >= 0;
  return ((EditorFactoryImpl)EditorFactory.getInstance()).createDocument(text, acceptSlashR, false);
}
项目:intellij-ce-playground    文件:CCProjectComponent.java   
public void projectOpened() {
  StartupManager.getInstance(myProject).runWhenProjectIsInitialized(new Runnable() {
    @Override
    public void run() {
      final Course course = CCProjectService.getInstance(myProject).getCourse();
      if (course != null) {
        course.initCourse(true);
        myProject.getMessageBus().connect(myProject).subscribe(
          FileEditorManagerListener.FILE_EDITOR_MANAGER, new FileEditorManagerAdapter() {
            @Override
            public void selectionChanged(@NotNull FileEditorManagerEvent event) {
              final VirtualFile oldFile = event.getOldFile();
              if (oldFile == null) {
                return;
              }
              if (CCProjectService.getInstance(myProject).isTaskFile(oldFile)) {
                FileEditorManager.getInstance(myProject).closeFile(oldFile);
                ApplicationManager.getApplication().runWriteAction(new Runnable() {
                  @Override
                  public void run() {
                    try {
                      oldFile.delete(myProject);
                    }
                    catch (IOException e) {
                      LOG.error(e);
                    }
                  }
                });
              }
            }
          });
        myListener = new CCFileDeletedListener(myProject);
        VirtualFileManager.getInstance().addVirtualFileListener(myListener);
        final CCEditorFactoryListener editorFactoryListener = new CCEditorFactoryListener();
        EditorFactory.getInstance().addEditorFactoryListener(editorFactoryListener, myProject);
        VirtualFile[] files = FileEditorManager.getInstance(myProject).getOpenFiles();
        for (VirtualFile file : files) {
          if (CCProjectService.getInstance(myProject).isTaskFile(file)) {
            FileEditorManager.getInstance(myProject).closeFile(file);
            continue;
          }
          FileEditor fileEditor = FileEditorManager.getInstance(myProject).getSelectedEditor(file);
          if (fileEditor instanceof PsiAwareTextEditorImpl) {
            Editor editor = ((PsiAwareTextEditorImpl)fileEditor).getEditor();
            editorFactoryListener.editorCreated(new EditorFactoryEvent(new EditorFactoryImpl(ProjectManager.getInstance()), editor));
          }
        }
      }
    }
  });
}
项目:tools-idea    文件:ConsoleViewUtil.java   
public static EditorEx setupConsoleEditor(Project project, final boolean foldingOutlineShown, final boolean lineMarkerAreaShown) {
  EditorFactory editorFactory = EditorFactory.getInstance();
  EditorEx editor = (EditorEx) editorFactory.createViewer(((EditorFactoryImpl)editorFactory).createDocument(true), project);
  setupConsoleEditor(editor, foldingOutlineShown, lineMarkerAreaShown);
  return editor;
}
项目:consulo    文件:FileDocumentManagerImpl.java   
private static Document createDocument(final CharSequence text, VirtualFile file) {
  boolean acceptSlashR = file instanceof LightVirtualFile && StringUtil.indexOf(text, '\r') >= 0;
  boolean freeThreaded = Boolean.TRUE.equals(file.getUserData(SingleRootFileViewProvider.FREE_THREADED));
  return ((EditorFactoryImpl)EditorFactory.getInstance()).createDocument(text, acceptSlashR, freeThreaded);
}