本文整理汇总了Java中com.intellij.openapi.fileEditor.FileEditorManager类的典型用法代码示例。如果您正苦于以下问题:Java FileEditorManager类的具体用法?Java FileEditorManager怎么用?Java FileEditorManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FileEditorManager类属于com.intellij.openapi.fileEditor包,在下文中一共展示了FileEditorManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isRenamingHandlerWithValidName
import com.intellij.openapi.fileEditor.FileEditorManager; //导入依赖的package包/类
private boolean isRenamingHandlerWithValidName(@NotNull String name, Project project) {
PsiElement elementToRename;
String oldName;
Editor editor = FileEditorManager.getInstance(project).getSelectedTextEditor();
if (editor != null) {
DataContext dataContext = DataManager.getInstance().getDataContext(editor.getComponent());
elementToRename = PsiElementRenameHandler.getElement(dataContext);
if (elementToRename instanceof AppleScriptHandler) {
oldName = ((AppleScriptHandler) elementToRename).getName();
final String[] newParts = name.split(":");
final String[] oldParts = oldName != null ? oldName.split(":") : null;
if (oldParts == null || oldParts.length != newParts.length) {
return false;
}
for (String part : newParts) {
if (!isIdentifier(part)) {
return false;
}
}
return true;
} else
return false;
} else
return false;
}
示例2: openFileInPanel
import com.intellij.openapi.fileEditor.FileEditorManager; //导入依赖的package包/类
/**
* 打开类文件
*
* @param filePath
* @param project
*/
public static void openFileInPanel(final String filePath, final Project project) {
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
VirtualFile file = LocalFileSystem.getInstance().refreshAndFindFileByPath(filePath);
if (file != null && file.isValid()) {
FileEditorProvider[] providers = FileEditorProviderManager.getInstance()
.getProviders(project, file);
if (providers.length != 0) {
OpenFileDescriptor descriptor = new OpenFileDescriptor(project, file);
FileEditorManager.getInstance(project).openTextEditor(descriptor, false);
}
}
}
});
}
示例3: insertToEditor
import com.intellij.openapi.fileEditor.FileEditorManager; //导入依赖的package包/类
public void insertToEditor(Project project, SearchResultElement element) {
CommandProcessor.getInstance().executeCommand(project, () -> getApplication().runWriteAction(() -> {
Editor editor = FileEditorManager.getInstance(project).getSelectedTextEditor();
if (editor != null) {
int offset = editor.getCaretModel().getOffset();
Document document = editor.getDocument();
String key = isXmlFile ?
"@" + element.getTag() + "/" + element.getName()
: "R." + element.getTag() + "." + element.getName();
if (key != null) {
document.insertString(offset, key);
editor.getCaretModel().moveToOffset(offset + key.length());
}
}
}), "InsertResultToEditor", "", UndoConfirmationPolicy.DO_NOT_REQUEST_CONFIRMATION);
}
示例4: getAnswerPlaceholder
import com.intellij.openapi.fileEditor.FileEditorManager; //导入依赖的package包/类
@Nullable
private static AnswerPlaceholder getAnswerPlaceholder(PsiElement e, int offset) {
PsiFile file = e.getContainingFile();
if (file == null) {
return null;
}
VirtualFile virtualFile = file.getVirtualFile();
if (virtualFile == null) {
return null;
}
TaskFile taskFile = StudyUtils.getTaskFile(e.getProject(), virtualFile);
if (taskFile == null) {
return null;
}
Document document = FileDocumentManager.getInstance().getDocument(virtualFile);
if (document == null) {
return null;
}
Editor editor = FileEditorManager.getInstance(e.getProject()).getSelectedTextEditor();
return editor == null ? null : taskFile.getAnswerPlaceholder(offset);
}
示例5: drawAllPlaceholders
import com.intellij.openapi.fileEditor.FileEditorManager; //导入依赖的package包/类
public static void drawAllPlaceholders(@NotNull final Project project, @NotNull final Task task) {
VirtualFile taskDir = task.getTaskDir(project);
if (taskDir == null) {
return;
}
for (Map.Entry<String, TaskFile> entry : task.getTaskFiles().entrySet()) {
String name = entry.getKey();
TaskFile taskFile = entry.getValue();
VirtualFile virtualFile = taskDir.findFileByRelativePath(name);
if (virtualFile == null) {
continue;
}
FileEditor fileEditor = FileEditorManager.getInstance(project).getSelectedEditor(virtualFile);
if (fileEditor instanceof StudyEditor) {
StudyEditor studyEditor = (StudyEditor)fileEditor;
StudyUtils.drawAllAnswerPlaceholders(studyEditor.getEditor(), taskFile);
}
}
}
示例6: 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);
}
}
示例7: openInEditor
import com.intellij.openapi.fileEditor.FileEditorManager; //导入依赖的package包/类
public void openInEditor(Project project, CvsModule cvsFile) {
CvsRepository repository = cvsFile.getRepository();
RevisionOrDate revisionOrDate = RevisionOrDateImpl.createOn(new DateOrRevisionSettings().updateFrom(repository.getDateOrRevision()));
GetFileContentOperation operation = new GetFileContentOperation(new File(cvsFile.getPathInCvs()),
CvsRootConfiguration.createOn(repository),
revisionOrDate
);
ComparableVcsRevisionOnOperation revision = new ComparableVcsRevisionOnOperation(operation,
project);
VcsVirtualFile vcsVirtualFile = new VcsVirtualFile(cvsFile.getPathInCvs(),
revision,
VcsFileSystem.getInstance());
OpenFileDescriptor openFileDescriptor = new OpenFileDescriptor(project, vcsVirtualFile);
FileEditorManager.getInstance(project).openTextEditor(openFileDescriptor, false);
}
示例8: actionPerformed
import com.intellij.openapi.fileEditor.FileEditorManager; //导入依赖的package包/类
public void actionPerformed(AnActionEvent e) {
final Project project = e.getProject();
if (project == null) {
return;
}
Editor editor = FileEditorManager.getInstance(project).getSelectedTextEditor();
if (editor == null) {
return;
}
final Document document = editor.getDocument();
/*
if (document == null) {
return;
}*/
VirtualFile virtualFile = FileDocumentManager.getInstance().getFile(document);
if (virtualFile == null) {
return;
}
System.out.println("should type check " + virtualFile);
}
示例9: 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>();
}
示例10: actionPerformed
import com.intellij.openapi.fileEditor.FileEditorManager; //导入依赖的package包/类
@Override
public void actionPerformed(AnActionEvent event) {
final Project project = event.getProject();
if (project == null) {
return;
}
VirtualFile virtualFile = event.getData(PlatformDataKeys.VIRTUAL_FILE);
if (virtualFile != null && virtualFile.isValid() && !virtualFile.isDirectory()) {
DeltaHexVirtualFile deltaHexVirtualFile = new DeltaHexVirtualFile(virtualFile);
OpenFileDescriptor descriptor = new OpenFileDescriptor(project, deltaHexVirtualFile, 0);
FileEditorManager fileEditorManager = FileEditorManager.getInstance(project);
List<FileEditor> editors = fileEditorManager.openEditor(descriptor, true);
fileEditorManager.setSelectedEditor(virtualFile, DeltaHexWindowProvider.DELTAHEX_EDITOR_TYPE_ID);
for (FileEditor fileEditor : editors) {
if (fileEditor instanceof DeltaHexFileEditor) {
((DeltaHexFileEditor) fileEditor).openFile(deltaHexVirtualFile);
}
}
}
}
示例11: highlightElement
import com.intellij.openapi.fileEditor.FileEditorManager; //导入依赖的package包/类
private static void highlightElement(@NotNull PsiElement element) {
final Project project = element.getProject();
final FileEditorManager editorManager =
FileEditorManager.getInstance(project);
final HighlightManager highlightManager =
HighlightManager.getInstance(project);
final EditorColorsManager editorColorsManager =
EditorColorsManager.getInstance();
final Editor editor = editorManager.getSelectedTextEditor();
final EditorColorsScheme globalScheme =
editorColorsManager.getGlobalScheme();
final TextAttributes textattributes =
globalScheme.getAttributes(
EditorColors.SEARCH_RESULT_ATTRIBUTES);
final PsiElement[] elements = new PsiElement[]{element};
highlightManager.addOccurrenceHighlights(editor, elements,
textattributes, true, null);
StatusBar.Info.set(IntentionPowerPackBundle.message(
"status.bar.escape.highlighting.message"), project);
}
示例12: propertyChanged
import com.intellij.openapi.fileEditor.FileEditorManager; //导入依赖的package包/类
public void propertyChanged(@NotNull VirtualFilePropertyEvent event) {
super.propertyChanged(event);
if (file.equals(event.getFile())) {
// Change document
file.refresh(true, false, new Runnable() {
public void run() {
if (ImageFileTypeManager.getInstance().isImage(file)) {
setValue(file);
} else {
setValue(null);
// Close editor
FileEditorManager editorManager = FileEditorManager.getInstance(project);
editorManager.closeFile(file);
}
}
});
}
}
示例13: notifyUser
import com.intellij.openapi.fileEditor.FileEditorManager; //导入依赖的package包/类
public void notifyUser() {
invokeLaterIfProjectAlive(myProject, new Runnable() {
@Override
public void run() {
EditorNotifications notifications = EditorNotifications.getInstance(myProject);
VirtualFile[] files = FileEditorManager.getInstance(myProject).getOpenFiles();
for (VirtualFile file : files) {
try {
notifications.updateNotifications(file);
}
catch (Throwable e) {
String filePath = toSystemDependentName(file.getPath());
String msg = String.format("Failed to update editor notifications for file '%1$s'", filePath);
LOG.info(msg, e);
}
}
BuildVariantView.getInstance(myProject).updateContents();
}
});
}
示例14: 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);
}
}
}
示例15: showTemplateBuilder
import com.intellij.openapi.fileEditor.FileEditorManager; //导入依赖的package包/类
private static void showTemplateBuilder(@NotNull PyFunction method) {
method = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(method);
final PsiFile file = method.getContainingFile();
if (file == null) return;
final TemplateBuilder builder = TemplateBuilderFactory.getInstance().createTemplateBuilder(method);
ParamHelper.walkDownParamArray(
method.getParameterList().getParameters(),
new ParamHelper.ParamVisitor() {
public void visitNamedParameter(PyNamedParameter param, boolean first, boolean last) {
builder.replaceElement(param, param.getName());
}
}
);
final PyStatementList statementList = method.getStatementList();
builder.replaceElement(statementList, PyNames.PASS);
final VirtualFile virtualFile = file.getVirtualFile();
if (virtualFile == null) return;
final Editor editor = FileEditorManager.getInstance(file.getProject()).openTextEditor(
new OpenFileDescriptor(file.getProject(), virtualFile), true);
if (editor == null) return;
builder.run(editor, false);
}