本文整理汇总了Java中com.intellij.openapi.fileEditor.FileEditorManager.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java FileEditorManager.getInstance方法的具体用法?Java FileEditorManager.getInstance怎么用?Java FileEditorManager.getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.fileEditor.FileEditorManager
的用法示例。
在下文中一共展示了FileEditorManager.getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addFileLevelHighlight
import com.intellij.openapi.fileEditor.FileEditorManager; //导入方法依赖的package包/类
@Override
public void addFileLevelHighlight(@NotNull final Project project,
final int group,
@NotNull final HighlightInfo info,
@NotNull final PsiFile psiFile) {
VirtualFile vFile = psiFile.getViewProvider().getVirtualFile();
final FileEditorManager manager = FileEditorManager.getInstance(project);
for (FileEditor fileEditor : manager.getEditors(vFile)) {
if (fileEditor instanceof TextEditor) {
FileLevelIntentionComponent component = new FileLevelIntentionComponent(info.getDescription(), info.getSeverity(),
info.getGutterIconRenderer(), info.quickFixActionRanges,
project, psiFile, ((TextEditor)fileEditor).getEditor());
manager.addTopComponent(fileEditor, component);
List<HighlightInfo> fileLevelInfos = fileEditor.getUserData(FILE_LEVEL_HIGHLIGHTS);
if (fileLevelInfos == null) {
fileLevelInfos = new ArrayList<HighlightInfo>();
fileEditor.putUserData(FILE_LEVEL_HIGHLIGHTS, fileLevelInfos);
}
info.fileLevelComponent = component;
info.setGroup(group);
fileLevelInfos.add(info);
}
}
}
示例2: tearDown
import com.intellij.openapi.fileEditor.FileEditorManager; //导入方法依赖的package包/类
@Override
protected void tearDown() throws Exception {
try {
if (myProject != null) {
FileEditorManager editorManager = FileEditorManager.getInstance(myProject);
VirtualFile[] openFiles = editorManager.getOpenFiles();
for (VirtualFile openFile : openFiles) {
editorManager.closeFile(openFile);
}
}
}
finally {
myEditor = null;
super.tearDown();
}
}
示例3: overrideOrImplement
import com.intellij.openapi.fileEditor.FileEditorManager; //导入方法依赖的package包/类
public static List<PsiGenerationInfo<PsiMethod>> overrideOrImplement(PsiClass psiClass, @NotNull PsiMethod baseMethod) throws IncorrectOperationException {
FileEditorManager fileEditorManager = FileEditorManager.getInstance(baseMethod.getProject());
List<PsiGenerationInfo<PsiMethod>> results = new ArrayList<PsiGenerationInfo<PsiMethod>>();
try {
List<PsiGenerationInfo<PsiMethod>> prototypes = convert2GenerationInfos(overrideOrImplementMethod(psiClass, baseMethod, false));
if (prototypes.isEmpty()) return null;
PsiSubstitutor substitutor = TypeConversionUtil.getSuperClassSubstitutor(baseMethod.getContainingClass(), psiClass, PsiSubstitutor.EMPTY);
PsiElement anchor = getDefaultAnchorToOverrideOrImplement(psiClass, baseMethod, substitutor);
results = GenerateMembersUtil.insertMembersBeforeAnchor(psiClass, anchor, prototypes);
return results;
}
finally {
PsiFile psiFile = psiClass.getContainingFile();
Editor editor = fileEditorManager.openTextEditor(new OpenFileDescriptor(psiFile.getProject(), psiFile.getVirtualFile()), true);
if (editor != null && !results.isEmpty()) {
results.get(0).positionCaret(editor, true);
editor.getScrollingModel().scrollToCaret(ScrollType.CENTER);
}
}
}
示例4: cleanFileLevelHighlights
import com.intellij.openapi.fileEditor.FileEditorManager; //导入方法依赖的package包/类
@Override
public void cleanFileLevelHighlights(@NotNull Project project, final int group, PsiFile psiFile) {
if (psiFile == null) return;
FileViewProvider provider = psiFile.getViewProvider();
VirtualFile vFile = provider.getVirtualFile();
final FileEditorManager manager = FileEditorManager.getInstance(project);
for (FileEditor fileEditor : manager.getEditors(vFile)) {
final List<HighlightInfo> infos = fileEditor.getUserData(FILE_LEVEL_HIGHLIGHTS);
if (infos == null) continue;
List<HighlightInfo> infosToRemove = new ArrayList<HighlightInfo>();
for (HighlightInfo info : infos) {
if (info.getGroup() == group) {
manager.removeTopComponent(fileEditor, info.fileLevelComponent);
infosToRemove.add(info);
}
}
infos.removeAll(infosToRemove);
}
}
示例5: tearDown
import com.intellij.openapi.fileEditor.FileEditorManager; //导入方法依赖的package包/类
@Override
protected void tearDown() throws Exception {
try {
FileEditorManager editorManager = FileEditorManager.getInstance(getProject());
VirtualFile[] openFiles = editorManager.getOpenFiles();
for (VirtualFile openFile : openFiles) {
editorManager.closeFile(openFile);
}
deleteVFile();
myEditor = null;
myFile = null;
myVFile = null;
}
finally {
super.tearDown();
}
}
示例6: scrollFromSource
import com.intellij.openapi.fileEditor.FileEditorManager; //导入方法依赖的package包/类
public void scrollFromSource() {
FileEditorManager fileEditorManager = FileEditorManager.getInstance(myProject);
Editor selectedTextEditor = fileEditorManager.getSelectedTextEditor();
if (selectedTextEditor != null) {
selectElementAtCaret(selectedTextEditor, false);
return;
}
final FileEditor[] editors = fileEditorManager.getSelectedEditors();
for (FileEditor fileEditor : editors) {
if (fileEditor instanceof TextEditor) {
Editor editor = ((TextEditor)fileEditor).getEditor();
selectElementAtCaret(editor, false);
return;
}
}
final VirtualFile[] selectedFiles = fileEditorManager.getSelectedFiles();
if (selectedFiles.length > 0) {
PsiFile file = PsiManager.getInstance(myProject).findFile(selectedFiles[0]);
selectFile(file, false);
}
}
示例7: showNavigationEditor
import com.intellij.openapi.fileEditor.FileEditorManager; //导入方法依赖的package包/类
public void showNavigationEditor(@Nullable Project project, @Nullable Module module, final String dir, final String file) {
if (project == null) {
return;
}
if (module == null) {
return;
}
VirtualFile baseDir = project.getBaseDir();
if (baseDir == null) { // this happens when we have the 'default' project; can't launch nav editor from here
return;
}
VirtualFile navFile = NavigationEditorUtils.getNavigationFile(baseDir, module.getName(), dir, file);
OpenFileDescriptor descriptor = new OpenFileDescriptor(project, navFile, 0);
FileEditorManager manager = FileEditorManager.getInstance(project);
manager.openEditor(descriptor, true);
manager.setSelectedEditor(navFile, NavigationEditorProvider.ID);
}
示例8: LineStatusTracker
import com.intellij.openapi.fileEditor.FileEditorManager; //导入方法依赖的package包/类
private LineStatusTracker(@NotNull final Document document,
@NotNull final Document vcsDocument,
@NotNull final Project project,
@NotNull final VirtualFile virtualFile,
@NotNull final Mode mode) {
myDocument = document;
myVcsDocument = vcsDocument;
myProject = project;
myVirtualFile = virtualFile;
myApplication = ApplicationManager.getApplication();
myFileEditorManager = FileEditorManager.getInstance(myProject);
myVcsDirtyScopeManager = VcsDirtyScopeManager.getInstance(myProject);
myMode = mode;
myRanges = new ArrayList<Range>();
}
示例9: scrollFromSource
import com.intellij.openapi.fileEditor.FileEditorManager; //导入方法依赖的package包/类
public void scrollFromSource() {
final FileEditorManager fileEditorManager = FileEditorManager.getInstance(myProject);
final Editor selectedTextEditor = fileEditorManager.getSelectedTextEditor();
if (selectedTextEditor != null) {
selectElementAtCaret(selectedTextEditor);
return;
}
final FileEditor[] editors = fileEditorManager.getSelectedEditors();
for (FileEditor fileEditor : editors) {
if (fileEditor instanceof TextEditor) {
Editor editor = ((TextEditor)fileEditor).getEditor();
selectElementAtCaret(editor);
return;
}
}
final VirtualFile[] selectedFiles = fileEditorManager.getSelectedFiles();
if (selectedFiles.length > 0) {
final PsiFile file = PsiManager.getInstance(myProject).findFile(selectedFiles[0]);
if (file != null) {
scrollFromFile(file, null);
}
}
}
示例10: updateOpenedTestFiles
import com.intellij.openapi.fileEditor.FileEditorManager; //导入方法依赖的package包/类
private static void updateOpenedTestFiles(@NotNull Project project,
@NotNull VirtualFile taskDir,
int fromTaskNumber,
int toSubtaskNumber) {
String fromSubtaskTestName = getTestFileName(project, fromTaskNumber);
String toSubtaskTestName = getTestFileName(project, toSubtaskNumber);
if (fromSubtaskTestName == null || toSubtaskTestName == null) {
return;
}
VirtualFile fromTest = taskDir.findChild(fromSubtaskTestName);
VirtualFile toTest = taskDir.findChild(toSubtaskTestName);
if (fromTest == null || toTest == null) {
return;
}
FileEditorManager editorManager = FileEditorManager.getInstance(project);
if (editorManager.isFileOpen(fromTest)) {
VirtualFile[] selectedFiles = editorManager.getSelectedFiles();
boolean isSelected = ArrayUtil.contains(fromTest, selectedFiles);
editorManager.closeFile(fromTest);
editorManager.openFile(toTest, isSelected);
if (!isSelected) {
for (VirtualFile file : selectedFiles) {
editorManager.openFile(file, true);
}
}
}
}
示例11: actionPerformed
import com.intellij.openapi.fileEditor.FileEditorManager; //导入方法依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
final DataContext context = e.getDataContext();
final VirtualFile file = CommonDataKeys.VIRTUAL_FILE.getData(context);
final Project project = e.getProject();
if (file == null || project == null) {
return;
}
final TaskFile taskFile = StudyUtils.getTaskFile(project, file);
if (taskFile == null) {
return;
}
Editor editor = CommonDataKeys.EDITOR.getData(context);
if (editor == null) {
FileEditorManager instance = FileEditorManager.getInstance(project);
if (!instance.isFileOpen(file)) {
return;
}
FileEditor fileEditor = instance.getSelectedEditor(file);
if (!(fileEditor instanceof TextEditor)) {
return;
}
editor = ((TextEditor)fileEditor).getEditor();
}
List<AnswerPlaceholder> placeholders = new ArrayList<>(taskFile.getAnswerPlaceholders());
final ClearPlaceholders action = new ClearPlaceholders(taskFile, placeholders, editor);
EduUtils.runUndoableAction(project, ACTION_NAME, action, UndoConfirmationPolicy.REQUEST_CONFIRMATION);
}
示例12: getActiveEditor
import com.intellij.openapi.fileEditor.FileEditorManager; //导入方法依赖的package包/类
public static Editor getActiveEditor( Project project )
{
if( FileEditorManager.getInstance( project ) instanceof FileEditorManagerImpl )
{
// get the active editor without having to use the dispatch thread, which otherwise can cause deadlock
return DataManager.getInstance().getDataContext( KeyboardFocusManager.getCurrentKeyboardFocusManager().getPermanentFocusOwner() ).getData( PlatformDataKeys.EDITOR );
}
else
{
return FileEditorManager.getInstance( project ).getSelectedTextEditor();
}
}
示例13: showRenameTemplate
import com.intellij.openapi.fileEditor.FileEditorManager; //导入方法依赖的package包/类
public static void showRenameTemplate(PsiElement context, PsiNameIdentifierOwner element) {
context = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(context);
final Query<PsiReference> query = ReferencesSearch.search(element, element.getUseScope());
final Collection<PsiReference> references = query.findAll();
final Project project = context.getProject();
final FileEditorManager fileEditorManager =
FileEditorManager.getInstance(project);
final Editor editor = fileEditorManager.getSelectedTextEditor();
if (editor == null) {
return;
}
final TemplateBuilderImpl builder = new TemplateBuilderImpl(context);
final Expression macroCallNode = new MacroCallNode(
new SuggestVariableNameMacro());
final PsiElement identifier = element.getNameIdentifier();
builder.replaceElement(identifier, "PATTERN", macroCallNode, true);
for (PsiReference reference : references) {
builder.replaceElement(reference, "PATTERN", "PATTERN", false);
}
final Template template = builder.buildInlineTemplate();
final TextRange textRange = context.getTextRange();
final int startOffset = textRange.getStartOffset();
editor.getCaretModel().moveToOffset(startOffset);
final TemplateManager templateManager =
TemplateManager.getInstance(project);
templateManager.startTemplate(editor, template);
}
示例14: openFiles
import com.intellij.openapi.fileEditor.FileEditorManager; //导入方法依赖的package包/类
/**
* open mvp's java file.
*
* @param project
*/
private static void openFiles(Project project, PsiClass... psiClasses) {
FileEditorManager fileEditorManager = FileEditorManager.getInstance(project);
for (PsiClass psiClass :
psiClasses) {
fileEditorManager.openFile(psiClass.getContainingFile().getVirtualFile(), true, true);
}
}
示例15: actionPerformed
import com.intellij.openapi.fileEditor.FileEditorManager; //导入方法依赖的package包/类
@Override
public void actionPerformed(AnActionEvent event) {
final Project project = CommonDataKeys.PROJECT.getData(event.getDataContext());
if (project == null) {
// no active project
LOG.debug("No project");
return;
}
Editor editor = CommonDataKeys.EDITOR.getData(event.getDataContext());
if (editor == null) {
FileEditorManager fem = FileEditorManager.getInstance(project);
editor = fem.getSelectedTextEditor();
}
if (editor == null) {
// no editor available
LOG.debug("No editor");
return;
}
// do we have an xml file?
final PsiDocumentManager pdm = PsiDocumentManager.getInstance(project);
final PsiFile psiFile = pdm.getPsiFile(editor.getDocument());
if (!(psiFile instanceof XmlFile)) {
// not xml
LOG.debug("No XML-File: " + psiFile);
return;
}
// make sure PSI is in sync with document
pdm.commitDocument(editor.getDocument());
execute(editor);
}