Java 类com.intellij.openapi.editor.EditorFactory 实例源码

项目:json2java4idea    文件:SettingsPanel.java   
private void createUIComponents() {
    final EditorFactory editorFactory = EditorFactory.getInstance();
    previewDocument = editorFactory.createDocument(EMPTY_TEXT);
    previewEditor = editorFactory.createEditor(previewDocument, null, JavaFileType.INSTANCE, true);

    final EditorSettings settings = previewEditor.getSettings();
    settings.setWhitespacesShown(true);
    settings.setLineMarkerAreaShown(false);
    settings.setIndentGuidesShown(false);
    settings.setLineNumbersShown(false);
    settings.setFoldingOutlineShown(false);
    settings.setRightMarginShown(false);
    settings.setVirtualSpace(false);
    settings.setWheelFontChangeEnabled(false);
    settings.setUseSoftWraps(false);
    settings.setAdditionalColumnsCount(0);
    settings.setAdditionalLinesCount(1);

    previewPanel = (JPanel) previewEditor.getComponent();
    previewPanel.setName(PREVIEW_PANEL_NAME);
    previewPanel.setPreferredSize(new Dimension(PREFERRED_PREVIEW_WIDTH, PREFERRED_PREVIEW_HEIGHT));
}
项目:json2java4idea    文件:NewClassDialog.java   
private void createUIComponents() {
    final EditorFactory editorFactory = EditorFactory.getInstance();
    jsonDocument = editorFactory.createDocument(EMPTY_TEXT);
    jsonEditor = editorFactory.createEditor(jsonDocument, project, JsonFileType.INSTANCE, false);

    final EditorSettings settings = jsonEditor.getSettings();
    settings.setWhitespacesShown(true);
    settings.setLineMarkerAreaShown(false);
    settings.setIndentGuidesShown(false);
    settings.setLineNumbersShown(true);
    settings.setFoldingOutlineShown(false);
    settings.setRightMarginShown(false);
    settings.setVirtualSpace(false);
    settings.setWheelFontChangeEnabled(false);
    settings.setUseSoftWraps(false);
    settings.setAdditionalColumnsCount(0);
    settings.setAdditionalLinesCount(1);

    final EditorColorsScheme colorsScheme = jsonEditor.getColorsScheme();
    colorsScheme.setColor(EditorColors.CARET_ROW_COLOR, null);

    jsonEditor.getContentComponent().setFocusable(true);
    jsonPanel = (JPanel) jsonEditor.getComponent();
}
项目:educational-plugin    文件:CCShowPreviewTest.java   
private void doTest(String name) {
  VirtualFile file = configureByTaskFile(name + CCTestsUtil.BEFORE_POSTFIX);
  CCShowPreview action = new CCShowPreview();
  TestActionEvent e = getActionEvent(action,PsiManager.getInstance(getProject()).findFile(file));
  action.beforeActionPerformedUpdate(e);
  assertTrue(e.getPresentation().isEnabled() && e.getPresentation().isVisible());
  action.actionPerformed(e);
  Editor editor = EditorFactory.getInstance().getAllEditors()[1];
  try {
    Pair<Document, List<AnswerPlaceholder>> pair = getPlaceholders(name + CCTestsUtil.AFTER_POSTFIX);
    assertEquals("Files don't match", pair.getFirst().getText(), editor.getDocument().getText());
    for (AnswerPlaceholder placeholder : pair.getSecond()) {
      assertNotNull("No highlighter for placeholder:" + CCTestsUtil.getPlaceholderPresentation(placeholder),
                    getHighlighter(editor.getMarkupModel(), placeholder));
    }
  }
  finally {
    EditorFactory.getInstance().releaseEditor(editor);
  }
}
项目:appetizer-intellij    文件:RemoteCallComponent.java   
public void initComponent() {
  final int port = mySettings.getPortNumber();
  final boolean allowRequestsFromLocalhostOnly = mySettings.isAllowRequestsFromLocalhostOnly();
  EditorEventMulticaster eventMulticaster = EditorFactory.getInstance().getEventMulticaster();
  eventMulticaster.addDocumentListener(new DocumentChangeListener());
  try {
    serverSocket = new ServerSocket();
    serverSocket.bind(new InetSocketAddress(allowRequestsFromLocalhostOnly ? "localhost" : "0.0.0.0", port));
    log.info("Listening " + port);
  }
  catch (IOException e) {
    ApplicationManager.getApplication().invokeLater(new Runnable() {
      public void run() {
        Messages.showMessageDialog("Can't bind with " + port + " port. Appetizer plugin won't work", "Appetizer Plugin Error",
                                   Messages.getErrorIcon());
      }
    });
    return;
  }

  MessageNotifier messageNotifier = new SocketMessageNotifier(serverSocket);
  messageNotifier.addMessageHandler(new OpenFileMessageHandler(new FileNavigatorImpl()));
  listenerThread = new Thread(messageNotifier);
  listenerThread.start();
}
项目:neovim-intellij-complete    文件:Inspect.java   
/**
 * Invokes action in intentionActionDescriptor on file found in path and writes the file to disk.
 *
 * @param path
 * @param fileContent
 * @param intentionActionDescriptor
 * @return
 */
