Browse Source

CHART-4027 系列+值 自定义相关celldata design

research/10.0
zheng 6 years ago
parent
commit
5c113a8dbb
  1. 106
      designer-chart/src/main/java/com/fr/design/chartx/component/AbstractChartDataCorrelationPane.java
  2. 55
      designer-chart/src/main/java/com/fr/design/chartx/component/CellDataSeriesValueFieldsPane.java
  3. 19
      designer-chart/src/main/java/com/fr/design/chartx/component/FieldEditorComponentWrapper.java
  4. 61
      designer-chart/src/main/java/com/fr/design/chartx/component/TinyFormulaPaneEditorComponent.java
  5. 16
      designer-chart/src/main/java/com/fr/design/chartx/fields/AbstractCellDataFieldsPane.java
  6. 41
      designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractCellDataFieldsWithSeriesValuePane.java
  7. 4
      designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractDataSetFieldsWithSeriesValuePane.java
  8. 9
      designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryCellDataFieldsPane.java
  9. 4
      designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryDataSetFieldsPane.java

106
designer-chart/src/main/java/com/fr/design/chartx/component/AbstractChartDataCorrelationPane.java

@ -0,0 +1,106 @@
package com.fr.design.chartx.component;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.frpane.UICorrelationPane;
import com.fr.design.gui.itable.UITable;
import com.fr.design.gui.itable.UITableEditor;
import com.fr.stable.StringUtils;
import javax.swing.JTable;
import javax.swing.event.ChangeEvent;
import java.awt.BorderLayout;
import java.awt.Component;
import java.util.List;
/**
* Created by shine on 2019/6/4.
*/
public abstract class AbstractChartDataCorrelationPane<T> extends BasicBeanPane<T> {
private FieldEditorComponentWrapper[] editorComponents;
private UICorrelationPane correlationPane;
public AbstractChartDataCorrelationPane() {
this.editorComponents = fieldEditorComponentWrappers();
String[] headers = new String[editorComponents.length];
for (int i = 0, len = editorComponents.length; i < len; i++) {
headers[i] = editorComponents[i].headerName();
}
initComps(headers);
}
protected abstract FieldEditorComponentWrapper[] fieldEditorComponentWrappers();
protected List<Object[]> update() {
return correlationPane.updateBean();
}
protected void populate(List<Object[]> list) {
correlationPane.populateBean(list);
}
@Override
public T updateBean() {
return null;
}
private void initComps(String[] headers) {
correlationPane = new UICorrelationPane(headers) {
public UITableEditor createUITableEditor() {
return new Editor();
}
protected UITable initUITable() {
return new UITable(columnCount) {
public UITableEditor createTableEditor() {
return createUITableEditor();
}
public void tableCellEditingStopped(ChangeEvent e) {
stopPaneEditing(e);
}
};
}
};
this.setLayout(new BorderLayout());
this.add(correlationPane, BorderLayout.CENTER);
}
private class Editor extends UITableEditor {
private Component currentComponent;
private FieldEditorComponentWrapper currentEditorWrapper;
public Object getCellEditorValue() {
return currentEditorWrapper.value(currentComponent);
}
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
if (column == table.getModel().getColumnCount()) {
return null;
}
correlationPane.stopCellEditing();
currentEditorWrapper = AbstractChartDataCorrelationPane.this.editorComponents[column];
currentComponent = currentEditorWrapper.createEditorComponent(correlationPane);
currentEditorWrapper.setValue(currentComponent, value);
return currentComponent;
}
}
@Override
protected String title4PopupWindow() {
return StringUtils.EMPTY;
}
}

55
designer-chart/src/main/java/com/fr/design/chartx/component/CellDataSeriesValueFieldsPane.java

@ -0,0 +1,55 @@
package com.fr.design.chartx.component;
import com.fr.chartx.data.field.ColumnField;
import com.fr.chartx.data.field.SeriesValueColumnFields;
import com.fr.chartx.data.field.SeriesValueField;
import com.fr.design.i18n.Toolkit;
import com.fr.general.GeneralUtils;
import java.util.ArrayList;
import java.util.List;
/**
* Created by shine on 2019/6/4.
*/
public class CellDataSeriesValueFieldsPane extends AbstractChartDataCorrelationPane<SeriesValueColumnFields> {
@Override
protected FieldEditorComponentWrapper[] fieldEditorComponentWrappers() {
return new FieldEditorComponentWrapper[]{
new TinyFormulaPaneEditorComponent(Toolkit.i18nText("Fine-Design_Chart_Series_Name")),
new TinyFormulaPaneEditorComponent(Toolkit.i18nText("Fine-Design_Chart_Series_Value"))
};
}
@Override
public void populateBean(SeriesValueColumnFields ob) {
List<Object[]> list = new ArrayList<Object[]>();
List<SeriesValueField> seriesValueFieldList = ob.getSeriesValueFieldList();
for (SeriesValueField seriesValueField : seriesValueFieldList) {
Object[] array = new Object[]{seriesValueField.getSeries().getFieldName(), seriesValueField.getValue().getFieldName()};
list.add(array);
}
populate(list);
}
@Override
public void updateBean(SeriesValueColumnFields ob) {
List<Object[]> list = update();
List<SeriesValueField> seriesValueFieldList = new ArrayList<SeriesValueField>();
for (Object[] objects : list) {
SeriesValueField seriesValueField = new SeriesValueField();
ColumnField series = new ColumnField(GeneralUtils.objectToString(objects[0]));
ColumnField value = new ColumnField(GeneralUtils.objectToString(objects[1]));
seriesValueField.setSeries(series);
seriesValueField.setValue(value);
seriesValueFieldList.add(seriesValueField);
}
ob.setSeriesValueFieldList(seriesValueFieldList);
}
}

