Browse Source

REPORT-2623 树数据集在菜单栏那边预览和在左侧目录树下面预览, 列数不一样

master
hzzz 8 years ago
parent
commit
ea6999c941
  1. 110
      designer_base/src/com/fr/design/data/datapane/TreeTableDataDictPane.java

110
designer_base/src/com/fr/design/data/datapane/TreeTableDataDictPane.java

@ -1,21 +1,21 @@
package com.fr.design.data.datapane;
import com.fr.design.data.DesignTableDataManager;
import com.fr.data.impl.RecursionTableData;
import com.fr.design.data.DesignTableDataManager;
import com.fr.design.data.datapane.preview.PreviewLabel;
import com.fr.design.data.datapane.preview.PreviewLabel.Previewable;
import com.fr.design.data.datapane.preview.PreviewTablePane;
import com.fr.design.data.tabledata.wrapper.TableDataWrapper;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIRadioButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.dialog.BasicPane;
import com.fr.design.editor.ValueEditorPane;
import com.fr.design.editor.ValueEditorPaneFactory;
import com.fr.design.editor.editor.ColumnIndexEditor;
import com.fr.design.editor.editor.ColumnNameEditor;
import com.fr.design.editor.editor.Editor;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIRadioButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.general.Inter;
import com.fr.script.Calculator;
import com.fr.stable.StringUtils;
@ -46,19 +46,20 @@ public class TreeTableDataDictPane extends BasicPane implements Previewable {
private ValueEditorPane parentMarkedFieldPane1;
private ValueEditorPane originalMarkedFieldPane2;
public TreeTableDataDictPane(){
public TreeTableDataDictPane() {
this(StringUtils.EMPTY);
}
public TreeTableDataDictPane(String treeName) {
this.setLayout(new BorderLayout(5,30));
this.setLayout(new BorderLayout(5, 30));
this.setBorder(BorderFactory.createEmptyBorder(20, 20, 0, 0));
selectTableDataLabel = new UILabel(Inter.getLocText(new String[]{"Please_Select","Single", "DS-TableData"}) + " :");
selectTableDataLabel = new UILabel(Inter.getLocText(new String[]{"Please_Select", "Single", "DS-TableData"}) + " :");
setTableDataNameComboBox(treeName);
tableDataNameComboBox.setPreferredSize(new Dimension(180, 20));
JPanel tableFlowPane = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane();
tableFlowPane.add(selectTableDataLabel);
tableFlowPane.add(tableDataNameComboBox);
tableDataNameComboBox.addItemListener(new ItemListener(){
tableDataNameComboBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
tdChange();
}
@ -66,12 +67,12 @@ public class TreeTableDataDictPane extends BasicPane implements Previewable {
tableFlowPane.add(new PreviewLabel(this));
this.add(tableFlowPane, BorderLayout.NORTH);
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
this.add(centerPane,BorderLayout.CENTER);
this.add(centerPane, BorderLayout.CENTER);
parentMarkRadio = new UIRadioButton(Inter.getLocText("Build_Tree_Accord_Parent_Marked_Filed"), true);
lengthMarkRadio = new UIRadioButton(Inter.getLocText("Build_Tree_Accord_Marked_Filed_Length"));
parentMarkRadio.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if(isBuildByParentFiled()) {
if (isBuildByParentFiled()) {
makeParentEnable();
tdChange();
}
@ -79,7 +80,7 @@ public class TreeTableDataDictPane extends BasicPane implements Previewable {
});
lengthMarkRadio.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if(!isBuildByParentFiled()) {
if (!isBuildByParentFiled()) {
makeLengthEnable();
tdChange();
}
@ -98,9 +99,9 @@ public class TreeTableDataDictPane extends BasicPane implements Previewable {
// originalMarkedFieldPane1 = ValueEditorPaneFactory.createValueEditorPane(new Editor[] {new OldColumnIndexEditor(Inter.getLocText("Columns"))});
// parentMarkedFieldPane1 = ValueEditorPaneFactory.createValueEditorPane(new Editor[] {new OldColumnIndexEditor(Inter.getLocText("Columns"))});
// originalMarkedFieldPane2 = ValueEditorPaneFactory.createValueEditorPane(new Editor[] {new OldColumnIndexEditor(Inter.getLocText("Columns"))});
originalMarkedFieldPane1 = ValueEditorPaneFactory.createValueEditorPane(new Editor[] { new ColumnNameEditor(), new ColumnIndexEditor() });
parentMarkedFieldPane1 = ValueEditorPaneFactory.createValueEditorPane(new Editor[] { new ColumnNameEditor(), new ColumnIndexEditor() });
originalMarkedFieldPane2 = ValueEditorPaneFactory.createValueEditorPane(new Editor[] { new ColumnNameEditor(), new ColumnIndexEditor() });
originalMarkedFieldPane1 = ValueEditorPaneFactory.createValueEditorPane(new Editor[]{new ColumnNameEditor(), new ColumnIndexEditor()});
parentMarkedFieldPane1 = ValueEditorPaneFactory.createValueEditorPane(new Editor[]{new ColumnNameEditor(), new ColumnIndexEditor()});
originalMarkedFieldPane2 = ValueEditorPaneFactory.createValueEditorPane(new Editor[]{new ColumnNameEditor(), new ColumnIndexEditor()});
makeParentEnable();
@ -116,14 +117,14 @@ public class TreeTableDataDictPane extends BasicPane implements Previewable {
border2.add(p4, BorderLayout.NORTH);
JPanel xx = FRGUIPaneFactory.createBorderLayout_S_Pane();
xx.add(parentMarkRadio,BorderLayout.NORTH);
xx.add(border1,BorderLayout.CENTER);
xx.add(parentMarkRadio, BorderLayout.NORTH);
xx.add(border1, BorderLayout.CENTER);
JPanel xxx = FRGUIPaneFactory.createBorderLayout_S_Pane();
xxx.add(lengthMarkRadio,BorderLayout.NORTH);
xxx.add(border2,BorderLayout.CENTER);
xxx.add(lengthMarkRadio, BorderLayout.NORTH);
xxx.add(border2, BorderLayout.CENTER);
JPanel buildTreePanel = new JPanel(new BorderLayout(5, 30));
buildTreePanel.add(xx,BorderLayout.NORTH);
buildTreePanel.add(xxx,BorderLayout.CENTER);
buildTreePanel.add(xx, BorderLayout.NORTH);
buildTreePanel.add(xxx, BorderLayout.CENTER);
centerPane.add(buildTreePanel, BorderLayout.NORTH);
JPanel previewPanel = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane();
UIButton treeDataPreviewButton = new UIButton(Inter.getLocText("Preview"));
@ -132,17 +133,26 @@ public class TreeTableDataDictPane extends BasicPane implements Previewable {
@Override
public void actionPerformed(ActionEvent e) {
TableDataWrapper tableDataWrappe = tableDataNameComboBox.getSelectedItem();
if(tableDataWrappe == null) {
if (tableDataWrappe == null) {
return;
}
RecursionTableData rtd = new RecursionTableData();
rtd.setOriginalTableDataName(tableDataWrappe.getTableDataName());
if(isBuildByParentFiled()) {
rtd.setMarkFields((Integer.parseInt(originalMarkedFieldPane1.update().toString()) - 1) + "");
rtd.setParentmarkFields(Integer.parseInt(parentMarkedFieldPane1.update().toString()) - 1 + "");
if (isBuildByParentFiled()) {
Object o = parentMarkedFieldPane1.update();
rtd.setParentmarkFields((Integer) o - 1 + "");
rtd.setParentmarkFieldName("" + o);
Object o2 = originalMarkedFieldPane1.update();
rtd.setMarkFields((Integer) o2 - 1 + "");
rtd.setMarkFieldName("" + o2);
} else {
rtd.setMarkFields(Integer.parseInt(originalMarkedFieldPane2.update().toString()) - 1 + "");
rtd.setParentmarkFields("-1");
Object o = originalMarkedFieldPane2.update();
if (o == null) {
rtd.setMarkFields("-1");
} else {
rtd.setMarkFields((Integer) o - 1 + "");
rtd.setMarkFieldName("" + o);
}
}
rtd.setTableDataSource(DesignTableDataManager.getEditingTableDataSource());
rtd.createDataModel(Calculator.createCalculator());
@ -153,17 +163,17 @@ public class TreeTableDataDictPane extends BasicPane implements Previewable {
}
protected void setTableDataNameComboBox(String treeName) {
tableDataNameComboBox = new TableDataComboBox(DesignTableDataManager.getEditingTableDataSource(),treeName);
tableDataNameComboBox = new TableDataComboBox(DesignTableDataManager.getEditingTableDataSource(), treeName);
}
private void tdChange(){
private void tdChange() {
TableDataWrapper tableDataWrappe = this.tableDataNameComboBox.getSelectedItem();
if (tableDataWrappe == null) {
return;
}
ValueEditorPane[] valueEditorPanes;
if(isBuildByParentFiled()) {
if (isBuildByParentFiled()) {
valueEditorPanes = new ValueEditorPane[]{originalMarkedFieldPane1, parentMarkedFieldPane1};
} else {
valueEditorPanes = new ValueEditorPane[]{originalMarkedFieldPane2};
@ -173,12 +183,12 @@ public class TreeTableDataDictPane extends BasicPane implements Previewable {
int len = namelist.size();
String[] columnNames = new String[len];
namelist.toArray(columnNames);
for(int i = 0; i < valueEditorPanes.length; i ++) {
valueEditorPanes[i].setEditors(new Editor[] { new ColumnNameEditor(columnNames), new ColumnIndexEditor(len) }, columnNames[0]);
for (int i = 0; i < valueEditorPanes.length; i++) {
valueEditorPanes[i].setEditors(new Editor[]{new ColumnNameEditor(columnNames), new ColumnIndexEditor(len)}, columnNames[0]);
}
} catch (Exception e) {
for(int i = 0; i < valueEditorPanes.length; i ++) {
valueEditorPanes[i].setEditors(new Editor[] { new ColumnNameEditor(), new ColumnIndexEditor() }, 1);
for (int i = 0; i < valueEditorPanes.length; i++) {
valueEditorPanes[i].setEditors(new Editor[]{new ColumnNameEditor(), new ColumnIndexEditor()}, 1);
}
} finally {
valueEditorPanes = null;
@ -192,31 +202,31 @@ public class TreeTableDataDictPane extends BasicPane implements Previewable {
public RecursionTableData update() {
RecursionTableData td = new RecursionTableData();
if(tableDataNameComboBox.getSelectedItem()==null){
if (tableDataNameComboBox.getSelectedItem() == null) {
td.setOriginalTableDataName(null);
}else{
} else {
td.setOriginalTableDataName(tableDataNameComboBox.getSelectedItem().getTableDataName());
}
if(isBuildByParentFiled()) {
if (isBuildByParentFiled()) {
Object o = parentMarkedFieldPane1.update(StringUtils.EMPTY);
if(o instanceof Object[]){
if (o instanceof Object[]) {
Object[] temp = (Object[]) o;
td.setParentmarkFields(((Integer)temp[0]).intValue() - 1 + "");
td.setParentmarkFields(((Integer) temp[0]).intValue() - 1 + "");
td.setParentmarkFieldName((String) temp[1]);
}
Object o2 = originalMarkedFieldPane1.update(StringUtils.EMPTY);
if(o2 instanceof Object[]){
if (o2 instanceof Object[]) {
Object[] temp = (Object[]) o2;
td.setMarkFields(((Integer)temp[0]).intValue() - 1 + "");
td.setMarkFields(((Integer) temp[0]).intValue() - 1 + "");
td.setMarkFieldName((String) temp[1]);
}
} else {
Object o = originalMarkedFieldPane2.update(StringUtils.EMPTY);
if(o == null || !(o instanceof Object[])){
if (o == null || !(o instanceof Object[])) {
td.setMarkFields("-1");
} else {
Object[] temp = (Object[]) o;
td.setMarkFields(((Integer)temp[0]).intValue() - 1 + "");
td.setMarkFields(((Integer) temp[0]).intValue() - 1 + "");
td.setMarkFieldName((String) temp[1]);
}
}
@ -225,19 +235,19 @@ public class TreeTableDataDictPane extends BasicPane implements Previewable {
}
public void populate(RecursionTableData rtb) {
if(StringUtils.isNotEmpty(rtb.getParentmarkFields())) {
if (StringUtils.isNotEmpty(rtb.getParentmarkFields())) {
makeParentEnable();
parentMarkRadio.setSelected(true);
lengthMarkRadio.setSelected(false);
tableDataNameComboBox.setSelectedTableDataByName(rtb.getOriginalTableDataName());
if(StringUtils.isNotEmpty(rtb.getMarkFieldName())){
if (StringUtils.isNotEmpty(rtb.getMarkFieldName())) {
originalMarkedFieldPane1.populate(rtb.getMarkFieldName());
}else{
} else {
originalMarkedFieldPane1.populate(rtb.getMarkFieldIndex() + 1);
}
if(StringUtils.isNotEmpty(rtb.getParentmarkFieldName())){
if (StringUtils.isNotEmpty(rtb.getParentmarkFieldName())) {
parentMarkedFieldPane1.populate(rtb.getParentmarkFieldName());
}else{
} else {
parentMarkedFieldPane1.populate(rtb.getParentmarkFieldIndex() + 1);
}
} else {
@ -245,9 +255,9 @@ public class TreeTableDataDictPane extends BasicPane implements Previewable {
lengthMarkRadio.setSelected(true);
parentMarkRadio.setSelected(false);
tableDataNameComboBox.setSelectedTableDataByName(rtb.getOriginalTableDataName());
if(StringUtils.isNotEmpty(rtb.getMarkFieldName())){
if (StringUtils.isNotEmpty(rtb.getMarkFieldName())) {
originalMarkedFieldPane2.populate(rtb.getMarkFieldName());
}else{
} else {
originalMarkedFieldPane2.populate(rtb.getMarkFieldIndex() + 1);
}
}

Loading…
Cancel
Save