ludc
2024-09-14 36c2449aec5b51e5ed4e5c6841154b746060e09a
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
package com.vci.client.portal.UI;
 
import java.awt.BorderLayout;
import java.awt.FlowLayout;
 
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import java.awt.GridBagLayout;
import javax.swing.JLabel;
import java.awt.GridBagConstraints;
import javax.swing.JTextField;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
 
import javax.swing.JRadioButton;
import javax.swing.JCheckBox;
 
import com.vci.client.portal.utility.PLDefination;
import com.vci.client.portal.utility.UITools;
import com.vci.common.portal.constants.TemplateTypeConstants;
import com.vci.common.utility.ObjectUtility;
import com.vci.corba.common.VCIError;
import com.vci.corba.portal.data.PLPageDefination;
import com.vci.corba.portal.data.PLUILayout;
 
/**
 * 树设置
 * @author liudi
 *
 */
public class TreeTablePanel extends JPanel{
 
    private final JPanel contentPanel = new JPanel();
 
    private JButton okButton;
    private JButton cancelButton;
    private JLabel label_1;
    private JRadioButton graduallyRad;
    private JRadioButton allRad;
    private ButtonGroup expandBg = new ButtonGroup();
    private ButtonGroup orientationBg= new ButtonGroup();
    private JCheckBox isShowImage;
    private JLabel lbltable;
    private JTextField templateIdTxt;
    private JPanel panel;
    private JButton btnSet;
    private JButton delBtn;
    private PLUILayout plpagelayoutdefination;
    private JLabel label_5;
    private JTextField linkTypeTxt;
    private JLabel lblNewLabel_1;
    private JTextField showTypeTxt;
    private JLabel lbllink;
    private JTextField expandColsTxt;
    private PLDefination pldefination;
    private String plPageDefinationID;
    private String btmName;
    private Integer templateType = TemplateTypeConstants.TREETABLE;
    private NavigationDialog navigationDialog;
    private static String buttonArea = "navigatorTreeTable";
    /**
     * Create the dialog.
     */
    public TreeTablePanel(PLUILayout plpagelayoutdefination,String btmName,NavigationDialog navigationDialog) {
        this.plpagelayoutdefination = plpagelayoutdefination;
        this.btmName = btmName;
        this.navigationDialog = navigationDialog;
        init();
        actionListener();
        initData();
        this.setVisible(true);
    }
 
