Browse Source

Pull request #15083: 无jira任务 优化使用

Merge in DESIGN/design from ~VITO/c-design:fbp/release to fbp/release

* commit '83cbfaa3f49a65140553169c2089706e7d111418':
  无jira任务 增加复用性
  无jira任务 优化使用
fbp/release
vito-刘恒霖 1 month ago
parent
commit
b48611a8ca
  1. 2
      designer-base/src/main/java/com/fine/theme/light/ui/FineTableHeaderUI.java
  2. 52
      designer-base/src/main/java/com/fr/design/remote/ui/debug/HeaderRenderer.java
  3. 6
      designer-base/src/main/java/com/fr/design/remote/ui/debug/RemoteDesignNetWorkAction.java
  4. 5
      designer-base/src/main/java/com/fr/design/remote/ui/debug/RemoteDesignNetWorkHelper.java
  5. 5
      designer-base/src/main/java/com/fr/design/remote/ui/debug/RemoteDesignNetWorkTablePane.java
  6. 1
      designer-base/src/main/java/com/fr/design/remote/ui/debug/RemoteDesignNetWorkTableRowSorter.java
  7. 37
      designer-base/src/main/java/com/fr/design/remote/ui/debug/SizeColorCellRenderer.java
  8. 38
      designer-base/src/main/java/com/fr/design/remote/ui/debug/TimeColorCellRenderer.java

2
designer-base/src/main/java/com/fine/theme/light/ui/FineTableHeaderUI.java

@ -101,9 +101,9 @@ public class FineTableHeaderUI extends FlatTableHeaderUI {
selectionBackground = UIManager.getColor("Table.background"); selectionBackground = UIManager.getColor("Table.background");
} }
setBackground(selectionBackground); setBackground(selectionBackground);
setText(value == null ? StringUtils.BLANK : String.valueOf(value));
setToolTipText(table, value, column); setToolTipText(table, value, column);
setBorder(border); setBorder(border);
setValue(value);
return this; return this;
} }

52
designer-base/src/main/java/com/fr/design/remote/ui/debug/HeaderRenderer.java

@ -0,0 +1,52 @@
package com.fr.design.remote.ui.debug;
import com.fine.theme.icon.LazyIcon;
import com.fine.theme.light.ui.FineTableHeaderUI;
import javax.swing.Icon;
import javax.swing.JTable;
import javax.swing.RowSorter;
import javax.swing.SortOrder;
import java.awt.Component;
/**
* 远程调试界面表头
*
* @author vito
* @since 11.0
* Created on 2024/10/17
*/
public class HeaderRenderer extends FineTableHeaderUI.TableHeaderRenderer {
private final Icon ascendingIcon = new LazyIcon("sort_asc");
private final Icon descendingIcon = new LazyIcon("sort_desc");
private final Icon nosortIcon = new LazyIcon("nosort");
@Override
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus,
int row, int col) {
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, col);
int modelColumn = table.convertColumnIndexToModel(col);
setIcon(null);
RemoteDesignNetWorkTableRowSorter sorter = (RemoteDesignNetWorkTableRowSorter) table.getRowSorter();
if (!sorter.isSortable(modelColumn)) {
return this;
}
SortOrder sortOrder = sorter.getSortKeys().stream()
.filter(key -> key.getColumn() == modelColumn)
.map(RowSorter.SortKey::getSortOrder)
.findFirst()
.orElse(null);
if (sortOrder == SortOrder.ASCENDING) {
setIcon(ascendingIcon);
} else if (sortOrder == SortOrder.DESCENDING) {
setIcon(descendingIcon);
} else {
setIcon(nosortIcon);
}
return this;
}
}

6
designer-base/src/main/java/com/fr/design/remote/ui/debug/RemoteDesignNetWorkAction.java

