|
|
|
@ -1,12 +1,17 @@
|
|
|
|
|
package com.fr.van.chart.designer.component.richText; |
|
|
|
|
|
|
|
|
|
import com.fr.data.util.function.AbstractDataFunction; |
|
|
|
|
import com.fr.data.util.function.DataFunction; |
|
|
|
|
import com.fr.design.event.UIObserverListener; |
|
|
|
|
import com.fr.design.i18n.Toolkit; |
|
|
|
|
import com.fr.design.ui.ModernUIPane; |
|
|
|
|
import com.fr.general.ComparatorUtils; |
|
|
|
|
import com.fr.log.FineLoggerFactory; |
|
|
|
|
import com.fr.plugin.chart.base.AttrTooltipContent; |
|
|
|
|
import com.fr.plugin.chart.base.TableFieldCollection; |
|
|
|
|
import com.fr.plugin.chart.base.TableFieldDefinition; |
|
|
|
|
import com.fr.plugin.chart.base.format.AttrTooltipCategoryFormat; |
|
|
|
|
import com.fr.plugin.chart.base.format.AttrTooltipFieldFormat; |
|
|
|
|
import com.fr.plugin.chart.base.format.AttrTooltipFormat; |
|
|
|
|
import com.fr.plugin.chart.base.format.AttrTooltipPercentFormat; |
|
|
|
|
import com.fr.plugin.chart.base.format.AttrTooltipSeriesFormat; |
|
|
|
@ -23,6 +28,7 @@ import java.awt.event.ActionListener;
|
|
|
|
|
import java.text.Format; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
public class VanChartFieldListPane extends JPanel { |
|
|
|
|
|
|
|
|
@ -38,13 +44,14 @@ public class VanChartFieldListPane extends JPanel {
|
|
|
|
|
private ModernUIPane<VanChartRichEditorModel> richEditorPane; |
|
|
|
|
private List<String> tableFieldNameList; |
|
|
|
|
private List<VanChartFieldButton> tableFieldButtonList = new ArrayList<>(); |
|
|
|
|
private TableFieldCollection tableFieldCollection = new TableFieldCollection(); |
|
|
|
|
|
|
|
|
|
private VanChartFieldListener fieldListener; |
|
|
|
|
|
|
|
|
|
public VanChartFieldListPane(List<String> tableFieldNameList, VanChartFieldAttrPane fieldAttrPane, |
|
|
|
|
ModernUIPane<VanChartRichEditorModel> richEditorPane) { |
|
|
|
|
|
|
|
|
|
this.tableFieldNameList = tableFieldNameList; |
|
|
|
|
this.tableFieldNameList = tableFieldNameList == null ? new ArrayList<>() : tableFieldNameList; |
|
|
|
|
|
|
|
|
|
this.fieldAttrPane = fieldAttrPane; |
|
|
|
|
this.richEditorPane = richEditorPane; |
|
|
|
@ -104,7 +111,7 @@ public class VanChartFieldListPane extends JPanel {
|
|
|
|
|
tableField.setLayout(new GridLayout(0, 1, 1, 0)); |
|
|
|
|
|
|
|
|
|
for (String name : tableFieldNameList) { |
|
|
|
|
VanChartFieldButton fieldButton = new VanChartFieldButton(name, getTableTooltipFormat(name), true, fieldListener); |
|
|
|
|
VanChartFieldButton fieldButton = new VanChartFieldButton(name, new AttrTooltipFieldFormat(name), true, fieldListener); |
|
|
|
|
|
|
|
|
|
tableField.add(fieldButton); |
|
|
|
|
tableFieldButtonList.add(fieldButton); |
|
|
|
@ -115,11 +122,6 @@ public class VanChartFieldListPane extends JPanel {
|
|
|
|
|
return TableLayout4VanChartHelper.createExpandablePaneWithTitleTopGap("数据集字段", tableField); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 生成新增字段对应的format
|
|
|
|
|
private AttrTooltipFormat getTableTooltipFormat(String fieldName) { |
|
|
|
|
return new AttrTooltipCategoryFormat(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected List<VanChartFieldButton> getDefaultFieldButtonList() { |
|
|
|
|
List<VanChartFieldButton> defaultFieldButtonList = new ArrayList<>(); |
|
|
|
|
|
|
|
|
@ -180,6 +182,16 @@ public class VanChartFieldListPane extends JPanel {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void addSelectedField(String fieldName, String fieldId) { |
|
|
|
|
if (tableFieldNameList.contains(fieldName)) { |
|
|
|
|
int index = tableFieldNameList.indexOf(fieldName); |
|
|
|
|
|
|
|
|
|
VanChartFieldButton fieldButton = tableFieldButtonList.get(index); |
|
|
|
|
Format fieldFormat = fieldButton.getFormat(); |
|
|
|
|
DataFunction dataFunction = fieldButton.getDataFunction(); |
|
|
|
|
|
|
|
|
|
tableFieldCollection.addFieldDefinition(fieldName, new TableFieldDefinition(fieldName, fieldFormat, dataFunction)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
VanChartRichEditorModel model = richEditorPane.update(); |
|
|
|
|
model.setAddition(fieldName); |
|
|
|
|
VanChartRichEditorPane.richEditorAddField(model); |
|
|
|
@ -264,7 +276,35 @@ public class VanChartFieldListPane extends JPanel {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void populateTableField(AttrTooltipContent tooltipContent) { |
|
|
|
|
TableFieldCollection fieldCollection = tooltipContent.getFieldCollection(); |
|
|
|
|
|
|
|
|
|
if (fieldCollection == null) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Map<String, TableFieldDefinition> fieldDefinitionGroup = fieldCollection.getFieldNameFormulaMap(); |
|
|
|
|
|
|
|
|
|
if (fieldDefinitionGroup == null || fieldDefinitionGroup.isEmpty()) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this.tableFieldCollection = new TableFieldCollection(); |
|
|
|
|
|
|
|
|
|
for (int i = 0, len = tableFieldNameList.size(); i < len; i++) { |
|
|
|
|
String fieldName = tableFieldNameList.get(i); |
|
|
|
|
VanChartFieldButton fieldButton = tableFieldButtonList.get(i); |
|
|
|
|
TableFieldDefinition fieldDefinition = fieldDefinitionGroup.get(fieldName); |
|
|
|
|
|
|
|
|
|
if (fieldDefinitionGroup.containsKey(fieldName)) { |
|
|
|
|
Format fieldFormat = fieldDefinition.getFormat(); |
|
|
|
|
DataFunction dataFunction = fieldDefinition.getDataFunction(); |
|
|
|
|
|
|
|
|
|
fieldButton.setFormat(fieldFormat); |
|
|
|
|
fieldButton.setDataFunction(dataFunction); |
|
|
|
|
|
|
|
|
|
this.tableFieldCollection.addFieldDefinition(fieldName, new TableFieldDefinition(fieldName, fieldFormat, dataFunction)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void update(AttrTooltipContent tooltipContent) { |
|
|
|
@ -280,7 +320,11 @@ public class VanChartFieldListPane extends JPanel {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void updateTableField(AttrTooltipContent tooltipContent) { |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
tooltipContent.setFieldCollection(this.tableFieldCollection); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void updateButtonFormat(VanChartFieldButton button, AttrTooltipFormat format) { |
|
|
|
|