當前位置: 首頁>>代碼示例>>Java>>正文


Java EditorFactory.createEditor方法代碼示例

本文整理匯總了Java中com.intellij.openapi.editor.EditorFactory.createEditor方法的典型用法代碼示例。如果您正苦於以下問題:Java EditorFactory.createEditor方法的具體用法?Java EditorFactory.createEditor怎麽用?Java EditorFactory.createEditor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.intellij.openapi.editor.EditorFactory的用法示例。


在下文中一共展示了EditorFactory.createEditor方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createUIComponents

import com.intellij.openapi.editor.EditorFactory; //導入方法依賴的package包/類
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));
}
 
開發者ID:t28hub,項目名稱:json2java4idea,代碼行數:23,代碼來源:SettingsPanel.java

示例2: createUIComponents

import com.intellij.openapi.editor.EditorFactory; //導入方法依賴的package包/類
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();
}
 
開發者ID:t28hub,項目名稱:json2java4idea,代碼行數:25,代碼來源:NewClassDialog.java

示例3: createEditor

import com.intellij.openapi.editor.EditorFactory; //導入方法依賴的package包/類
private Editor createEditor() {
    PsiFile myFile = null;
    EditorFactory editorFactory = EditorFactory.getInstance();
    Document doc = myFile == null
            ? editorFactory.createDocument("")
            : PsiDocumentManager.getInstance(mProject).getDocument(myFile);
    Editor editor = editorFactory.createEditor(doc, mProject);
    EditorSettings editorSettings = editor.getSettings();
    editorSettings.setVirtualSpace(false);
    editorSettings.setLineMarkerAreaShown(false);
    editorSettings.setIndentGuidesShown(false);
    editorSettings.setFoldingOutlineShown(true);
    editorSettings.setAdditionalColumnsCount(3);
    editorSettings.setAdditionalLinesCount(3);
    editorSettings.setLineNumbersShown(true);
    editorSettings.setCaretRowShown(true);

    editor.getDocument().addDocumentListener(new DocumentAdapter() {
        @Override
        public void documentChanged(DocumentEvent e) {
        }
    });
    ((EditorEx) editor).setHighlighter(createHighlighter(FileTypes.PLAIN_TEXT));
    return editor;
}
 
開發者ID:FingerArt,項目名稱:ApiDebugger,代碼行數:26,代碼來源:ResponseBodyWidget.java

示例4: createEditor

import com.intellij.openapi.editor.EditorFactory; //導入方法依賴的package包/類
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;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:24,代碼來源:TemplateEditorUtil.java

示例5: createEditorPanel

import com.intellij.openapi.editor.EditorFactory; //導入方法依賴的package包/類
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;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:17,代碼來源:AnalyzeStacktraceUtil.java

示例6: addVmEditor

import com.intellij.openapi.editor.EditorFactory; //導入方法依賴的package包/類
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);
}
 
開發者ID:zeng198821,項目名稱:CodeGenerate,代碼行數:11,代碼來源:TemplateEditPane.java

示例7: showPreviewDialog

import com.intellij.openapi.editor.EditorFactory; //導入方法依賴的package包/類
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();
  }
}
 
開發者ID:medvector,項目名稱:educational-plugin,代碼行數:37,代碼來源:CCShowPreview.java

示例8: testFileStructureForClass