@ -8,13 +8,16 @@ import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import javax.swing.JDialog; import javax.swing.JDialog;
import javax.swing.KeyStroke;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter; import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent; import java.awt.event.WindowEvent;
import static com.fine.theme.utils.FineUIScale.createScaleDimension; import static com.fine.theme.utils.FineUIScale.createScaleDimension;
import static com.fine.theme.utils.FineUIScale.unscale; import static com.fine.theme.utils.FineUIScale.unscale;
import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER;
/** /**
* 远程设计网络调试 * 远程设计网络调试
@ -27,7 +30,8 @@ public class RemoteDesignNetWorkAction extends UpdateAction {
public static final String TITLE = "Remote Design NetWork"; public static final String TITLE = "Remote Design NetWork";
public RemoteDesignNetWorkAction() { public RemoteDesignNetWorkAction() {
setName(TITLE); this.setName(TITLE);
this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, DEFAULT_MODIFIER));
} }
@Override @Override

5
designer-base/src/main/java/com/fr/design/remote/ui/debug/RemoteDesignNetWorkHelper.java

@ -2,6 +2,8 @@ package com.fr.design.remote.ui.debug;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javax.swing.UIManager;
import java.awt.Color;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
@ -14,6 +16,9 @@ import java.util.Date;
* Created on 2024/10/11 * Created on 2024/10/11
*/ */
public class RemoteDesignNetWorkHelper { public class RemoteDesignNetWorkHelper {
static final Color DEFAULT_COLOR = UIManager.getColor("Table.foreground");
private static final int UNIT = 1000; private static final int UNIT = 1000;
private static final int UNIT_BYTES = 1024; private static final int UNIT_BYTES = 1024;
private static final String SECOND = "s"; private static final String SECOND = "s";

5
designer-base/src/main/java/com/fr/design/remote/ui/debug/RemoteDesignNetWorkTablePane.java

@ -86,7 +86,11 @@ public class RemoteDesignNetWorkTablePane extends JPanel {
model.addColumn("request"); model.addColumn("request");
model.addColumn("response"); model.addColumn("response");
uiTable = new JTable(model); uiTable = new JTable(model);
uiTable.getColumnModel().getColumn(4).setCellRenderer(new TimeColorCellRenderer());
uiTable.getColumnModel().getColumn(5).setCellRenderer(new SizeColorCellRenderer());
uiTable.getColumnModel().getColumn(6).setCellRenderer(new SizeColorCellRenderer());
uiTable.setRowSorter(new RemoteDesignNetWorkTableRowSorter(model)); uiTable.setRowSorter(new RemoteDesignNetWorkTableRowSorter(model));
uiTable.getTableHeader().setDefaultRenderer(new HeaderRenderer());
add(new JScrollPane(uiTable), BorderLayout.CENTER); add(new JScrollPane(uiTable), BorderLayout.CENTER);
} }
@ -155,5 +159,4 @@ public class RemoteDesignNetWorkTablePane extends JPanel {
} }
} }
} }

1
designer-base/src/main/java/com/fr/design/remote/ui/debug/RemoteDesignNetWorkTableRowSorter.java

@ -19,6 +19,7 @@ public class RemoteDesignNetWorkTableRowSorter extends TableRowSorter<DefaultTab
setComparator(4, Comparator.comparingLong(RemoteDesignNetWorkHelper::parseCostToMS)); setComparator(4, Comparator.comparingLong(RemoteDesignNetWorkHelper::parseCostToMS));
setComparator(5, Comparator.comparingLong(RemoteDesignNetWorkHelper::parseSizeToBytes)); setComparator(5, Comparator.comparingLong(RemoteDesignNetWorkHelper::parseSizeToBytes));
setComparator(6, Comparator.comparingLong(RemoteDesignNetWorkHelper::parseSizeToBytes)); setComparator(6, Comparator.comparingLong(RemoteDesignNetWorkHelper::parseSizeToBytes));
setMaxSortKeys(1);
} }
@Override @Override

37
designer-base/src/main/java/com/fr/design/remote/ui/debug/SizeColorCellRenderer.java

@ -0,0 +1,37 @@
package com.fr.design.remote.ui.debug;
import com.fine.theme.light.ui.FineTableHeaderUI;
import java.awt.Color;
import static com.fr.design.remote.ui.debug.RemoteDesignNetWorkHelper.DEFAULT_COLOR;
/**
* 大小多颜色渲染
*
* @author vito
* @since 11.0
* Created on 2024/10/16
*/
public class SizeColorCellRenderer extends FineTableHeaderUI.TableRenderer {
private static final int UNIT_BYTES = 1024;
private static final int SIZE_MIDDLE = UNIT_BYTES * 100;
private static final int SIZE_LARGE = UNIT_BYTES * 200;
@Override
protected void setValue(Object value) {
if (value instanceof String) {
long parsed = RemoteDesignNetWorkHelper.parseSizeToBytes((String) value);
if (parsed > SIZE_LARGE) {
setForeground(Color.RED);
} else if (parsed > SIZE_MIDDLE) {
setForeground(Color.ORANGE);
} else {
setForeground(DEFAULT_COLOR);
}
}
setText((value == null) ? "" : value.toString());
}
}

38
designer-base/src/main/java/com/fr/design/remote/ui/debug/TimeColorCellRenderer.java

@ -0,0 +1,38 @@
package com.fr.design.remote.ui.debug;
import com.fine.theme.light.ui.FineTableHeaderUI;
import java.awt.Color;
import static com.fr.design.remote.ui.debug.RemoteDesignNetWorkHelper.DEFAULT_COLOR;
/**
* 时间多颜色渲染
*
* @author vito
* @since 11.0
* Created on 2024/10/16
*/
public class TimeColorCellRenderer extends FineTableHeaderUI.TableRenderer {
private static final int SIZE_MIDDLE = 1000;
private static final int SIZE_LARGE = 5000;
@Override
protected void setValue(Object value) {
if (value instanceof String) {
long parsed = RemoteDesignNetWorkHelper.parseCostToMS((String) value);
if (parsed > SIZE_LARGE) {
setForeground(Color.RED);
} else if (parsed > SIZE_MIDDLE) {
setForeground(Color.ORANGE);
} else {
setForeground(DEFAULT_COLOR);
}
}
setText((value == null) ? "" : value.toString());
}
}
Loading…
Cancel
Save