roger
11 months ago
17 changed files with 187 additions and 121 deletions
@ -1,70 +0,0 @@
|
||||
package com.fr.widgettheme.theme.panel; |
||||
|
||||
import com.fr.design.gui.ibutton.UIColorButton; |
||||
import com.fr.design.gui.frpane.FontSizeComboPane; |
||||
import com.fr.widgettheme.theme.widget.style.ThemeTextStyle; |
||||
|
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.JPanel; |
||||
import java.awt.Color; |
||||
import java.awt.Dimension; |
||||
import java.awt.FlowLayout; |
||||
import java.util.Vector; |
||||
|
||||
/** |
||||
* 控件文本样式配置面板 |
||||
* 包含文本字体大小和字体颜色 |
||||
* |
||||
* @author oBo |
||||
* @since 11.0 |
||||
* Created on 2023/12/13 |
||||
*/ |
||||
public class WidgetTextStylePane extends JPanel { |
||||
|
||||
private final FontSizeComboPane fontSizePane; |
||||
|
||||
private final UIColorButton fontColorButton; |
||||
|
||||
public WidgetTextStylePane(int preferredWidth) { |
||||
this(null, preferredWidth); |
||||
} |
||||
|
||||
public WidgetTextStylePane(Vector<Integer> fontSizes, int preferredWidth) { |
||||
this.setLayout(new FlowLayout(FlowLayout.LEFT)); |
||||
this.setBorder(BorderFactory.createEmptyBorder()); |
||||
fontSizePane = new FontSizeComboPane(fontSizes); |
||||
fontColorButton = new UIColorButton(); |
||||
fontSizePane.setPreferredSize(new Dimension(preferredWidth, fontSizePane.getPreferredSize().height)); |
||||
this.add(fontSizePane); |
||||
this.add(fontColorButton); |
||||
} |
||||
|
||||
public void setTextStyle(ThemeTextStyle themeTextStyle) { |
||||
this.fontSizePane.setValue(themeTextStyle.getFontSize()); |
||||
this.fontColorButton.setColor(themeTextStyle.getFontColor()); |
||||
} |
||||
|
||||
public ThemeTextStyle getTextStyle() { |
||||
ThemeTextStyle themeTextStyle = new ThemeTextStyle(); |
||||
themeTextStyle.setFontSize(this.fontSizePane.getValue()); |
||||
themeTextStyle.setFontColor(this.fontColorButton.getColor()); |
||||
return themeTextStyle; |
||||
} |
||||
|
||||
public void setFontSizeValue(int fontSize) { |
||||
this.fontSizePane.setValue(fontSize); |
||||
} |
||||
|
||||
public void setFontColorValue(Color fontColor) { |
||||
this.fontColorButton.setColor(fontColor); |
||||
} |
||||
|
||||
public int getFontSizeValue() { |
||||
return this.fontSizePane.getValue(); |
||||
} |
||||
|
||||
public Color getFontColorValue() { |
||||
return this.fontColorButton.getColor(); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,40 @@
|
||||
package com.fr.widgettheme.util; |
||||
|
||||
import com.fr.design.gui.frpane.FontSizeComboPane; |
||||
import com.fr.design.gui.ibutton.UIColorButton; |
||||
import com.fr.design.layout.TableLayout; |
||||
import com.fr.design.layout.TableLayoutHelper; |
||||
|
||||
import javax.swing.Box; |
||||
import javax.swing.JPanel; |
||||
import java.awt.Component; |
||||
|
||||
/** |
||||
* 创建主题文本样式的工具类 |
||||
* |
||||
* @author obo |
||||
* @since 11.0 |
||||
* Created on 2023/12/21 |
||||
*/ |
||||
public class ThemeTextStylePaneCreator { |
||||
private ThemeTextStylePaneCreator() {} |
||||
|
||||
/** |
||||
* 创建主题文本样式配置面板 |
||||
* 包含字体大小下拉框和字体颜色按钮 |
||||
* 可以自适应布局 |
||||
* |
||||
* @param fontSizePane 字体大小配置 |
||||
* @param fontColorButton 字体颜色配置 |
||||
* @return 文本样式面板 |
||||
*/ |
||||
public static JPanel create(FontSizeComboPane fontSizePane, UIColorButton fontColorButton) { |
||||
Component[][] components = {{fontSizePane, Box.createHorizontalStrut(5), fontColorButton}}; |
||||
double f = TableLayout.FILL; |
||||
double p = TableLayout.PREFERRED; |
||||
double[] rowSize = {f}; |
||||
double[] columnSize = {f, p, p}; |
||||
int[][] rowCount = {{1, 1, 1}}; |
||||
return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, 0, 0); |
||||
} |
||||
} |
@ -0,0 +1,41 @@
|
||||
package com.fr.design.data.tabledata.tabledatapane; |
||||
|
||||
import com.fr.base.Parameter; |
||||
import com.fr.design.data.datapane.sqlpane.SQLEditPane; |
||||
import com.fr.invoke.Reflect; |
||||
import junit.framework.TestCase; |
||||
import org.junit.Assert; |
||||
|
||||
/** |
||||
* @author Yuan.Wang |
||||
* @since 11.0 |
||||
* Created on 2023/12/22 |
||||
*/ |
||||
public class DBTableDataPaneTest extends TestCase { |
||||
|
||||
public void testGetParameters() { |
||||
DBTableDataPane pane = new DBTableDataPane(); |
||||
SQLEditPane editPane = new SQLEditPane(); |
||||
String sql = "select distinct 类别ID from S产品\n" + |
||||
"where 1=1\n" + |
||||
"order by 类别ID\n" + |
||||
"--${ if(len(comboBox0) = 0,\"\",\"AND 类别00ID = '\" + comboBox0 + \"'\")}"; |
||||
|
||||
String sql1 = "select distinct 类别ID from S产品\n" + |
||||
"where 1=1\n" + |
||||
"order by 类别ID\n" + |
||||
"${ if(len(comboBox0) = 0,\"\",\"AND 类别00ID = '\" + comboBox0 + \"'\")}"; |
||||
editPane.setText(sql); |
||||
Reflect.on(pane).set("sqlTextPane", editPane); |
||||
Reflect.on(pane).set("pageQuery", sql); |
||||
|
||||
Parameter[] parameters = Reflect.on(pane).call("getParameters").get(); |
||||
|
||||
Assert.assertEquals(0, parameters.length); |
||||
editPane.setText(sql1); |
||||
|
||||
parameters = Reflect.on(pane).call("getParameters").get(); |
||||
Assert.assertEquals(1, parameters.length); |
||||
Assert.assertEquals(parameters[0].getName(), "comboBox0"); |
||||
} |
||||
} |
Loading…
Reference in new issue