01: package com.calipso.reportgenerator.usermanager;
02:
03: import com.calipso.reportgenerator.common.LanguageTraslator;
04: import com.calipso.reportgenerator.common.AbsoluteLayout;
05: import com.calipso.reportgenerator.common.AbsoluteConstraints;
06:
07: import javax.swing.*;
08: import java.util.ArrayList;
09: import java.awt.*;
10: import java.awt.event.ActionListener;
11: import java.awt.event.ActionEvent;
12:
13: /**
14: * frame para agregar roles a la lista de rolManagerModifyFrame
15: */
16: public class AddUsertoRolFrame extends JDialog {
17: private JPanel jpanel;
18: private JList listUsers;
19: private DefaultListModel listModel;
20: private JButton accept;
21: private JButton cancel;
22: private Object[] users;
23: private ArrayList list;
24:
25: public AddUsertoRolFrame(JDialog parent, ArrayList list) {
26: super (parent, true);
27: this .list = list;
28: initComponents();
29: }
30:
31: private void initComponents() {
32: jpanel = new JPanel();
33:
34: accept = new JButton();
35: cancel = new JButton();
36:
37: getContentPane().setLayout(new AbsoluteLayout());
38: jpanel.setLayout(new AbsoluteLayout());
39:
40: listModel = new DefaultListModel();
41:
42: for (int i = 0; i < list.size(); i++) {
43: listModel.addElement(list.get(i));
44: }
45:
46: listUsers = new JList(listModel);
47:
48: listUsers
49: .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
50:
51: listUsers.setVisible(true);
52:
53: JScrollPane scrollpane = new JScrollPane(listUsers);
54:
55: accept.setText(LanguageTraslator.traslate("112"));
56: jpanel.add(accept, new AbsoluteConstraints(5, 190, 90, 25));
57: accept.addActionListener(new Listener());
58:
59: cancel.setText(LanguageTraslator.traslate("113"));
60: jpanel.add(cancel, new AbsoluteConstraints(90, 190, 90, 25));
61:
62: jpanel.add(scrollpane, new AbsoluteConstraints(0, 0, 180, 180));
63:
64: setResizable(false);
65: getContentPane().add(jpanel,
66: new AbsoluteConstraints(0, 0, 180, 220));
67: Dimension scrn = getToolkit().getScreenSize();
68:
69: this .setLocation((scrn.width - getWidth()) / 3 + 270,
70: (scrn.height - getHeight()) / 3 + 150);
71: cancel.addActionListener(new Listener());
72: accept.addActionListener(new Listener());
73: pack();
74:
75: }
76:
77: class Listener implements ActionListener {
78:
79: public void actionPerformed(ActionEvent e) {
80: if (e.getSource() == cancel) {
81: setVisible(false);
82: } else if (e.getSource() == accept
83: && listUsers.getSelectedValues() != null) {
84: users = new Object[listUsers.getSelectedValues().length];
85:
86: users = listUsers.getSelectedValues();
87: setVisible(false);
88: }
89: }
90: }
91:
92: public Object[] getUsers() {
93: return users;
94: }
95:
96: }
|