Browse Source

REPORT-127437 fix: table UI 调整

newui
lemon 5 months ago
parent
commit
ae244f874e
  1. 6
      designer-base/src/main/java/com/fine/theme/light/ui/FineTableHeaderUI.java
  2. 12
      designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java
  3. 30
      designer-base/src/main/java/com/fr/design/gui/iscrollbar/UIVerticalScrollBar.java
  4. 11
      designer-base/src/main/java/com/fr/design/gui/itable/SortableJTable.java
  5. 31
      designer-base/src/main/java/com/fr/design/gui/itableeditorpane/UITableEditorPane.java
  6. 3
      designer-base/src/main/java/com/fr/design/report/SelectImagePane.java
  7. 7
      designer-base/src/main/java/com/fr/design/write/submit/DBManipulationPane.java
  8. 2
      designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLaf.properties
  9. 15
      designer-base/src/test/java/com/fr/design/gui/storybook/components/TableStoryBoard.java
  10. 19
      designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditorPane.java
  11. 22
      designer-realize/src/main/java/com/fr/design/cell/smartaction/SmartJTablePane.java

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

@ -34,13 +34,15 @@ public class FineTableHeaderUI extends FlatTableHeaderUI {
header.setDefaultRenderer(new TableHeaderRenderer());
JTable table = header.getTable();
FineUIStyle.setStyle(table, FineUIStyle.DEFAULT_TABLE);
table.getTableHeader().getTable().setDefaultRenderer(Object.class, new TableRenderer());
if (table != null) {
table.setDefaultRenderer(Object.class, new TableRenderer());
}
}
@Override
public void paint(Graphics g, JComponent c) {
FineUIStyle.setStyle(((JTableHeader) c).getTable(), FineUIStyle.DEFAULT_TABLE);
super.paint(g, c);
}

12
designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java

@ -5,7 +5,6 @@ package com.fr.design.data.datapane.preview;
import com.fine.theme.icon.LazyIcon;
import com.fine.theme.light.ui.FineTableHeaderUI;
import com.fine.theme.light.ui.FineTableScrollBarPaneUI;
import com.fine.theme.utils.FineUIScale;
import com.fine.theme.utils.FineUIStyle;
import com.fine.theme.utils.FineUIUtils;
@ -31,6 +30,8 @@ import com.fr.design.gui.frpane.UITabbedPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.iprogressbar.AutoProgressBar;
import com.fr.design.gui.iscrollbar.UIScrollBar;
import com.fr.design.gui.iscrollbar.UIVerticalScrollBar;
import com.fr.design.gui.itable.SortableJTable;
import com.fr.design.gui.itable.TableSorter;
import com.fr.design.gui.itextfield.UINumberField;
@ -51,6 +52,7 @@ import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollBar;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
@ -305,8 +307,12 @@ public class PreviewTablePane extends BasicPane {
preveiwTable = new CopyableJTable(new TableSorter());
preveiwTable.setRowSelectionAllowed(false);
preveiwTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
JScrollPane scrollPane = new JScrollPane(preveiwTable);
scrollPane.getVerticalScrollBar().setUI(new FineTableScrollBarPaneUI(preveiwTable));
JScrollPane scrollPane = new JScrollPane(preveiwTable) {
@Override
public UIScrollBar createVerticalScrollBar() {
return new UIVerticalScrollBar(preveiwTable, JScrollBar.VERTICAL);
}
};
return scrollPane;
}

30
designer-base/src/main/java/com/fr/design/gui/iscrollbar/UIVerticalScrollBar.java

@ -0,0 +1,30 @@
package com.fr.design.gui.iscrollbar;
import com.fine.theme.light.ui.FineTableScrollBarPaneUI;
import javax.swing.JTable;
/**
* jtable 垂直滚动条
*
* @author lemon
* @since
* Created on
*/
public class UIVerticalScrollBar extends UIScrollBar {
private static final String UI_CLASS_ID = "TableScrollBarUI";
private static final long serialVersionUID = 1L;
public UIVerticalScrollBar() {
}
public UIVerticalScrollBar(JTable table, int orientation) {
super(orientation);
this.setUI(new FineTableScrollBarPaneUI(table));
}
@Override
public String getUIClassID() {
return UI_CLASS_ID;
}
}