19
designer-chart/src/main/java/com/fr/design/chartx/component/FieldEditorComponentWrapper.java

@ -0,0 +1,19 @@
package com.fr.design.chartx.component;
import com.fr.design.gui.frpane.UICorrelationPane;
import java.awt.Component;
/**
* Created by shine on 2019/6/4.
*/
public interface FieldEditorComponentWrapper<T extends Component> {
String headerName();
T createEditorComponent(UICorrelationPane parent);
Object value(T t);
void setValue(T t, Object o);
}

61
designer-chart/src/main/java/com/fr/design/chartx/component/TinyFormulaPaneEditorComponent.java

@ -0,0 +1,61 @@
package com.fr.design.chartx.component;
import com.fr.base.BaseFormula;
import com.fr.base.Utils;
import com.fr.design.constants.UIConstants;
import com.fr.design.event.UIObserverListener;
import com.fr.design.formula.TinyFormulaPane;
import com.fr.design.gui.frpane.UICorrelationPane;
/**
* Created by shine on 2019/6/4.
*/
public class TinyFormulaPaneEditorComponent implements FieldEditorComponentWrapper<TinyFormulaPane> {
private String header;
public TinyFormulaPaneEditorComponent(String header) {
this.header = header;
}
@Override
public String headerName() {
return this.header;
}
@Override
public TinyFormulaPane createEditorComponent(final UICorrelationPane parent) {
TinyFormulaPane editorComponent = new TinyFormulaPane() {
@Override
public void okEvent() {
parent.stopCellEditing();
parent.fireTargetChanged();
}
@Override
protected void populateTextField(BaseFormula fm) {
formulaTextField.setText(fm.getContent());
}
};
editorComponent.setBackground(UIConstants.FLESH_BLUE);
editorComponent.getUITextField().registerChangeListener(new UIObserverListener() {
@Override
public void doChange() {
parent.fireTargetChanged();
}
});
return editorComponent;
}
@Override
public Object value(TinyFormulaPane formulaPane) {
return formulaPane.getUITextField().getText();
}
@Override
public void setValue(TinyFormulaPane formulaPane, Object o) {
formulaPane.getUITextField().setText(Utils.objectToString(o));
}
}

16
designer-chart/src/main/java/com/fr/design/chartx/fields/AbstractCellDataFieldsPane.java

