wangting
2024-12-26 fa261e8c1220b31af54e8167e4de9c3320b1af27
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
package com.vci.client.framework.appConfig;
 
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.Locale;
 
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.border.TitledBorder;
 
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.ui.exception.VCIException;
import com.vci.client.ui.locale.LocaleDisplay;
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.VCIJPanel;
import com.vci.client.ui.swing.components.table.VCIJTablePanel;
 
public class AppConfigDetailPanel extends VCIJPanel implements IConfigDetailPanel{
 
    /**
     * 
     */
    private static final long serialVersionUID = 538726303706205608L;
 
    private VCIJTablePanel<AppConfigDetailObject> tablePanel = null;
    private AppConfigDetailDataProvider dataProvider = null;
    private JComboBox clsfCombo;
    private VCIJButton addButton = null;
    private VCIJButton editButton = null;
    private VCIJButton deleteButton = null;
    private LinkedList<VCIJButton> selfCustomButtons = new LinkedList<VCIJButton>();
    private JScrollPane jsp = new JScrollPane();
    
    public AppConfigDetailPanel() {
        init();
    }
    
    private void init(){
        this.setLayout(new BorderLayout());
        this.setBorder(new TitledBorder("配置项管理"));
        
        JPanel topPanel = new JPanel();//上面的PANEL
        topPanel.setLayout(new FlowLayout(FlowLayout.LEADING));
        JLabel ruleLabel = new JLabel("请选择分类:");
        ruleLabel.setPreferredSize(new Dimension(80,25));
        clsfCombo = new JComboBox();//选择系统下拉框
        initClsfCombo();
        clsfCombo.addActionListener(new ActionListener(){
 
            @Override
            public void actionPerformed(ActionEvent arg0) {
                tablePanel.refreshTableData();
            }});
        
        clsfCombo.setPreferredSize(new Dimension(150,25));
        topPanel.add(ruleLabel);
        topPanel.add(clsfCombo);
        
        initSelfButton();
        VCIJPanel mainPannel = initMainPanl();
        jsp.getViewport().add(mainPannel);
        
        this.add(topPanel,BorderLayout.NORTH);
        this.add(jsp, BorderLayout.CENTER);
    }
    
    private void initSelfButton() {
        addButton = VCISwingUtil.createVCIJButton("create",
                LocaleDisplay.getI18nString("rmip.framework.systemFunctionTree.modelManagment.addButton",
                        "RMIPFramework", getLocale()), LocaleDisplay.getI18nString(
                        "rmip.framework.systemFunctionTree.modelManagment.addButton", "RMIPFramework", getLocale()),
                "create.gif", null);
        editButton = VCISwingUtil.createVCIJButton("edit",
                LocaleDisplay.getI18nString("rmip.framework.systemFunctionTree.modelManagment.modifyButton",
                        "RMIPFramework", getLocale()), LocaleDisplay.getI18nString(
                        "rmip.framework.systemFunctionTree.modelManagment.modifyButton", "RMIPFramework", getLocale()),
                "modify.gif", null);
        deleteButton = VCISwingUtil.createVCIJButton("delete",
                LocaleDisplay.getI18nString("rmip.framework.systemFunctionTree.modelManagment.deleteButton",
                        "RMIPFramework", getLocale()), LocaleDisplay.getI18nString(
                        "rmip.framework.systemFunctionTree.modelManagment.deleteButton", "RMIPFramework", getLocale()),
                "delete.gif", null);
        AppConfigDetailPanelActionListener listener = new AppConfigDetailPanelActionListener(this);
        addButton.addActionListener(listener);
        editButton.addActionListener(listener);
        deleteButton.addActionListener(listener);
        
        selfCustomButtons.add(addButton);
        selfCustomButtons.add(editButton);
        selfCustomButtons.add(deleteButton);
    }
    
    public VCIJPanel initMainPanl() {
        dataProvider = new AppConfigDetailDataProvider(this);
        tablePanel = new VCIJTablePanel<AppConfigDetailObject>(dataProvider);
        int startIndex = dataProvider.getDataColumnStartIndex();
        LinkedHashMap<Integer, Integer> widthMaps = new LinkedHashMap<Integer, Integer>();
        widthMaps.put(startIndex++, 200);
        widthMaps.put(startIndex++, 200);
        widthMaps.put(startIndex++, 600);
        widthMaps.put(startIndex++, 300);
        tablePanel.setColumnWidthMaps(widthMaps);
        tablePanel.setShowPaging(true);
        tablePanel.setCustomButtons(selfCustomButtons);
        tablePanel.setCustomButtonFlowAlign(FlowLayout.CENTER);
        tablePanel.setPageButtonFlowAlign(FlowLayout.CENTER);
        tablePanel.buildTablePanel();
        tablePanel.refreshTableData();
        return tablePanel;
    }
    
    @Override
    public String getConfigCategory() {
        Object selObj = clsfCombo.getSelectedItem();
        if (selObj == null) {
            return "root";
        } else {
            return ((AppConfigCategoryObject)selObj).getId();
        }
    }
    
    private void initClsfCombo() {
        AppConfigCategoryObject[] objects = null;
        try {
            AppConfigCategoryClientDelegate delegate = new AppConfigCategoryClientDelegate(LogonApplication.getUserEntityObject());
            objects = delegate.getAppConfigCategorys();
            for (int i = 0; i < objects.length; i++) {
                clsfCombo.addItem(objects[i]);
            }
        } catch (VCIException e) {
            VCIOptionPane.showError(LogonApplication.frame, LocaleDisplay.getI18nString(e, "RMIPFramework", Locale.getDefault()));
        }
    }
    
    @Override
    public  VCIJTablePanel<AppConfigDetailObject> getTablePanel() {
        return this.tablePanel;
    }
}