Browse Source

REPORT-114888 fix:设计器新UI图表无法打开配置面板

newui
vito 9 months ago
parent
commit
c30278f28b
  1. 4
      build.gradle
  2. 58
      designer-base/src/main/java/com/fr/design/gui/imenutable/UIMenuTable.java
  3. 65
      designer-base/src/main/java/com/fr/design/gui/itable/UITable.java

4
build.gradle

@ -87,9 +87,9 @@ allprojects {
implementation 'com.fr.report:engine-chart:' + frDevVersion
implementation 'com.fr.report:engine-i18n:' + frDevVersion
implementation 'com.fr.design:design-i18n:' + frDevVersion
implementation 'com.formdev:flatlaf:3.2'
implementation 'com.formdev:flatlaf-extras:3.2.1'
implementation 'com.github.weisj:jsvg:1.2.0'
implementation 'com.formdev:flatlaf:3.4'
implementation 'com.formdev:flatlaf-extras:3.4'
implementation 'com.fanruan.vito:gui-inspector:1.0.1'
implementation 'com.fine.swing.ui:layout:1.0-SNAPSHOT'
testImplementation 'org.easymock:easymock:3.5.1'

58
designer-base/src/main/java/com/fr/design/gui/imenutable/UIMenuTable.java

@ -10,17 +10,23 @@ import com.fr.design.hyperlink.ReportletHyperlinkPane;
import com.fr.design.hyperlink.WebHyperlinkPane;
import com.fr.design.javascript.EmailPane;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.js.EmailJavaScript;
import com.fr.js.ReportletHyperlink;
import com.fr.js.WebHyperlink;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.plaf.TableUI;
import javax.swing.table.TableCellRenderer;
import java.awt.*;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.util.ArrayList;
import java.util.List;
@ -35,11 +41,11 @@ public class UIMenuTable extends JTable {
}
public void populateBean(List<UIMenuNameableCreator> values) {
((UIMenuTableDataModel)dataModel).populateBean(values);
((UIMenuTableDataModel) dataModel).populateBean(values);
}
public List<UIMenuNameableCreator> updateBean() {
return ((UIMenuTableDataModel)dataModel).updateBean();
return ((UIMenuTableDataModel) dataModel).updateBean();
}
public void editingEvent(int rowIndex, int mouseY) {
@ -68,7 +74,7 @@ public class UIMenuTable extends JTable {
}
protected Color getRenderBackground(int row) {
if(selectedRowIndex == row ) {
if (selectedRowIndex == row) {
return UIConstants.SKY_BLUE;
} else {
return (rollOverRowIndex == row) ? UIConstants.LIGHT_BLUE : UIConstants.NORMAL_BACKGROUND;
@ -76,15 +82,14 @@ public class UIMenuTable extends JTable {
}
/**
*
* @param value 该行列的值(字符串)
* @param row
* @param column
* @return 列表中默认显示的东西如果有很多内容可以装载一个JPanel里再嵌进来
*/
protected JComponent getRenderCompoment(Object value, int row,int column) {
protected JComponent getRenderCompoment(Object value, int row, int column) {
UILabel text = new UILabel();
if(value != null) {
if (value != null) {
text.setText(value.toString());
}
return text;
@ -95,7 +100,7 @@ public class UIMenuTable extends JTable {
* 在table底部增加一行内容
*/
public void addLine(UIMenuNameableCreator line) {
((UIMenuTableDataModel)dataModel).addLine(line);
((UIMenuTableDataModel) dataModel).addLine(line);
}
/**
@ -103,15 +108,16 @@ public class UIMenuTable extends JTable {
* @return 某一行的内容
*/
public UIMenuNameableCreator getLine(int rowIndex) {
return ((UIMenuTableDataModel)dataModel).getLine(rowIndex);
return ((UIMenuTableDataModel) dataModel).getLine(rowIndex);
}
/**
* 删除某行内容
*
* @param rowIndex
*/
public void removeLine(int rowIndex) {
((UIMenuTableDataModel)dataModel).removeLine(rowIndex);
((UIMenuTableDataModel) dataModel).removeLine(rowIndex);
}
/**
@ -119,23 +125,24 @@ public class UIMenuTable extends JTable {
*/
public void clearAll() {
int rowCount = dataModel.getRowCount();
for(int i = 0; i < rowCount; i++) {
for (int i = 0; i < rowCount; i++) {
removeLine(i);
}
}
/**
* 对某一行拖动时进行排序
*
* @param rowIndex
* @param positive 鼠标移动的距离
*/
public void dragSort(int rowIndex, boolean positive) {
((UIMenuTableDataModel)dataModel).dragSort(rowIndex, positive);
((UIMenuTableDataModel) dataModel).dragSort(rowIndex, positive);
}
@Override
public boolean isCellEditable(int row, int column) {
if(column == 0) {
if (column == 0) {
return false;
} else {
return super.isCellEditable(row, column);
@ -157,7 +164,16 @@ public class UIMenuTable extends JTable {
@Override
public TableCellRenderer getDefaultRenderer(Class<?> columnClass) {
return super.getDefaultRenderer(UITable.class);
// 处理null的情况用于创建时未指定数据结构的情况
if (columnClass == null) {
return createDefaultRenderer();
}
return super.getDefaultRenderer(columnClass);
}
private @NotNull TableCellRenderer createDefaultRenderer() {
Object renderer = defaultRenderersByColumnClass.get(UITable.class);
return renderer != null ? (TableCellRenderer) renderer : new UITableRender();
}
private class UITableRender implements TableCellRenderer {
@ -165,11 +181,11 @@ public class UIMenuTable extends JTable {
public Component getTableCellRendererComponent(JTable table,
Object value, boolean isSelected, boolean hasFocus, int row,
int column) {
JPanel pane = new JPanel(new BorderLayout(4,0));
JPanel pane = new JPanel(new BorderLayout(4, 0));
Color back = getRenderBackground(row);
pane.setBackground(back);
if(draggingIndex == row) {
if (draggingIndex == row) {
return pane;
}
pane.add(getRenderCompoment(value, row, column), BorderLayout.CENTER);
@ -191,7 +207,7 @@ public class UIMenuTable extends JTable {
for (int i = listeners.length - 2; i >= 0; i -= 2) {
if (listeners[i] == ChangeListener.class) {
((ChangeListener)listeners[i + 1]).stateChanged(new ChangeEvent(this));
((ChangeListener) listeners[i + 1]).stateChanged(new ChangeEvent(this));
}
}
}
@ -207,7 +223,7 @@ public class UIMenuTable extends JTable {
public static void main(String... args) {
JFrame jf = new JFrame("test");
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel content = (JPanel)jf.getContentPane();
JPanel content = (JPanel) jf.getContentPane();
content.setLayout(new BorderLayout());
List<UIMenuNameableCreator> data = new ArrayList<UIMenuNameableCreator>();
UIMenuNameableCreator reportlet = new UIMenuNameableCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Reportlet"),
@ -217,7 +233,7 @@ public class UIMenuTable extends JTable {
new EmailJavaScript(), EmailPane.class);
UIMenuNameableCreator web = new UIMenuNameableCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Web_Link"),
new WebHyperlink(), WebHyperlinkPane.class );
new WebHyperlink(), WebHyperlinkPane.class);
data.add(reportlet);
data.add(email);
data.add(web);

65
designer-base/src/main/java/com/fr/design/gui/itable/UITable.java

@ -6,6 +6,7 @@ import com.fr.design.event.UIObserverListener;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.utils.gui.GUICoreUtils;
import org.jetbrains.annotations.NotNull;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
@ -35,9 +36,9 @@ public class UITable extends JTable implements UIObserver {
private static final int OFF_LEFT = 10;
private static final int DEFAULT_ROW_HEIGHT =20;
private static final int DEFAULT_ROW_HEIGHT = 20;
private UIObserverListener uiObserverListener;
UITableEditor editor ;
UITableEditor editor;
private boolean shouldResponseAwt;
private boolean isEditingStopped;
@ -57,7 +58,7 @@ public class UITable extends JTable implements UIObserver {
// Toolkit.getDefaultToolkit().addAWTEventListener(awt, AWTEvent.MOUSE_EVENT_MASK);
}
public UITable (int columnSize, boolean needAWTEventListener) {
public UITable(int columnSize, boolean needAWTEventListener) {
this(columnSize);
shouldResponseAwt = needAWTEventListener;
isEditingStopped = true;
@ -91,10 +92,9 @@ public class UITable extends JTable implements UIObserver {
}
private AWTEventListener awt = new AWTEventListener() {
public void eventDispatched(AWTEvent event) {
if(!UITable.this.isShowing()){
if (!UITable.this.isShowing()) {
return;
}
doSomeInAll(event);
@ -131,6 +131,7 @@ public class UITable extends JTable implements UIObserver {
/**
* 在table底部增加一行内容
*
* @param line 该行的内容
*/
public void addLine(Object[] line) {
@ -166,7 +167,8 @@ public class UITable extends JTable implements UIObserver {
/**
*格子是否可编辑可置顶某一列column不可编辑
* 格子是否可编辑可置顶某一列column不可编辑
*
* @param row 行号
* @param column 列号
* @return 是否可编辑
@ -232,19 +234,20 @@ public class UITable extends JTable implements UIObserver {
/**
* 鼠标悬浮再某一行时触发的事件
*
* @param index 行号
*/
public void dealWithRollOver(int index){
public void dealWithRollOver(int index) {
}
private void iniListener(){
if(shouldResponseChangeListener()){
private void iniListener() {
if (shouldResponseChangeListener()) {
this.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
if(uiObserverListener == null){
return ;
if (uiObserverListener == null) {
return;
}
uiObserverListener.doChange();
}
@ -258,7 +261,8 @@ public class UITable extends JTable implements UIObserver {
/**
*停止编辑事件
* 停止编辑事件
*
* @param e 事件
*/
public void tableCellEditingStopped(ChangeEvent e) {
@ -266,7 +270,8 @@ public class UITable extends JTable implements UIObserver {
}
/**
*取消编辑事件
* 取消编辑事件
*
* @param e 事件
*/
public void tableCellEditingCanceled(ChangeEvent e) {
@ -275,6 +280,7 @@ public class UITable extends JTable implements UIObserver {
/**
* 编辑器
*
* @return 编辑器
*/
public UITableEditor createTableEditor() {
@ -289,21 +295,19 @@ public class UITable extends JTable implements UIObserver {
return new UITableUI();
}
// @Override
/**
*
*/
// public TableCellEditor getDefaultEditor(Class<?> columnClass) {
// return super.getDefaultEditor(UITable.class);
// }
@Override
public TableCellRenderer getDefaultRenderer(Class<?> columnClass) {
// 处理null的情况用于创建时未指定数据结构的情况
if (columnClass == null) {
return createDefaultRenderer();
}
return super.getDefaultRenderer(columnClass);
}
// @Override
/**
*
*/
// public TableCellRenderer getDefaultRenderer(Class<?> columnClass) {
// return super.getDefaultRenderer(UITable.class);
// }
private @NotNull TableCellRenderer createDefaultRenderer() {
Object renderer = defaultRenderersByColumnClass.get(UITable.class);
return renderer != null ? (TableCellRenderer) renderer : new UITableRender();
}
/**
* 给组件登记一个观察者监听事件
@ -347,6 +351,7 @@ public class UITable extends JTable implements UIObserver {
/**
* 增加监听
*
* @param l 监听
*/
public void addChangeListener(ChangeListener l) {
@ -354,7 +359,8 @@ public class UITable extends JTable implements UIObserver {
}
/**
*移除监听
* 移除监听
*
* @param l 监听
*/
public void removeChangeListener(ChangeListener l) {
@ -362,7 +368,8 @@ public class UITable extends JTable implements UIObserver {
}
/**
*测试主函数
* 测试主函数
*
* @param args 参数
*/
public static void main(String... args) {

Loading…
Cancel
Save