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


Java FileDocumentManager.getFile方法代码示例

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


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

示例1: actionPerformed

import com.intellij.openapi.fileEditor.FileDocumentManager; //导入方法依赖的package包/类
public void actionPerformed( AnActionEvent e ) {
    Editor editor = ( Editor ) e.getDataContext().getData( "editor" );
    SelectionModel selectionModel = editor.getSelectionModel();
    if ( selectionModel != null ) {
        String selectedText = selectionModel.getSelectedText();
        if ( selectedText != null && selectedText.trim().length() > 0 ) {
            Project project = ( Project ) e.getDataContext().getData( DataConstants.PROJECT );
            String panelid = ( String ) project.getUserData( QuickNotes.KEY_PANELID );
            QuickNotesPanel quickNotesPanel = QuickNotesManager.getInstance().getQuickNotesPanel( panelid );
            if ( quickNotesPanel != null ) {
                FileDocumentManager manager = FileDocumentManager.getInstance();
                VirtualFile virtualFile = manager.getFile( editor.getDocument() );
                quickNotesPanel.addNewNote( "[File: " + virtualFile.getPath() + "]\n" + selectedText );
            }
        }
    }
}
 
开发者ID:jrana,项目名称:quicknotes,代码行数:18,代码来源:AddToQuickNotes.java

示例2: navigateToPlaceholder

