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