    private void init() {
        setBounds(100, 100, 450, 345);
        setLayout(new BorderLayout());
        contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
        add(contentPanel, BorderLayout.CENTER);
        GridBagLayout gbl_contentPanel = new GridBagLayout();
        gbl_contentPanel.columnWidths = new int[]{0, 0, 0, 0, 0};
        gbl_contentPanel.rowHeights = new int[]{0, 0, 0, 0, 0, 0, 0};
        gbl_contentPanel.columnWeights = new double[]{0.0, 1.0, 1.0, 0.0, Double.MIN_VALUE};
        gbl_contentPanel.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
        contentPanel.setLayout(gbl_contentPanel);
        {
            lblNewLabel_1 = new JLabel("显示类型");
            GridBagConstraints gbc_lblNewLabel_1 = new GridBagConstraints();
            gbc_lblNewLabel_1.insets = new Insets(0, 0, 5, 5);
            gbc_lblNewLabel_1.gridx = 1;
            gbc_lblNewLabel_1.gridy = 0;
            contentPanel.add(lblNewLabel_1, gbc_lblNewLabel_1);
        }
        {
            showTypeTxt = new JTextField();
            GridBagConstraints gbc_showTypeTxt = new GridBagConstraints();
            gbc_showTypeTxt.insets = new Insets(0, 0, 5, 5);
            gbc_showTypeTxt.fill = GridBagConstraints.HORIZONTAL;
            gbc_showTypeTxt.gridx = 2;
            gbc_showTypeTxt.gridy = 0;
            contentPanel.add(showTypeTxt, gbc_showTypeTxt);
            showTypeTxt.setColumns(10);
        }
        {
            label_1 = new JLabel("展开方式");
            GridBagConstraints gbc_label_1 = new GridBagConstraints();
            gbc_label_1.insets = new Insets(0, 0, 5, 5);
            gbc_label_1.gridx = 1;
            gbc_label_1.gridy = 1;
            contentPanel.add(label_1, gbc_label_1);
        }
        {
            panel = new JPanel();
            FlowLayout flowLayout = (FlowLayout) panel.getLayout();
            flowLayout.setAlignment(FlowLayout.LEFT);
            GridBagConstraints gbc_panel = new GridBagConstraints();
            gbc_panel.insets = new Insets(0, 0, 5, 5);
            gbc_panel.fill = GridBagConstraints.BOTH;
            gbc_panel.gridx = 2;
            gbc_panel.gridy = 1;
            contentPanel.add(panel, gbc_panel);
            graduallyRad = new JRadioButton("逐级展开");
            graduallyRad.setSelected(true);
            panel.add(graduallyRad);
            expandBg.add(graduallyRad);
            {
                
                allRad = new JRadioButton("全部展开");
                panel.add(allRad);
                expandBg.add(allRad);
            }
        }
        {
            isShowImage = new JCheckBox("显示图标");
            GridBagConstraints gbc_isShowImage = new GridBagConstraints();
            gbc_isShowImage.insets = new Insets(0, 0, 5, 5);
            gbc_isShowImage.gridx = 1;
            gbc_isShowImage.gridy = 2;
            contentPanel.add(isShowImage, gbc_isShowImage);
        }
        {
            lbllink = new JLabel("树形结构展开列");
            GridBagConstraints gbc_lbllink = new GridBagConstraints();
            gbc_lbllink.insets = new Insets(0, 0, 5, 5);
            gbc_lbllink.gridx = 1;
            gbc_lbllink.gridy = 3;
            contentPanel.add(lbllink, gbc_lbllink);
        }
        {
            expandColsTxt = new JTextField();
            GridBagConstraints gbc_expandColsTxt = new GridBagConstraints();
            gbc_expandColsTxt.insets = new Insets(0, 0, 5, 5);
            gbc_expandColsTxt.fill = GridBagConstraints.HORIZONTAL;
            gbc_expandColsTxt.gridx = 2;
            gbc_expandColsTxt.gridy = 3;
            contentPanel.add(expandColsTxt, gbc_expandColsTxt);
            expandColsTxt.setColumns(10);
        }
        {
            lbltable = new JLabel("关联table");
            GridBagConstraints gbc_lbltable = new GridBagConstraints();
            gbc_lbltable.insets = new Insets(0, 0, 5, 5);
            gbc_lbltable.gridx = 1;
            gbc_lbltable.gridy = 4;
            contentPanel.add(lbltable, gbc_lbltable);
        }
        {
            templateIdTxt = new JTextField();
            GridBagConstraints gbc_templateIdTxt = new GridBagConstraints();
            gbc_templateIdTxt.insets = new Insets(0, 0, 5, 5);
            gbc_templateIdTxt.fill = GridBagConstraints.HORIZONTAL;
            gbc_templateIdTxt.gridx = 2;
            gbc_templateIdTxt.gridy = 4;
            contentPanel.add(templateIdTxt, gbc_templateIdTxt);
            templateIdTxt.setColumns(10);
        }
        {
            label_5 = new JLabel("链接类型");
            GridBagConstraints gbc_label_5 = new GridBagConstraints();
            gbc_label_5.insets = new Insets(0, 0, 0, 5);
            gbc_label_5.gridx = 1;
            gbc_label_5.gridy = 5;
            contentPanel.add(label_5, gbc_label_5);
        }
        {
            linkTypeTxt = new JTextField();
            GridBagConstraints gbc_linkTypeTxt = new GridBagConstraints();
            gbc_linkTypeTxt.insets = new Insets(0, 0, 0, 5);
            gbc_linkTypeTxt.fill = GridBagConstraints.HORIZONTAL;
            gbc_linkTypeTxt.gridx = 2;
            gbc_linkTypeTxt.gridy = 5;
            contentPanel.add(linkTypeTxt, gbc_linkTypeTxt);
            linkTypeTxt.setColumns(10);
        }
        {
            JPanel buttonPane = new JPanel();
            buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
            add(buttonPane, BorderLayout.SOUTH);
            {
                btnSet = new JButton("按钮设计");
                buttonPane.add(btnSet);
            }
            {
                delBtn = new JButton("删除");
                buttonPane.add(delBtn);
            }
            {
                okButton = new JButton("保存");
                buttonPane.add(okButton);
            }
            {
                cancelButton = new JButton("关闭");
                buttonPane.add(cancelButton);
            }
        }
    }
 
