Browse Source

CHART-3073 字段下拉框包含无这个选项 && CHART-3060 中文无和英文none

final/10.0
zheng 6 years ago
parent
commit
740ae4fb47
  1. 16
      designer-base/src/main/java/com/fr/design/gui/icombobox/UIComboBox.java
  2. 12
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/DataPaneHelper.java
  3. 23
      designer-chart/src/main/java/com/fr/extended/chart/AbstractExtendedChartTableDataPane.java
  4. 32
      designer-chart/src/main/java/com/fr/extended/chart/ExtendedCustomFieldComboBoxPane.java
  5. 44
      designer-chart/src/main/java/com/fr/extended/chart/UIComboBoxWithNone.java

16
designer-base/src/main/java/com/fr/design/gui/icombobox/UIComboBox.java

@ -15,6 +15,7 @@ import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.List;
import java.util.Vector;
/**
@ -131,6 +132,21 @@ public class UIComboBox extends JComboBox implements UIObserver, GlobalNameObser
return new Dimension(super.getPreferredSize().width + SIZE5, SIZE);
}
public void refreshBoxItems(List list) {
Object ob = getSelectedItem();
removeAllItems();
for (Object o : list) {
addItem(o);
}
getModel().setSelectedItem(ob);
}
public void clearBoxItems() {
removeAllItems();
}
/**
* 鼠标进入事件
*/

12
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/DataPaneHelper.java

@ -21,15 +21,7 @@ public class DataPaneHelper {
return;
}
Object ob = box.getSelectedItem();
box.removeAllItems();
int length = list.size();
for (int i = 0; i < length; i++) {
box.addItem(list.get(i));
}
box.getModel().setSelectedItem(ob);
box.refreshBoxItems(list);
}
/**
@ -39,7 +31,7 @@ public class DataPaneHelper {
*/
public static void clearBoxItems(UIComboBox box) {
if (box != null) {
box.removeAllItems();
box.clearBoxItems();
}
}

23
designer-chart/src/main/java/com/fr/extended/chart/AbstractExtendedChartTableDataPane.java