public static String doFix(String path, @Nullable String fileContent, HighlightInfo.IntentionActionDescriptor intentionActionDescriptor) {
    UIUtil.invokeAndWaitIfNeeded((Runnable)() -> {
        PsiFile psiFile = EmbeditorUtil.findTargetFile(path);
        Project project = psiFile.getProject();

        PsiFile fileCopy = fileContent != null
                ? EmbeditorUtil.createDummyPsiFile(project, fileContent, psiFile)
                : EmbeditorUtil.createDummyPsiFile(project, psiFile.getText(), psiFile);

        VirtualFile targetVirtualFile =  psiFile.getVirtualFile();
        Document document = fileCopy.getViewProvider().getDocument();

        Editor editor = EditorFactory.getInstance().createEditor(document, project, targetVirtualFile, false);

        intentionActionDescriptor.getAction().invoke(project, editor, fileCopy);

        FileDocumentManager.getInstance().saveDocument(psiFile.getViewProvider().getDocument());
    });
    return null;
}
项目:intellij-ce-playground    文件:GuiEditor.java   
public void showFormSource() {
  EditorFactory editorFactory = EditorFactory.getInstance();

  Editor editor = editorFactory.createViewer(myDocument, myProject);

  try {
    ((EditorEx)editor).setHighlighter(
      new LexerEditorHighlighter(new XmlFileHighlighter(), EditorColorsManager.getInstance().getGlobalScheme()));

    JComponent component = editor.getComponent();
    component.setPreferredSize(new Dimension(640, 480));

    DialogBuilder dialog = new DialogBuilder(myProject);

    dialog.title("Form - " + myFile.getPresentableName()).dimensionKey("GuiDesigner.FormSource.Dialog");
    dialog.centerPanel(component).setPreferredFocusComponent(editor.getContentComponent());
    dialog.addOkAction();

    dialog.show();
  }
  finally {
    editorFactory.releaseEditor(editor);
  }
}
项目:DarkyenusTimeTracker    文件:TimeTrackerWidget.java   
private void setupAutoStartDocumentListener(boolean enabled) {
    final EditorEventMulticaster editorEventMulticaster = EditorFactory.getInstance().getEventMulticaster();
    if (autoStartDocumentListener != null) {
        editorEventMulticaster.removeDocumentListener(autoStartDocumentListener);
        autoStartDocumentListener = null;
    }
    if (enabled) {
        editorEventMulticaster.addDocumentListener(autoStartDocumentListener = new DocumentListener() {
            @Override
            public void documentChanged(DocumentEvent e) {
                if (running) return;
                //getSelectedTextEditor() must be run from event dispatch thread
                EventQueue.invokeLater(() -> {
                    final Editor selectedTextEditor = FileEditorManager.getInstance(project).getSelectedTextEditor();
                    if (selectedTextEditor == null) return;
                    if(e.getDocument().equals(selectedTextEditor.getDocument())) {
                        setRunning(true);
                    }
                });
            }
        });
    }
}
项目:intellij-ce-playground    文件:PyUtil.java   
/**
 * Force re-highlighting in all open editors that belong to specified project.
 */