11
designer-base/src/main/java/com/fr/design/gui/itable/SortableJTable.java

@ -1,14 +1,19 @@
package com.fr.design.gui.itable;
import com.fine.theme.light.ui.FineTableHeaderUI;
import javax.swing.JTable;
public class SortableJTable extends JTable{
private static final String UI_CLASS_ID = "FineTableHeaderUI";
public SortableJTable(TableSorter tableModel){
super(tableModel);
tableModel.setTableHeader(getTableHeader());
setShowGrid(true);
getTableHeader().setUI(new FineTableHeaderUI());
}
@Override
public String getUIClassID() {
return UI_CLASS_ID;
}
}

31
designer-base/src/main/java/com/fr/design/gui/itableeditorpane/UITableEditorPane.java

@ -1,20 +1,22 @@
package com.fr.design.gui.itableeditorpane;
import com.fine.swing.ui.layout.Layouts;
import com.fine.swing.ui.layout.Row;
import com.fine.theme.light.ui.FineRoundBorder;
import com.fine.theme.light.ui.FineTableHeaderUI;
import com.fine.theme.light.ui.FineTableScrollBarPaneUI;
import com.fine.theme.utils.FineUIScale;
import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.iscrollbar.UIScrollBar;
import com.fr.design.gui.iscrollbar.UIVerticalScrollBar;
import com.fr.design.layout.FRGUIPaneFactory;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.JScrollBar;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.UIDefaults;
import javax.swing.event.TableModelListener;
import java.awt.BorderLayout;
import java.awt.Dimension;
@ -29,6 +31,7 @@ import java.util.List;
* @since 2012-3-28下午3:06:30
*/
public class UITableEditorPane<T> extends BasicPane {
private static final String UI_CLASS_ID = "FineTableHeaderUI";
/**
*
*/
@ -70,16 +73,19 @@ public class UITableEditorPane<T> extends BasicPane {
UILabel l = new UILabel(leftLabelName);
editTable = tableModel.createTable();
UIScrollPane scrollPane = new UIScrollPane(editTable);
UIScrollPane scrollPane = new UIScrollPane(editTable){
@Override
public UIScrollBar createVerticalScrollBar() {
return new UIVerticalScrollBar(editTable, JScrollBar.VERTICAL);
}
};
scrollPane.setBorder(new FineRoundBorder());
initbuttonPane(action);
JPanel controlPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
controlPane.add(buttonPane, BorderLayout.EAST);
controlPane.add(content == null ? l : content, BorderLayout.WEST);
scrollPane.getVerticalScrollBar().setUI(new FineTableScrollBarPaneUI(editTable));
pane.add(Layouts.column(10, Layouts.cell(controlPane), Layouts.cell(scrollPane).weight(1)).getComponent());
this.editTable.getTableHeader().setUI(new FineTableHeaderUI());
this.editTable.setRowHeight(FineUIScale.scale(24));
}
@ -193,4 +199,17 @@ public class UITableEditorPane<T> extends BasicPane {
editTable.getTableHeader().setResizingAllowed(resizingAllowed);
}
/**
* Returns the name of the L&amp;F class that renders this component.
*
* @return the string "ToolTipUI"
* @see JComponent#getUIClassID
* @see UIDefaults#getUI
*/
@Override
public String getUIClassID() {
return UI_CLASS_ID;
}
}

3
designer-base/src/main/java/com/fr/design/report/SelectImagePane.java

