001: package org.objectweb.salome_tmf.ihm;
002:
003: import java.awt.Frame;
004: import java.awt.event.ActionEvent;
005: import java.awt.event.ActionListener;
006:
007: import javax.swing.JMenuItem;
008: import javax.swing.JOptionPane;
009: import javax.swing.JPopupMenu;
010: import javax.swing.tree.DefaultMutableTreeNode;
011:
012: import org.objectweb.salome_tmf.api.api2ihm.AdminProject;
013: import org.objectweb.salome_tmf.data.Family;
014: import org.objectweb.salome_tmf.data.TestPlanData;
015: import org.objectweb.salome_tmf.ihm.datawrapper.DataModel;
016: import org.objectweb.salome_tmf.ihm.languages.Language;
017:
018: public class PopupMenuFactory {
019: static JMenuItem importToCampMenuItem = null;
020: static JMenuItem delTestMenuItem = null;
021: static JMenuItem delCampMenuItem = null;
022:
023: /**
024: * Methode qui cree un menu PopUp pour le clic droit de la souris sur
025: * l'arbre des suites
026: * @return un menu PopUp
027: */
028: public static JPopupMenu createTreePopUpForList() {
029: //Creation du menu PopUp de la table
030: JPopupMenu popup = new JPopupMenu();
031:
032: JMenuItem newFamilyMenuItem = new JMenuItem(Language
033: .getInstance().getText("Nouvelle_famille"));
034: newFamilyMenuItem.addActionListener(new ActionListener() {
035: public void actionPerformed(ActionEvent e) {
036: DataModel.addNewFamily();
037: }
038: });
039: popup.add(newFamilyMenuItem);
040:
041: JMenuItem newListMenuItem = new JMenuItem(Language
042: .getInstance().getText("Nouvelle_suite"));
043: newListMenuItem.addActionListener(new ActionListener() {
044: public void actionPerformed(ActionEvent e) {
045: DataModel.addNewTestList();
046: }
047: });
048: popup.add(newListMenuItem);
049:
050: JMenuItem newTestMenuItem = new JMenuItem(Language
051: .getInstance().getText("Nouveau_test"));
052: newTestMenuItem.addActionListener(new ActionListener() {
053: public void actionPerformed(ActionEvent e) {
054: DataModel.addNewTest();
055: }
056: });
057: popup.add(newTestMenuItem);
058:
059: delTestMenuItem = new JMenuItem(Language.getInstance().getText(
060: "Supprimer"));
061: delTestMenuItem.addActionListener(new ActionListener() {
062: public void actionPerformed(ActionEvent e) {
063: DataModel.deleteInTestTree();
064: }
065: });
066: popup.add(delTestMenuItem);
067:
068: // V?rification des droits de l'utilisateur
069: if (!AdminProject.canDeleteTest()) {
070: delTestMenuItem.setEnabled(false);
071: }
072: if (!AdminProject.canCreateTest()) {
073: newFamilyMenuItem.setEnabled(false);
074: newTestMenuItem.setEnabled(false);
075: newListMenuItem.setEnabled(false);
076: }
077:
078: return popup;
079: } // Fin de la m?thode createTreePopUpForList
080:
081: /**
082: * M?thode qui cr?e un menu PopUp pour le clic droit de la souris sur
083: * l'arbre des campagnes
084: * @return un menu PopUp
085: */
086: public static JPopupMenu createTreePopUpForCampagne() {
087:
088: //Creation du menu PopUp de la table
089: JPopupMenu popup = new JPopupMenu();
090:
091: JMenuItem newMenuItem = new JMenuItem(Language.getInstance()
092: .getText("Nouvelle_campagne"));
093: newMenuItem.addActionListener(new ActionListener() {
094: public void actionPerformed(ActionEvent e) {
095: DataModel.addNewCampagne();
096: }
097: });
098: popup.add(newMenuItem);
099:
100: JMenuItem importMenuItem = new JMenuItem(Language.getInstance()
101: .getText("Importer"));
102: importMenuItem.setEnabled(false);
103: importMenuItem.addActionListener(new ActionListener() {
104: public void actionPerformed(ActionEvent e) {
105: DataModel.importTestsToCampaign();
106: }
107: });
108: importToCampMenuItem = importMenuItem;
109: popup.add(importMenuItem);
110:
111: delCampMenuItem = new JMenuItem(Language.getInstance().getText(
112: "Supprimer"));
113: delCampMenuItem.addActionListener(new ActionListener() {
114: public void actionPerformed(ActionEvent e) {
115: DataModel.deleteInCampaignTree();
116: }
117: });
118: popup.add(delCampMenuItem);
119:
120: // V?rification des droits
121: if (!AdminProject.canDeleteCamp()) {
122: delCampMenuItem.setEnabled(false);
123:
124: }
125: if (!AdminProject.canCreateCamp()) {
126: newMenuItem.setEnabled(false);
127: importMenuItem.setEnabled(false);
128: }
129:
130: return popup;
131: } // Fin de la m?thode createTreePopUpForCampagne/0
132:
133: public static JMenuItem getImportToCampMenuItem() {
134: return importToCampMenuItem;
135: }
136:
137: public static JMenuItem getDelTestMenuItem() {
138: return delTestMenuItem;
139: }
140:
141: public static JMenuItem getDelCampMenuItem() {
142: return delCampMenuItem;
143: }
144: }
|