public static void rehighlightOpenEditors(final @NotNull Project project) {
  ApplicationManager.getApplication().runWriteAction(new Runnable() {
    @Override
    public void run() {

      for (Editor editor : EditorFactory.getInstance().getAllEditors()) {
        if (editor instanceof EditorEx && editor.getProject() == project) {
          final VirtualFile vFile = ((EditorEx)editor).getVirtualFile();
          if (vFile != null) {
            final EditorHighlighter highlighter = EditorHighlighterFactory.getInstance().createEditorHighlighter(project, vFile);
            ((EditorEx)editor).setHighlighter(highlighter);
          }
        }
      }
    }
  });
}
项目:intellij-ce-playground    文件:BinaryContent.java   
@Override
@Nullable
public Document getDocument() {
  if (myDocument == null) {
    if (isBinary()) return null;

    String text = null;
    try {
      Charset charset = ObjectUtils.notNull(myCharset, EncodingProjectManager.getInstance(myProject).getDefaultCharset());
      text = CharsetToolkit.bytesToString(myBytes, charset);
    }
    catch (IllegalCharsetNameException ignored) { }

    //  Still NULL? only if not supported or an exception was thrown.
    //  Decode a string using the truly default encoding.
    if (text == null) text = new String(myBytes);
    text = LineTokenizer.correctLineSeparators(text);

    myDocument = EditorFactory.getInstance().createDocument(text);
    myDocument.setReadOnly(true);
  }

  return myDocument;
}
项目:intellij-ce-playground    文件:ChangeSignatureGestureDetector.java   
public ChangeSignatureGestureDetector(final PsiDocumentManager psiDocumentManager,
                                      final FileDocumentManager documentManager,
                                      final PsiManager psiManager,
                                      final FileEditorManager fileEditorManager,
                                      final Project project) {
  myDocumentManager = documentManager;
  myPsiDocumentManager = psiDocumentManager;
  myPsiManager = psiManager;
  myFileEditorManager = fileEditorManager;
  myProject = project;
  myPsiManager.addPsiTreeChangeListener(this, this);
  EditorFactory.getInstance().addEditorFactoryListener(this, this);
  Disposer.register(this, new Disposable() {
    @Override
    public void dispose() {
      LOG.assertTrue(myListenerMap.isEmpty(), myListenerMap);
    }
  });
}
项目:intellij-ce-playground    文件:GithubCreateGistContentTest.java   
public void testCreateFromEditorWithoutFile() throws Throwable {
  VirtualFile file = myProjectRoot.findFileByRelativePath("file.txt");
  assertNotNull(file);

  Document document = FileDocumentManager.getInstance().getDocument(file);
  assertNotNull(document);

  myEditor = EditorFactory.getInstance().createEditor(document, myProject);
  assertNotNull(myEditor);

  List<FileContent> expected = new ArrayList<FileContent>();
  expected.add(new FileContent("", "file.txt content"));

  List<FileContent> actual = GithubCreateGistAction.collectContents(myProject, myEditor, null, null);

  checkEquals(expected, actual);
}
项目:intellij-ce-playground    文件:DelayedDocumentWatcher.java   
public void activate() {
  if (myConnection == null) {
    myListenerDisposable = Disposer.newDisposable();
    Disposer.register(myProject, myListenerDisposable);
    EditorFactory.getInstance().getEventMulticaster().addDocumentListener(myListener, myListenerDisposable);
    myConnection = ApplicationManager.getApplication().getMessageBus().connect(myProject);
    myConnection.subscribe(AppTopics.FILE_DOCUMENT_SYNC, new FileDocumentManagerAdapter() {
      @Override
      public void beforeAllDocumentsSaving() {
        myDocumentSavingInProgress = true;
        ApplicationManager.getApplication().invokeLater(new Runnable() {
          @Override
          public void run() {
            myDocumentSavingInProgress = false;
          }
        }, ModalityState.any());
      }
    });
  }
}
项目:intellij-ce-playground    文件:TogglePresentationModeAction.java   
private static void tweakEditorAndFireUpdateUI(UISettings settings, boolean inPresentation) {
  EditorColorsScheme globalScheme = EditorColorsManager.getInstance().getGlobalScheme();
  int fontSize = inPresentation ? settings.PRESENTATION_MODE_FONT_SIZE : globalScheme.getEditorFontSize();
  if (inPresentation) {
    ourSavedConsoleFontSize = globalScheme.getConsoleFontSize();
    globalScheme.setConsoleFontSize(fontSize);
  }
  else {
    globalScheme.setConsoleFontSize(ourSavedConsoleFontSize);
  }
  for (Editor editor : EditorFactory.getInstance().getAllEditors()) {
    if (editor instanceof EditorEx) {
      ((EditorEx)editor).setFontSize(fontSize);
    }
  }
  UISettings.getInstance().fireUISettingsChanged();
  LafManager.getInstance().updateUI();
  EditorUtil.reinitSettings();
}
项目:intellij-ce-playground    文件:AnalyzeStacktraceUtil.java   
public static StacktraceEditorPanel createEditorPanel(Project project, @NotNull Disposable parentDisposable) {
  EditorFactory editorFactory = EditorFactory.getInstance();
  Document document = editorFactory.createDocument("");
  Editor editor = editorFactory.createEditor(document, project);
  EditorSettings settings = editor.getSettings();
  settings.setFoldingOutlineShown(false);
  settings.setLineMarkerAreaShown(false);
  settings.setIndentGuidesShown(false);
  settings.setLineNumbersShown(false);
  settings.setRightMarginShown(false);

  StacktraceEditorPanel editorPanel = new StacktraceEditorPanel(project, editor);
  editorPanel.setPreferredSize(JBUI.size(600, 400));
  Disposer.register(parentDisposable, editorPanel);
  return editorPanel;
}
项目:intellij-ce-playground    文件:EditVarConstraintsDialog.java   
private static Editor createEditor(final Project project, final String text, final String fileName) {
  final FileType fileType = getFileType(fileName);
  final Document doc = createDocument(fileName, fileType, text);
  final Editor editor = EditorFactory.getInstance().createEditor(doc, project);

  ((EditorEx)editor).setEmbeddedIntoDialogWrapper(true);
  final EditorSettings settings = editor.getSettings();
  settings.setLineNumbersShown(false);
  settings.setFoldingOutlineShown(false);
  settings.setRightMarginShown(false);
  settings.setLineMarkerAreaShown(false);
  settings.setIndentGuidesShown(false);
  ((EditorEx)editor).setHighlighter(HighlighterFactory.createHighlighter(fileType, DefaultColorSchemesManager.getInstance().getFirstScheme(), project));

  return editor;
}
项目:intellij-ce-playground    文件:LineStatusTrackerManager.java   
@Override
public void projectOpened() {
  StartupManager.getInstance(myProject).registerPreStartupActivity(new Runnable() {
    @Override
    public void run() {
      final MyFileStatusListener fileStatusListener = new MyFileStatusListener();
      final EditorFactoryListener editorFactoryListener = new MyEditorFactoryListener();
      final MyVirtualFileListener virtualFileListener = new MyVirtualFileListener();
      final EditorColorsListener editorColorsListener = new MyEditorColorsListener();

      final FileStatusManager fsManager = FileStatusManager.getInstance(myProject);
      fsManager.addFileStatusListener(fileStatusListener, myDisposable);

      final EditorFactory editorFactory = EditorFactory.getInstance();
      editorFactory.addEditorFactoryListener(editorFactoryListener, myDisposable);

      final VirtualFileManager virtualFileManager = VirtualFileManager.getInstance();
      virtualFileManager.addVirtualFileListener(virtualFileListener, myDisposable);

      final EditorColorsManager editorColorsManager = EditorColorsManager.getInstance();
      editorColorsManager.addEditorColorsListener(editorColorsListener, myDisposable);
    }
  });
}
项目:intellij-ce-playground    文件:QuickDocOnMouseOverManager.java   
/**
 * Instructs the manager to enable or disable 'show quick doc automatically when the mouse goes over an editor element' mode.
 *
 * @param enabled  flag that identifies if quick doc should be automatically shown
 */
