# Conflicts: # designer-base/src/main/resources/com/fr/design/data/tabledata/datacenter/web/data-choose.main.jsfbp/master
@ -1,62 +0,0 @@ |
|||||||
package com.fr.design.cache; |
|
||||||
|
|
||||||
import com.fr.base.TableData; |
|
||||||
import com.fr.design.data.tabledata.wrapper.TableDataFactory; |
|
||||||
|
|
||||||
import java.util.Map; |
|
||||||
|
|
||||||
/** |
|
||||||
* 设计器缓存管理 |
|
||||||
* |
|
||||||
* @author Destiny.Lin |
|
||||||
* @since 11.0 |
|
||||||
* Created on 2024/8/11 |
|
||||||
*/ |
|
||||||
public class DesignCacheManager { |
|
||||||
|
|
||||||
public static ThreadLocal<Map<String, TableData>> cacheTableData = new ThreadLocal<>(); |
|
||||||
|
|
||||||
/** |
|
||||||
* 处理任务(使用数据集缓存) |
|
||||||
*/ |
|
||||||
public static void processByCacheTableData(Task task) { |
|
||||||
try { |
|
||||||
cacheTableData.set(TableDataFactory.getTableDatas()); |
|
||||||
task.process(); |
|
||||||
} finally { |
|
||||||
cacheTableData.remove(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
/** |
|
||||||
* 是否使用数据集的缓存 |
|
||||||
*/ |
|
||||||
public static boolean useDataCache() { |
|
||||||
return cacheTableData.get() != null; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 获取数据集缓存 |
|
||||||
*/ |
|
||||||
public static ThreadLocal<Map<String, TableData>> getCacheTableData() { |
|
||||||
return cacheTableData; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 设置数据集缓存 |
|
||||||
*/ |
|
||||||
public static void setCacheTableData(ThreadLocal<Map<String, TableData>> cacheTableData) { |
|
||||||
DesignCacheManager.cacheTableData = cacheTableData; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 任务 |
|
||||||
*/ |
|
||||||
public interface Task { |
|
||||||
/** |
|
||||||
* 处理 |
|
||||||
*/ |
|
||||||
void process(); |
|
||||||
} |
|
||||||
} |
|
@ -0,0 +1,145 @@ |
|||||||
|
package com.fr.design.dialog; |
||||||
|
|
||||||
|
import com.fine.theme.icon.LazyIcon; |
||||||
|
import com.fine.theme.utils.FineUIScale; |
||||||
|
import com.fine.theme.utils.FineUIStyle; |
||||||
|
import com.formdev.flatlaf.ui.FlatUIUtils; |
||||||
|
import com.formdev.flatlaf.util.ScaledEmptyBorder; |
||||||
|
import com.fr.design.constants.LayoutConstants; |
||||||
|
import com.fr.design.gui.ibutton.UIButton; |
||||||
|
import com.fr.design.gui.ilable.UILabel; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
import com.fr.design.utils.gui.GUICoreUtils; |
||||||
|
import java.awt.*; |
||||||
|
import java.awt.event.ActionEvent; |
||||||
|
import java.awt.event.ActionListener; |
||||||
|
import java.awt.event.MouseAdapter; |
||||||
|
import java.awt.event.MouseEvent; |
||||||
|
import javax.swing.JPanel; |
||||||
|
import javax.swing.JDialog; |
||||||
|
import javax.swing.JScrollPane; |
||||||
|
import javax.swing.JTextArea; |
||||||
|
|
||||||
|
|
||||||
|
import static com.fine.swing.ui.layout.Layouts.cell; |
||||||
|
import static com.fine.swing.ui.layout.Layouts.row; |
||||||
|
import static com.fine.swing.ui.layout.Layouts.column; |
||||||
|
import static com.fine.swing.ui.layout.Layouts.flex; |
||||||
|
import static com.fine.swing.ui.layout.Layouts.fix; |
||||||
|
|
||||||
|
/** |
||||||
|
* 折叠弹窗 |
||||||
|
* |
||||||
|
* @author Richard |
||||||
|
* @since 11.0 |
||||||
|
* Created on 2024/10/22 |
||||||
|
*/ |
||||||
|
public class CollapsibleDetailDialog extends JDialog implements ActionListener { |
||||||
|
|
||||||
|
public JPanel upInTopPanel; |
||||||
|
private JPanel downInTopPanel; |
||||||
|
private JPanel topPanel; |
||||||
|
public JPanel hiddenPanel; |
||||||
|
private JPanel bottomPanel; |
||||||
|
private UILabel directUILabel; |
||||||
|
private UILabel detailLabel; |
||||||
|
// 内容标题
|
||||||
|
private final UILabel messageLabel; |
||||||
|
// 详情
|
||||||
|
private final String detailText; |
||||||
|
private final Dimension collapseDimension = FineUIScale.createScaleDimension(450, 185); |
||||||
|
private final Dimension unfoldDimension = FineUIScale.createScaleDimension(450, 280); |
||||||
|
|
||||||
|
public CollapsibleDetailDialog(Frame parent, UILabel label, String detailText) { |
||||||
|
super(parent, true); |
||||||
|
this.detailText = detailText; |
||||||
|
this.messageLabel = label; |
||||||
|
initComponent(); |
||||||
|
} |
||||||
|
|
||||||
|
private void initComponent() { |
||||||
|
initTopPanel(); |
||||||
|
initHiddenPanel(); |
||||||
|
initBottomPanel(); |
||||||
|
addListeners(); |
||||||
|
this.setResizable(false); |
||||||
|
this.add(topPanel, BorderLayout.NORTH); |
||||||
|
this.add(hiddenPanel, BorderLayout.CENTER); |
||||||
|
this.add(bottomPanel, BorderLayout.SOUTH); |
||||||
|
this.setSize(this.collapseDimension); |
||||||
|
GUICoreUtils.centerWindow(this); |
||||||
|
this.setAlwaysOnTop(true); |
||||||
|
} |
||||||
|
|
||||||
|
private void initTopPanel() { |
||||||
|
initUpInTopPanel(); |
||||||
|
// 查看详情按钮
|
||||||
|
directUILabel = new UILabel(); |
||||||
|
directUILabel.setIcon(new LazyIcon("plus")); |
||||||
|
detailLabel = new UILabel(); |
||||||
|
detailLabel.setText(com.fr.design.i18n.Toolkit.i18nText("Fine_Designer_Look_Detail")); |
||||||
|
downInTopPanel = row(fix(30), row(cell(directUILabel), cell(detailLabel), flex())).getComponent(); |
||||||
|
topPanel = column(cell(upInTopPanel), cell(downInTopPanel)).getComponent(); |
||||||
|
} |
||||||
|
|
||||||
|
private void initUpInTopPanel() { |
||||||
|
upInTopPanel = row(LayoutConstants.HORIZONTAL_GAP, |
||||||
|
column(cell(new UILabel(new LazyIcon("error", 20))), flex()), |
||||||
|
column(cell(messageLabel))).getComponent(); |
||||||
|
upInTopPanel.setBorder(new ScaledEmptyBorder(10, 10, 10, 10)); |
||||||
|
} |
||||||
|
|
||||||
|
private void initHiddenPanel() { |
||||||
|
hiddenPanel = FRGUIPaneFactory.createBorderLayout_L_Pane(); |
||||||
|
JScrollPane scrollPane = new JScrollPane(); |
||||||
|
JTextArea textArea = new JTextArea(detailText); |
||||||
|
scrollPane.setViewportView(textArea); |
||||||
|
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); |
||||||
|
scrollPane.setBackground(FlatUIUtils.getUIColor("background.normal", Color.WHITE)); |
||||||
|
scrollPane.getViewport().setOpaque(false); |
||||||
|
textArea.setOpaque(false); |
||||||
|
textArea.setEditable(false); |
||||||
|
hiddenPanel = row(fix(30), cell(scrollPane).weight(1)).getComponent(); |
||||||
|
hiddenPanel.setVisible(false); |
||||||
|
hiddenPanel.setBorder(new ScaledEmptyBorder(0, 0, 0, 10)); |
||||||
|
} |
||||||
|
|
||||||
|
private void initBottomPanel() { |
||||||
|
//底部的按钮面板
|
||||||
|
UIButton okButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_OK")); |
||||||
|
FineUIStyle.setStyle(okButton, FineUIStyle.STYLE_PRIMARY); |
||||||
|
okButton.addActionListener(this); |
||||||
|
bottomPanel = FRGUIPaneFactory.createBorderLayout_L_Pane(); |
||||||
|
bottomPanel.setBorder(new ScaledEmptyBorder(10, 10, 10, 10)); |
||||||
|
bottomPanel.add(okButton, BorderLayout.EAST); |
||||||
|
} |
||||||
|
|
||||||
|
private void addListeners() { |
||||||
|
downInTopPanel.addMouseListener(new MouseAdapter() { |
||||||
|
@Override |
||||||
|
public void mouseClicked(MouseEvent e) { |
||||||
|
toggleHiddenPanel(); |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
private void toggleHiddenPanel() { |
||||||
|
if (hiddenPanel.isVisible()) { |
||||||
|
hiddenPanel.setVisible(false); |
||||||
|
setSize(collapseDimension); |
||||||
|
detailLabel.setText(Toolkit.i18nText("Fine_Designer_Look_Detail")); |
||||||
|
directUILabel.setIcon(new LazyIcon("plus")); |
||||||
|
} else { |
||||||
|
setSize(unfoldDimension); |
||||||
|
hiddenPanel.setVisible(true); |
||||||
|
detailLabel.setText(Toolkit.i18nText("Fine_Designer_Hide_Detail")); |
||||||
|
directUILabel.setIcon(new LazyIcon("minus")); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void actionPerformed(ActionEvent e) { |
||||||
|
this.dispose(); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,44 @@ |
|||||||
|
package com.fr.design.gui.core; |
||||||
|
|
||||||
|
import javax.swing.JPanel; |
||||||
|
import java.awt.CardLayout; |
||||||
|
import java.awt.Component; |
||||||
|
import java.awt.Dimension; |
||||||
|
|
||||||
|
/** |
||||||
|
* 自适应尺寸大小变更的Card面板 |
||||||
|
* |
||||||
|
* @author Levy.Xie |
||||||
|
* @since 11.0 |
||||||
|
* Created on 2024/10/22 |
||||||
|
*/ |
||||||
|
public class SimpleCardPane extends JPanel { |
||||||
|
|
||||||
|
private final CardLayout cardLayout; |
||||||
|
|
||||||
|
public SimpleCardPane() { |
||||||
|
cardLayout = new CardLayout(); |
||||||
|
setLayout(cardLayout); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 显示卡片 |
||||||
|
* @param key 卡片名 |
||||||
|
*/ |
||||||
|
public void show(String key) { |
||||||
|
setVisible(true); |
||||||
|
cardLayout.show(this, key); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Dimension getPreferredSize() { |
||||||
|
for (Component comp : getComponents()) { |
||||||
|
if (comp.isVisible()) { |
||||||
|
return comp.getPreferredSize(); |
||||||
|
} |
||||||
|
} |
||||||
|
setVisible(false); |
||||||
|
return new Dimension(0, 0); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -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; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,88 @@ |
|||||||
|
package com.fr.design.remote.ui.debug; |
||||||
|
|
||||||
|
import com.fr.stable.StringUtils; |
||||||
|
|
||||||
|
import javax.swing.UIManager; |
||||||
|
import java.awt.Color; |
||||||
|
import java.text.DecimalFormat; |
||||||
|
import java.text.SimpleDateFormat; |
||||||
|
import java.util.Date; |
||||||
|
|
||||||
|
/** |
||||||
|
* 帮助类 |
||||||
|
* |
||||||
|
* @author vito |
||||||
|
* @since 11.0 |
||||||
|
* Created on 2024/10/11 |
||||||
|
*/ |
||||||
|
public class RemoteDesignNetWorkHelper { |
||||||
|
|
||||||
|
static final Color DEFAULT_COLOR = UIManager.getColor("Table.foreground"); |
||||||
|
|
||||||
|
private static final int UNIT = 1000; |
||||||
|
private static final int UNIT_BYTES = 1024; |
||||||
|
private static final String SECOND = "s"; |
||||||
|
private static final int K = 1024; |
||||||
|
private static final int MS = 1000; |
||||||
|
|
||||||
|
static String dateFormat(Date date) { |
||||||
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); |
||||||
|
return dateFormat.format(date); |
||||||
|
} |
||||||
|
|
||||||
|
static String simpleTime(long time) { |
||||||
|
if (time < 0) { |
||||||
|
return time + ""; |
||||||
|
} else if (time < MS) { |
||||||
|
return time + " ms"; |
||||||
|
} else { |
||||||
|
DecimalFormat df = new DecimalFormat("#.0"); |
||||||
|
return df.format((float) time / MS) + " s"; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
static String simpleSize(long bytes) { |
||||||
|
if (bytes < 0) { |
||||||
|
return bytes + ""; |
||||||
|
} else if (bytes < K) { |
||||||
|
return bytes + " B"; |
||||||
|
} else { |
||||||
|
DecimalFormat df = new DecimalFormat("#.00"); |
||||||
|
return df.format((float) bytes / K) + " K"; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
static long parseCostToMS(String timeStr) { |
||||||
|
String[] split = timeStr.split(" "); |
||||||
|
if (split.length > 1) { |
||||||
|
double number = Double.parseDouble(split[0]); |
||||||
|
String unit = split[1].toLowerCase(); |
||||||
|
|
||||||
|
if (StringUtils.equals(unit, SECOND)) { |
||||||
|
return (long) (number * UNIT); |
||||||
|
} |
||||||
|
return (long) number; |
||||||
|
} |
||||||
|
return 0; |
||||||
|
} |
||||||
|
|
||||||
|
static long parseSizeToBytes(String sizeStr) { |
||||||
|
String[] split = sizeStr.split(" "); |
||||||
|
if (split.length > 1) { |
||||||
|
double number = Double.parseDouble(split[0]); |
||||||
|
String unit = split[1].toUpperCase(); |
||||||
|
|
||||||
|
switch (unit) { |
||||||
|
case "K": |
||||||
|
return (long) (number * UNIT_BYTES); |
||||||
|
case "M": |
||||||
|
return (long) (number * UNIT_BYTES * UNIT_BYTES); |
||||||
|
case "G": |
||||||
|
return (long) (number * UNIT_BYTES * UNIT_BYTES * UNIT_BYTES); |
||||||
|
default: |
||||||
|
return (long) number; |
||||||
|
} |
||||||
|
} |
||||||
|
return 0; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,33 @@ |
|||||||
|
package com.fr.design.remote.ui.debug; |
||||||
|
|
||||||
|
import javax.swing.table.DefaultTableModel; |
||||||
|
import javax.swing.table.TableRowSorter; |
||||||
|
import java.util.Comparator; |
||||||
|
|
||||||
|
/** |
||||||
|
* 行排序器 |
||||||
|
* |
||||||
|
* @author vito |
||||||
|
* @since 11.0 |
||||||
|
* Created on 2024/10/11 |
||||||
|
*/ |
||||||
|
public class RemoteDesignNetWorkTableRowSorter extends TableRowSorter<DefaultTableModel> { |
||||||
|
|
||||||
|
public RemoteDesignNetWorkTableRowSorter(DefaultTableModel model) { |
||||||
|
super(model); |
||||||
|
setComparator(0, (Comparator<Long>) Long::compareTo); |
||||||
|
setComparator(4, Comparator.comparingLong(RemoteDesignNetWorkHelper::parseCostToMS)); |
||||||
|
setComparator(5, Comparator.comparingLong(RemoteDesignNetWorkHelper::parseSizeToBytes)); |
||||||
|
setComparator(6, Comparator.comparingLong(RemoteDesignNetWorkHelper::parseSizeToBytes)); |
||||||
|
setMaxSortKeys(1); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean isSortable(int column) { |
||||||
|
return column == 0 |
||||||
|
|| column == 4 |
||||||
|
|| column == 5 |
||||||
|
|| column == 6; |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -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()); |
||||||
|
} |
||||||
|
} |
@ -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()); |
||||||
|
} |
||||||
|
} |
After Width: | Height: | Size: 437 B |
After Width: | Height: | Size: 418 B |
After Width: | Height: | Size: 426 B |
After Width: | Height: | Size: 426 B |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 574 B |
After Width: | Height: | Size: 417 B |
After Width: | Height: | Size: 398 B |
After Width: | Height: | Size: 428 B |
After Width: | Height: | Size: 409 B |
After Width: | Height: | Size: 422 B |
After Width: | Height: | Size: 400 B |
After Width: | Height: | Size: 417 B |
After Width: | Height: | Size: 417 B |
After Width: | Height: | Size: 619 B |
After Width: | Height: | Size: 567 B |
After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 817 B After Width: | Height: | Size: 593 B |
Before Width: | Height: | Size: 818 B After Width: | Height: | Size: 594 B |
Before Width: | Height: | Size: 349 B |