package com.vci.ubcs.codeapply; import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.Frame; import java.awt.Toolkit; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import javax.swing.JPanel; import com.vci.base.ui.exception.VCIException; import com.vci.base.ui.swing.VCISwingUtil; import com.vci.base.ui.swing.components.VCIJButton; import com.vci.base.ui.swing.components.VCIJDialog; import com.vci.base.ui.swing.components.VCIJPanel; import com.vci.base.ui.swing.components.VCIJTable; import com.vci.base.ui.swing.components.table.VCIJTablePanel; import org.apache.poi.ss.formula.functions.T; public class RMDataReferTempDialog extends VCIJDialog { private VCIJDialog rmDataAddDialog; private String templateId = ""; private RMDataReferTempDialogActionListener actionListener = new RMDataReferTempDialogActionListener(this); private VCIJButton btnOk = VCISwingUtil.createVCIJButton("ok", "确定", "确定", "accept.png", actionListener); private VCIJButton btnCancel = VCISwingUtil.createVCIJButton("cancel", "取消", "取消", "cancel.png", actionListener); private static final long serialVersionUID = 1L; public RMDataReferTempDialog(VCIJDialog rmDataAddDialog,String templateId) { //super(true); this.rmDataAddDialog = rmDataAddDialog; this.templateId = templateId; init(); setTitle("引用模板-属性选择"); //initDialogSize(rmDataAddDialog.getWidth(), rmDataAddDialog.getHeight()); } private void init(){ this.setLayout(new BorderLayout()); JPanel panel = new JPanel(new FlowLayout()); panel.add(btnOk); panel.add(btnCancel); this.add(createRMDataMainPanel(), BorderLayout.CENTER); this.add(panel,BorderLayout.SOUTH); Dimension dime = Toolkit.getDefaultToolkit().getScreenSize().getSize(); int x = dime.width/6; int y = dime.height/6 + 50; this.setLocation(x , y); this.setSize(850, 400); } private boolean fromTableDoubleClick = false; public boolean isFromTableDoubleClick() { return fromTableDoubleClick; } public void setFromTableDoubleClick(boolean fromTableDoubleClick) { this.fromTableDoubleClick = fromTableDoubleClick; } private VCIJPanel createRMDataMainPanel(){ VCIJPanel rmDataTablePanel = new VCIJPanel(); if(!templateId.equals("")){ //rmDataTablePanel = getRMDataMainPanel("", "", templateId); } rmDataTablePanel.setPreferredSize(new Dimension(880,300)); return rmDataTablePanel; } private VCIJTablePanel tablePanel = null; private CodeDataMainPanelDataProvider dataProvider; public VCIJTablePanel getRMDataMainPanel(String libId, String classifyId, String templateId) { dataProvider = new CodeDataMainPanelDataProvider(); tablePanel = new VCIJTablePanel(dataProvider); //tablePanel.setCustomButtons(getCombinedButtons()); tablePanel.setShowExport(true); tablePanel.setShowPaging(true); tablePanel.setPageButtonFlowAlign(FlowLayout.CENTER); tablePanel.setCustomButtonFlowAlign(FlowLayout.CENTER); tablePanel.buildTablePanel(); int columnCount = tablePanel.getTable().getColumnCount(); tablePanel.getTable().getColumnModel().getColumn(columnCount - 2).setPreferredWidth(150); tablePanel.getTable().getColumnModel().getColumn(columnCount - 4).setPreferredWidth(150); /** * 禁止table表头拖动,防止第一列的复选框和第二列的序号拖动出问题: * 点击某行,表格中的复选框看不到,且选中表头上的复选框系统会报错;数据信息显示不正确。 * 2012-12-4 wangxl */ tablePanel.getTable().getTableHeader().setReorderingAllowed(false); tablePanel.refreshTableData(); VCIJTable table = tablePanel.getTable(); table.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getButton() == 1 && e.getClickCount() == 2) { setFromTableDoubleClick(true); btnOk.doClick(); } } }); return tablePanel; } /***获取资源数据的主面板**/ /* public RMDataMainPanel getRMDataMainPanel() { return rmDataMainPanel; } */ /*private RMDataTransmitObject loadTemplateAttributes(String libId, String classifyId, String templateId){ LinkedHashMap tempPropObjsMap = new LinkedHashMap(); LinkedList tempPropObjsList = new LinkedList(); LinkedHashMap tempAttrObjsMap = new LinkedHashMap(); LinkedList tempAttrObjsList = new LinkedList(); TemplateObject templateObject = null; RMDataTransmitObject transmit = new RMDataTransmitObject(); transmit.setLibId(libId); transmit.setClassifyId(classifyId); transmit.setTemplateId(templateId); transmit.setSpecialLib(true);//added by ligang 2012.07.04备件库不做权限校验 try{ UserEntityObject userEntityObject = LogonApplication.getUserEntityObject(); TemplateClientDelegate tempDel = new TemplateClientDelegate(userEntityObject); RMTemplateProertyClientDelegate tempPropDel = new RMTemplateProertyClientDelegate(userEntityObject); AttributeClientDelegate attrDel = new AttributeClientDelegate(userEntityObject); // RMTypeObject rmTypeObject = new RMTypeClientDelegate(userEntityObject).getRMTypeById(classifyId); RMTypeObject rmTypeObject = new RMTypeObject(); // 从资源分类树中选择的对应的分类对象 transmit.setRmTypeObject(rmTypeObject); // 获取模板对象 templateObject = tempDel.getTemplateObjectById(templateId); transmit.setTemplateObject(templateObject); // 获取模板定义的属性对象(这个对象包含的是属性在模板中是否为关键属性、可否为空等等) TemplatePropertyObject[] tempPropObjs = tempPropDel.getTempletePropertys(templateId); for(TemplatePropertyObject obj : tempPropObjs){ tempPropObjsMap.put(obj.getAttrId(), obj); tempPropObjsList.add(obj); } transmit.setTempPropObjsMap(tempPropObjsMap); transmit.setTempPropObjsList(tempPropObjsList); // 获取模板定义的属性对象对应到的真实的属性对象(系统配置模块定义的那些属性对象) AttributeObject[] attrObjs = attrDel.fetchAttributeByTemplateId(templateId); for(AttributeObject obj : attrObjs){ tempAttrObjsMap.put(obj.getId(), obj); tempAttrObjsList.add(obj); } transmit.setTempAttrObjsMap(tempAttrObjsMap); transmit.setTempAttrObjsList(tempAttrObjsList); }catch(VCIException e){ e.printStackTrace(); } return transmit; }*/ }