@ -10,13 +10,14 @@ import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.chart.gui.data.CalculateComboBox;
import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane;
import com.fr.general.GeneralUtils;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import java.awt.BorderLayout;
import java.awt.Component;
import java.util.Arrays;
import java.util.List;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
/**
* Created by shine on 2018/3/2.
@ -52,8 +53,8 @@ public abstract class AbstractExtendedChartTableDataPane<T extends AbstractDataC
this.setBorder(BorderFactory.createEmptyBorder(2, 24, 0, 15));
this.add(panel, BorderLayout.NORTH);
if (hasCustomFieldPane()) {
customFieldComboBoxPane = new ExtendedCustomFieldComboBoxPane(hasNoneItem());
customFieldComboBoxPane = createExtendedCustomFieldComboBoxPane();
if (customFieldComboBoxPane != null) {
this.add(customFieldComboBoxPane, BorderLayout.CENTER);
}
@ -64,12 +65,8 @@ public abstract class AbstractExtendedChartTableDataPane<T extends AbstractDataC
return new JPanel();
}
protected boolean hasCustomFieldPane() {
return false;
}
protected boolean hasNoneItem() {
return false;
protected ExtendedCustomFieldComboBoxPane createExtendedCustomFieldComboBoxPane() {
return null;
}
protected Component[] fieldComponents() {
@ -99,7 +96,7 @@ public abstract class AbstractExtendedChartTableDataPane<T extends AbstractDataC
if (dataConfig != null) {
populate((T) dataConfig);
if (hasCustomFieldPane()) {
if (customFieldComboBoxPane != null) {
customFieldComboBoxPane.populateBean(dataConfig);
}
}
@ -118,7 +115,7 @@ public abstract class AbstractExtendedChartTableDataPane<T extends AbstractDataC
ExtendedTableDataSet dataSet = new ExtendedTableDataSet();
dataSet.setDataConfig(update());
if (hasCustomFieldPane()) {
if (customFieldComboBoxPane != null) {
customFieldComboBoxPane.updateBean(dataSet.getDataConfig());
}

32
designer-chart/src/main/java/com/fr/extended/chart/ExtendedCustomFieldComboBoxPane.java

@ -11,12 +11,16 @@ import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itable.UITable;
import com.fr.design.gui.itable.UITableEditor;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.chart.gui.data.CalculateComboBox;
import com.fr.design.mainframe.chart.gui.data.table.DataPaneHelper;
import com.fr.stable.StringUtils;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.SwingConstants;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
@ -26,10 +30,6 @@ import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.SwingConstants;
/**
* Created by shine on 2018/9/12.
@ -39,16 +39,10 @@ public class ExtendedCustomFieldComboBoxPane extends UIComboBoxPane<AbstractData
private UseFieldValuePane useFieldValuePane;
private boolean hasNoneItem = false;
private CustomFieldNamePane customFieldNamePane;
private List<String> fieldList = new ArrayList<String>();
public ExtendedCustomFieldComboBoxPane(boolean hasNoneItem) {
this.hasNoneItem = hasNoneItem;
}
@Override
protected void initLayout() {
this.setLayout(new BorderLayout(0, 6));
@ -76,6 +70,10 @@ public class ExtendedCustomFieldComboBoxPane extends UIComboBoxPane<AbstractData
return StringUtils.EMPTY;
}
protected boolean valueComboBoxHasNone() {
return false;
}
public void checkBoxUse(boolean hasUse) {
jcb.setEnabled(hasUse);
useFieldValuePane.checkBoxUse(hasUse);
@ -125,11 +123,7 @@ public class ExtendedCustomFieldComboBoxPane extends UIComboBoxPane<AbstractData
private void initComponents() {
series = new UIComboBox();
value = new UIComboBox();
if (hasNoneItem) {
value.addItem(Toolkit.i18nText("Fine-Design_Chart_Use_None"));
}
value = valueComboBoxHasNone() ? new UIComboBoxWithNone() : new UIComboBox();
function = new CalculateComboBox();
@ -158,17 +152,11 @@ public class ExtendedCustomFieldComboBoxPane extends UIComboBoxPane<AbstractData
public void clearAllBoxList() {
DataPaneHelper.clearBoxItems(series);
DataPaneHelper.clearBoxItems(value);
if (hasNoneItem) {
value.addItem(Toolkit.i18nText("Fine-Design_Chart_Use_None"));
}
}
public void refreshBoxListWithSelectTableData(List columnNameList) {
DataPaneHelper.refreshBoxItems(series, columnNameList);
DataPaneHelper.refreshBoxItems(value, columnNameList);
if (hasNoneItem) {
value.addItem(Toolkit.i18nText("Fine-Design_Chart_Use_None"));
}
}
@Override

44
designer-chart/src/main/java/com/fr/extended/chart/UIComboBoxWithNone.java

@ -0,0 +1,44 @@
package com.fr.extended.chart;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.i18n.Toolkit;
import java.util.List;
/**
* Created by shine on 2018/9/27.
*/
public class UIComboBoxWithNone extends UIComboBox {
private static String getNoneLocaleString() {
return Toolkit.i18nText("Fine-Design_Chart_Use_None");
}
@Override
public void refreshBoxItems(List list) {
super.refreshBoxItems(list);
addNoneItem();
}
@Override
public void clearBoxItems() {
super.clearBoxItems();
addNoneItem();
}
private void addNoneItem() {
addItem(getNoneLocaleString());
}
@Override
public void setSelectedItem(Object anObject) {
super.setSelectedItem(anObject);
if (getSelectedIndex() == -1) {//找不到的都选中无。中文的无 英文下是none。
super.setSelectedItem(getNoneLocaleString());
}
}
}
Loading…
Cancel
Save