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.Component;
029: import java.awt.Container;
030: import java.awt.Dimension;
031: import java.awt.event.ActionEvent;
032: import java.awt.event.ActionListener;
033:
034: import javax.swing.BorderFactory;
035: import javax.swing.Box;
036: import javax.swing.BoxLayout;
037: import javax.swing.JButton;
038: import javax.swing.JComboBox;
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.Campaign;
048: import org.objectweb.salome_tmf.data.ProjectData;
049: import org.objectweb.salome_tmf.ihm.languages.Language;
050:
051: /**
052: * Classe qui définit la fenêtre permettant de créer une nouvelle campagne
053: * @author teaml039
054: * @version 0.1
055: */
056: public class AskNewCampagne extends JDialog {
057:
058: /**
059: * Le champ du nom de campagne
060: */
061: JTextField campagneNameField;
062:
063: /**
064: * Le champ du concepteur
065: */
066: JComboBox conceptorNameField;
067:
068: /**
069: * La description
070: */
071: JTextArea descriptionArea;
072:
073: /**
074: * La campagne créée
075: */
076: Campaign campagne;
077:
078: /******************************************************************************/
079: /** CONSTRUCTEUR ***/
080: /******************************************************************************/
081:
082: /**
083: * Constructeur de la fenêtre.
084: * @param textToBePrompt chaîne correspondant à la demande.
085: */
086: public AskNewCampagne(Component parent, String textToBePrompt) {
087:
088: //Pour bloquer le focus sur la boite de dialogue
089: super (SalomeTMF.ptrFrame, true);
090: campagneNameField = new JTextField(10);
091: conceptorNameField = new JComboBox();
092: descriptionArea = new JTextArea(10, 20);
093: JPanel page = new JPanel();
094:
095: JLabel testNameLabel = new JLabel(Language.getInstance()
096: .getText("Nom_de_la_campagne_:_"));
097: JLabel conceptorNameLabel = new JLabel(Language.getInstance()
098: .getText("Nom_du_concepteur_:"));
099:
100: JPanel giveName = new JPanel();
101: giveName.setLayout(new BoxLayout(giveName, BoxLayout.X_AXIS));
102: giveName.setBorder(BorderFactory.createEmptyBorder(0, 10, 10,
103: 10));
104: giveName.add(Box.createHorizontalGlue());
105: giveName.add(testNameLabel);
106: giveName.add(Box.createRigidArea(new Dimension(10, 0)));
107: giveName.add(campagneNameField);
108:
109: JPanel giveConceptorName = new JPanel();
110: giveConceptorName.setLayout(new BoxLayout(giveConceptorName,
111: BoxLayout.X_AXIS));
112: giveConceptorName.setBorder(BorderFactory.createEmptyBorder(0,
113: 10, 10, 10));
114: giveConceptorName.add(Box.createHorizontalGlue());
115: giveConceptorName.add(conceptorNameLabel);
116: giveConceptorName
117: .add(Box.createRigidArea(new Dimension(10, 0)));
118: giveConceptorName.add(conceptorNameField);
119:
120: //descriptionArea.setPreferredSize(new Dimension(100,150));
121: JScrollPane descriptionScrollPane = new JScrollPane(
122: descriptionArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
123: JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
124: descriptionScrollPane.setBorder(BorderFactory
125: .createTitledBorder(BorderFactory
126: .createLineBorder(Color.BLACK), Language
127: .getInstance().getText("Description")));
128:
129: JPanel textPanel = new JPanel();
130: textPanel.setLayout(new BoxLayout(textPanel, BoxLayout.Y_AXIS));
131: textPanel.add(Box.createRigidArea(new Dimension(0, 10)));
132: textPanel.add(giveName);
133:
134: textPanel.add(Box.createRigidArea(new Dimension(1, 30)));
135: textPanel.add(Box.createRigidArea(new Dimension(1, 30)));
136: textPanel.add(descriptionScrollPane);
137:
138: JButton okButton = new JButton(Language.getInstance().getText(
139: "Valider"));
140: okButton.setToolTipText(Language.getInstance().getText(
141: "Valider"));
142: okButton.addActionListener(new ActionListener() {
143: public void actionPerformed(ActionEvent e) {
144:
145: if (campagneNameField.getText() != null
146: && !campagneNameField.getText().trim().equals(
147: "")) {
148: campagne = new Campaign();
149: campagne
150: .setName(campagneNameField.getText().trim());
151: campagne.setConceptor(ProjectData.getCurrentUser()
152: .getLogin());
153: campagne.setDescription(descriptionArea.getText());
154: AskNewCampagne.this .dispose();
155: } else {
156: JOptionPane
157: .showMessageDialog(
158: AskNewCampagne.this ,
159: Language
160: .getInstance()
161: .getText(
162: "Il_faut_obligatoirement_donner_un_nom_à_la_campagne_!"),
163: Language.getInstance().getText(
164: "Attention_!"),
165: JOptionPane.WARNING_MESSAGE);
166: }
167: }
168: });
169:
170: campagneNameField.addActionListener(new ActionListener() {
171: public void actionPerformed(ActionEvent e) {
172: }
173: });
174:
175: JButton cancelButton = new JButton(Language.getInstance()
176: .getText("Annuler"));
177: cancelButton.setToolTipText(Language.getInstance().getText(
178: "Annuler"));
179: cancelButton.addActionListener(new ActionListener() {
180: public void actionPerformed(ActionEvent e) {
181: AskNewCampagne.this .dispose();
182: }
183: });
184:
185: JPanel buttonPanel = new JPanel();
186: buttonPanel.setLayout(new BorderLayout());
187: buttonPanel.add(okButton, BorderLayout.NORTH);
188: buttonPanel.add(cancelButton, BorderLayout.SOUTH);
189:
190: page.add(textPanel, BorderLayout.WEST);
191: page.add(Box.createRigidArea(new Dimension(40, 10)),
192: BorderLayout.CENTER);
193: page.add(buttonPanel, BorderLayout.EAST);
194:
195: Container contentPaneFrame = this .getContentPane();
196: contentPaneFrame.add(page, BorderLayout.CENTER);
197:
198: this .setLocation(400, 400);
199: this .setTitle(textToBePrompt);
200: this .pack();
201: this .setVisible(true);
202:
203: } // Fin du constructeur AskNewCampagne/2
204:
205: /******************************************************************************/
206: /** METHODES PUBLIQUES ***/
207: /******************************************************************************/
208:
209: /**
210: * Retourne la campagne
211: * @return la campagne
212: */
213: public Campaign getCampagne() {
214: return campagne;
215: } // Fin de la méthode getCampagne/0
216:
217: } // Fin de la classe AskNewCampagne
|