Source Code Cross Referenced for SalomeLocksPanel.java in  » Test-Coverage » salome-tmf » org » objectweb » salome_tmf » ihm » main » 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 » org.objectweb.salome_tmf.ihm.main 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.objectweb.salome_tmf.ihm.main;
002:
003:        import java.awt.BorderLayout;
004:        import java.awt.Dimension;
005:        import java.awt.FlowLayout;
006:        import java.awt.Font;
007:        import java.awt.event.ActionEvent;
008:        import java.awt.event.ActionListener;
009:        import java.util.Vector;
010:
011:        import javax.swing.BorderFactory;
012:        import javax.swing.JButton;
013:        import javax.swing.JLabel;
014:        import javax.swing.JPanel;
015:        import javax.swing.JScrollPane;
016:        import javax.swing.JTable;
017:
018:        import org.objectweb.salome_tmf.api.Api;
019:        import org.objectweb.salome_tmf.api.data.ExecutionAttachmentWrapper;
020:        import org.objectweb.salome_tmf.api.data.LockInfoWrapper;
021:        import org.objectweb.salome_tmf.api.sql.ISQLPersonne;
022:        import org.objectweb.salome_tmf.api.sql.ISQLSalomeLock;
023:        import org.objectweb.salome_tmf.ihm.languages.Language;
024:        import org.objectweb.salome_tmf.ihm.models.MyTableModel;
025:
026:        public class SalomeLocksPanel extends JPanel implements  ActionListener {
027:
028:            JTable locksTable;
029:
030:            MyTableModel locksTableModel;
031:
032:            JButton deletelockButton;
033:            JButton deleteAlllocksButton;
034:            JButton refreshlocksButton;
035:
036:            ISQLSalomeLock pSQLlock;
037:            ISQLPersonne pSQLPersone;
038:
039:            Vector locksVector;
040:
041:            int project_id = -1;
042:
043:            public SalomeLocksPanel(int project_id) {
044:                super (new BorderLayout());
045:                this .project_id = project_id;
046:                initComponent();
047:            }
048:
049:            void initComponent() {
050:                locksTableModel = new MyTableModel();
051:                locksTable = new JTable();
052:
053:                deletelockButton = new JButton(Language.getInstance().getText(
054:                        "Supprimer"));
055:                deletelockButton.addActionListener(this );
056:
057:                deleteAlllocksButton = new JButton(Language.getInstance()
058:                        .getText("Supprimer_tous_les_locks"));
059:                deleteAlllocksButton.addActionListener(this );
060:
061:                refreshlocksButton = new JButton(Language.getInstance()
062:                        .getText("Actualiser"));
063:                refreshlocksButton.addActionListener(this );
064:
065:                locksTableModel.addColumnNameAndColumn("PID");
066:                locksTableModel.addColumnNameAndColumn(Language.getInstance()
067:                        .getText("Login"));
068:                locksTableModel.addColumnNameAndColumn(Language.getInstance()
069:                        .getText("Lock_Type"));
070:                locksTableModel.addColumnNameAndColumn(Language.getInstance()
071:                        .getText("Action_Code"));
072:                locksTableModel.addColumnNameAndColumn(Language.getInstance()
073:                        .getText("Date"));
074:
075:                locksTable.setModel(locksTableModel);
076:
077:                locksTable.setPreferredScrollableViewportSize(new Dimension(
078:                        500, 200));
079:                JScrollPane tablePane = new JScrollPane(locksTable);
080:
081:                JPanel buttonSet = new JPanel(new FlowLayout());
082:                buttonSet.setAlignmentY(FlowLayout.LEFT);
083:                buttonSet.add(refreshlocksButton);
084:                buttonSet.add(deletelockButton);
085:                buttonSet.add(deleteAlllocksButton);
086:                buttonSet.setBorder(BorderFactory.createRaisedBevelBorder());
087:
088:                JLabel locksTableLabel = new JLabel(Language.getInstance()
089:                        .getText("Liste_des_locks_existantes"));
090:                locksTableLabel.setFont(new Font(null, Font.BOLD, 20));
091:                locksTableLabel.setSize(300, 60);
092:
093:                JLabel noteLabel = new JLabel(Language.getInstance().getText(
094:                        "locks_types_precisions"));
095:                Language.getInstance().getText("Liste_des_locks_existantes");
096:                JPanel notePanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
097:                notePanel.add(noteLabel);
098:
099:                JPanel center = new JPanel(new BorderLayout());
100:                center.add(BorderLayout.NORTH, locksTableLabel);
101:                center.add(BorderLayout.CENTER, tablePane);
102:                center.add(notePanel, BorderLayout.SOUTH);
103:                center.setBorder(BorderFactory
104:                        .createEmptyBorder(20, 10, 10, 10));
105:                this .add(BorderLayout.NORTH, buttonSet);
106:                this .add(BorderLayout.CENTER, center);
107:                pSQLlock = Api.getISQLObjectFactory().getISQLSalomeLock();
108:                pSQLPersone = Api.getISQLObjectFactory().getISQLPersonne();
109:            }
110:
111:            public void loadDataFromDB() {
112:                //On crée une instance pour les méthodes de sélection
113:                //pISQLlock = Api.getISQLObjectFactory().getISQLSalomeLock();
114:                if (pSQLlock != null) {
115:                    refreshData();
116:                }
117:            }
118:
119:            public void actionPerformed(ActionEvent e) {
120:                if (e.getSource().equals(deletelockButton)) {
121:                    try {
122:                        int selectedRow = locksTable.getSelectedRow();
123:                        if (selectedRow != -1) {
124:                            Integer value = (Integer) locksTableModel
125:                                    .getValueAt(selectedRow, 0);
126:                            deleteLock(value.intValue());
127:                        }
128:                    } catch (Exception ex) {
129:                    }
130:
131:                } else if (e.getSource().equals(deleteAlllocksButton)) {
132:                    deleteAllSession();
133:                } else if (e.getSource().equals(refreshlocksButton)) {
134:                    refreshData();
135:                }
136:            }
137:
138:            void deleteLock(int pid) {
139:                try {
140:                    if (pSQLlock != null) {
141:                        pSQLlock.delete(project_id, pid);
142:                        refreshData();
143:                    }
144:                } catch (Exception e) {
145:                }
146:
147:            }
148:
149:            void deleteAllSession() {
150:                try {
151:                    if (pSQLlock != null) {
152:                        pSQLlock.delete(project_id);
153:                        refreshData();
154:                    }
155:                } catch (Exception e) {
156:                }
157:            }
158:
159:            void refreshData() {
160:                try {
161:                    LockInfoWrapper[] tmpArray = pSQLlock
162:                            .getAllProjectLocks(project_id);
163:                    Vector tmpVector = new Vector();
164:                    for (int i = 0; i < tmpArray.length; i++) {
165:                        tmpVector.add(tmpArray[i]);
166:                    }
167:                    locksVector = tmpVector;
168:                    locksTableModel.clearTable();
169:                    int nbData = locksVector.size();
170:                    for (int i = 0; i < nbData; i++) {
171:                        LockInfoWrapper pLockInfo = (LockInfoWrapper) locksVector
172:                                .elementAt(i);
173:
174:                        int lock_type = pLockInfo.getLock_code();
175:                        int test = lock_type / 100;
176:                        if (test == 1)
177:                            lock_type -= 100;
178:                        int camp = lock_type / 10;
179:                        if (camp == 1)
180:                            lock_type -= 10;
181:                        int data = lock_type;
182:                        String lockTypeStr = new String("[T=" + test + ", C="
183:                                + camp + ", D=" + data + "]");
184:
185:                        String login = "unknow";
186:                        if (pSQLPersone != null) {
187:                            login = pSQLPersone.getLogin(pLockInfo
188:                                    .getPersonne_id());
189:                        }
190:                        locksTableModel.addValueAt(new Integer(pLockInfo
191:                                .getPid()), i, 0);
192:                        locksTableModel.addValueAt(login, i, 1);
193:                        locksTableModel.addValueAt(lockTypeStr, i, 2);
194:                        locksTableModel.addValueAt(new Integer(pLockInfo
195:                                .getAction_code()), i, 3);
196:                        locksTableModel.addValueAt(pLockInfo.getLockdate(), i,
197:                                4);
198:                    }
199:                } catch (Exception ex) {
200:                    ex.printStackTrace();
201:                }
202:            }
203:
204:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.