You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
158 lines
4.3 KiB
158 lines
4.3 KiB
package com.fr.design.gui.frpane; |
|
|
|
import com.fr.data.impl.TableDataDictionary; |
|
import com.fr.data.impl.TreeAttr; |
|
import com.fr.data.impl.TreeNodeAttr; |
|
import com.fr.data.impl.TreeNodeWrapper; |
|
import com.fr.design.data.DataCreatorUI; |
|
import com.fr.design.dialog.BasicPane; |
|
import com.fr.design.gui.controlpane.NameObjectCreator; |
|
import com.fr.design.gui.controlpane.NameableCreator; |
|
import com.fr.design.gui.frpane.tree.layer.config.LayerDataControlPane; |
|
import com.fr.design.gui.icombobox.UIComboBox; |
|
import com.fr.design.gui.ilable.UILabel; |
|
import com.fr.design.gui.itree.refreshabletree.TreeDataCardPane; |
|
import com.fr.design.layout.FRGUIPaneFactory; |
|
import com.fr.form.ui.TreeComboBoxEditor; |
|
import com.fr.form.ui.TreeEditor; |
|
import com.fr.form.ui.tree.LayerConfig; |
|
|
|
import com.fr.general.NameObject; |
|
|
|
import javax.swing.*; |
|
import java.awt.*; |
|
import java.awt.event.ItemEvent; |
|
import java.awt.event.ItemListener; |
|
import java.util.Arrays; |
|
|
|
public class TreeSettingPane extends BasicPane implements DataCreatorUI { |
|
/** |
|
* 普通分层构建方式 |
|
*/ |
|
private JTreeControlPane controlPane; |
|
|
|
/** |
|
* 自动构建方式 |
|
*/ |
|
private JTreeAutoBuildPane autoBuildPane; |
|
|
|
/** |
|
* 急速分层构建方式 |
|
*/ |
|
private LayerDataControlPane layerDataControlPane; |
|
|
|
private UIComboBox buildBox; |
|
|
|
/** |
|
* |
|
*/ |
|
private static final long serialVersionUID = 1762889323082827111L; |
|
|
|
private String[] buildWay = new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_DataTable_Build"), |
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Auto_Build"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Layer_Build")}; |
|
|
|
public TreeSettingPane() { |
|
this.initComponents(); |
|
} |
|
|
|
private void initComponents() { |
|
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
|
JPanel buildWayPanel = FRGUIPaneFactory.createMediumHGapFlowInnerContainer_M_Pane(); |
|
buildWayPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
|
UILabel buildWayLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Build_Way") + " :"); |
|
buildWayPanel.add(buildWayLabel); |
|
buildBox = new UIComboBox(buildWay); |
|
buildBox.addItemListener(new ItemListener() { |
|
|
|
@Override |
|
public void itemStateChanged(ItemEvent e) { |
|
cardChanged(buildBox.getSelectedIndex()); |
|
} |
|
}); |
|
buildWayPanel.add(buildBox); |
|
|
|
controlPane = new JTreeControlPane(new NameableCreator[]{treeNode}, |
|
new TreeDataCardPane()); |
|
autoBuildPane = new JTreeAutoBuildPane(); |
|
layerDataControlPane = new LayerDataControlPane(); |
|
this.add(buildWayPanel, BorderLayout.NORTH); |
|
cardChanged(0); |
|
} |
|
|
|
private void cardChanged(int index) { |
|
|
|
this.remove(controlPane); |
|
this.remove(autoBuildPane); |
|
this.remove(layerDataControlPane); |
|
switch (index) { |
|
case 0: |
|
this.add(layerDataControlPane); |
|
break; |
|
case 1: |
|
this.add(autoBuildPane); |
|
break; |
|
case 2: |
|
this.add(controlPane); |
|
|
|
break; |
|
default: |
|
break; |
|
} |
|
validate(); |
|
repaint(); |
|
revalidate(); |
|
} |
|
|
|
@Override |
|
protected String title4PopupWindow() { |
|
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Create_Tree"); |
|
} |
|
|
|
@Override |
|
public JComponent toSwingComponent() { |
|
return this; |
|
} |
|
|
|
NameableCreator treeNode = new NameObjectCreator( |
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Gradation"), |
|
"/com/fr/design/images/data/source/jdbcTableData.png", |
|
TreeNodeAttr.class); |
|
|
|
|
|
/** |
|
* 树节点属性的update |
|
* |
|
* @return |
|
*/ |
|
public Object updateTreeNodeAttrs() { |
|
|
|
if (buildBox.getSelectedIndex() == 2) { |
|
NameObject no = controlPane.update(); |
|
if (no != null) { |
|
return no.getObject(); |
|
} |
|
} else if (buildBox.getSelectedIndex() == 0) { |
|
return layerDataControlPane.update(); |
|
} else { |
|
return autoBuildPane.update(); |
|
} |
|
return null; |
|
} |
|
|
|
/** |
|
* @param nodeOrDict |
|
*/ |
|
public void populate(Object nodeOrDict) { |
|
if (nodeOrDict instanceof TreeNodeAttr[] || nodeOrDict instanceof TreeNodeWrapper) { |
|
buildBox.setSelectedIndex(2); |
|
NameObject no = new NameObject("name", nodeOrDict); |
|
controlPane.populate(no); |
|
} else if (nodeOrDict instanceof TableDataDictionary) { |
|
buildBox.setSelectedIndex(1); |
|
autoBuildPane.populate((TableDataDictionary) nodeOrDict); |
|
} else if (nodeOrDict instanceof LayerConfig[]) { |
|
buildBox.setSelectedIndex(0); |
|
layerDataControlPane.populate((LayerConfig[]) nodeOrDict); |
|
} |
|
} |
|
} |