Example #1
0
  /** Opens the given editor on the selected file revision. */
  protected void openEditor(IEditorDescriptor editorDescriptor, boolean openUsingDescriptor) {
    IFileRevision fileRevision = getFileRevision();
    if (fileRevision == null) {
      return;
    }
    try {
      IProgressMonitor monitor = new NullProgressMonitor();
      IStorage storage = fileRevision.getStorage(monitor);
      boolean isFile = storage instanceof IFile;

      if (openUsingDescriptor) {
        // discouraged access to open system editors
        ((WorkbenchPage) (page.getSite().getPage()))
            .openEditorFromDescriptor(
                isFile
                    ? new FileEditorInput((IFile) storage)
                    : (IEditorInput)
                        FileRevisionEditorInput.createEditorInputFor(fileRevision, monitor),
                editorDescriptor,
                true,
                null);
      } else {
        String editorId =
            editorDescriptor == null
                ? IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID
                : editorDescriptor.getId();
        page.getSite()
            .getPage()
            .openEditor(
                isFile
                    ? new FileEditorInput((IFile) storage)
                    : (IEditorInput)
                        FileRevisionEditorInput.createEditorInputFor(fileRevision, monitor),
                editorId,
                true,
                MATCH_BOTH);
      }
    } catch (PartInitException e) {
      StatusAdapter statusAdapter = new StatusAdapter(e.getStatus());
      statusAdapter.setProperty(
          IStatusAdapterConstants.TITLE_PROPERTY, TeamUIMessages.LocalHistoryPage_OpenEditorError);
      StatusManager.getManager().handle(statusAdapter, StatusManager.SHOW);
    } catch (CoreException e) {
      StatusAdapter statusAdapter = new StatusAdapter(e.getStatus());
      statusAdapter.setProperty(
          IStatusAdapterConstants.TITLE_PROPERTY, TeamUIMessages.LocalHistoryPage_OpenEditorError);
      StatusManager.getManager().handle(statusAdapter, StatusManager.LOG);
    }
  }
  @SuppressWarnings("unchecked")
  public void onScroll(
      AbsListView absListView, int firstVisible, int visibleCount, int totalCount) {

    boolean loadMore = /* maybe add a padding */ firstVisible + visibleCount >= totalCount - 1;

    //        Log.d("onScroll:","loadMore f=" + firstVisible + ", vc=" + visibleCount + ", tc="
    // +totalCount);
    if (loadMore) {
      // Debug.startMethodTracing("list" + firstVisible);
      ListAdapter adapter = absListView.getAdapter();
      if (adapter instanceof StatusAdapter) {
        StatusAdapter sta = (StatusAdapter) adapter;
        if (totalCount > 0) {
          Object item = sta.getItem(totalCount - 1);
          int i = 0;
          if (item instanceof DirectMessage) {
            DirectMessage message = (DirectMessage) item;

            List<DirectMessage> messages = th.getDirectsFromDb(message.getId(), 7);
            for (DirectMessage direct : messages) {
              sta.insert(direct, totalCount + i);
              directs.add(direct);
              i++;
            }
          } else if (item instanceof Status) {
            Status last = (Status) item;
            if (statuses == null) statuses = new ArrayList<Status>();

            List<Status> newStatuses = th.getStatuesFromDb(last.getId(), 7, list_id);
            // TODO add checking for old
            List<Long> readIds = obtainReadIds(newStatuses);
            sta.readIds.addAll(readIds);
            for (Status status : newStatuses) {
              if (!matchesFilter(status)) {
                sta.insert(status, totalCount + i);
                statuses.add(status);
                i++;
              }
            }
          }
          sta.notifyDataSetChanged();
        }
      }
      // Debug.stopMethodTracing();
    }
  }