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.Color;
028: import java.awt.Container;
029: import java.awt.Dimension;
030: import java.awt.FlowLayout;
031: import java.awt.GridLayout;
032: import java.awt.event.ActionEvent;
033: import java.awt.event.ActionListener;
034:
035: import javax.swing.BorderFactory;
036: import javax.swing.Box;
037: import javax.swing.BoxLayout;
038: import javax.swing.ButtonGroup;
039: import javax.swing.DefaultComboBoxModel;
040: import javax.swing.DefaultListModel;
041: import javax.swing.Icon;
042: import javax.swing.JButton;
043: import javax.swing.JComboBox;
044: import javax.swing.JDialog;
045: import javax.swing.JList;
046: import javax.swing.JPanel;
047: import javax.swing.JRadioButton;
048: import javax.swing.JScrollPane;
049: import javax.swing.ListSelectionModel;
050:
051: import org.objectweb.salome_tmf.ihm.languages.Language;
052: import org.objectweb.salome_tmf.ihm.models.UserListRenderer;
053: import org.objectweb.salome_tmf.ihm.tools.Tools;
054:
055: /**
056: * Classe qui permet d'afficher une fen?tre pour ordonner les campagnes de tests
057: * @author teaml039
058: * @version : 0.1
059: */
060: public class CampagneOrdering extends JDialog implements IHMConstants {
061:
062: /**
063: * Ancien mod?le de donn?e (avant r?organisation)
064: */
065: DefaultListModel oldModel;
066:
067: /**
068: * Mod?le de donn?es pour la liste de choix (famille, suites ou tests)
069: */
070: private DefaultComboBoxModel comboModel;
071:
072: /**
073: * Liste d?roulante pour le choix des ?l?ments ? trier
074: */
075: JComboBox choiceComboBox;
076:
077: /******************************************************************************/
078: /** CONSTRUCTEUR ***/
079: /******************************************************************************/
080:
081: /**
082: * Constructeur de la fen?tre de r?ordonnancement
083: * @param listModel le mod?le de donn?es de la liste
084: */
085: public CampagneOrdering(DefaultListModel listModel) {
086: super (SalomeTMF.ptrFrame);
087: comboModel = new DefaultComboBoxModel();
088: choiceComboBox = new JComboBox(comboModel);
089: JRadioButton campagneButton = new JRadioButton(Language
090: .getInstance().getText("Campagnes"));
091: campagneButton.addActionListener(new ActionListener() {
092: public void actionPerformed(ActionEvent e) {
093: choiceComboBox.setEnabled(false);
094: }
095: });
096:
097: JRadioButton familyButton = new JRadioButton(Language
098: .getInstance().getText("Familles"));
099: familyButton.addActionListener(new ActionListener() {
100: public void actionPerformed(ActionEvent e) {
101: choiceComboBox.setEnabled(true);
102: }
103: });
104:
105: JRadioButton testListButton = new JRadioButton(Language
106: .getInstance().getText("Suites"));
107: testListButton.addActionListener(new ActionListener() {
108: public void actionPerformed(ActionEvent e) {
109: choiceComboBox.setEnabled(true);
110: }
111: });
112:
113: JRadioButton testButton = new JRadioButton(Language
114: .getInstance().getText("Tests"));
115: testButton.addActionListener(new ActionListener() {
116: public void actionPerformed(ActionEvent e) {
117: choiceComboBox.setEnabled(true);
118: }
119: });
120:
121: //Grouper les boutons radio
122: ButtonGroup choiceGroup = new ButtonGroup();
123: choiceGroup.add(campagneButton);
124: choiceGroup.add(familyButton);
125: choiceGroup.add(testListButton);
126: choiceGroup.add(testButton);
127:
128: //Put the radio buttons in a column in a panel.
129: JPanel radioPanel = new JPanel(new GridLayout(1, 0));
130: radioPanel.add(campagneButton);
131: radioPanel.add(familyButton);
132: radioPanel.add(testListButton);
133: radioPanel.add(testButton);
134:
135: // Combo Panel
136: JPanel comboPanel = new JPanel(
137: new FlowLayout(FlowLayout.CENTER));
138: comboPanel.add(choiceComboBox);
139: choiceComboBox.setEnabled(false);
140:
141: JPanel choicePanel = new JPanel();
142: choicePanel.setLayout(new BoxLayout(choicePanel,
143: BoxLayout.Y_AXIS));
144: choicePanel.add(radioPanel);
145: choicePanel.add(comboPanel);
146: choicePanel.setBorder(BorderFactory
147: .createLineBorder(Color.BLACK));
148:
149: JButton upButton = new JButton();
150: Icon icon = Tools.createAppletImageIcon(PATH_TO_ARROW_UP_ICON,
151: "");
152: upButton.setIcon(icon);
153: upButton.setToolTipText(Language.getInstance().getText(
154: "Monter_d'un_cran"));
155: upButton.addActionListener(new ActionListener() {
156: public void actionPerformed(ActionEvent e) {
157: }
158: });
159:
160: JButton downButton = new JButton();
161: icon = Tools.createAppletImageIcon(PATH_TO_ARROW_DOWN_ICON, "");
162: downButton.setIcon(icon);
163: downButton.setToolTipText(Language.getInstance().getText(
164: "Descendre_d'un_cran"));
165: downButton.addActionListener(new ActionListener() {
166: public void actionPerformed(ActionEvent e) {
167: }
168: });
169:
170: JPanel buttonSet = new JPanel();
171: buttonSet.setLayout(new BoxLayout(buttonSet, BoxLayout.Y_AXIS));
172: buttonSet.add(upButton);
173: buttonSet.add(Box.createRigidArea(new Dimension(1, 25)));
174: buttonSet.add(downButton);
175:
176: JList list = new JList(listModel);
177: list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
178: list.setSelectedIndex(0);
179: list.setCellRenderer(new UserListRenderer());
180: list.setVisibleRowCount(15);
181: JScrollPane usersListScrollPane = new JScrollPane(list);
182:
183: usersListScrollPane.setBorder(BorderFactory
184: .createTitledBorder(""));
185:
186: JButton validate = new JButton(Language.getInstance().getText(
187: "Valider"));
188: validate.setToolTipText(Language.getInstance().getText(
189: "Valider"));
190: validate.addActionListener(new ActionListener() {
191: public void actionPerformed(ActionEvent e) {
192: CampagneOrdering.this .dispose();
193: }
194: });
195:
196: JButton cancel = new JButton(Language.getInstance().getText(
197: "Annuler"));
198: cancel
199: .setToolTipText(Language.getInstance().getText(
200: "Annuler"));
201: cancel.addActionListener(new ActionListener() {
202: public void actionPerformed(ActionEvent e) {
203: CampagneOrdering.this .dispose();
204: }
205: });
206:
207: JPanel secondButtonSet = new JPanel();
208: secondButtonSet.add(validate);
209: secondButtonSet.add(cancel);
210:
211: JPanel center = new JPanel();
212: center.add(usersListScrollPane);
213: center.add(buttonSet);
214:
215: JPanel page = new JPanel();
216: page.setLayout(new BoxLayout(page, BoxLayout.Y_AXIS));
217:
218: page.add(choicePanel);
219: page.add(Box.createRigidArea(new Dimension(1, 10)));
220: page.add(center);
221: page.add(secondButtonSet);
222:
223: Container contentPaneFrame = this .getContentPane();
224: contentPaneFrame.add(page, BorderLayout.CENTER);
225:
226: this .setLocation(400, 400);
227: this .setTitle(Language.getInstance().getText("Ordonner"));
228: this .pack();
229: this .setVisible(true);
230:
231: } // Fin du constructeur CampagneOrdering/1
232: } // Fin de la classe CampagneOrdering
|