001: /*
002: * SalomeTMF is a Test Management Framework
003: * Copyright (C) 2005 France Telecom R&D
004: *
005: * This library is free software; you can redistribute it and/or
006: * modify it under the terms of the GNU Lesser General Public
007: * License as published by the Free Software Foundation; either
008: * version 2 of the License, or (at your option) any later version.
009: *
010: * This library is distributed in the hope that it will be useful,
011: * but WITHOUT ANY WARRANTY; without even the implied warranty of
012: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
013: * Lesser General Public License for more details.
014: *
015: * You should have received a copy of the GNU Lesser General Public
016: * License along with this library; if not, write to the Free Software
017: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
018: *
019: * @author Fayçal SOUGRATI, Vincent Pautret, Marche Mikael
020: *
021: * Contact: mikael.marche@rd.francetelecom.com
022: */
023:
024: package org.objectweb.salome_tmf.ihm;
025:
026: import java.awt.BorderLayout;
027: import java.awt.Container;
028: import java.awt.Dimension;
029: import java.awt.Frame;
030: import java.awt.event.ActionEvent;
031: import java.awt.event.ActionListener;
032: import java.util.ArrayList;
033: import java.util.Iterator;
034:
035: import javax.swing.BorderFactory;
036: import javax.swing.Box;
037: import javax.swing.BoxLayout;
038: import javax.swing.DefaultListModel;
039: import javax.swing.JButton;
040: import javax.swing.JDialog;
041: import javax.swing.JList;
042: import javax.swing.JPanel;
043: import javax.swing.JScrollPane;
044: import javax.swing.ListSelectionModel;
045:
046: import org.objectweb.salome_tmf.data.AdminProjectData;
047: import org.objectweb.salome_tmf.ihm.languages.Language;
048: import org.objectweb.salome_tmf.ihm.models.UserListRenderer;
049:
050: /**
051: * Classe qui représentant la fenêtre de dialogue permettant d'ajouter un
052: * nouvel utilisateur à un groupe
053: * @author teaml039
054: * @version : 0.1
055: */
056: public class AddUser extends JDialog {
057:
058: /**
059: * Liste des utilisateurs à ajouter
060: */
061: private ArrayList userListResult;
062:
063: /**
064: * Modèle de données pour la liste d'utilisateurs
065: */
066: private DefaultListModel listModel;
067:
068: /**
069: * Liste des utilisateurs
070: */
071: private JList userList;
072:
073: /******************************************************************************/
074: /** CONSTRUCTEUR ***/
075: /******************************************************************************/
076:
077: /**
078: * Constructeur de la fenêtre
079: */
080: public AddUser() {
081:
082: // Pour maintenir le focus sur la fenêtre
083: super (new Frame(), true);
084: listModel = new DefaultListModel();
085: userList = new JList(listModel);
086: JButton addButton = new JButton(Language.getInstance().getText(
087: "Ajouter"));
088: addButton.setToolTipText(Language.getInstance().getText(
089: "Ajouter_un_utilisateur"));
090: addButton.addActionListener(new ActionListener() {
091: public void actionPerformed(ActionEvent e) {
092: userListResult = new ArrayList();
093: for (int i = 0; i < userList.getSelectedValues().length; i++) {
094: userListResult.add(userList.getSelectedValues()[i]);
095: }
096: AddUser.this .dispose();
097: }
098: });
099:
100: JButton cancelButton = new JButton(Language.getInstance()
101: .getText("Annuler"));
102: cancelButton.setToolTipText(Language.getInstance().getText(
103: "Annuler"));
104: cancelButton.addActionListener(new ActionListener() {
105: public void actionPerformed(ActionEvent e) {
106: AddUser.this .dispose();
107: }
108: });
109:
110: JPanel buttonGroup = new JPanel();
111: buttonGroup.setLayout(new BoxLayout(buttonGroup,
112: BoxLayout.X_AXIS));
113: buttonGroup.setBorder(BorderFactory.createEmptyBorder(0, 10,
114: 10, 10));
115: buttonGroup.add(Box.createHorizontalGlue());
116: buttonGroup.add(addButton);
117: buttonGroup.add(Box.createRigidArea(new Dimension(10, 0)));
118: buttonGroup.add(cancelButton);
119:
120: for (Iterator iter = AdminProjectData.getNotInProjectUserSet()
121: .iterator(); iter.hasNext();) {
122: listModel.addElement(iter.next());
123: }
124:
125: userList
126: .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
127: userList.setSelectedIndex(0);
128: userList.setCellRenderer(new UserListRenderer());
129: userList.setVisibleRowCount(5);
130: JScrollPane userListScrollPane = new JScrollPane(userList);
131:
132: userListScrollPane.setBorder(BorderFactory
133: .createTitledBorder(Language.getInstance().getText(
134: "Utilisateurs_possibles")));
135:
136: Container contentPaneFrame = this .getContentPane();
137: contentPaneFrame.setLayout(new BoxLayout(contentPaneFrame,
138: BoxLayout.Y_AXIS));
139: contentPaneFrame.add(userListScrollPane, BorderLayout.CENTER);
140: contentPaneFrame.add(buttonGroup);
141:
142: this .pack();
143: this .setLocation(400, 300);
144: this .setVisible(true);
145: this .setTitle(Language.getInstance().getText(
146: "Ajouter_un_nouvel_utilisateur"));
147: this .setFocusableWindowState(true);
148:
149: } // Fin du constructeur AddUser/0
150:
151: /******************************************************************************/
152: /** METHODES PUBLIQUES ***/
153: /******************************************************************************/
154:
155: /**
156: * Retourne la liste des utilisateurs à ajouter
157: * @return la liste des utilisateurs à ajouter
158: */
159: public ArrayList getUserList() {
160: return userListResult;
161: } // Fin de la méthode getUserList/0
162:
163: } // Fin de la class AddUser
|