Browse Source

开发富文本字段界面

feature/big-screen
Qinghui.Liu 4 years ago
parent
commit
f642971375
  1. 44
      designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTooltipContentPane.java
  2. 124
      designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartFieldAddPane.java
  3. 115
      designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartFieldGroupPane.java
  4. 15
      designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartFieldListener.java
  5. 2
      designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichEditorPane.java
  6. 8
      designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichTextDialog.java
  7. 144
      designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichTextPane.java

44
designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTooltipContentPane.java

@ -2,6 +2,7 @@ package com.fr.van.chart.designer.component;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIButtonGroup;
@ -32,7 +33,11 @@ import com.fr.van.chart.designer.component.format.ValueFormatPaneWithCheckBox;
import com.fr.van.chart.designer.component.format.ValueFormatPaneWithoutCheckBox;
import com.fr.van.chart.designer.component.format.VanChartFormatPaneWithCheckBox;
import com.fr.van.chart.designer.component.format.VanChartFormatPaneWithoutCheckBox;
import com.fr.van.chart.designer.component.richText.VanChartRichEditorPane;
import com.fr.van.chart.designer.component.richText.VanChartRichTextDialog;
import com.fr.van.chart.designer.component.richText.VanChartRichTextPane;
import com.fr.van.chart.designer.style.VanChartStylePane;
import org.nfunk.jep.function.Str;
import javax.swing.JComponent;
import javax.swing.JPanel;
@ -45,6 +50,8 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.List;
/**
* 数据点提示内容界面含有通用设置富文本编辑器自定义JS界面
@ -437,24 +444,27 @@ public class VanChartTooltipContentPane extends BasicBeanPane<AttrTooltipContent
}
private void fireRichEditor() {
final ModernUIPane<VanChartRichEditorPane.RichEditorModel> pane = VanChartRichEditorPane.createRichEditorPane(richText);
BasicDialog dialog = new VanChartRichEditorDialog(DesignerContext.getDesignerFrame(), pane);
final ModernUIPane<VanChartRichEditorPane.RichEditorModel> richEditorPane = VanChartRichEditorPane.createRichEditorPane(richText);
pane.populate(VanChartRichEditorPane.getRichEditorModel(richText));
BasicPane panel = new VanChartRichTextPane(parent, getDefaultFieldNames(), getTableFieldNames(), richEditorPane);
BasicDialog dialog = new VanChartRichTextDialog(DesignerContext.getDesignerFrame(), panel);
richEditorPane.populate(VanChartRichEditorPane.getRichEditorModel(richText));
dialog.addDialogActionListener(new DialogActionAdapter() {
public void doOk() {
VanChartRichEditorPane.RichEditorModel model = pane.update();
VanChartRichEditorPane.RichEditorModel model = richEditorPane.update();
String content = model.getContent();
updateLocalRichText(content, model.isAuto());
SwingUtilities.getWindowAncestor(pane).setVisible(false);
SwingUtilities.getWindowAncestor(richEditorPane).setVisible(false);
}
public void doCancel() {
SwingUtilities.getWindowAncestor(pane).setVisible(false);
SwingUtilities.getWindowAncestor(richEditorPane).setVisible(false);
}
});
@ -465,6 +475,28 @@ public class VanChartTooltipContentPane extends BasicBeanPane<AttrTooltipContent
}
}
private List<String> getDefaultFieldNames() {
List<String> fieldNames = new ArrayList<>();
fieldNames.add("分类");
fieldNames.add("系列");
fieldNames.add("值");
fieldNames.add("百分比");
return fieldNames;
}
private List<String> getTableFieldNames() {
List<String> fieldNames = new ArrayList<>();
fieldNames.add("字段A");
fieldNames.add("字段B");
fieldNames.add("字段C");
fieldNames.add("字段D");
return fieldNames;
}
private JPanel createHtmlPane() {
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;

124
designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartFieldAddPane.java

@ -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);
}
}

115
designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartFieldGroupPane.java

@ -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() {
}
};
}
}

15
designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartFieldListener.java

@ -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();
}

2
designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartRichEditorPane.java → designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichEditorPane.java

@ -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;

8
designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartRichEditorDialog.java → designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichTextDialog.java

@ -1,4 +1,4 @@
package com.fr.van.chart.designer.component;
package com.fr.van.chart.designer.component.richText;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.BasicPane;
@ -8,17 +8,17 @@ import com.fr.design.utils.gui.GUICoreUtils;
import java.awt.Dimension;
import java.awt.Frame;
public class VanChartRichEditorDialog extends BasicDialog {
public class VanChartRichTextDialog extends BasicDialog {
public static final Dimension DEFAULT = new Dimension(960, 600);
public VanChartRichEditorDialog(Frame parent, BasicPane pane) {
public VanChartRichTextDialog(Frame parent, BasicPane pane) {
super(parent, pane);
this.setTitle(Toolkit.i18nText("Fine-Design_Report_RichTextEditor"));
this.setBasicDialogSize(DEFAULT);
GUICoreUtils.centerWindow(this);
this.setResizable(true);
this.setResizable(false);
this.setModal(true);
}

144
designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichTextPane.java

@ -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…
Cancel
Save