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.FlowLayout;
031: import java.awt.GridLayout;
032: import java.awt.event.ActionEvent;
033: import java.awt.event.ActionListener;
034: import java.awt.event.WindowEvent;
035: import java.awt.event.WindowListener;
036: import java.io.File;
037: import java.util.ArrayList;
038: import java.util.Collection;
039: import java.util.Enumeration;
040: import java.util.Iterator;
041: import java.util.Set;
042: import java.util.StringTokenizer;
043:
044: import javax.swing.BorderFactory;
045: import javax.swing.Box;
046: import javax.swing.BoxLayout;
047: import javax.swing.JButton;
048: import javax.swing.JDialog;
049: import javax.swing.JFileChooser;
050: import javax.swing.JLabel;
051: import javax.swing.JOptionPane;
052: import javax.swing.JPanel;
053: import javax.swing.JScrollPane;
054: import javax.swing.JTable;
055: import javax.swing.JTextArea;
056: import javax.swing.JTextField;
057: import javax.swing.ListSelectionModel;
058: import javax.swing.event.ListSelectionEvent;
059: import javax.swing.event.ListSelectionListener;
060:
061: import org.java.plugin.Extension;
062: import org.objectweb.salome_tmf.api.Api;
063: import org.objectweb.salome_tmf.api.ApiConstants;
064: import org.objectweb.salome_tmf.api.api2ihm.AdminProject;
065: import org.objectweb.salome_tmf.data.Attachment;
066: import org.objectweb.salome_tmf.data.ConnectionData;
067: import org.objectweb.salome_tmf.data.DataConstants;
068: import org.objectweb.salome_tmf.data.Environment;
069: import org.objectweb.salome_tmf.data.Parameter;
070: import org.objectweb.salome_tmf.data.ProjectData;
071: import org.objectweb.salome_tmf.data.Script;
072: import org.objectweb.salome_tmf.ihm.datawrapper.DataModel;
073: import org.objectweb.salome_tmf.ihm.languages.Language;
074: import org.objectweb.salome_tmf.ihm.models.MyTableModel;
075: import org.objectweb.salome_tmf.ihm.models.ScriptFileFilter;
076: import org.objectweb.salome_tmf.ihm.models.TableSorter;
077: import org.objectweb.salome_tmf.ihm.plugins.PluginsTools;
078: import org.objectweb.salome_tmf.ihm.tools.Tools;
079:
080: /**
081: * @author teaml039
082: * @version : 0.1
083: */
084: public class AskNewEnvironment extends JDialog implements ApiConstants,
085: DataConstants, ActionListener, ListSelectionListener {
086:
087: /**
088: * La zone texte pour saisir le nom de l'environnement
089: */
090: JTextField nameField;
091:
092: /**
093: * La zone texte pour saisir la description
094: */
095: JTextArea descriptionArea;
096:
097: /**
098: * Le nouvel environnement
099: */
100: Environment environment;
101:
102: /**
103: * Zone de texte pour saisir le nom du script
104: */
105: JLabel scriptLabel;
106:
107: /**
108: * Table des paramètres
109: */
110: JTable parametersTable;
111:
112: /**
113: * Modèle de sélection pour la table des paramètres
114: */
115: ListSelectionModel rowSM;
116:
117: JButton deleteScriptButton;
118:
119: JButton modifyParameterButton;
120: JButton deleteParameter;
121:
122: JButton okButton;
123:
124: JButton cancelButton;
125:
126: private File scriptFile;
127:
128: private Script script;
129:
130: JButton addParameterButton;
131:
132: JButton addScriptFileButton;
133:
134: JButton useDefinedParameterButton;
135:
136: TableSorter sorter;
137:
138: boolean newFile = false;
139:
140: static ScriptFileFilter[] tabPlugScriptFileFilter = null;
141: static JFileChooser fileChooser = new JFileChooser();
142:
143: AttachmentView attachmentPanel;
144:
145: /**************************************************************************/
146: /** CONSTRUCTEUR ***/
147: /**************************************************************************/
148:
149: public AskNewEnvironment(Environment oldEnvironment) {
150: super (SalomeTMF.ptrFrame, true);
151:
152: nameField = new JTextField(10);
153: descriptionArea = new JTextArea(15, 40);
154: JLabel testNameLabel = new JLabel(Language.getInstance()
155: .getText("Nom_de_l'environnement_:_"));
156: scriptLabel = new JLabel(Language.getInstance().getText(
157: "Nom_du_script_:_"));
158: parametersTable = new JTable();
159: modifyParameterButton = new JButton(Language.getInstance()
160: .getText("Modifier"));
161: deleteParameter = new JButton(Language.getInstance().getText(
162: "Supprimer"));
163: deleteScriptButton = new JButton(Language.getInstance()
164: .getText("Supprimer"));
165: JPanel giveName = new JPanel();
166: giveName.setLayout(new BoxLayout(giveName, BoxLayout.X_AXIS));
167: giveName.setBorder(BorderFactory.createEmptyBorder(0, 10, 10,
168: 10));
169: giveName.add(Box.createHorizontalGlue());
170: giveName.add(testNameLabel);
171: giveName.add(Box.createRigidArea(new Dimension(10, 0)));
172: giveName.add(nameField);
173:
174: JScrollPane descriptionScrollPane = new JScrollPane(
175: descriptionArea);
176: descriptionScrollPane.setBorder(BorderFactory
177: .createTitledBorder(BorderFactory
178: .createLineBorder(Color.BLACK), Language
179: .getInstance().getText("Description")));
180: descriptionScrollPane.setPreferredSize(new Dimension(100, 100));
181:
182: addScriptFileButton = new JButton(Language.getInstance()
183: .getText("Chercher..."));
184: addScriptFileButton.setToolTipText(Language.getInstance()
185: .getText("Chercher_le_fichier_de_script"));
186: addScriptFileButton.addActionListener(this );
187:
188: deleteScriptButton.setToolTipText(Language.getInstance()
189: .getText("Supprimer_le_fichier_de_script"));
190: deleteScriptButton.addActionListener(this );
191:
192: JPanel giveScriptNamePanel = new JPanel(new FlowLayout(
193: FlowLayout.LEFT));
194: giveScriptNamePanel.add(scriptLabel);
195:
196: JPanel scriptButtonPanel = new JPanel(new FlowLayout(
197: FlowLayout.LEFT));
198: scriptButtonPanel.add(addScriptFileButton);
199: scriptButtonPanel.add(deleteScriptButton);
200:
201: JPanel giveScriptPanel = new JPanel();
202: giveScriptPanel.setLayout(new BoxLayout(giveScriptPanel,
203: BoxLayout.Y_AXIS));
204: giveScriptPanel.add(giveScriptNamePanel);
205: giveScriptPanel.add(scriptButtonPanel);
206:
207: sorter = new TableSorter(DataModel
208: .getEnvironmentParameterTableModel());
209: parametersTable.setModel(sorter);
210: sorter.setTableHeader(parametersTable.getTableHeader());
211:
212: JScrollPane parametersScrollPane = new JScrollPane(
213: parametersTable);
214: parametersScrollPane.setPreferredSize(new Dimension(450, 100));
215:
216: addParameterButton = new JButton(Language.getInstance()
217: .getText("Nouveau"));
218: addParameterButton.setToolTipText(Language.getInstance()
219: .getText("Ajouter_un_nouveau_paramètre"));
220: addParameterButton.addActionListener(this );
221:
222: useDefinedParameterButton = new JButton(Language.getInstance()
223: .getText("Utiliser"));
224: useDefinedParameterButton.setToolTipText(Language.getInstance()
225: .getText("Utiliser_un_paramètre_existant"));
226: useDefinedParameterButton.addActionListener(this );
227:
228: modifyParameterButton.setToolTipText(Language.getInstance()
229: .getText("Modifier_un_paramètre"));
230: modifyParameterButton.setEnabled(false);
231: modifyParameterButton.addActionListener(this );
232:
233: deleteParameter.setToolTipText(Language.getInstance().getText(
234: "Supprimer_un_paramètre"));
235: deleteParameter.setEnabled(false);
236: deleteParameter.addActionListener(this );
237:
238: //JPanel attachButtonPanel = new JPanel();
239: //attachButtonPanel.setLayout(new BoxLayout(attachButtonPanel, BoxLayout.Y_AXIS));
240: JPanel attachButtonPanel = new JPanel(new GridLayout(4, 1));
241: attachButtonPanel.add(addParameterButton);
242: attachButtonPanel.add(useDefinedParameterButton);
243: attachButtonPanel.add(modifyParameterButton);
244: attachButtonPanel.add(deleteParameter);
245:
246: JPanel parameterPanel = new JPanel();
247: parameterPanel.setLayout(new BoxLayout(parameterPanel,
248: BoxLayout.X_AXIS));
249: parameterPanel.add(parametersScrollPane);
250: parameterPanel.add(attachButtonPanel);
251: parameterPanel.setBorder(BorderFactory.createTitledBorder(
252: BorderFactory.createLineBorder(Color.BLACK), Language
253: .getInstance().getText("Paramètres")));
254:
255: JPanel textPanel = new JPanel();
256: textPanel.setLayout(new BoxLayout(textPanel, BoxLayout.Y_AXIS));
257: textPanel.add(Box.createRigidArea(new Dimension(0, 10)));
258: textPanel.add(giveName);
259: textPanel.add(Box.createRigidArea(new Dimension(0, 10)));
260: textPanel.add(giveScriptPanel);
261: textPanel.add(Box.createRigidArea(new Dimension(1, 30)));
262: textPanel.add(descriptionScrollPane);
263: textPanel.add(Box.createRigidArea(new Dimension(1, 30)));
264: textPanel.add(parameterPanel);
265:
266: attachmentPanel = new AttachmentView(DataModel.getApplet(),
267: ENVIRONMENT, ENVIRONMENT, oldEnvironment,
268: SMALL_SIZE_FOR_ATTACH, null, null, null);
269: attachmentPanel.setBorder(BorderFactory.createTitledBorder(
270: BorderFactory.createLineBorder(Color.BLACK), Language
271: .getInstance().getText("Attachements")));
272: textPanel.add(attachmentPanel);
273:
274: okButton = new JButton(Language.getInstance()
275: .getText("Valider"));
276: okButton.setToolTipText(Language.getInstance().getText(
277: "Valider"));
278: okButton.addActionListener(this );
279:
280: cancelButton = new JButton(Language.getInstance().getText(
281: "Annuler"));
282: cancelButton.setToolTipText(Language.getInstance().getText(
283: "Annuler"));
284: cancelButton.addActionListener(this );
285:
286: JPanel buttonPanel = new JPanel(new FlowLayout());
287:
288: buttonPanel.add(okButton);
289: buttonPanel.add(cancelButton);
290:
291: textPanel.add(buttonPanel);
292:
293: //Initialisation des données de la fenêtre
294: initData(oldEnvironment);
295:
296: Container contentPaneFrame = this .getContentPane();
297: contentPaneFrame.add(textPanel, BorderLayout.CENTER);
298:
299: rowSM = parametersTable.getSelectionModel();
300: rowSM.addListSelectionListener(this );
301:
302: this .addWindowListener(new WindowListener() {
303: public void windowClosing(WindowEvent e) {
304: environment = null;
305: }
306:
307: public void windowDeiconified(WindowEvent e) {
308: }
309:
310: public void windowOpened(WindowEvent e) {
311: }
312:
313: public void windowActivated(WindowEvent e) {
314: }
315:
316: public void windowDeactivated(WindowEvent e) {
317: }
318:
319: public void windowClosed(WindowEvent e) {
320: }
321:
322: public void windowIconified(WindowEvent e) {
323: }
324: });
325:
326: giveAccessToIhm();
327:
328: this .setLocation(200, 20);
329: if (oldEnvironment == null) {
330: this .setTitle(Language.getInstance().getText(
331: "Ajouter_un_environnement"));
332: } else {
333: this .setTitle(Language.getInstance().getText(
334: "Modifier_un_environnement"));
335: }
336: if (tabPlugScriptFileFilter == null) {
337: initTabPlugScriptFileFilter();
338: }
339:
340: // Mapping entre objets graphiques et constantes
341: SalomeTMF.addToUIComponentsMap(
342: UICompCst.DATA_MANAGEMENT_NEW_ENV_WINDOW, this );
343: // Activation des plugins associés
344: PluginsTools
345: .activateAssociatedPlgs(UICompCst.DATA_MANAGEMENT_NEW_ENV_WINDOW);
346:
347: this .pack();
348: this .setVisible(true);
349:
350: } // Fin du constructeur AskNewEnvironment/1
351:
352: public AskNewEnvironment() {
353: this (null);
354: } // Fin du constructeur AskNewEnvironment/0
355:
356: private void initTabPlugScriptFileFilter() {
357: if (SalomeTMF.associatedScriptEngine.size() == 0) {
358: deleteScriptButton.setEnabled(false);
359: addScriptFileButton.setEnabled(false);
360: fileChooser = null;
361: return;
362: }
363: tabPlugScriptFileFilter = new ScriptFileFilter[SalomeTMF.associatedScriptEngine
364: .size()];
365: Enumeration e = SalomeTMF.associatedScriptEngine.keys();
366: int i = 0;
367: while (e.hasMoreElements()) {
368: Extension ScriptExt = (Extension) e.nextElement();
369: String extID = ScriptExt.getId();
370: String extList = (String) SalomeTMF.associatedScriptEngine
371: .get(ScriptExt);
372: StringTokenizer st = new StringTokenizer(extList, ",");
373: String[] tabExt = new String[st.countTokens()];
374: Api.log("Add extension " + extID + ", with filter :"
375: + extList);
376: int j = 0;
377: while (st.hasMoreTokens()) {
378: tabExt[j] = st.nextToken();
379: j++;
380: }
381: tabPlugScriptFileFilter[i] = new ScriptFileFilter(extID,
382: tabExt);
383: i++;
384: }
385: int tabFilterSize = tabPlugScriptFileFilter.length;
386: for (i = 0; i < tabFilterSize; i++) {
387: fileChooser
388: .addChoosableFileFilter(tabPlugScriptFileFilter[i]);
389: }
390: fileChooser.setAcceptAllFileFilterUsed(false);
391: }
392:
393: /**
394: *
395: * @return
396: */
397: public Environment getEnvironment() {
398: return environment;
399: } // Fin de la méthode getEnvironment/0
400:
401: /**
402: *
403: * @param oldEnvironment
404: */
405: private void initData(Environment oldEnvironment) {
406: if (oldEnvironment != null) {
407: environment = oldEnvironment;
408: nameField.setText(oldEnvironment.getName());
409: if (oldEnvironment.getInitScript() != null) {
410: scriptLabel.setText(Language.getInstance().getText(
411: "Nom_du_script_:_")
412: + oldEnvironment.getInitScript().getName());
413: }
414: script = oldEnvironment.getInitScript();
415: descriptionArea.setText(oldEnvironment.getDescription());
416: ((MyTableModel) ((TableSorter) parametersTable.getModel())
417: .getTableModel()).clearTable();
418: int i = 0;
419: Set keysSet = oldEnvironment.getParametersHashTable()
420: .keySet();
421: for (Iterator iter = keysSet.iterator(); iter.hasNext();) {
422: Parameter param = (Parameter) iter.next();
423: ((MyTableModel) ((TableSorter) parametersTable
424: .getModel()).getTableModel()).addValueAt(param
425: .getName(), i, 0);
426: ((MyTableModel) ((TableSorter) parametersTable
427: .getModel()).getTableModel()).addValueAt(
428: oldEnvironment.getParameterValue(param), i, 1);
429: ((MyTableModel) ((TableSorter) parametersTable
430: .getModel()).getTableModel()).addValueAt(param
431: .getDescription(), i, 2);
432: }
433: Collection col = oldEnvironment.getAttachmentMap().values();
434: DataModel.initAttachmentTable(col);
435: } else {
436: environment = new Environment();
437: ((MyTableModel) ((TableSorter) parametersTable.getModel())
438: .getTableModel()).clearTable();
439: DataModel.getAttachmentTableModel().clearTable();
440: }
441: DataModel.setCurrentEnvironment(environment);
442: } // Fin de la méthode initData/1
443:
444: private void createAndQuit() {
445: environment.setName(nameField.getText().trim());
446: environment.setDescription(descriptionArea.getText());
447: environment.setInitScript(script);
448: environment.getAttachmentMap().clear();
449: Collection values = attachmentPanel.getAttachmentMap().values();
450: for (Iterator iter = values.iterator(); iter.hasNext();) {
451: environment.addAttachment((Attachment) iter.next());
452: }
453:
454: AskNewEnvironment.this .dispose();
455: }
456:
457: public File getScriptFile() {
458: return scriptFile;
459: }
460:
461: private void giveAccessToIhm() {
462: if (!AdminProject.canDeleteCamp()) {
463: deleteScriptButton.setEnabled(false);
464: deleteParameter.setEnabled(false);
465: }
466: if (!AdminProject.canCreateCamp()) {
467: addParameterButton.setEnabled(false);
468: addScriptFileButton.setEnabled(false);
469: useDefinedParameterButton.setEnabled(false);
470: }
471: if (!AdminProject.canUpdateCamp()) {
472: modifyParameterButton.setEnabled(false);
473: }
474: }
475:
476: public void actionPerformed(ActionEvent e) {
477: Object source = e.getSource();
478: if (source.equals(addScriptFileButton)) {
479: addScriptPerformed(e);
480: } else if (source.equals(deleteScriptButton)) {
481: deleteScriptPerformed(e);
482: } else if (source.equals(addParameterButton)) {
483: addParameterPerformed(e);
484: } else if (source.equals(useDefinedParameterButton)) {
485: useDefinedParameterPerformed(e);
486: } else if (source.equals(modifyParameterButton)) {
487: modifyParameterPerformed(e);
488: } else if (source.equals(deleteParameter)) {
489: deleteParameterPerformed(e);
490: } else if (source.equals(okButton)) {
491: okButtonPerformed(e);
492: } else if (source.equals(cancelButton)) {
493: cancelPerformed(e);
494: }
495: }
496:
497: public void addScriptPerformed(ActionEvent e) {
498: if (fileChooser == null) {
499: addScriptFileButton.setEnabled(false);
500: deleteScriptButton.setEnabled(false);
501: return;
502: }
503: fileChooser.setApproveButtonText(Language.getInstance()
504: .getText("Valider"));
505:
506: int returnVal = fileChooser
507: .showOpenDialog(AskNewEnvironment.this );
508: if (returnVal == JFileChooser.APPROVE_OPTION) {
509: ScriptFileFilter filter = (ScriptFileFilter) fileChooser
510: .getFileFilter();
511:
512: String scriptPlugIns = filter.getDescription();
513: scriptFile = fileChooser.getSelectedFile();
514: try {
515: if (!scriptFile.exists()) {
516: scriptFile.createNewFile();
517: newFile = true;
518: }
519: } catch (Exception ex) {
520: return;
521: }
522: scriptLabel.setText(Language.getInstance().getText(
523: "Nom_du_script_:_")
524: + scriptFile.getAbsolutePath());
525: script = new Script();
526: script.setName(scriptFile.getName());
527: script.setLocalisation(scriptFile.getAbsolutePath());
528: script.setScriptExtension(scriptPlugIns);
529: script.setPlugArg("");
530: script.setType(INIT_SCRIPT);
531: }
532: }
533:
534: public void deleteScriptPerformed(ActionEvent e) {
535: scriptLabel.setText(Language.getInstance().getText(
536: "Nom_du_script_:_"));
537: script = null;
538: }
539:
540: public void addParameterPerformed(ActionEvent e) {
541: AskNewParameter askNewParameter = new AskNewParameter(
542: environment);
543: if (askNewParameter.getParameter() != null
544: && askNewParameter.getParameter().getName() != null
545: && askNewParameter.getParameter().getName() != "") {
546:
547: try {
548: // BdD
549: ProjectData.getCurrentProject()
550: .addParameterToBddAndModel(
551: askNewParameter.getParameter());
552: //askNewParameter.getParameter().add2DB();
553: // IHM
554: ArrayList data = new ArrayList();
555: data.add(askNewParameter.getParameter().getName());
556: data.add(askNewParameter.getValue());
557: data.add(askNewParameter.getParameter()
558: .getDescription());
559: DataModel.getEnvironmentParameterTableModel().addRow(
560: data);
561: environment.addParameter(
562: askNewParameter.getParameter(), askNewParameter
563: .getValue());
564: //ProjectData.getCurrentProject().addParameter(askNewParameter.getParameter());
565: data.remove(1);
566: DataModel.getParameterTableModel().addRow(data);
567:
568: } catch (Exception exception) {
569: Tools.ihmExceptionView(exception.toString());
570: }
571: }
572: }
573:
574: public void useDefinedParameterPerformed(ActionEvent e) {
575: UsingDefinedParameterView usingDefinedParameterView = new UsingDefinedParameterView(
576: true, true);
577: if (usingDefinedParameterView.getParameter() != null) {
578: if (!environment
579: .containsParameter(usingDefinedParameterView
580: .getParameter())) {
581: ArrayList data = new ArrayList();
582: data.add(usingDefinedParameterView.getParameter()
583: .getName());
584: data.add(usingDefinedParameterView.getValue());
585: data.add(usingDefinedParameterView.getParameter()
586: .getDescription());
587: DataModel.getEnvironmentParameterTableModel().addRow(
588: data);
589: environment.addParameter(usingDefinedParameterView
590: .getParameter(), usingDefinedParameterView
591: .getValue());
592: } else {
593: JOptionPane
594: .showMessageDialog(
595: AskNewEnvironment.this ,
596: Language
597: .getInstance()
598: .getText(
599: "Ce_paramètre_est_déjà_présent_dans_votre_environnement_!"),
600: Language.getInstance().getText(
601: "Erreur_!"),
602: JOptionPane.ERROR_MESSAGE);
603: }
604: }
605: }
606:
607: public void modifyParameterPerformed(ActionEvent e) {
608: int selectedRow = parametersTable.getSelectedRow();
609: if (selectedRow != -1) {
610: //Parameter param = environment.getParameter((String)TestData.getEnvironmentParameterTableModel().getValueAt(selectedRow,0));
611: Parameter param = environment.getParameter((String) sorter
612: .getValueAt(selectedRow, 0));
613: AskNewParameter askNewParameter = new AskNewParameter(
614: environment, param);
615: if (askNewParameter.getParameter() != null) {
616:
617: sorter.setValueAt(askNewParameter.getParameter()
618: .getName(), selectedRow, 0);
619: sorter.setValueAt(askNewParameter.getValue(),
620: selectedRow, 1);
621: sorter.setValueAt(askNewParameter.getParameter()
622: .getDescription(), selectedRow, 2);
623: environment.setNewValue(askNewParameter.getParameter(),
624: askNewParameter.getValue());
625: }
626: }
627: }
628:
629: public void deleteParameterPerformed(ActionEvent e) {
630: int[] selectedRows = parametersTable.getSelectedRows();
631: for (int i = selectedRows.length - 1; i >= 0; i--) {
632:
633: environment.removeParameter((String) sorter.getValueAt(
634: selectedRows[i], 0));
635: DataModel.getEnvironmentParameterTableModel().removeData(
636: sorter.modelIndex(selectedRows[i]));
637: }
638: }
639:
640: public void okButtonPerformed(ActionEvent e) {
641: if (!nameField.getText().trim().equals("")) {
642: if (!ProjectData.getCurrentProject().containsEnvironment(
643: nameField.getText().trim())
644: && !nameField.getText().trim().equals(
645: DataModel.EMPTY_NAME)
646: && !ConnectionData.isInBaseEnv(nameField.getText()
647: .trim())) {
648: createAndQuit();
649: } else if (ProjectData.getCurrentProject().getEnvironment(
650: nameField.getText().trim()) != null
651: && ProjectData.getCurrentProject().getEnvironment(
652: nameField.getText().trim()).equals(
653: environment)) {
654: createAndQuit();
655: } else {
656: JOptionPane
657: .showMessageDialog(
658: AskNewEnvironment.this ,
659: Language
660: .getInstance()
661: .getText(
662: "Ce_nom_d'environnement_existe_déjà_!"),
663: Language.getInstance().getText(
664: "Erreur_!"),
665: JOptionPane.ERROR_MESSAGE);
666: }
667: } else {
668: JOptionPane
669: .showMessageDialog(
670: AskNewEnvironment.this ,
671: Language
672: .getInstance()
673: .getText(
674: "Il_faut_obligatoirement_donner_un_nom_à_l'environnement_!"),
675: Language.getInstance().getText(
676: "Attention_!"),
677: JOptionPane.WARNING_MESSAGE);
678: }
679:
680: }
681:
682: public void cancelPerformed(ActionEvent e) {
683: environment = null;
684: if (newFile)
685: scriptFile.delete();
686: AskNewEnvironment.this .dispose();
687: }
688:
689: public void valueChanged(ListSelectionEvent e) {
690: int nbOfSelectedRows = parametersTable.getSelectedRowCount();
691: int selectedRow = parametersTable.getSelectedRow();
692: if (selectedRow != -1) {
693: if (nbOfSelectedRows != 1) {
694: if (AdminProject.canDeleteCamp())
695: deleteParameter.setEnabled(true);
696: modifyParameterButton.setEnabled(false);
697: } else {
698: if (AdminProject.canUpdateCamp())
699: modifyParameterButton.setEnabled(true);
700: if (AdminProject.canDeleteCamp())
701: deleteParameter.setEnabled(true);
702: }
703: } else {
704: deleteParameter.setEnabled(false);
705: modifyParameterButton.setEnabled(false);
706: }
707:
708: }
709:
710: } // Fin de la classe AskNewEnvironment
|