private boolean isViewPagerContentViewToTop() {
    if (mNestedContentView == null) {
      regetNestedContentView();
    }

    if (mDirectNormalView != null) {
      return true;
    }

    if (ScrollingUtil.isScrollViewOrWebViewToTop(mNestedWebView)) {
      return true;
    }

    if (ScrollingUtil.isScrollViewOrWebViewToTop(mNestedScrollView)) {
      return true;
    }

    if (ScrollingUtil.isAbsListViewToTop(mNestedAbsListView)) {
      return true;
    }

    if (ScrollingUtil.isRecyclerViewToTop(mNestedRecyclerView)) {
      return true;
    }

    return false;
  }
Ejemplo n.º 2
0
  private boolean isContentViewToTop() {
    // 内容是普通控件,满足
    if (mNormalView != null) {
      return true;
    }

    if (ScrollingUtil.isScrollViewOrWebViewToTop(mWebView)) {
      return true;
    }

    if (ScrollingUtil.isScrollViewOrWebViewToTop(mScrollView)) {
      return true;
    }

    if (ScrollingUtil.isAbsListViewToTop(mAbsListView)) {
      return true;
    }

    if (ScrollingUtil.isRecyclerViewToTop(mRecyclerView)) {
      return true;
    }

    if (ScrollingUtil.isStickyNavLayoutToTop(mStickyNavLayout)) {
      return true;
    }

    return false;
  }
  public boolean isContentViewToTop() {
    if (mDirectNormalView != null) {
      return true;
    }

    if (ScrollingUtil.isScrollViewOrWebViewToTop(mDirectWebView)) {
      return true;
    }

    if (ScrollingUtil.isScrollViewOrWebViewToTop(mDirectScrollView)) {
      return true;
    }

    if (ScrollingUtil.isAbsListViewToTop(mDirectAbsListView)) {
      return true;
    }

    if (ScrollingUtil.isRecyclerViewToTop(mDirectRecyclerView)) {
      return true;
    }

    if (mDirectViewPager != null) {
      return isViewPagerContentViewToTop();
    }

    return false;
  }
Ejemplo n.º 4
0
  /**
   * 是否满足处理刷新的条件
   *
   * @return
   */
  private boolean shouldHandleLoadingMore() {
    if (mIsLoadingMore
        || mCurrentRefreshStatus == RefreshStatus.REFRESHING
        || mLoadMoreFooterView == null
        || mDelegate == null) {
      return false;
    }

    // 内容是普通控件,满足
    if (mNormalView != null) {
      return true;
    }

    if (ScrollingUtil.isWebViewToBottom(mWebView)) {
      return true;
    }

    if (ScrollingUtil.isScrollViewToBottom(mScrollView)) {
      return true;
    }

    if (mAbsListView != null) {
      return shouldHandleAbsListViewLoadingMore(mAbsListView);
    }

    if (mRecyclerView != null) {
      return shouldHandleRecyclerViewLoadingMore(mRecyclerView);
    }

    if (mStickyNavLayout != null) {
      return mStickyNavLayout.shouldHandleLoadingMore();
    }

    return false;
  }
