mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-14 18:05:27 +07:00
KTNB-1022: Add extensive logging
GitOrigin-RevId: ad9a41abbf7dbaf54f48acc42bd6771de37e8bc9
This commit is contained in:
committed by
intellij-monorepo-bot
parent
96cefd06ec
commit
7375547ea9
@@ -7,9 +7,12 @@ import com.intellij.database.run.ui.FloatingPagingManager;
|
||||
import com.intellij.openapi.actionSystem.ActionPlaces;
|
||||
import com.intellij.openapi.actionSystem.ActionUpdateThread;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.DumbAwareAction;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import static com.intellij.database.datagrid.GridUtil.hidePageActions;
|
||||
|
||||
/**
|
||||
@@ -38,16 +41,6 @@ public abstract class PageAction extends DumbAwareAction implements GridAction {
|
||||
e.getPresentation().setVisible(isVisible(e, dataGrid) && (enabled || !ActionPlaces.EDITOR_POPUP.equals(e.getPlace())));
|
||||
}
|
||||
|
||||
protected static void additionalUpdateVisibilityCheck(@NotNull AnActionEvent e) {
|
||||
DataGrid dataGrid = e.getData(DatabaseDataKeys.DATA_GRID_KEY);
|
||||
if (dataGrid == null) return;
|
||||
GridPagingModel<GridRow, GridColumn> pageModel = dataGrid.getDataHookup().getPageModel();
|
||||
|
||||
if (pageModel.getPageSize() == GridPagingModel.UNLIMITED_PAGE_SIZE || (long)pageModel.getPageSize() >= pageModel.getTotalRowCount()) {
|
||||
e.getPresentation().setEnabledAndVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean isVisible(@NotNull AnActionEvent e, DataGrid dataGrid) {
|
||||
return !hidePageActions(dataGrid, e.getPlace());
|
||||
}
|
||||
@@ -82,16 +75,54 @@ public abstract class PageAction extends DumbAwareAction implements GridAction {
|
||||
loader.reloadCurrentPage(source);
|
||||
}
|
||||
}
|
||||
|
||||
public static class First extends PageAction {
|
||||
|
||||
|
||||
public static abstract class NavigationAction extends PageAction {
|
||||
private static final Logger LOG = Logger.getInstance(NavigationAction.class);
|
||||
|
||||
private static void traceIfEnabled(Supplier<String> messageSupplier) {
|
||||
if (LOG.isTraceEnabled()) {
|
||||
LOG.trace(messageSupplier.get());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(@NotNull AnActionEvent e) {
|
||||
traceIfEnabled(
|
||||
() -> "Updating " + this.getClass().getSimpleName() + ": " +
|
||||
"visible: " + e.getPresentation().isVisible() + ", " +
|
||||
"enabled: " + e.getPresentation().isEnabled() + ", ");
|
||||
super.update(e);
|
||||
traceIfEnabled(
|
||||
() -> "Updated " + this.getClass().getSimpleName() + " (super called): " +
|
||||
"visible: " + e.getPresentation().isVisible() + ", " +
|
||||
"enabled: " + e.getPresentation().isEnabled() + ", ");
|
||||
additionalUpdateVisibilityCheck(e);
|
||||
FloatingPagingManager.adjustAction(e);
|
||||
}
|
||||
|
||||
private static void additionalUpdateVisibilityCheck(@NotNull AnActionEvent e) {
|
||||
DataGrid dataGrid = e.getData(DatabaseDataKeys.DATA_GRID_KEY);
|
||||
if (dataGrid == null) return;
|
||||
GridPagingModel<GridRow, GridColumn> pageModel = dataGrid.getDataHookup().getPageModel();
|
||||
|
||||
final int pageSize = pageModel.getPageSize();
|
||||
traceIfEnabled(() -> "Page size: " + pageSize);
|
||||
|
||||
if (pageSize == GridPagingModel.UNLIMITED_PAGE_SIZE) {
|
||||
e.getPresentation().setEnabledAndVisible(false);
|
||||
return;
|
||||
}
|
||||
|
||||
final long totalRowCount = pageModel.getTotalRowCount();
|
||||
traceIfEnabled(() -> "Total rows: " + totalRowCount);
|
||||
if ((long)pageSize >= totalRowCount) {
|
||||
e.getPresentation().setEnabledAndVisible(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class First extends NavigationAction {
|
||||
|
||||
@Override
|
||||
protected boolean isEnabled(GridPagingModel<GridRow, GridColumn> pageModel) {
|
||||
return !pageModel.isFirstPage();
|
||||
@@ -103,14 +134,7 @@ public abstract class PageAction extends DumbAwareAction implements GridAction {
|
||||
}
|
||||
}
|
||||
|
||||
public static class Last extends PageAction {
|
||||
|
||||
@Override
|
||||
public void update(@NotNull AnActionEvent e) {
|
||||
super.update(e);
|
||||
additionalUpdateVisibilityCheck(e);
|
||||
FloatingPagingManager.adjustAction(e);
|
||||
}
|
||||
public static class Last extends NavigationAction {
|
||||
|
||||
@Override
|
||||
protected boolean isEnabled(GridPagingModel<GridRow, GridColumn> pageModel) {
|
||||
@@ -123,14 +147,7 @@ public abstract class PageAction extends DumbAwareAction implements GridAction {
|
||||
}
|
||||
}
|
||||
|
||||
public static class Next extends PageAction {
|
||||
|
||||
@Override
|
||||
public void update(@NotNull AnActionEvent e) {
|
||||
super.update(e);
|
||||
additionalUpdateVisibilityCheck(e);
|
||||
FloatingPagingManager.adjustAction(e);
|
||||
}
|
||||
public static class Next extends NavigationAction {
|
||||
|
||||
@Override
|
||||
protected boolean isEnabled(GridPagingModel<GridRow, GridColumn> pageModel) {
|
||||
@@ -143,14 +160,7 @@ public abstract class PageAction extends DumbAwareAction implements GridAction {
|
||||
}
|
||||
}
|
||||
|
||||
public static class Previous extends PageAction {
|
||||
|
||||
@Override
|
||||
public void update(@NotNull AnActionEvent e) {
|
||||
super.update(e);
|
||||
additionalUpdateVisibilityCheck(e);
|
||||
FloatingPagingManager.adjustAction(e);
|
||||
}
|
||||
public static class Previous extends NavigationAction {
|
||||
|
||||
@Override
|
||||
protected boolean isEnabled(GridPagingModel<GridRow, GridColumn> pageModel) {
|
||||
|
||||
Reference in New Issue
Block a user