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.event.ActionEvent;
031: import java.awt.event.ActionListener;
032: import java.awt.event.WindowEvent;
033: import java.awt.event.WindowListener;
034:
035: import javax.swing.BorderFactory;
036: import javax.swing.Box;
037: import javax.swing.BoxLayout;
038: import javax.swing.JButton;
039: import javax.swing.JDialog;
040: import javax.swing.JLabel;
041: import javax.swing.JOptionPane;
042: import javax.swing.JPanel;
043: import javax.swing.JScrollPane;
044: import javax.swing.JTextArea;
045: import javax.swing.JTextField;
046:
047: import org.objectweb.salome_tmf.data.TestList;
048: import org.objectweb.salome_tmf.ihm.languages.Language;
049:
050: /**
051: * Classe qui permet d'afficher une fenêtre demandant d'entrer les
052: * informations pour les suites de tests
053: * @author teaml039
054: * @version 0.1
055: */
056: public class AskNewTestList extends JDialog {
057:
058: /**
059: * La nouvelle suite de tests
060: */
061: private TestList testList;
062:
063: /**
064: * Le Field permettant de récupérer la chaîne
065: */
066: private JTextField testListNameField;
067:
068: /**
069: * La zone de texte permettant de récupérer la description
070: */
071: private JTextArea descriptionArea;
072:
073: /**
074: * Nom de la famille
075: */
076: //private String familyName;
077: /******************************************************************************/
078: /** CONSTRUCTEUR ***/
079: /******************************************************************************/
080:
081: /**
082: * Constructeur de la fenêtre.
083: * @param title le titre de la fenêtre
084: * @param textToBePrompt chaîne correspondant à la demande.
085: */
086: public AskNewTestList(String title, String textToBePrompt) {
087:
088: super (SalomeTMF.ptrFrame, true);
089: testListNameField = new JTextField(10);
090: //familyName = "";
091: descriptionArea = new JTextArea(10, 20);
092: JPanel page = new JPanel();
093:
094: JLabel prompt = new JLabel(textToBePrompt);
095:
096: JPanel giveName = new JPanel();
097:
098: giveName.setLayout(new BoxLayout(giveName, BoxLayout.X_AXIS));
099: giveName.setBorder(BorderFactory.createEmptyBorder(0, 10, 10,
100: 10));
101: giveName.add(Box.createHorizontalGlue());
102: giveName.add(prompt);
103: giveName.add(Box.createRigidArea(new Dimension(10, 0)));
104: giveName.add(testListNameField);
105:
106: //descriptionArea.setPreferredSize(new Dimension(100,150));
107: JScrollPane descriptionScrollPane = new JScrollPane(
108: descriptionArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
109: JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
110: descriptionScrollPane.setBorder(BorderFactory
111: .createTitledBorder(BorderFactory
112: .createLineBorder(Color.BLACK), Language
113: .getInstance().getText("Description")));
114:
115: JPanel textPanel = new JPanel();
116: textPanel.setLayout(new BoxLayout(textPanel, BoxLayout.Y_AXIS));
117: textPanel.add(Box.createRigidArea(new Dimension(0, 10)));
118: textPanel.add(giveName);
119: textPanel.add(Box.createRigidArea(new Dimension(0, 10)));
120: textPanel.add(descriptionScrollPane);
121:
122: JButton okButton = new JButton(Language.getInstance().getText(
123: "Valider"));
124: okButton.setToolTipText(Language.getInstance().getText(
125: "Valider"));
126: okButton.addActionListener(new ActionListener() {
127: public void actionPerformed(ActionEvent e) {
128: if (testListNameField.getText() != null
129: && (!testListNameField.getText().trim().equals(
130: ""))) {
131: testList = new TestList();
132: testList
133: .setName(testListNameField.getText().trim());
134: testList.setDescription(descriptionArea.getText());
135:
136: AskNewTestList.this .dispose();
137: } else {
138: testListNameField.selectAll();
139: JOptionPane.showMessageDialog(AskNewTestList.this ,
140: Language.getInstance().getText(
141: "Vous_devez_entrez_un_nom."),
142: Language.getInstance().getText("Erreur_!"),
143: JOptionPane.ERROR_MESSAGE);
144: testListNameField.requestFocusInWindow();
145: }
146: }
147: });
148:
149: testListNameField.addActionListener(new ActionListener() {
150: public void actionPerformed(ActionEvent e) {
151:
152: }
153: });
154: JButton cancelButton = new JButton(Language.getInstance()
155: .getText("Annuler"));
156: cancelButton.setToolTipText(Language.getInstance().getText(
157: "Annuler"));
158: cancelButton.addActionListener(new ActionListener() {
159: public void actionPerformed(ActionEvent e) {
160: testList = null;
161: AskNewTestList.this .dispose();
162: }
163: });
164:
165: JPanel buttonPanel = new JPanel();
166: buttonPanel.setLayout(new BorderLayout());
167: buttonPanel.add(okButton, BorderLayout.NORTH);
168: buttonPanel.add(cancelButton, BorderLayout.SOUTH);
169:
170: page.add(textPanel, BorderLayout.WEST);
171: page.add(Box.createRigidArea(new Dimension(40, 10)),
172: BorderLayout.CENTER);
173: page.add(buttonPanel, BorderLayout.EAST);
174:
175: Container contentPaneFrame = this .getContentPane();
176: contentPaneFrame.add(page, BorderLayout.CENTER);
177:
178: this .addWindowListener(new WindowListener() {
179: public void windowClosing(WindowEvent e) {
180: testList = null;
181: }
182:
183: public void windowDeiconified(WindowEvent e) {
184: }
185:
186: public void windowOpened(WindowEvent e) {
187: }
188:
189: public void windowActivated(WindowEvent e) {
190: }
191:
192: public void windowDeactivated(WindowEvent e) {
193: }
194:
195: public void windowClosed(WindowEvent e) {
196: }
197:
198: public void windowIconified(WindowEvent e) {
199: }
200: });
201:
202: this .setTitle(title);
203: this .pack();
204: this .setLocation(400, 300);
205: this .setVisible(true);
206: } // Fin du constructeur AskNewTestList/2
207:
208: /******************************************************************************/
209: /** METHODES PUBLIQUES ***/
210: /******************************************************************************/
211:
212: /**
213: * Récupère la nouvelle suite de tests
214: * @return la nouvelle suite de tests
215: */
216: public TestList getTestList() {
217: return testList;
218: } // Fin de la méthode getTestList/0
219:
220: } // Fin de la classe AskNewTestList
|