package com.vci.client.portal.NewUI;
|
|
import java.awt.BorderLayout;
|
import java.awt.FlowLayout;
|
import java.awt.GridBagConstraints;
|
import java.awt.GridBagLayout;
|
import java.awt.Insets;
|
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionListener;
|
|
import javax.swing.ButtonGroup;
|
import javax.swing.JButton;
|
import javax.swing.JCheckBox;
|
import javax.swing.JLabel;
|
import javax.swing.JPanel;
|
import javax.swing.JRadioButton;
|
import javax.swing.JTextField;
|
import javax.swing.border.EmptyBorder;
|
|
import com.vci.client.LogonApplication;
|
import com.vci.client.portal.utility.PLDefination;
|
import com.vci.client.portal.utility.UITools;
|
import com.vci.client.ui.swing.VCIOptionPane;
|
import com.vci.common.portal.constants.TemplateTypeConstants;
|
import com.vci.common.utility.ObjectUtility;
|
import com.vci.corba.common.VCIError;
|
import com.vci.corba.portal.data.PLPageDefination;
|
import com.vci.corba.portal.data.PLUILayout;
|
|
/**
|
* 树设置
|
* @author liudi
|
*
|
*/
|
public class TreeTablePanel extends JPanel{
|
|
private final JPanel contentPanel = new JPanel();
|
|
private JButton okButton;
|
private JButton cancelButton;
|
private JLabel label_1;
|
private JRadioButton graduallyRad;
|
private JRadioButton allRad;
|
private ButtonGroup expandBg = new ButtonGroup();
|
private ButtonGroup orientationBg= new ButtonGroup();
|
private JCheckBox isShowImage;
|
private JLabel lbltable;
|
private JTextField templateIdTxt;
|
private JPanel panel;
|
private JButton btnSet;
|
private JButton delBtn;
|
private PLUILayout plpagelayoutdefination;
|
private JLabel label_5;
|
private JTextField linkTypeTxt;
|
private JLabel lblNewLabel_1;
|
private JTextField showTypeTxt;
|
private JLabel lbllink;
|
private JTextField expandColsTxt;
|
private PLDefination pldefination;
|
private String plPageDefinationID;
|
private String btmName;
|
private Integer templateType = TemplateTypeConstants.TREETABLE;
|
private NavigationDialog navigationDialog;
|
private static String buttonArea = "navigatorTreeTable";
|
/**
|
* Create the dialog.
|
*/
|
public TreeTablePanel(PLUILayout plpagelayoutdefination,String btmName,NavigationDialog navigationDialog) {
|
this.plpagelayoutdefination = plpagelayoutdefination;
|
this.btmName = btmName;
|
this.navigationDialog = navigationDialog;
|
init();
|
actionListener();
|
initData();
|
this.setVisible(true);
|
}
|
|
private void init() {
|
setBounds(100, 100, 450, 345);
|
setLayout(new BorderLayout());
|
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
|
add(contentPanel, BorderLayout.CENTER);
|
GridBagLayout gbl_contentPanel = new GridBagLayout();
|
gbl_contentPanel.columnWidths = new int[]{0, 0, 0, 0, 0};
|
gbl_contentPanel.rowHeights = new int[]{0, 0, 0, 0, 0, 0, 0};
|
gbl_contentPanel.columnWeights = new double[]{0.0, 1.0, 1.0, 0.0, Double.MIN_VALUE};
|
gbl_contentPanel.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
|
contentPanel.setLayout(gbl_contentPanel);
|
{
|
lblNewLabel_1 = new JLabel("显示类型");
|
GridBagConstraints gbc_lblNewLabel_1 = new GridBagConstraints();
|
gbc_lblNewLabel_1.insets = new Insets(0, 0, 5, 5);
|
gbc_lblNewLabel_1.gridx = 1;
|
gbc_lblNewLabel_1.gridy = 0;
|
contentPanel.add(lblNewLabel_1, gbc_lblNewLabel_1);
|
}
|
{
|
showTypeTxt = new JTextField();
|
GridBagConstraints gbc_showTypeTxt = new GridBagConstraints();
|
gbc_showTypeTxt.insets = new Insets(0, 0, 5, 5);
|
gbc_showTypeTxt.fill = GridBagConstraints.HORIZONTAL;
|
gbc_showTypeTxt.gridx = 2;
|
gbc_showTypeTxt.gridy = 0;
|
contentPanel.add(showTypeTxt, gbc_showTypeTxt);
|
showTypeTxt.setColumns(10);
|
}
|
{
|
label_1 = new JLabel("展开方式");
|
GridBagConstraints gbc_label_1 = new GridBagConstraints();
|
gbc_label_1.insets = new Insets(0, 0, 5, 5);
|
gbc_label_1.gridx = 1;
|
gbc_label_1.gridy = 1;
|
contentPanel.add(label_1, gbc_label_1);
|
}
|
{
|
panel = new JPanel();
|
FlowLayout flowLayout = (FlowLayout) panel.getLayout();
|
flowLayout.setAlignment(FlowLayout.LEFT);
|
GridBagConstraints gbc_panel = new GridBagConstraints();
|
gbc_panel.insets = new Insets(0, 0, 5, 5);
|
gbc_panel.fill = GridBagConstraints.BOTH;
|
gbc_panel.gridx = 2;
|
gbc_panel.gridy = 1;
|
contentPanel.add(panel, gbc_panel);
|
graduallyRad = new JRadioButton("逐级展开");
|
graduallyRad.setSelected(true);
|
panel.add(graduallyRad);
|
expandBg.add(graduallyRad);
|
{
|
|
allRad = new JRadioButton("全部展开");
|
panel.add(allRad);
|
expandBg.add(allRad);
|
}
|
}
|
{
|
isShowImage = new JCheckBox("显示图标");
|
GridBagConstraints gbc_isShowImage = new GridBagConstraints();
|
gbc_isShowImage.insets = new Insets(0, 0, 5, 5);
|
gbc_isShowImage.gridx = 1;
|
gbc_isShowImage.gridy = 2;
|
contentPanel.add(isShowImage, gbc_isShowImage);
|
}
|
{
|
lbllink = new JLabel("树形结构展开列");
|
GridBagConstraints gbc_lbllink = new GridBagConstraints();
|
gbc_lbllink.insets = new Insets(0, 0, 5, 5);
|
gbc_lbllink.gridx = 1;
|
gbc_lbllink.gridy = 3;
|
contentPanel.add(lbllink, gbc_lbllink);
|
}
|
{
|
expandColsTxt = new JTextField();
|
GridBagConstraints gbc_expandColsTxt = new GridBagConstraints();
|
gbc_expandColsTxt.insets = new Insets(0, 0, 5, 5);
|
gbc_expandColsTxt.fill = GridBagConstraints.HORIZONTAL;
|
gbc_expandColsTxt.gridx = 2;
|
gbc_expandColsTxt.gridy = 3;
|
contentPanel.add(expandColsTxt, gbc_expandColsTxt);
|
expandColsTxt.setColumns(10);
|
}
|
{
|
lbltable = new JLabel("关联table");
|
GridBagConstraints gbc_lbltable = new GridBagConstraints();
|
gbc_lbltable.insets = new Insets(0, 0, 5, 5);
|
gbc_lbltable.gridx = 1;
|
gbc_lbltable.gridy = 4;
|
contentPanel.add(lbltable, gbc_lbltable);
|
}
|
{
|
templateIdTxt = new JTextField();
|
GridBagConstraints gbc_templateIdTxt = new GridBagConstraints();
|
gbc_templateIdTxt.insets = new Insets(0, 0, 5, 5);
|
gbc_templateIdTxt.fill = GridBagConstraints.HORIZONTAL;
|
gbc_templateIdTxt.gridx = 2;
|
gbc_templateIdTxt.gridy = 4;
|
contentPanel.add(templateIdTxt, gbc_templateIdTxt);
|
templateIdTxt.setColumns(10);
|
}
|
{
|
label_5 = new JLabel("链接类型");
|
GridBagConstraints gbc_label_5 = new GridBagConstraints();
|
gbc_label_5.insets = new Insets(0, 0, 0, 5);
|
gbc_label_5.gridx = 1;
|
gbc_label_5.gridy = 5;
|
contentPanel.add(label_5, gbc_label_5);
|
}
|
{
|
linkTypeTxt = new JTextField();
|
GridBagConstraints gbc_linkTypeTxt = new GridBagConstraints();
|
gbc_linkTypeTxt.insets = new Insets(0, 0, 0, 5);
|
gbc_linkTypeTxt.fill = GridBagConstraints.HORIZONTAL;
|
gbc_linkTypeTxt.gridx = 2;
|
gbc_linkTypeTxt.gridy = 5;
|
contentPanel.add(linkTypeTxt, gbc_linkTypeTxt);
|
linkTypeTxt.setColumns(10);
|
}
|
{
|
JPanel buttonPane = new JPanel();
|
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
|
add(buttonPane, BorderLayout.SOUTH);
|
{
|
btnSet = new JButton("按钮设计");
|
buttonPane.add(btnSet);
|
}
|
{
|
delBtn = new JButton("删除");
|
buttonPane.add(delBtn);
|
}
|
{
|
okButton = new JButton("保存");
|
buttonPane.add(okButton);
|
}
|
{
|
cancelButton = new JButton("关闭");
|
buttonPane.add(cancelButton);
|
}
|
}
|
}
|
|
private void actionListener(){
|
btnSet.addActionListener(new ActionListener() {
|
|
@Override
|
public void actionPerformed(ActionEvent arg0) {
|
ButtonDialog dialog = new ButtonDialog(null,plpagelayoutdefination,buttonArea);
|
}
|
});
|
delBtn.addActionListener(new ActionListener() {
|
|
@Override
|
public void actionPerformed(ActionEvent arg0) {
|
PLPageDefination plPageDefination = new PLPageDefination();
|
plPageDefination.plOId = plPageDefinationID;
|
try {
|
if (VCIOptionPane.showQuestion(LogonApplication.frame,
|
"确定要删除记录吗?") != 0) {
|
return;
|
}
|
boolean flag = UITools.getService().deletePLPageDefination(plPageDefination);
|
} catch (VCIError e) {
|
e.printStackTrace();
|
}
|
|
}
|
});
|
okButton.addActionListener(new ActionListener() {
|
|
@Override
|
public void actionPerformed(ActionEvent arg0) {
|
if(pldefination!=null){
|
edit();
|
}else{
|
save();
|
}
|
// navigationDialog.dispose();
|
}
|
|
private void edit() {
|
PLPageDefination plPageDefination = new PLPageDefination();
|
plPageDefination.plOId = plPageDefinationID;
|
plPageDefination.plTabPageOId = plpagelayoutdefination.plOId;
|
plPageDefination.plType=1;
|
PLDefination obj = new PLDefination();
|
obj.setType(templateType);
|
obj.setShowType(showTypeTxt.getText());
|
//逐级展开:1、全部展开:0
|
if(graduallyRad.isSelected()){
|
obj.setExpandMode("1");
|
}
|
|
if(allRad.isSelected()){
|
obj.setExpandMode("0");
|
}
|
obj.setLinkType(linkTypeTxt.getText());
|
// obj.setValidity(validityTxt.getText());
|
obj.setExpandCols(expandColsTxt.getText());
|
if(isShowImage.isSelected()){
|
obj.setIsShowImage("1");
|
}else{
|
obj.setIsShowImage("0");
|
}
|
obj.setTemplateId(templateIdTxt.getText());
|
try {
|
plPageDefination.plDefination = UITools.getPLDefinationText(obj);
|
boolean flag = UITools.getService().updatePLPageDefination(plPageDefination);
|
} catch (Throwable e) {
|
e.printStackTrace();
|
}
|
}
|
|
private void save() {
|
PLPageDefination plPageDefination = new PLPageDefination();
|
plPageDefination.plOId = ObjectUtility.getNewObjectID36();
|
plPageDefination.plTabPageOId = plpagelayoutdefination.plOId;
|
plPageDefination.plType=1;
|
PLDefination obj = new PLDefination();
|
obj.setType(templateType);
|
obj.setShowType(showTypeTxt.getText());
|
//逐级展开:1、全部展开:0
|
if(graduallyRad.isSelected()){
|
obj.setExpandMode("1");
|
}
|
|
if(allRad.isSelected()){
|
obj.setExpandMode("0");
|
}
|
obj.setLinkType(linkTypeTxt.getText());
|
// obj.setValidity(validityTxt.getText());
|
obj.setExpandCols(expandColsTxt.getText());
|
if(isShowImage.isSelected()){
|
obj.setIsShowImage("1");
|
}else{
|
obj.setIsShowImage("0");
|
}
|
obj.setTemplateId(templateIdTxt.getText());
|
try {
|
plPageDefination.plDefination = UITools.getPLDefinationText(obj);
|
boolean flag = UITools.getService().savePLPageDefination(plPageDefination);
|
} catch (Throwable e) {
|
e.printStackTrace();
|
}
|
}
|
|
});
|
cancelButton.addActionListener(new ActionListener() {
|
|
@Override
|
public void actionPerformed(ActionEvent arg0) {
|
navigationDialog.dispose();
|
}
|
});
|
}
|
|
private void initData(){
|
PLPageDefination[] obj;
|
PLDefination p ;
|
try {
|
obj = UITools.getService().getPLPageDefinationsByPageContextOId(plpagelayoutdefination.plOId);
|
for(int i=0;i<obj.length;i++){
|
if(obj[i].plType==templateType){
|
plPageDefinationID = obj[i].plOId;
|
p = UITools.getPLDefination(obj[i].plDefination);
|
|
showTypeTxt.setText(p.getShowType());
|
if(p.getExpandMode().equals("1")){
|
graduallyRad.setSelected(true);
|
}
|
if(p.getExpandMode().equals("0")){
|
allRad.setSelected(true);
|
}
|
linkTypeTxt.setText(p.getLinkType());
|
templateIdTxt.setText(p.getTemplateId());
|
expandColsTxt.setText(p.getExpandCols());
|
if(p.getIsShowImage().equals("1")){
|
isShowImage.setSelected(true);
|
}
|
this.pldefination = p;
|
}
|
}
|
} catch (VCIError e) {
|
e.printStackTrace();
|
} catch (Throwable e) {
|
e.printStackTrace();
|
}
|
}
|
}
|