Java 类com.intellij.openapi.editor.actions.IncrementalFindAction 实例源码

项目:intellij-ce-playground    文件:FindUtil.java   
public static void searchBack(final Project project, final Editor editor, @Nullable DataContext context) {
  FindManager findManager = FindManager.getInstance(project);
  if (!findManager.findWasPerformed() && !findManager.selectNextOccurrenceWasPerformed()) {
    new IncrementalFindAction().getHandler().execute(editor, context);
    return;
  }

  FindModel model = findManager.getFindNextModel(editor);
  if (model == null) {
    model = findManager.getFindInFileModel();
  }
  model = model.clone();
  model.setForward(!model.isForward());
  if (!model.isGlobal() && !editor.getSelectionModel().hasSelection()) {
    model.setGlobal(true);
  }

  int offset;
  if (Direction.UP.equals(editor.getUserData(KEY)) && !model.isForward()) {
    offset = editor.getDocument().getTextLength();
  }
  else if (Direction.DOWN.equals(editor.getUserData(KEY)) && model.isForward()) {
    offset = 0;
  }
  else {
    editor.putUserData(KEY, null);
    offset = editor.getCaretModel().getOffset();
    if (!model.isForward() && offset > 0) {
      offset--;
    }
  }
  searchAgain(project, editor, offset, model);
}
项目:intellij-ce-playground    文件:FindUtil.java   
public static boolean searchAgain(final Project project, final Editor editor, @Nullable DataContext context) {
  FindManager findManager = FindManager.getInstance(project);
  if (!findManager.findWasPerformed() && !findManager.selectNextOccurrenceWasPerformed()) {
    new IncrementalFindAction().getHandler().execute(editor, context);
    return false;
  }

  FindModel model = findManager.getFindNextModel(editor);
  if (model == null) {
    model = findManager.getFindInFileModel();
  }
  model = model.clone();

  int offset;
  if (Direction.DOWN.equals(editor.getUserData(KEY)) && model.isForward()) {
    offset = 0;
  }
  else if (Direction.UP.equals(editor.getUserData(KEY)) && !model.isForward()) {
    offset = editor.getDocument().getTextLength();
  }
  else {
    editor.putUserData(KEY, null);
    offset = model.isGlobal() && model.isForward() ? editor.getSelectionModel().getSelectionEnd() : editor.getCaretModel().getOffset();
    if (!model.isForward() && offset > 0) {
      offset--;
    }
  }
  return searchAgain(project, editor, offset, model);
}
项目:tools-idea    文件:FindUtil.java   
public static void searchBack(final Project project, final Editor editor, @Nullable DataContext context) {
  FindManager findManager = FindManager.getInstance(project);
  if (!findManager.findWasPerformed()) {
    new IncrementalFindAction().getHandler().execute(editor, context);
    return;
  }

  FindModel model = findManager.getFindNextModel(editor);
  if (model == null) {
    model = findManager.getFindInFileModel();
  }
  model = (FindModel)model.clone();
  model.setForward(!model.isForward());
  if (!model.isGlobal() && !editor.getSelectionModel().hasSelection()) {
    model.setGlobal(true);
  }

  int offset;
  if (Direction.UP.equals(editor.getUserData(KEY)) && !model.isForward()) {
    offset = editor.getDocument().getTextLength();
  }
  else if (Direction.DOWN.equals(editor.getUserData(KEY)) && model.isForward()) {
    offset = 0;
  }
  else {
    editor.putUserData(KEY, null);
    offset = editor.getCaretModel().getOffset();
    if (!model.isForward() && offset > 0) {
      offset--;
    }
  }
  searchAgain(project, editor, offset, model);
}
项目:tools-idea    文件:FindUtil.java   
public static boolean searchAgain(final Project project, final Editor editor, @Nullable DataContext context) {
  FindManager findManager = FindManager.getInstance(project);
  if (!findManager.findWasPerformed()) {
    new IncrementalFindAction().getHandler().execute(editor, context);
    return false;
  }

  FindModel model = findManager.getFindNextModel(editor);
  if (model == null) {
    model = findManager.getFindInFileModel();
  }
  model = (FindModel)model.clone();

  int offset;
  if (Direction.DOWN.equals(editor.getUserData(KEY)) && model.isForward()) {
    offset = 0;
  }
  else if (Direction.UP.equals(editor.getUserData(KEY)) && !model.isForward()) {
    offset = editor.getDocument().getTextLength();
  }
  else {
    editor.putUserData(KEY, null);
    offset = editor.getCaretModel().getOffset();
    if (!model.isForward() && offset > 0) {
      offset--;
    }
  }
  return searchAgain(project, editor, offset, model);
}
项目:consulo    文件:FindUtil.java   
public static void searchBack(final Project project, final Editor editor, @Nullable DataContext context) {
  FindManager findManager = FindManager.getInstance(project);
  if (!findManager.findWasPerformed() && !findManager.selectNextOccurrenceWasPerformed()) {
    new IncrementalFindAction().getHandler().execute(editor, context);
    return;
  }

  FindModel model = findManager.getFindNextModel(editor);
  if (model == null) {
    model = findManager.getFindInFileModel();
  }
  model = model.clone();
  model.setForward(!model.isForward());
  if (!model.isGlobal() && !editor.getSelectionModel().hasSelection()) {
    model.setGlobal(true);
  }

  int offset;
  if (Direction.UP.equals(editor.getUserData(KEY)) && !model.isForward()) {
    offset = editor.getDocument().getTextLength();
  }
  else if (Direction.DOWN.equals(editor.getUserData(KEY)) && model.isForward()) {
    offset = 0;
  }
  else {
    editor.putUserData(KEY, null);
    offset = editor.getCaretModel().getOffset();
    if (!model.isForward() && offset > 0) {
      offset--;
    }
  }
  searchAgain(project, editor, offset, model);
}
项目:consulo    文件:FindUtil.java   
private static boolean searchAgain(final Project project, final Editor editor, @Nullable DataContext context) {
  FindManager findManager = FindManager.getInstance(project);
  if (!findManager.findWasPerformed() && !findManager.selectNextOccurrenceWasPerformed()) {
    new IncrementalFindAction().getHandler().execute(editor, context);
    return false;
  }

  FindModel model = findManager.getFindNextModel(editor);
  if (model == null) {
    model = findManager.getFindInFileModel();
  }
  model = model.clone();

  int offset;
  if (Direction.DOWN.equals(editor.getUserData(KEY)) && model.isForward()) {
    offset = 0;
  }
  else if (Direction.UP.equals(editor.getUserData(KEY)) && !model.isForward()) {
    offset = editor.getDocument().getTextLength();
  }
  else {
    editor.putUserData(KEY, null);
    offset = model.isGlobal() && model.isForward() ? editor.getSelectionModel().getSelectionEnd() : editor.getCaretModel().getOffset();
    if (!model.isForward() && offset > 0) {
      offset--;
    }
  }
  return searchAgain(project, editor, offset, model);
}