当前位置: 首页>>代码示例>>Java>>正文


Java FileEditorManagerEx.getEditorsWithProviders方法代码示例

本文整理汇总了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();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:52,代码来源:EditorHistoryManager.java

示例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);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:62,代码来源:EditorHistoryManager.java

示例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();
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:52,代码来源:EditorHistoryManager.java

示例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);
    }
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:63,代码来源:EditorHistoryManager.java

示例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();
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:50,代码来源:EditorHistoryManager.java

示例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);
    }
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:61,代码来源:EditorHistoryManager.java


注:本文中的com.intellij.openapi.fileEditor.ex.FileEditorManagerEx.getEditorsWithProviders方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。