本文整理匯總了Java中com.intellij.openapi.editor.EditorFactory.getInstance方法的典型用法代碼示例。如果您正苦於以下問題:Java EditorFactory.getInstance方法的具體用法?Java EditorFactory.getInstance怎麽用?Java EditorFactory.getInstance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.intellij.openapi.editor.EditorFactory
的用法示例。
在下文中一共展示了EditorFactory.getInstance方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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));
}
示例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();
}
示例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;
}
示例4: setEnabled
import com.intellij.openapi.editor.EditorFactory; //導入方法依賴的package包/類
/**
* 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);
}
}
}
示例5: 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;
}
示例6: 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;
}
示例7: showFormSource
import com.intellij.openapi.editor.EditorFactory; //導入方法依賴的package包/類
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);
}
}
示例8: 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);
}
示例9: 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();
}
}
示例10: ColorPreviewPanel
import com.intellij.openapi.editor.EditorFactory; //導入方法依賴的package包/類
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);
}
示例11: 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);
}
}
示例12: 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;
}
示例13: 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;
}
示例14: setUp
import com.intellij.openapi.editor.EditorFactory; //導入方法依賴的package包/類
@Override
protected void setUp() throws Exception {
super.setUp();
myHistory = new IdeDocumentHistoryImpl(getProject(), EditorFactory.getInstance(), new EditorManager(), VirtualFileManager.getInstance(), CommandProcessor.getInstance(), new Mock.MyToolWindowManager()) {
@Override
protected Pair<FileEditor,FileEditorProvider> getSelectedEditor() {
return Pair.create ((FileEditor)mySelectedEditor, myProvider);
}
@Override
protected void executeCommand(Runnable runnable, String name, Object groupId) {
myHistory.onCommandStarted();
runnable.run();
myHistory.onSelectionChanged();
myHistory.onCommandFinished(groupId);
}
};
mySelectedEditor = new Mock.MyFileEditor() {
@Override
@NotNull
public FileEditorState getState(@NotNull FileEditorStateLevel level) {
return myEditorState;
}
@Override
public void setState(@NotNull FileEditorState state) {
myEditorState = state;
}
};
mySelectedFile = new Mock.MyVirtualFile();
myEditorState = new MyState(false, "start");
myProvider = new Mock.MyFileEditorProvider() {
@Override
@NotNull
public String getEditorTypeId() {
return "EditorType";
}
};
}
示例15: setUp
import com.intellij.openapi.editor.EditorFactory; //導入方法依賴的package包/類
@Override
public void setUp() throws Exception {
super.setUp();
myHistory = new IdeDocumentHistoryImpl(getProject(), EditorFactory.getInstance(),
myManager, VirtualFileManager.getInstance(), CommandProcessor.getInstance(), ToolWindowManager
.getInstance(getProject()));
myHistory.projectOpened();
}