class EditorModel {

  public Buffer selectBufferForFile(File file) throws ConsoleException {
    final Buffer existingBuffer = getBufferForFile(file);
    final Buffer buffer;

    if (existingBuffer != null) {
      buffer = existingBuffer;

      selectBuffer(buffer);

      if (!buffer.isUpToDate()) {
        // The user's edits conflict with a file system change.
        // We ensure the buffer is selected before firing this event because
        // the UI might only raise out of date warnings for selected buffers.
        fireBufferNotUpToDate(buffer);
      }
    }
    else {
      buffer = new BufferImplementation(m_resources,
                                        m_textSourceFactory.create(),
                                        file);
      buffer.load();
      addBuffer(buffer);

      m_fileBuffers.put(file, buffer);

      selectBuffer(buffer);
    }

    return buffer;
  }

  public  EditorModel(Resources resources,
                     TextSource.Factory textSourceFactory,
                     AgentCacheState agentCacheState,
                     FileChangeWatcher fileChangeWatcher);

}