package com.vci.client.portal.UI.v3.comptdesign.compt.popupcompt; import java.awt.BorderLayout; import java.awt.Color; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import javax.swing.JRootPane; import javax.swing.border.LineBorder; import com.vci.client.portal.UI.v3.comptdesign.UIComptDesignDialog; import com.vci.client.ui.swing.VCISwingUtil; import com.vci.client.ui.swing.components.VCIJButton; import com.vci.client.ui.swing.components.VCIJOptionPane; import com.vci.client.ui.swing.components.VCIJPanel; import com.vci.client.ui.swing.components.VCIJTextField; import com.vci.corba.portal.data.PLUILayout; import com.vci.mw.ClientContextVariable; public class UILayoutPopupDialog extends BasePopupDialog { /** * */ private static final long serialVersionUID = -7290990397315653210L; private VCIJTextField btmTypeTxt = null; private UILayoutPopupTablePanel uiLayoutPanel = null; private VCIJButton btnOk = VCISwingUtil.createVCIJButton("ok", "确定", "确定", "accept.png", new ActionListener() { @Override public void actionPerformed(ActionEvent e) { btnOk_actionPerformed(e, true); } }); private VCIJButton btnCancel = VCISwingUtil.createVCIJButton("cancel", "取消", "取消", "cancel.png", new ActionListener() { @Override public void actionPerformed(ActionEvent e) { btnCancel_actionPerformed(e); } }); public UILayoutPopupDialog(UIComptDesignDialog ownedUIComptDesignDialog, VCIJTextField searchInputTxt, VCIJTextField btmLinkTypeTxt){ super(ownedUIComptDesignDialog, searchInputTxt); this.btmTypeTxt = btmLinkTypeTxt; } @Override public void buildDialog(){ init(); super.setBuildCompleted(true); } private void init(){ initUI(); } private void initUI(){ setUndecorated(true); getRootPane().setWindowDecorationStyle(JRootPane.NONE); setLayout(new BorderLayout()); VCIJPanel pal = new VCIJPanel(new BorderLayout()); pal.setBorder(new LineBorder(Color.black)); uiLayoutPanel = new UILayoutPopupTablePanel(this); uiLayoutPanel.buildTablePanel(); uiLayoutPanel.getTablePanel().getTable().addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { int row = uiLayoutPanel.getTablePanel().getTable().rowAtPoint(e.getPoint()); int column = uiLayoutPanel.getTablePanel().getTable().columnAtPoint(e.getPoint()); if(row < 0 || column <= 0){ return; } setBtmTypeNameTableRowIndex(row); } }); pal.add(uiLayoutPanel, BorderLayout.CENTER); pal.add(getSouthButtonPanel(), BorderLayout.SOUTH); add(pal, BorderLayout.CENTER); } private VCIJPanel getSouthButtonPanel(){ VCIJPanel pal = new VCIJPanel(); pal.add(btnOk); pal.add(btnCancel); return pal; } private void btnOk_actionPerformed(ActionEvent e, boolean fromBtnOk){ if(fromBtnOk){ PLUILayout[] sels = uiLayoutPanel.getTablePanel().getSelectedRowObjectsList().toArray(new PLUILayout[]{}); if(sels.length == 0 && !isSelected()){ VCIJOptionPane.showMessage(ClientContextVariable.getFrame(), "请选选择数据"); return; } if(sels.length >= 2){ VCIJOptionPane.showMessage(ClientContextVariable.getFrame(), "只能选择一条数据"); return; } setSelectedUILayoutName(sels[0]); close(DialogResult.OK); } else { int row = uiLayoutPanel.getTablePanel().getTable().getSelectedRow(); setBtmTypeNameTableRowIndex(row); } } private void setBtmTypeNameTableRowIndex(int rowIndex){ if(rowIndex >= 0 && rowIndex < uiLayoutPanel.getTablePanel().getTableModel().getList().size()){ PLUILayout ui = uiLayoutPanel.getTablePanel().getSpecialObjectByRowIndex(rowIndex); setSelectedUILayoutName(ui); close(DialogResult.OK); } } private void setSelectedUILayoutName(PLUILayout ui){ selectedUILayoutCode = ui.plCode; } private String selectedUILayoutCode = ""; public String getSelectedUILayoutCode(){ return selectedUILayoutCode; } private boolean isSelected(){ return uiLayoutPanel.getTablePanel().getTable().getSelectedRow() >= 0; } private void btnCancel_actionPerformed(ActionEvent e){ close(DialogResult.CANCEL); } private void close(DialogResult dialogRes){ setDialogResult(dialogRes); if(getDialogCallback() != null){ getDialogCallback().run(); } setVisible(false); } public UILayoutPopupTablePanel getPortalVITablePanel() { return uiLayoutPanel; } public void setPortalVITablePanel(UILayoutPopupTablePanel uiLayoutPanel) { this.uiLayoutPanel = uiLayoutPanel; } @Override public void loadData(){ uiLayoutPanel.getTablePanel().refreshTableData(); } public VCIJTextField getBtmTypeTxt() { return btmTypeTxt; } }