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