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


Java FileEditorManagerEx.getSelectedEditorWithProvider方法代码示例

本文整理汇总了Java中com.intellij.openapi.fileEditor.ex.FileEditorManagerEx.getSelectedEditorWithProvider方法的典型用法代码示例。如果您正苦于以下问题:Java FileEditorManagerEx.getSelectedEditorWithProvider方法的具体用法?Java FileEditorManagerEx.getSelectedEditorWithProvider怎么用?Java FileEditorManagerEx.getSelectedEditorWithProvider使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.openapi.fileEditor.ex.FileEditorManagerEx的用法示例。


在下文中一共展示了FileEditorManagerEx.getSelectedEditorWithProvider方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例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 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

示例3: 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.getSelectedEditorWithProvider方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。