    private void actionListener(){
        btnSet.addActionListener(new ActionListener() {
            
            @Override
            public void actionPerformed(ActionEvent arg0) {
                ButtonDialog dialog = new ButtonDialog(null,plpagelayoutdefination,buttonArea);
            }
        });
        delBtn.addActionListener(new ActionListener() {
            
            @Override
            public void actionPerformed(ActionEvent arg0) {
                PLPageDefination plPageDefination = new PLPageDefination();
                plPageDefination.plOId = plPageDefinationID;
                try {
                    boolean flag = UITools.getService().deletePLPageDefination(plPageDefination);
                } catch (VCIError e) {
                    e.printStackTrace();
                }
                
            }
        });
        okButton.addActionListener(new ActionListener() {
            
            @Override
            public void actionPerformed(ActionEvent arg0) {
                if(pldefination!=null){
                    edit();
                }else{
                    save();
                }
//                navigationDialog.dispose();
            }
 
            private void edit() {
                PLPageDefination plPageDefination = new PLPageDefination();
                plPageDefination.plOId = plPageDefinationID;
                plPageDefination.plTabPageOId = plpagelayoutdefination.plOId;
                plPageDefination.plType=1;
                PLDefination obj = new PLDefination();
                obj.setType(templateType);
                obj.setShowType(showTypeTxt.getText());
                //逐级展开:1、全部展开:0
                if(graduallyRad.isSelected()){
                    obj.setExpandMode("1");
                }
                
                if(allRad.isSelected()){
                    obj.setExpandMode("0");
                }
                obj.setLinkType(linkTypeTxt.getText());
//                obj.setValidity(validityTxt.getText());
                obj.setExpandCols(expandColsTxt.getText());
                if(isShowImage.isSelected()){
                    obj.setIsShowImage("1");
                }else{
                    obj.setIsShowImage("0");
                }
                obj.setTemplateId(templateIdTxt.getText());
                try {
                    plPageDefination.plDefination = UITools.getPLDefinationText(obj);
                    boolean flag = UITools.getService().updatePLPageDefination(plPageDefination);
                } catch (Throwable e) {
                    e.printStackTrace();
                }
            }
            
            private void save() {
                PLPageDefination plPageDefination = new PLPageDefination();
                plPageDefination.plOId = ObjectUtility.getNewObjectID36();
                plPageDefination.plTabPageOId = plpagelayoutdefination.plOId;
                plPageDefination.plType=1;
                PLDefination obj = new PLDefination();
                obj.setType(templateType);
                obj.setShowType(showTypeTxt.getText());
                //逐级展开:1、全部展开:0
                if(graduallyRad.isSelected()){
                    obj.setExpandMode("1");
                }
                
                if(allRad.isSelected()){
                    obj.setExpandMode("0");
                }
                obj.setLinkType(linkTypeTxt.getText());
//                obj.setValidity(validityTxt.getText());
                obj.setExpandCols(expandColsTxt.getText());
                if(isShowImage.isSelected()){
                    obj.setIsShowImage("1");
                }else{
                    obj.setIsShowImage("0");
                }
                obj.setTemplateId(templateIdTxt.getText());
                try {
                    plPageDefination.plDefination = UITools.getPLDefinationText(obj);
                    boolean flag = UITools.getService().savePLPageDefination(plPageDefination);
                } catch (Throwable e) {
                    e.printStackTrace();
                }
            }
            
        });
        cancelButton.addActionListener(new ActionListener() {
            
            @Override
            public void actionPerformed(ActionEvent arg0) {
                navigationDialog.dispose();
            }
        });
    }
    
    private void initData(){
        PLPageDefination[] obj;
        PLDefination p ;
        try {
            obj = UITools.getService().getPLPageDefinationsByPageContextOId(plpagelayoutdefination.plOId);
            for(int i=0;i<obj.length;i++){
                if(obj[i].plType==templateType){
                    plPageDefinationID = obj[i].plOId;
                    p = UITools.getPLDefination(obj[i].plDefination);
                    
                    showTypeTxt.setText(p.getShowType());
                    if(p.getExpandMode().equals("1")){
                        graduallyRad.setSelected(true);
                    }
                    if(p.getExpandMode().equals("0")){
                        allRad.setSelected(true);
                    }
                    linkTypeTxt.setText(p.getLinkType());
                    templateIdTxt.setText(p.getTemplateId());
                    expandColsTxt.setText(p.getExpandCols());
                    if(p.getIsShowImage().equals("1")){
                        isShowImage.setSelected(true);
                    }
                    this.pldefination = p;
                }
            }
        } catch (VCIError e) {
            e.printStackTrace();
        } catch (Throwable e) {
            e.printStackTrace();
        }
    }
}