package com.vci.client.framework.appConfig; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.Locale; import com.vci.client.LogonApplication; import com.vci.client.framework.appConfig.object.AppConfigCategoryObject; import com.vci.client.framework.appConfig.object.AppConfigDetailObject; import com.vci.client.framework.delegate.AppConfigCategoryClientDelegate; import com.vci.client.framework.delegate.AppConfigDetailClientDelegate; import com.vci.client.ui.exception.VCIException; import com.vci.client.ui.locale.LocaleDisplay; import com.vci.client.ui.swing.VCIOptionPane; public class AppConfigCategoryPanelActionListener implements ActionListener { private AppConfigCategoryPanel owner = null; private LinkedHashMap actionMaps = new LinkedHashMap(); public AppConfigCategoryPanelActionListener(AppConfigCategoryPanel owner) { this.owner = owner; this.initActionMap(); } private void initActionMap() { actionMaps.put("create", new Runnable() { public void run() { createAppConfigCategory();// } }); actionMaps.put("edit", new Runnable() { public void run() { editAppConfigCategory();// } }); actionMaps.put("delete", new Runnable() { public void run() { deleteAppConfigCategory();// } }); } @Override public void actionPerformed(ActionEvent e) { String key = e.getActionCommand(); if (actionMaps.containsKey(key)) { actionMaps.get(key).run(); } } private void createAppConfigCategory() { showAppConfigCategoryDialog(null); if (owner.getOwnerPanel() != null) { owner.getOwnerPanel().refrashTree(); } } private void showAppConfigCategoryDialog(AppConfigCategoryObject obj) { AppConfigCategoryDialog dialog = new AppConfigCategoryDialog(LogonApplication.frame, owner, obj); // dialog.setModal(true); // dialog.setVisible(true); } private void editAppConfigCategory() { int[] chk = owner.getTablePanel().getSelectedRowIndexs(); Integer[] chkSelRows = new Integer[chk.length]; for (int i = 0; i < chk.length; i++) { chkSelRows[i] = new Integer(chk[i]); } int len = chkSelRows.length; if (len == 0) { VCIOptionPane.showMessage(owner, LocaleDisplay.getI18nString("rmip.stafforg.operate.deptedit1", "RMIPFramework", owner.getLocale())); return; } if (len > 1) { VCIOptionPane.showMessage(owner, LocaleDisplay.getI18nString("rmip.stafforg.operate.deptedit2", "RMIPFramework", owner.getLocale())); return; } AppConfigCategoryObject obj = owner.getTablePanel().getSelectedRowObjects().get(0); showAppConfigCategoryDialog(obj); if (owner.getOwnerPanel() != null) { owner.getOwnerPanel().refrashTree(); } } private void deleteAppConfigCategory() { int[] chk = owner.getTablePanel().getSelectedRowIndexs(); Integer[] chkSelRows = new Integer[chk.length]; for (int i = 0; i < chk.length; i++) { chkSelRows[i] = new Integer(chk[i]); } int len = chkSelRows.length; if (len == 0) { VCIOptionPane.showMessage(owner, "请选择要删除的对象!"); return; } String[] puids = new String[len]; for (int i = 0; i < len; i++) { LinkedList list = owner.getTablePanel().getSelectedRowObjects(); puids[i] = list.get(i).getId(); int ok = VCIOptionPane.showQuestion(LogonApplication.frame, "您确定要删除选中的对象吗?"); if (ok == 0) { boolean rs = true; try { rs = new AppConfigCategoryClientDelegate(LogonApplication.getUserEntityObject()) .deleteAppConfigCategory(puids); } catch (VCIException e) { VCIOptionPane.showError(LogonApplication.frame, LocaleDisplay.getI18nString(e, "RMIPFramework", Locale.getDefault())); return; } if (!rs) { return; } owner.getTablePanel().refreshTableData(); } } if (owner.getOwnerPanel() != null) { owner.getOwnerPanel().refrashTree(); } } }