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