Browse Source

去掉接口代码中instnceof,用泛型代替。

master
mengao 7 years ago
parent
commit
db283848a0
  1. 18
      designer_chart/src/com/fr/design/mainframe/chart/ChartsConfigPane.java
  2. 2
      designer_chart/src/com/fr/design/mainframe/chart/ChartsEditPane.java
  3. 24
      designer_chart/src/com/fr/design/mainframe/chart/DefaultChartsConfigPane.java

18
designer_chart/src/com/fr/design/mainframe/chart/ChartsConfigPane.java

@ -1,27 +1,39 @@
package com.fr.design.mainframe.chart;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.chart.chartattr.Charts;
import com.fr.general.Inter;
import com.fr.stable.StableUtils;
import javax.swing.*;
/**
* Created by mengao on 2017/5/16.
*/
public class ChartsConfigPane extends AbstractChartAttrPane {
public abstract class ChartsConfigPane <T extends Charts> extends AbstractChartAttrPane {
public final static String CHART_STYLE_TITLE = Inter.getLocText("Chart-Style_Name");
public abstract Class<? extends Charts> accptType();
@Override
public void populate(ChartCollection collection) {
if (StableUtils.classInstanceOf(collection.getSelectedChart().getClass(),accptType())) {
populate(collection, (T)collection.getSelectedChart());
}
}
protected abstract void populate(ChartCollection collection, T selectedChart);
@Override
public void update(ChartCollection collection) {
if (StableUtils.classInstanceOf(collection.getSelectedChart().getClass(),accptType())) {
update(collection, (T)collection.getSelectedChart());
}
}
protected abstract void update(ChartCollection collection, T selectedChart);
@Override
protected JPanel createContentPane() {
return new JPanel();

2
designer_chart/src/com/fr/design/mainframe/chart/ChartsEditPane.java

@ -20,7 +20,7 @@ public class ChartsEditPane extends ChartEditPane {
dataPane4SupportCell = new ChartDataPane(listener);
dataPane4SupportCell.setSupportCellData(true);
chartsConfigPane = new ChartsConfigPane();
chartsConfigPane = new DefaultChartsConfigPane();
paneList.add(dataPane4SupportCell);
paneList.add(chartsConfigPane);

24
designer_chart/src/com/fr/design/mainframe/chart/DefaultChartsConfigPane.java

@ -0,0 +1,24 @@
package com.fr.design.mainframe.chart;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.chart.chartattr.Charts;
/**
* Created by mengao on 2017/6/4.
*/
public class DefaultChartsConfigPane extends ChartsConfigPane {
@Override
public Class<? extends Charts> accptType() {
return null;
}
@Override
protected void populate(ChartCollection collection, Charts selectedChart) {
}
@Override
protected void update(ChartCollection collection, Charts selectedChart) {
}
}
Loading…
Cancel
Save