@ -31,19 +31,23 @@ public abstract class AbstractCellDataFieldsPane<T extends AbstractColumnFieldCo
this.setLayout(new BorderLayout(0, 6));
this.add(addNorthPane(), BorderLayout.NORTH);
this.add(addCenterPane(), BorderLayout.CENTER);
this.add(addSouthPane(), BorderLayout.SOUTH);
this.add(createNorthPane(), BorderLayout.NORTH);
this.add(createCenterPane(), BorderLayout.CENTER);
this.add(createSouthPane(), BorderLayout.SOUTH);
this.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 8));
}
protected JPanel addCenterPane() {
protected JPanel createCenterPane() {
String[] labels = fieldLabels();
Component[] formulaPanes = fieldComponents();
int len = Math.min(labels.length, formulaPanes.length);
if (len == 0) {
return null;
}
Component[][] components = new Component[len][2];
for (int i = 0; i < len; i++) {
components[i] = new Component[]{new UILabel(labels[i], SwingConstants.LEFT), formulaPanes[i]};
@ -59,11 +63,11 @@ public abstract class AbstractCellDataFieldsPane<T extends AbstractColumnFieldCo
}
protected JPanel addNorthPane() {
protected JPanel createNorthPane() {
return new JPanel();
}
protected JPanel addSouthPane() {
protected JPanel createSouthPane() {
return new JPanel();
}

41
designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractCellDataFieldsWithSeriesValuePane.java

@ -0,0 +1,41 @@
package com.fr.design.chartx.fields.diff;
import com.fr.chartx.data.field.diff.AbstractColumnFieldCollectionWithSeriesValue;
import com.fr.design.chartx.component.CellDataSeriesValueFieldsPane;
import com.fr.design.chartx.fields.AbstractCellDataFieldsPane;
import javax.swing.JPanel;
import java.awt.BorderLayout;
/**
* Created by shine on 2019/6/4.
*/
public abstract class AbstractCellDataFieldsWithSeriesValuePane<T extends AbstractColumnFieldCollectionWithSeriesValue>
extends AbstractCellDataFieldsPane<T> {
private CellDataSeriesValueFieldsPane seriesValueFieldsPane;
@Override
protected JPanel createCenterPane() {
JPanel normalCenter = super.createCenterPane();
seriesValueFieldsPane = new CellDataSeriesValueFieldsPane();
if (normalCenter != null) {
JPanel panel = new JPanel(new BorderLayout());
panel.add(normalCenter, BorderLayout.CENTER);
panel.add(seriesValueFieldsPane, BorderLayout.SOUTH);
return panel;
} else {
return seriesValueFieldsPane;
}
}
protected void populateSeriesValuePane(AbstractColumnFieldCollectionWithSeriesValue t) {
seriesValueFieldsPane.populateBean(t.getSeriesValueColumnFields());
}
protected void updateSeriesValuePane(AbstractColumnFieldCollectionWithSeriesValue t) {
seriesValueFieldsPane.updateBean(t.getSeriesValueColumnFields());
}
}

4
designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractDataSetFieldsWithSeriesValuePane.java

@ -50,11 +50,11 @@ public abstract class AbstractDataSetFieldsWithSeriesValuePane<T extends Abstrac
seriesValueFieldComboBoxPane.refreshBoxListWithSelectTableData(columnNameList);
}
protected void populateCustomPane(AbstractColumnFieldCollectionWithSeriesValue t) {
protected void populateSeriesValuePane(AbstractColumnFieldCollectionWithSeriesValue t) {
seriesValueFieldComboBoxPane.populateBean(t.getSeriesValueColumnFields());
}
protected void updateCustomPane(AbstractColumnFieldCollectionWithSeriesValue t) {
protected void updateSeriesValuePane(AbstractColumnFieldCollectionWithSeriesValue t) {
seriesValueFieldComboBoxPane.updateBean(t.getSeriesValueColumnFields());
}
}

9
designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryCellDataFieldsPane.java

@ -3,7 +3,6 @@ package com.fr.design.chartx.fields.diff;
import com.fr.chartx.data.field.ColumnField;
import com.fr.chartx.data.field.diff.MultiCategoryColumnFieldCollection;
import com.fr.design.chartx.component.MultiTinyFormulaPane;
import com.fr.design.chartx.fields.AbstractCellDataFieldsPane;
import com.fr.design.formula.TinyFormulaPane;
import javax.swing.JPanel;
@ -12,7 +11,7 @@ import java.util.List;
/**
* Created by shine on 2019/4/12.
*/
public class MultiCategoryCellDataFieldsPane extends AbstractCellDataFieldsPane<MultiCategoryColumnFieldCollection> {
public class MultiCategoryCellDataFieldsPane extends AbstractCellDataFieldsWithSeriesValuePane<MultiCategoryColumnFieldCollection> {
private MultiTinyFormulaPane multiCategoryPane;
@ -23,7 +22,7 @@ public class MultiCategoryCellDataFieldsPane extends AbstractCellDataFieldsPane<
}
@Override
protected JPanel addNorthPane() {
protected JPanel createNorthPane() {
createMultiFormulaPane();
@ -50,6 +49,8 @@ public class MultiCategoryCellDataFieldsPane extends AbstractCellDataFieldsPane<
List<ColumnField> categoryList = ob.getCategoryList();
multiCategoryPane.populate(categoryList);
populateSeriesValuePane(ob);
}
@Override
@ -60,6 +61,8 @@ public class MultiCategoryCellDataFieldsPane extends AbstractCellDataFieldsPane<
multiCategoryPane.update(categoryList);
updateSeriesValuePane(fieldCollection);
return fieldCollection;
}
}

4
designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryDataSetFieldsPane.java

@ -46,7 +46,7 @@ public class MultiCategoryDataSetFieldsPane extends AbstractDataSetFieldsWithSer
multiCategoryPane.populate(categoryList);
populateCustomPane(ob);
populateSeriesValuePane(ob);
}
@Override
@ -57,7 +57,7 @@ public class MultiCategoryDataSetFieldsPane extends AbstractDataSetFieldsWithSer
multiCategoryPane.update(categoryList);
updateCustomPane(columnFieldCollection);
updateSeriesValuePane(columnFieldCollection);
return columnFieldCollection;
}

Loading…
Cancel
Save