Browse Source

富文本编辑器增加字段名的类属性

research/11.0
Qinghui.Liu 4 years ago
parent
commit
9fa14e369f
  1. 2
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartOtherPane.java
  2. 44
      designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTooltipContentPane.java
  3. 7
      designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartFieldListPane.java
  4. 60
      designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichEditorPane.java
  5. 11
      designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichTextPane.java
  6. 55
      designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartStylePane.java

2
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartOtherPane.java

@ -13,6 +13,7 @@ import com.fr.design.mainframe.chart.gui.other.ChartConditionAttrPane;
import com.fr.design.mainframe.chart.gui.other.ChartInteractivePane;
import com.fr.design.mainframe.chart.gui.type.ChartTabPane;
import com.fr.design.mainframe.chart.info.ChartInfoCollector;
import com.fr.van.chart.designer.component.richText.VanChartRichEditorPane;
import javax.swing.JPanel;
import java.util.ArrayList;
@ -110,6 +111,7 @@ public class ChartOtherPane extends AbstractChartAttrPane {
public void populateBean(Chart chart) {
interactivePane.populateBean(chart);
if (ChartOtherPane.this.isHaveCondition()) {
VanChartRichEditorPane.refreshFieldNames(chart);
conditionAttrPane.populateBean(chart);
}
}

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

@ -36,7 +36,6 @@ import com.fr.van.chart.designer.component.format.SeriesNameFormatPaneWithoutChe
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.VanChartRichEditorModel;
import com.fr.van.chart.designer.component.richText.VanChartRichEditorPane;
import com.fr.van.chart.designer.component.richText.VanChartRichTextDialog;
@ -445,7 +444,7 @@ public class VanChartTooltipContentPane extends BasicBeanPane<AttrTooltipContent
AttrTooltipRichText richText = this.richTextTooltipContent.getRichTextAttr();
ModernUIPane<VanChartRichEditorModel> richEditorPane = VanChartRichEditorPane.createRichEditorPane(richText);
VanChartRichTextPane richTextPane = this.createRichTextPane(getTableFieldNames(), richEditorPane);
VanChartRichTextPane richTextPane = this.createRichTextPane(richEditorPane);
BasicDialog richTextDialog = new VanChartRichTextDialog(DesignerContext.getDesignerFrame(), richTextPane);
@ -483,19 +482,11 @@ public class VanChartTooltipContentPane extends BasicBeanPane<AttrTooltipContent
}
}
private List<String> getTableFieldNames() {
if (parent == null) {
return null;
protected VanChartRichTextPane createRichTextPane(ModernUIPane<VanChartRichEditorModel> richEditorPane) {
return new VanChartRichTextPane(richEditorPane);
}
return parent.getDataModelColumnNames();
}
protected VanChartRichTextPane createRichTextPane(List<String> tableFieldNames, ModernUIPane<VanChartRichEditorModel> richEditorPane) {
return new VanChartRichTextPane(tableFieldNames, richEditorPane);
}
protected void refreshRichTextFormat(AttrTooltipRichText richText) {
protected void refreshRichTextParams(AttrTooltipRichText richText) {
String[] fieldNames = new String[]{
Toolkit.i18nText("Fine-Design_Chart_Category_Use_Name"),
Toolkit.i18nText("Fine-Design_Chart_Series_Name"),
@ -516,7 +507,7 @@ public class VanChartTooltipContentPane extends BasicBeanPane<AttrTooltipContent
params.put(fieldNames[i], fieldFormats[i].getJs());
}
List<String> tableFieldNames = this.getTableFieldNames();
List<String> tableFieldNames = VanChartRichEditorPane.getFieldNames();
if (tableFieldNames != null) {
for (String fieldName : tableFieldNames) {
@ -757,30 +748,13 @@ public class VanChartTooltipContentPane extends BasicBeanPane<AttrTooltipContent
}
protected void populateRichEditor(AttrTooltipContent attrTooltipContent) {
VanChartFormatPaneWithoutCheckBox[] formatPaneGroup = new VanChartFormatPaneWithoutCheckBox[]{
richTextCategoryNameFormatPane,
richTextSeriesNameFormatPane,
richTextValueFormatPane,
richTextPercentFormatPane,
richTextChangedValueFormatPane,
richTextChangedPercentFormatPane
};
AttrTooltipFormat[] formatGroup = new AttrTooltipFormat[]{
attrTooltipContent.getRichTextCategoryFormat(),
attrTooltipContent.getRichTextSeriesFormat(),
attrTooltipContent.getRichTextValueFormat(),
attrTooltipContent.getRichTextPercentFormat(),
attrTooltipContent.getRichTextChangedValueFormat(),
attrTooltipContent.getRichTextChangedPercentFormat()
};
if (parent != null) {
parent.refreshTableFieldNames();
}
updateTooltipFormat(richTextTooltipContent, attrTooltipContent);
// populateRichTextFormat(richTextTooltipContent.getRichTextAttr());
refreshRichTextFormat(richTextTooltipContent.getRichTextAttr());
refreshRichTextParams(richTextTooltipContent.getRichTextAttr());
populateRichText(attrTooltipContent.getRichTextAttr());
checkRichEditorState(attrTooltipContent);
}

7
designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartFieldListPane.java

@ -48,10 +48,11 @@ public class VanChartFieldListPane extends JPanel {
private VanChartFieldListener fieldListener;
public VanChartFieldListPane(List<String> tableFieldNameList, VanChartFieldAttrPane fieldAttrPane,
ModernUIPane<VanChartRichEditorModel> richEditorPane) {
public VanChartFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane<VanChartRichEditorModel> richEditorPane) {
this.tableFieldNameList = tableFieldNameList == null ? new ArrayList<>() : tableFieldNameList;
List<String> richEditorFieldNames = VanChartRichEditorPane.getFieldNames();
this.tableFieldNameList = richEditorFieldNames == null ? new ArrayList<>() : richEditorFieldNames;
this.fieldAttrPane = fieldAttrPane;
this.richEditorPane = richEditorPane;

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

@ -1,8 +1,19 @@
package com.fr.van.chart.designer.component.richText;
import com.fr.base.TableData;
import com.fr.base.chart.chartdata.TopDefinitionProvider;
import com.fr.chart.chartattr.Chart;
import com.fr.chart.chartdata.MoreNameCDDefinition;
import com.fr.chart.chartdata.OneValueCDDefinition;
import com.fr.data.TableDataSource;
import com.fr.data.impl.EmbeddedTableData;
import com.fr.design.DesignModelAdapter;
import com.fr.design.DesignerEnvManager;
import com.fr.design.data.DesignTableDataManager;
import com.fr.design.ui.ModernUIPane;
import com.fr.general.ComparatorUtils;
import com.fr.general.IOUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.chart.base.AttrTooltipRichText;
import com.fr.plugin.chart.type.TextAlign;
import com.fr.stable.StringUtils;
@ -11,6 +22,7 @@ import com.teamdev.jxbrowser.chromium.JSValue;
import com.teamdev.jxbrowser.chromium.events.ScriptContextAdapter;
import com.teamdev.jxbrowser.chromium.events.ScriptContextEvent;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@ -26,6 +38,54 @@ public class VanChartRichEditorPane {
private static ModernUIPane<VanChartRichEditorModel> richEditorPane;
private static Browser browser;
private static List<String> fieldNames;
public static List<String> getFieldNames() {
return fieldNames;
}
public static void refreshFieldNames(Chart chart) {
VanChartRichEditorPane.fieldNames = null;
if (chart == null) {
return;
}
TopDefinitionProvider definition = chart.getFilterDefinition();
if (definition == null) {
return;
}
DesignModelAdapter adapter = DesignModelAdapter.getCurrentModelAdapter();
TableDataSource tableDataSource = adapter == null ? null : adapter.getBook();
TableData tableData = null;
if (ComparatorUtils.equals(definition.getDataDefinitionType(), OneValueCDDefinition.DEFINITION_TYPE)) {
OneValueCDDefinition oneValueCDDefinition = (OneValueCDDefinition) definition;
tableData = oneValueCDDefinition.getTableData();
}
if (ComparatorUtils.equals(definition.getDataDefinitionType(), MoreNameCDDefinition.DEFINITION_TYPE)) {
MoreNameCDDefinition moreNameCDDefinition = (MoreNameCDDefinition) definition;
tableData = moreNameCDDefinition.getTableData();
}
if (tableData == null) {
return;
}
try {
EmbeddedTableData embeddedTableData = DesignTableDataManager.previewTableDataNotNeedInputParameters(tableDataSource,
tableData, TableData.RESULT_NOT_NEED, false);
List<String> fieldNames = DesignTableDataManager.getColumnNamesByTableData(embeddedTableData);
VanChartRichEditorPane.fieldNames = fieldNames;
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
public static ModernUIPane<VanChartRichEditorModel> createRichEditorPane(AttrTooltipRichText richEditor) {
VanChartRichEditorModel model = getRichEditorModel(richEditor);

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

@ -11,7 +11,6 @@ import javax.swing.JPanel;
import javax.swing.JScrollPane;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.util.List;
// 标签提示中的富文本面板,包含字段设置和富文本编辑器
public class VanChartRichTextPane extends BasicBeanPane<AttrTooltipContent> {
@ -25,10 +24,9 @@ public class VanChartRichTextPane extends BasicBeanPane<AttrTooltipContent> {
private VanChartFieldListPane fieldListPane;
private VanChartFieldAttrPane fieldAttrPane;
public VanChartRichTextPane(List<String> tableFieldNames, ModernUIPane<VanChartRichEditorModel> richEditor) {
public VanChartRichTextPane(ModernUIPane<VanChartRichEditorModel> richEditor) {
fieldAttrPane = new VanChartFieldAttrPane();
fieldListPane = createFieldListPane(tableFieldNames, fieldAttrPane, richEditor);
fieldListPane = createFieldListPane(fieldAttrPane, richEditor);
this.setLayout(new BorderLayout());
this.add(createFieldContentPane(), BorderLayout.CENTER);
@ -59,9 +57,8 @@ public class VanChartRichTextPane extends BasicBeanPane<AttrTooltipContent> {
return fieldPane;
}
protected VanChartFieldListPane createFieldListPane(List<String> tableFieldNames, VanChartFieldAttrPane fieldAttrPane,
ModernUIPane<VanChartRichEditorModel> richEditor) {
return new VanChartFieldListPane(tableFieldNames, fieldAttrPane, richEditor);
protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane<VanChartRichEditorModel> richEditor) {
return new VanChartFieldListPane(fieldAttrPane, richEditor);
}
private JPanel createRichEditorPane(JPanel richEditor) {

55
designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartStylePane.java

@ -1,21 +1,11 @@
package com.fr.van.chart.designer.style;
import com.fr.base.TableData;
import com.fr.base.chart.chartdata.TopDefinitionProvider;
import com.fr.chart.chartattr.Chart;
import com.fr.chart.chartattr.Plot;
import com.fr.chart.chartdata.MoreNameCDDefinition;
import com.fr.chart.chartdata.OneValueCDDefinition;
import com.fr.data.TableDataSource;
import com.fr.data.impl.EmbeddedTableData;
import com.fr.design.DesignModelAdapter;
import com.fr.design.data.DesignTableDataManager;
import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.frpane.AttributeChangeListener;
import com.fr.design.mainframe.chart.gui.ChartStylePane;
import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.chart.attr.plot.VanChartAxisPlot;
import com.fr.van.chart.designer.component.richText.VanChartRichEditorPane;
import com.fr.van.chart.designer.style.axis.VanChartAxisPane;
import com.fr.van.chart.designer.style.background.VanChartAreaPane;
import com.fr.van.chart.designer.style.datasheet.VanChartDataSheetPane;
@ -87,46 +77,7 @@ public class VanChartStylePane extends ChartStylePane {
paneList.add(new VanChartTooltipPane(VanChartStylePane.this));
}
public List<String> getDataModelColumnNames() {
Chart chart = getChart();
if (chart == null) {
return null;
}
TopDefinitionProvider definition = chart.getFilterDefinition();
if (definition == null) {
return null;
}
DesignModelAdapter adapter = DesignModelAdapter.getCurrentModelAdapter();
TableDataSource tableDataSource = adapter == null ? null : adapter.getBook();
TableData tableData = null;
if (ComparatorUtils.equals(definition.getDataDefinitionType(), OneValueCDDefinition.DEFINITION_TYPE)) {
OneValueCDDefinition oneValueCDDefinition = (OneValueCDDefinition) definition;
tableData = oneValueCDDefinition.getTableData();
}
if (ComparatorUtils.equals(definition.getDataDefinitionType(), MoreNameCDDefinition.DEFINITION_TYPE)) {
MoreNameCDDefinition moreNameCDDefinition = (MoreNameCDDefinition) definition;
tableData = moreNameCDDefinition.getTableData();
}
if (tableData == null) {
return null;
}
try {
EmbeddedTableData embeddedTableData = DesignTableDataManager.previewTableDataNotNeedInputParameters(tableDataSource,
tableData, TableData.RESULT_NOT_NEED, false);
return DesignTableDataManager.getColumnNamesByTableData(embeddedTableData);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
return null;
}
public void refreshTableFieldNames() {
VanChartRichEditorPane.refreshFieldNames(getChart());
}
}
Loading…
Cancel
Save