Source Code Cross Referenced for SelectRequirement.java in  » Test-Coverage » salome-tmf » salomeTMF_plug » requirements » ihm » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Test Coverage » salome tmf » salomeTMF_plug.requirements.ihm 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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 Marche Mikael
020:         *
021:         * Contact: mikael.marche@rd.francetelecom.com
022:         */
023:
024:        package salomeTMF_plug.requirements.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.GraphicsConfiguration;
032:        import java.awt.GraphicsDevice;
033:        import java.awt.GraphicsEnvironment;
034:        import java.awt.GridLayout;
035:        import java.awt.Rectangle;
036:        import java.awt.event.ActionEvent;
037:        import java.awt.event.ActionListener;
038:        import java.awt.event.WindowEvent;
039:        import java.awt.event.WindowListener;
040:        import java.util.ArrayList;
041:        import java.util.Enumeration;
042:        import java.util.Hashtable;
043:        import java.util.Vector;
044:
045:        import javax.swing.BorderFactory;
046:        import javax.swing.Box;
047:        import javax.swing.BoxLayout;
048:        import javax.swing.JButton;
049:        import javax.swing.JDialog;
050:        import javax.swing.JList;
051:        import javax.swing.JPanel;
052:        import javax.swing.JScrollPane;
053:        import javax.swing.JTree;
054:        import javax.swing.tree.DefaultMutableTreeNode;
055:        import javax.swing.tree.TreeNode;
056:        import javax.swing.tree.TreePath;
057:
058:        import org.objectweb.salome_tmf.ihm.languages.Language;
059:        import org.objectweb.salome_tmf.ihm.main.SalomeTMFContext;
060:
061:        import salomeTMF_plug.requirements.ReqPlugin;
062:        import salomeTMF_plug.requirements.data.DataLoader;
063:        import salomeTMF_plug.requirements.data.IReqFilter;
064:        import salomeTMF_plug.requirements.data.ReqFamily;
065:        import salomeTMF_plug.requirements.data.ReqFilter;
066:        import salomeTMF_plug.requirements.data.ReqLeaf;
067:        import salomeTMF_plug.requirements.data.Requirement;
068:
069:        public class SelectRequirement extends JDialog implements 
070:                ActionListener, WindowListener {
071:
072:            JTree reqTree;
073:            //RequirementTree pRequirementTree; // Used for reload
074:            JList reqList;
075:            JButton removeButton;
076:            JButton addButton;
077:            JButton validateButton;
078:            JButton cancelButton;
079:            //JButton refreshReq;
080:            ArrayList reqSelectedNodes;
081:
082:            Hashtable reqSelected;
083:            FiltrePanel pFiltrePanel;
084:            InfoFiltrePanel pInfoFiltrePanel;
085:            CoverFiltrePanel pCoverFiltrePanel;
086:            IReqFilter pPriorityFilter;
087:            FilterReqTreeModel treeModel;
088:            Hashtable<Integer, Requirement> removedReq;
089:
090:            /**
091:             * 
092:             * @param _reqTree
093:             * @param title
094:             * @param usedReq
095:             * @param coverFiltre
096:             * @param _removedReq hashtable of requirement that can't be selected when add action is performed
097:             */
098:            public SelectRequirement(JTree _reqTree, String title,
099:                    Vector usedReq, boolean coverFiltre,
100:                    Hashtable<Integer, Requirement> _removedReq) {
101:                //RequirementTree _pRequirementTree){
102:                super (SalomeTMFContext.getInstance().getSalomeFrame());
103:
104:                int t_x = 1024 - 100;
105:                int t_y = 768 - 50;
106:                try {
107:                    GraphicsEnvironment ge = GraphicsEnvironment
108:                            .getLocalGraphicsEnvironment();
109:                    GraphicsDevice[] gs = ge.getScreenDevices();
110:                    GraphicsDevice gd = gs[0];
111:                    GraphicsConfiguration[] gc = gd.getConfigurations();
112:                    Rectangle r = gc[0].getBounds();
113:                    t_x = r.width - 100;
114:                    t_y = r.height - 50;
115:                } catch (Exception E) {
116:
117:                }
118:
119:                setResizable(false);
120:                setModal(true);
121:                reqTree = _reqTree;
122:                //pRequirementTree = _pRequirementTree;
123:                reqSelectedNodes = new ArrayList();
124:
125:                setDefaultCloseOperation(DISPOSE_ON_CLOSE);
126:                addWindowListener(this );
127:                removeButton = new JButton("<");
128:                removeButton.addActionListener(this );
129:
130:                addButton = new JButton(">");
131:                addButton.addActionListener(this );
132:
133:                /*
134:                refreshReq = new JButton(Language.getInstance().getText("Rafraichir") + " " + Language.getInstance().getText("Exigences"));
135:                refreshReq.addActionListener(this);
136:                refreshReq.setEnabled(true);
137:                 */
138:
139:                JPanel buttonSet = new JPanel();
140:                buttonSet.setLayout(new BoxLayout(buttonSet, BoxLayout.Y_AXIS));
141:                buttonSet.add(addButton);
142:                buttonSet.add(Box.createRigidArea(new Dimension(1, 25)));
143:                buttonSet.add(removeButton);
144:
145:                JPanel reqPanel = new JPanel(new BorderLayout());
146:
147:                pPriorityFilter = new ReqFilter(1007);
148:                reqTree.getModel().getRoot();
149:                treeModel = new FilterReqTreeModel(pPriorityFilter,
150:                        (TreeNode) reqTree.getModel().getRoot(), reqTree);
151:                reqTree.setModel(treeModel);
152:
153:                pFiltrePanel = new FiltrePanel(treeModel);
154:
155:                JPanel lesFiltresPanel = new JPanel(new GridLayout(2, 1));
156:                lesFiltresPanel.setBorder(BorderFactory.createTitledBorder(
157:                        BorderFactory.createLineBorder(Color.BLACK), "Filtre"));
158:
159:                JPanel filtresPanel1 = new JPanel(new GridLayout(2, 1));
160:                filtresPanel1.add(pFiltrePanel);
161:                if (coverFiltre) {
162:                    pCoverFiltrePanel = new CoverFiltrePanel(treeModel, null);
163:                    filtresPanel1.add(pCoverFiltrePanel);
164:                }
165:
166:                lesFiltresPanel.add(filtresPanel1);
167:                pInfoFiltrePanel = new InfoFiltrePanel(
168:                        (FilterReqTreeModel) reqTree.getModel(), null);
169:                lesFiltresPanel.add(pInfoFiltrePanel);
170:                /*JPanel buttonOptionPanel = new JPanel(new FlowLayout());
171:                buttonOptionPanel.add(refreshReq);
172:                lesFiltresPanel.add(buttonOptionPanel);*/
173:
174:                JScrollPane reqScrollPane = new JScrollPane(reqTree);
175:                reqScrollPane.setBorder(BorderFactory
176:                        .createTitledBorder(Language.getInstance().getText(
177:                                "Exigence_disponible")));
178:                reqScrollPane.setPreferredSize(new Dimension(t_x / 2 - 50,
179:                        t_y / 3 * 2 - 50));
180:                reqPanel.add(reqScrollPane, BorderLayout.CENTER);
181:                //reqPanel.add(pFiltrePanel, BorderLayout.SOUTH);
182:                reqPanel.add(lesFiltresPanel, BorderLayout.SOUTH);
183:
184:                if (_removedReq != null) {
185:                    removedReq = _removedReq;
186:                    //System.out.println("RemovedReq is not null, size = " + removedReq.size());
187:                } else {
188:                    removedReq = new Hashtable<Integer, Requirement>();
189:                }
190:
191:                reqList = new JList(usedReq);
192:                reqList.setCellRenderer(new PriorityListCellRenderer());
193:                reqSelected = new Hashtable();
194:                int size = usedReq.size();
195:                for (int i = 0; i < size; i++) {
196:                    Requirement pReq = (Requirement) usedReq.elementAt(i);
197:                    reqSelected.put(new Integer(pReq.getIdBdd()), pReq);
198:                }
199:                JScrollPane selectedScrollPane = new JScrollPane(reqList);
200:                selectedScrollPane.setBorder(BorderFactory
201:                        .createTitledBorder(Language.getInstance().getText(
202:                                "Exigence_selectionne")));
203:                selectedScrollPane.setPreferredSize(new Dimension(t_x / 2 - 50,
204:                        t_y / 3 * 2 - 50));
205:                selectedScrollPane.getViewport().setView(reqList);
206:
207:                JPanel windowPanel = new JPanel();
208:                windowPanel.setLayout(new BoxLayout(windowPanel,
209:                        BoxLayout.X_AXIS));
210:                //windowPanel.add(reqScrollPane);
211:                windowPanel.add(reqPanel);
212:                windowPanel.add(Box.createRigidArea(new Dimension(20, 50)));
213:                windowPanel.add(buttonSet);
214:                windowPanel.add(Box.createRigidArea(new Dimension(20, 50)));
215:                windowPanel.add(selectedScrollPane);
216:
217:                validateButton = new JButton(Language.getInstance().getText(
218:                        "Valider"));
219:                validateButton.addActionListener(this );
220:
221:                cancelButton = new JButton(Language.getInstance().getText(
222:                        "Annuler"));
223:                cancelButton.addActionListener(this );
224:
225:                JPanel secondButtonSet = new JPanel();
226:                secondButtonSet.add(validateButton);
227:                secondButtonSet.add(cancelButton);
228:
229:                JPanel center = new JPanel();
230:                center.add(windowPanel);
231:
232:                JPanel page = new JPanel();
233:                page.setLayout(new BoxLayout(page, BoxLayout.Y_AXIS));
234:                page.add(center);
235:                page.add(secondButtonSet);
236:
237:                Container contentPaneFrame = this .getContentPane();
238:                contentPaneFrame.add(page, BorderLayout.CENTER);
239:
240:                /* addWindowFocusListener(new java.awt.event.WindowFocusListener() {
241:                     public void windowGainedFocus(java.awt.event.WindowEvent evt) {
242:                     }
243:                     public void windowLostFocus(java.awt.event.WindowEvent evt) {
244:                         toFront();
245:                     }
246:                 });*/
247:                this .setTitle(title);
248:                //this.setLocation(300,200);
249:                this .setSize(t_x, t_y);
250:                //this.setLocation(50,50);
251:                /*this.setLocationRelativeTo(this.getParent()); 
252:                this.pack();
253:                this.setVisible(true);*/
254:                centerScreen();
255:
256:            }
257:
258:            void centerScreen() {
259:                Dimension dim = getToolkit().getScreenSize();
260:                this .pack();
261:                Rectangle abounds = getBounds();
262:                setLocation((dim.width - abounds.width) / 2,
263:                        (dim.height - abounds.height) / 2);
264:
265:                this .setVisible(true);
266:                requestFocus();
267:            }
268:
269:            /*void reloadData(){
270:            	pRequirementTree.copyIn(reqTree, true);
271:            	treeModel.reload();
272:            }*/
273:
274:            public void actionPerformed(ActionEvent e) {
275:                if (e.getSource().equals(removeButton)) {
276:                    removePerformed(e);
277:                } else if (e.getSource().equals(addButton)) {
278:                    addPerformed(e);
279:                } else if (e.getSource().equals(validateButton)) {
280:                    validatePerformed(e);
281:                } else if (e.getSource().equals(cancelButton)) {
282:                    cancelPerformed(e);
283:                }
284:                /*}  else if (e.getSource().equals(refreshReq)){
285:                	reloadData();
286:                }*/
287:            }
288:
289:            /**
290:             * Return true if pReq is fitred (appears in ReqTree)
291:             * @param pReq
292:             * @return
293:             */
294:
295:            void removePerformed(ActionEvent e) {
296:                Object[] selectedValue = reqList.getSelectedValues();
297:                for (int i = 0; i < selectedValue.length; i++) {
298:                    Requirement pReq = (Requirement) selectedValue[i];
299:                    reqSelected.remove(new Integer(pReq.getIdBdd()));
300:
301:                }
302:                Vector data = new Vector();
303:                reqList.clearSelection();
304:                Enumeration enumReq = reqSelected.elements();
305:                while (enumReq.hasMoreElements()) {
306:                    data.add(enumReq.nextElement());
307:                }
308:                reqList.setListData(data);
309:            }
310:
311:            void addPerformed(ActionEvent e) {
312:                TreePath[] pathTab = reqTree.getSelectionPaths();
313:                //DefaultTreeModel treeModel =(DefaultTreeModel) reqTree.getModel();
314:                if (pathTab != null) {
315:                    reqSelectedNodes.clear();
316:                    for (int i = 0; i < pathTab.length; i++) {
317:                        reqSelectedNodes.add(pathTab[i].getLastPathComponent());
318:                    }
319:                    int filtre = pFiltrePanel.getFiltre();
320:                    Vector data = new Vector();
321:                    for (int i = 0; i < reqSelectedNodes.size(); i++) {
322:                        Requirement pReq = (Requirement) ((DefaultMutableTreeNode) reqSelectedNodes
323:                                .get(i)).getUserObject();
324:                        if (pReq instanceof  ReqLeaf) {
325:                            if ((((ReqLeaf) pReq).getPriorityFromModel() & filtre) > 0) {
326:                                if (pPriorityFilter
327:                                        .isFiltredByInfo((ReqLeaf) pReq)) {
328:                                    if (removedReq.get(pReq.getIdBdd()) == null) {
329:                                        reqSelected.put(new Integer(pReq
330:                                                .getIdBdd()), pReq);
331:                                    }
332:                                }
333:                            }
334:                        } else {
335:                            ReqFamily pReqFamily = (ReqFamily) pReq;
336:                            //Vector listOfReq = pReqFamily.getFistLeaf();
337:                            Vector listOfReq = pReqFamily.getAllLeaf();
338:                            int size = listOfReq.size();
339:                            for (int j = 0; j < size; j++) {
340:                                Requirement pReq2 = (Requirement) listOfReq
341:                                        .elementAt(j);
342:                                if ((((ReqLeaf) pReq2).getPriorityFromModel() & filtre) > 0) {
343:                                    if (pPriorityFilter
344:                                            .isFiltredByInfo((ReqLeaf) pReq2)) {
345:                                        if (removedReq.get(pReq2.getIdBdd()) == null) {
346:                                            reqSelected.put(new Integer(pReq2
347:                                                    .getIdBdd()), pReq2);
348:                                        }
349:                                    }
350:                                }
351:                            }
352:                        }
353:                    }
354:                    reqList.clearSelection();
355:                    Enumeration enumReq = reqSelected.elements();
356:                    while (enumReq.hasMoreElements()) {
357:                        data.add(enumReq.nextElement());
358:                    }
359:                    reqList.setListData(data);
360:                }
361:            }
362:
363:            void validatePerformed(ActionEvent e) {
364:                dispose();
365:            }
366:
367:            void cancelPerformed(ActionEvent e) {
368:                reqSelected.clear();
369:                reqSelected = null;
370:                dispose();
371:            }
372:
373:            /*public void setVisible(boolean arg0) {
374:            	// TODO Auto-generated method stub
375:            	super.setVisible(arg0);
376:            	if (arg0 == true){
377:            		reqSelected = new Hashtable();
378:            	}
379:            }*/
380:
381:            public Hashtable getSelection() {
382:                return reqSelected;
383:            }
384:
385:            public void windowClosing(WindowEvent e) {
386:                reqSelected.clear();
387:                reqSelected = null;
388:            }
389:
390:            public void windowDeiconified(WindowEvent e) {
391:            }
392:
393:            public void windowOpened(WindowEvent e) {
394:            }
395:
396:            public void windowActivated(WindowEvent e) {
397:            }
398:
399:            public void windowDeactivated(WindowEvent e) {
400:            }
401:
402:            public void windowClosed(WindowEvent e) {
403:            }
404:
405:            public void windowIconified(WindowEvent e) {
406:            }
407:
408:            /*class MyCellReqRenderer extends JLabel implements ListCellRenderer {
409:            	ImageIcon ReqFamIcon = createImageIcon("/salomeTMF_plug/requirements/resources/images/reqFam.png");
410:            	ImageIcon ReqLeafIncon =createImageIcon("/salomeTMF_plug/requirements/resources/images/req.png");
411:            	
412:                // This is the only method defined by ListCellRenderer.
413:                // We just reconfigure the JLabel each time we're called.
414:
415:                public Component getListCellRendererComponent(
416:                  JList list,
417:                  Object value,            // value to display
418:                  int index,               // cell index
419:                  boolean isSelected,      // is the cell selected
420:                  boolean cellHasFocus)    // the list and the cell have the focus
421:                {
422:                    String s = value.toString();
423:                    setText(s);
424:                    setIcon((s.length() > 10) ? longIcon : shortIcon);
425:              	   if (isSelected) {
426:                        setBackground(list.getSelectionBackground());
427:                   setForeground(list.getSelectionForeground());
428:               }
429:                    else {
430:                   setBackground(list.getBackground());
431:                   setForeground(list.getForeground());
432:               }
433:               setEnabled(list.isEnabled());
434:               setFont(list.getFont());
435:                    setOpaque(true);
436:                    return this;
437:                }
438:            }*/
439:
440:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.