本文整理汇总了Java中com.intellij.openapi.fileEditor.ex.FileEditorManagerEx.getEditorsWithProviders方法的典型用法代码示例。如果您正苦于以下问题:Java FileEditorManagerEx.getEditorsWithProviders方法的具体用法?Java FileEditorManagerEx.getEditorsWithProviders怎么用?Java FileEditorManagerEx.getEditorsWithProviders使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.fileEditor.ex.FileEditorManagerEx
的用法示例。
在下文中一共展示了FileEditorManagerEx.getEditorsWithProviders方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fileOpenedImpl
import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx; //导入方法依赖的package包/类
/**
* Makes file most recent one
*/
private void fileOpenedImpl(@NotNull final VirtualFile file,
@Nullable final FileEditor fallbackEditor,
@Nullable FileEditorProvider fallbackProvider)
{
ApplicationManager.getApplication().assertIsDispatchThread();
// don't add files that cannot be found via VFM (light & etc.)
if (VirtualFileManager.getInstance().findFileByUrl(file.getUrl()) == null) return;
final FileEditorManagerEx editorManager = FileEditorManagerEx.getInstanceEx(myProject);
final Pair<FileEditor[], FileEditorProvider[]> editorsWithProviders = editorManager.getEditorsWithProviders(file);
FileEditor[] editors = editorsWithProviders.getFirst();
FileEditorProvider[] oldProviders = editorsWithProviders.getSecond();
if (editors.length <= 0 && fallbackEditor != null) {
editors = new FileEditor[] { fallbackEditor };
}
if (oldProviders.length <= 0 && fallbackProvider != null) {
oldProviders = new FileEditorProvider[] { fallbackProvider };
}
if (editors.length <= 0) {
LOG.error("No editors for file " + file.getPresentableUrl());
}
FileEditor selectedEditor = editorManager.getSelectedEditor(file);
if (selectedEditor == null) {
selectedEditor = fallbackEditor;
}
LOG.assertTrue(selectedEditor != null);
final int selectedProviderIndex = ArrayUtilRt.find(editors, selectedEditor);
LOG.assertTrue(selectedProviderIndex != -1, "Can't find " + selectedEditor + " among " + Arrays.asList(editors));
final HistoryEntry entry = getEntry(file);
if(entry != null){
removeEntry(entry);
addEntry(entry);
}
else {
final FileEditorState[] states=new FileEditorState[editors.length];
final FileEditorProvider[] providers=new FileEditorProvider[editors.length];
for (int i = states.length - 1; i >= 0; i--) {
final FileEditorProvider provider = oldProviders [i];
LOG.assertTrue(provider != null);
providers[i] = provider;
states[i] = editors[i].getState(FileEditorStateLevel.FULL);
}
addEntry(new HistoryEntry(file, providers, states, providers[selectedProviderIndex]));
trimToSize();
}
}
示例2: updateHistoryEntry
import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx; //导入方法依赖的package包/类
private void updateHistoryEntry(@Nullable final VirtualFile file,
@Nullable final FileEditor fallbackEditor,
@Nullable FileEditorProvider fallbackProvider,
final boolean changeEntryOrderOnly) {
if (file == null) {
return;
}
final FileEditorManagerEx editorManager = FileEditorManagerEx.getInstanceEx(myProject);
final Pair<FileEditor[], FileEditorProvider[]> editorsWithProviders = editorManager.getEditorsWithProviders(file);
FileEditor[] editors = editorsWithProviders.getFirst();
FileEditorProvider[] providers = editorsWithProviders.getSecond();
if (editors.length <= 0 && fallbackEditor != null) {
editors = new FileEditor[] {fallbackEditor};
providers = new FileEditorProvider[] {fallbackProvider};
}
if (editors.length == 0) {
// obviously not opened in any editor at the moment,
// makes no sense to put the file in the history
return;
}
final HistoryEntry entry = getEntry(file);
if(entry == null){
// Size of entry list can be less than number of opened editors (some entries can be removed)
if (file.isValid()) {
// the file could have been deleted, so the isValid() check is essential
fileOpenedImpl(file, fallbackEditor, fallbackProvider);
}
return;
}
if (!changeEntryOrderOnly) { // update entry state
//LOG.assertTrue(editors.length > 0);
for (int i = editors.length - 1; i >= 0; i--) {
final FileEditor editor = editors [i];
final FileEditorProvider provider = providers [i];
if (!editor.isValid()) {
// this can happen for example if file extension was changed
// and this method was called during corresponding myEditor close up
continue;
}
final FileEditorState oldState = entry.getState(provider);
final FileEditorState newState = editor.getState(FileEditorStateLevel.FULL);
if (!newState.equals(oldState)) {
entry.putState(provider, newState);
}
}
}
final Pair <FileEditor, FileEditorProvider> selectedEditorWithProvider = editorManager.getSelectedEditorWithProvider(file);
if (selectedEditorWithProvider != null) {
//LOG.assertTrue(selectedEditorWithProvider != null);
entry.mySelectedProvider = selectedEditorWithProvider.getSecond ();
LOG.assertTrue(entry.mySelectedProvider != null);
if(changeEntryOrderOnly){
removeEntry(entry);
addEntry(entry);
}
}
}
示例3: fileOpenedImpl
import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx; //导入方法依赖的package包/类
/**
* Makes file most recent one
*/
private void fileOpenedImpl(@NotNull final VirtualFile file,
@Nullable final FileEditor fallbackEditor,
@Nullable FileEditorProvider fallbackProvider)
{
ApplicationManager.getApplication().assertIsDispatchThread();
// don't add files that cannot be found via VFM (light & etc.)
if (VirtualFileManager.getInstance().findFileByUrl(file.getUrl()) == null) return;
final FileEditorManagerEx editorManager = FileEditorManagerEx.getInstanceEx(myProject);
final Pair<FileEditor[], FileEditorProvider[]> editorsWithProviders = editorManager.getEditorsWithProviders(file);
FileEditor[] editors = editorsWithProviders.getFirst();
FileEditorProvider[] oldProviders = editorsWithProviders.getSecond();
if (editors.length <= 0 && fallbackEditor != null) {
editors = new FileEditor[] { fallbackEditor };
}
if (oldProviders.length <= 0 && fallbackProvider != null) {
oldProviders = new FileEditorProvider[] { fallbackProvider };
}
if (editors.length <= 0) {
LOG.error("No editors for file " + file.getPresentableUrl());
}
FileEditor selectedEditor = editorManager.getSelectedEditor(file);
if (selectedEditor == null) {
selectedEditor = fallbackEditor;
}
LOG.assertTrue(selectedEditor != null);
final int selectedProviderIndex = ArrayUtilRt.find(editors, selectedEditor);
LOG.assertTrue(selectedProviderIndex != -1);
final HistoryEntry entry = getEntry(file);
if(entry != null){
myEntriesList.remove(entry);
myEntriesList.add(entry);
}
else {
final FileEditorState[] states=new FileEditorState[editors.length];
final FileEditorProvider[] providers=new FileEditorProvider[editors.length];
for (int i = states.length - 1; i >= 0; i--) {
final FileEditorProvider provider = oldProviders [i];
LOG.assertTrue(provider != null);
providers[i] = provider;
states[i] = editors[i].getState(FileEditorStateLevel.FULL);
}
myEntriesList.add(new HistoryEntry(file, providers, states, providers[selectedProviderIndex]));
trimToSize();
}
}
示例4: updateHistoryEntry
import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx; //导入方法依赖的package包/类
private void updateHistoryEntry(@Nullable final VirtualFile file,
@Nullable final FileEditor fallbackEditor,
@Nullable FileEditorProvider fallbackProvider,
final boolean changeEntryOrderOnly)
{
if (file == null) {
return;
}
final FileEditorManagerEx editorManager = FileEditorManagerEx.getInstanceEx(myProject);
final Pair<FileEditor[], FileEditorProvider[]> editorsWithProviders = editorManager.getEditorsWithProviders(file);
FileEditor[] editors = editorsWithProviders.getFirst();
FileEditorProvider[] providers = editorsWithProviders.getSecond();
if (editors.length <= 0 && fallbackEditor != null) {
editors = new FileEditor[] {fallbackEditor};
providers = new FileEditorProvider[] {fallbackProvider};
}
if (editors.length == 0) {
// obviously not opened in any editor at the moment,
// makes no sense to put the file in the history
return;
}
final HistoryEntry entry = getEntry(file);
if(entry == null){
// Size of entry list can be less than number of opened editors (some entries can be removed)
if (file.isValid()) {
// the file could have been deleted, so the isValid() check is essential
fileOpenedImpl(file, fallbackEditor, fallbackProvider);
}
return;
}
if (!changeEntryOrderOnly) { // update entry state
//LOG.assertTrue(editors.length > 0);
for (int i = editors.length - 1; i >= 0; i--) {
final FileEditor editor = editors [i];
final FileEditorProvider provider = providers [i];
if (!editor.isValid()) {
// this can happen for example if file extension was changed
// and this method was called during correponding myEditor close up
continue;
}
final FileEditorState oldState = entry.getState(provider);
final FileEditorState newState = editor.getState(FileEditorStateLevel.FULL);
if (!newState.equals(oldState)) {
entry.putState(provider, newState);
}
}
}
final Pair <FileEditor, FileEditorProvider> selectedEditorWithProvider = editorManager.getSelectedEditorWithProvider(file);
if (selectedEditorWithProvider != null) {
//LOG.assertTrue(selectedEditorWithProvider != null);
entry.mySelectedProvider = selectedEditorWithProvider.getSecond ();
LOG.assertTrue(entry.mySelectedProvider != null);
if(changeEntryOrderOnly){
myEntriesList.remove(entry);
myEntriesList.add(entry);
}
}
}
示例5: fileOpenedImpl
import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx; //导入方法依赖的package包/类
/**
* Makes file most recent one
*/
private void fileOpenedImpl(@Nonnull final VirtualFile file, @Nullable final FileEditor fallbackEditor, @Nullable FileEditorProvider fallbackProvider) {
ApplicationManager.getApplication().assertIsDispatchThread();
// don't add files that cannot be found via VFM (light & etc.)
if (VirtualFileManager.getInstance().findFileByUrl(file.getUrl()) == null) return;
final FileEditorManagerEx editorManager = FileEditorManagerEx.getInstanceEx(myProject);
final Pair<FileEditor[], FileEditorProvider[]> editorsWithProviders = editorManager.getEditorsWithProviders(file);
FileEditor[] editors = editorsWithProviders.getFirst();
FileEditorProvider[] oldProviders = editorsWithProviders.getSecond();
if (editors.length <= 0 && fallbackEditor != null) {
editors = new FileEditor[]{fallbackEditor};
}
if (oldProviders.length <= 0 && fallbackProvider != null) {
oldProviders = new FileEditorProvider[]{fallbackProvider};
}
if (editors.length <= 0) {
LOG.error("No editors for file " + file.getPresentableUrl());
}
FileEditor selectedEditor = editorManager.getSelectedEditor(file);
if (selectedEditor == null) {
selectedEditor = fallbackEditor;
}
LOG.assertTrue(selectedEditor != null);
final int selectedProviderIndex = ArrayUtilRt.find(editors, selectedEditor);
LOG.assertTrue(selectedProviderIndex != -1, "Can't find " + selectedEditor + " among " + Arrays.asList(editors));
final HistoryEntry entry = getEntry(file);
if (entry != null) {
moveOnTop(entry);
}
else {
final FileEditorState[] states = new FileEditorState[editors.length];
final FileEditorProvider[] providers = new FileEditorProvider[editors.length];
for (int i = states.length - 1; i >= 0; i--) {
final FileEditorProvider provider = oldProviders[i];
LOG.assertTrue(provider != null);
FileEditor editor = editors[i];
if (!editor.isValid()) continue;
providers[i] = provider;
states[i] = editor.getState(FileEditorStateLevel.FULL);
}
addEntry(HistoryEntry.createHeavy(myProject, file, providers, states, providers[selectedProviderIndex]));
trimToSize();
}
}
示例6: updateHistoryEntry
import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx; //导入方法依赖的package包/类
private void updateHistoryEntry(@Nullable final VirtualFile file,
@Nullable final FileEditor fallbackEditor,
@Nullable FileEditorProvider fallbackProvider,
final boolean changeEntryOrderOnly) {
if (file == null) {
return;
}
final FileEditorManagerEx editorManager = FileEditorManagerEx.getInstanceEx(myProject);
final Pair<FileEditor[], FileEditorProvider[]> editorsWithProviders = editorManager.getEditorsWithProviders(file);
FileEditor[] editors = editorsWithProviders.getFirst();
FileEditorProvider[] providers = editorsWithProviders.getSecond();
if (editors.length <= 0 && fallbackEditor != null) {
editors = new FileEditor[]{fallbackEditor};
providers = new FileEditorProvider[]{fallbackProvider};
}
if (editors.length == 0) {
// obviously not opened in any editor at the moment,
// makes no sense to put the file in the history
return;
}
final HistoryEntry entry = getEntry(file);
if (entry == null) {
// Size of entry list can be less than number of opened editors (some entries can be removed)
if (file.isValid()) {
// the file could have been deleted, so the isValid() check is essential
fileOpenedImpl(file, fallbackEditor, fallbackProvider);
}
return;
}
if (!changeEntryOrderOnly) { // update entry state
//LOG.assertTrue(editors.length > 0);
for (int i = editors.length - 1; i >= 0; i--) {
final FileEditor editor = editors[i];
final FileEditorProvider provider = providers[i];
if (!editor.isValid()) {
// this can happen for example if file extension was changed
// and this method was called during corresponding myEditor close up
continue;
}
final FileEditorState oldState = entry.getState(provider);
final FileEditorState newState = editor.getState(FileEditorStateLevel.FULL);
if (!newState.equals(oldState)) {
entry.putState(provider, newState);
}
}
}
final Pair<FileEditor, FileEditorProvider> selectedEditorWithProvider = editorManager.getSelectedEditorWithProvider(file);
if (selectedEditorWithProvider != null) {
//LOG.assertTrue(selectedEditorWithProvider != null);
entry.setSelectedProvider(selectedEditorWithProvider.getSecond());
LOG.assertTrue(entry.getSelectedProvider() != null);
if (changeEntryOrderOnly) {
moveOnTop(entry);
}
}
}