package com.vci.client.portal.platformPortal;
|
|
import java.awt.BorderLayout;
|
import java.awt.Dialog;
|
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 java.util.ArrayList;
|
import java.util.LinkedHashMap;
|
import java.util.LinkedList;
|
import java.util.List;
|
|
import javax.swing.ButtonGroup;
|
import javax.swing.JButton;
|
import javax.swing.JLabel;
|
import javax.swing.JOptionPane;
|
import javax.swing.JPanel;
|
import javax.swing.JRadioButton;
|
import javax.swing.JTextField;
|
import javax.swing.border.TitledBorder;
|
import javax.swing.event.DocumentEvent;
|
import javax.swing.event.DocumentListener;
|
|
import com.vci.client.LogonApplication;
|
import com.vci.client.omd.btm.ui.BtmClient;
|
import com.vci.client.omd.btm.wrapper.BtmItemWrapper;
|
import com.vci.client.omd.linktype.LinkTypeStart;
|
import com.vci.client.omd.linktype.LinkTypeWrapper;
|
import com.vci.client.portal.Formdesign.FormDesignDialog;
|
import com.vci.client.portal.utility.UITools;
|
import com.vci.client.ui.swing.VCIOptionPane;
|
import com.vci.client.ui.swing.VCISwingUtil;
|
import com.vci.client.ui.swing.components.VCIJButton;
|
import com.vci.client.ui.swing.components.VCIJComboBox;
|
import com.vci.client.ui.swing.components.VCIJPanel;
|
import com.vci.client.ui.swing.components.table.AbstractVCIJTableDataProvider;
|
import com.vci.client.ui.swing.components.table.VCIJTableNode;
|
import com.vci.client.ui.swing.components.table.VCIJTablePanel;
|
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.PortalService.GetPagePortalVIArrayByPageInfoResult;
|
import com.vci.corba.portal.data.PortalVI;
|
|
public class PlatformPortalTablePanel extends JPanel {
|
private static final long serialVersionUID = 1L;
|
private VCIJButton addButton = VCISwingUtil.createVCIJButton("", "增加", "增加", "add.png", null);
|
private VCIJButton editButton = VCISwingUtil.createVCIJButton("", "修改", "修改", "edit.png", null);
|
private VCIJButton deleteButton = VCISwingUtil.createVCIJButton("", "删除", "删除", "delete.gif", null);
|
private VCIJButton cloneBtn = VCISwingUtil.createVCIJButton("", "克隆", "克隆", "copy.gif");
|
// private VCIJButton allExpBtn = new VCIJButton("全部导出");
|
private VCIJButton expBtn = new VCIJButton("导出");
|
private VCIJButton impBtn = new VCIJButton("导入");
|
// private VCIJButton viewI18nButton =
|
// VCISwingUtil.createVCIJButton("viewI18nButton", "查看国际化字典", "查看国际化字典",
|
// "image.png");
|
// add by guo
|
private VCIJButton getSeletedNode = new VCIJButton("选择");
|
|
private VCIJComboBox typeComb = new VCIJComboBox();
|
|
private JTextField textField = null;
|
private Object selectTreeNodeobject;
|
|
private JRadioButton formRadio;
|
private JRadioButton tableRadio;
|
private ButtonGroup bg = new ButtonGroup();
|
// private int type = -1;
|
// private int type1 = -1;
|
private PortalVITypeFlag typeFlag;
|
private String searchValue;
|
private JButton clonedestbutton;
|
private Object clonedestObject;
|
private String selectedObjectName;
|
private Dialog parentDialog;
|
// 是否通过输入界面的查询条件进行刷新
|
private boolean isConditionRefresh = false;
|
/**
|
* 是否显示 Form & Table JRadioButton
|
*/
|
private boolean showFormTableRadioButton = true;
|
/**
|
* 是否显示 克隆输入及按钮
|
*/
|
private boolean showCloneOptButton = true;
|
/**
|
* 是否显示底部的操作按钮
|
*/
|
private boolean showSouthNormalButtons = true;
|
/**
|
* 表单类型 -1:全部 0:table 1:form
|
*/
|
private PortalVIType portalVIType = null;
|
|
// public PlatformPortalTablePanel(Object object,
|
// PortalVITypeFlag typeFlag) {
|
// this(object, typeFlag, true, true, true, null, "门户管理", true);
|
// }
|
|
private boolean loadDataAfterBuildCompleted = true;
|
|
public PlatformPortalTablePanel(Object object, PortalVITypeFlag typeFlag, boolean showFormTableRadioButton,
|
boolean showCloneOptButton, boolean showSouthNormalButtons, PortalVIType portalVIType, String borderTitle,
|
boolean loadDataAfterBuildCompleted) {
|
this.selectTreeNodeobject = object;
|
this.typeFlag = typeFlag;
|
this.portalVIType = portalVIType;
|
this.showFormTableRadioButton = showFormTableRadioButton;
|
this.showCloneOptButton = showCloneOptButton;
|
this.showSouthNormalButtons = showSouthNormalButtons;
|
this.borderTitle = borderTitle;
|
this.loadDataAfterBuildCompleted = loadDataAfterBuildCompleted;
|
init();
|
getSeletedNode.setVisible(false);
|
}
|
|
// add by guo==
|
public PlatformPortalTablePanel(Object object, PortalVITypeFlag typeFlag, boolean isDialog, Dialog parentDialog,
|
PortalVIType portalVIType, boolean isLinkType) {
|
this.portalVIType = portalVIType;
|
try {
|
// 把选择的Btmtree上的节点类型由 String转换成需要的BtmItemWrapper类型,再赋值给selectTreeNodeobject
|
if (isLinkType == true) {
|
LinkTypeWrapper treeNode = new LinkTypeWrapper(LinkTypeStart.getService().getLinkType((String) object));
|
this.selectTreeNodeobject = treeNode;
|
} else {
|
BtmItemWrapper treeNode = new BtmItemWrapper(BtmClient.getService().getBtmItemByName((String) object));
|
this.selectTreeNodeobject = treeNode;
|
}
|
} catch (VCIError e) {
|
// TODO Auto-generated catch block
|
e.printStackTrace();
|
}
|
this.typeFlag = typeFlag;
|
this.parentDialog = parentDialog;
|
init();
|
getSeletedNode.setVisible(true);
|
}
|
|
private void init() {
|
LogonApplication.getUserEntityObject().setModules(this.getClass().getName());
|
initComponents();
|
initAction();// 初始化按钮点击事件
|
}
|
|
private void initComponents() {
|
setLayout(new BorderLayout());
|
add(initTablePanel(), BorderLayout.CENTER);
|
|
if (typeComb.getModel().getSize() > 0) {
|
typeComb.setSelectedIndex(0);
|
comboxActionPerformed();
|
}
|
}
|
|
private List<VCIJButton> selfCustomButtons = new LinkedList<VCIJButton>();
|
|
private List<VCIJButton> getSelfCustomButtons() {
|
selfCustomButtons.clear();
|
if (this.showSouthNormalButtons) {
|
selfCustomButtons.add(addButton);
|
selfCustomButtons.add(editButton);
|
selfCustomButtons.add(deleteButton);
|
selfCustomButtons.add(cloneBtn);
|
// selfCustomButtons.add(allExpBtn);
|
selfCustomButtons.add(expBtn);
|
selfCustomButtons.add(impBtn);
|
selfCustomButtons.add(getSeletedNode);
|
// selfCustomButtons.add(viewI18nButton);
|
}
|
return selfCustomButtons;
|
}
|
|
class MyDataProvider extends AbstractVCIJTableDataProvider<PortalVI> {
|
|
public PortalVI[] getDatas(int pageIndex, int pageSize) {
|
int type = -1;
|
if (portalVIType == null) {
|
type = -1;
|
}
|
if (tableRadio.isSelected()) {
|
type = 0;
|
} else if (formRadio.isSelected()) {
|
type = 1;
|
} else {
|
type = -1;
|
}
|
String btmName = "";
|
if (selectTreeNodeobject instanceof BtmItemWrapper) {
|
btmName = ((BtmItemWrapper) selectTreeNodeobject).btmItem.name;
|
} else if (selectTreeNodeobject instanceof LinkTypeWrapper) {
|
btmName = ((LinkTypeWrapper) selectTreeNodeobject).linkType.name;
|
}
|
PortalVI[] res = new PortalVI[0];
|
int total = 0;
|
try {
|
short viTypeVal = -1;
|
if (portalVIType != null) {
|
viTypeVal = portalVIType.getIntVal();
|
}
|
short typeFlagVal = -1;
|
if (typeFlag != null) {
|
typeFlagVal = typeFlag.getIntVal();
|
}
|
GetPagePortalVIArrayByPageInfoResult result = UITools.getService().getPagePortalVIArrayByPageInfo(btmName, searchNameText.getText().trim(),
|
viTypeVal, typeFlagVal, pageIndex, pageSize);
|
|
res = result.returnValue;
|
total = (int)result.total;
|
|
} catch (Exception ex) {
|
ex.printStackTrace();
|
}
|
super.total = total;
|
return res;
|
|
// if (searchValue == null) {
|
// searchValue = "";
|
// }
|
// if (isConditionRefresh) {
|
// startPage = 1;
|
// }
|
// int start = (startPage - 1) * pageSize + 1;
|
// int end = startPage * pageSize + 1;
|
// PortalVI[] portalViInfos = null;
|
// try {
|
// String btmName = "";
|
// if(selectTreeNodeobject instanceof BtmItemWrapper){
|
// btmName = ((BtmItemWrapper)selectTreeNodeobject).btmItem.name;
|
// }else if(selectTreeNodeobject instanceof LinkTypeWrapper){
|
// btmName = ((LinkTypeWrapper)selectTreeNodeobject).o.name;
|
// }
|
// if(type!=-1){
|
// portalViInfos = Tool.getService().getPagePortalVIArrayByCondition(btmName, type, searchValue, start, end);
|
// List<PortalVI> list = new ArrayList<PortalVI>();
|
// for(PortalVI portalvi : portalViInfos){
|
// if(portalvi.viType==type){
|
// list.add(portalvi);
|
// }
|
// }
|
// if(searchValue!=null&&!"".equals(searchValue)){
|
// portalViInfos = list.toArray(new PortalVI[0]);
|
// list = new ArrayList<PortalVI>();
|
// for(PortalVI portalvi : portalViInfos){
|
// if(portalvi.viName.contains(searchValue)){
|
// list.add(portalvi);
|
// }
|
// }
|
// }
|
// portalViInfos = list.toArray(new PortalVI[0]);
|
// }else{
|
// if(searchValue!=null&&!"".equals(searchValue)){
|
// portalViInfos = Tool.getService().getPagePortalVIArrayByCondition(btmName, type, searchValue, start, end);
|
// }else{
|
// portalViInfos = Tool.getService().getPagePortalVIArrayByCondition(btmName, type, searchValue, start, end);
|
// }
|
// }
|
// this.total = Tool.getService().getPortalVICountByCondition(btmName, type, searchValue);
|
// } catch (VCIError e) {
|
// e.printStackTrace();
|
// } catch (Throwable e) {
|
// e.printStackTrace();
|
// }
|
// return portalViInfos;
|
}
|
|
public VCIJTableNode<PortalVI> getNewRowNode(PortalVI dataObj) {
|
VCIJTableNode<PortalVI> node = new VCIJTableNode<PortalVI>(dataObj);
|
node.setPropertyValue(getSpecialColumns()[0], dataObj.typeName);
|
node.setPropertyValue(getSpecialColumns()[1], dataObj.viName);
|
String type = "";
|
if (dataObj.viType == 1) {
|
type = "表单";
|
} else if (dataObj.viType == 0) {
|
type = "表格";
|
}
|
node.setPropertyValue(getSpecialColumns()[2], type);
|
return node;
|
}
|
|
public String[] getSpecialColumns() {
|
return "业务名称, 名称,类型".split(",");
|
}
|
|
public int getTotal() {
|
return this.total;
|
}
|
|
}
|
|
MyDataProvider dataProvider = new MyDataProvider();
|
VCIJTablePanel<PortalVI> tablePanel = new VCIJTablePanel<PortalVI>(dataProvider);
|
private JTextField searchNameText = new JTextField();
|
private JTextField textField_1 = new JTextField();
|
|
public VCIJTablePanel<PortalVI> getTablePanel() {
|
return tablePanel;
|
}
|
|
public void setTablePanel(VCIJTablePanel<PortalVI> tablePanel) {
|
this.tablePanel = tablePanel;
|
}
|
|
private VCIJPanel tablePanel() {
|
int startIndex = dataProvider.getDataColumnStartIndex();
|
LinkedHashMap<Integer, Integer> widthMaps = new LinkedHashMap<Integer, Integer>();
|
widthMaps.put(startIndex++, 150);
|
widthMaps.put(startIndex++, 350);
|
widthMaps.put(startIndex++, 100);
|
tablePanel.setColumnWidthMaps(widthMaps);
|
tablePanel.setPageSizeList(new int[] { 50, 100, 200, 500, 50 });
|
tablePanel.setCustomButtonFlowAlign(FlowLayout.CENTER);
|
tablePanel.setPageButtonFlowAlign(FlowLayout.CENTER);
|
tablePanel.setCustomButtons(getSelfCustomButtons());
|
tablePanel.setShowPaging(false);
|
tablePanel.setShowExport(false);
|
setTablePanelParams(tablePanel);
|
tablePanel.buildTablePanel();
|
if (loadDataAfterBuildCompleted) {
|
tablePanel.refreshTableData();
|
}
|
return tablePanel;
|
}
|
|
protected void setTablePanelParams(VCIJTablePanel<PortalVI> tablePanel) {
|
|
}
|
|
private String borderTitle = "";
|
|
private JPanel initTablePanel() {
|
|
JPanel pal = new JPanel();
|
pal.setLayout(new BorderLayout());
|
pal.setBorder(new TitledBorder(borderTitle));
|
|
pal.add(tablePanel(), BorderLayout.CENTER);
|
JPanel searchPal = new JPanel();
|
pal.add(searchPal, BorderLayout.NORTH);
|
GridBagLayout gbl_searchPal = new GridBagLayout();
|
gbl_searchPal.columnWidths = new int[] { 67, 48, 48, 42, 105, 0, 118, 0, 0 };
|
gbl_searchPal.rowHeights = new int[] { 23, 0 };
|
gbl_searchPal.columnWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE };
|
gbl_searchPal.rowWeights = new double[] { 0.0, Double.MIN_VALUE };
|
searchPal.setLayout(gbl_searchPal);
|
|
formRadio = new JRadioButton("表单");
|
GridBagConstraints gbc_formRadio = new GridBagConstraints();
|
gbc_formRadio.anchor = GridBagConstraints.NORTH;
|
gbc_formRadio.insets = new Insets(0, 0, 0, 5);
|
gbc_formRadio.gridx = 1;
|
gbc_formRadio.gridy = 0;
|
searchPal.add(formRadio, gbc_formRadio);
|
bg.add(formRadio);
|
|
tableRadio = new JRadioButton("表格(先导入表单,再导入表格!)");
|
GridBagConstraints gbc_tableRadio = new GridBagConstraints();
|
gbc_tableRadio.anchor = GridBagConstraints.NORTH;
|
gbc_tableRadio.insets = new Insets(0, 0, 0, 5);
|
gbc_tableRadio.gridx = 2;
|
gbc_tableRadio.gridy = 0;
|
searchPal.add(tableRadio, gbc_tableRadio);
|
bg.add(tableRadio);
|
|
// 选择选项确定是否显示
|
formRadio.setVisible(this.showFormTableRadioButton);
|
tableRadio.setVisible(this.showFormTableRadioButton);
|
|
JLabel nameLab = new JLabel("名称");
|
GridBagConstraints gbc_nameLab = new GridBagConstraints();
|
gbc_nameLab.insets = new Insets(0, 0, 0, 5);
|
gbc_nameLab.gridx = 3;
|
gbc_nameLab.gridy = 0;
|
searchPal.add(nameLab, gbc_nameLab);
|
|
searchNameText = new JTextField();
|
GridBagConstraints gbc_searchNameText = new GridBagConstraints();
|
gbc_searchNameText.insets = new Insets(0, 0, 0, 5);
|
gbc_searchNameText.fill = GridBagConstraints.HORIZONTAL;
|
gbc_searchNameText.gridx = 4;
|
gbc_searchNameText.gridy = 0;
|
searchPal.add(searchNameText, gbc_searchNameText);
|
searchNameText.setColumns(40);
|
|
JLabel label = new JLabel("克隆目标");
|
GridBagConstraints gbc_label = new GridBagConstraints();
|
gbc_label.insets = new Insets(0, 0, 0, 5);
|
gbc_label.gridx = 5;
|
gbc_label.gridy = 0;
|
searchPal.add(label, gbc_label);
|
|
textField_1 = new JTextField();
|
textField_1.setEditable(false);
|
textField_1.setFocusable(false);
|
GridBagConstraints gbc_textField_1 = new GridBagConstraints();
|
gbc_textField_1.insets = new Insets(0, 0, 0, 5);
|
gbc_textField_1.fill = GridBagConstraints.HORIZONTAL;
|
gbc_textField_1.gridx = 6;
|
gbc_textField_1.gridy = 0;
|
searchPal.add(textField_1, gbc_textField_1);
|
textField_1.setColumns(10);
|
|
clonedestbutton = new JButton("克隆目标");
|
clonedestbutton.setToolTipText("*如果选择克隆目标,则克隆到选择的类型下,如果没有选择克隆目标,则克隆到当前类型下");
|
GridBagConstraints gbc_button = new GridBagConstraints();
|
gbc_button.gridx = 7;
|
gbc_button.gridy = 0;
|
searchPal.add(clonedestbutton, gbc_button);
|
|
label.setVisible(this.showCloneOptButton);
|
textField_1.setVisible(this.showCloneOptButton);
|
clonedestbutton.setVisible(this.showCloneOptButton);
|
|
pal.setVisible(true);
|
return pal;
|
}
|
|
/**
|
* 事件
|
*/
|
private void initAction() {
|
searchNameText.getDocument().addDocumentListener(new DocumentListener() {
|
|
@Override
|
public void removeUpdate(DocumentEvent arg0) {
|
searchValue = searchNameText.getText();
|
isConditionRefresh = true;
|
tablePanel.refreshTableData();
|
isConditionRefresh = false;
|
}
|
|
@Override
|
public void insertUpdate(DocumentEvent arg0) {
|
searchValue = searchNameText.getText();
|
isConditionRefresh = true;
|
tablePanel.refreshTableData();
|
isConditionRefresh = false;
|
}
|
|
@Override
|
public void changedUpdate(DocumentEvent arg0) {
|
}
|
});
|
formRadio.addActionListener(new ActionListener() {
|
@Override
|
public void actionPerformed(ActionEvent paramActionEvent) {
|
tablePanel.setPageIndex(1);
|
portalVIType = PortalVIType.Form;
|
tablePanel.refreshTableData();
|
}
|
});
|
tableRadio.addActionListener(new ActionListener() {
|
@Override
|
public void actionPerformed(ActionEvent paramActionEvent) {
|
tablePanel.setPageIndex(1);
|
portalVIType = PortalVIType.Table;
|
tablePanel.refreshTableData();
|
}
|
});
|
addButton.addActionListener(new java.awt.event.ActionListener() {
|
public void actionPerformed(ActionEvent e) {
|
addButton_conform();
|
}
|
});
|
|
editButton.addActionListener(new java.awt.event.ActionListener() {
|
public void actionPerformed(ActionEvent e) {
|
editButton_conform();
|
}
|
});
|
|
deleteButton.addActionListener(new java.awt.event.ActionListener() {
|
public void actionPerformed(ActionEvent e) {
|
deleteButton_conform();
|
}
|
});
|
|
cloneBtn.addActionListener(new java.awt.event.ActionListener() {
|
public void actionPerformed(ActionEvent e) {
|
cloneButton_conform();
|
}
|
});
|
// allExpBtn.addActionListener(new java.awt.event.ActionListener() {
|
// public void actionPerformed(ActionEvent e) {
|
//
|
// AllExportExcel allee = new AllExportExcel(typeFlag.getIntVal());
|
// if(allee.export())
|
// {
|
// VCIOptionPane.showMessage(LogonApplication.frame, "导出成功");
|
// }
|
// }
|
// });
|
// viewI18nButton.addActionListener(new java.awt.event.ActionListener() {
|
// public void actionPerformed(ActionEvent e) {
|
// i18nTable();
|
// }
|
// });
|
expBtn.addActionListener(new java.awt.event.ActionListener() {
|
public void actionPerformed(ActionEvent e) {
|
List<PortalVI> objList = new ArrayList<PortalVI>();
|
int len = tablePanel.getSelectedRowIndexs().length;
|
if (len == 0) {
|
VCIOptionPane.showMessage(LogonApplication.frame, "请选择数据再进行修改操作!");
|
return;
|
}
|
int[] rows = tablePanel.getSelectedRowIndexs();
|
for (int i = 0; i < len; i++) {
|
PortalVI obj = tablePanel.getSpecialObjectByRowIndex(rows[i]);
|
try {
|
obj = UITools.getService().getPortalVIById(obj.id);
|
} catch (Exception ex) {
|
// TODO: handle exception
|
ex.printStackTrace();
|
continue;
|
}
|
objList.add(obj);
|
}
|
ExportExcel ee = new ExportExcel(objList);
|
if (ee.export()) {
|
VCIOptionPane.showMessage(LogonApplication.frame, "导出成功");
|
}
|
}
|
});
|
impBtn.addActionListener(new java.awt.event.ActionListener() {
|
public void actionPerformed(ActionEvent e) {
|
if (selectTreeNodeobject == null) {
|
VCIOptionPane.showMessage(LogonApplication.frame, "请选择一个类型!");
|
return;
|
}
|
ImportExcel imp = new ImportExcel(selectTreeNodeobject);
|
if (imp.impExcel()) {
|
VCIOptionPane.showMessage(LogonApplication.frame, "导入成功");
|
}
|
tablePanel.refreshTableData();
|
}
|
});
|
typeComb.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent arg0) {
|
comboxActionPerformed();
|
}
|
});
|
clonedestbutton.addActionListener(new ActionListener() {
|
|
@Override
|
public void actionPerformed(ActionEvent arg0) {
|
UICloneDestDialog clonedestdia = new UICloneDestDialog();
|
clonedestdia.setVisible(true);
|
clonedestObject = clonedestdia.getTreeObject();
|
if (clonedestObject instanceof BtmItemWrapper) {
|
textField_1.setText(((BtmItemWrapper) clonedestObject).btmItem.name);
|
} else if (clonedestObject instanceof LinkTypeWrapper) {
|
textField_1.setText(((LinkTypeWrapper) clonedestObject).linkType.name);
|
}
|
}
|
});
|
|
// add by guo
|
getSeletedNode.addActionListener(new ActionListener() {
|
@Override
|
public void actionPerformed(ActionEvent arg0) {
|
int[] rows = tablePanel.getSelectedRowIndexs();
|
int len = rows.length;
|
if (len == 0) {
|
VCIOptionPane.showMessageDialog(null, "请选择一个对象!");
|
return;
|
}
|
if (len > 1) {
|
VCIOptionPane.showMessageDialog(null, "只能对一个对象!");
|
return;
|
}
|
PortalVI obj = tablePanel.getSpecialObjectByRowIndex(rows[0]);
|
setSelectedObjectName(obj.viName);
|
parentDialog.dispose();
|
}
|
});
|
|
// searchButton.addActionListener(new ActionListener() {
|
// public void actionPerformed(ActionEvent e) {
|
// searchButton_actionPerformed();
|
// }
|
// });
|
}
|
|
/**
|
*
|
* <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);
|
// }
|
public String getTextField() {
|
return textField.getText().trim();
|
}
|
|
private void comboxActionPerformed() {
|
tablePanel.refreshTableData();
|
}
|
|
/**
|
* 添加事件
|
*/
|
private void addButton_conform() {
|
if (!tableRadio.isSelected() && !formRadio.isSelected()) {
|
VCIOptionPane.showMessage(LogonApplication.frame, "请选择类型");
|
return;
|
}
|
if (formRadio.isSelected()) {
|
FormDesignDialog dt = new FormDesignDialog(selectTreeNodeobject, PortalVIType.Form, null, false, this, typeFlag);
|
dt.setVisible(true);
|
} else if (tableRadio.isSelected()) {
|
TableDialog dialog = new TableDialog(null, selectTreeNodeobject, PortalVIType.Table, false, this, typeFlag);
|
dialog.setVisible(true);
|
}
|
tablePanel.refreshTableData();
|
}
|
|
/**
|
* 修改事件
|
*/
|
private void editButton_conform() {
|
int[] rows = tablePanel.getSelectedRowIndexs();
|
int len = rows.length;
|
if (len == 0) {
|
VCIOptionPane.showMessage(this, "请选择数据再进行修改操作!");
|
return;
|
}
|
if (len > 1) {
|
VCIOptionPane.showMessage(this, "一次只能对一个对象进行修改,请重新选择!");
|
return;
|
}
|
PortalVI obj = tablePanel.getSpecialObjectByRowIndex(rows[0]);
|
try {
|
obj = UITools.getService().getPortalVIById(obj.id);
|
} catch (Exception ex) {
|
ex.printStackTrace();
|
return;
|
}
|
|
if (obj.viType == PortalVIType.Form.getIntVal()) {
|
FormDesignDialog dt = new FormDesignDialog(selectTreeNodeobject, PortalVIType.getByIntVal(obj.viType), obj, true,
|
this, typeFlag);
|
dt.setVisible(true);
|
} else if (obj.viType == PortalVIType.Table.getIntVal()) {
|
TableDialog dialog = new TableDialog(obj, selectTreeNodeobject, PortalVIType.getByIntVal(obj.viType), true,
|
this, typeFlag);
|
dialog.setVisible(true);
|
}
|
tablePanel.refreshTableData();
|
}
|
|
/**
|
* 克隆处理
|
*/
|
private void cloneButton_conform() {
|
int[] rows = tablePanel.getSelectedRowIndexs();
|
int len = rows.length;
|
if (len == 0) {
|
VCIOptionPane.showMessage(this, "请选择数据再进行修改操作!");
|
return;
|
}
|
for (int i = 0; i < len; i++) {
|
PortalVI obj = tablePanel.getSpecialObjectByRowIndex(rows[i]);
|
String viName = VCIOptionPane.showInputDialog(LogonApplication.frame, "源文件名称为:" + obj.viName + ",请输入新名称");
|
if (viName != null) {
|
if (checkViName(viName, obj))
|
return;
|
|
try {
|
obj = UITools.getService().getPortalVIById(obj.id);
|
obj.id = ObjectUtility.getNewObjectID36();
|
obj.viName = viName;
|
if (clonedestObject != null) {
|
if (clonedestObject instanceof BtmItemWrapper) {
|
obj.typeName = ((BtmItemWrapper) clonedestObject).btmItem.name;
|
} else if (clonedestObject instanceof LinkTypeWrapper) {
|
obj.typeName = ((LinkTypeWrapper) clonedestObject).linkType.name;
|
}
|
}
|
UITools.getService().savePortalVI(obj);
|
} catch (VCIError e) {
|
e.printStackTrace();
|
}
|
}
|
}
|
tablePanel.refreshTableData();
|
}
|
|
private boolean checkViName(String viName, PortalVI obj) {
|
if ("".equals(viName)) {
|
VCIOptionPane.showMessage(this, "请输入名称!");
|
viName = VCIOptionPane.showInputDialog(LogonApplication.frame, "源文件名称为:" + obj.viName + ",请输入新名称");
|
checkViName(viName, obj);
|
return true;
|
}
|
if (viName == null) {
|
return true;
|
}
|
return false;
|
}
|
|
/**
|
* 删除事件
|
*/
|
private void deleteButton_conform() {
|
int[] rows = tablePanel.getSelectedRowIndexs();
|
int len = rows.length;
|
if (len == 0) {
|
VCIOptionPane.showMessage(this, "请选择要删除的对象!");
|
return;
|
}
|
Object[] options = { "Yes", "No" };
|
int option = JOptionPane.showOptionDialog(LogonApplication.frame, "确定要删除所选择的数据吗?", "删除数据",
|
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
|
if (option != JOptionPane.YES_OPTION) {
|
return;
|
}
|
|
for (int row : rows) {
|
PortalVI obj = tablePanel.getSpecialObjectByRowIndex(row);
|
String name = obj.viName;
|
String typeName = obj.typeName;
|
String id = obj.id;
|
int viType = obj.viType;
|
boolean flag = false;
|
boolean formFlag = false;
|
|
try {
|
if (viType == 1) {
|
// 判断该表单是否在表格中被引用
|
formFlag = UITools.getService().judgeDeleteButton(id, typeName);
|
if (formFlag) {
|
VCIOptionPane.showMessage(this, "第" + (row + 1) + "行表单已经在表格中被引用,请重新选择要删除的对象!");
|
return;
|
}
|
}
|
// 判断该表单或表格是否在UI定义时被引用
|
flag = UITools.getService().judgeUpdateButton(obj.viType, name, typeName);
|
if (flag) {
|
VCIOptionPane.showMessage(this, "第" + (row + 1) + "行数据已经被UI组件引用,请重新选择要删除的对象!");
|
return;
|
}
|
UITools.getService().deletePortalVIByID(obj.id);
|
} catch (VCIError e) {
|
e.printStackTrace();
|
}
|
}
|
tablePanel.refreshTableData();
|
}
|
|
public String getSelectedObjectName() {
|
return selectedObjectName;
|
}
|
|
public void setSelectedObjectName(String selectedObjectName) {
|
this.selectedObjectName = selectedObjectName;
|
}
|
|
public Object getSelectTreeNodeobject() {
|
return selectTreeNodeobject;
|
}
|
|
public void setSelectTreeNodeobject(Object selectTreeNodeobject) {
|
this.selectTreeNodeobject = selectTreeNodeobject;
|
}
|
|
public PortalVITypeFlag getTypeFlag() {
|
return typeFlag;
|
}
|
|
public void setTypeFlag(PortalVITypeFlag typeFlag) {
|
this.typeFlag = typeFlag;
|
}
|
|
public JRadioButton getTableRadio() {
|
return tableRadio;
|
}
|
|
public void setTableRadio(JRadioButton tableRadio) {
|
this.tableRadio = tableRadio;
|
}
|
|
public JRadioButton getFormRadio() {
|
return formRadio;
|
}
|
|
public void setFormRadio(JRadioButton formRadio) {
|
this.formRadio = formRadio;
|
}
|
|
}
|