public void setEnabled(boolean enabled) {
  myEnabled = enabled;
  myApplicationActive = enabled;
  if (!enabled) {
    closeQuickDocIfPossible();
    myAlarm.cancelAllRequests();
  }
  EditorFactory factory = EditorFactory.getInstance();
  if (factory == null) {
    return;
  }
  for (Editor editor : factory.getAllEditors()) {
    if (enabled) {
      registerListeners(editor);
    }
    else {
      unRegisterListeners(editor);
    }
  }
}
项目:intellij-ce-playground    文件:GithubCreateGistContentTest.java   
public void testCreateFromEditor() throws Throwable {
  VirtualFile file = myProjectRoot.findFileByRelativePath("file.txt");
  assertNotNull(file);

  Document document = FileDocumentManager.getInstance().getDocument(file);
  assertNotNull(document);

  myEditor = EditorFactory.getInstance().createEditor(document, myProject);
  assertNotNull(myEditor);

  List<FileContent> expected = new ArrayList<FileContent>();
  expected.add(new FileContent("file.txt", "file.txt content"));

  List<FileContent> actual = GithubCreateGistAction.collectContents(myProject, myEditor, file, null);

  checkEquals(expected, actual);
}
项目:intellij-ce-playground    文件:TemplateEditorUtil.java   
private static Editor createEditor(boolean isReadOnly, final Document document, final Project project) {
  EditorFactory editorFactory = EditorFactory.getInstance();
  Editor editor = (isReadOnly ? editorFactory.createViewer(document, project) : editorFactory.createEditor(document, project));
  editor.getContentComponent().setFocusable(!isReadOnly);

  EditorSettings editorSettings = editor.getSettings();
  editorSettings.setVirtualSpace(false);
  editorSettings.setLineMarkerAreaShown(false);
  editorSettings.setIndentGuidesShown(false);
  editorSettings.setLineNumbersShown(false);
  editorSettings.setFoldingOutlineShown(false);
  editorSettings.setCaretRowShown(false);

  EditorColorsScheme scheme = editor.getColorsScheme();
  VirtualFile file = FileDocumentManager.getInstance().getFile(document);
  if (file != null) {
    EditorHighlighter highlighter = EditorHighlighterFactory.getInstance().createEditorHighlighter(file, scheme, project);
    ((EditorEx) editor).setHighlighter(highlighter);

  }

  return editor;
}
项目:intellij-ce-playground    文件:PsiAwareFileEditorManagerImpl.java   
public PsiAwareFileEditorManagerImpl(final Project project,
                                     final PsiManager psiManager,
                                     final WolfTheProblemSolver problemSolver,
                                     DockManager dockManager,
                                     MessageBus messageBus,
                                     EditorHistoryManager editorHistoryManager) {
  super(project, dockManager, editorHistoryManager);
  myPsiManager = psiManager;
  myProblemSolver = problemSolver;
  myPsiTreeChangeListener = new MyPsiTreeChangeListener();
  myProblemListener = new MyProblemListener();
  registerExtraEditorDataProvider(new TextEditorPsiDataProvider(), null);

  // reinit syntax highlighter for Groovy. In power save mode keywords are highlighted by GroovySyntaxHighlighter insteadof
  // GrKeywordAndDeclarationHighlighter. So we need to drop caches for token types attributes in LayeredLexerEditorHighlighter
  messageBus.connect().subscribe(PowerSaveMode.TOPIC, new PowerSaveMode.Listener() {
    @Override
    public void powerSaveStateChanged() {
      for (Editor editor : EditorFactory.getInstance().getAllEditors()) {
        ((EditorEx)editor).reinitSettings();
      }
    }
  });
}
项目:CodeGenerate    文件:TemplateEditPane.java   
private void addVmEditor(String template) {
    EditorFactory factory = EditorFactory.getInstance();
    Document velocityTemplate = factory.createDocument(template);
    editor = factory.createEditor(velocityTemplate, null, FileTypeManager.getInstance()
        .getFileTypeByExtension("vm"), false);
    GridConstraints constraints = new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST,
        GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW,
        GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(300, 300), null, 0, true);
    editorPane.add(editor.getComponent(), constraints);
}
项目:reasonml-idea-plugin    文件:RmlProjectTracker.java   
@Override
public void projectOpened() {
    m_documentListener = new RmlDocumentListener(myProject);
    EditorFactory.getInstance().getEventMulticaster().addDocumentListener(m_documentListener);

    m_messageBusConnection = myProject.getMessageBus().connect();
    m_messageBusConnection.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new RmlFileEditorListener(myProject));

    m_vfListener = new VirtualFileListener(myProject);
    VirtualFileManager.getInstance().addVirtualFileListener(m_vfListener);
}
项目:reasonml-idea-plugin    文件:RmlProjectTracker.java   
@Override
public void projectClosed() {
    EditorFactory.getInstance().getEventMulticaster().removeDocumentListener(m_documentListener);
    VirtualFileManager.getInstance().removeVirtualFileListener(m_vfListener);
    m_documentListener.projectClosed();
    m_messageBusConnection.disconnect();
}
项目:json2java4idea    文件:SettingsPanel.java   
@Override
public void dispose() {
    Collections.list(styleGroup.getElements()).forEach(button -> button.removeActionListener(this));
    classNamePrefixField.getDocument().removeDocumentListener(this);
    classNameSuffixField.getDocument().removeDocumentListener(this);
    generatedAnnotationCheckBox.removeActionListener(this);
    suppressWarningsAnnotationCheckBox.removeActionListener(this);

    if (previewEditor == null || previewEditor.isDisposed()) {
        return;
    }
    EditorFactory.getInstance().releaseEditor(previewEditor);
}
项目:json2java4idea    文件:NewClassDialog.java   
@Override
protected void dispose() {
    if (jsonEditor != null && !jsonEditor.isDisposed()) {
        EditorFactory.getInstance().releaseEditor(jsonEditor);
    }
    super.dispose();
}
项目:json2java4idea    文件:SettingsPanelTest.java   
@Test
public void disposeShouldReleaseEditor() throws Exception {
    // exercise
    application.invokeAndWait(() -> underTest.dispose());

    // verify
    final Editor[] actual = EditorFactory.getInstance().getAllEditors();
    assertThat(actual)
            .isEmpty();
}
项目:intellij-postfix-templates    文件:CptPluginSettingsForm.java   
@Override
public void dispose() {
    if (templatesEditor != null && !templatesEditor.isDisposed()) {
        EditorFactory.getInstance().releaseEditor(templatesEditor);
    }
    templatesEditor = null;
}
项目:educational-plugin    文件:StudySerializationUtils.java   
private static void convertToAbsoluteOffset(JsonObject taskFileObject, JsonObject placeholderObject) {
  int line = placeholderObject.getAsJsonPrimitive(LINE).getAsInt();
  int start = placeholderObject.getAsJsonPrimitive(START).getAsInt();
  if (line == -1) {
    placeholderObject.addProperty(OFFSET, start);
  }
  else {
    Document document = EditorFactory.getInstance().createDocument(taskFileObject.getAsJsonPrimitive(TEXT).getAsString());
    placeholderObject.addProperty(OFFSET, document.getLineStartOffset(line) + start);
  }
}
项目:educational-plugin    文件:CCShowPreview.java   
private static void showPreviewDialog(@NotNull Project project, @NotNull TaskFile taskFile) {
  final FrameWrapper showPreviewFrame = new FrameWrapper(project);
  final LightVirtualFile userFile = new LightVirtualFile(taskFile.name, taskFile.text);
  showPreviewFrame.setTitle(userFile.getName());
  LabeledEditor labeledEditor = new LabeledEditor(null);
  final EditorFactory factory = EditorFactory.getInstance();
  Document document = FileDocumentManager.getInstance().getDocument(userFile);
  if (document == null) {
    return;
  }
  final EditorEx createdEditor = (EditorEx)factory.createEditor(document, project, userFile, true);
  Disposer.register(project, () -> factory.releaseEditor(createdEditor));
  for (AnswerPlaceholder answerPlaceholder : taskFile.getActivePlaceholders()) {
    if (answerPlaceholder.getActiveSubtaskInfo().isNeedInsertText()) {
      answerPlaceholder.setLength(answerPlaceholder.getTaskText().length());
    }
    Integer minIndex = Collections.min(answerPlaceholder.getSubtaskInfos().keySet());
    answerPlaceholder.setUseLength(minIndex >= answerPlaceholder.getActiveSubtaskIndex());
    EduAnswerPlaceholderPainter.drawAnswerPlaceholder(createdEditor, answerPlaceholder, JBColor.BLUE);
  }
  JPanel header = new JPanel();
  header.setLayout(new BoxLayout(header, BoxLayout.Y_AXIS));
  header.setBorder(new EmptyBorder(10, 10, 10, 10));
  header.add(new JLabel("Read-only preview."));
  String timeStamp = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(Calendar.getInstance().getTime());
  header.add(new JLabel(String.format("Created %s.", timeStamp)));
  JComponent editorComponent = createdEditor.getComponent();
  labeledEditor.setComponent(editorComponent, header);
  createdEditor.setCaretVisible(false);
  createdEditor.setCaretEnabled(false);
  showPreviewFrame.setComponent(labeledEditor);
  if (!ApplicationManager.getApplication().isUnitTestMode()) {
    showPreviewFrame.setSize(new Dimension(500, 500));
    showPreviewFrame.show();
  }
}
项目:educational-plugin    文件:CCTestCase.java   
public Pair<Document, List<AnswerPlaceholder>> getPlaceholders(String name, boolean useLength, boolean removeMarkers) {
  try {
    String text = StringUtil.convertLineSeparators(FileUtil.loadFile(new File(getBasePath(), name)));
    Document tempDocument = EditorFactory.getInstance().createDocument(text);
    if (removeMarkers) {
      EditorTestUtil.extractCaretAndSelectionMarkers(tempDocument);
    }
    List<AnswerPlaceholder> placeholders = getPlaceholders(tempDocument, useLength);
    return Pair.create(tempDocument, placeholders);
  }
  catch (IOException e) {
    LOG.error(e);
  }
  return Pair.create(null, null);
}
项目:CodeGen    文件:SqlEditorPanel.java   
private void createUIComponents() {
    // TODO: place custom component creation code here
    rootPanel = new JPanel();
    sqlPanel = new JPanel();
    sqlPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    // 设置 sql text editor
    Document document = EditorFactory.getInstance().createDocument("");
    sqlTextArea = EditorFactory.getInstance().createEditor(document, ideaContext.getProject(), SqlFileType.INSTANCE, false);

    sqlScrollPane = new JBScrollPane();
    sqlScrollPane.setViewportView(sqlTextArea.getComponent());
}
项目:MultiHighlight    文件:ColorPreviewPanel.java   
public ColorPreviewPanel() {
    final EditorFactory editorFactory = EditorFactory.getInstance();
    myEditor = (EditorEx) editorFactory.createViewer(editorFactory.createDocument(""));

    final EditorSettings settings = myEditor.getSettings();
    settings.setLineNumbersShown(true);
    settings.setWhitespacesShown(true);
    settings.setLineMarkerAreaShown(false);
    settings.setIndentGuidesShown(false);
    settings.setFoldingOutlineShown(false);
    settings.setAdditionalColumnsCount(0);
    settings.setAdditionalLinesCount(0);
    settings.setRightMarginShown(true);
    settings.setRightMargin(60);

    /** {@link FontEditorPreview#installTrafficLights(EditorEx)} */
    TrafficLightRenderer renderer = new TrafficLightRenderer(null, null, null) {

        private final DaemonCodeAnalyzerStatus status = new DaemonCodeAnalyzerStatus();

        {
            status.errorAnalyzingFinished = true;
            status.errorCount = new int[]{ 0 };
        }

        @NotNull
        @Override
        protected DaemonCodeAnalyzerStatus getDaemonCodeAnalyzerStatus(
                @NotNull SeverityRegistrar severityRegistrar) {
            return status;
        }
    };

    Disposer.register((Disposable) myEditor.getCaretModel(), renderer);
    EditorMarkupModel markupModel = (EditorMarkupModel) myEditor.getMarkupModel();
    markupModel.setErrorStripeRenderer(renderer);
    markupModel.setErrorStripeVisible(true);
}
项目:mule-intellij-plugins    文件:WeaveEditor.java   
@Override
public void dispose() {
    for (Editor editor : editors.values()) {
        EditorFactory.getInstance().releaseEditor(editor);
    }
    Disposer.dispose(textEditor);
    Disposer.dispose(this);
}
项目:appetizer-intellij    文件:DocumentChangeListener.java   
public void documentChanged(DocumentEvent event) {
  Editor[] editors = EditorFactory.getInstance().getEditors(event.getDocument());
  for (Editor editor : editors) {
    editor.getMarkupModel().removeAllHighlighters();
    HighLight.removeAll();
  }
}
项目:MissingInActions    文件:ContentChooser.java   
private void updateViewerForSelection() {
    if (myAllContents.isEmpty()) return;
    String fullString = getSelectedText();

    if (myViewer != null) {
        EditorFactory.getInstance().releaseEditor(myViewer);
    }

    if (myUseIdeaEditor) {
        myViewer = createIdeaEditor(fullString);
        JComponent component = myViewer.getComponent();
        JComponent aboveEditorComponent = getAboveEditorComponent();
        component.setPreferredSize(JBUI.size(300, 500));
        if (aboveEditorComponent != null) {
            JPanel panel = JBUI.Panels.simplePanel(0, 10)
                    .addToTop(aboveEditorComponent)
                    .addToCenter(component);

            mySplitter.setSecondComponent(panel);
        } else {
            mySplitter.setSecondComponent(component);
        }
        updateViewerForSelection(myViewer, myAllContents, getSelectedIndices());
    } else {
        final JTextArea textArea = new JTextArea(fullString);
        textArea.setRows(3);
        textArea.setWrapStyleWord(true);
        textArea.setLineWrap(true);
        textArea.setSelectionStart(0);
        textArea.setSelectionEnd(textArea.getText().length());
        textArea.setEditable(false);
        mySplitter.setSecondComponent(ScrollPaneFactory.createScrollPane(textArea));
    }
    mySplitter.revalidate();
}
项目:MissingInActions    文件:ContentChooser.java   
protected Editor createIdeaEditor(String text) {
    Document doc = EditorFactory.getInstance().createDocument(text);
    Editor editor = EditorFactory.getInstance().createViewer(doc, myProject);
    editor.getSettings().setFoldingOutlineShown(false);
    editor.getSettings().setLineNumbersShown(false);
    editor.getSettings().setLineMarkerAreaShown(false);
    editor.getSettings().setIndentGuidesShown(false);
    return editor;
}
项目:MissingInActions    文件:ContentChooser.java   
@Override
public void dispose() {
    super.dispose();

    SplitterProportionsData d = new SplitterProportionsDataImpl();
    d.externalizeToDimensionService(getClass().getName());
    d.saveSplitterProportions(mySplitter);

    if (myViewer != null) {
        EditorFactory.getInstance().releaseEditor(myViewer);
        myViewer = null;
    }
}
项目:intellij-ce-playground    文件:CvsTabbedWindow.java   
public void dispose() {
  if (myOutput != null) {
    EditorFactory.getInstance().releaseEditor(myOutput);
    myOutput = null;
  }
  if (myErrorsView != null) {
    myErrorsView.dispose();
    myErrorsView = null;
  }
}
项目:stylint-plugin    文件:StylintConfigFileChangeTracker.java   
public void startIfNeeded() {
    if (TRACKING.compareAndSet(false, true))
        ApplicationManager.getApplication().invokeLater(() -> ApplicationManager.getApplication().runWriteAction(() -> {
            VirtualFileManager.getInstance().addVirtualFileListener(new StylintConfigFileVfsListener(), StylintConfigFileChangeTracker.this.project);
            EditorEventMulticaster multicaster = EditorFactory.getInstance().getEventMulticaster();
            multicaster.addDocumentListener(new StylintConfigFileDocumentListener(), StylintConfigFileChangeTracker.this.project);
        }));
}
项目:sass-lint-plugin    文件:SassLintConfigFileListener.java   
private void startListener() {
    if (LISTENING.compareAndSet(false, true))
        ApplicationManager.getApplication().invokeLater(new Runnable() {
            public void run() {
                ApplicationManager.getApplication().runWriteAction(new Runnable() {
                    public void run() {
                        VirtualFileManager.getInstance().addVirtualFileListener(new SassLintConfigFileVfsListener(), SassLintConfigFileListener.this.project);
                        EditorEventMulticaster multicaster = EditorFactory.getInstance().getEventMulticaster();
                        multicaster.addDocumentListener(new SassLintConfigFileDocumentListener(), SassLintConfigFileListener.this.project);
                    }
                });
            }
        });
}