Browse Source

Add logging to CellHintPopupListener

pull/229/head
weisj 4 years ago
parent
commit
7c209ef6fb
  1. 8
      core/src/main/java/com/github/weisj/darklaf/ui/cell/hint/CellHintPopupListener.java

8
core/src/main/java/com/github/weisj/darklaf/ui/cell/hint/CellHintPopupListener.java

@ -24,6 +24,7 @@ package com.github.weisj.darklaf.ui.cell.hint;
import java.awt.*; import java.awt.*;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.util.Objects; import java.util.Objects;
import java.util.logging.Logger;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.Border; import javax.swing.border.Border;
@ -32,10 +33,13 @@ import javax.swing.event.MouseInputAdapter;
import com.github.weisj.darklaf.graphics.PaintUtil; import com.github.weisj.darklaf.graphics.PaintUtil;
import com.github.weisj.darklaf.ui.DarkPopupFactory; import com.github.weisj.darklaf.ui.DarkPopupFactory;
import com.github.weisj.darklaf.util.DarkUIUtil; import com.github.weisj.darklaf.util.DarkUIUtil;
import com.github.weisj.darklaf.util.LogUtil;
import com.github.weisj.darklaf.util.WindowUtil; import com.github.weisj.darklaf.util.WindowUtil;
public class CellHintPopupListener<T extends JComponent, I> extends MouseInputAdapter { public class CellHintPopupListener<T extends JComponent, I> extends MouseInputAdapter {
private static final Logger LOGGER = LogUtil.getLogger(CellHintPopupListener.class);
private final IndexedCellContainer<T, I> cellContainer; private final IndexedCellContainer<T, I> cellContainer;
private final PopupComponent popupComponent; private final PopupComponent popupComponent;
private I lastIndex; private I lastIndex;
@ -92,10 +96,12 @@ public class CellHintPopupListener<T extends JComponent, I> extends MouseInputAd
final Rectangle cellBounds = cellContainer.getCellBoundsAt(index, isEditing); final Rectangle cellBounds = cellContainer.getCellBoundsAt(index, isEditing);
if (cellBounds != null && allocation != null) { if (cellBounds != null && allocation != null) {
final Rectangle visibleBounds = allocation.intersection(cellBounds); final Rectangle visibleBounds = allocation.intersection(cellBounds);
LOGGER.fine(() -> "Visible bounds at index " + index + ": " + visibleBounds);
if (visibleBounds.contains(p)) { if (visibleBounds.contains(p)) {
if (isPopupNeeded(index, isEditing, visibleBounds)) { if (isPopupNeeded(index, isEditing, visibleBounds)) {
Point popupLocation = cellContainer.getComponent().getLocationOnScreen(); Point popupLocation = cellContainer.getComponent().getLocationOnScreen();
Rectangle popupBounds = calculatePopupBounds(cellBounds, visibleBounds, !isEditing); Rectangle popupBounds = calculatePopupBounds(cellBounds, visibleBounds, !isEditing);
LOGGER.fine(() -> "Popup bounds at index " + index + ": " + popupBounds);
if (!visibleBounds.contains(popupBounds)) { if (!visibleBounds.contains(popupBounds)) {
cellBounds.x = popupBounds.x - cellBounds.x; cellBounds.x = popupBounds.x - cellBounds.x;
cellBounds.y = popupBounds.y - cellBounds.y; cellBounds.y = popupBounds.y - cellBounds.y;
@ -120,6 +126,7 @@ public class CellHintPopupListener<T extends JComponent, I> extends MouseInputAd
private boolean isPopupNeeded(final I index, final boolean isEditing, final Rectangle visibleBounds) { private boolean isPopupNeeded(final I index, final boolean isEditing, final Rectangle visibleBounds) {
final Component comp = cellContainer.getEffectiveCellRendererComponent(index, isEditing); final Component comp = cellContainer.getEffectiveCellRendererComponent(index, isEditing);
final Dimension prefSize = getPreferredSize(isEditing, comp); final Dimension prefSize = getPreferredSize(isEditing, comp);
LOGGER.fine(() -> "Necessary cell size at index " + index + ": " + prefSize);
return !fitsInside(prefSize, visibleBounds); return !fitsInside(prefSize, visibleBounds);
} }
@ -237,6 +244,7 @@ public class CellHintPopupListener<T extends JComponent, I> extends MouseInputAd
} }
private void enter(final I index, final Rectangle bounds, final Rectangle rendererBounds) { private void enter(final I index, final Rectangle bounds, final Rectangle rendererBounds) {
LOGGER.fine("Showing cell popup at index " + index);
if (index != null) { if (index != null) {
lastIndex = index; lastIndex = index;
popupComponent.setPreferredSize(bounds.getSize()); popupComponent.setPreferredSize(bounds.getSize());

Loading…
Cancel
Save