Ejemplo n.º 5
0
  /** 显示上拉加载更多控件 */
  private void showLoadingMoreView() {
    mRefreshViewHolder.changeToLoadingMore();
    mLoadMoreFooterView.setVisibility(VISIBLE);

    ScrollingUtil.scrollToBottom(mScrollView);
    ScrollingUtil.scrollToBottom(mRecyclerView);
    ScrollingUtil.scrollToBottom(mAbsListView);
    if (mStickyNavLayout != null) {
      mStickyNavLayout.scrollToBottom();
    }
  }
  public boolean shouldHandleLoadingMore() {
    if (mRefreshLayout == null) {
      return false;
    }

    if (mDirectNormalView != null) {
      return true;
    }

    if (ScrollingUtil.isWebViewToBottom(mDirectWebView)) {
      return true;
    }

    if (ScrollingUtil.isScrollViewToBottom(mDirectScrollView)) {
      return true;
    }

    if (mDirectAbsListView != null) {
      return mRefreshLayout.shouldHandleAbsListViewLoadingMore(mDirectAbsListView);
    }

    if (mDirectRecyclerView != null) {
      return mRefreshLayout.shouldHandleRecyclerViewLoadingMore(mDirectRecyclerView);
    }

    if (mDirectViewPager != null) {
      if (mNestedContentView == null) {
        regetNestedContentView();
      }

      if (mNestedNormalView != null) {
        return true;
      }

      if (ScrollingUtil.isWebViewToBottom(mNestedWebView)) {
        return true;
      }

      if (ScrollingUtil.isScrollViewToBottom(mNestedScrollView)) {
        return true;
      }

      if (mNestedAbsListView != null) {
        return mRefreshLayout.shouldHandleAbsListViewLoadingMore(mNestedAbsListView);
      }

      if (mNestedRecyclerView != null) {
        return mRefreshLayout.shouldHandleRecyclerViewLoadingMore(mNestedRecyclerView);
      }
    }

    return false;
  }
    public Selection(@NotNull VcsLogGraphTable table) {
      myTable = table;
      List<Integer> selectedRows = ContainerUtil.sorted(toList(myTable.getSelectedRows()));
      Couple<Integer> visibleRows = ScrollingUtil.getVisibleRows(myTable);
      myScrollToTop = visibleRows.first - 1 == 0;

      VisibleGraph<Integer> graph = myTable.getVisibleGraph();

      mySelectedCommits = new TIntHashSet();

      Integer visibleSelectedCommit = null;
      Integer delta = null;
      for (int row : selectedRows) {
        if (row < graph.getVisibleCommitCount()) {
          Integer commit = graph.getRowInfo(row).getCommit();
          mySelectedCommits.add(commit);
          if (visibleRows.first - 1 <= row
              && row <= visibleRows.second
              && visibleSelectedCommit == null) {
            visibleSelectedCommit = commit;
            delta = myTable.getCellRect(row, 0, false).y - myTable.getVisibleRect().y;
          }
        }
      }
      if (visibleSelectedCommit == null && visibleRows.first - 1 >= 0) {
        visibleSelectedCommit = graph.getRowInfo(visibleRows.first - 1).getCommit();
        delta = myTable.getCellRect(visibleRows.first - 1, 0, false).y - myTable.getVisibleRect().y;
      }

      myVisibleSelectedCommit = visibleSelectedCommit;
      myDelta = delta;
    }
  public VcsLogGraphTable(
      @NotNull VcsLogUiImpl UI,
      @NotNull final VcsLogDataHolder logDataHolder,
      @NotNull VisiblePack initialDataPack) {
    super();
    myUI = UI;
    myLogDataHolder = logDataHolder;
    myGraphCommitCellRenderer = new GraphCommitCellRender(logDataHolder, myGraphCellPainter, this);

    setDefaultRenderer(VirtualFile.class, new RootCellRenderer(myUI));
    setDefaultRenderer(GraphCommitCell.class, myGraphCommitCellRenderer);
    setDefaultRenderer(String.class, new StringCellRenderer());

    setShowHorizontalLines(false);
    setIntercellSpacing(JBUI.emptySize());

    MouseAdapter mouseAdapter = new MyMouseAdapter();
    addMouseMotionListener(mouseAdapter);
    addMouseListener(mouseAdapter);
    MyHeaderMouseAdapter headerAdapter = new MyHeaderMouseAdapter();
    getTableHeader().addMouseListener(headerAdapter);
    getTableHeader().addMouseMotionListener(headerAdapter);

    getTableHeader().setReorderingAllowed(false);

    PopupHandler.installPopupHandler(
        this, VcsLogActionPlaces.POPUP_ACTION_GROUP, VcsLogActionPlaces.VCS_LOG_TABLE_PLACE);
    ScrollingUtil.installActions(this, false);

    GraphTableModel model = new GraphTableModel(initialDataPack, myLogDataHolder, myUI);
    setModel(model);
    initColumnSize();
  }
    @Override
    public Component getTableCellRendererComponent(
        JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
      String text;
      Color color;

      if (value instanceof VirtualFile) {
        VirtualFile root = (VirtualFile) value;
        int readableRow =
            ScrollingUtil.getReadableRow(table, Math.round(myUi.getTable().getRowHeight() * 0.5f));
        if (row < readableRow) {
          text = "";
        } else if (row == 0
            || !value.equals(table.getModel().getValueAt(row - 1, column))
            || readableRow == row) {
          text = root.getName();
        } else {
          text = "";
        }
        color = getRootBackgroundColor(root, myUi.getColorManager());
      } else {
        text = null;
        color = UIUtil.getTableBackground(isSelected);
      }

      myColor = color;
      Color background =
          ((VcsLogGraphTable) table)
              .getStyle(row, column, text, hasFocus, isSelected)
              .getBackground();
      assert background != null;
      myBorderColor = background;
      setForeground(UIUtil.getTableForeground(false));

      if (myUi.isShowRootNames()) {
        setText(text);
        isNarrow = false;
      } else {
        setText("");
        isNarrow = true;
      }

      return this;
    }
  public void scrollToBottom() {
    ScrollingUtil.scrollToBottom(mDirectScrollView);
    ScrollingUtil.scrollToBottom(mDirectRecyclerView);
    ScrollingUtil.scrollToBottom(mDirectAbsListView);

    if (mDirectViewPager != null) {
      if (mNestedContentView == null) {
        regetNestedContentView();
      }
      ScrollingUtil.scrollToBottom(mNestedScrollView);
      ScrollingUtil.scrollToBottom(mNestedRecyclerView);
      ScrollingUtil.scrollToBottom(mNestedAbsListView);
    }
  }
 public void setSelectedIndex(int index) {
   myList.setSelectedIndex(index);
   ScrollingUtil.ensureIndexIsVisible(myList, index, 0);
   updateViewerForSelection();
 }
  @Override
  protected JComponent createCenterPanel() {
    final int selectionMode =
        myAllowMultipleSelections
            ? ListSelectionModel.MULTIPLE_INTERVAL_SELECTION
            : ListSelectionModel.SINGLE_SELECTION;
    myList.setSelectionMode(selectionMode);
    if (myUseIdeaEditor) {
      EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
      myList.setFont(scheme.getFont(EditorFontType.PLAIN));
      Color fg =
          ObjectUtils.chooseNotNull(scheme.getDefaultForeground(), UIUtil.getListForeground());
      Color bg =
          ObjectUtils.chooseNotNull(scheme.getDefaultBackground(), UIUtil.getListBackground());
      myList.setForeground(fg);
      myList.setBackground(bg);
    }

    new DoubleClickListener() {
      @Override
      protected boolean onDoubleClick(MouseEvent e) {
        close(OK_EXIT_CODE);
        return true;
      }
    }.installOn(myList);

    myList.setCellRenderer(new MyListCellRenderer());
    myList.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_DELETE) {
              int newSelectionIndex = -1;
              for (Object o : myList.getSelectedValues()) {
                int i = ((Item) o).index;
                removeContentAt(myAllContents.get(i));
                if (newSelectionIndex < 0) {
                  newSelectionIndex = i;
                }
              }

              rebuildListContent();
              if (myAllContents.isEmpty()) {
                close(CANCEL_EXIT_CODE);
                return;
              }
              newSelectionIndex = Math.min(newSelectionIndex, myAllContents.size() - 1);
              myList.setSelectedIndex(newSelectionIndex);
            } else if (e.getKeyCode() == KeyEvent.VK_ENTER) {
              doOKAction();
            } else {
              final char aChar = e.getKeyChar();
              if (aChar >= '0' && aChar <= '9') {
                int idx = aChar == '0' ? 9 : aChar - '1';
                if (idx < myAllContents.size()) {
                  myList.setSelectedIndex(idx);
                  e.consume();
                  doOKAction();
                }
              }
            }
          }
        });

    mySplitter.setFirstComponent(
        ListWithFilter.wrap(
            myList,
            ScrollPaneFactory.createScrollPane(myList),
            new Function<Object, String>() {
              @Override
              public String fun(Object o) {
                return ((Item) o).longText;
              }
            }));
    mySplitter.setSecondComponent(new JPanel());
    rebuildListContent();

    ScrollingUtil.installActions(myList);
    ScrollingUtil.ensureSelectionExists(myList);
    updateViewerForSelection();
    myList.addListSelectionListener(
        new ListSelectionListener() {
          @Override
          public void valueChanged(ListSelectionEvent e) {
            myUpdateAlarm.cancelAllRequests();
            myUpdateAlarm.addRequest(
                new Runnable() {
                  @Override
                  public void run() {
                    updateViewerForSelection();
                  }
                },
                100);
          }
        });

    mySplitter.setPreferredSize(JBUI.size(500, 500));

    SplitterProportionsData d = new SplitterProportionsDataImpl();
    d.externalizeToDimensionService(getClass().getName());
    d.restoreSplitterProportions(mySplitter);

    return mySplitter;
  }