import com.intellij.openapi.editor.EditorFactory; //導入方法依賴的package包/類
public void testFileStructureForClass() throws Exception {
  final PsiPackage aPackage = JavaDirectoryService.getInstance().getPackage(getPackageDirectory());
  assertNotNull(aPackage);
  final PsiClass psiClass = aPackage.getClasses()[0];
  final VirtualFile virtualFile = psiClass.getContainingFile().getVirtualFile();
  assertNotNull(virtualFile);
  final StructureViewBuilder structureViewBuilder =
    StructureViewBuilder.PROVIDER.getStructureViewBuilder(virtualFile.getFileType(), virtualFile, myProject);
  assertNotNull(structureViewBuilder);
  final StructureViewModel structureViewModel = ((TreeBasedStructureViewBuilder)structureViewBuilder).createStructureViewModel(null);

  final EditorFactory factory = EditorFactory.getInstance();
  assertNotNull(factory);
  final Document document = FileDocumentManager.getInstance().getDocument(virtualFile);
  assertNotNull(document);

  final Editor editor = factory.createEditor(document, myProject);
  try {
    final FileStructureDialog dialog =
      new FileStructureDialog(structureViewModel, editor, myProject, psiClass, new Disposable() {
        @Override
        public void dispose() {
          structureViewModel.dispose();
        }
      }, true);
    try {
      final CommanderPanel panel = dialog.getPanel();
      assertListsEqual((ListModel)panel.getModel(), "Inner1\n" + "Inner2\n" + "__method(): void\n" + "_myField1: int\n" + "_myField2: String\n");
    }
    finally {
      dialog.close(0);
    }
  }
  finally {
    factory.releaseEditor(editor);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:38,代碼來源:FileStructureDialogTest.java

示例9: createViewComponentEditor

import com.intellij.openapi.editor.EditorFactory; //導入方法依賴的package包/類
@Nullable
protected Editor createViewComponentEditor(Project project, @Nullable byte[] content, @Nullable FileType fileType) {
  EditorFactory editorFactory = EditorFactory.getInstance();
  if (editorFactory == null) return null;
  T value = getValue();
  Document document = value instanceof VirtualFile
                      ? FileDocumentManager.getInstance().getDocument((VirtualFile)value)
                      : editorFactory.createDocument(StringUtil.convertLineSeparators(new String(content)));

  if (document != null && fileType != null) {
    return editorFactory.createEditor(document, project, fileType, true);
  }
  return null;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:15,代碼來源:DiffElement.java

示例10: createEditor

import com.intellij.openapi.editor.EditorFactory; //導入方法依賴的package包/類
public static EditorEx createEditor(Document document, Project project, boolean isViewer, @Nullable FileType fileType) {
  EditorFactory factory = EditorFactory.getInstance();
  EditorEx editor = (EditorEx)(isViewer ? factory.createViewer(document, project) : factory.createEditor(document, project));
  editor.putUserData(DiffManagerImpl.EDITOR_IS_DIFF_KEY, Boolean.TRUE);
  editor.getGutterComponentEx().revalidateMarkup();

  if (fileType != null && project != null && !project.isDisposed()) {
    CodeStyleFacade codeStyleFacade = CodeStyleFacade.getInstance(project);
    editor.getSettings().setTabSize(codeStyleFacade.getTabSize(fileType));
    editor.getSettings().setUseTabCharacter(codeStyleFacade.useTabCharacter(fileType));
  }

  return editor;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:15,代碼來源:DiffUtil.java

示例11: GenerateTemplateConfigurable

import com.intellij.openapi.editor.EditorFactory; //導入方法依賴的package包/類
public GenerateTemplateConfigurable(TemplateResource template, Map<String, PsiType> contextMap, Project project, boolean multipleFields) {
  this.template = template;
  final EditorFactory factory = EditorFactory.getInstance();
  Document doc = factory.createDocument(template.getTemplate());
  final FileType ftl = FileTypeManager.getInstance().findFileTypeByName("VTL");
  if (project != null && ftl != null) {
    final PsiFile file = PsiFileFactory.getInstance(project)
        .createFileFromText(template.getFileName(), ftl, template.getTemplate(), LocalTimeCounter.currentTime(), true);
    if (!template.isDefault()) {
      final HashMap<String, PsiType> map = new LinkedHashMap<String, PsiType>();
      map.put("java_version", PsiType.INT);
      map.put("class", TemplatesManager.createElementType(project, ClassElement.class));
      if (multipleFields) {
        map.put("fields", TemplatesManager.createFieldListElementType(project));
      } 
      else {
        map.put("field", TemplatesManager.createElementType(project, FieldElement.class));
      }
      map.put("helper", TemplatesManager.createElementType(project, GenerationHelper.class));
      map.put("settings", PsiType.NULL);
      map.putAll(contextMap);
      availableImplicits.addAll(map.keySet());
      file.getViewProvider().putUserData(TemplatesManager.TEMPLATE_IMPLICITS, map);
    }
    final Document document = PsiDocumentManager.getInstance(project).getDocument(file);
    if (document != null) {
      doc = document;
    }
  }
  myEditor = factory.createEditor(doc, project, ftl != null ? ftl : FileTypes.PLAIN_TEXT, template.isDefault());
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:32,代碼來源:GenerateTemplateConfigurable.java

示例12: createEditor

import com.intellij.openapi.editor.EditorFactory; //導入方法依賴的package包/類
@NotNull
private static Editor createEditor() {
	EditorFactory editorFactory = EditorFactory.getInstance();
	Document editorDocument = editorFactory.createDocument("");
	return editorFactory.createEditor(editorDocument, null, CptFileType.INSTANCE, true);
}
 
開發者ID:xylo,項目名稱:intellij-postfix-templates,代碼行數:7,代碼來源:CptPluginSettingsForm.java


注:本文中的com.intellij.openapi.editor.EditorFactory.createEditor方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。