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