@ -1,6 +1,7 @@
package com.fr.design.report;
import com.fine.theme.light.ui.FineRoundBorder;
import com.fine.theme.utils.FineUIStyle;
import com.formdev.flatlaf.ui.FlatUIUtils;
import com.fr.base.Style;
import com.fr.design.dialog.BasicPane;
@ -82,7 +83,7 @@ public class SelectImagePane extends BasicPane {
previewPane.setOpaque(false);
this.add(column(
5,
cell(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preview"))),
cell(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preview"))).with(it -> FineUIStyle.setStyle(it, FineUIStyle.LABEL_TIP)),
row(
10,
cell(new JScrollPane(previewPane)).with(it -> {

7
designer-base/src/main/java/com/fr/design/write/submit/DBManipulationPane.java

@ -173,7 +173,6 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
keyColumnValuesTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
keyColumnValuesTable.setPreferredScrollableViewportSize(FineUIScale.scale(new Dimension(280, 150)));
keyColumnValuesTable.setShowHorizontalLines(true);
keyColumnValuesTable.getTableHeader().setUI(new FineTableHeaderUI());
northPane.add(column(10,
cell(FineUIUtils.wrapComponentWithTitle(typePane, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Write_Submit_Type"))),
@ -1019,6 +1018,12 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
}
protected static class KeyColumnNameValueTable extends JTable {
private static final String UI_CLASS_ID = "FineTableHeaderUI";
@Override
public String getUIClassID() {
return UI_CLASS_ID;
}
public KeyColumnNameValueTable() {
super(new KeyColumnValueTableModel(null));

2
designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLaf.properties

@ -34,7 +34,7 @@ SpinnerUI=com.formdev.flatlaf.ui.FlatSpinnerUI
SplitPaneUI=com.formdev.flatlaf.ui.FlatSplitPaneUI
TabbedPaneUI=com.formdev.flatlaf.ui.FlatTabbedPaneUI
TableUI=com.formdev.flatlaf.ui.FlatTableUI
TableHeaderUI=com.formdev.flatlaf.ui.FlatTableHeaderUI
TableHeaderUI=com.fine.theme.light.ui.FineTableHeaderUI
TextAreaUI=com.formdev.flatlaf.ui.FlatTextAreaUI
TextFieldUI=com.formdev.flatlaf.ui.FlatTextFieldUI
TextPaneUI=com.formdev.flatlaf.ui.FlatTextPaneUI

15
designer-base/src/test/java/com/fr/design/gui/storybook/components/TableStoryBoard.java

@ -5,14 +5,11 @@ import com.fine.theme.light.ui.FineTableHeaderUI;
import com.fine.theme.light.ui.FineTableScrollBarPaneUI;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.iscrollbar.UIScrollBar;
import com.fr.design.gui.iscrollbar.UIVerticalScrollBar;
import com.fr.design.gui.storybook.StoryBoard;
import javax.swing.BorderFactory;
import javax.swing.JCheckBox;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.UIManager;
import javax.swing.*;
import javax.swing.plaf.UIResource;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableCellRenderer;
@ -81,7 +78,11 @@ public class TableStoryBoard extends StoryBoard {
table3.getTableHeader().setUI(new FineTableHeaderUI());
table3.getTableHeader().getColumnModel().getColumn(0).setCellRenderer(new BooleanRenderer());
add(column(20, cell(new UIScrollPane(table1)).with(this::setFixSize).with(it -> it.getVerticalScrollBar().setUI(new FineTableScrollBarPaneUI(table1))),
add(column(20, cell(new UIScrollPane(table1) {
public UIScrollBar createVerticalScrollBar() {
return new UIVerticalScrollBar(table1, JScrollBar.VERTICAL);
}
}).with(this::setFixSize),
cell(new UIScrollPane(table2)).with(this::setFixSize),
cell(new UIScrollPane(table3)).with(this::setFixSize)).getComponent());
}

19
designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditorPane.java

@ -2,9 +2,7 @@ package com.fr.design.actions.replace.ui;
import com.fine.theme.icon.LazyIcon;
import com.fine.theme.light.ui.FineTableHeaderUI;
import com.fine.theme.light.ui.FineTableScrollBarPaneUI;
import com.fine.theme.utils.FineUIStyle;
import com.formdev.flatlaf.ui.FlatUIUtils;
import com.fr.base.TRL;
import com.fr.design.actions.replace.info.base.ITContent;
@ -12,6 +10,8 @@ import com.fr.design.dialog.BasicPane;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.iscrollbar.UIScrollBar;
import com.fr.design.gui.iscrollbar.UIVerticalScrollBar;
import com.fr.design.gui.itableeditorpane.UITableEditAction;
import com.fr.design.gui.itableeditorpane.UITableModelAdapter;
import com.fr.design.layout.FRGUIPaneFactory;
@ -26,6 +26,7 @@ import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollBar;
import javax.swing.JTable;
import javax.swing.SortOrder;
import javax.swing.SwingConstants;
@ -50,6 +51,7 @@ import static com.fine.swing.ui.layout.Layouts.cell;
* Created On
*/
public class ITTableEditorPane<T> extends BasicPane {
private static final String UI_CLASS_ID = "FineTableHeaderUI";
public static JTable editTable;
private UITableModelAdapter<T> tableModel;
private String leftLabelName;
@ -94,8 +96,12 @@ public class ITTableEditorPane<T> extends BasicPane {
}
});
UIScrollPane scrollPane = new UIScrollPane(editTable);
scrollPane.getVerticalScrollBar().setUI(new FineTableScrollBarPaneUI(editTable));
UIScrollPane scrollPane = new UIScrollPane(editTable) {
@Override
public UIScrollBar createVerticalScrollBar() {
return new UIVerticalScrollBar(editTable, JScrollBar.VERTICAL);
}
};
add(cell(scrollPane).weight(1).getComponent());
}
@ -245,7 +251,6 @@ public class ITTableEditorPane<T> extends BasicPane {
* @param table
*/
public static void makeFace(JTable table) {
table.getTableHeader().setUI(new FineTableHeaderUI());
table.getTableHeader().setDefaultRenderer(new ITHeaderRenderer(table));
}
@ -361,5 +366,9 @@ public class ITTableEditorPane<T> extends BasicPane {
this.editTable = editTable;
}
@Override
public String getUIClassID() {
return UI_CLASS_ID;
}
}

22
designer-realize/src/main/java/com/fr/design/cell/smartaction/SmartJTablePane.java

@ -3,18 +3,17 @@ package com.fr.design.cell.smartaction;
import java.awt.BorderLayout;
import java.awt.Window;
import com.fine.theme.light.ui.FineTableHeaderUI;
import com.fine.theme.light.ui.FineTableScrollBarPaneUI;
import com.fr.design.gui.ilable.UILabel;
import javax.swing.JScrollBar;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.SwingConstants;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.DefaultTableCellRenderer;
import com.fr.design.gui.iscrollbar.UIScrollBar;
import com.fr.design.gui.iscrollbar.UIVerticalScrollBar;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.BasicPane;
@ -27,6 +26,7 @@ import com.fr.design.selection.SelectionListener;
* SmartJTablePane用于在Grid上面选单元格时编辑JTable
*/
public abstract class SmartJTablePane extends BasicPane {
private static final String UI_CLASS_ID = "FineTableHeaderUI";
public static final int OK = 0;
public static final int CANCEL = 1;
@ -61,8 +61,12 @@ public abstract class SmartJTablePane extends BasicPane {
// BasicPane的center放JTable
table = new JTable(model);
this.add(scrollPane = new JScrollPane(table), BorderLayout.CENTER);
scrollPane.getVerticalScrollBar().setUI(new FineTableScrollBarPaneUI(table));
this.add(scrollPane = new JScrollPane(table) {
@Override
public UIScrollBar createVerticalScrollBar() {
return new UIVerticalScrollBar(table, JScrollBar.VERTICAL);
}
}, BorderLayout.CENTER);
// 鼠标切换选中项时,editingRowIndex也要跟着变
table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
@ -76,7 +80,6 @@ public abstract class SmartJTablePane extends BasicPane {
}
}
});
table.getTableHeader().setUI(new FineTableHeaderUI());
setCellRenderer();
actionReportPane.addSelectionChangeListener(gridSelectionChangeL);
@ -120,5 +123,10 @@ public abstract class SmartJTablePane extends BasicPane {
return dlg;
}
@Override
public String getUIClassID() {
return UI_CLASS_ID;
}
}

Loading…
Cancel
Save