本文整理匯總了Java中com.intellij.openapi.editor.EditorFactory類的典型用法代碼示例。如果您正苦於以下問題:Java EditorFactory類的具體用法?Java EditorFactory怎麽用?Java EditorFactory使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
EditorFactory類屬於com.intellij.openapi.editor包,在下文中一共展示了EditorFactory類的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: doTest
import com.intellij.openapi.editor.EditorFactory; //導入依賴的package包/類
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);
}
}
示例4: initComponent
import com.intellij.openapi.editor.EditorFactory; //導入依賴的package包/類
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();
}
示例5: doFix
import com.intellij.openapi.editor.EditorFactory; //導入依賴的package包/類
/**
* 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;
}
示例6: 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);
}
}
示例7: setupAutoStartDocumentListener
import com.intellij.openapi.editor.EditorFactory; //導入依賴的package包/類
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);
}
});
}
});
}
}
示例8: rehighlightOpenEditors
import com.intellij.openapi.editor.EditorFactory; //導入依賴的package包/類
/**
* 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);
}
}
}
}
});
}
示例9: getDocument
import com.intellij.openapi.editor.EditorFactory; //導入依賴的package包/類
@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;
}
示例10: ChangeSignatureGestureDetector
import com.intellij.openapi.editor.EditorFactory; //導入依賴的package包/類
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);
}
});
}
示例11: testCreateFromEditorWithoutFile
import com.intellij.openapi.editor.EditorFactory; //導入依賴的package包/類
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);
}
示例12: activate
import com.intellij.openapi.editor.EditorFactory; //導入依賴的package包/類
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());
}
});
}
}
示例13: tweakEditorAndFireUpdateUI
import com.intellij.openapi.editor.EditorFactory; //導入依賴的package包/類
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();
}
示例14: 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;
}
示例15: createEditor
import com.intellij.openapi.editor.EditorFactory; //導入依賴的package包/類
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;
}