package com.vci.client.portal.Formdesign;
|
|
import java.awt.BasicStroke;
|
import java.awt.BorderLayout;
|
import java.awt.Color;
|
import java.awt.Component;
|
import java.awt.Dimension;
|
import java.awt.GridBagConstraints;
|
import java.awt.GridBagLayout;
|
import java.awt.Insets;
|
import java.awt.Toolkit;
|
import java.awt.datatransfer.DataFlavor;
|
import java.awt.datatransfer.Transferable;
|
import java.awt.datatransfer.UnsupportedFlavorException;
|
import java.awt.dnd.DnDConstants;
|
import java.awt.dnd.DragGestureEvent;
|
import java.awt.dnd.DragGestureListener;
|
import java.awt.dnd.DragSource;
|
import java.awt.dnd.DragSourceDragEvent;
|
import java.awt.dnd.DragSourceDropEvent;
|
import java.awt.dnd.DragSourceEvent;
|
import java.awt.dnd.DragSourceListener;
|
import java.awt.dnd.DropTarget;
|
import java.awt.dnd.DropTargetDragEvent;
|
import java.awt.dnd.DropTargetDropEvent;
|
import java.awt.dnd.DropTargetEvent;
|
import java.awt.dnd.DropTargetListener;
|
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionListener;
|
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyListener;
|
import java.awt.event.MouseAdapter;
|
import java.awt.event.MouseEvent;
|
import java.io.IOException;
|
import java.util.ArrayList;
|
import java.util.HashMap;
|
import java.util.LinkedList;
|
import java.util.List;
|
import java.util.Map;
|
|
import javax.swing.ButtonGroup;
|
import javax.swing.JButton;
|
import javax.swing.JComboBox;
|
import javax.swing.JDialog;
|
import javax.swing.JLabel;
|
import javax.swing.JOptionPane;
|
import javax.swing.JPanel;
|
import javax.swing.JRadioButton;
|
import javax.swing.JScrollPane;
|
import javax.swing.JSplitPane;
|
import javax.swing.JTextArea;
|
import javax.swing.JTextField;
|
import javax.swing.border.TitledBorder;
|
|
import com.vci.client.LogonApplication;
|
import com.vci.client.omd.btm.wrapper.BtmItemWrapper;
|
import com.vci.client.omd.linktype.LinkTypeWrapper;
|
import com.vci.client.omd.provider.BtmProvider;
|
import com.vci.client.oq.QTClient;
|
import com.vci.client.oq.QTDClient;
|
import com.vci.client.portal.Formdesign.object.CompnentGroup;
|
import com.vci.client.portal.Formdesign.util.CompnentUtil;
|
import com.vci.client.portal.platformPortal.CreateQueryModelDialog;
|
import com.vci.client.portal.platformPortal.PlatformPortalTablePanel;
|
import com.vci.client.portal.utility.PRM;
|
import com.vci.client.portal.utility.PRMItem;
|
import com.vci.client.portal.utility.UITools;
|
import com.vci.client.ui.exception.VCIException;
|
import com.vci.client.ui.locale.LocaleDisplay;
|
import com.vci.client.ui.swing.VCIOptionPane;
|
import com.vci.client.ui.swing.components.VCIJOptionPane;
|
import com.vci.client.ui.swing.components.table.VCIJTableNode;
|
import com.vci.common.portal.enums.ControlType;
|
import com.vci.common.portal.enums.PortalVIType;
|
import com.vci.common.portal.enums.PortalVITypeFlag;
|
import com.vci.common.utility.ObjectUtility;
|
import com.vci.corba.common.VCIError;
|
import com.vci.corba.portal.data.PortalVI;
|
import com.vci.corba.omd.atm.AttribItem;
|
import com.vci.corba.omd.qtm.QTInfo;
|
|
/**
|
* 自定义ui界面
|
*
|
* @author liudi
|
*
|
*/
|
public class FormDesignDialog extends JDialog implements DropTargetListener, DragGestureListener, DragSourceListener {
|
/**
|
*
|
*/
|
// add by guo
|
private boolean _isBtm = false;
|
private static final long serialVersionUID = 1L;
|
private JPanel attrPane = new JPanel();
|
private JPanel contentPanel = new JPanel();
|
private JButton addModelButton;
|
private int type1 = 0;
|
private String name;
|
private boolean editFlag = false;
|
private int KeyFlag = 0;
|
private JPanel mainPanel = new JPanel();
|
private int countX = 0;
|
private int countY = 0;
|
private List<JLabel> JLabelList = new ArrayList<JLabel>();
|
DragSource dragSource;
|
|
private String titleName = null;
|
// 默认线的宽度
|
static final int LINEWIDTH = 3;
|
|
static final BasicStroke linestyle = new BasicStroke(LINEWIDTH);
|
// 记录删除组件后的组件在布局中的坐标
|
int[] coordinate;
|
|
// 功能按钮
|
private JButton saveBtn;
|
private JButton clearCompnent;
|
private JButton deleteCompnent;
|
|
// 欲删除的组件
|
private Component selectedComponent;
|
/**
|
* 页面元素
|
*/
|
// private JLabel labelCom = null;
|
// private JTextField textField = null;
|
// private JTextArea textArea = null;
|
// private JScrollPane jsp = null;
|
// private VCIJCalendarPanel calendarPanel = null;
|
// private VCIJComboBox comboBox;
|
// private TextButtonJPanel textBtn = null;
|
// private CanzhaoJPanel cz = null;
|
// private JCheckBox checkBox = null;
|
// private FileChooserJPanel fileChooserJPanel = null;
|
|
private GridBagLayout gridBagLayout;
|
// 组件坐标
|
int x = 0, y = 0, width = 100, height = 20;
|
|
// 组件唯一标识
|
//private int comHashCode = 0;
|
private JScrollPane jScrollPane;
|
|
// 面板高度
|
//private int panelheight;
|
|
private int gridBaglayoutRowCount = 0;
|
AttribItem attribItem;
|
//String filenamePath;
|
|
// 对象类型,可能是业务类型,也可能是链接类型
|
private static String otName = "";
|
|
//private Map<Component, String> textAreaMap = new HashMap<Component, String>();
|
|
/**
|
* 存储组件
|
*/
|
private ArrayList<CompnentGroup> _lstCompnent = new ArrayList<CompnentGroup>();
|
|
private WidgetPanel widgetPanel;
|
private Object selectTreeNodeobject;
|
private PortalVI pvi;
|
private PRM prm;
|
private PRMItem prmItem;
|
private JPanel configPanel;
|
|
/**
|
* 存储属性名称和属性对象
|
*/
|
//private Map<String, AttribItem> attribItemMap = new HashMap<String, AttribItem>();
|
/**
|
* 保存组件和属性的关系
|
*/
|
//private Map<String, PRMItem> comPRMItemMap = (Map<String, PRMItem>) new ListOrderedMap();
|
private PortalVIType portalVIType;
|
// public static DragTreemain getInstance(){
|
// if(dragTreemain == null){
|
// dragTreemain = new DragTreemain(selectTreeNodeobject,type);
|
// }
|
// return dragTreemain;
|
// }
|
|
/**
|
* 显示列数,默认是3列
|
*/
|
private int colCount = 3;
|
private PortalVITypeFlag typeFlag;
|
private PlatformPortalTablePanel platformPortalTablePanel;
|
|
public FormDesignDialog(Object object, PortalVIType portalVIType, PortalVI pvi, Boolean editFlag,
|
PlatformPortalTablePanel platformPortalTablePanel, PortalVITypeFlag typeFlag) {
|
this(object, portalVIType, pvi, editFlag, platformPortalTablePanel, typeFlag, false);
|
}
|
|
// add by guo
|
public FormDesignDialog(Object object, PortalVIType portalVIType, PortalVI pvi, Boolean editFlag,
|
PlatformPortalTablePanel platformPortalTablePanel, PortalVITypeFlag typeFlag, boolean isTrue) {
|
super(LogonApplication.frame, true);
|
|
this.titleName = "表单定义";
|
|
this.selectTreeNodeobject = object;
|
this.portalVIType = portalVIType;
|
this._isBtm = isTrue;
|
this.pvi = pvi;
|
this.typeFlag = typeFlag;
|
this.editFlag = editFlag;
|
this.platformPortalTablePanel = platformPortalTablePanel;
|
if (pvi != null) {
|
titleName = pvi.viName;
|
}
|
init();
|
actionListener();
|
fillQtNameCom();
|
initData();
|
display();
|
}
|
|
private void init() {
|
if (selectTreeNodeobject instanceof BtmItemWrapper) {
|
otName = ((BtmItemWrapper) selectTreeNodeobject).btmItem.name;
|
} else if (selectTreeNodeobject instanceof LinkTypeWrapper) {
|
otName = ((LinkTypeWrapper) selectTreeNodeobject).linkType.name;
|
}
|
getContentPane().setLayout(new BorderLayout());
|
dragSource = DragSource.getDefaultDragSource();
|
dragSource.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_COPY_OR_MOVE, this);
|
attrPane.addKeyListener(new KeyListener() {
|
@Override
|
public void keyTyped(KeyEvent e) {
|
// TODO Auto-generated method stub
|
}
|
|
@Override
|
public void keyReleased(KeyEvent e) {
|
KeyFlag = 0;
|
// TODO Auto-generated method stub
|
}
|
|
@Override
|
public void keyPressed(KeyEvent e) {
|
if (e.getKeyCode() == 17) {
|
KeyFlag = 1;
|
}
|
// TODO Auto-generated method stub
|
}
|
});
|
new DropTarget(attrPane, DnDConstants.ACTION_COPY_OR_MOVE, this);
|
attrPane.setBorder(new TitledBorder("页面定义"));
|
JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, createTreePanel(), createTextPanel());
|
splitPane.setDividerLocation(250);
|
splitPane.setOneTouchExpandable(true);
|
|
getContentPane().add(splitPane, BorderLayout.CENTER);
|
|
gridBagLayout = new GridBagLayout();
|
Dimension panelDimension = jScrollPane.getPreferredSize();
|
//panelheight = panelDimension.height;
|
gridBaglayoutRowCount = 100;// panelheight / 40;
|
int[] gridBaglayoutRow = new int[gridBaglayoutRowCount];
|
double[] gridBaglayoutRowWeidth = new double[gridBaglayoutRowCount];
|
for (int i = 0; i < gridBaglayoutRowCount; i++) {
|
gridBaglayoutRow[i] = 30;// 20;
|
gridBaglayoutRowWeidth[i] = 0.1;
|
}
|
gridBagLayout.rowWeights = gridBaglayoutRowWeidth;
|
gridBagLayout.rowHeights = gridBaglayoutRow;
|
gridBagLayout.columnWeights = new double[] { 0.1, 0.1, 0.1, 0.1, 0.1 };
|
gridBagLayout.columnWidths = new int[] { 1, 1, 1, 1, 1 };
|
attrPane.setLayout(gridBagLayout);
|
|
panel = new JPanel(new GridBagLayout());
|
panelMain = new JPanel();
|
panelMain.add(panel, BorderLayout.WEST);
|
mainPanel.add(panelMain, BorderLayout.NORTH);
|
|
lblNewLabel = new JLabel("名称");
|
GridBagConstraints gbc_lblNewLabel = new GridBagConstraints();
|
gbc_lblNewLabel.insets = new Insets(0, 0, 0, 5);
|
gbc_lblNewLabel.fill = GridBagConstraints.WEST;
|
gbc_lblNewLabel.gridx = 0;
|
gbc_lblNewLabel.gridy = 0;
|
panel.add(lblNewLabel, gbc_lblNewLabel);
|
|
viName = new JTextField();
|
GridBagConstraints gbc_viName = new GridBagConstraints();
|
gbc_viName.gridwidth = 4;
|
gbc_viName.insets = new Insets(0, 0, 0, 5);
|
gbc_viName.gridx = 1;
|
gbc_viName.gridy = 0;
|
gbc_viName.weightx = 0.5;
|
gbc_viName.fill = GridBagConstraints.HORIZONTAL;
|
viName.setColumns(40);
|
panel.add(viName, gbc_viName);
|
|
qtNameLab = new JLabel("查询模板名称");
|
GridBagConstraints gbc_qtNameLab = new GridBagConstraints();
|
gbc_qtNameLab.anchor = GridBagConstraints.EAST;
|
gbc_qtNameLab.gridwidth = 2;
|
gbc_qtNameLab.insets = new Insets(0, 0, 0, 5);
|
gbc_qtNameLab.gridx = 5;
|
gbc_qtNameLab.gridy = 0;
|
gbc_qtNameLab.anchor = GridBagConstraints.NORTHEAST;
|
panel.add(qtNameLab, gbc_qtNameLab);
|
|
qtName = new JComboBox();
|
GridBagConstraints gbc_qtName = new GridBagConstraints();
|
gbc_qtName.gridwidth = 3;
|
gbc_qtName.insets = new Insets(0, 0, 0, 5);
|
gbc_qtName.gridx = 7;
|
gbc_qtName.gridy = 0;
|
qtName.setPreferredSize(new Dimension(240, 23));
|
panel.add(qtName, gbc_qtName);
|
|
addModelButton = new JButton("添加");
|
GridBagConstraints gbc_addModelButton = new GridBagConstraints();
|
gbc_addModelButton.anchor = GridBagConstraints.WEST;
|
gbc_addModelButton.insets = new Insets(0, 0, 0, 5);
|
gbc_addModelButton.gridx = 10;
|
gbc_addModelButton.gridy = 0;
|
panel.add(addModelButton, gbc_addModelButton);
|
if (editFlag == false) {
|
addModelButton.setVisible(false);
|
}
|
|
label = new JLabel("显示列数");
|
GridBagConstraints gbc_label = new GridBagConstraints();
|
gbc_label.gridwidth = 2;
|
gbc_label.insets = new Insets(0, 0, 0, 5);
|
gbc_label.gridx = 11;
|
gbc_label.gridy = 0;
|
panel.add(label, gbc_label);
|
|
componentDisCol = new JTextField();
|
GridBagConstraints gbc_componentDisCol = new GridBagConstraints();
|
gbc_componentDisCol.gridwidth = 2;
|
gbc_componentDisCol.insets = new Insets(0, 0, 0, 5);
|
gbc_componentDisCol.gridx = 13;
|
gbc_componentDisCol.gridy = 0;
|
componentDisCol.setText(colCount + "");
|
componentDisCol.setColumns(10);
|
panel.add(componentDisCol, gbc_componentDisCol);
|
|
setColBtn = new JButton("设置");
|
GridBagConstraints gbc_setColBtn = new GridBagConstraints();
|
gbc_setColBtn.insets = new Insets(0, 0, 0, 5);
|
gbc_setColBtn.gridx = 15;
|
gbc_setColBtn.gridy = 0;
|
panel.add(setColBtn, gbc_setColBtn);
|
|
label_1 = new JLabel("位置");
|
GridBagConstraints gbc_label_1 = new GridBagConstraints();
|
gbc_label_1.insets = new Insets(0, 0, 0, 5);
|
gbc_label_1.gridx = 16;
|
gbc_label_1.gridy = 0;
|
panel.add(label_1, gbc_label_1);
|
|
compIndex = new JTextField();
|
GridBagConstraints gbc_compIndex = new GridBagConstraints();
|
gbc_compIndex.gridwidth = 2;
|
gbc_compIndex.insets = new Insets(0, 0, 0, 5);
|
gbc_compIndex.gridx = 17;
|
gbc_compIndex.gridy = 0;
|
compIndex.setColumns(10);
|
panel.add(compIndex, gbc_compIndex);
|
|
compIndexBtn = new JButton("调整位置");
|
GridBagConstraints gbc_compIndexBtn = new GridBagConstraints();
|
gbc_compIndexBtn.gridwidth = 2;
|
gbc_compIndexBtn.insets = new Insets(0, 0, 0, 5);
|
gbc_compIndexBtn.gridx = 19;
|
gbc_compIndexBtn.gridy = 0;
|
panel.add(compIndexBtn, gbc_compIndexBtn);
|
|
// deleteRadio = new JRadioButton("删除前缀(值为字符个数)");
|
// GridBagConstraints gbc_deleteRadio = new GridBagConstraints();
|
// gbc_deleteRadio.gridwidth = 2;
|
// gbc_lblNewLabel.anchor = GridBagConstraints.WEST;
|
// gbc_deleteRadio.insets = new Insets(0, 0, 0, 5);
|
// gbc_deleteRadio.gridx = 1;
|
// gbc_deleteRadio.gridy = 1;
|
// panel.add(deleteRadio, gbc_deleteRadio);
|
// bg.add(deleteRadio);
|
// deleteRadio.setSelected(true);
|
//
|
// addRadio = new JRadioButton("增加前缀(值为要增加的字符)");
|
// GridBagConstraints gbc_addRadio = new GridBagConstraints();
|
// gbc_addRadio.gridwidth = 2;
|
// gbc_addRadio.insets = new Insets(0, 0, 0, 5);
|
// gbc_addRadio.gridx = 3;
|
// gbc_addRadio.gridy = 1;
|
// panel.add(addRadio, gbc_addRadio);
|
// bg.add(addRadio);
|
//
|
// label_2 = new JLabel("值");
|
// GridBagConstraints gbc_label_2 = new GridBagConstraints();
|
// gbc_label_2.insets = new Insets(0, 0, 0, 5);
|
// gbc_label_2.gridwidth = 2;
|
// gbc_label_2.gridx = 5;
|
// gbc_label_2.gridy = 1;
|
// gbc_label_2.anchor = GridBagConstraints.NORTHEAST;
|
// panel.add(label_2, gbc_label_2);
|
|
// valueIndex = new JTextField();
|
// GridBagConstraints gbc_valueIndex = new GridBagConstraints();
|
// gbc_valueIndex.gridwidth = 2;
|
// gbc_valueIndex.anchor = GridBagConstraints.WEST;
|
// gbc_valueIndex.insets = new Insets(0, 0, 0, 5);
|
// gbc_valueIndex.gridx = 7;
|
// gbc_valueIndex.gridy = 1;
|
// gbc_valueIndex.weightx = 0.5;
|
// gbc_valueIndex.fill = GridBagConstraints.HORIZONTAL;
|
// valueIndex.setColumns(10);
|
// panel.add(valueIndex, gbc_valueIndex);
|
//
|
// editIndexBtn = new JButton("修改");
|
// GridBagConstraints gbc_editIndexBtn = new GridBagConstraints();
|
// gbc_editIndexBtn.insets = new Insets(0, 0, 0, 5);
|
// gbc_editIndexBtn.anchor = GridBagConstraints.WEST;
|
// gbc_editIndexBtn.gridx = 10;
|
// gbc_editIndexBtn.gridy = 1;
|
// panel.add(editIndexBtn, gbc_editIndexBtn);
|
|
// viewI18nButton = new JButton("查看国际化字典");
|
// GridBagConstraints gbc_viewI18nButton = new GridBagConstraints();
|
// gbc_viewI18nButton.insets = new Insets(0, 0, 0, 5);
|
// gbc_viewI18nButton.anchor = GridBagConstraints.WEST;
|
// gbc_viewI18nButton.gridx = 12;
|
// gbc_viewI18nButton.gridy = 1;
|
// panel.add(viewI18nButton, gbc_viewI18nButton);
|
}
|
|
private void display() {
|
Insets screenInsets = Toolkit.getDefaultToolkit()
|
.getScreenInsets(LogonApplication.frame.getGraphicsConfiguration());
|
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
|
this.setLocation(0, 0);
|
// dialog.setResizable(false);
|
this.setSize((int) screenSize.getWidth(), (int) (screenSize.getHeight() - screenInsets.bottom));
|
}
|
|
private JPanel createTreePanel() {
|
JPanel treePanel = new JPanel();
|
JScrollPane js = new JScrollPane();
|
DragTree tree = new DragTree(selectTreeNodeobject, otName);
|
treePanel.setLayout(new BorderLayout());
|
js.setViewportView(tree);
|
treePanel.add(js, BorderLayout.CENTER);
|
return treePanel;
|
}
|
|
private JPanel createTextPanel() {
|
JPanel btnPanel = new JPanel();
|
saveBtn = new JButton("保存");
|
clearCompnent = new JButton("清空");
|
deleteCompnent = new JButton("删除组件");
|
btnPanel.add(saveBtn);
|
btnPanel.add(clearCompnent);
|
btnPanel.add(deleteCompnent);
|
|
addCustBtn = new JButton("添加自定义组件");
|
btnPanel.add(addCustBtn);
|
|
previewBtn = new JButton("预览");
|
btnPanel.add(previewBtn);
|
|
// attrListBtn = new JButton("属性列表");
|
// btnPanel.add(attrListBtn);
|
|
configPanel = new JPanel();
|
configPanel.setBorder(new TitledBorder("设置"));
|
configPanel.setLayout(new BorderLayout());
|
widgetPanel = new WidgetPanel(prmItem, attribItem, _lstCompnent, this);
|
configPanel.add(widgetPanel, BorderLayout.CENTER);
|
|
mainPanel.setLayout(new BorderLayout());
|
contentPanel.setLayout(new BorderLayout());
|
jScrollPane = new JScrollPane(attrPane);
|
jScrollPane.setPreferredSize(new Dimension(800, 800));
|
contentPanel.add(jScrollPane, BorderLayout.CENTER);
|
// contentPanel.add(buttonPanel(),BorderLayout.SOUTH);
|
mainPanel.add(contentPanel, BorderLayout.CENTER);
|
mainPanel.add(btnPanel, BorderLayout.SOUTH);
|
// mainPanel.setBorder(BorderFactory
|
// .createTitledBorder("Drop target for filenames"));
|
mainPanel.add(configPanel, BorderLayout.EAST);
|
return mainPanel;
|
}
|
|
private void actionListener() {
|
// 修改前缀
|
// editIndexBtn.addActionListener(new ActionListener() {
|
// public void actionPerformed(ActionEvent paramActionEvent) {
|
// if (JLabelList.size() < 1) {
|
// VCIOptionPane.showMessage(LogonApplication.frame, "请选择要修改的组件!");
|
// return;
|
// }
|
// String setLabIndex = valueIndex.getText();
|
// if (setLabIndex != null && setLabIndex.length() > 0 && deleteRadio.isSelected()) {
|
// int labIndex = 0;
|
// try {
|
// labIndex = Integer.parseInt(setLabIndex);
|
// } catch (Exception e) {
|
// VCIOptionPane.showMessage(LogonApplication.frame, "输入值必须为整数!");
|
// return;
|
// }
|
// if (labIndex < 1) {
|
// VCIOptionPane.showMessage(LogonApplication.frame, "输入值无效!");
|
// return;
|
// }
|
// for (int i = 0; i < JLabelList.size(); i++) {
|
// String labText = JLabelList.get(i).getText();
|
// if (labText.length() <= labIndex) {
|
// VCIOptionPane.showMessage(LogonApplication.frame, "输入值必须小于字段长度!");
|
// return;
|
// }
|
// labText = labText.substring(labIndex);
|
//// if (comPRMItemMap.containsKey(labText)) {
|
//// VCIOptionPane.showMessage(LogonApplication.frame, "修改后字段名不能与当前已有字段同名!");
|
//// return;
|
//// }
|
// //prmItem = comPRMItemMap.get(JLabelList.get(i).getText());
|
// prmItem.setItemField(labText);
|
// JLabelList.get(i).setText(labText);
|
// //comPRMItemMap.remove(prmItem.getItemField());
|
// //comPRMItemMap.put(labText, prmItem);
|
// }
|
// } else if (setLabIndex != null && setLabIndex.length() > 0 && addRadio.isSelected()) {
|
// for (int i = 0; i < JLabelList.size(); i++) {
|
// String labText = JLabelList.get(i).getText();
|
// labText = setLabIndex + labText;
|
//// if (comPRMItemMap.containsKey(labText)) {
|
//// VCIOptionPane.showMessage(LogonApplication.frame, "修改后字段名不能与当前已有字段同名!");
|
//// return;
|
//// }
|
// JLabelList.get(i).setText(labText);
|
// prmItem.setItemField(labText);
|
// //comPRMItemMap.remove(JLabelList.get(i).getText());
|
// //comPRMItemMap.put(labText, prmItem);
|
// }
|
// } else {
|
// VCIOptionPane.showMessage(LogonApplication.frame, "值不能为空!");
|
// return;
|
// }
|
// layoutComponent();
|
// configPanel.remove(widgetPanel);
|
// addWidgetPanel();
|
// configPanel.updateUI();
|
// }
|
// });
|
// 保存页面元素
|
saveBtn.addActionListener(new ActionListener() {
|
|
@Override
|
public void actionPerformed(ActionEvent arg0) {
|
// filenamePath = JOptionPane.showInputDialog("输入文件名称");
|
// if(filenamePath==null||"".equals(filenamePath)){
|
// return;
|
// }
|
boolean flag = false;
|
if (_isBtm == false) {
|
if (viName.getText() == null || "".equals(viName.getText())) {
|
VCIOptionPane.showMessage(LogonApplication.frame, "名称不能为空!");
|
return;
|
}
|
Component[] cs = attrPane.getComponents();
|
if (cs == null || cs.length == 0) {
|
VCIOptionPane.showMessage(LogonApplication.frame, "页面不能为空!");
|
return;
|
}
|
LinkedList<VCIJTableNode<PortalVI>> list = platformPortalTablePanel.getTablePanel().getTableModel()
|
.getList();
|
for (int i = 0; i < list.size(); i++) {
|
VCIJTableNode<PortalVI> vcijTableNode = list.get(i);
|
PortalVI object = vcijTableNode.getObject();
|
if (pvi != null) {
|
try {
|
flag = UITools.getService().judgeUpdateButton(typeFlag.getIntVal(), pvi.viName, pvi.typeName);
|
} catch (VCIError e) {
|
showMessage(LogonApplication.frame, new VCIException(e.code, e.messages));
|
return;
|
}
|
if (flag && (!viName.getText().equals(titleName)) && (titleName != null)) {
|
VCIOptionPane.showMessage(LogonApplication.frame, "该表单已经被引用,不能修改名称!");
|
viName.setText(pvi.viName);
|
return;
|
}
|
if (!object.id.equals(pvi.id)) {
|
if (object.viName.equals(viName.getText())) {
|
VCIOptionPane.showMessage(LogonApplication.frame, "名称已经存在!");
|
return;
|
}
|
}
|
} else {
|
if (object.viName.equals(viName.getText())) {
|
VCIOptionPane.showMessage(LogonApplication.frame, "名称已经存在!");
|
return;
|
}
|
}
|
|
}
|
if (saveForm()) {
|
dispose();
|
}
|
} else {
|
try {
|
flag = UITools.getService().judgeUpdateButton(typeFlag.getIntVal(), pvi.viName, pvi.typeName);
|
if (saveForm()) {
|
dispose();
|
}
|
} catch (VCIError e) {
|
showMessage(LogonApplication.frame, new VCIException(e.code, e.messages));
|
return;
|
}
|
}
|
}
|
});
|
|
// 清空页面元素
|
clearCompnent.addActionListener(new ActionListener() {
|
|
@Override
|
public void actionPerformed(ActionEvent arg0) {
|
Object[] options = { "Yes", "No" };
|
int option = JOptionPane.showOptionDialog(LogonApplication.frame, "确认是否清除所有组件", "表单页面定义",
|
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[1]);
|
// int option = JOptionPane.showConfirmDialog(getInstance(), "是否确认删除", "删除确认",
|
// JOptionPane.YES_NO_CANCEL_OPTION);
|
if (option != JOptionPane.YES_OPTION) {
|
return;
|
}
|
countX = 0;
|
countY = 0;
|
attrPane.removeAll();
|
attrPane.updateUI();
|
_lstCompnent.clear();
|
configMap.clear();
|
//comPRMItemMap.clear();
|
}
|
});
|
|
// 删除指定组件
|
deleteCompnent.addActionListener(new ActionListener() {
|
|
@Override
|
public void actionPerformed(ActionEvent arg0) {
|
if (selectedComponent instanceof JLabel) {
|
attrPane.remove(configMap.get(selectedComponent));
|
attrPane.remove(selectedComponent);
|
configMap.remove(selectedComponent);
|
|
for (int i = 0; i < _lstCompnent.size(); i++) {
|
if (_lstCompnent.get(i).getjLabel() != null && ((JLabel) selectedComponent).getText()
|
.equals(_lstCompnent.get(i).getjLabel().getText())) {
|
//comPRMItemMap.remove(((JLabel) selectedComponent).getText());
|
_lstCompnent.remove(i);
|
break;
|
}
|
}
|
attrPane.updateUI();
|
attrPane.validate();
|
|
layoutComponent();
|
} else {
|
VCIOptionPane.showMessage(LogonApplication.frame, "请选择了组件名称进行删除!");
|
}
|
}
|
|
});
|
|
addCustBtn.addActionListener(new ActionListener() {
|
|
@Override
|
public void actionPerformed(ActionEvent arg0) {
|
CustomWidgetDialog dialog = new CustomWidgetDialog(null, null, selectTreeNodeobject, null);//, comPRMItemMap);
|
dialog.setVisible(true);
|
String arrtName = dialog.getArrtName();
|
if ("".equals(arrtName)) {
|
return;
|
}
|
CompnentGroup gg = new CompnentGroup(arrtName);
|
String attrDisType = dialog.getAttrDisType();
|
if (attribItem == null) {
|
attribItem = new AttribItem();
|
}
|
attribItem.name = dialog.getArrtName();
|
gg.setPrmItem(dialog.getPrmItem());
|
|
addCustomComponent(gg, arrtName, attrDisType);
|
_lstCompnent.add(gg);
|
layoutComponent();
|
}
|
});
|
previewBtn.addActionListener(new ActionListener() {
|
|
@Override
|
public void actionPerformed(ActionEvent arg0) {
|
// Component[] cs = attrPane.getComponents();// 遍历内容控制面版
|
List<PRMItem> prmItemList = new ArrayList<PRMItem>();
|
// for (int i = 0; i < cs.length; i++) {
|
// String name = "";
|
// if (cs[i] instanceof JLabel) {
|
// name = ((JLabel) cs[i]).getText();
|
// }
|
// if (name != null && !"".equals(name)) {
|
// PRMItem newPrmItem = comPRMItemMap.get(name);
|
// if (newPrmItem != null) {
|
// prmItemList.add(newPrmItem);
|
// }
|
// }
|
// }
|
for (int i = 0; i < _lstCompnent.size(); i++) {
|
prmItemList.add(_lstCompnent.get(i).getPrmItem());
|
}
|
|
PortalVI p = new PortalVI();
|
p.viType = portalVIType.getIntVal();
|
p.typeFlag = typeFlag.getIntVal();
|
PRM newPrm = new PRM();
|
newPrm.setShowCols(componentDisCol.getText());
|
newPrm.setFormQtName((String) qtName.getSelectedItem());
|
newPrm.setPrmItemList(prmItemList);
|
String prmText;
|
try {
|
prmText = UITools.getPRMText(newPrm);
|
p.viName = viName.getText();
|
p.typeName = otName;
|
p.prm = prmText;
|
} catch (Throwable e) {
|
e.printStackTrace();
|
}
|
|
PreviewDialog pd = new PreviewDialog(p, typeFlag);
|
pd.setVisible(true);
|
}
|
});
|
setColBtn.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent paramActionEvent) {
|
colCount = Integer.parseInt(componentDisCol.getText());
|
if (colCount > 3) {
|
VCIOptionPane.showMessage(LogonApplication.frame, "显示列不能超过3列!");
|
return;
|
}
|
layoutComponent();
|
}
|
});
|
|
compIndexBtn.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent paramActionEvent) {
|
int setIndex = Integer.parseInt(compIndex.getText());
|
if (setIndex < 1)
|
return;
|
|
//ArrayList<CompnentGroup> newGroupList = new ArrayList<CompnentGroup>();
|
String labText = ((JLabel) selectedComponent).getText();
|
CompnentGroup group = getCompnentGroup(labText);
|
_lstCompnent.remove(group);
|
_lstCompnent.add(setIndex - 1, group);
|
|
// List<CompnentGroup> hidComlist = new ArrayList<CompnentGroup>();
|
// for (int i = 0; i < _lstCompnent.size(); i++) {
|
// if (_lstCompnent.get(i).getjLabel() == null) {
|
// hidComlist.add(_lstCompnent.get(i));
|
// }
|
// }
|
// for (int i = 0; i < hidComlist.size(); i++) {
|
// _lstCompnent.remove(hidComlist.get(i));
|
// }
|
// for (int i = 0; i < _lstCompnent.size(); i++) {
|
// if (labText.equals(_lstCompnent.get(i).getjLabel().getText())) {
|
// if (setLabIndex - 1 > i) {
|
// _lstCompnent.add(setLabIndex, _lstCompnent.get(i));
|
// _lstCompnent.remove(i);
|
// } else {
|
// _lstCompnent.add(setLabIndex - 1, _lstCompnent.get(i));
|
// _lstCompnent.remove(i + 1);
|
// }
|
// break;
|
// }
|
// }
|
// for(int i=0;i<_lstCompnent.size();i++){
|
// newGroupList.add(_lstCompnent.get(i));
|
// }
|
// _lstCompnent = newGroupList;
|
layoutComponent();
|
}
|
});
|
|
// ===add by guo===
|
addModelButton.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent paramActionEvent) {
|
String btmName;
|
if (selectTreeNodeobject instanceof BtmItemWrapper) {
|
btmName = ((BtmItemWrapper) selectTreeNodeobject).btmItem.name;
|
CreateQueryModelDialog queryModelDialog = new CreateQueryModelDialog(FormDesignDialog.this,
|
selectTreeNodeobject, PortalVITypeFlag.BtmType);
|
name = queryModelDialog.getSelectedObject1();
|
dialog(btmName, queryModelDialog);
|
|
} else if (selectTreeNodeobject instanceof LinkTypeWrapper) {
|
btmName = ((LinkTypeWrapper) selectTreeNodeobject).linkType.name;
|
CreateQueryModelDialog queryModelDialog = new CreateQueryModelDialog(FormDesignDialog.this,
|
selectTreeNodeobject, PortalVITypeFlag.LinkType);
|
name = queryModelDialog.getSelectedObject2();
|
dialog(btmName, queryModelDialog);
|
}
|
|
}
|
});
|
// viewI18nButton.addActionListener(new ActionListener() {
|
// public void actionPerformed(ActionEvent paramActionEvent) {
|
// i18nTable();
|
// }
|
// });
|
}
|
|
/**
|
*
|
* <p>
|
* 国际化字典Dialog:
|
* </p>
|
*
|
* @author yangyang
|
* @time 2017-10-31
|
*/
|
// private void i18nTable(){
|
// VciI18nTableDialog vi18n = new VciI18nTableDialog();
|
// vi18n.setModal(true);
|
// vi18n.init();
|
// vi18n.setSize(900,600);
|
// vi18n.setLocationRelativeTo(ClientContextVariable.getFrame());
|
// vi18n.setVisible(true);
|
// }
|
private void dialog(String btmName, CreateQueryModelDialog queryModelDialog) {
|
if (!"".equals(name) && name != null) {
|
qtName.removeAllItems();
|
if (type1 == 1) {
|
btmName = ((BtmItemWrapper) selectTreeNodeobject).btmItem.name;
|
} else if (type1 == 2) {
|
btmName = ((LinkTypeWrapper) selectTreeNodeobject).linkType.name;
|
}
|
try {
|
QTInfo[] qts = QTDClient.getService().getObjTypeQTs(btmName);
|
for (QTInfo qt : qts) {
|
qtName.addItem(qt.qtName.trim());
|
}
|
} catch (VCIError e) {
|
e.printStackTrace();
|
}
|
qtName.setSelectedItem(name);
|
queryModelDialog.dispose();
|
}
|
}
|
|
public void showMessage(Component parent, VCIException exp) {
|
String message = LocaleDisplay.getI18nString(exp, "PLMUIService", this.getLocale());
|
VCIJOptionPane.showMessage(parent, message);
|
}
|
|
/**
|
* 添加自定义组件
|
*
|
* @param gg
|
* @param arrtName
|
*/
|
private void addCustomComponent(CompnentGroup gg, String arrtName, String type) {
|
// labelCom = new JLabel(arrtName);
|
// textField = new JTextField();
|
// textField.setEditable(false);
|
// textField.setPreferredSize(new Dimension(90, 25));
|
//
|
// textBtn = new TextButtonJPanel();
|
//
|
// textArea = new JTextArea();
|
// textArea.setEnabled(false);
|
// textArea.setEditable(false);
|
//
|
// calendarPanel = new VCIJCalendarPanel();
|
//
|
// comboBox = new VCIJComboBox();
|
// comboBox.setEditable(false);
|
//
|
// cz = new CanzhaoJPanel();
|
//
|
// checkBox = new JCheckBox();
|
//
|
// fileChooserJPanel = new FileChooserJPanel();
|
// System.out.println("X==" + countX + ";Y==" + countY);
|
// int nextCountX = 0;
|
|
ControlType ctrlType = ControlType.Parse(type);
|
if (ctrlType == null)
|
return;
|
|
CompnentUtil.CreateCompent(gg, ctrlType);
|
|
JLabel label = gg.getjLabel();
|
|
configMap.put(gg.getjLabel(), gg.getjCompnent());
|
|
// Map<String, List<String>> typeMap = TypeConstant.getTypeMap();
|
// String vtDataType = "";
|
//
|
// for (Map.Entry<String, List<String>> entry : typeMap.entrySet()) {
|
// List<String> value = entry.getValue();
|
// for (int i = 0; i < value.size(); i++) {
|
// if (type.equals(value.get(i))) {
|
// vtDataType = entry.getKey();
|
// }
|
// }
|
// }
|
// if (vtDataType.equals("VTInteger") || vtDataType.equals("VTString")
|
// || vtDataType.equals("VTDouble")) {
|
// }
|
// // textarea类型
|
// else if (vtDataType.equals("VTNote")) {
|
// }
|
// // 日期类型
|
// else if (vtDataType.equals("VTDate") || vtDataType.equals("VTTime")
|
// || vtDataType.equals("VTDateTime")) {
|
// }
|
// // 参照类型
|
// else if (vtDataType.equals("canzhao")) {
|
// attrPane.add(labelCom, new GridBagConstraints(countX, countY, 0, 0,
|
// 0.0, 0.0, GridBagConstraints.NORTHWEST,
|
// GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
|
// nextCountX = countX + 1;
|
// //System.out.println("X1==" + nextCountX + ";Y1==" + countY);
|
// attrPane.add(cz, new GridBagConstraints(nextCountX, countY, 0, 0,
|
// 0.0, 0.0, GridBagConstraints.NORTHWEST,
|
// GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
|
// configMap.put(labelCom, cz);
|
// gg.setjCompnent(cz);
|
// gg.setjLabel(labelCom);
|
// }
|
// // boolean类型
|
// else if (vtDataType.equals("VTBoolean")) {
|
// }
|
// // 文件选择组件
|
// else if (vtDataType.equals("VTFilePath")) {
|
// }else if(vtDataType.equals("partition")){
|
//
|
// }else{
|
// }
|
if (btmAttrMap.size() == 0) {
|
initBtmAttrMap();
|
}
|
attribItem = btmAttrMap.get(arrtName);
|
//attribItemMap.put(arrtName, attribItem);
|
gg.setAItem(attribItem);
|
|
// attrNameAndCompMap.put(arrtName, configMap);
|
label.addMouseListener(new MouseAdapter() {
|
@Override
|
public void mouseClicked(MouseEvent e) {
|
attrPane.requestFocus();
|
super.mouseClicked(e);
|
labelActionListener(e);
|
}
|
});
|
}
|
|
/**
|
* 添加自定义组件
|
*
|
* @param gg
|
* @param arrtName
|
*/
|
// private void addCustomComponent_old(Group gg, String arrtName, String type) {
|
// labelCom = new JLabel(arrtName);
|
// textField = new JTextField();
|
// textField.setEditable(false);
|
// textField.setPreferredSize(new Dimension(90, 25));
|
// textArea = new JTextArea();
|
// textArea.setEnabled(false);
|
// textArea.setEditable(false);
|
// calendarPanel = new VCIJCalendarPanel();
|
// comboBox = new VCIJComboBox();
|
// comboBox.setEditable(false);
|
// cz = new CanzhaoJPanel();
|
// checkBox = new JCheckBox();
|
// fileChooserJPanel = new FileChooserJPanel();
|
// //System.out.println("X==" + countX + ";Y==" + countY);
|
// int nextCountX = 0;
|
//
|
//
|
// Map<String, List<String>> typeMap = TypeConstant.getTypeMap();
|
// String vtDataType = "";
|
//
|
// for (Map.Entry<String, List<String>> entry : typeMap.entrySet()) {
|
// List<String> value = entry.getValue();
|
// for (int i = 0; i < value.size(); i++) {
|
// if (type.equals(value.get(i))) {
|
// vtDataType = entry.getKey();
|
// }
|
// }
|
// }
|
// if (vtDataType.equals("VTInteger") || vtDataType.equals("VTString")
|
// || vtDataType.equals("VTDouble")) {
|
// attrPane.add(labelCom, new GridBagConstraints(countX, countY, 0, 0,
|
// 0.0, 0.0, GridBagConstraints.NORTHWEST,
|
// GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
|
// nextCountX = countX + 1;
|
// //System.out.println("X1==" + nextCountX + ";Y1==" + countY);
|
// attrPane.add(textField, new GridBagConstraints(nextCountX, countY,
|
// 0, 0, 0.0, 0.0, GridBagConstraints.NORTHWEST,
|
// GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
|
// configMap.put(labelCom, textField);
|
// gg.setjCompnent(textField);
|
// gg.setjLabel(labelCom);
|
// }
|
// // textarea类型
|
// else if (vtDataType.equals("VTNote")) {
|
// countY++;
|
// countX = 0;
|
// attrPane.add(labelCom, new GridBagConstraints(countX, countY, 0, 0,
|
// 0.0, 0.0, GridBagConstraints.NORTHWEST,
|
// GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
|
//
|
// textArea = new JTextArea();
|
// jsp = new JScrollPane();
|
// jsp.getViewport().add(textArea);
|
// nextCountX = countX + 1;
|
// //System.out.println("X1==" + nextCountX + ";Y1==" + countY);
|
// // 文本域
|
// attrPane.add(jsp, new GridBagConstraints(nextCountX, countY,
|
// 7, 2, 0.0, 0.0, GridBagConstraints.NORTH,
|
// GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
|
// countX = 0;
|
// nextCountX = 0;
|
// countY = countY + 2;
|
// textAreaMap.put(labelCom, "VTNote");
|
// textAreaMap.put(textArea, "VTNote");
|
// configMap.put(labelCom, textArea);
|
// gg.setjCompnent(textArea);
|
// gg.setjLabel(labelCom);
|
// }
|
// // 日期类型
|
// else if (vtDataType.equals("VTDate") || vtDataType.equals("VTTime")
|
// || vtDataType.equals("VTDateTime")) {
|
// attrPane.add(labelCom, new GridBagConstraints(countX, countY, 0, 0,
|
// 0.0, 0.0, GridBagConstraints.NORTHWEST,
|
// GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
|
//
|
// nextCountX = countX + 1;
|
// //System.out.println("X1==" + nextCountX + ";Y1==" + countY);
|
// attrPane.add(calendarPanel, new GridBagConstraints(nextCountX,
|
// countY, 0, 0, 0.0, 0.0, GridBagConstraints.NORTHWEST,
|
// GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
|
// configMap.put(labelCom, calendarPanel);
|
// gg.setjCompnent(calendarPanel);
|
// gg.setjLabel(labelCom);
|
// }
|
// // 参照类型
|
// else if (vtDataType.equals("canzhao")) {
|
// attrPane.add(labelCom, new GridBagConstraints(countX, countY, 0, 0,
|
// 0.0, 0.0, GridBagConstraints.NORTHWEST,
|
// GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
|
// nextCountX = countX + 1;
|
// //System.out.println("X1==" + nextCountX + ";Y1==" + countY);
|
// attrPane.add(cz, new GridBagConstraints(nextCountX, countY, 0, 0,
|
// 0.0, 0.0, GridBagConstraints.NORTHWEST,
|
// GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
|
// configMap.put(labelCom, cz);
|
// gg.setjCompnent(cz);
|
// gg.setjLabel(labelCom);
|
// }
|
// // boolean类型
|
// else if (vtDataType.equals("VTBoolean")) {
|
// attrPane.add(labelCom, new GridBagConstraints(countX, countY, 0, 0,
|
// 0.0, 0.0, GridBagConstraints.NORTHWEST,
|
// GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
|
//
|
// nextCountX = countX + 1;
|
// //System.out.println("X1==" + nextCountX + ";Y1==" + countY);
|
// comboBox.setPreferredSize(new Dimension(120, 25));
|
// comboBox.setEditable(false);
|
// attrPane.add(comboBox, new GridBagConstraints(nextCountX, countY,
|
// 0, 0, 0.0, 0.0, GridBagConstraints.NORTHWEST,
|
// GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
|
// configMap.put(labelCom, comboBox);
|
// gg.setjCompnent(comboBox);
|
// gg.setjLabel(labelCom);
|
// }
|
// // 文件选择组件
|
// else if (vtDataType.equals("VTFilePath")) {
|
// attrPane.add(labelCom, new GridBagConstraints(countX, countY, 0, 0,
|
// 0.0, 0.0, GridBagConstraints.NORTHWEST,
|
// GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
|
//
|
// nextCountX = countX + 1;
|
// //System.out.println("X1==" + nextCountX + ";Y1==" + countY);
|
// attrPane.add(fileChooserJPanel, new GridBagConstraints(nextCountX,
|
// countY, 0, 0, 0.0, 0.0, GridBagConstraints.NORTHWEST,
|
// GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
|
// configMap.put(labelCom, fileChooserJPanel);
|
// gg.setjCompnent(fileChooserJPanel);
|
// gg.setjLabel(labelCom);
|
// }else if(vtDataType.equals("partition")){
|
//
|
// }else{
|
// attrPane.add(labelCom, new GridBagConstraints(countX, countY, 0, 0,
|
// 0.0, 0.0, GridBagConstraints.NORTHWEST,
|
// GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
|
// nextCountX = countX + 1;
|
// //System.out.println("X1==" + nextCountX + ";Y1==" + countY);
|
// attrPane.add(textField, new GridBagConstraints(nextCountX, countY,
|
// 0, 0, 0.0, 0.0, GridBagConstraints.NORTHWEST,
|
// GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
|
// configMap.put(labelCom, textField);
|
// gg.setjCompnent(textField);
|
// gg.setjLabel(labelCom);
|
// }
|
// if(btmAttrMap.size() == 0){
|
// initBtmAttrMap();
|
// }
|
// attribItem = btmAttrMap.get(arrtName);
|
// attribItemMap.put(arrtName, attribItem);
|
// attrNameAndCompMap.put(arrtName, configMap);
|
// labelCom.addMouseListener(new MouseAdapter() {
|
// @Override
|
// public void mouseClicked(MouseEvent e) {
|
// attrPane.requestFocus();
|
// super.mouseClicked(e);
|
// labelActionListener(e);
|
// }
|
// });
|
// }
|
|
private void labelActionListener(MouseEvent e) {
|
// Component[] components = attrPane.getComponents();
|
// for (Component c : components) {
|
// if (c instanceof JLabel) {
|
// ((JLabel) c).setBorder(null);
|
// }
|
// }
|
if (selectedComponent != null) {
|
((JLabel) selectedComponent).setBorder(null);
|
selectedComponent = null;
|
}
|
Component source = (Component) e.getSource();
|
selectedComponent = source;
|
JLabel lb = (JLabel) selectedComponent;
|
|
if (lb == null)
|
return;
|
|
lb.setBorder(javax.swing.BorderFactory.createLineBorder(Color.RED));
|
// if (KeyFlag == 0 && JLabelList.size() == 0 || KeyFlag == 1 && JLabelList.size() > 0) {
|
// int flag = -1;
|
// for (int i = 0; i < JLabelList.size(); i++) {
|
// if (JLabelList.get(i).getText().equals(lb.getText())) {
|
// flag = i;
|
// break;
|
// }
|
// }
|
// if (flag == -1) {
|
// JLabelList.add(lb);
|
// } else {
|
// JLabelList.remove(flag);
|
// }
|
// }
|
// if (KeyFlag == 1) {
|
// for (int i = 0; i < JLabelList.size(); i++) {
|
// JLabelList.get(i).setBorder(javax.swing.BorderFactory.createLineBorder(Color.BLACK));
|
// }
|
// } else {
|
// lb.setBorder(javax.swing.BorderFactory.createLineBorder(Color.BLACK));
|
// JLabelList.clear();
|
// JLabelList.add(lb);
|
// }
|
//comHashCode = source.hashCode();
|
// System.out.println("labelCom.comHashCode=" + comHashCode);
|
//attribItem = attribItemMap.get(lb.getText());
|
//prmItem = comPRMItemMap.get(lb.getText());
|
CompnentGroup group = getCompnentGroup(lb.getName());
|
if (group != null)
|
prmItem = group.getPrmItem();
|
else
|
prmItem = null;
|
|
attribItem = group.getAItem();
|
|
configPanel.remove(widgetPanel);
|
addWidgetPanel();
|
configPanel.updateUI();
|
|
int index = _lstCompnent.indexOf(group) + 1;
|
compIndex.setText(index + "");
|
// for (int i = 0; i < _lstCompnent.size(); i++) {
|
// CompnentGroup group = _lstCompnent.get(i);
|
// if (((JLabel) group.getjLabel()) != null && ((JLabel) group.getjLabel()).getText().equals(lb.getText())) {
|
// i = i + 1;
|
// compIndex.setText(i + "");
|
// }
|
// }
|
}
|
|
private CompnentGroup getCompnentGroup(String field) {
|
for (int i = 0; i < _lstCompnent.size(); i++) {
|
CompnentGroup group = _lstCompnent.get(i);
|
if (group.getField().equals(field)) {
|
return group;
|
}
|
}
|
|
return null;
|
}
|
|
private Map<String, AttribItem> btmAttrMap = new HashMap<String, AttribItem>();
|
|
private void initBtmAttrMap() {
|
AttribItem[] btAbItems = BtmProvider.getInstance().getBtAbItems(otName);
|
for (AttribItem attribItem : btAbItems) {
|
btmAttrMap.put(attribItem.name, attribItem);
|
}
|
}
|
|
private void labelKeyListener(KeyEvent e) {
|
// System.out.println(e);
|
}
|
|
private void attrPane_key(KeyEvent e) {
|
|
}
|
|
private void addWidgetPanel() {
|
widgetPanel = new WidgetPanel(prmItem, attribItem, _lstCompnent, this);
|
configPanel.add(widgetPanel, BorderLayout.CENTER);
|
}
|
|
/**
|
* 组件重新绘制
|
*/
|
public void layoutComponent() {
|
attrPane.removeAll();
|
int x = 0;
|
int y = 0;
|
for (int i = 0; i < _lstCompnent.size(); i++) {
|
if (x > 2 * colCount - 1) {
|
x = 0;
|
y++;
|
}
|
|
CompnentGroup comp = _lstCompnent.get(i);
|
if (comp.getjCompnent() instanceof JTextArea) {
|
if (x != 0)
|
y++;
|
|
attrPane.add(comp.getjLabel(), new GridBagConstraints(0, y, 0, 0, 0.0, 0.0,
|
GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
|
JScrollPane jsp = new JScrollPane();
|
jsp.getViewport().add(comp.getjCompnent());
|
attrPane.add(jsp, new GridBagConstraints(1, y, 7, 2, 0.0, 0.0, GridBagConstraints.NORTH,
|
GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
|
y = y + 2;
|
x = 0;
|
} else {
|
if (comp.getjLabel() != null) {
|
attrPane.add(comp.getjLabel(), new GridBagConstraints(x++, y, 0, 0, 0.0, 0.0,
|
GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
|
attrPane.add(comp.getjCompnent(), new GridBagConstraints(x++, y, 0, 0, 0.0, 0.0,
|
GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
|
}
|
}
|
}
|
|
countX = x;
|
countY = y;
|
|
attrPane.updateUI();
|
}
|
|
/**
|
* 存储lab与其后面关联的组件关系
|
*/
|
private Map<Component, Component> configMap = new HashMap<Component, Component>();
|
/**
|
* 存储属性对应的控件
|
*/
|
// private Map<String, Map<Component, Component>> attrNameAndCompMap = new
|
// HashMap<String, Map<Component, Component>>();
|
private JPanel panel;
|
private JPanel panelMain;
|
private JLabel lblNewLabel;
|
private JTextField viName;
|
private JButton addCustBtn;
|
private JButton previewBtn;
|
// private JButton attrListBtn;
|
private JRadioButton deleteRadio;
|
private JRadioButton addRadio;
|
private ButtonGroup bg = new ButtonGroup();
|
|
private JLabel label;
|
private JLabel qtNameLab;
|
private JTextField componentDisCol;
|
private JButton setColBtn;
|
private JLabel label_1;
|
private JLabel label_2;
|
private JTextField compIndex;
|
private JTextField valueIndex;
|
private JComboBox qtName;
|
private JButton compIndexBtn;
|
private JButton editIndexBtn;
|
// private JButton viewI18nButton;
|
|
public void drop(DropTargetDropEvent e) {
|
try {
|
DataFlavor stringFlavor = DataFlavor.stringFlavor;
|
Transferable tr = e.getTransferable();
|
|
if (e.isDataFlavorSupported(stringFlavor)) {
|
Object transferData = tr.getTransferData(stringFlavor);
|
String arrtName = "";
|
if (transferData instanceof AttributeNode) {
|
AttributeNode anode = (AttributeNode)transferData;
|
attribItem = anode.getAttrItem();
|
arrtName = anode.getName();
|
}
|
else if (transferData instanceof AttribItem) {
|
attribItem = (AttribItem) transferData;
|
arrtName = attribItem.name;
|
}
|
else if (transferData instanceof String) {
|
arrtName = (String) transferData;
|
attribItem = new AttribItem();
|
attribItem.name = arrtName;
|
}
|
e.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
|
|
if (checkComponentIsExist(arrtName))
|
return;
|
|
CompnentGroup gg = new CompnentGroup(arrtName);
|
gg.setAItem(attribItem);
|
addComponent(gg, arrtName);
|
|
attrPane.updateUI();
|
_lstCompnent.add(gg);
|
layoutComponent();
|
e.dropComplete(true);
|
} else {
|
e.rejectDrop();
|
}
|
} catch (IOException ioe) {
|
ioe.printStackTrace();
|
} catch (UnsupportedFlavorException ufe) {
|
ufe.printStackTrace();
|
}
|
}
|
|
/**
|
* 添加页面元素
|
*
|
* @param gg
|
* @param arrtName
|
*/
|
private void addComponent(CompnentGroup gg, String arrtName) {
|
|
int nextCountX = 0;
|
String vtDataType = "";
|
vtDataType = attribItem.vtDataType;
|
|
ControlType ctrlType = ControlType.Text;
|
|
if (vtDataType.equals("VTString")) {
|
ctrlType = ControlType.Text;
|
}
|
else if (vtDataType.equals("VTInteger") || vtDataType.equals("VTDouble")) {
|
ctrlType = ControlType.Number;
|
}
|
// textarea类型
|
else if (vtDataType.equals("VTNote")) {
|
ctrlType = ControlType.TextArea;
|
}
|
// 日起类型
|
else if (vtDataType.equals("VTDate") || vtDataType.equals("VTTime") || vtDataType.equals("VTDateTime")) {
|
ctrlType = ControlType.Date;
|
}
|
// 参照类型
|
else if (vtDataType.equals("canzhao")) {
|
ctrlType = ControlType.TextBtn;
|
}
|
// boolean类型
|
else if (vtDataType.equals("VTBoolean")) {
|
ctrlType = ControlType.Checkbox;
|
}
|
// 文件选择组件
|
else if (vtDataType.equals("VTFilePath")) {
|
ctrlType = ControlType.File;
|
} else {
|
ctrlType = ControlType.Text;
|
}
|
|
if (gg.getPrmItem() == null) {
|
PRMItem prmi = new PRMItem();
|
prmi.setItemField(arrtName);
|
prmi.setItemName(attribItem.label);
|
prmi.setItemType(ctrlType.name().toLowerCase());
|
prmi.setItemValueList(new ArrayList<String>());
|
|
gg.setPrmItem(prmi);
|
}
|
|
CompnentUtil.CreateCompent(gg, ctrlType);
|
|
if (ctrlType == ControlType.TextArea) {
|
if (countX != 0)
|
countY++;
|
countX = 0;
|
attrPane.add(gg.getjLabel(), new GridBagConstraints(countX, countY, 0, 0, 0.0, 0.0, GridBagConstraints.NORTHWEST,
|
GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
|
|
nextCountX = countX + 1;
|
JScrollPane jsp = new JScrollPane();
|
jsp.getViewport().add(gg.getjCompnent());
|
attrPane.add(jsp, new GridBagConstraints(nextCountX, countY, 7, 2, 0.0, 0.0, GridBagConstraints.NORTH,
|
GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
|
countX = 0;
|
countY = countY + 2;
|
} else {
|
attrPane.add(gg.getjLabel(), new GridBagConstraints(countX, countY, 0, 0, 0.0, 0.0, GridBagConstraints.NORTHWEST,
|
GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
|
|
nextCountX = countX + 1;
|
attrPane.add(gg.getjCompnent(), new GridBagConstraints(nextCountX, countY, 0, 0, 0.0, 0.0,
|
GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
|
}
|
//attribItemMap.put(arrtName, attribItem);
|
|
// attrNameAndCompMap.put(arrtName, configMap);
|
gg.getjLabel().addMouseListener(new MouseAdapter() {
|
@Override
|
public void mouseClicked(MouseEvent e) {
|
super.mouseClicked(e);
|
labelActionListener(e);
|
}
|
});
|
gg.getjLabel().addKeyListener(new KeyListener() {
|
@Override
|
public void keyTyped(KeyEvent e) {
|
labelKeyListener(e);
|
}
|
|
@Override
|
public void keyReleased(KeyEvent e) {
|
labelKeyListener(e);
|
}
|
|
@Override
|
public void keyPressed(KeyEvent e) {
|
labelKeyListener(e);
|
}
|
});
|
}
|
|
/**
|
* 判断页面元素重复
|
*
|
* @param arrtName
|
*/
|
private boolean checkComponentIsExist(String arrtName) {
|
// 判断页面元素重复
|
Component[] components = attrPane.getComponents();
|
for (Component c : components) {
|
if (c instanceof JLabel) {
|
String labelName = ((JLabel) c).getText().toString().trim();
|
if (labelName.equals(arrtName)) {
|
VCIOptionPane.showMessage(LogonApplication.frame, "该元素已经存在,不能重复添加!");
|
return true;
|
}
|
}
|
}
|
return false;
|
}
|
|
public boolean saveForm() {
|
Component[] cs = this.attrPane.getComponents();// 遍历内容控制面版
|
List<PRMItem> prmItemList = new ArrayList<PRMItem>();
|
// for (int i = 0; i < cs.length; i++) {
|
// String name = "";
|
// if (cs[i] instanceof JLabel) {
|
// name = ((JLabel) cs[i]).getText();
|
// }
|
// if (name != null && !"".equals(name)) {
|
// PRMItem newPrmItem = comPRMItemMap.get(name);
|
// if (newPrmItem == null) {
|
// VCIOptionPane.showMessage(LogonApplication.frame, "请先保存\"" + name + "\"的属性设置");
|
// return false;
|
// }
|
//// comPRMItemMap.remove(name);
|
// prmItemList.add(newPrmItem);
|
// }
|
// }
|
// for (Map.Entry<String, PRMItem> entry : comPRMItemMap.entrySet()) {
|
// PRMItem newPrmItem = entry.getValue();
|
// if (newPrmItem == null) {
|
// VCIOptionPane.showMessage(LogonApplication.frame, "请先保存\"" + entry.getValue() + "\"的属性设置");
|
// return false;
|
// }
|
//// prmItemList.add(newPrmItem);
|
// }
|
|
for (int i = 0; i < _lstCompnent.size(); i++) {
|
PRMItem prmItem = _lstCompnent.get(i).getPrmItem();
|
if (prmItem == null) {
|
VCIOptionPane.showMessage(LogonApplication.frame, "请先保存\"" + _lstCompnent.get(i).getField() + "\"的属性设置");
|
return false;
|
}
|
prmItemList.add(prmItem);
|
}
|
|
if (pvi == null) {
|
pvi = new PortalVI();
|
pvi.id = ObjectUtility.getNewObjectID36();
|
pvi.viType = portalVIType.getIntVal();
|
} else {
|
pvi.viType = pvi.viType;
|
}
|
pvi.typeFlag = typeFlag.getIntVal();
|
PRM newPrm = new PRM();
|
newPrm.setShowCols(componentDisCol.getText());
|
newPrm.setFormQtName((String) qtName.getSelectedItem());
|
newPrm.setPrmItemList(prmItemList);
|
try {
|
String prmText = UITools.getPRMText(newPrm);
|
pvi.viName = viName.getText();
|
pvi.typeName = otName;
|
pvi.prm = prmText;
|
if (pvi == null) {
|
UITools.getService().savePortalVI(pvi);
|
} else {
|
UITools.getService().updatePortalVI(pvi);
|
}
|
return true;
|
} catch (Throwable e) {
|
e.printStackTrace();
|
return false;
|
}
|
}
|
|
private void initData() {
|
if (pvi != null) {
|
viName.setText(pvi.viName);
|
if (_isBtm == true) {
|
viName.setEditable(false);
|
}
|
String prmText = pvi.prm;
|
prm = UITools.getPRM(prmText);
|
colCount = Integer.parseInt(prm.getShowCols() == null ? "3" : prm.getShowCols());
|
componentDisCol.setText(colCount + "");
|
qtName.setSelectedItem(prm.getFormQtName());
|
PRMItem[] dataObjs = prm.getPrmItemList().toArray(new PRMItem[] {});
|
// System.out.println();
|
String arrtName = "";
|
String arrtDisType = "";
|
for (PRMItem obj : dataObjs) {
|
CompnentGroup gg = new CompnentGroup(obj.getItemField());
|
arrtName = obj.getItemField();
|
arrtDisType = obj.getItemType();
|
//comPRMItemMap.put(arrtName, obj);
|
gg.setPrmItem(obj);
|
|
addCustomComponent(gg, arrtName, arrtDisType);
|
_lstCompnent.add(gg);
|
}
|
layoutComponent();
|
// attrPane.updateUI();
|
}
|
}
|
|
private void fillQtNameCom() {
|
qtName.addItem("");
|
try {
|
QTInfo[] qts = QTDClient.getService().getObjTypeQTs(otName);
|
for (QTInfo qt : qts) {
|
qtName.addItem(qt.qtName);
|
}
|
} catch (VCIError e) {
|
e.printStackTrace();
|
}
|
|
}
|
|
public void dragEnter(DropTargetDragEvent e) {
|
}
|
|
public void dragExit(DropTargetEvent e) {
|
}
|
|
public void dragOver(DropTargetDragEvent e) {
|
}
|
|
public void dropActionChanged(DropTargetDragEvent e) {
|
}
|
|
@Override
|
public void dragGestureRecognized(DragGestureEvent e) {
|
|
}
|
|
@Override
|
public void dragDropEnd(DragSourceDropEvent dsde) {
|
// TODO Auto-generated method stub
|
|
}
|
|
@Override
|
public void dragEnter(DragSourceDragEvent dsde) {
|
// TODO Auto-generated method stub
|
|
}
|
|
@Override
|
public void dragExit(DragSourceEvent dse) {
|
// TODO Auto-generated method stub
|
|
}
|
|
@Override
|
public void dragOver(DragSourceDragEvent dsde) {
|
// TODO Auto-generated method stub
|
|
}
|
|
@Override
|
public void dropActionChanged(DragSourceDragEvent dsde) {
|
// TODO Auto-generated method stub
|
|
}
|
|
}
|