forked from fanruan/design
Qinghui.Liu
4 years ago
7 changed files with 441 additions and 11 deletions
@ -0,0 +1,124 @@
|
||||
package com.fr.van.chart.designer.component.richText; |
||||
|
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.data.util.function.DataFunction; |
||||
import com.fr.design.gui.ibutton.UIButton; |
||||
import com.fr.design.gui.ibutton.UIToggleButton; |
||||
import com.fr.design.layout.TableLayout; |
||||
import com.fr.design.layout.TableLayoutHelper; |
||||
import com.fr.van.chart.designer.TableLayout4VanChartHelper; |
||||
|
||||
import javax.swing.Icon; |
||||
import javax.swing.JPanel; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Component; |
||||
import java.awt.Dimension; |
||||
import java.awt.event.MouseAdapter; |
||||
import java.awt.event.MouseEvent; |
||||
import java.awt.event.MouseListener; |
||||
import java.text.Format; |
||||
|
||||
public class VanChartFieldAddPane extends JPanel { |
||||
|
||||
private static final Icon ADD_ICON = BaseUtils.readIcon("/com/fr/base/images/cell/control/add.png"); |
||||
|
||||
private static final int W = 200; |
||||
private static final int H = 28; |
||||
|
||||
private UIToggleButton fieldButton; |
||||
private UIButton addButton; |
||||
|
||||
private Format format; |
||||
private DataFunction dataFunction; |
||||
|
||||
private String fieldName; |
||||
private boolean showSummary; |
||||
|
||||
public VanChartFieldAddPane(String fieldName, VanChartFieldListener listener) { |
||||
this(fieldName, false, listener); |
||||
} |
||||
|
||||
public VanChartFieldAddPane(String fieldName, boolean showSummary, VanChartFieldListener listener) { |
||||
this.fieldName = fieldName; |
||||
this.showSummary = showSummary; |
||||
|
||||
initComponents(fieldName, listener); |
||||
|
||||
this.setLayout(new BorderLayout()); |
||||
this.add(getContentPane(), BorderLayout.CENTER); |
||||
} |
||||
|
||||
public String getFieldName() { |
||||
return fieldName; |
||||
} |
||||
|
||||
public Format getFormat() { |
||||
return format; |
||||
} |
||||
|
||||
public void setFormat(Format format) { |
||||
this.format = format; |
||||
} |
||||
|
||||
public DataFunction getDataFunction() { |
||||
return dataFunction; |
||||
} |
||||
|
||||
public void setDataFunction(DataFunction dataFunction) { |
||||
this.dataFunction = dataFunction; |
||||
} |
||||
|
||||
public boolean isShowSummary() { |
||||
return showSummary; |
||||
} |
||||
|
||||
private void initComponents(String fieldName, VanChartFieldListener listener) { |
||||
fieldButton = new UIToggleButton(fieldName) { |
||||
|
||||
protected MouseListener getMouseListener() { |
||||
|
||||
return new MouseAdapter() { |
||||
public void mousePressed(MouseEvent e) { |
||||
setSelected(true); |
||||
|
||||
listener.refreshSelectedField(fieldName); |
||||
listener.setGlobalName(fieldName); |
||||
} |
||||
}; |
||||
} |
||||
}; |
||||
|
||||
addButton = new UIButton(ADD_ICON); |
||||
|
||||
addButton.addMouseListener(new MouseAdapter() { |
||||
|
||||
public void mousePressed(MouseEvent e) { |
||||
super.mousePressed(e); |
||||
|
||||
listener.addSelectedField(fieldName); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
private JPanel getContentPane() { |
||||
Component[][] components = new Component[][]{ |
||||
new Component[]{fieldButton, addButton} |
||||
}; |
||||
|
||||
double p = TableLayout.PREFERRED; |
||||
double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; |
||||
double d = TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH; |
||||
|
||||
double[] rowSize = {p}; |
||||
double[] columnSize = {e, d}; |
||||
|
||||
JPanel content = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 5, 0); |
||||
content.setPreferredSize(new Dimension(W, H)); |
||||
|
||||
return content; |
||||
} |
||||
|
||||
public void setSelectedState(boolean selected) { |
||||
fieldButton.setSelected(selected); |
||||
} |
||||
} |
@ -0,0 +1,115 @@
|
||||
package com.fr.van.chart.designer.component.richText; |
||||
|
||||
import com.fr.general.ComparatorUtils; |
||||
import com.fr.van.chart.designer.TableLayout4VanChartHelper; |
||||
|
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.JPanel; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Dimension; |
||||
import java.awt.GridLayout; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
public class VanChartFieldGroupPane extends JPanel { |
||||
|
||||
private static final int FIELD_ADD_W = 400; |
||||
private static final int FIELD_ADD_H = 28; |
||||
|
||||
private List<String> defaultFieldNameList; |
||||
private List<String> tableFieldNameList; |
||||
|
||||
private List<VanChartFieldAddPane> defaultFieldPaneList = new ArrayList<>(); |
||||
private List<VanChartFieldAddPane> tableFieldPaneList = new ArrayList<>(); |
||||
|
||||
private VanChartFieldListener fieldListener; |
||||
|
||||
public VanChartFieldGroupPane(List<String> defaultFieldNameList, List<String> tableFieldNameList) { |
||||
this.defaultFieldNameList = defaultFieldNameList; |
||||
this.tableFieldNameList = tableFieldNameList; |
||||
|
||||
initFieldListener(); |
||||
|
||||
this.setLayout(new BorderLayout()); |
||||
|
||||
this.add(createDefaultFieldPane(), BorderLayout.CENTER); |
||||
this.add(createTableFieldPane(), BorderLayout.SOUTH); |
||||
} |
||||
|
||||
private JPanel createDefaultFieldPane() { |
||||
JPanel defaultField = new JPanel(); |
||||
|
||||
defaultField.setLayout(new GridLayout(0, 1, 1, 0)); |
||||
|
||||
for (String title : defaultFieldNameList) { |
||||
VanChartFieldAddPane fieldAddPane = new VanChartFieldAddPane(title, fieldListener); |
||||
|
||||
defaultField.add(fieldAddPane); |
||||
defaultFieldPaneList.add(fieldAddPane); |
||||
} |
||||
|
||||
defaultField.setPreferredSize(new Dimension(FIELD_ADD_W, defaultFieldNameList.size() * FIELD_ADD_H)); |
||||
defaultField.setBorder(BorderFactory.createEmptyBorder(10, 5, 0, 0)); |
||||
|
||||
return defaultField; |
||||
} |
||||
|
||||
private JPanel createTableFieldPane() { |
||||
JPanel tableField = new JPanel(); |
||||
|
||||
tableField.setLayout(new GridLayout(0, 1, 1, 0)); |
||||
|
||||
for (String title : tableFieldNameList) { |
||||
VanChartFieldAddPane fieldAddPane = new VanChartFieldAddPane(title, fieldListener); |
||||
|
||||
tableField.add(fieldAddPane); |
||||
tableFieldPaneList.add(fieldAddPane); |
||||
} |
||||
|
||||
tableField.setPreferredSize(new Dimension(FIELD_ADD_W, defaultFieldNameList.size() * FIELD_ADD_H)); |
||||
|
||||
return TableLayout4VanChartHelper.createExpandablePaneWithTitleTopGap("数据集字段", tableField); |
||||
} |
||||
|
||||
private void initFieldListener() { |
||||
|
||||
fieldListener = new VanChartFieldListener() { |
||||
|
||||
private String fieldName; |
||||
|
||||
public void setGlobalName(String fieldName) { |
||||
this.fieldName = fieldName; |
||||
} |
||||
|
||||
public String getGlobalName() { |
||||
return this.fieldName; |
||||
} |
||||
|
||||
public void refreshSelectedField(String fieldName) { |
||||
if (ComparatorUtils.equals(fieldName, this.fieldName)) { |
||||
return; |
||||
} |
||||
|
||||
for (VanChartFieldAddPane fieldAddPane : defaultFieldPaneList) { |
||||
fieldAddPane.setSelectedState(ComparatorUtils.equals(fieldAddPane.getFieldName(), fieldName)); |
||||
} |
||||
|
||||
for (VanChartFieldAddPane fieldAddPane : tableFieldPaneList) { |
||||
fieldAddPane.setSelectedState(ComparatorUtils.equals(fieldAddPane.getFieldName(), fieldName)); |
||||
} |
||||
} |
||||
|
||||
public void addSelectedField(String fieldName) { |
||||
System.out.println(fieldName); |
||||
} |
||||
|
||||
public void populateFieldFormatPane() { |
||||
|
||||
} |
||||
|
||||
public void updateFieldFormatPane() { |
||||
|
||||
} |
||||
}; |
||||
} |
||||
} |
@ -0,0 +1,15 @@
|
||||
package com.fr.van.chart.designer.component.richText; |
||||
|
||||
import com.fr.design.event.GlobalNameListener; |
||||
|
||||
public interface VanChartFieldListener extends GlobalNameListener { |
||||
|
||||
public void refreshSelectedField(String fieldName); |
||||
|
||||
public void addSelectedField(String fieldName); |
||||
|
||||
public void populateFieldFormatPane(); |
||||
|
||||
public void updateFieldFormatPane(); |
||||
|
||||
} |
@ -1,4 +1,4 @@
|
||||
package com.fr.van.chart.designer.component; |
||||
package com.fr.van.chart.designer.component.richText; |
||||
|
||||
import com.fr.concurrent.NamedThreadFactory; |
||||
import com.fr.design.DesignerEnvManager; |
@ -0,0 +1,144 @@
|
||||
package com.fr.van.chart.designer.component.richText; |
||||
|
||||
import com.fr.design.beans.BasicBeanPane; |
||||
import com.fr.design.gui.icombobox.UIComboBox; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.gui.style.FormatPane; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.layout.TableLayout; |
||||
import com.fr.design.mainframe.chart.gui.data.CalculateComboBox; |
||||
import com.fr.plugin.chart.base.AttrTooltipContent; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.van.chart.designer.TableLayout4VanChartHelper; |
||||
import com.fr.van.chart.designer.component.format.FormatPaneWithOutFont; |
||||
import com.fr.van.chart.designer.style.VanChartStylePane; |
||||
|
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.JScrollPane; |
||||
import javax.swing.SwingConstants; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Component; |
||||
import java.awt.Dimension; |
||||
import java.util.List; |
||||
|
||||
// 标签提示中的富文本面板,包含字段设置和富文本编辑器
|
||||
public class VanChartRichTextPane extends BasicBeanPane<AttrTooltipContent> { |
||||
|
||||
private static final int FIELD_PANE_W = 470; |
||||
private static final int FIELD_PANE_H = 270; |
||||
|
||||
private static final int RICH_EDITOR_W = 940; |
||||
private static final int RICH_EDITOR_H = 260; |
||||
|
||||
private static final double P = TableLayout.PREFERRED; |
||||
private static final double D = TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH; |
||||
private static final double E = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; |
||||
|
||||
private JScrollPane fieldContentPane; |
||||
private JScrollPane fieldPropsPane; |
||||
|
||||
private FormatPane fieldFormatPane; |
||||
private JPanel fieldSummaryPane; |
||||
|
||||
private UIComboBox fieldSummaryBox; |
||||
|
||||
private VanChartStylePane parent; |
||||
|
||||
private List<String> defaultFieldsFormat; |
||||
private List<String> tableFieldsFormat; |
||||
|
||||
public VanChartRichTextPane(VanChartStylePane parent, List<String> defaultFieldsFormat, List<String> tableFieldsFormat, JPanel richEditor) { |
||||
this.parent = parent; |
||||
|
||||
this.defaultFieldsFormat = defaultFieldsFormat; |
||||
this.tableFieldsFormat = tableFieldsFormat; |
||||
|
||||
initFieldContentPane(); |
||||
initFieldPropsPane(); |
||||
|
||||
this.setLayout(new BorderLayout()); |
||||
this.add(createFieldDetailPane(), BorderLayout.CENTER); |
||||
this.add(createRichEditorPane(richEditor), BorderLayout.SOUTH); |
||||
} |
||||
|
||||
private void initFieldContentPane() { |
||||
JPanel content = new JPanel(); |
||||
content.setLayout(new BorderLayout()); |
||||
content.add(createDefaultContentPane(), BorderLayout.NORTH); |
||||
content.add(createTableFieldsPane(), BorderLayout.CENTER); |
||||
|
||||
fieldContentPane = new JScrollPane(content); |
||||
fieldContentPane.setPreferredSize(new Dimension(FIELD_PANE_W, FIELD_PANE_H)); |
||||
fieldContentPane.setHorizontalScrollBar(null); |
||||
fieldContentPane.setBorder(BorderFactory.createTitledBorder("添加字段")); |
||||
} |
||||
|
||||
private void initFieldPropsPane() { |
||||
fieldFormatPane = new FormatPaneWithOutFont() { |
||||
protected JPanel createContentPane(Component[][] components) { |
||||
return TableLayout4VanChartHelper.createGapTableLayoutPane(components, new double[]{P, P, P}, new double[]{D, E}); |
||||
} |
||||
}; |
||||
|
||||
fieldSummaryBox = new CalculateComboBox(); |
||||
|
||||
Component[][] components = new Component[][]{ |
||||
new Component[]{null, null}, |
||||
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Summary_Method"), SwingConstants.LEFT), fieldSummaryBox} |
||||
}; |
||||
|
||||
fieldSummaryPane = TableLayout4VanChartHelper.createGapTableLayoutPane(components, new double[]{P, P}, new double[]{D, E}); |
||||
|
||||
JPanel props = new JPanel(); |
||||
props.setLayout(new BorderLayout()); |
||||
props.add(fieldFormatPane, BorderLayout.NORTH); |
||||
props.add(fieldSummaryPane, BorderLayout.CENTER); |
||||
props.setBorder(BorderFactory.createEmptyBorder(0, 30, 0, 0)); |
||||
|
||||
fieldPropsPane = new JScrollPane(props); |
||||
fieldPropsPane.setPreferredSize(new Dimension(FIELD_PANE_W, FIELD_PANE_H)); |
||||
fieldPropsPane.setBorder(BorderFactory.createTitledBorder("字段设置")); |
||||
} |
||||
|
||||
private JPanel createDefaultContentPane() { |
||||
|
||||
return new VanChartFieldGroupPane(defaultFieldsFormat, tableFieldsFormat); |
||||
} |
||||
|
||||
private JPanel createTableFieldsPane() { |
||||
return new JPanel(); |
||||
} |
||||
|
||||
private JPanel createFieldDetailPane() { |
||||
JPanel fieldPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); |
||||
|
||||
fieldPane.add(fieldContentPane); |
||||
fieldPane.add(fieldPropsPane); |
||||
|
||||
return fieldPane; |
||||
} |
||||
|
||||
private JPanel createRichEditorPane(JPanel richEditor) { |
||||
JPanel richEditorPane = new JPanel(); |
||||
|
||||
richEditorPane.setLayout(new BorderLayout()); |
||||
richEditorPane.setPreferredSize(new Dimension(RICH_EDITOR_W, RICH_EDITOR_H)); |
||||
richEditorPane.add(richEditor, BorderLayout.CENTER); |
||||
|
||||
return richEditorPane; |
||||
} |
||||
|
||||
public void populateBean(AttrTooltipContent ob) { |
||||
|
||||
} |
||||
|
||||
public AttrTooltipContent updateBean() { |
||||
return null; |
||||
} |
||||
|
||||
protected String title4PopupWindow() { |
||||
return StringUtils.EMPTY; |
||||
} |
||||
} |
Loading…
Reference in new issue