import com.intellij.openapi.fileEditor.FileDocumentManager; //导入方法依赖的package包/类
private void navigateToPlaceholder(@NotNull final Project project) {
  final Editor selectedEditor = StudyUtils.getSelectedEditor(project);
  if (selectedEditor != null) {
    final FileDocumentManager fileDocumentManager = FileDocumentManager.getInstance();
    final VirtualFile openedFile = fileDocumentManager.getFile(selectedEditor.getDocument());
    if (openedFile != null) {
      final TaskFile selectedTaskFile = StudyUtils.getTaskFile(project, openedFile);
      if (selectedTaskFile != null) {
        final int offset = selectedEditor.getCaretModel().getOffset();
        final AnswerPlaceholder targetPlaceholder = getTargetPlaceholder(selectedTaskFile, offset);
        if (targetPlaceholder == null) {
          return;
        }
        StudyNavigator.navigateToAnswerPlaceholder(selectedEditor, targetPlaceholder);
      }
    }
  }
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:19,代码来源:StudyWindowNavigationAction.java

示例3: processKeyTyped

import com.intellij.openapi.fileEditor.FileDocumentManager; //导入方法依赖的package包/类
private boolean processKeyTyped(char c) {
  // [vova] This is patch for Mac OS X. Under Mac "input methods"
  // is handled before our EventQueue consume upcoming KeyEvents.
  IdeEventQueue queue = IdeEventQueue.getInstance();
  if (queue.shouldNotTypeInEditor() || ProgressManager.getInstance().hasModalProgressIndicator()) {
    return false;
  }
  FileDocumentManager manager = FileDocumentManager.getInstance();
  final VirtualFile file = manager.getFile(myDocument);
  if (file != null && !file.isValid()) {
    return false;
  }

  ActionManagerEx actionManager = ActionManagerEx.getInstanceEx();
  DataContext dataContext = getDataContext();
  actionManager.fireBeforeEditorTyping(c, dataContext);
  MacUIUtil.hideCursor();
  EditorActionManager.getInstance().getTypedAction().actionPerformed(this, c, dataContext);

  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:bigFile.java

示例4: documentChanged

import com.intellij.openapi.fileEditor.FileDocumentManager; //导入方法依赖的package包/类
@Override
public void documentChanged(DocumentEvent event) {
  Document document = event.getDocument();
  FileDocumentManager fileDocumentManager = FileDocumentManager.getInstance();
  VirtualFile file = fileDocumentManager.getFile(document);
  if (file == null) {
    return;
  }

  String path = ExternalSystemApiUtil.getLocalFileSystemPath(file);
  for (MyEntry entry : myAutoImportAware) {
    if (entry.aware.getAffectedExternalProjectPath(path, myProject) != null) {
      // Document save triggers VFS event but FileDocumentManager might be registered after the current listener, that's why
      // call to 'saveDocument()' might not produce the desired effect. That's why we reschedule document save if necessary.
      scheduleDocumentSave(document);
      return;
    }
  } 
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:ExternalSystemAutoImporter.java

示例5: processKeyTyped

import com.intellij.openapi.fileEditor.FileDocumentManager; //导入方法依赖的package包/类
private boolean processKeyTyped(char c) {
  // [vova] This is patch for Mac OS X. Under Mac "input methods"
  // is handled before our EventQueue consume upcoming KeyEvents.
  IdeEventQueue queue = IdeEventQueue.getInstance();
  if (queue.shouldNotTypeInEditor() || ProgressManager.getInstance().hasModalProgressIndicator()) {
    return false;
  }
  FileDocumentManager manager = FileDocumentManager.getInstance();
  final VirtualFile file = manager.getFile(myDocument);
  if (file != null && !file.isValid()) {
    return false;
  }

  ActionManagerEx actionManager = ActionManagerEx.getInstanceEx();
  DataContext dataContext = getDataContext();

  myImmediatePainter.paintCharacter(myEditorComponent.getGraphics(), c);

  actionManager.fireBeforeEditorTyping(c, dataContext);
  MacUIUtil.hideCursor();
  EditorActionManager.getInstance().getTypedAction().actionPerformed(this, c, dataContext);

  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:EditorImpl.java

示例6: navigateToPlaceholder

import com.intellij.openapi.fileEditor.FileDocumentManager; //导入方法依赖的package包/类
private void navigateToPlaceholder(@NotNull final Project project) {
final Editor selectedEditor = StudyUtils.getSelectedEditor(project);
if (selectedEditor != null) {
  final FileDocumentManager fileDocumentManager = FileDocumentManager.getInstance();
  final VirtualFile openedFile = fileDocumentManager.getFile(selectedEditor.getDocument());
  if (openedFile != null) {
    final TaskFile selectedTaskFile = StudyUtils.getTaskFile(project, openedFile);
    if (selectedTaskFile != null) {
      final AnswerPlaceholder selectedAnswerPlaceholder = getSelectedAnswerPlaceholder(selectedEditor, selectedTaskFile);
      if (selectedAnswerPlaceholder == null) {
        return;
      }
      final AnswerPlaceholder nextAnswerPlaceholder = getNextAnswerPlaceholder(selectedAnswerPlaceholder);
      if (nextAnswerPlaceholder == null) {
        return;
      }
      StudyNavigator.navigateToAnswerPlaceholder(selectedEditor, nextAnswerPlaceholder, selectedTaskFile);
      selectedEditor.getSelectionModel().removeSelection();
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:StudyWindowNavigationAction.java

示例7: processUnsaved

import com.intellij.openapi.fileEditor.FileDocumentManager; //导入方法依赖的package包/类
private static void processUnsaved(@NotNull VcsDirtyScope dirtyScope,
                                   ChangeListManagerGate addGate,
                                   @NotNull SvnChangeProviderContext context)
  throws SVNException {
  FileDocumentManager fileDocumentManager = FileDocumentManager.getInstance();

  for (Document unsavedDocument : fileDocumentManager.getUnsavedDocuments()) {
    final VirtualFile file = fileDocumentManager.getFile(unsavedDocument);
    if (file != null && dirtyScope.belongsTo(VcsUtil.getFilePath(file)) && fileDocumentManager.isFileModified(file)) {
      final FileStatus status = addGate.getStatus(file);
      if (status == null || FileStatus.NOT_CHANGED.equals(status)) {
        context.addModifiedNotSavedChange(file);
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:SvnChangeProvider.java

示例8: visibleAreaChanged

import com.intellij.openapi.fileEditor.FileDocumentManager; //导入方法依赖的package包/类
@Override
public void visibleAreaChanged(VisibleAreaEvent visibleAreaEvent) {
    final FileDocumentManager instance = FileDocumentManager.getInstance();
    final VirtualFile file = instance.getFile(visibleAreaEvent.getEditor().getDocument());
    if (file != null) {
        GTMRecord.record(file.getPath(), visibleAreaEvent.getEditor().getProject());
    }
}
 
开发者ID:git-time-metric,项目名称:gtm-jetbrains-plugin,代码行数:9,代码来源:GTMVisibleAreaListener.java

示例9: mousePressed

import com.intellij.openapi.fileEditor.FileDocumentManager; //导入方法依赖的package包/类
@Override
public void mousePressed(EditorMouseEvent editorMouseEvent) {
    final FileDocumentManager instance = FileDocumentManager.getInstance();
    final VirtualFile file = instance.getFile(editorMouseEvent.getEditor().getDocument());
    if (file != null) {
        GTMRecord.record(file.getPath(), editorMouseEvent.getEditor().getProject());
    }
}
 
开发者ID:git-time-metric,项目名称:gtm-jetbrains-plugin,代码行数:9,代码来源:GTMEditorMouseListener.java

示例10: getFile

import com.intellij.openapi.fileEditor.FileDocumentManager; //导入方法依赖的package包/类
private static PsiFile getFile(final Editor      editor ,
                               final DataContext context )
{
    final Project             project             = (Project) context.getData(DataConstants.PROJECT);
    final Document            document            = editor.getDocument();
    final FileDocumentManager fileDocumentManager = FileDocumentManager.getInstance();
    final VirtualFile         virtualFile         = fileDocumentManager.getFile(document);
    final PsiManager          psiManager          = PsiManager.getInstance(project);
    return psiManager.findFile(virtualFile);
}
 
开发者ID:DaveKriewall,项目名称:Rearranger,代码行数:11,代码来源:RearrangerActionHandler.java

示例11: getFile

import com.intellij.openapi.fileEditor.FileDocumentManager; //导入方法依赖的package包/类
private static PsiFile getFile(final Editor editor,
                               final DataContext context)
{
    final Project project = (Project) context.getData(DataConstants.PROJECT);
    final Document document = editor.getDocument();
    final FileDocumentManager fileDocumentManager = FileDocumentManager.getInstance();
    final VirtualFile virtualFile = fileDocumentManager.getFile(document);
    final PsiManager psiManager = PsiManager.getInstance(project);
    return psiManager.findFile(virtualFile);
}
 
开发者ID:DaveKriewall,项目名称:Rearranger,代码行数:11,代码来源:LiveRearrangerActionHandler.java

示例12: doBeforeChangedUpdate

import com.intellij.openapi.fileEditor.FileDocumentManager; //导入方法依赖的package包/类
private void doBeforeChangedUpdate(DocumentEvent event) {
  Application app = ApplicationManager.getApplication();
  if (app != null) {
    FileDocumentManager manager = FileDocumentManager.getInstance();
    VirtualFile file = manager.getFile(this);
    if (file != null && !file.isValid()) {
      LOG.error("File of this document has been deleted.");
    }
  }
  assertInsideCommand();

  getLineSet(); // initialize line set to track changed lines

  if (!ShutDownTracker.isShutdownHookRunning()) {
    DocumentListener[] listeners = getCachedListeners();
    for (int i = listeners.length - 1; i >= 0; i--) {
      try {
        listeners[i].beforeDocumentChange(event);
      }
      catch (Throwable e) {
        LOG.error(e);
      }
    }
  }

  myEventsHandling = true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:28,代码来源:DocumentImpl.java

示例13: strip

import com.intellij.openapi.fileEditor.FileDocumentManager; //导入方法依赖的package包/类
private void strip(@NotNull final Document document) {
  if (!document.isWritable()) return;
  FileDocumentManager fileDocumentManager = FileDocumentManager.getInstance();
  VirtualFile file = fileDocumentManager.getFile(document);
  if (file == null || !file.isValid() || Boolean.TRUE.equals(DISABLE_FOR_FILE_KEY.get(file))) return;

  final EditorSettingsExternalizable settings = EditorSettingsExternalizable.getInstance();
  if (settings == null) return;

  final String overrideStripTrailingSpacesData = file.getUserData(OVERRIDE_STRIP_TRAILING_SPACES_KEY);
  final Boolean overrideEnsureNewlineData = file.getUserData(OVERRIDE_ENSURE_NEWLINE_KEY);
  @EditorSettingsExternalizable.StripTrailingSpaces
  String stripTrailingSpaces = overrideStripTrailingSpacesData != null ? overrideStripTrailingSpacesData : settings.getStripTrailingSpaces();
  final boolean doStrip = !stripTrailingSpaces.equals(EditorSettingsExternalizable.STRIP_TRAILING_SPACES_NONE);
  final boolean ensureEOL = overrideEnsureNewlineData != null ? overrideEnsureNewlineData.booleanValue() : settings.isEnsureNewLineAtEOF();

  if (doStrip) {
    final boolean inChangedLinesOnly = !stripTrailingSpaces.equals(EditorSettingsExternalizable.STRIP_TRAILING_SPACES_WHOLE);
    boolean success = stripIfNotCurrentLine(document, inChangedLinesOnly);
    if (!success) {
      myDocumentsToStripLater.add(document);
    }
  }

  final int lines = document.getLineCount();
  if (ensureEOL && lines > 0) {
    final int start = document.getLineStartOffset(lines - 1);
    final int end = document.getLineEndOffset(lines - 1);
    if (start != end) {
      final CharSequence content = document.getCharsSequence();
      ApplicationManager.getApplication().runWriteAction(new DocumentRunnable(document, null) {
        @Override
        public void run() {
          CommandProcessor.getInstance().runUndoTransparentAction(new Runnable() {
            @Override
            public void run() {
              if (CharArrayUtil.containsOnlyWhiteSpaces(content.subSequence(start, end)) && doStrip) {
                document.deleteString(start, end);
              }
              else {
                document.insertString(end, "\n");
              }
            }
          });
        }
      });
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:50,代码来源:TrailingSpacesStripper.java

示例14: selectConfigMatch

import com.intellij.openapi.fileEditor.FileDocumentManager; //导入方法依赖的package包/类
@NotNull
private ConfigMatch selectConfigMatch(@NotNull List<ConfigMatch> matches) {
  List<String> deviceIds = myManager.getStateManager().getProjectState().getDeviceIds();
  Map<String, Integer> idRank = Maps.newHashMapWithExpectedSize(deviceIds.size());
  int rank = 0;
  for (String id : deviceIds) {
    idRank.put(id, rank++);
  }

  // API 11-13: look for a x-large device
  Comparator<ConfigMatch> comparator = null;
  IAndroidTarget projectTarget = myManager.getProjectTarget();
  if (projectTarget != null) {
    int apiLevel = projectTarget.getVersion().getFeatureLevel();
    if (apiLevel >= 11 && apiLevel < 14) {
      // TODO: Maybe check the compatible-screen tag in the manifest to figure out
      // what kind of device should be used for display.
      comparator = new TabletConfigComparator(idRank);
    }
  }

  if (comparator == null) {
    // lets look for a high density device
    comparator = new PhoneConfigComparator(idRank);
  }

  Collections.sort(matches, comparator);

  // Look at the currently active editor to see if it's a layout editor, and if so,
  // look up its configuration and if the configuration is in our match list,
  // use it. This means we "preserve" the current configuration when you open
  // new layouts.
  // TODO: This is running too late for the layout preview; the new editor has
  // already taken over so getSelectedTextEditor() returns self. Perhaps we
  // need to fish in the open editors instead.

  //Editor activeEditor = ApplicationManager.getApplication().runReadAction(new Computable<Editor>() {
  //  @Override
  //  public Editor compute() {
  //    FileEditorManager editorManager = FileEditorManager.getInstance(myManager.getProject());
  //    return editorManager.getSelectedTextEditor();
  //  }
  //});

  // TODO: How do I redispatch without risking lock?
  //Editor activeEditor = AndroidUtils.getSelectedEditor(myManager.getProject());
  if (ApplicationManager.getApplication().isDispatchThread()) {
    FileEditorManager editorManager = FileEditorManager.getInstance(myManager.getProject());
    Editor activeEditor = editorManager.getSelectedTextEditor();
    if (activeEditor != null) {
      FileDocumentManager documentManager = FileDocumentManager.getInstance();
      VirtualFile file = documentManager.getFile(activeEditor.getDocument());
      if (file != null && !file.equals(myFile) && file.getFileType() == StdFileTypes.XML
          && ResourceHelper.getFolderType(myFile) == ResourceHelper.getFolderType(file)) {
        Configuration configuration = myManager.getConfiguration(file);
        FolderConfiguration fullConfig = configuration.getFullConfig();
        for (ConfigMatch match : matches) {
          if (fullConfig.equals(match.testConfig)) {
            return match;
          }
        }
      }
    }
  }

  // the list has been sorted so that the first item is the best config
  return matches.get(0);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:69,代码来源:ConfigurationMatcher.java


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